-
Notifications
You must be signed in to change notification settings - Fork 234
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
chore: Initial code to generate ts code from Noir ABI #2750
Merged
kevaundray
merged 6 commits into
feature_branch/private-kernel
from
kw/initial-abi-generator
Oct 10, 2023
Merged
chore: Initial code to generate ts code from Noir ABI #2750
kevaundray
merged 6 commits into
feature_branch/private-kernel
from
kw/initial-abi-generator
Oct 10, 2023
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For private kernel init, this generates: // Type aliases needed for Noir primitives
type Field = number;
type u32 = number;
interface Address {
inner: Field;
}
interface Point {
x: Field;
y: Field;
}
interface EthAddress {
inner: Field;
}
interface ContractDeploymentData {
deployer_public_key: Point;
constructor_vk_hash: Field;
function_tree_root: Field;
contract_address_salt: Field;
portal_contract_address: EthAddress;
}
interface TxContext {
is_fee_payment_tx: boolean;
is_rebate_payment_tx: boolean;
is_contract_deployment_tx: boolean;
contract_deployment_data: ContractDeploymentData;
chain_id: Field;
version: Field;
}
interface FunctionSelector {
inner: u32;
}
interface FunctionData {
selector: FunctionSelector;
is_internal: boolean;
is_private: boolean;
is_constructor: boolean;
}
interface TxRequest {
origin: Address;
args_hash: Field;
tx_context: TxContext;
function_data: FunctionData;
}
interface CallContext {
msg_sender: Address;
storage_contract_address: Address;
portal_contract_address: EthAddress;
function_selector: FunctionSelector;
is_delegate_call: boolean;
is_static_call: boolean;
is_contract_deployment: boolean;
}
interface Block {
private_data_tree_root: Field;
nullifier_tree_root: Field;
contract_tree_root: Field;
l1_to_l2_data_tree_root: Field;
public_data_tree_root: Field;
global_variables_hash: Field;
}
interface HistoricalBlockData {
blocks_tree_root: Field;
block: Block;
private_kernel_vk_tree_root: Field;
}
interface PrivateCircuitPublicInputs {
call_context: CallContext;
args_hash: Field;
return_values: Field[];
read_requests: Field[];
new_commitments: Field[];
new_nullifiers: Field[];
nullified_commitments: Field[];
private_call_stack: Field[];
public_call_stack: Field[];
new_l2_to_l1_msgs: Field[];
encrypted_logs_hash: Field[];
unencrypted_logs_hash: Field[];
encrypted_log_preimages_length: Field;
unencrypted_log_preimages_length: Field;
historical_block_data: HistoricalBlockData;
contract_deployment_data: ContractDeploymentData;
chain_id: Field;
version: Field;
}
interface CallStackItem {
contract_address: Address;
public_inputs: PrivateCircuitPublicInputs;
is_execution_request: boolean;
function_data: FunctionData;
}
interface PrivateCallStackItem {
inner: CallStackItem;
}
interface Proof {
}
interface VerificationKey {
}
interface MembershipWitness {
leaf_index: Field;
sibling_path: Field[];
}
interface ReadRequestMembershipWitness {
leaf_index: Field;
sibling_path: Field[];
is_transient: boolean;
hint_to_commitment: Field;
}
interface PrivateCallData {
call_stack_item: PrivateCallStackItem;
private_call_stack_preimages: PrivateCallStackItem[];
proof: Proof;
vk: VerificationKey;
function_leaf_membership_witness: MembershipWitness;
contract_leaf_membership_witness: MembershipWitness;
read_request_membership_witnesses: ReadRequestMembershipWitness[];
portal_contract_address: EthAddress;
acir_hash: Field;
}
interface PrivateKernelInputsInit {
tx_request: TxRequest;
private_call: PrivateCallData;
}
interface AggregationObject {
}
interface NewContractData {
contract_address: Address;
portal_contract_address: EthAddress;
function_tree_root: Field;
}
interface OptionallyRevealedData {
call_stack_item_hash: Field;
function_data: FunctionData;
vk_hash: Field;
portal_contract_address: EthAddress;
pay_fee_from_l1: boolean;
pay_fee_from_public_l2: boolean;
called_from_l1: boolean;
called_from_public_l2: boolean;
}
interface PublicDataUpdateRequest {
leaf_index: Field;
old_value: Field;
new_value: Field;
}
interface PublicDataRead {
leaf_index: Field;
value: Field;
}
interface CombinedAccumulatedData {
aggregation_object: AggregationObject;
read_requests: Field[];
new_commitments: Field[];
new_nullifiers: Field[];
nullified_commitments: Field[];
private_call_stack: Field[];
public_call_stack: Field[];
new_l2_to_l1_msgs: Field[];
encrypted_logs_hash: Field[];
unencrypted_logs_hash: Field[];
encrypted_log_preimages_length: Field;
unencrypted_log_preimages_length: Field;
new_contracts: NewContractData[];
optionally_revealed_data: OptionallyRevealedData[];
public_data_update_requests: PublicDataUpdateRequest[];
public_data_reads: PublicDataRead[];
}
interface CombinedConstantData {
block_data: HistoricalBlockData;
tx_context: TxContext;
}
interface KernelCircuitPublicInputs {
end: CombinedAccumulatedData;
constants: CombinedConstantData;
is_private: boolean;
}
export interface ReturnType {
value: KernelCircuitPublicInputs;
}
export interface InputType {
input: PrivateKernelInputsInit;
}
export function execute(input: InputType): ReturnType {
throw Error('Add execute function logic here')
} |
Last three structs are the most important, ReturnType may need to be changed to a type alias:
|
kevaundray
merged commit Oct 10, 2023
71d543a
into
feature_branch/private-kernel
79 of 80 checks passed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This is some rough code to generate typescript bindings for a given abi.json
Checklist:
Remove the checklist to signal you've completed it. Enable auto-merge if the PR is ready to merge.