@aztec/aztec.js 0.80.0 → 0.82.0
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/{contract.d.ts → account_contract.d.ts} +11 -5
- package/dest/account/account_contract.d.ts.map +1 -0
- package/dest/account/{contract.js → account_contract.js} +5 -1
- package/dest/account/index.d.ts +2 -3
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +1 -2
- package/dest/account/interface.d.ts +1 -13
- package/dest/account/interface.d.ts.map +1 -1
- package/dest/account/interface.js +1 -0
- package/dest/account_manager/account_manager.d.ts +105 -0
- package/dest/account_manager/account_manager.d.ts.map +1 -0
- package/dest/account_manager/account_manager.js +165 -0
- package/dest/account_manager/deploy_account_method.d.ts +4 -4
- package/dest/account_manager/deploy_account_method.d.ts.map +1 -1
- package/dest/account_manager/deploy_account_method.js +28 -13
- package/dest/account_manager/deploy_account_sent_tx.d.ts +3 -3
- package/dest/account_manager/deploy_account_sent_tx.d.ts.map +1 -1
- package/dest/account_manager/deploy_account_sent_tx.js +2 -2
- package/dest/account_manager/index.d.ts +1 -104
- package/dest/account_manager/index.d.ts.map +1 -1
- package/dest/account_manager/index.js +1 -157
- package/dest/api/account.d.ts +2 -1
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/contract.d.ts +4 -1
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +3 -0
- package/dest/api/fee.d.ts +1 -1
- package/dest/api/fee.d.ts.map +1 -1
- package/dest/api/utils.d.ts +2 -1
- package/dest/api/utils.d.ts.map +1 -1
- package/dest/api/utils.js +2 -1
- package/dest/api/wallet.d.ts +1 -1
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.d.ts +22 -57
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +12 -67
- package/dest/contract/batch_call.d.ts +6 -18
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +25 -54
- package/dest/contract/contract.d.ts +1 -1
- package/dest/contract/contract.d.ts.map +1 -1
- package/dest/contract/contract_base.d.ts +2 -2
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.d.ts +38 -18
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +34 -41
- package/dest/contract/deploy_method.d.ts +7 -8
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +27 -32
- package/dest/contract/deploy_proven_tx.d.ts +2 -3
- package/dest/contract/deploy_proven_tx.d.ts.map +1 -1
- package/dest/contract/deploy_sent_tx.d.ts +2 -3
- package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
- package/dest/contract/deploy_sent_tx.js +4 -4
- package/dest/contract/protocol_contracts.d.ts +1 -1
- package/dest/contract/protocol_contracts.d.ts.map +1 -1
- package/dest/contract/proven_tx.d.ts +3 -4
- package/dest/contract/proven_tx.d.ts.map +1 -1
- package/dest/contract/sent_tx.d.ts +4 -16
- package/dest/contract/sent_tx.d.ts.map +1 -1
- package/dest/contract/sent_tx.js +6 -37
- package/dest/contract/unsafe_contract.d.ts +1 -1
- package/dest/contract/unsafe_contract.d.ts.map +1 -1
- package/dest/contract/wait_for_proven.d.ts +17 -0
- package/dest/contract/wait_for_proven.d.ts.map +1 -0
- package/dest/contract/wait_for_proven.js +17 -0
- package/dest/deployment/broadcast_function.js +12 -8
- package/dest/deployment/contract_deployer.d.ts +1 -1
- package/dest/deployment/contract_deployer.d.ts.map +1 -1
- package/dest/deployment/register_class.d.ts +1 -1
- package/dest/deployment/register_class.d.ts.map +1 -1
- package/dest/deployment/register_class.js +6 -11
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts +3 -2
- package/dest/entrypoint/default_multi_call_entrypoint.d.ts.map +1 -1
- package/dest/entrypoint/default_multi_call_entrypoint.js +12 -8
- package/dest/ethereum/portal_manager.d.ts +20 -11
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +64 -30
- package/dest/fee/fee_juice_payment_method.d.ts +3 -3
- package/dest/fee/fee_juice_payment_method.d.ts.map +1 -1
- package/dest/fee/fee_juice_payment_method.js +3 -2
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts +4 -4
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
- package/dest/fee/fee_juice_payment_method_with_claim.js +6 -5
- package/dest/fee/private_fee_payment_method.d.ts +6 -6
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +13 -12
- package/dest/fee/public_fee_payment_method.d.ts +7 -7
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +10 -11
- package/dest/fee/utils.d.ts +13 -0
- package/dest/fee/utils.d.ts.map +1 -0
- package/dest/fee/utils.js +32 -0
- package/dest/index.d.ts +1 -1
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +1 -1
- package/dest/test/aztec_cheat_codes.d.ts +2 -2
- package/dest/test/aztec_cheat_codes.d.ts.map +1 -1
- package/dest/test/aztec_cheat_codes.js +3 -3
- package/dest/utils/authwit.d.ts +16 -9
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +26 -35
- package/dest/wallet/account_wallet.d.ts +6 -6
- package/dest/wallet/account_wallet.d.ts.map +1 -1
- package/dest/wallet/account_wallet.js +15 -17
- package/dest/wallet/base_wallet.d.ts +12 -35
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +11 -64
- package/dest/wallet/index.d.ts +2 -2
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +1 -1
- package/dest/wallet/signerless_wallet.d.ts +3 -3
- package/dest/wallet/signerless_wallet.d.ts.map +1 -1
- package/dest/wallet/signerless_wallet.js +3 -6
- package/dest/wallet/wallet.d.ts +11 -0
- package/dest/wallet/wallet.d.ts.map +1 -0
- package/package.json +8 -7
- package/src/account/{contract.ts → account_contract.ts} +17 -4
- package/src/account/index.ts +2 -3
- package/src/account/interface.ts +1 -12
- package/src/account_manager/account_manager.ts +235 -0
- package/src/account_manager/deploy_account_method.ts +35 -15
- package/src/account_manager/deploy_account_sent_tx.ts +4 -4
- package/src/account_manager/index.ts +1 -227
- package/src/api/account.ts +2 -8
- package/src/api/contract.ts +5 -5
- package/src/api/fee.ts +1 -1
- package/src/api/utils.ts +1 -1
- package/src/api/wallet.ts +7 -1
- package/src/contract/base_contract_interaction.ts +32 -88
- package/src/contract/batch_call.ts +40 -43
- package/src/contract/contract.ts +1 -1
- package/src/contract/contract_base.ts +1 -1
- package/src/contract/contract_function_interaction.ts +85 -56
- package/src/contract/deploy_method.ts +24 -26
- package/src/contract/deploy_proven_tx.ts +2 -3
- package/src/contract/deploy_sent_tx.ts +6 -6
- package/src/contract/protocol_contracts.ts +1 -1
- package/src/contract/proven_tx.ts +2 -3
- package/src/contract/sent_tx.ts +6 -47
- package/src/contract/unsafe_contract.ts +1 -1
- package/src/contract/wait_for_proven.ts +38 -0
- package/src/deployment/broadcast_function.ts +40 -40
- package/src/deployment/contract_deployer.ts +1 -1
- package/src/deployment/register_class.ts +9 -22
- package/src/entrypoint/default_multi_call_entrypoint.ts +14 -7
- package/src/ethereum/portal_manager.ts +73 -24
- package/src/fee/fee_juice_payment_method.ts +4 -5
- package/src/fee/fee_juice_payment_method_with_claim.ts +24 -20
- package/src/fee/private_fee_payment_method.ts +29 -28
- package/src/fee/public_fee_payment_method.ts +29 -29
- package/src/fee/utils.ts +39 -0
- package/src/index.ts +1 -1
- package/src/test/aztec_cheat_codes.ts +3 -3
- package/src/utils/authwit.ts +32 -35
- package/src/wallet/account_wallet.ts +18 -17
- package/src/wallet/base_wallet.ts +27 -88
- package/src/wallet/index.ts +2 -2
- package/src/wallet/signerless_wallet.ts +9 -8
- package/src/wallet/wallet.ts +34 -0
- package/dest/account/contract.d.ts.map +0 -1
- package/dest/account/wallet.d.ts +0 -11
- package/dest/account/wallet.d.ts.map +0 -1
- package/dest/api/entrypoint.d.ts +0 -2
- package/dest/api/entrypoint.d.ts.map +0 -1
- package/dest/api/entrypoint.js +0 -1
- package/dest/entrypoint/default_entrypoint.d.ts +0 -12
- package/dest/entrypoint/default_entrypoint.d.ts.map +0 -1
- package/dest/entrypoint/default_entrypoint.js +0 -28
- package/dest/entrypoint/entrypoint.d.ts +0 -39
- package/dest/entrypoint/entrypoint.d.ts.map +0 -1
- package/dest/entrypoint/entrypoint.js +0 -20
- package/dest/entrypoint/payload.d.ts +0 -128
- package/dest/entrypoint/payload.d.ts.map +0 -1
- package/dest/entrypoint/payload.js +0 -143
- package/dest/fee/fee_payment_method.d.ts +0 -22
- package/dest/fee/fee_payment_method.d.ts.map +0 -1
- package/dest/fee/fee_payment_method.js +0 -3
- package/src/account/wallet.ts +0 -13
- package/src/api/entrypoint.ts +0 -1
- package/src/entrypoint/default_entrypoint.ts +0 -39
- package/src/entrypoint/entrypoint.ts +0 -60
- package/src/entrypoint/payload.ts +0 -238
- package/src/fee/fee_payment_method.ts +0 -22
- /package/dest/{account → wallet}/wallet.js +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
+
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/entrypoints/payload';
|
|
1
2
|
import { FunctionType, decodeFromAbi } from '@aztec/stdlib/abi';
|
|
2
|
-
import { mergeExecutionRequestInits } from '../entrypoint/entrypoint.js';
|
|
3
3
|
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
4
4
|
/** A batch of function calls to be sent as a single transaction through a wallet. */ export class BatchCall extends BaseContractInteraction {
|
|
5
5
|
calls;
|
|
@@ -13,27 +13,24 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
13
13
|
* @returns A Promise that resolves to a transaction instance.
|
|
14
14
|
*/ async create(options = {}) {
|
|
15
15
|
const requestWithoutFee = await this.request(options);
|
|
16
|
-
const { fee: userFee } = options;
|
|
17
|
-
const fee = await this.getFeeOptions({
|
|
18
|
-
|
|
19
|
-
|
|
16
|
+
const { fee: userFee, nonce, cancellable } = options;
|
|
17
|
+
const fee = await this.getFeeOptions(requestWithoutFee, userFee, {
|
|
18
|
+
nonce,
|
|
19
|
+
cancellable
|
|
20
20
|
});
|
|
21
|
-
return await this.wallet.createTxExecutionRequest({
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
return await this.wallet.createTxExecutionRequest(requestWithoutFee, fee, {
|
|
22
|
+
nonce,
|
|
23
|
+
cancellable
|
|
24
24
|
});
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Returns an execution request that represents this operation.
|
|
28
|
-
* @param options - An optional object containing additional configuration for the
|
|
29
|
-
* @returns An execution
|
|
28
|
+
* @param options - An optional object containing additional configuration for the request generation.
|
|
29
|
+
* @returns An execution payload wrapped in promise.
|
|
30
30
|
*/ async request(options = {}) {
|
|
31
31
|
const requests = await this.getRequests();
|
|
32
|
-
const
|
|
33
|
-
return
|
|
34
|
-
nonce,
|
|
35
|
-
cancellable
|
|
36
|
-
});
|
|
32
|
+
const combinedPayload = mergeExecutionPayloads(requests);
|
|
33
|
+
return new ExecutionPayload(combinedPayload.calls, combinedPayload.authWitnesses.concat(options.authWitnesses ?? []), combinedPayload.capsules.concat(options.capsules ?? []), combinedPayload.extraHashedArgs);
|
|
37
34
|
}
|
|
38
35
|
/**
|
|
39
36
|
* Simulate a transaction and get its return values
|
|
@@ -44,7 +41,7 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
44
41
|
* @param options - An optional object containing additional configuration for the transaction.
|
|
45
42
|
* @returns The result of the transaction as returned by the contract function.
|
|
46
43
|
*/ async simulate(options = {}) {
|
|
47
|
-
const {
|
|
44
|
+
const { indexedExecutionPayloads, unconstrained } = (await this.getRequests()).reduce((acc, current, index)=>{
|
|
48
45
|
const call = current.calls[0];
|
|
49
46
|
if (call.type === FunctionType.UNCONSTRAINED) {
|
|
50
47
|
acc.unconstrained.push([
|
|
@@ -52,7 +49,7 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
52
49
|
index
|
|
53
50
|
]);
|
|
54
51
|
} else {
|
|
55
|
-
acc.
|
|
52
|
+
acc.indexedExecutionPayloads.push([
|
|
56
53
|
current,
|
|
57
54
|
index,
|
|
58
55
|
call.type === FunctionType.PRIVATE ? acc.privateIndex++ : acc.publicIndex++
|
|
@@ -60,24 +57,22 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
60
57
|
}
|
|
61
58
|
return acc;
|
|
62
59
|
}, {
|
|
63
|
-
|
|
60
|
+
indexedExecutionPayloads: [],
|
|
64
61
|
unconstrained: [],
|
|
65
62
|
publicIndex: 0,
|
|
66
63
|
privateIndex: 0
|
|
67
64
|
});
|
|
68
|
-
const
|
|
69
|
-
const
|
|
70
|
-
const
|
|
71
|
-
const fee =
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
...requestWithoutFee,
|
|
77
|
-
fee
|
|
65
|
+
const payloads = indexedExecutionPayloads.map(([request])=>request);
|
|
66
|
+
const combinedPayload = mergeExecutionPayloads(payloads);
|
|
67
|
+
const requestWithoutFee = new ExecutionPayload(combinedPayload.calls, combinedPayload.authWitnesses.concat(options.authWitnesses ?? []), combinedPayload.capsules.concat(options.capsules ?? []), combinedPayload.extraHashedArgs);
|
|
68
|
+
const { fee: userFee, nonce, cancellable } = options;
|
|
69
|
+
const fee = await this.getFeeOptions(requestWithoutFee, userFee, {});
|
|
70
|
+
const txRequest = await this.wallet.createTxExecutionRequest(requestWithoutFee, fee, {
|
|
71
|
+
nonce,
|
|
72
|
+
cancellable
|
|
78
73
|
});
|
|
79
74
|
const unconstrainedCalls = unconstrained.map(async ([call, index])=>[
|
|
80
|
-
await this.wallet.simulateUnconstrained(call.name, call.args, call.to, options?.from),
|
|
75
|
+
await this.wallet.simulateUnconstrained(call.name, call.args, call.to, options?.authWitnesses, options?.from),
|
|
81
76
|
index
|
|
82
77
|
]);
|
|
83
78
|
const [unconstrainedResults, simulatedTx] = await Promise.all([
|
|
@@ -88,7 +83,7 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
88
83
|
unconstrainedResults.forEach(([result, index])=>{
|
|
89
84
|
results[index] = result;
|
|
90
85
|
});
|
|
91
|
-
|
|
86
|
+
indexedExecutionPayloads.forEach(([request, callIndex, resultIndex])=>{
|
|
92
87
|
const call = request.calls[0];
|
|
93
88
|
// As account entrypoints are private, for private functions we retrieve the return values from the first nested call
|
|
94
89
|
// since we're interested in the first set of values AFTER the account entrypoint
|
|
@@ -98,30 +93,6 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
98
93
|
});
|
|
99
94
|
return results;
|
|
100
95
|
}
|
|
101
|
-
/**
|
|
102
|
-
* Return all authWitnesses added for this interaction.
|
|
103
|
-
*/ getAuthWitnesses() {
|
|
104
|
-
return [
|
|
105
|
-
this.authWitnesses,
|
|
106
|
-
...this.calls.map((c)=>c.getAuthWitnesses())
|
|
107
|
-
].flat();
|
|
108
|
-
}
|
|
109
|
-
/**
|
|
110
|
-
* Return all hashedArguments added for this interaction.
|
|
111
|
-
*/ getHashedArguments() {
|
|
112
|
-
return [
|
|
113
|
-
this.hashedArguments,
|
|
114
|
-
...this.calls.map((c)=>c.getHashedArguments())
|
|
115
|
-
].flat();
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Return all capsules added for this interaction.
|
|
119
|
-
*/ getCapsules() {
|
|
120
|
-
return [
|
|
121
|
-
this.capsules,
|
|
122
|
-
...this.calls.map((c)=>c.getCapsules())
|
|
123
|
-
].flat();
|
|
124
|
-
}
|
|
125
96
|
async getRequests() {
|
|
126
97
|
return await Promise.all(this.calls.map((c)=>c.request()));
|
|
127
98
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
4
|
-
import type { Wallet } from '../
|
|
4
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
5
5
|
import { ContractBase } from './contract_base.js';
|
|
6
6
|
import { DeployMethod } from './deploy_method.js';
|
|
7
7
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/contract/contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/contract/contract.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAElD;;;;;;GAMG;AACH,qBAAa,QAAS,SAAQ,YAAY;IACxC;;;;;;OAMG;WACiB,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,CAAC;IAc5G;;;;;;OAMG;WACW,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,eAAe,CAAC,EAAE,MAAM;IAKtG;;;;;;;OAOG;WACW,oBAAoB,CAChC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,EAC1B,IAAI,EAAE,GAAG,EAAE,EACX,eAAe,CAAC,EAAE,MAAM;CAK3B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type ContractArtifact, type ContractNote, type FieldLayout, FunctionSelector } from '@aztec/stdlib/abi';
|
|
2
2
|
import { type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
|
-
import type { Wallet } from '../
|
|
3
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
4
4
|
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
5
5
|
/**
|
|
6
6
|
* Type representing a contract method that returns a ContractFunctionInteraction instance
|
|
@@ -48,7 +48,7 @@ export declare class ContractBase {
|
|
|
48
48
|
/** The wallet used for interacting with this contract. */
|
|
49
49
|
wallet: Wallet);
|
|
50
50
|
/** Address of the contract. */
|
|
51
|
-
get address(): import("
|
|
51
|
+
get address(): import("../index.js").AztecAddress;
|
|
52
52
|
/** Partial address of the contract. */
|
|
53
53
|
get partialAddress(): Promise<import("@aztec/foundation/schemas").Fr>;
|
|
54
54
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract_base.d.ts","sourceRoot":"","sources":["../../src/contract/contract_base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,YAAY,EACjB,KAAK,WAAW,EAEhB,gBAAgB,EAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,KAAK,2BAA2B,EAAyB,MAAM,wBAAwB,CAAC;AAEjG,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"contract_base.d.ts","sourceRoot":"","sources":["../../src/contract/contract_base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,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@@
|
|
|
1
|
+
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
1
2
|
import { type FunctionAbi } from '@aztec/stdlib/abi';
|
|
3
|
+
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
2
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type
|
|
6
|
-
import type { ExecutionRequestInit } from '../entrypoint/entrypoint.js';
|
|
7
|
-
import { BaseContractInteraction, type SendMethodOptions } from './base_contract_interaction.js';
|
|
5
|
+
import type { Capsule, HashedValues, TxExecutionRequest, TxProfileResult } from '@aztec/stdlib/tx';
|
|
6
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
7
|
+
import { BaseContractInteraction, type RequestMethodOptions, type SendMethodOptions } from './base_contract_interaction.js';
|
|
8
8
|
export type { SendMethodOptions };
|
|
9
9
|
/**
|
|
10
10
|
* Represents the options for simulating a contract function interaction.
|
|
11
11
|
* Allows specifying the address from which the view method should be called.
|
|
12
12
|
* Disregarded for simulation of public functions
|
|
13
13
|
*/
|
|
14
|
-
export type
|
|
14
|
+
export type ProfileMethodOptions = Pick<SendMethodOptions, 'authWitnesses' | 'capsules' | 'fee' | 'nonce' | 'cancellable'> & {
|
|
15
|
+
/** Whether to return gates information or the bytecode/witnesses. */
|
|
16
|
+
profileMode: 'gates' | 'execution-steps' | 'full';
|
|
17
|
+
/** The sender's Aztec address. */
|
|
18
|
+
from?: AztecAddress;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Represents the options for simulating a contract function interaction.
|
|
22
|
+
* Allows specifying the address from which the method should be called.
|
|
23
|
+
* Disregarded for simulation of public functions
|
|
24
|
+
*/
|
|
25
|
+
export type SimulateMethodOptions = Pick<SendMethodOptions, 'authWitnesses' | 'capsules' | 'fee' | 'nonce' | 'cancellable'> & {
|
|
15
26
|
/** The sender's Aztec address. */
|
|
16
27
|
from?: AztecAddress;
|
|
17
28
|
/** Simulate without checking for the validity of the resulting transaction, e.g. whether it emits any existing nullifiers. */
|
|
@@ -19,13 +30,6 @@ export type SimulateMethodOptions = Pick<SendMethodOptions, 'fee'> & {
|
|
|
19
30
|
/** Whether to ensure the fee payer is not empty and has enough balance to pay for the fee. */
|
|
20
31
|
skipFeeEnforcement?: boolean;
|
|
21
32
|
};
|
|
22
|
-
/**
|
|
23
|
-
* The result of a profile() call.
|
|
24
|
-
*/
|
|
25
|
-
export type ProfileResult = PrivateKernelProverProfileResult & {
|
|
26
|
-
/** The result of the transaction as returned by the contract function. */
|
|
27
|
-
returnValues: any;
|
|
28
|
-
};
|
|
29
33
|
/**
|
|
30
34
|
* This is the class that is returned when calling e.g. `contract.methods.myMethod(arg0, arg1)`.
|
|
31
35
|
* It contains available interactions one can call on a method, including view.
|
|
@@ -34,7 +38,8 @@ export declare class ContractFunctionInteraction extends BaseContractInteraction
|
|
|
34
38
|
protected contractAddress: AztecAddress;
|
|
35
39
|
protected functionDao: FunctionAbi;
|
|
36
40
|
protected args: any[];
|
|
37
|
-
|
|
41
|
+
private extraHashedArgs;
|
|
42
|
+
constructor(wallet: Wallet, contractAddress: AztecAddress, functionDao: FunctionAbi, args: any[], authWitnesses?: AuthWitness[], capsules?: Capsule[], extraHashedArgs?: HashedValues[]);
|
|
38
43
|
/**
|
|
39
44
|
* Create a transaction execution request that represents this call, encoded and authenticated by the
|
|
40
45
|
* user's wallet, ready to be simulated.
|
|
@@ -45,10 +50,10 @@ export declare class ContractFunctionInteraction extends BaseContractInteraction
|
|
|
45
50
|
/**
|
|
46
51
|
* Returns an execution request that represents this operation.
|
|
47
52
|
* Can be used as a building block for constructing batch requests.
|
|
48
|
-
* @param options - An optional object containing additional configuration for the
|
|
49
|
-
* @returns An execution
|
|
53
|
+
* @param options - An optional object containing additional configuration for the request generation.
|
|
54
|
+
* @returns An execution payload wrapped in promise.
|
|
50
55
|
*/
|
|
51
|
-
request(options?:
|
|
56
|
+
request(options?: RequestMethodOptions): Promise<ExecutionPayload>;
|
|
52
57
|
/**
|
|
53
58
|
* Simulate a transaction and get its return values
|
|
54
59
|
* Differs from prove in a few important ways:
|
|
@@ -65,6 +70,21 @@ export declare class ContractFunctionInteraction extends BaseContractInteraction
|
|
|
65
70
|
*
|
|
66
71
|
* @returns An object containing the function return value and profile result.
|
|
67
72
|
*/
|
|
68
|
-
|
|
73
|
+
profile(options?: ProfileMethodOptions): Promise<TxProfileResult>;
|
|
74
|
+
/**
|
|
75
|
+
* Augments this ContractFunctionInteraction with additional metadata, such as authWitnesses, capsules, and extraHashedArgs.
|
|
76
|
+
* This is useful when creating a "batteries included" interaction, such as registering a contract class with its associated
|
|
77
|
+
* capsule instead of having the user provide them externally.
|
|
78
|
+
* @param options - An object containing the metadata to add to the interaction
|
|
79
|
+
* @returns A new ContractFunctionInteraction with the added metadata, but calling the same original function in the same manner
|
|
80
|
+
*/
|
|
81
|
+
with({ authWitnesses, capsules, extraHashedArgs, }: {
|
|
82
|
+
/** The authWitnesses to add to the interaction */
|
|
83
|
+
authWitnesses?: AuthWitness[];
|
|
84
|
+
/** The capsules to add to the interaction */
|
|
85
|
+
capsules?: Capsule[];
|
|
86
|
+
/** The extra hashed args to add to the interaction */
|
|
87
|
+
extraHashedArgs?: HashedValues[];
|
|
88
|
+
}): ContractFunctionInteraction;
|
|
69
89
|
}
|
|
70
90
|
//# sourceMappingURL=contract_function_interaction.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract_function_interaction.d.ts","sourceRoot":"","sources":["../../src/contract/contract_function_interaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"contract_function_interaction.d.ts","sourceRoot":"","sources":["../../src/contract/contract_function_interaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,KAAK,WAAW,EAAkE,MAAM,mBAAmB,CAAC;AACrH,OAAO,KAAK,EA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AAI,EAAE,GAAG,EAAE,EACrB,aAAa,GAAE,WAAW,EAAO,EACjC,QAAQ,GAAE,OAAO,EAAO,EAChB,eAAe,GAAE,YAAY,EAAO;IAS9C;;;;;OAKG;IACU,MAAM,CAAC,OAAO,GAAE,iBAAsB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IAcjF;;;;;OAKG;IACU,OAAO,CAAC,OAAO,GAAE,oBAAyB,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAwBnF;;;;;;;;OAQG;IACU,QAAQ,CAAC,OAAO,GAAE,qBAA0B,GAAG,OAAO,CAAC,GAAG,CAAC;IAuCxE;;;;;OAKG;IACU,OAAO,CAAC,OAAO,GAAE,oBAA+C,GAAG,OAAO,CAAC,eAAe,CAAC;IAUxG;;;;;;OAMG;IACI,IAAI,CAAC,EACV,aAAkB,EAClB,QAAa,EACb,eAAoB,GACrB,EAAE;QACD,kDAAkD;QAClD,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;QAC9B,6CAA6C;QAC7C,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;QACrB,sDAAsD;QACtD,eAAe,CAAC,EAAE,YAAY,EAAE,CAAC;KAClC,GAAG,2BAA2B;CAWhC"}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
+
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
1
2
|
import { FunctionSelector, FunctionType, decodeFromAbi, encodeArguments } from '@aztec/stdlib/abi';
|
|
2
|
-
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
-
import { FeeJuicePaymentMethod } from '../fee/fee_juice_payment_method.js';
|
|
4
3
|
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
5
4
|
/**
|
|
6
5
|
* This is the class that is returned when calling e.g. `contract.methods.myMethod(arg0, arg1)`.
|
|
@@ -9,8 +8,9 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
9
8
|
contractAddress;
|
|
10
9
|
functionDao;
|
|
11
10
|
args;
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
extraHashedArgs;
|
|
12
|
+
constructor(wallet, contractAddress, functionDao, args, authWitnesses = [], capsules = [], extraHashedArgs = []){
|
|
13
|
+
super(wallet, authWitnesses, capsules), this.contractAddress = contractAddress, this.functionDao = functionDao, this.args = args, this.extraHashedArgs = extraHashedArgs;
|
|
14
14
|
if (args.some((arg)=>arg === undefined || arg === null)) {
|
|
15
15
|
throw new Error('All function interaction arguments must be defined and not null. Received: ' + args);
|
|
16
16
|
}
|
|
@@ -27,22 +27,22 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
27
27
|
throw new Error("Can't call `create` on an unconstrained function.");
|
|
28
28
|
}
|
|
29
29
|
const requestWithoutFee = await this.request(options);
|
|
30
|
-
const { fee: userFee } = options;
|
|
31
|
-
const fee = await this.getFeeOptions({
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
const { fee: userFee, nonce, cancellable } = options;
|
|
31
|
+
const fee = await this.getFeeOptions(requestWithoutFee, userFee, {
|
|
32
|
+
nonce,
|
|
33
|
+
cancellable
|
|
34
34
|
});
|
|
35
|
-
return await this.wallet.createTxExecutionRequest({
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
return await this.wallet.createTxExecutionRequest(requestWithoutFee, fee, {
|
|
36
|
+
nonce,
|
|
37
|
+
cancellable
|
|
38
38
|
});
|
|
39
39
|
}
|
|
40
40
|
// docs:start:request
|
|
41
41
|
/**
|
|
42
42
|
* Returns an execution request that represents this operation.
|
|
43
43
|
* Can be used as a building block for constructing batch requests.
|
|
44
|
-
* @param options - An optional object containing additional configuration for the
|
|
45
|
-
* @returns An execution
|
|
44
|
+
* @param options - An optional object containing additional configuration for the request generation.
|
|
45
|
+
* @returns An execution payload wrapped in promise.
|
|
46
46
|
*/ async request(options = {}) {
|
|
47
47
|
// docs:end:request
|
|
48
48
|
const args = encodeArguments(this.functionDao, this.args);
|
|
@@ -57,18 +57,8 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
57
57
|
returnTypes: this.functionDao.returnTypes
|
|
58
58
|
}
|
|
59
59
|
];
|
|
60
|
-
const authWitnesses =
|
|
61
|
-
|
|
62
|
-
const capsules = this.getCapsules();
|
|
63
|
-
const { nonce, cancellable } = options;
|
|
64
|
-
return {
|
|
65
|
-
calls,
|
|
66
|
-
authWitnesses,
|
|
67
|
-
hashedArguments,
|
|
68
|
-
capsules,
|
|
69
|
-
nonce,
|
|
70
|
-
cancellable
|
|
71
|
-
};
|
|
60
|
+
const { authWitnesses, capsules } = options;
|
|
61
|
+
return new ExecutionPayload(calls, this.authWitnesses.concat(authWitnesses ?? []), this.capsules.concat(capsules ?? []), this.extraHashedArgs);
|
|
72
62
|
}
|
|
73
63
|
// docs:start:simulate
|
|
74
64
|
/**
|
|
@@ -82,14 +72,9 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
82
72
|
*/ async simulate(options = {}) {
|
|
83
73
|
// docs:end:simulate
|
|
84
74
|
if (this.functionDao.functionType == FunctionType.UNCONSTRAINED) {
|
|
85
|
-
return this.wallet.simulateUnconstrained(this.functionDao.name, this.args, this.contractAddress, options?.from);
|
|
75
|
+
return this.wallet.simulateUnconstrained(this.functionDao.name, this.args, this.contractAddress, options.authWitnesses ?? [], options?.from);
|
|
86
76
|
}
|
|
87
|
-
const
|
|
88
|
-
paymentMethod: new FeeJuicePaymentMethod(AztecAddress.ZERO)
|
|
89
|
-
};
|
|
90
|
-
const txRequest = await this.create({
|
|
91
|
-
fee
|
|
92
|
-
});
|
|
77
|
+
const txRequest = await this.create(options);
|
|
93
78
|
const simulatedTx = await this.wallet.simulateTx(txRequest, true, options.from, options.skipTxValidation, options.skipFeeEnforcement ?? true);
|
|
94
79
|
let rawReturnValues;
|
|
95
80
|
if (this.functionDao.functionType == FunctionType.PRIVATE) {
|
|
@@ -112,19 +97,27 @@ import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
|
112
97
|
* @param options - Same options as `simulate`.
|
|
113
98
|
*
|
|
114
99
|
* @returns An object containing the function return value and profile result.
|
|
115
|
-
*/ async
|
|
100
|
+
*/ async profile(options = {
|
|
101
|
+
profileMode: 'gates'
|
|
102
|
+
}) {
|
|
116
103
|
if (this.functionDao.functionType == FunctionType.UNCONSTRAINED) {
|
|
117
104
|
throw new Error("Can't profile an unconstrained function.");
|
|
118
105
|
}
|
|
106
|
+
const { authWitnesses, capsules, fee } = options;
|
|
119
107
|
const txRequest = await this.create({
|
|
120
|
-
fee
|
|
108
|
+
fee,
|
|
109
|
+
authWitnesses,
|
|
110
|
+
capsules
|
|
121
111
|
});
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
112
|
+
return await this.wallet.profileTx(txRequest, options.profileMode, options?.from);
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Augments this ContractFunctionInteraction with additional metadata, such as authWitnesses, capsules, and extraHashedArgs.
|
|
116
|
+
* This is useful when creating a "batteries included" interaction, such as registering a contract class with its associated
|
|
117
|
+
* capsule instead of having the user provide them externally.
|
|
118
|
+
* @param options - An object containing the metadata to add to the interaction
|
|
119
|
+
* @returns A new ContractFunctionInteraction with the added metadata, but calling the same original function in the same manner
|
|
120
|
+
*/ with({ authWitnesses = [], capsules = [], extraHashedArgs = [] }) {
|
|
121
|
+
return new ContractFunctionInteraction(this.wallet, this.contractAddress, this.functionDao, this.args, this.authWitnesses.concat(authWitnesses), this.capsules.concat(capsules), this.extraHashedArgs.concat(extraHashedArgs));
|
|
129
122
|
}
|
|
130
123
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
1
2
|
import type { Fr } from '@aztec/foundation/fields';
|
|
2
3
|
import { type ContractArtifact, type FunctionArtifact } from '@aztec/stdlib/abi';
|
|
3
4
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
@@ -5,12 +6,10 @@ import { type ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
|
5
6
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
6
7
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
7
8
|
import type { TxExecutionRequest } from '@aztec/stdlib/tx';
|
|
8
|
-
import type { Wallet } from '../
|
|
9
|
-
import { type ExecutionRequestInit } from '../entrypoint/entrypoint.js';
|
|
9
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
10
10
|
import { BaseContractInteraction, type SendMethodOptions } from './base_contract_interaction.js';
|
|
11
11
|
import type { Contract } from './contract.js';
|
|
12
12
|
import type { ContractBase } from './contract_base.js';
|
|
13
|
-
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
14
13
|
import { DeployProvenTx } from './deploy_proven_tx.js';
|
|
15
14
|
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
16
15
|
/**
|
|
@@ -61,24 +60,24 @@ export declare class DeployMethod<TContract extends ContractBase = Contract> ext
|
|
|
61
60
|
* @remarks This method does not have the same return type as the `request` in the ContractInteraction object,
|
|
62
61
|
* it returns a promise for an array instead of a function call directly.
|
|
63
62
|
*/
|
|
64
|
-
request(options?: DeployOptions): Promise<
|
|
63
|
+
request(options?: DeployOptions): Promise<ExecutionPayload>;
|
|
65
64
|
/**
|
|
66
65
|
* Register this contract in the PXE and returns the Contract object.
|
|
67
66
|
* @param options - Deployment options.
|
|
68
67
|
*/
|
|
69
68
|
register(options?: DeployOptions): Promise<TContract>;
|
|
70
69
|
/**
|
|
71
|
-
* Returns
|
|
70
|
+
* Returns the execution payload for registration of the class and deployment of the instance, depending on the provided options.
|
|
72
71
|
* @param options - Deployment options.
|
|
73
|
-
* @returns
|
|
72
|
+
* @returns An execution payload with potentially calls (and bytecode capsule) to the class registerer and instance deployer.
|
|
74
73
|
*/
|
|
75
|
-
protected
|
|
74
|
+
protected getDeploymentExecutionPayload(options?: DeployOptions): Promise<ExecutionPayload>;
|
|
76
75
|
/**
|
|
77
76
|
* Returns the calls necessary to initialize the contract.
|
|
78
77
|
* @param options - Deployment options.
|
|
79
78
|
* @returns - An array of function calls.
|
|
80
79
|
*/
|
|
81
|
-
protected
|
|
80
|
+
protected getInitializeExecutionPayload(options: DeployOptions): Promise<ExecutionPayload>;
|
|
82
81
|
/**
|
|
83
82
|
* Send the contract deployment transaction using the provided options.
|
|
84
83
|
* This function extends the 'send' method from the ContractFunctionInteraction class,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy_method.d.ts","sourceRoot":"","sources":["../../src/contract/deploy_method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,KAAK,gBAAgB,EAAoB,KAAK,gBAAgB,EAAkB,MAAM,mBAAmB,CAAC;AACnH,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,KAAK,2BAA2B,EAIjC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"deploy_method.d.ts","sourceRoot":"","sources":["../../src/contract/deploy_method.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAAE,KAAK,gBAAgB,EAAoB,KAAK,gBAAgB,EAAkB,MAAM,mBAAmB,CAAC;AACnH,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,KAAK,2BAA2B,EAIjC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,WAAW,EAAE,M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
|
2
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
4
|
import { computePartialAddress, getContractClassFromArtifact, getContractInstanceFromDeployParams } from '@aztec/stdlib/contract';
|
|
4
5
|
import { deployInstance } from '../deployment/deploy_instance.js';
|
|
5
6
|
import { registerContractClass } from '../deployment/register_class.js';
|
|
6
|
-
import { mergeExecutionRequestInits } from '../entrypoint/entrypoint.js';
|
|
7
7
|
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
8
8
|
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
9
9
|
import { DeployProvenTx } from './deploy_proven_tx.js';
|
|
@@ -34,13 +34,14 @@ import { DeploySentTx } from './deploy_sent_tx.js';
|
|
|
34
34
|
* @returns A Promise resolving to an object containing the signed transaction data and other relevant information.
|
|
35
35
|
*/ async create(options = {}) {
|
|
36
36
|
const requestWithoutFee = await this.request(options);
|
|
37
|
-
const fee =
|
|
38
|
-
|
|
39
|
-
|
|
37
|
+
const { fee: userFee, nonce, cancellable } = options;
|
|
38
|
+
const fee = await this.getFeeOptions(requestWithoutFee, userFee, {
|
|
39
|
+
nonce,
|
|
40
|
+
cancellable
|
|
40
41
|
});
|
|
41
|
-
return this.wallet.createTxExecutionRequest({
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
return this.wallet.createTxExecutionRequest(requestWithoutFee, fee, {
|
|
43
|
+
nonce,
|
|
44
|
+
cancellable
|
|
44
45
|
});
|
|
45
46
|
}
|
|
46
47
|
// REFACTOR: Having a `request` method with different semantics than the ones in the other
|
|
@@ -53,10 +54,7 @@ import { DeploySentTx } from './deploy_sent_tx.js';
|
|
|
53
54
|
* @remarks This method does not have the same return type as the `request` in the ContractInteraction object,
|
|
54
55
|
* it returns a promise for an array instead of a function call directly.
|
|
55
56
|
*/ async request(options = {}) {
|
|
56
|
-
const deployment = await this.
|
|
57
|
-
// NOTE: MEGA HACK. Remove with #10007
|
|
58
|
-
// register the contract after generating deployment function calls in order to publicly register the class and (optioanlly) emit its bytecode
|
|
59
|
-
//
|
|
57
|
+
const deployment = await this.getDeploymentExecutionPayload(options);
|
|
60
58
|
// TODO: Should we add the contracts to the DB here, or once the tx has been sent or mined?
|
|
61
59
|
// Note that we need to run this registerContract here so it's available when computeFeeOptionsFromEstimatedGas
|
|
62
60
|
// runs, since it needs the contract to have been registered in order to estimate gas for its initialization,
|
|
@@ -67,19 +65,16 @@ import { DeploySentTx } from './deploy_sent_tx.js';
|
|
|
67
65
|
artifact: this.artifact,
|
|
68
66
|
instance: await this.getInstance(options)
|
|
69
67
|
});
|
|
70
|
-
const bootstrap = await this.
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
]
|
|
75
|
-
|
|
68
|
+
const bootstrap = await this.getInitializeExecutionPayload(options);
|
|
69
|
+
const exec = [
|
|
70
|
+
deployment,
|
|
71
|
+
bootstrap
|
|
72
|
+
];
|
|
73
|
+
const fnCalls = exec.map((exec)=>exec.calls).flat();
|
|
74
|
+
if (!fnCalls.length) {
|
|
76
75
|
throw new Error(`No function calls needed to deploy contract ${this.artifact.name}`);
|
|
77
76
|
}
|
|
78
|
-
|
|
79
|
-
return mergeExecutionRequestInits(requests, {
|
|
80
|
-
nonce,
|
|
81
|
-
cancellable
|
|
82
|
-
});
|
|
77
|
+
return mergeExecutionPayloads(exec);
|
|
83
78
|
}
|
|
84
79
|
/**
|
|
85
80
|
* Register this contract in the PXE and returns the Contract object.
|
|
@@ -93,10 +88,10 @@ import { DeploySentTx } from './deploy_sent_tx.js';
|
|
|
93
88
|
return this.postDeployCtor(instance.address, this.wallet);
|
|
94
89
|
}
|
|
95
90
|
/**
|
|
96
|
-
* Returns
|
|
91
|
+
* Returns the execution payload for registration of the class and deployment of the instance, depending on the provided options.
|
|
97
92
|
* @param options - Deployment options.
|
|
98
|
-
* @returns
|
|
99
|
-
*/ async
|
|
93
|
+
* @returns An execution payload with potentially calls (and bytecode capsule) to the class registerer and instance deployer.
|
|
94
|
+
*/ async getDeploymentExecutionPayload(options = {}) {
|
|
100
95
|
const calls = [];
|
|
101
96
|
// Set contract instance object so it's available for populating the DeploySendTx object
|
|
102
97
|
const instance = await this.getInstance(options);
|
|
@@ -113,28 +108,28 @@ import { DeploySentTx } from './deploy_sent_tx.js';
|
|
|
113
108
|
} else {
|
|
114
109
|
this.log.info(`Creating request for registering contract class ${contractClass.id.toString()} as part of deployment for ${instance.address.toString()}`);
|
|
115
110
|
const registerContractClassInteraction = await registerContractClass(this.wallet, this.artifact);
|
|
116
|
-
calls.push(registerContractClassInteraction);
|
|
111
|
+
calls.push(await registerContractClassInteraction.request());
|
|
117
112
|
}
|
|
118
113
|
}
|
|
119
114
|
// Deploy the contract via the instance deployer.
|
|
120
115
|
if (!options.skipPublicDeployment) {
|
|
121
116
|
const deploymentInteraction = await deployInstance(this.wallet, instance);
|
|
122
|
-
calls.push(deploymentInteraction);
|
|
117
|
+
calls.push(await deploymentInteraction.request());
|
|
123
118
|
}
|
|
124
|
-
return calls;
|
|
119
|
+
return mergeExecutionPayloads(calls);
|
|
125
120
|
}
|
|
126
121
|
/**
|
|
127
122
|
* Returns the calls necessary to initialize the contract.
|
|
128
123
|
* @param options - Deployment options.
|
|
129
124
|
* @returns - An array of function calls.
|
|
130
|
-
*/ async
|
|
131
|
-
const
|
|
125
|
+
*/ async getInitializeExecutionPayload(options) {
|
|
126
|
+
const executionsPayloads = [];
|
|
132
127
|
if (this.constructorArtifact && !options.skipInitialization) {
|
|
133
128
|
const { address } = await this.getInstance(options);
|
|
134
129
|
const constructorCall = new ContractFunctionInteraction(this.wallet, address, this.constructorArtifact, this.args);
|
|
135
|
-
|
|
130
|
+
executionsPayloads.push(await constructorCall.request());
|
|
136
131
|
}
|
|
137
|
-
return
|
|
132
|
+
return mergeExecutionPayloads(executionsPayloads);
|
|
138
133
|
}
|
|
139
134
|
/**
|
|
140
135
|
* Send the contract deployment transaction using the provided options.
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
2
2
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
|
-
import type { PXE } from '@aztec/stdlib/interfaces/client';
|
|
4
3
|
import type { Tx } from '@aztec/stdlib/tx';
|
|
5
|
-
import type { Wallet } from '../
|
|
4
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
6
5
|
import type { Contract } from './contract.js';
|
|
7
6
|
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
8
7
|
import { ProvenTx } from './proven_tx.js';
|
|
@@ -12,7 +11,7 @@ import { ProvenTx } from './proven_tx.js';
|
|
|
12
11
|
export declare class DeployProvenTx<TContract extends Contract = Contract> extends ProvenTx {
|
|
13
12
|
private postDeployCtor;
|
|
14
13
|
private instanceGetter;
|
|
15
|
-
constructor(wallet:
|
|
14
|
+
constructor(wallet: Wallet, tx: Tx, postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>, instanceGetter: () => Promise<ContractInstanceWithAddress>);
|
|
16
15
|
/**
|
|
17
16
|
* Sends the transaction to the network via the provided wallet.
|
|
18
17
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy_proven_tx.d.ts","sourceRoot":"","sources":["../../src/contract/deploy_proven_tx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"deploy_proven_tx.d.ts","sourceRoot":"","sources":["../../src/contract/deploy_proven_tx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAE3C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C;;GAEG;AACH,qBAAa,cAAc,CAAC,SAAS,SAAS,QAAQ,GAAG,QAAQ,CAAE,SAAQ,QAAQ;IAI/E,OAAO,CAAC,cAAc;IACtB,OAAO,CAAC,cAAc;gBAHtB,MAAM,EAAE,MAAM,EACd,EAAE,EAAE,EAAE,EACE,cAAc,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,CAAC,EAC7E,cAAc,EAAE,MAAM,OAAO,CAAC,2BAA2B,CAAC;IAKpE;;OAEG;IACa,IAAI,IAAI,YAAY,CAAC,SAAS,CAAC;CAOhD"}
|