@aztec/aztec.js 0.0.1-commit.03f7ef2 → 0.0.1-commit.04852196a
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 +25 -40
- package/dest/account/account.d.ts.map +1 -1
- package/dest/account/account.js +19 -47
- package/dest/account/account_contract.d.ts +8 -9
- package/dest/account/account_contract.d.ts.map +1 -1
- package/dest/account/account_with_secret_key.d.ts +19 -7
- package/dest/account/account_with_secret_key.d.ts.map +1 -1
- package/dest/account/account_with_secret_key.js +21 -4
- package/dest/account/index.d.ts +3 -2
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +2 -0
- package/dest/account/signerless_account.d.ts +5 -6
- package/dest/account/signerless_account.d.ts.map +1 -1
- package/dest/account/signerless_account.js +8 -11
- package/dest/api/abi.d.ts +2 -2
- package/dest/api/abi.d.ts.map +1 -1
- package/dest/api/account.d.ts +2 -4
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +1 -3
- package/dest/api/authorization.d.ts +2 -2
- package/dest/api/authorization.d.ts.map +1 -1
- package/dest/api/authorization.js +1 -1
- package/dest/api/contract.d.ts +18 -12
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +16 -10
- package/dest/api/deployment.d.ts +1 -2
- package/dest/api/deployment.d.ts.map +1 -1
- package/dest/api/deployment.js +0 -1
- package/dest/api/events.d.ts +18 -6
- package/dest/api/events.d.ts.map +1 -1
- package/dest/api/events.js +37 -22
- package/dest/api/fields.d.ts +2 -1
- package/dest/api/fields.d.ts.map +1 -1
- package/dest/api/fields.js +1 -0
- package/dest/api/keys.d.ts +1 -1
- package/dest/api/keys.js +1 -1
- package/dest/api/node.d.ts +8 -4
- package/dest/api/node.d.ts.map +1 -1
- package/dest/api/node.js +7 -3
- package/dest/api/protocol.d.ts +7 -1
- package/dest/api/protocol.d.ts.map +1 -1
- package/dest/api/protocol.js +6 -0
- package/dest/api/tx.d.ts +2 -2
- package/dest/api/tx.d.ts.map +1 -1
- package/dest/api/tx.js +1 -1
- package/dest/api/wallet.d.ts +3 -2
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +2 -1
- package/dest/authorization/call_authorization_request.d.ts +22 -1
- package/dest/authorization/call_authorization_request.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.d.ts +8 -10
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +5 -17
- package/dest/contract/batch_call.d.ts +3 -3
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +20 -9
- package/dest/contract/contract_base.d.ts +4 -1
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.d.ts +7 -16
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +107 -18
- package/dest/contract/deploy_method.d.ts +91 -19
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +73 -34
- package/dest/contract/get_gas_limits.js +3 -3
- package/dest/contract/interaction_options.d.ts +99 -21
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +41 -1
- package/dest/contract/protocol_contracts/auth-registry.d.ts +36 -0
- package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/auth-registry.js +1005 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts +15 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-class-registry.js +139 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +22 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.js +465 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts +21 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/fee-juice.js +434 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +34 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.js +601 -0
- package/dest/contract/protocol_contracts/public-checks.d.ts +26 -0
- package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/public-checks.js +609 -0
- package/dest/contract/wait_for_proven.d.ts +2 -2
- package/dest/contract/wait_for_proven.d.ts.map +1 -1
- package/dest/contract/wait_for_proven.js +1 -1
- package/dest/contract/wait_opts.d.ts +16 -0
- package/dest/contract/wait_opts.d.ts.map +1 -0
- package/dest/contract/wait_opts.js +5 -0
- package/dest/deployment/publish_class.js +2 -2
- package/dest/deployment/publish_instance.d.ts +2 -2
- package/dest/deployment/publish_instance.d.ts.map +1 -1
- package/dest/deployment/publish_instance.js +3 -3
- package/dest/ethereum/portal_manager.d.ts +7 -4
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +15 -16
- package/dest/fee/fee_juice_payment_method_with_claim.js +6 -6
- package/dest/fee/private_fee_payment_method.d.ts +2 -1
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +11 -10
- package/dest/fee/public_fee_payment_method.d.ts +2 -1
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +11 -10
- package/dest/fee/sponsored_fee_payment.js +3 -3
- package/dest/scripts/generate_protocol_contract_types.d.ts +2 -0
- package/dest/scripts/generate_protocol_contract_types.d.ts.map +1 -0
- package/dest/scripts/generate_protocol_contract_types.js +120 -0
- package/dest/utils/abi_types.d.ts +6 -1
- package/dest/utils/abi_types.d.ts.map +1 -1
- package/dest/utils/abi_types.js +1 -1
- package/dest/utils/authwit.d.ts +8 -6
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +15 -15
- package/dest/utils/cross_chain.d.ts +3 -8
- package/dest/utils/cross_chain.d.ts.map +1 -1
- package/dest/utils/cross_chain.js +8 -15
- package/dest/utils/node.d.ts +12 -1
- package/dest/utils/node.d.ts.map +1 -1
- package/dest/utils/node.js +46 -0
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +5 -8
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
- package/dest/wallet/account_entrypoint_meta_payment_method.js +28 -43
- package/dest/wallet/account_manager.d.ts +5 -8
- package/dest/wallet/account_manager.d.ts.map +1 -1
- package/dest/wallet/account_manager.js +5 -11
- package/dest/wallet/capabilities.d.ts +452 -0
- package/dest/wallet/capabilities.d.ts.map +1 -0
- package/dest/wallet/capabilities.js +3 -0
- package/dest/wallet/deploy_account_method.d.ts +46 -7
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/deploy_account_method.js +33 -5
- package/dest/wallet/index.d.ts +2 -1
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +1 -0
- package/dest/wallet/wallet.d.ts +1810 -2493
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +230 -108
- package/package.json +25 -14
- package/src/account/account.ts +34 -58
- package/src/account/account_contract.ts +6 -7
- package/src/account/account_with_secret_key.ts +33 -8
- package/src/account/index.ts +2 -1
- package/src/account/signerless_account.ts +13 -12
- package/src/api/abi.ts +1 -0
- package/src/api/account.ts +9 -3
- package/src/api/authorization.ts +1 -0
- package/src/api/contract.ts +31 -9
- package/src/api/deployment.ts +0 -1
- package/src/api/events.ts +50 -32
- package/src/api/fields.ts +1 -0
- package/src/api/keys.ts +2 -2
- package/src/api/node.ts +7 -3
- package/src/api/protocol.ts +7 -0
- package/src/api/tx.ts +2 -0
- package/src/api/wallet.ts +48 -3
- package/src/contract/base_contract_interaction.ts +28 -15
- package/src/contract/batch_call.ts +20 -15
- package/src/contract/contract_function_interaction.ts +114 -26
- package/src/contract/deploy_method.ts +179 -41
- package/src/contract/get_gas_limits.ts +3 -3
- package/src/contract/interaction_options.ts +141 -23
- package/src/contract/protocol_contracts/auth-registry.ts +553 -0
- package/src/contract/protocol_contracts/contract-class-registry.ts +99 -0
- package/src/contract/protocol_contracts/contract-instance-registry.ts +302 -0
- package/src/contract/protocol_contracts/fee-juice.ts +266 -0
- package/src/contract/protocol_contracts/multi-call-entrypoint.ts +336 -0
- package/src/contract/protocol_contracts/public-checks.ts +320 -0
- package/src/contract/wait_for_proven.ts +1 -1
- package/src/contract/wait_opts.ts +21 -0
- package/src/deployment/publish_class.ts +2 -2
- package/src/deployment/publish_instance.ts +3 -6
- package/src/ethereum/portal_manager.ts +17 -21
- package/src/fee/fee_juice_payment_method_with_claim.ts +5 -5
- package/src/fee/private_fee_payment_method.ts +8 -7
- package/src/fee/public_fee_payment_method.ts +9 -8
- package/src/fee/sponsored_fee_payment.ts +3 -3
- package/src/scripts/generate_protocol_contract_types.ts +150 -0
- package/src/utils/abi_types.ts +7 -0
- package/src/utils/authwit.ts +34 -24
- package/src/utils/cross_chain.ts +9 -18
- package/src/utils/node.ts +62 -0
- package/src/wallet/account_entrypoint_meta_payment_method.ts +28 -60
- package/src/wallet/account_manager.ts +5 -13
- package/src/wallet/capabilities.ts +500 -0
- package/src/wallet/deploy_account_method.ts +74 -13
- package/src/wallet/index.ts +1 -0
- package/src/wallet/wallet.ts +367 -128
- package/dest/account/interface.d.ts +0 -19
- package/dest/account/interface.d.ts.map +0 -1
- package/dest/account/interface.js +0 -5
- package/dest/contract/deploy_sent_tx.d.ts +0 -48
- package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
- package/dest/contract/deploy_sent_tx.js +0 -46
- package/dest/contract/protocol_contracts.d.ts +0 -9
- package/dest/contract/protocol_contracts.d.ts.map +0 -1
- package/dest/contract/protocol_contracts.js +0 -26
- package/dest/contract/sent_tx.d.ts +0 -50
- package/dest/contract/sent_tx.d.ts.map +0 -1
- package/dest/contract/sent_tx.js +0 -90
- package/dest/contract/unsafe_contract.d.ts +0 -15
- package/dest/contract/unsafe_contract.d.ts.map +0 -1
- package/dest/contract/unsafe_contract.js +0 -6
- package/dest/deployment/broadcast_function.d.ts +0 -24
- package/dest/deployment/broadcast_function.d.ts.map +0 -1
- package/dest/deployment/broadcast_function.js +0 -74
- package/src/account/interface.ts +0 -25
- package/src/contract/deploy_sent_tx.ts +0 -75
- package/src/contract/protocol_contracts.ts +0 -35
- package/src/contract/sent_tx.ts +0 -129
- package/src/contract/unsafe_contract.ts +0 -19
- package/src/deployment/broadcast_function.ts +0 -148
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
import { type FunctionCall, FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
2
|
-
import {
|
|
3
|
-
ExecutionPayload,
|
|
4
|
-
TxSimulationResult,
|
|
5
|
-
UtilitySimulationResult,
|
|
6
|
-
mergeExecutionPayloads,
|
|
7
|
-
} from '@aztec/stdlib/tx';
|
|
2
|
+
import { ExecutionPayload, TxSimulationResult, UtilityExecutionResult, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
8
3
|
|
|
9
4
|
import type { BatchedMethod, Wallet } from '../wallet/wallet.js';
|
|
10
5
|
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
11
6
|
import {
|
|
12
7
|
type RequestInteractionOptions,
|
|
13
8
|
type SimulateInteractionOptions,
|
|
9
|
+
emptyOffchainOutput,
|
|
10
|
+
extractOffchainOutput,
|
|
14
11
|
toSimulateOptions,
|
|
15
12
|
} from './interaction_options.js';
|
|
16
13
|
|
|
17
14
|
/** A batch of function calls to be sent as a single transaction through a wallet. */
|
|
15
|
+
// docs:start:batch_call_class
|
|
18
16
|
export class BatchCall extends BaseContractInteraction {
|
|
19
17
|
constructor(
|
|
20
18
|
wallet: Wallet,
|
|
@@ -22,6 +20,7 @@ export class BatchCall extends BaseContractInteraction {
|
|
|
22
20
|
) {
|
|
23
21
|
super(wallet);
|
|
24
22
|
}
|
|
23
|
+
// docs:end:batch_call_class
|
|
25
24
|
|
|
26
25
|
/**
|
|
27
26
|
* Returns an execution request that represents this operation.
|
|
@@ -40,9 +39,9 @@ export class BatchCall extends BaseContractInteraction {
|
|
|
40
39
|
}
|
|
41
40
|
|
|
42
41
|
/**
|
|
43
|
-
* Simulates the batch, supporting private, public and utility functions. Although this is a single
|
|
42
|
+
* Simulates/executes the batch, supporting private, public and utility functions. Although this is a single
|
|
44
43
|
* interaction with the wallet, private and public functions will be grouped into a single ExecutionPayload
|
|
45
|
-
* that the wallet will simulate as a single transaction. Utility function calls will
|
|
44
|
+
* that the wallet will simulate as a single transaction. Utility function calls will be executed
|
|
46
45
|
* one by one.
|
|
47
46
|
* @param options - An optional object containing additional configuration for the interaction.
|
|
48
47
|
* @returns The results of all the interactions that make up the batch
|
|
@@ -74,13 +73,13 @@ export class BatchCall extends BaseContractInteraction {
|
|
|
74
73
|
{ indexedExecutionPayloads: [], utility: [], publicIndex: 0, privateIndex: 0 },
|
|
75
74
|
);
|
|
76
75
|
|
|
77
|
-
const batchRequests:
|
|
76
|
+
const batchRequests: BatchedMethod[] = [];
|
|
78
77
|
|
|
79
78
|
// Add utility calls to batch
|
|
80
79
|
for (const [call] of utility) {
|
|
81
80
|
batchRequests.push({
|
|
82
|
-
name: '
|
|
83
|
-
args: [call, options
|
|
81
|
+
name: 'executeUtility' as const,
|
|
82
|
+
args: [call, { scope: options.from, authWitnesses: options.authWitnesses }],
|
|
84
83
|
});
|
|
85
84
|
}
|
|
86
85
|
|
|
@@ -109,9 +108,12 @@ export class BatchCall extends BaseContractInteraction {
|
|
|
109
108
|
for (let i = 0; i < utility.length; i++) {
|
|
110
109
|
const [call, resultIndex] = utility[i];
|
|
111
110
|
const wrappedResult = batchResults[i];
|
|
112
|
-
if (wrappedResult.name === '
|
|
113
|
-
const rawReturnValues = (wrappedResult.result as
|
|
114
|
-
results[resultIndex] =
|
|
111
|
+
if (wrappedResult.name === 'executeUtility') {
|
|
112
|
+
const rawReturnValues = (wrappedResult.result as UtilityExecutionResult).result;
|
|
113
|
+
results[resultIndex] = {
|
|
114
|
+
result: rawReturnValues ? decodeFromAbi(call.returnTypes, rawReturnValues) : [],
|
|
115
|
+
...emptyOffchainOutput(),
|
|
116
|
+
};
|
|
115
117
|
}
|
|
116
118
|
}
|
|
117
119
|
|
|
@@ -130,7 +132,10 @@ export class BatchCall extends BaseContractInteraction {
|
|
|
130
132
|
? simulatedTx.getPrivateReturnValues()?.nested?.[resultIndex].values
|
|
131
133
|
: simulatedTx.getPublicReturnValues()?.[resultIndex].values;
|
|
132
134
|
|
|
133
|
-
results[callIndex] =
|
|
135
|
+
results[callIndex] = {
|
|
136
|
+
result: rawReturnValues ? decodeFromAbi(call.returnTypes, rawReturnValues) : [],
|
|
137
|
+
...extractOffchainOutput(simulatedTx.offchainEffects),
|
|
138
|
+
};
|
|
134
139
|
});
|
|
135
140
|
}
|
|
136
141
|
}
|
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
type ABIParameter,
|
|
3
|
+
type AbiType,
|
|
4
|
+
type FunctionAbi,
|
|
5
|
+
FunctionCall,
|
|
6
|
+
FunctionSelector,
|
|
7
|
+
FunctionType,
|
|
8
|
+
canBeMappedFromNullOrUndefined,
|
|
9
|
+
decodeFromAbi,
|
|
10
|
+
encodeArguments,
|
|
11
|
+
isOptionStruct,
|
|
12
|
+
} from '@aztec/stdlib/abi';
|
|
2
13
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
3
14
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import {
|
|
15
|
+
import type { Capsule, HashedValues, TxProfileResult } from '@aztec/stdlib/tx';
|
|
5
16
|
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
6
17
|
|
|
7
18
|
import type { Wallet } from '../wallet/wallet.js';
|
|
@@ -11,7 +22,9 @@ import {
|
|
|
11
22
|
type ProfileInteractionOptions,
|
|
12
23
|
type RequestInteractionOptions,
|
|
13
24
|
type SimulateInteractionOptions,
|
|
14
|
-
type
|
|
25
|
+
type SimulationResult,
|
|
26
|
+
emptyOffchainOutput,
|
|
27
|
+
extractOffchainOutput,
|
|
15
28
|
toProfileOptions,
|
|
16
29
|
toSimulateOptions,
|
|
17
30
|
} from './interaction_options.js';
|
|
@@ -31,11 +44,32 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
31
44
|
private extraHashedArgs: HashedValues[] = [],
|
|
32
45
|
) {
|
|
33
46
|
super(wallet, authWitnesses, capsules);
|
|
34
|
-
|
|
35
|
-
|
|
47
|
+
// This may feel a bit ad-hoc here, so it warrants a comment. We accept Noir Option<T> parameters, and it's natural
|
|
48
|
+
// to map JS's null/undefined to Noir Option's None. One possible way to deal with null/undefined arguments at this
|
|
49
|
+
// point in the codebase is to conclude that they are accepted since at least one Noir type (ie: Option) can be
|
|
50
|
+
// encoded from them. Then we would let `encode` deal with potential mismatches. I chose not to do that because of
|
|
51
|
+
// the pervasiveness of null/undefined in JS, and how easy it is to inadvertently pass it around. Having this check
|
|
52
|
+
// here allows us to fail at a point where the boundaries and intent are clear.
|
|
53
|
+
if (this.hasInvalidNullOrUndefinedArguments(args)) {
|
|
54
|
+
const signature = formatFunctionSignature(this.functionDao.name, this.functionDao.parameters);
|
|
55
|
+
const received = args.map(formatArg).join(', ');
|
|
56
|
+
throw new Error(
|
|
57
|
+
`Null or undefined arguments are only allowed for Option<T> parameters in ${signature}. Received: (${received}).`,
|
|
58
|
+
);
|
|
36
59
|
}
|
|
37
60
|
}
|
|
38
61
|
|
|
62
|
+
private hasInvalidNullOrUndefinedArguments(args: any[]) {
|
|
63
|
+
return args.some((arg, index) => {
|
|
64
|
+
if (arg !== undefined && arg !== null) {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
const parameterType = this.functionDao.parameters[index]?.type;
|
|
69
|
+
return !parameterType || !canBeMappedFromNullOrUndefined(parameterType);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
|
|
39
73
|
/**
|
|
40
74
|
* Returns the encoded function call wrapped by this interaction
|
|
41
75
|
* Useful when generating authwits
|
|
@@ -43,16 +77,16 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
43
77
|
*/
|
|
44
78
|
public async getFunctionCall() {
|
|
45
79
|
const args = encodeArguments(this.functionDao, this.args);
|
|
46
|
-
return {
|
|
80
|
+
return FunctionCall.from({
|
|
47
81
|
name: this.functionDao.name,
|
|
48
|
-
|
|
82
|
+
to: this.contractAddress,
|
|
49
83
|
selector: await FunctionSelector.fromNameAndParameters(this.functionDao.name, this.functionDao.parameters),
|
|
50
84
|
type: this.functionDao.functionType,
|
|
51
|
-
to: this.contractAddress,
|
|
52
|
-
isStatic: this.functionDao.isStatic,
|
|
53
85
|
hideMsgSender: false /** Only set to `true` for enqueued public function calls */,
|
|
86
|
+
isStatic: this.functionDao.isStatic,
|
|
87
|
+
args,
|
|
54
88
|
returnTypes: this.functionDao.returnTypes,
|
|
55
|
-
};
|
|
89
|
+
});
|
|
56
90
|
}
|
|
57
91
|
|
|
58
92
|
/**
|
|
@@ -90,21 +124,16 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
90
124
|
* function or a rich object containing extra metadata, such as estimated gas costs (if requested via options),
|
|
91
125
|
* execution statistics and emitted offchain effects
|
|
92
126
|
*/
|
|
93
|
-
public async simulate<T extends SimulateInteractionOptions>(
|
|
94
|
-
options: T,
|
|
95
|
-
): Promise<SimulationReturn<Exclude<T['fee'], undefined>['estimateGas']>>;
|
|
96
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
97
|
-
public async simulate<T extends SimulateInteractionOptions>(
|
|
98
|
-
options: T,
|
|
99
|
-
): Promise<SimulationReturn<T['includeMetadata']>>;
|
|
100
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
101
127
|
public async simulate(
|
|
102
|
-
options: SimulateInteractionOptions,
|
|
103
|
-
): Promise<
|
|
128
|
+
options: SimulateInteractionOptions = {} as SimulateInteractionOptions,
|
|
129
|
+
): Promise<SimulationResult> {
|
|
104
130
|
// docs:end:simulate
|
|
105
131
|
if (this.functionDao.functionType == FunctionType.UTILITY) {
|
|
106
132
|
const call = await this.getFunctionCall();
|
|
107
|
-
const utilityResult = await this.wallet.
|
|
133
|
+
const utilityResult = await this.wallet.executeUtility(call, {
|
|
134
|
+
scope: options.from,
|
|
135
|
+
authWitnesses: options.authWitnesses,
|
|
136
|
+
});
|
|
108
137
|
|
|
109
138
|
// Decode the raw field elements to the actual return type
|
|
110
139
|
const returnValue = utilityResult.result ? decodeFromAbi(this.functionDao.returnTypes, utilityResult.result) : [];
|
|
@@ -112,11 +141,11 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
112
141
|
if (options.includeMetadata) {
|
|
113
142
|
return {
|
|
114
143
|
stats: utilityResult.stats,
|
|
144
|
+
...emptyOffchainOutput(),
|
|
115
145
|
result: returnValue,
|
|
116
146
|
};
|
|
117
|
-
} else {
|
|
118
|
-
return returnValue;
|
|
119
147
|
}
|
|
148
|
+
return { result: returnValue, ...emptyOffchainOutput() };
|
|
120
149
|
}
|
|
121
150
|
|
|
122
151
|
const executionPayload = await this.request(options);
|
|
@@ -138,6 +167,7 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
138
167
|
}
|
|
139
168
|
|
|
140
169
|
const returnValue = rawReturnValues ? decodeFromAbi(this.functionDao.returnTypes, rawReturnValues) : [];
|
|
170
|
+
const offchainOutput = extractOffchainOutput(simulatedTx.offchainEffects);
|
|
141
171
|
|
|
142
172
|
if (options.includeMetadata || options.fee?.estimateGas) {
|
|
143
173
|
const { gasLimits, teardownGasLimits } = getGasLimits(simulatedTx, options.fee?.estimatedGasPadding);
|
|
@@ -146,13 +176,12 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
146
176
|
);
|
|
147
177
|
return {
|
|
148
178
|
stats: simulatedTx.stats,
|
|
149
|
-
|
|
179
|
+
...offchainOutput,
|
|
150
180
|
result: returnValue,
|
|
151
181
|
estimatedGas: { gasLimits, teardownGasLimits },
|
|
152
182
|
};
|
|
153
|
-
} else {
|
|
154
|
-
return returnValue;
|
|
155
183
|
}
|
|
184
|
+
return { result: returnValue, ...offchainOutput };
|
|
156
185
|
}
|
|
157
186
|
|
|
158
187
|
/**
|
|
@@ -200,3 +229,62 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
200
229
|
);
|
|
201
230
|
}
|
|
202
231
|
}
|
|
232
|
+
|
|
233
|
+
/**
|
|
234
|
+
* Render an AbiType as a human readable string
|
|
235
|
+
* */
|
|
236
|
+
function formatAbiType(abiType: AbiType): string {
|
|
237
|
+
switch (abiType.kind) {
|
|
238
|
+
case 'field':
|
|
239
|
+
return 'Field';
|
|
240
|
+
case 'boolean':
|
|
241
|
+
return 'bool';
|
|
242
|
+
case 'integer':
|
|
243
|
+
return `${abiType.sign === 'signed' ? 'i' : 'u'}${abiType.width}`;
|
|
244
|
+
case 'string':
|
|
245
|
+
return `str<${abiType.length}>`;
|
|
246
|
+
case 'array':
|
|
247
|
+
return `[${formatAbiType(abiType.type)}; ${abiType.length}]`;
|
|
248
|
+
case 'struct': {
|
|
249
|
+
if (isOptionStruct(abiType)) {
|
|
250
|
+
const innerType = abiType.fields.find(f => f.name === '_value')!.type;
|
|
251
|
+
return `Option<${formatAbiType(innerType)}>`;
|
|
252
|
+
}
|
|
253
|
+
return `(${abiType.fields.map(f => `${f.name}: ${formatAbiType(f.type)}`).join(', ')})`;
|
|
254
|
+
}
|
|
255
|
+
case 'tuple':
|
|
256
|
+
return `(${abiType.fields.map(formatAbiType).join(', ')})`;
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Pretty print a function signature
|
|
262
|
+
*/
|
|
263
|
+
function formatFunctionSignature(name: string, parameters: ABIParameter[]): string {
|
|
264
|
+
const params = parameters.map(p => `${p.name}: ${formatAbiType(p.type)}`).join(', ');
|
|
265
|
+
return `${name}(${params})`;
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/**
|
|
269
|
+
* Non-exhaustive pretty print of JS args to display in error messages in this module
|
|
270
|
+
*/
|
|
271
|
+
function formatArg(arg: unknown): string {
|
|
272
|
+
if (arg === undefined) {
|
|
273
|
+
return 'undefined';
|
|
274
|
+
}
|
|
275
|
+
if (arg === null) {
|
|
276
|
+
return 'null';
|
|
277
|
+
}
|
|
278
|
+
if (typeof arg === 'bigint') {
|
|
279
|
+
return `${arg}n`;
|
|
280
|
+
}
|
|
281
|
+
if (Array.isArray(arg)) {
|
|
282
|
+
return `[${arg.map(formatArg).join(', ')}]`;
|
|
283
|
+
}
|
|
284
|
+
if (typeof arg === 'object') {
|
|
285
|
+
const entries = Object.entries(arg).map(([k, v]) => `${k}: ${formatArg(v)}`);
|
|
286
|
+
return `{ ${entries.join(', ')} }`;
|
|
287
|
+
}
|
|
288
|
+
// eslint-disable-next-line @typescript-eslint/no-base-to-string
|
|
289
|
+
return String(arg);
|
|
290
|
+
}
|
|
@@ -9,27 +9,50 @@ import {
|
|
|
9
9
|
getContractInstanceFromInstantiationParams,
|
|
10
10
|
} from '@aztec/stdlib/contract';
|
|
11
11
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
12
|
-
import { type Capsule, type TxProfileResult,
|
|
12
|
+
import { type Capsule, HashedValues, type TxProfileResult, type TxReceipt } from '@aztec/stdlib/tx';
|
|
13
13
|
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
14
14
|
|
|
15
15
|
import { publishContractClass } from '../deployment/publish_class.js';
|
|
16
16
|
import { publishInstance } from '../deployment/publish_instance.js';
|
|
17
|
-
import type { Wallet } from '../wallet/wallet.js';
|
|
17
|
+
import type { ProfileOptions, SendOptions, SimulateOptions, Wallet } from '../wallet/wallet.js';
|
|
18
18
|
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
19
19
|
import type { ContractBase } from './contract_base.js';
|
|
20
20
|
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
21
|
-
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
22
21
|
import { getGasLimits } from './get_gas_limits.js';
|
|
23
22
|
import {
|
|
23
|
+
NO_WAIT,
|
|
24
|
+
type NoWait,
|
|
25
|
+
type OffchainOutput,
|
|
24
26
|
type ProfileInteractionOptions,
|
|
25
27
|
type RequestInteractionOptions,
|
|
26
|
-
type
|
|
28
|
+
type SendInteractionOptionsWithoutWait,
|
|
27
29
|
type SimulationInteractionFeeOptions,
|
|
28
|
-
type
|
|
30
|
+
type SimulationResult,
|
|
31
|
+
type TxSendResultImmediate,
|
|
32
|
+
type TxSendResultMined,
|
|
33
|
+
extractOffchainOutput,
|
|
29
34
|
toProfileOptions,
|
|
30
35
|
toSendOptions,
|
|
31
36
|
toSimulateOptions,
|
|
32
37
|
} from './interaction_options.js';
|
|
38
|
+
import type { WaitOpts } from './wait_opts.js';
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Wait options specific to deployment transactions.
|
|
42
|
+
* Extends WaitOpts with a flag to return the full receipt instead of just the contract.
|
|
43
|
+
*/
|
|
44
|
+
export type DeployWaitOptions = WaitOpts & {
|
|
45
|
+
/** If true, return the full DeployTxReceipt instead of just the contract. Defaults to false. */
|
|
46
|
+
returnReceipt?: boolean;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Type for wait options in deployment interactions.
|
|
51
|
+
* - NO_WAIT symbol: Don't wait, return TxHash immediately
|
|
52
|
+
* - DeployWaitOptions: Wait with custom options
|
|
53
|
+
* - undefined: Wait with default options
|
|
54
|
+
*/
|
|
55
|
+
export type DeployInteractionWaitOptions = NoWait | DeployWaitOptions | undefined;
|
|
33
56
|
|
|
34
57
|
/**
|
|
35
58
|
* Options for deploying a contract on the Aztec network.
|
|
@@ -55,21 +78,34 @@ export type RequestDeployOptions = RequestInteractionOptions & {
|
|
|
55
78
|
};
|
|
56
79
|
|
|
57
80
|
/**
|
|
58
|
-
*
|
|
81
|
+
* Base deployment options without wait parameter.
|
|
59
82
|
*/
|
|
60
|
-
export type
|
|
83
|
+
export type DeployOptionsWithoutWait = Omit<RequestDeployOptions, 'deployer'> & {
|
|
61
84
|
/**
|
|
62
85
|
* Set to true to *not* include the sender in the address computation. This option
|
|
63
86
|
* is mutually exclusive with "deployer"
|
|
64
87
|
*/
|
|
65
88
|
universalDeploy?: boolean;
|
|
66
|
-
} & Pick<
|
|
89
|
+
} & Pick<SendInteractionOptionsWithoutWait, 'from' | 'fee' | 'additionalScopes'>;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Extends the deployment options with the required parameters to send the transaction.
|
|
93
|
+
*/
|
|
94
|
+
export type DeployOptions<W extends DeployInteractionWaitOptions = undefined> = DeployOptionsWithoutWait & {
|
|
95
|
+
/**
|
|
96
|
+
* Options for waiting for the transaction to be mined.
|
|
97
|
+
* - undefined (default): wait with default options and return the contract instance
|
|
98
|
+
* - DeployWaitOptions: wait with custom options and return contract or receipt based on returnReceipt flag
|
|
99
|
+
* - NO_WAIT: return TxHash immediately without waiting
|
|
100
|
+
*/
|
|
101
|
+
wait?: W;
|
|
102
|
+
};
|
|
67
103
|
|
|
68
104
|
/**
|
|
69
105
|
* Options for simulating the deployment of a contract
|
|
70
106
|
* Allows skipping certain validations and computing gas estimations
|
|
71
107
|
*/
|
|
72
|
-
export type SimulateDeployOptions = Omit<
|
|
108
|
+
export type SimulateDeployOptions = Omit<DeployOptionsWithoutWait, 'fee'> & {
|
|
73
109
|
/** The fee options for the transaction. */
|
|
74
110
|
fee?: SimulationInteractionFeeOptions;
|
|
75
111
|
/** Simulate without checking for the validity of the resulting transaction,
|
|
@@ -83,6 +119,41 @@ export type SimulateDeployOptions = Omit<DeployOptions, 'fee'> & {
|
|
|
83
119
|
includeMetadata?: boolean;
|
|
84
120
|
};
|
|
85
121
|
|
|
122
|
+
/** Receipt for a deployment transaction with the deployed contract instance. */
|
|
123
|
+
export type DeployTxReceipt<TContract extends ContractBase = ContractBase> = TxReceipt & {
|
|
124
|
+
/** Type-safe wrapper around the deployed contract instance, linked to the deployment wallet */
|
|
125
|
+
contract: TContract;
|
|
126
|
+
/** The deployed contract instance with address and metadata. */
|
|
127
|
+
instance: ContractInstanceWithAddress;
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
/** Wait options that request a full receipt instead of just the contract instance. */
|
|
131
|
+
type WaitWithReturnReceipt = {
|
|
132
|
+
/** Request the full receipt instead of just the contract instance. */
|
|
133
|
+
returnReceipt: true;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Represents the result type of deploying a contract.
|
|
138
|
+
* - If wait is NO_WAIT, returns TxHash immediately.
|
|
139
|
+
* - If wait has returnReceipt: true, returns DeployTxReceipt after waiting.
|
|
140
|
+
* - Otherwise (undefined or DeployWaitOptions without returnReceipt), returns TContract after waiting.
|
|
141
|
+
*/
|
|
142
|
+
/** Result of deploying a contract when waiting for mining (default case). */
|
|
143
|
+
export type DeployResultMined<TContract extends ContractBase> = {
|
|
144
|
+
/** The deployed contract instance. */
|
|
145
|
+
contract: TContract;
|
|
146
|
+
/** The deploy transaction receipt. */
|
|
147
|
+
receipt: DeployTxReceipt<TContract>;
|
|
148
|
+
} & OffchainOutput;
|
|
149
|
+
|
|
150
|
+
/** Conditional return type for deploy based on wait options. */
|
|
151
|
+
export type DeployReturn<TContract extends ContractBase, W extends DeployInteractionWaitOptions> = W extends NoWait
|
|
152
|
+
? TxSendResultImmediate
|
|
153
|
+
: W extends WaitWithReturnReceipt
|
|
154
|
+
? TxSendResultMined<DeployTxReceipt<TContract>>
|
|
155
|
+
: DeployResultMined<TContract>;
|
|
156
|
+
|
|
86
157
|
/**
|
|
87
158
|
* Contract interaction for deployment.
|
|
88
159
|
* Handles class publication, instance publication, and initialization of the contract.
|
|
@@ -92,8 +163,6 @@ export type SimulateDeployOptions = Omit<DeployOptions, 'fee'> & {
|
|
|
92
163
|
* then technically the contract has already been "created", and all of the contract's
|
|
93
164
|
* functions (private and utility) can be interacted-with immediately, without any
|
|
94
165
|
* "deployment tx".
|
|
95
|
-
*
|
|
96
|
-
* Extends the BaseContractInteraction class.
|
|
97
166
|
*/
|
|
98
167
|
export class DeployMethod<TContract extends ContractBase = ContractBase> extends BaseContractInteraction {
|
|
99
168
|
/** The contract instance to be deployed. */
|
|
@@ -111,6 +180,7 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
111
180
|
constructorNameOrArtifact?: string | FunctionArtifact,
|
|
112
181
|
authWitnesses: AuthWitness[] = [],
|
|
113
182
|
capsules: Capsule[] = [],
|
|
183
|
+
private extraHashedArgs: HashedValues[] = [],
|
|
114
184
|
) {
|
|
115
185
|
super(wallet, authWitnesses, capsules);
|
|
116
186
|
this.constructorArtifact = getInitializer(artifact, constructorNameOrArtifact);
|
|
@@ -121,20 +191,29 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
121
191
|
* @param options - Configuration options.
|
|
122
192
|
* @returns The execution payload for this operation
|
|
123
193
|
*/
|
|
124
|
-
public async request(options
|
|
194
|
+
public async request(options: RequestDeployOptions = {}): Promise<ExecutionPayload> {
|
|
125
195
|
const publication = await this.getPublicationExecutionPayload(options);
|
|
126
196
|
|
|
127
197
|
if (!options?.skipRegistration) {
|
|
128
198
|
await this.wallet.registerContract(await this.getInstance(options), this.artifact);
|
|
129
199
|
}
|
|
200
|
+
const { authWitnesses, capsules } = options;
|
|
130
201
|
|
|
202
|
+
// Propagates the included authwitnesses, capsules, and extraHashedArgs
|
|
203
|
+
// potentially baked into the interaction
|
|
204
|
+
const initialExecutionPayload = new ExecutionPayload(
|
|
205
|
+
[],
|
|
206
|
+
this.authWitnesses.concat(authWitnesses ?? []),
|
|
207
|
+
this.capsules.concat(capsules ?? []),
|
|
208
|
+
this.extraHashedArgs,
|
|
209
|
+
);
|
|
131
210
|
const initialization = await this.getInitializationExecutionPayload(options);
|
|
132
211
|
const feeExecutionPayload = options?.fee?.paymentMethod
|
|
133
212
|
? await options.fee.paymentMethod.getExecutionPayload()
|
|
134
213
|
: undefined;
|
|
135
214
|
const finalExecutionPayload = feeExecutionPayload
|
|
136
|
-
? mergeExecutionPayloads([feeExecutionPayload, publication, initialization])
|
|
137
|
-
: mergeExecutionPayloads([publication, initialization]);
|
|
215
|
+
? mergeExecutionPayloads([initialExecutionPayload, feeExecutionPayload, publication, initialization])
|
|
216
|
+
: mergeExecutionPayloads([initialExecutionPayload, publication, initialization]);
|
|
138
217
|
if (!finalExecutionPayload.calls.length) {
|
|
139
218
|
throw new Error(`No transactions are needed to publish or initialize contract ${this.artifact.name}`);
|
|
140
219
|
}
|
|
@@ -142,13 +221,48 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
142
221
|
return finalExecutionPayload;
|
|
143
222
|
}
|
|
144
223
|
|
|
145
|
-
convertDeployOptionsToRequestOptions(options:
|
|
224
|
+
convertDeployOptionsToRequestOptions(options: DeployOptionsWithoutWait): RequestDeployOptions {
|
|
146
225
|
return {
|
|
147
226
|
...options,
|
|
148
227
|
deployer: !options?.universalDeploy ? options.from : undefined,
|
|
149
228
|
};
|
|
150
229
|
}
|
|
151
230
|
|
|
231
|
+
/**
|
|
232
|
+
* Converts DeployOptions to SendOptions, stripping out the returnReceipt flag if present.
|
|
233
|
+
* @param options - Deploy options with wait parameter
|
|
234
|
+
* @returns Send options with wait parameter
|
|
235
|
+
*/
|
|
236
|
+
protected convertDeployOptionsToSendOptions<W extends DeployInteractionWaitOptions>(
|
|
237
|
+
options: DeployOptions<W>,
|
|
238
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
239
|
+
): SendOptions<W extends { returnReceipt: true } ? WaitOpts : W> {
|
|
240
|
+
return {
|
|
241
|
+
...toSendOptions({
|
|
242
|
+
...options,
|
|
243
|
+
wait: options.wait as any,
|
|
244
|
+
}),
|
|
245
|
+
} as any;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
/**
|
|
249
|
+
* Converts deploy simulation options into wallet-level simulate options.
|
|
250
|
+
* @param options - The deploy simulation options to convert.
|
|
251
|
+
*/
|
|
252
|
+
protected convertDeployOptionsToSimulateOptions(options: SimulateDeployOptions): SimulateOptions {
|
|
253
|
+
return toSimulateOptions(options);
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Converts deploy profile options into wallet-level profile options.
|
|
258
|
+
* @param options - The deploy profile options to convert.
|
|
259
|
+
*/
|
|
260
|
+
protected convertDeployOptionsToProfileOptions(
|
|
261
|
+
options: DeployOptionsWithoutWait & ProfileInteractionOptions,
|
|
262
|
+
): ProfileOptions {
|
|
263
|
+
return toProfileOptions(options);
|
|
264
|
+
}
|
|
265
|
+
|
|
152
266
|
/**
|
|
153
267
|
* Adds this contract to the wallet and returns the Contract object.
|
|
154
268
|
* @param options - Deployment options.
|
|
@@ -184,16 +298,17 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
184
298
|
|
|
185
299
|
// Publish the contract class if it hasn't been published already.
|
|
186
300
|
if (!options?.skipClassPublication) {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
`Skipping publication of already-registered contract class ${contractClass.id.toString()} for ${instance.address.toString()}`,
|
|
190
|
-
);
|
|
191
|
-
} else {
|
|
301
|
+
const classMetadata = await this.wallet.getContractClassMetadata(contractClass.id);
|
|
302
|
+
if (!classMetadata.isContractClassPubliclyRegistered) {
|
|
192
303
|
this.log.info(
|
|
193
304
|
`Creating request for publishing contract class ${contractClass.id.toString()} as part of deployment for ${instance.address.toString()}`,
|
|
194
305
|
);
|
|
195
306
|
const registerContractClassInteraction = await publishContractClass(this.wallet, this.artifact);
|
|
196
307
|
calls.push(await registerContractClassInteraction.request());
|
|
308
|
+
} else {
|
|
309
|
+
this.log.debug(
|
|
310
|
+
`Skipping contract class publication for ${contractClass.id.toString()} as it is already registered`,
|
|
311
|
+
);
|
|
197
312
|
}
|
|
198
313
|
}
|
|
199
314
|
|
|
@@ -202,7 +317,7 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
202
317
|
// TODO(https://github.com/AztecProtocol/aztec-packages/issues/15596):
|
|
203
318
|
// Read the artifact, and if there are no public functions, warn the caller that publication of the
|
|
204
319
|
// contract instance is not necessary (until such time as they wish to update the instance (i.e. change its class_id)).
|
|
205
|
-
const deploymentInteraction =
|
|
320
|
+
const deploymentInteraction = publishInstance(this.wallet, instance);
|
|
206
321
|
calls.push(await deploymentInteraction.request());
|
|
207
322
|
}
|
|
208
323
|
|
|
@@ -231,20 +346,44 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
231
346
|
|
|
232
347
|
/**
|
|
233
348
|
* Send a contract deployment transaction (initialize and/or publish) using the provided options.
|
|
234
|
-
*
|
|
235
|
-
* allowing us to send a transaction specifically for contract deployment.
|
|
349
|
+
* By default, waits for the transaction to be mined and returns the deployed contract instance.
|
|
236
350
|
*
|
|
237
351
|
* @param options - An object containing various deployment options such as contractAddressSalt and from.
|
|
238
|
-
* @returns
|
|
352
|
+
* @returns TxHash (if wait is NO_WAIT), TContract (if wait is undefined or doesn't have returnReceipt), or DeployTxReceipt (if wait.returnReceipt is true)
|
|
239
353
|
*/
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
354
|
+
// Overload for when wait is not specified at all - returns the contract
|
|
355
|
+
public override send(options: DeployOptionsWithoutWait): Promise<DeployResultMined<TContract>>;
|
|
356
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
357
|
+
public override send<W extends DeployInteractionWaitOptions>(
|
|
358
|
+
options: DeployOptions<W>,
|
|
359
|
+
): Promise<DeployReturn<TContract, W>>;
|
|
360
|
+
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
361
|
+
public override async send(options: DeployOptions<DeployInteractionWaitOptions>): Promise<any> {
|
|
362
|
+
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
363
|
+
const sendOptions = this.convertDeployOptionsToSendOptions(options);
|
|
364
|
+
|
|
365
|
+
if (options.wait === NO_WAIT) {
|
|
366
|
+
const result = await this.wallet.sendTx(executionPayload, sendOptions as SendOptions<NoWait>);
|
|
367
|
+
this.log.debug(`Sent deployment tx ${result.txHash.hash} of ${this.artifact.name} contract`);
|
|
368
|
+
return result;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
const { receipt, ...offchainOutput } = await this.wallet.sendTx(
|
|
372
|
+
executionPayload,
|
|
373
|
+
sendOptions as SendOptions<WaitOpts | undefined>,
|
|
374
|
+
);
|
|
375
|
+
this.log.debug(`Deployed ${this.artifact.name} contract in tx ${receipt.txHash}`);
|
|
376
|
+
|
|
377
|
+
// Attach contract instance
|
|
378
|
+
const instance = await this.getInstance(options);
|
|
379
|
+
const contract = this.postDeployCtor(instance, this.wallet) as TContract;
|
|
380
|
+
|
|
381
|
+
// Return full receipt if requested, otherwise just the contract
|
|
382
|
+
if (options.wait && typeof options.wait === 'object' && options.wait.returnReceipt) {
|
|
383
|
+
return { receipt: { ...receipt, contract, instance }, ...offchainOutput };
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
return { contract, receipt, ...offchainOutput };
|
|
248
387
|
}
|
|
249
388
|
|
|
250
389
|
/**
|
|
@@ -273,9 +412,12 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
273
412
|
* @returns A simulation result object containing metadata of the execution, including gas
|
|
274
413
|
* estimations (if requested via options), execution statistics and emitted offchain effects
|
|
275
414
|
*/
|
|
276
|
-
public async simulate(options: SimulateDeployOptions): Promise<
|
|
415
|
+
public async simulate(options: SimulateDeployOptions): Promise<SimulationResult> {
|
|
277
416
|
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
278
|
-
const simulatedTx = await this.wallet.simulateTx(
|
|
417
|
+
const simulatedTx = await this.wallet.simulateTx(
|
|
418
|
+
executionPayload,
|
|
419
|
+
this.convertDeployOptionsToSimulateOptions(options),
|
|
420
|
+
);
|
|
279
421
|
|
|
280
422
|
const { gasLimits, teardownGasLimits } = getGasLimits(simulatedTx, options.fee?.estimatedGasPadding);
|
|
281
423
|
this.log.verbose(
|
|
@@ -283,7 +425,7 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
283
425
|
);
|
|
284
426
|
return {
|
|
285
427
|
stats: simulatedTx.stats!,
|
|
286
|
-
|
|
428
|
+
...extractOffchainOutput(simulatedTx.offchainEffects),
|
|
287
429
|
result: undefined,
|
|
288
430
|
estimatedGas: { gasLimits, teardownGasLimits },
|
|
289
431
|
};
|
|
@@ -295,13 +437,9 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
295
437
|
*
|
|
296
438
|
* @returns An object containing the function return value and profile result.
|
|
297
439
|
*/
|
|
298
|
-
public async profile(options:
|
|
440
|
+
public async profile(options: DeployOptionsWithoutWait & ProfileInteractionOptions): Promise<TxProfileResult> {
|
|
299
441
|
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
300
|
-
return await this.wallet.profileTx(executionPayload,
|
|
301
|
-
...toProfileOptions(options),
|
|
302
|
-
profileMode: options.profileMode,
|
|
303
|
-
skipProofGeneration: options.skipProofGeneration,
|
|
304
|
-
});
|
|
442
|
+
return await this.wallet.profileTx(executionPayload, this.convertDeployOptionsToProfileOptions(options));
|
|
305
443
|
}
|
|
306
444
|
|
|
307
445
|
/** Return this deployment address. */
|