@aztec/aztec.js 3.0.0-canary.a9708bd → 3.0.0-devnet.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/account/account.d.ts +60 -0
- package/dest/account/account.d.ts.map +1 -0
- package/dest/account/account.js +59 -0
- package/dest/account/account_contract.d.ts +5 -5
- package/dest/account/account_contract.d.ts.map +1 -1
- package/dest/account/account_contract.js +0 -1
- package/dest/{wallet/account_wallet_with_private_key.d.ts → account/account_with_secret_key.d.ts} +7 -8
- package/dest/account/account_with_secret_key.d.ts.map +1 -0
- package/dest/{wallet/account_wallet_with_private_key.js → account/account_with_secret_key.js} +5 -5
- package/dest/account/index.d.ts +1 -4
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +1 -4
- package/dest/account/signerless_account.d.ts +24 -0
- package/dest/account/signerless_account.d.ts.map +1 -0
- package/dest/account/signerless_account.js +27 -0
- package/dest/api/abi.d.ts +1 -0
- package/dest/api/abi.d.ts.map +1 -1
- package/dest/api/account.d.ts +4 -2
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +3 -1
- package/dest/api/addresses.d.ts +1 -0
- package/dest/api/addresses.d.ts.map +1 -1
- package/dest/api/addresses.js +1 -0
- package/dest/api/authorization.d.ts +2 -0
- package/dest/api/authorization.d.ts.map +1 -1
- package/dest/api/authorization.js +2 -0
- package/dest/api/block.d.ts +3 -0
- package/dest/api/block.d.ts.map +1 -0
- package/dest/api/block.js +2 -0
- package/dest/api/contract.d.ts +4 -5
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +3 -3
- package/dest/api/crypto.d.ts +2 -0
- package/dest/api/crypto.d.ts.map +1 -0
- package/dest/api/crypto.js +1 -0
- package/dest/api/ethereum.d.ts +0 -1
- package/dest/api/ethereum.d.ts.map +1 -1
- package/dest/api/ethereum.js +0 -1
- package/dest/api/events.d.ts +12 -0
- package/dest/api/events.d.ts.map +1 -0
- package/dest/api/events.js +30 -0
- package/dest/api/fee.d.ts +1 -2
- package/dest/api/fee.d.ts.map +1 -1
- package/dest/api/fee.js +0 -1
- package/dest/api/keys.d.ts +4 -0
- package/dest/api/keys.d.ts.map +1 -0
- package/dest/api/keys.js +3 -0
- package/dest/api/log.d.ts +1 -0
- package/dest/api/log.d.ts.map +1 -1
- package/dest/api/log.js +1 -0
- package/dest/api/messaging.d.ts +3 -0
- package/dest/api/messaging.d.ts.map +1 -0
- package/dest/api/messaging.js +2 -0
- package/dest/api/node.d.ts +21 -0
- package/dest/api/node.d.ts.map +1 -0
- package/dest/api/node.js +18 -0
- package/dest/api/note.d.ts +2 -0
- package/dest/api/note.d.ts.map +1 -0
- package/dest/api/note.js +1 -0
- package/dest/api/protocol.d.ts +3 -0
- package/dest/api/protocol.d.ts.map +1 -0
- package/dest/api/protocol.js +2 -0
- package/dest/api/trees.d.ts +3 -0
- package/dest/api/trees.d.ts.map +1 -0
- package/dest/api/trees.js +2 -0
- package/dest/api/tx.d.ts +2 -0
- package/dest/api/tx.d.ts.map +1 -0
- package/dest/api/tx.js +1 -0
- package/dest/api/utils.d.ts +10 -6
- package/dest/api/utils.d.ts.map +1 -1
- package/dest/api/utils.js +10 -5
- package/dest/api/wallet.d.ts +4 -1
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +4 -1
- package/dest/contract/base_contract_interaction.d.ts +6 -48
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +6 -106
- package/dest/contract/batch_call.d.ts +6 -14
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +42 -52
- package/dest/contract/contract.d.ts +1 -1
- package/dest/contract/contract.d.ts.map +1 -1
- package/dest/contract/contract.js +2 -12
- package/dest/contract/contract_base.d.ts +1 -1
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.d.ts +29 -40
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +41 -53
- package/dest/contract/deploy_method.d.ts +63 -56
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +68 -86
- package/dest/contract/deploy_sent_tx.d.ts +0 -1
- package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
- package/dest/contract/deploy_sent_tx.js +7 -10
- package/dest/contract/interaction_options.d.ts +74 -19
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +51 -3
- package/dest/contract/sent_tx.d.ts +3 -3
- package/dest/contract/sent_tx.d.ts.map +1 -1
- package/dest/contract/sent_tx.js +5 -5
- package/dest/contract/wait_for_proven.d.ts +3 -3
- package/dest/contract/wait_for_proven.d.ts.map +1 -1
- package/dest/contract/wait_for_proven.js +2 -2
- package/dest/deployment/publish_instance.d.ts +1 -1
- package/dest/deployment/publish_instance.d.ts.map +1 -1
- package/dest/deployment/publish_instance.js +2 -5
- package/dest/ethereum/portal_manager.d.ts +3 -4
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +3 -5
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts +12 -7
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
- package/dest/fee/fee_juice_payment_method_with_claim.js +21 -12
- package/dest/fee/fee_payment_method.d.ts +26 -0
- package/dest/fee/fee_payment_method.d.ts.map +1 -0
- package/dest/fee/fee_payment_method.js +3 -0
- package/dest/fee/private_fee_payment_method.d.ts +22 -5
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +34 -13
- package/dest/fee/public_fee_payment_method.d.ts +22 -5
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +37 -14
- package/dest/fee/sponsored_fee_payment.d.ts +2 -0
- package/dest/fee/sponsored_fee_payment.d.ts.map +1 -1
- package/dest/fee/sponsored_fee_payment.js +4 -0
- package/dest/utils/authwit.d.ts +77 -25
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +219 -24
- package/dest/utils/cross_chain.d.ts +24 -0
- package/dest/utils/cross_chain.d.ts.map +1 -0
- package/dest/utils/cross_chain.js +30 -0
- package/dest/utils/fee_juice.d.ts +3 -2
- package/dest/utils/fee_juice.d.ts.map +1 -1
- package/dest/utils/fee_juice.js +3 -2
- package/dest/{fee → wallet}/account_entrypoint_meta_payment_method.d.ts +13 -10
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -0
- package/dest/wallet/account_entrypoint_meta_payment_method.js +76 -0
- package/dest/wallet/account_manager.d.ts +69 -0
- package/dest/wallet/account_manager.d.ts.map +1 -0
- package/dest/wallet/account_manager.js +113 -0
- package/dest/wallet/base_wallet.d.ts +78 -35
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +216 -48
- package/dest/wallet/deploy_account_method.d.ts +52 -0
- package/dest/wallet/deploy_account_method.d.ts.map +1 -0
- package/dest/wallet/deploy_account_method.js +77 -0
- package/dest/wallet/index.d.ts +2 -15
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +2 -19
- package/dest/wallet/wallet.d.ts +2473 -6
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +202 -3
- package/package.json +25 -21
- package/src/account/account.ts +97 -0
- package/src/account/account_contract.ts +4 -6
- package/src/{wallet/account_wallet_with_private_key.ts → account/account_with_secret_key.ts} +6 -8
- package/src/account/index.ts +1 -4
- package/src/account/signerless_account.ts +46 -0
- package/src/api/abi.ts +11 -0
- package/src/api/account.ts +4 -2
- package/src/api/addresses.ts +1 -0
- package/src/api/authorization.ts +11 -0
- package/src/api/block.ts +2 -0
- package/src/api/contract.ts +16 -8
- package/src/api/crypto.ts +1 -0
- package/src/api/ethereum.ts +0 -1
- package/src/api/events.ts +44 -0
- package/src/api/fee.ts +1 -2
- package/src/api/keys.ts +8 -0
- package/src/api/log.ts +1 -0
- package/src/api/messaging.ts +2 -0
- package/src/api/node.ts +20 -0
- package/src/api/note.ts +1 -0
- package/src/api/protocol.ts +2 -0
- package/src/api/trees.ts +2 -0
- package/src/api/tx.ts +11 -0
- package/src/api/utils.ts +12 -19
- package/src/api/wallet.ts +33 -5
- package/src/contract/base_contract_interaction.ts +9 -138
- package/src/contract/batch_call.ts +52 -61
- package/src/contract/contract.ts +2 -12
- package/src/contract/contract_function_interaction.ts +65 -97
- package/src/contract/deploy_method.ts +117 -99
- package/src/contract/deploy_sent_tx.ts +4 -10
- package/src/contract/interaction_options.ts +126 -24
- package/src/contract/sent_tx.ts +4 -4
- package/src/contract/wait_for_proven.ts +4 -4
- package/src/deployment/publish_instance.ts +3 -8
- package/src/ethereum/portal_manager.ts +4 -12
- package/src/fee/fee_juice_payment_method_with_claim.ts +26 -17
- package/src/fee/fee_payment_method.ts +26 -0
- package/src/fee/private_fee_payment_method.ts +60 -41
- package/src/fee/public_fee_payment_method.ts +73 -49
- package/src/fee/sponsored_fee_payment.ts +6 -0
- package/src/utils/authwit.ts +250 -38
- package/src/utils/cross_chain.ts +53 -0
- package/src/utils/fee_juice.ts +4 -3
- package/src/wallet/account_entrypoint_meta_payment_method.ts +105 -0
- package/src/wallet/account_manager.ts +154 -0
- package/src/wallet/base_wallet.ts +287 -78
- package/src/wallet/deploy_account_method.ts +125 -0
- package/src/wallet/index.ts +2 -32
- package/src/wallet/wallet.ts +357 -29
- package/dest/account_manager/account_manager.d.ts +0 -119
- package/dest/account_manager/account_manager.d.ts.map +0 -1
- package/dest/account_manager/account_manager.js +0 -202
- package/dest/account_manager/deploy_account_sent_tx.d.ts +0 -30
- package/dest/account_manager/deploy_account_sent_tx.d.ts.map +0 -1
- package/dest/account_manager/deploy_account_sent_tx.js +0 -29
- package/dest/account_manager/index.d.ts +0 -3
- package/dest/account_manager/index.d.ts.map +0 -1
- package/dest/account_manager/index.js +0 -2
- package/dest/api/interfaces.d.ts +0 -2
- package/dest/api/interfaces.d.ts.map +0 -1
- package/dest/api/interfaces.js +0 -1
- package/dest/api/log_id.d.ts +0 -2
- package/dest/api/log_id.d.ts.map +0 -1
- package/dest/api/log_id.js +0 -1
- package/dest/api/rpc.d.ts +0 -3
- package/dest/api/rpc.d.ts.map +0 -1
- package/dest/api/rpc.js +0 -2
- package/dest/api/tx_hash.d.ts +0 -2
- package/dest/api/tx_hash.d.ts.map +0 -1
- package/dest/api/tx_hash.js +0 -1
- package/dest/contract/deploy_proven_tx.d.ts +0 -21
- package/dest/contract/deploy_proven_tx.d.ts.map +0 -1
- package/dest/contract/deploy_proven_tx.js +0 -21
- package/dest/contract/proven_tx.d.ts +0 -21
- package/dest/contract/proven_tx.d.ts.map +0 -1
- package/dest/contract/proven_tx.js +0 -23
- package/dest/ethereum/l1_contracts.d.ts +0 -3
- package/dest/ethereum/l1_contracts.d.ts.map +0 -1
- package/dest/ethereum/l1_contracts.js +0 -13
- package/dest/fee/account_entrypoint_meta_payment_method.d.ts.map +0 -1
- package/dest/fee/account_entrypoint_meta_payment_method.js +0 -64
- package/dest/fee/fee_juice_payment_method.d.ts +0 -14
- package/dest/fee/fee_juice_payment_method.d.ts.map +0 -1
- package/dest/fee/fee_juice_payment_method.js +0 -21
- package/dest/fee/utils.d.ts +0 -13
- package/dest/fee/utils.d.ts.map +0 -1
- package/dest/fee/utils.js +0 -32
- package/dest/index.d.ts +0 -59
- package/dest/index.d.ts.map +0 -1
- package/dest/index.js +0 -62
- package/dest/rpc_clients/node/index.d.ts +0 -12
- package/dest/rpc_clients/node/index.d.ts.map +0 -1
- package/dest/rpc_clients/node/index.js +0 -72
- package/dest/rpc_clients/pxe_client.d.ts +0 -10
- package/dest/rpc_clients/pxe_client.d.ts.map +0 -1
- package/dest/rpc_clients/pxe_client.js +0 -23
- package/dest/utils/pxe.d.ts +0 -4
- package/dest/utils/pxe.d.ts.map +0 -1
- package/dest/utils/pxe.js +0 -14
- package/dest/wallet/account_wallet.d.ts +0 -74
- package/dest/wallet/account_wallet.d.ts.map +0 -1
- package/dest/wallet/account_wallet.js +0 -232
- package/dest/wallet/account_wallet_with_private_key.d.ts.map +0 -1
- package/dest/wallet/signerless_wallet.d.ts +0 -23
- package/dest/wallet/signerless_wallet.d.ts.map +0 -1
- package/dest/wallet/signerless_wallet.js +0 -33
- package/src/account_manager/account_manager.ts +0 -276
- package/src/account_manager/deploy_account_sent_tx.ts +0 -46
- package/src/account_manager/index.ts +0 -2
- package/src/api/interfaces.ts +0 -1
- package/src/api/log_id.ts +0 -1
- package/src/api/rpc.ts +0 -2
- package/src/api/tx_hash.ts +0 -1
- package/src/contract/deploy_proven_tx.ts +0 -45
- package/src/contract/proven_tx.ts +0 -36
- package/src/ethereum/l1_contracts.ts +0 -21
- package/src/fee/account_entrypoint_meta_payment_method.ts +0 -89
- package/src/fee/fee_juice_payment_method.ts +0 -25
- package/src/fee/utils.ts +0 -39
- package/src/index.ts +0 -85
- package/src/rpc_clients/node/index.ts +0 -77
- package/src/rpc_clients/pxe_client.ts +0 -25
- package/src/utils/pxe.ts +0 -17
- package/src/wallet/account_wallet.ts +0 -246
- package/src/wallet/signerless_wallet.ts +0 -56
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import { mergeExecutionPayloads } from '@aztec/entrypoints/payload';
|
|
2
|
+
import { Fr } from '@aztec/foundation/fields';
|
|
2
3
|
import { getInitializer } from '@aztec/stdlib/abi';
|
|
3
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
5
|
import { computePartialAddress, getContractClassFromArtifact, getContractInstanceFromInstantiationParams } from '@aztec/stdlib/contract';
|
|
6
|
+
import { collectOffchainEffects } from '@aztec/stdlib/tx';
|
|
5
7
|
import { publishContractClass } from '../deployment/publish_class.js';
|
|
6
8
|
import { publishInstance } from '../deployment/publish_instance.js';
|
|
7
9
|
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
8
10
|
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
9
|
-
import { DeployProvenTx } from './deploy_proven_tx.js';
|
|
10
11
|
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
import { getGasLimits } from './get_gas_limits.js';
|
|
13
|
+
import { toProfileOptions, toSendOptions, toSimulateOptions } from './interaction_options.js';
|
|
13
14
|
/**
|
|
14
15
|
* Contract interaction for deployment.
|
|
15
16
|
* Handles class publication, instance publication, and initialization of the contract.
|
|
@@ -33,82 +34,39 @@ import { DeploySentTx } from './deploy_sent_tx.js';
|
|
|
33
34
|
this.constructorArtifact = getInitializer(artifact, constructorNameOrArtifact);
|
|
34
35
|
}
|
|
35
36
|
/**
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* - Initialize the contract
|
|
40
|
-
*
|
|
41
|
-
* A tx is not necessary if the function has no public functions nor any
|
|
42
|
-
* initializer function.
|
|
43
|
-
*
|
|
44
|
-
* This function internally calls `request()` and `sign()` methods to prepare
|
|
45
|
-
* the transaction for deployment. The resulting signed transaction can be
|
|
46
|
-
* later sent using the `send()` method.
|
|
47
|
-
*
|
|
48
|
-
* @param options - An object containing optional deployment settings, contractAddressSalt, and from.
|
|
49
|
-
* @returns A Promise resolving to an object containing the signed transaction data and other relevant information.
|
|
50
|
-
*/ async create(options) {
|
|
51
|
-
const requestWithoutFee = await this.request(options);
|
|
52
|
-
const { fee: userFee, txNonce, cancellable } = options;
|
|
53
|
-
const fee = await this.getFeeOptions(requestWithoutFee, userFee, {
|
|
54
|
-
txNonce,
|
|
55
|
-
cancellable
|
|
56
|
-
});
|
|
57
|
-
return this.wallet.createTxExecutionRequest(requestWithoutFee, fee, {
|
|
58
|
-
txNonce,
|
|
59
|
-
cancellable
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
// REFACTOR: Having a `request` method with different semantics than the ones in the other
|
|
63
|
-
// derived ContractInteractions is confusing. We should unify the flow of all ContractInteractions.
|
|
64
|
-
/**
|
|
65
|
-
* Returns an array of function calls that represent this operation. Useful as a building
|
|
66
|
-
* block for constructing batch requests.
|
|
67
|
-
* @param options - Deployment options.
|
|
68
|
-
* @returns An array of function calls.
|
|
69
|
-
* @remarks This method does not have the same return type as the `request` in the ContractInteraction object,
|
|
70
|
-
* it returns a promise for an array instead of a function call directly.
|
|
37
|
+
* Returns the execution payload that allows this operation to happen on chain.
|
|
38
|
+
* @param options - Configuration options.
|
|
39
|
+
* @returns The execution payload for this operation
|
|
71
40
|
*/ async request(options) {
|
|
72
41
|
const publication = await this.getPublicationExecutionPayload(options);
|
|
73
|
-
|
|
74
|
-
// Note that we need to run this registerContract here so it's available when computeFeeOptionsFromEstimatedGas
|
|
75
|
-
// runs, since it needs the contract to have been registered in order to estimate gas for its initialization,
|
|
76
|
-
// in case the initializer is public. This hints at the need of having "transient" contracts scoped to a
|
|
77
|
-
// simulation, so we can run the simulation with a set of contracts, but only "commit" them to the wallet
|
|
78
|
-
// once this tx has gone through.
|
|
79
|
-
await this.wallet.registerContract({
|
|
80
|
-
artifact: this.artifact,
|
|
81
|
-
instance: await this.getInstance(options)
|
|
82
|
-
});
|
|
42
|
+
await this.wallet.registerContract(await this.getInstance(options), this.artifact);
|
|
83
43
|
const initialization = await this.getInitializationExecutionPayload(options);
|
|
84
|
-
const
|
|
44
|
+
const feeExecutionPayload = options?.fee?.paymentMethod ? await options.fee.paymentMethod.getExecutionPayload() : undefined;
|
|
45
|
+
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
46
|
+
feeExecutionPayload,
|
|
47
|
+
publication,
|
|
48
|
+
initialization
|
|
49
|
+
]) : mergeExecutionPayloads([
|
|
85
50
|
publication,
|
|
86
51
|
initialization
|
|
87
|
-
];
|
|
88
|
-
|
|
89
|
-
if (!fnCalls.length) {
|
|
52
|
+
]);
|
|
53
|
+
if (!finalExecutionPayload.calls.length) {
|
|
90
54
|
throw new Error(`No transactions are needed to publish or initialize contract ${this.artifact.name}`);
|
|
91
55
|
}
|
|
92
|
-
return
|
|
56
|
+
return finalExecutionPayload;
|
|
93
57
|
}
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
*/ async profile(options) {
|
|
100
|
-
const txRequest = await this.create(options);
|
|
101
|
-
return await this.wallet.profileTx(txRequest, options.profileMode, options.skipProofGeneration, options?.from);
|
|
58
|
+
convertDeployOptionsToRequestOptions(options) {
|
|
59
|
+
return {
|
|
60
|
+
...options,
|
|
61
|
+
deployer: !options?.universalDeploy ? options.from : undefined
|
|
62
|
+
};
|
|
102
63
|
}
|
|
103
64
|
/**
|
|
104
|
-
* Adds this contract to the
|
|
65
|
+
* Adds this contract to the wallet and returns the Contract object.
|
|
105
66
|
* @param options - Deployment options.
|
|
106
|
-
*/ async register(options
|
|
67
|
+
*/ async register(options) {
|
|
107
68
|
const instance = await this.getInstance(options);
|
|
108
|
-
await this.wallet.registerContract(
|
|
109
|
-
artifact: this.artifact,
|
|
110
|
-
instance
|
|
111
|
-
});
|
|
69
|
+
await this.wallet.registerContract(instance, this.artifact);
|
|
112
70
|
return this.postDeployCtor(instance.address, this.wallet);
|
|
113
71
|
}
|
|
114
72
|
/**
|
|
@@ -118,7 +76,7 @@ import { DeploySentTx } from './deploy_sent_tx.js';
|
|
|
118
76
|
* depending on the provided options.
|
|
119
77
|
* @param options - Contract creation options.
|
|
120
78
|
* @returns An execution payload with potentially calls (and bytecode capsule) to the class registry and instance registry.
|
|
121
|
-
*/ async getPublicationExecutionPayload(options
|
|
79
|
+
*/ async getPublicationExecutionPayload(options) {
|
|
122
80
|
const calls = [];
|
|
123
81
|
// Set contract instance object so it's available for populating the DeploySendTx object
|
|
124
82
|
const instance = await this.getInstance(options);
|
|
@@ -129,7 +87,7 @@ import { DeploySentTx } from './deploy_sent_tx.js';
|
|
|
129
87
|
throw new Error(`Contract class mismatch when deploying contract: got ${instance.currentContractClassId.toString()} from instance and ${contractClass.id.toString()} from artifact`);
|
|
130
88
|
}
|
|
131
89
|
// Publish the contract class if it hasn't been published already.
|
|
132
|
-
if (!options
|
|
90
|
+
if (!options?.skipClassPublication) {
|
|
133
91
|
if ((await this.wallet.getContractClassMetadata(contractClass.id)).isContractClassPubliclyRegistered) {
|
|
134
92
|
this.log.debug(`Skipping publication of already-registered contract class ${contractClass.id.toString()} for ${instance.address.toString()}`);
|
|
135
93
|
} else {
|
|
@@ -139,7 +97,7 @@ import { DeploySentTx } from './deploy_sent_tx.js';
|
|
|
139
97
|
}
|
|
140
98
|
}
|
|
141
99
|
// Publish the contract instance:
|
|
142
|
-
if (!options
|
|
100
|
+
if (!options?.skipInstancePublication) {
|
|
143
101
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/15596):
|
|
144
102
|
// Read the artifact, and if there are no public functions, warn the caller that publication of the
|
|
145
103
|
// contract instance is not necessary (until such time as they wish to update the instance (i.e. change its class_id)).
|
|
@@ -152,9 +110,9 @@ import { DeploySentTx } from './deploy_sent_tx.js';
|
|
|
152
110
|
* Returns the calls necessary to initialize the contract.
|
|
153
111
|
* @param options - Deployment options.
|
|
154
112
|
* @returns - An array of function calls.
|
|
155
|
-
*/ async getInitializationExecutionPayload(options
|
|
113
|
+
*/ async getInitializationExecutionPayload(options) {
|
|
156
114
|
const executionsPayloads = [];
|
|
157
|
-
if (this.constructorArtifact && !options
|
|
115
|
+
if (this.constructorArtifact && !options?.skipInitialization) {
|
|
158
116
|
const { address } = await this.getInstance(options);
|
|
159
117
|
const constructorCall = new ContractFunctionInteraction(this.wallet, address, this.constructorArtifact, this.args);
|
|
160
118
|
executionsPayloads.push(await constructorCall.request());
|
|
@@ -169,7 +127,11 @@ import { DeploySentTx } from './deploy_sent_tx.js';
|
|
|
169
127
|
* @param options - An object containing various deployment options such as contractAddressSalt and from.
|
|
170
128
|
* @returns A SentTx object that returns the receipt and the deployed contract instance.
|
|
171
129
|
*/ send(options) {
|
|
172
|
-
const sendTx = ()=>
|
|
130
|
+
const sendTx = async ()=>{
|
|
131
|
+
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
132
|
+
const sendOptions = await toSendOptions(options);
|
|
133
|
+
return this.wallet.sendTx(executionPayload, sendOptions);
|
|
134
|
+
};
|
|
173
135
|
this.log.debug(`Sent deployment tx of ${this.artifact.name} contract`);
|
|
174
136
|
return new DeploySentTx(this.wallet, sendTx, this.postDeployCtor, ()=>this.getInstance(options));
|
|
175
137
|
}
|
|
@@ -178,31 +140,51 @@ import { DeploySentTx } from './deploy_sent_tx.js';
|
|
|
178
140
|
*
|
|
179
141
|
* @param options - An object containing various initialization and publication options.
|
|
180
142
|
* @returns An instance object.
|
|
181
|
-
*/ async getInstance(options
|
|
143
|
+
*/ async getInstance(options) {
|
|
182
144
|
if (!this.instance) {
|
|
183
145
|
this.instance = await getContractInstanceFromInstantiationParams(this.artifact, {
|
|
184
146
|
constructorArgs: this.args,
|
|
185
|
-
salt: options.
|
|
147
|
+
salt: options?.contractAddressSalt ?? Fr.random(),
|
|
186
148
|
publicKeys: this.publicKeys,
|
|
187
149
|
constructorArtifact: this.constructorArtifact,
|
|
188
|
-
deployer: options
|
|
150
|
+
deployer: options?.deployer ? options.deployer : AztecAddress.ZERO
|
|
189
151
|
});
|
|
190
152
|
}
|
|
191
153
|
return this.instance;
|
|
192
154
|
}
|
|
193
155
|
/**
|
|
194
|
-
*
|
|
195
|
-
*
|
|
196
|
-
* @
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
156
|
+
* Simulate the deployment
|
|
157
|
+
*
|
|
158
|
+
* @param options - An optional object containing additional configuration for the simulation.
|
|
159
|
+
* @returns A simulation result object containing metadata of the execution, including gas
|
|
160
|
+
* estimations (if requested via options), execution statistics and emitted offchain effects
|
|
161
|
+
*/ async simulate(options) {
|
|
162
|
+
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
163
|
+
const simulatedTx = await this.wallet.simulateTx(executionPayload, await toSimulateOptions(options));
|
|
164
|
+
const { gasLimits, teardownGasLimits } = getGasLimits(simulatedTx, options.fee?.estimatedGasPadding);
|
|
165
|
+
this.log.verbose(`Estimated gas limits for tx: DA=${gasLimits.daGas} L2=${gasLimits.l2Gas} teardownDA=${teardownGasLimits.daGas} teardownL2=${teardownGasLimits.l2Gas}`);
|
|
166
|
+
return {
|
|
167
|
+
stats: simulatedTx.stats,
|
|
168
|
+
offchainEffects: collectOffchainEffects(simulatedTx.privateExecutionResult),
|
|
169
|
+
result: undefined,
|
|
170
|
+
estimatedGas: {
|
|
171
|
+
gasLimits,
|
|
172
|
+
teardownGasLimits
|
|
173
|
+
}
|
|
174
|
+
};
|
|
200
175
|
}
|
|
201
176
|
/**
|
|
202
|
-
*
|
|
203
|
-
* @param options -
|
|
204
|
-
|
|
205
|
-
|
|
177
|
+
* Simulate a deployment and profile the gate count for each function in the transaction.
|
|
178
|
+
* @param options - Same options as `send`, plus extra profiling options.
|
|
179
|
+
*
|
|
180
|
+
* @returns An object containing the function return value and profile result.
|
|
181
|
+
*/ async profile(options) {
|
|
182
|
+
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
183
|
+
return await this.wallet.profileTx(executionPayload, {
|
|
184
|
+
...await toProfileOptions(options),
|
|
185
|
+
profileMode: options.profileMode,
|
|
186
|
+
skipProofGeneration: options.skipProofGeneration
|
|
187
|
+
});
|
|
206
188
|
}
|
|
207
189
|
/** Return this deployment address. */ get address() {
|
|
208
190
|
return this.instance?.address;
|
|
@@ -39,6 +39,5 @@ export declare class DeploySentTx<TContract extends Contract = Contract> extends
|
|
|
39
39
|
* @returns The transaction receipt with the deployed contract instance.
|
|
40
40
|
*/
|
|
41
41
|
wait(opts?: DeployedWaitOpts): Promise<DeployTxReceipt<TContract>>;
|
|
42
|
-
protected getContractObject(wallet?: Wallet): Promise<TContract>;
|
|
43
42
|
}
|
|
44
43
|
//# sourceMappingURL=deploy_sent_tx.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy_sent_tx.d.ts","sourceRoot":"","sources":["../../src/contract/deploy_sent_tx.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"deploy_sent_tx.d.ts","sourceRoot":"","sources":["../../src/contract/deploy_sent_tx.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAErD,sDAAsD;AACtD,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG;IACxC,+GAA+G;IAC/G,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,0GAA0G;AAC1G,MAAM,MAAM,eAAe,CAAC,SAAS,SAAS,YAAY,GAAG,QAAQ,IAAI,QAAQ,CAAC,SAAS,CAAC,GAAG;IAC7F,+CAA+C;IAC/C,QAAQ,EAAE,SAAS,CAAC;CACrB,CAAC;AAEF;;GAEG;AACH,qBAAa,YAAY,CAAC,SAAS,SAAS,QAAQ,GAAG,QAAQ,CAAE,SAAQ,MAAM;IAM3E,OAAO,CAAC,cAAc;IACtB,kDAAkD;IAC3C,cAAc,EAAE,MAAM,OAAO,CAAC,2BAA2B,CAAC;IAPnE,OAAO,CAAC,GAAG,CAA0C;gBAGnD,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EACrB,cAAc,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,CAAC;IACrF,kDAAkD;IAC3C,cAAc,EAAE,MAAM,OAAO,CAAC,2BAA2B,CAAC;IAKnE;;;;OAIG;IACU,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;IAOlE;;;;OAIG;IACmB,IAAI,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;CAWzF"}
|
|
@@ -25,19 +25,16 @@ import { SentTx } from './sent_tx.js';
|
|
|
25
25
|
* @returns The transaction receipt with the deployed contract instance.
|
|
26
26
|
*/ async wait(opts) {
|
|
27
27
|
const receipt = await super.wait(opts);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
...receipt,
|
|
31
|
-
contract
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
async getContractObject(wallet) {
|
|
35
|
-
const isWallet = (pxeWalletOrNode)=>!!pxeWalletOrNode.createTxExecutionRequest;
|
|
36
|
-
const contractWallet = wallet ?? (isWallet(this.pxeWalletOrNode) && this.pxeWalletOrNode);
|
|
28
|
+
// In the case of DeploySentTx we have a guarantee that this.walletOrNode is a Wallet so we can cast it to Wallet.
|
|
29
|
+
const contractWallet = opts?.wallet ?? this.walletOrNode;
|
|
37
30
|
if (!contractWallet) {
|
|
38
31
|
throw new Error(`A wallet is required for creating a contract instance`);
|
|
39
32
|
}
|
|
40
33
|
const instance = await this.instanceGetter();
|
|
41
|
-
|
|
34
|
+
const contract = await this.postDeployCtor(instance.address, contractWallet);
|
|
35
|
+
return {
|
|
36
|
+
...receipt,
|
|
37
|
+
contract
|
|
38
|
+
};
|
|
42
39
|
}
|
|
43
40
|
}
|
|
@@ -1,44 +1,68 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type { Fr } from '@aztec/foundation/fields';
|
|
1
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
3
2
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
4
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
5
|
-
import type {
|
|
4
|
+
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
5
|
+
import type { Capsule, OffchainEffect, SimulationStats } from '@aztec/stdlib/tx';
|
|
6
|
+
import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
7
|
+
import type { ProfileOptions, SendOptions, SimulateOptions } from '../wallet/index.js';
|
|
8
|
+
/**
|
|
9
|
+
* Options used to tweak the simulation and add gas estimation capabilities
|
|
10
|
+
*/
|
|
11
|
+
export type FeeEstimationOptions = {
|
|
12
|
+
/** Whether to modify the fee settings of the simulation with high gas limit to figure out actual gas settings. */
|
|
13
|
+
estimateGas?: boolean;
|
|
14
|
+
/** Percentage to pad the estimated gas limits by, if empty, defaults to 0.1. Only relevant if estimateGas is set. */
|
|
15
|
+
estimatedGasPadding?: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Interactions allow configuring a custom fee payment method that gets bundled with the transaction before
|
|
19
|
+
* sending it to the wallet
|
|
20
|
+
*/
|
|
21
|
+
export type FeePaymentMethodOption = {
|
|
22
|
+
/** Fee payment method to embed in the interaction */
|
|
23
|
+
paymentMethod?: FeePaymentMethod;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* User-defined partial gas settings for the interaction. This type is completely optional since
|
|
27
|
+
* the wallet will fill in the missing options
|
|
28
|
+
*/
|
|
29
|
+
export type GasSettingsOption = {
|
|
30
|
+
/** The gas settings */
|
|
31
|
+
gasSettings?: Partial<FieldsOf<GasSettings>>;
|
|
32
|
+
};
|
|
33
|
+
/** Fee options as set by a user. */
|
|
34
|
+
export type InteractionFeeOptions = GasSettingsOption & FeePaymentMethodOption;
|
|
35
|
+
/** Fee options that can be set for simulation *only* */
|
|
36
|
+
export type SimulationInteractionFeeOptions = InteractionFeeOptions & FeeEstimationOptions;
|
|
6
37
|
/**
|
|
7
38
|
* Represents the options to configure a request from a contract interaction.
|
|
8
39
|
* Allows specifying additional auth witnesses and capsules to use during execution
|
|
9
40
|
*/
|
|
10
|
-
export type
|
|
41
|
+
export type RequestInteractionOptions = {
|
|
11
42
|
/** Extra authwits to use during execution */
|
|
12
43
|
authWitnesses?: AuthWitness[];
|
|
13
44
|
/** Extra capsules to use during execution */
|
|
14
45
|
capsules?: Capsule[];
|
|
46
|
+
/** Fee payment method to embed in the interaction request */
|
|
47
|
+
fee?: FeePaymentMethodOption;
|
|
15
48
|
};
|
|
16
49
|
/**
|
|
17
50
|
* Represents options for calling a (constrained) function in a contract.
|
|
18
51
|
*/
|
|
19
|
-
export type
|
|
52
|
+
export type SendInteractionOptions = RequestInteractionOptions & {
|
|
20
53
|
/** The sender's Aztec address. */
|
|
21
54
|
from: AztecAddress;
|
|
22
55
|
/** The fee options for the transaction. */
|
|
23
|
-
fee?:
|
|
24
|
-
/**
|
|
25
|
-
* A nonce to inject into the app payload of the transaction. When used with cancellable=true, this nonce will be
|
|
26
|
-
* used to compute a nullifier that allows cancelling this transaction by submitting a new one with the same nonce
|
|
27
|
-
* but higher fee. The nullifier ensures only one transaction can succeed.
|
|
28
|
-
*/
|
|
29
|
-
txNonce?: Fr;
|
|
30
|
-
/**
|
|
31
|
-
* Whether the transaction can be cancelled by submitting a new transaction with the same txNonce but
|
|
32
|
-
* higher fee.
|
|
33
|
-
*/
|
|
34
|
-
cancellable?: boolean;
|
|
56
|
+
fee?: InteractionFeeOptions;
|
|
35
57
|
};
|
|
36
58
|
/**
|
|
37
59
|
* Represents the options for simulating a contract function interaction.
|
|
38
60
|
* Allows specifying the address from which the method should be called.
|
|
39
61
|
* Disregarded for simulation of public functions
|
|
40
62
|
*/
|
|
41
|
-
export type
|
|
63
|
+
export type SimulateInteractionOptions = Omit<SendInteractionOptions, 'fee'> & {
|
|
64
|
+
/** The fee options for the transaction. */
|
|
65
|
+
fee?: SimulationInteractionFeeOptions;
|
|
42
66
|
/** Simulate without checking for the validity of the resulting transaction, e.g. whether it emits any existing nullifiers. */
|
|
43
67
|
skipTxValidation?: boolean;
|
|
44
68
|
/** Whether to ensure the fee payer is not empty and has enough balance to pay for the fee. */
|
|
@@ -50,10 +74,41 @@ export type SimulateMethodOptions = Pick<SendMethodOptions, 'from' | 'authWitnes
|
|
|
50
74
|
/**
|
|
51
75
|
* Represents the options for profiling an interaction.
|
|
52
76
|
*/
|
|
53
|
-
export type
|
|
77
|
+
export type ProfileInteractionOptions = SimulateInteractionOptions & {
|
|
54
78
|
/** Whether to return gates information or the bytecode/witnesses. */
|
|
55
79
|
profileMode: 'gates' | 'execution-steps' | 'full';
|
|
56
80
|
/** Whether to generate a ClientIVC proof or not */
|
|
57
81
|
skipProofGeneration?: boolean;
|
|
58
82
|
};
|
|
83
|
+
/**
|
|
84
|
+
* Represents the result type of a simulation.
|
|
85
|
+
* By default, it will just be the return value of the simulated function
|
|
86
|
+
* If `includeMetadata` is set to true in `SimulateInteractionOptions` on the input of `simulate(...)`,
|
|
87
|
+
* it will provide extra information.
|
|
88
|
+
*/
|
|
89
|
+
export type SimulationReturn<T extends boolean | undefined> = T extends true ? {
|
|
90
|
+
/** Additional stats about the simulation */
|
|
91
|
+
stats: SimulationStats;
|
|
92
|
+
/** Offchain effects generated during the simulation */
|
|
93
|
+
offchainEffects: OffchainEffect[];
|
|
94
|
+
/** Return value of the function */
|
|
95
|
+
result: any;
|
|
96
|
+
/** Gas estimation results */
|
|
97
|
+
estimatedGas: Pick<GasSettings, 'gasLimits' | 'teardownGasLimits'>;
|
|
98
|
+
} : any;
|
|
99
|
+
/**
|
|
100
|
+
* Transforms and cleans up the higher level SendInteractionOptions defined by the interaction into
|
|
101
|
+
* SendOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
102
|
+
*/
|
|
103
|
+
export declare function toSendOptions(options: SendInteractionOptions): Promise<SendOptions>;
|
|
104
|
+
/**
|
|
105
|
+
* Transforms and cleans up the higher level SimulateInteractionOptions defined by the interaction into
|
|
106
|
+
* SimulateOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
107
|
+
*/
|
|
108
|
+
export declare function toSimulateOptions(options: SimulateInteractionOptions): Promise<SimulateOptions>;
|
|
109
|
+
/**
|
|
110
|
+
* Transforms and cleans up the higher level ProfileInteractionOptions defined by the interaction into
|
|
111
|
+
* ProfileOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
112
|
+
*/
|
|
113
|
+
export declare function toProfileOptions(options: ProfileInteractionOptions): Promise<ProfileOptions>;
|
|
59
114
|
//# sourceMappingURL=interaction_options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interaction_options.d.ts","sourceRoot":"","sources":["../../src/contract/interaction_options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"interaction_options.d.ts","sourceRoot":"","sources":["../../src/contract/interaction_options.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,4 +1,52 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
|
|
4
|
-
export
|
|
2
|
+
* Transforms and cleans up the higher level SendInteractionOptions defined by the interaction into
|
|
3
|
+
* SendOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
4
|
+
*/ export async function toSendOptions(options) {
|
|
5
|
+
return {
|
|
6
|
+
...options,
|
|
7
|
+
fee: {
|
|
8
|
+
// If this interaction includes a fee payment method, pass the fee payer
|
|
9
|
+
// as a hint to the wallet
|
|
10
|
+
embeddedPaymentMethodFeePayer: await options.fee?.paymentMethod?.getFeePayer(),
|
|
11
|
+
// If a payment method that includes gas settings was used,
|
|
12
|
+
// try to reuse as much as possible while still allowing
|
|
13
|
+
// manual override. CAREFUL: this can cause mismatches during proving
|
|
14
|
+
gasSettings: {
|
|
15
|
+
...options.fee?.paymentMethod?.getGasSettings(),
|
|
16
|
+
...options.fee?.gasSettings
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Transforms and cleans up the higher level SimulateInteractionOptions defined by the interaction into
|
|
23
|
+
* SimulateOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
24
|
+
*/ export async function toSimulateOptions(options) {
|
|
25
|
+
return {
|
|
26
|
+
...options,
|
|
27
|
+
fee: {
|
|
28
|
+
// If this interaction includes a fee payment method, pass the fee payer
|
|
29
|
+
// as a hint to the wallet
|
|
30
|
+
embeddedPaymentMethodFeePayer: await options.fee?.paymentMethod?.getFeePayer(),
|
|
31
|
+
// If a payment method that includes gas settings was used,
|
|
32
|
+
// try to reuse as much as possible while still allowing
|
|
33
|
+
// manual override. CAREFUL: this can cause mismatches during proving
|
|
34
|
+
gasSettings: {
|
|
35
|
+
...options.fee?.paymentMethod?.getGasSettings(),
|
|
36
|
+
...options.fee?.gasSettings
|
|
37
|
+
},
|
|
38
|
+
estimateGas: options.fee?.estimateGas,
|
|
39
|
+
estimatedGasPadding: options.fee?.estimatedGasPadding
|
|
40
|
+
}
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Transforms and cleans up the higher level ProfileInteractionOptions defined by the interaction into
|
|
45
|
+
* ProfileOptions, which are the ones that can be serialized and forwarded to the wallet
|
|
46
|
+
*/ export async function toProfileOptions(options) {
|
|
47
|
+
return {
|
|
48
|
+
...await toSimulateOptions(options),
|
|
49
|
+
profileMode: options.profileMode,
|
|
50
|
+
skipProofGeneration: options.skipProofGeneration
|
|
51
|
+
};
|
|
52
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
2
|
-
import type { AztecNode
|
|
2
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
3
3
|
import { TxHash, type TxReceipt } from '@aztec/stdlib/tx';
|
|
4
4
|
import type { Wallet } from '../wallet/wallet.js';
|
|
5
5
|
/** Options related to waiting for a tx. */
|
|
@@ -19,11 +19,11 @@ export declare const DefaultWaitOpts: WaitOpts;
|
|
|
19
19
|
* its hash, receipt, and mining status.
|
|
20
20
|
*/
|
|
21
21
|
export declare class SentTx {
|
|
22
|
-
protected
|
|
22
|
+
protected walletOrNode: Wallet | AztecNode;
|
|
23
23
|
protected sendTxPromise: Promise<void>;
|
|
24
24
|
protected sendTxError?: Error;
|
|
25
25
|
protected txHash?: TxHash;
|
|
26
|
-
constructor(
|
|
26
|
+
constructor(walletOrNode: Wallet | AztecNode, sendTx: () => Promise<TxHash>);
|
|
27
27
|
/**
|
|
28
28
|
* Retrieves the transaction hash of the SentTx instance.
|
|
29
29
|
* The function internally awaits for the 'txHashPromise' to resolve, and then returns the resolved transaction hash.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sent_tx.d.ts","sourceRoot":"","sources":["../../src/contract/sent_tx.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"sent_tx.d.ts","sourceRoot":"","sources":["../../src/contract/sent_tx.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,EAAE,MAAM,EAAE,KAAK,SAAS,EAAY,MAAM,kBAAkB,CAAC;AAEpE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD,2CAA2C;AAC3C,MAAM,MAAM,QAAQ,GAAG;IACrB,gKAAgK;IAChK,wBAAwB,CAAC,EAAE,MAAM,CAAC;IAClC,6FAA6F;IAC7F,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,sGAAsG;IACtG,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0HAA0H;IAC1H,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,QAI7B,CAAC;AAEF;;;GAGG;AACH,qBAAa,MAAM;IAMf,SAAS,CAAC,YAAY,EAAE,MAAM,GAAG,SAAS;IAL5C,SAAS,CAAC,aAAa,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACvC,SAAS,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC;IAC9B,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,CAAC;gBAGd,YAAY,EAAE,MAAM,GAAG,SAAS,EAC1C,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC;IAgB/B;;;;;;OAMG;IACU,SAAS,IAAI,OAAO,CAAC,MAAM,CAAC;IAazC;;;;;;OAMG;IACU,UAAU,IAAI,OAAO,CAAC,SAAS,CAAC;IAK7C;;;;OAIG;IACU,IAAI,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;cAUhD,cAAc,CAAC,IAAI,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC,SAAS,CAAC;CA6BpE"}
|
package/dest/contract/sent_tx.js
CHANGED
|
@@ -10,12 +10,12 @@ export const DefaultWaitOpts = {
|
|
|
10
10
|
* The SentTx class represents a sent transaction through the PXE (or directly to a node) providing methods to fetch
|
|
11
11
|
* its hash, receipt, and mining status.
|
|
12
12
|
*/ export class SentTx {
|
|
13
|
-
|
|
13
|
+
walletOrNode;
|
|
14
14
|
sendTxPromise;
|
|
15
15
|
sendTxError;
|
|
16
16
|
txHash;
|
|
17
|
-
constructor(
|
|
18
|
-
this.
|
|
17
|
+
constructor(walletOrNode, sendTx){
|
|
18
|
+
this.walletOrNode = walletOrNode;
|
|
19
19
|
const { promise, resolve } = promiseWithResolvers();
|
|
20
20
|
this.sendTxPromise = promise;
|
|
21
21
|
sendTx().then((txHash)=>{
|
|
@@ -51,7 +51,7 @@ export const DefaultWaitOpts = {
|
|
|
51
51
|
* @returns A promise that resolves to a TxReceipt object representing the fetched transaction receipt.
|
|
52
52
|
*/ async getReceipt() {
|
|
53
53
|
const txHash = await this.getTxHash();
|
|
54
|
-
return await this.
|
|
54
|
+
return await this.walletOrNode.getTxReceipt(txHash);
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
57
|
* Awaits for a tx to be mined and returns the receipt. Throws if tx is not mined.
|
|
@@ -69,7 +69,7 @@ export const DefaultWaitOpts = {
|
|
|
69
69
|
const startTime = Date.now();
|
|
70
70
|
const ignoreDroppedReceiptsFor = opts?.ignoreDroppedReceiptsFor ?? DefaultWaitOpts.ignoreDroppedReceiptsFor;
|
|
71
71
|
return await retryUntil(async ()=>{
|
|
72
|
-
const txReceipt = await this.
|
|
72
|
+
const txReceipt = await this.walletOrNode.getTxReceipt(txHash);
|
|
73
73
|
// If receipt is not yet available, try again
|
|
74
74
|
if (txReceipt.status === TxStatus.PENDING) {
|
|
75
75
|
return undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { AztecNode
|
|
2
|
-
import type { TxReceipt } from '
|
|
1
|
+
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
2
|
+
import type { TxReceipt } from '@aztec/stdlib/tx';
|
|
3
3
|
/**
|
|
4
4
|
* Options for waiting for a transaction to be proven.
|
|
5
5
|
*/
|
|
@@ -13,5 +13,5 @@ export declare const DefaultWaitForProvenOpts: WaitForProvenOpts;
|
|
|
13
13
|
/**
|
|
14
14
|
* Wait for a transaction to be proven by polling the node
|
|
15
15
|
*/
|
|
16
|
-
export declare function waitForProven(
|
|
16
|
+
export declare function waitForProven(node: AztecNode, receipt: TxReceipt, opts?: WaitForProvenOpts): Promise<number>;
|
|
17
17
|
//# sourceMappingURL=wait_for_proven.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wait_for_proven.d.ts","sourceRoot":"","sources":["../../src/contract/wait_for_proven.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"wait_for_proven.d.ts","sourceRoot":"","sources":["../../src/contract/wait_for_proven.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iCAAiC,CAAC;AACjE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAIlD;;GAEG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B,6DAA6D;IAC7D,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,6CAA6C;IAC7C,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEF,eAAO,MAAM,wBAAwB,EAAE,iBAGtC,CAAC;AAEF;;GAEG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,EAAE,iBAAiB,mBAahG"}
|
|
@@ -6,12 +6,12 @@ export const DefaultWaitForProvenOpts = {
|
|
|
6
6
|
};
|
|
7
7
|
/**
|
|
8
8
|
* Wait for a transaction to be proven by polling the node
|
|
9
|
-
*/ export async function waitForProven(
|
|
9
|
+
*/ export async function waitForProven(node, receipt, opts) {
|
|
10
10
|
if (!receipt.blockNumber) {
|
|
11
11
|
throw new Error(`Cannot wait for proven: receipt of tx ${receipt.txHash} does not have a block number`);
|
|
12
12
|
}
|
|
13
13
|
return await retryUntil(async ()=>{
|
|
14
|
-
const provenBlock = await
|
|
14
|
+
const provenBlock = await node.getProvenBlockNumber();
|
|
15
15
|
return provenBlock >= receipt.blockNumber ? provenBlock : undefined;
|
|
16
16
|
}, 'isProven', opts?.provenTimeout ?? DefaultWaitForProvenOpts.provenTimeout, opts?.interval ?? DefaultWaitForProvenOpts.interval);
|
|
17
17
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
2
2
|
import type { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
3
|
-
import type { Wallet } from '../wallet/
|
|
3
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
4
4
|
/**
|
|
5
5
|
* Sets up a call to the canonical contract instance registry to publish a contract instance.
|
|
6
6
|
* @param wallet - The wallet to use for the publication (setup) tx.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"publish_instance.d.ts","sourceRoot":"","sources":["../../src/deployment/publish_instance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAEhG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"publish_instance.d.ts","sourceRoot":"","sources":["../../src/deployment/publish_instance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAE1E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,8CAA8C,CAAC;AAEhG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAElD;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,2BAA2B,GACpC,OAAO,CAAC,2BAA2B,CAAC,CAWtC"}
|
|
@@ -5,10 +5,7 @@ import { getInstanceRegistryContract } from '../contract/protocol_contracts.js';
|
|
|
5
5
|
* @param instance - The instance to publish.
|
|
6
6
|
*/ export async function publishInstance(wallet, instance) {
|
|
7
7
|
const contractInstanceRegistry = await getInstanceRegistryContract(wallet);
|
|
8
|
-
const { salt, currentContractClassId: contractClassId, publicKeys, deployer } = instance;
|
|
9
|
-
const isUniversalDeploy =
|
|
10
|
-
if (!isUniversalDeploy && !wallet.getAddress().equals(deployer)) {
|
|
11
|
-
throw new Error(`Expected deployer ${deployer.toString()} does not match sender wallet ${wallet.getAddress().toString()}`);
|
|
12
|
-
}
|
|
8
|
+
const { salt, currentContractClassId: contractClassId, publicKeys, deployer: instanceDeployer } = instance;
|
|
9
|
+
const isUniversalDeploy = instanceDeployer.isZero();
|
|
13
10
|
return contractInstanceRegistry.methods.publish_for_public_execution(salt, contractClassId, instance.initializationHash, publicKeys, isUniversalDeploy);
|
|
14
11
|
}
|