@aztec/aztec.js 0.0.1-commit.fcb71a6 → 0.0.1-commit.fffb133c
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/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 +16 -10
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +14 -8
- 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 +2 -2
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +1 -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 +1 -1
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +3 -1
- 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 +1 -1
- package/dest/contract/deploy_method.d.ts +63 -16
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +41 -23
- package/dest/contract/interaction_options.d.ts +42 -5
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +8 -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 +963 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts +35 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-class-registry.js +784 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +31 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.js +858 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts +30 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/fee-juice.js +827 -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 +563 -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 +579 -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/broadcast_function.js +3 -3
- 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 +6 -3
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +10 -10
- 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/authwit.d.ts +8 -6
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +5 -9
- 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/deploy_account_method.d.ts +34 -6
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/deploy_account_method.js +7 -5
- package/dest/wallet/wallet.d.ts +233 -2490
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +61 -87
- package/package.json +14 -12
- 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/account.ts +9 -3
- package/src/api/authorization.ts +1 -0
- package/src/api/contract.ts +22 -7
- 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 +5 -2
- package/src/contract/base_contract_interaction.ts +27 -15
- package/src/contract/batch_call.ts +4 -2
- package/src/contract/deploy_method.ts +122 -29
- package/src/contract/interaction_options.ts +49 -4
- package/src/contract/protocol_contracts/auth-registry.ts +545 -0
- package/src/contract/protocol_contracts/contract-class-registry.ts +433 -0
- package/src/contract/protocol_contracts/contract-instance-registry.ts +493 -0
- package/src/contract/protocol_contracts/fee-juice.ts +457 -0
- package/src/contract/protocol_contracts/multi-call-entrypoint.ts +329 -0
- package/src/contract/protocol_contracts/public-checks.ts +315 -0
- package/src/contract/wait_for_proven.ts +1 -1
- package/src/contract/wait_opts.ts +21 -0
- package/src/deployment/broadcast_function.ts +3 -3
- package/src/deployment/publish_class.ts +2 -2
- package/src/deployment/publish_instance.ts +3 -6
- package/src/ethereum/portal_manager.ts +9 -8
- package/src/scripts/generate_protocol_contract_types.ts +150 -0
- package/src/utils/authwit.ts +19 -7
- 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/deploy_account_method.ts +37 -13
- package/src/wallet/wallet.ts +140 -92
- 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/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
|
@@ -5,30 +5,58 @@ import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
|
5
5
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
6
6
|
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
7
7
|
|
|
8
|
+
import type { Account } from '../account/account.js';
|
|
8
9
|
import type { Contract } from '../contract/contract.js';
|
|
9
10
|
import type { ContractBase } from '../contract/contract_base.js';
|
|
10
11
|
import {
|
|
11
12
|
DeployMethod,
|
|
12
|
-
type
|
|
13
|
+
type DeployOptionsWithoutWait,
|
|
13
14
|
type RequestDeployOptions,
|
|
14
15
|
type SimulateDeployOptions,
|
|
15
16
|
} from '../contract/deploy_method.js';
|
|
17
|
+
import type { FeePaymentMethodOption, InteractionWaitOptions } from '../contract/interaction_options.js';
|
|
16
18
|
import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
17
19
|
import { AccountEntrypointMetaPaymentMethod } from './account_entrypoint_meta_payment_method.js';
|
|
18
20
|
import type { Wallet } from './index.js';
|
|
19
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Extended fee payment method option for account deployments that includes entrypoint wrapping options
|
|
24
|
+
*/
|
|
25
|
+
export type DeployAccountFeePaymentMethodOption = FeePaymentMethodOption & {
|
|
26
|
+
/** Optional entrypoint-specific options for wrapping execution payloads */
|
|
27
|
+
feeEntrypointOptions?: unknown;
|
|
28
|
+
};
|
|
29
|
+
|
|
20
30
|
/**
|
|
21
31
|
* The configuration options for the request method. Omits the contractAddressSalt, since
|
|
22
32
|
* for account contracts that is fixed in the constructor
|
|
23
33
|
*/
|
|
24
|
-
export type RequestDeployAccountOptions = Omit<RequestDeployOptions, 'contractAddressSalt'
|
|
34
|
+
export type RequestDeployAccountOptions = Omit<RequestDeployOptions, 'contractAddressSalt' | 'fee'> & {
|
|
35
|
+
/** Fee options specific to account deployment */
|
|
36
|
+
fee?: DeployAccountFeePaymentMethodOption;
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Base configuration options for the send/prove methods without wait parameter. Omits:
|
|
41
|
+
* - The contractAddressSalt, since for account contracts that is fixed in the constructor.
|
|
42
|
+
* - UniversalDeployment flag, since account contracts are always deployed with it set to true
|
|
43
|
+
*/
|
|
44
|
+
export type DeployAccountOptionsWithoutWait = Omit<DeployOptionsWithoutWait, 'contractAddressSalt' | 'universalDeploy'>;
|
|
25
45
|
|
|
26
46
|
/**
|
|
27
47
|
* The configuration options for the send/prove methods. Omits:
|
|
28
48
|
* - The contractAddressSalt, since for account contracts that is fixed in the constructor.
|
|
29
49
|
* - UniversalDeployment flag, since account contracts are always deployed with it set to true
|
|
30
50
|
*/
|
|
31
|
-
export type DeployAccountOptions =
|
|
51
|
+
export type DeployAccountOptions<W extends InteractionWaitOptions = undefined> = DeployAccountOptionsWithoutWait & {
|
|
52
|
+
/**
|
|
53
|
+
* Whether to wait for the transaction to be mined.
|
|
54
|
+
* - undefined (default): wait with default options and return TxReceipt
|
|
55
|
+
* - WaitOpts object: wait with custom options and return TxReceipt
|
|
56
|
+
* - false: return txHash immediately without waiting
|
|
57
|
+
*/
|
|
58
|
+
wait?: W;
|
|
59
|
+
};
|
|
32
60
|
|
|
33
61
|
/**
|
|
34
62
|
* The configuration options for the simulate method. Omits the contractAddressSalt, since
|
|
@@ -47,6 +75,7 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
|
|
|
47
75
|
artifact: ContractArtifact,
|
|
48
76
|
postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
|
|
49
77
|
private salt: Fr,
|
|
78
|
+
private account: Account,
|
|
50
79
|
args: any[] = [],
|
|
51
80
|
constructorNameOrArtifact?: string | FunctionArtifact,
|
|
52
81
|
) {
|
|
@@ -61,19 +90,14 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
|
|
|
61
90
|
* For more details on how the fee payment routing works see documentation of AccountEntrypointMetaPaymentMethod class.
|
|
62
91
|
*
|
|
63
92
|
* @param originalPaymentMethod - originalPaymentMethod The original payment method to be wrapped.
|
|
93
|
+
* @param feeEntrypointOptions - Optional entrypoint-specific options for wrapping. If not provided, will be auto-computed based on the payment method.
|
|
64
94
|
* @returns A FeePaymentMethod that routes the original one through the account's entrypoint (AccountEntrypointMetaPaymentMethod)
|
|
65
95
|
*/
|
|
66
|
-
private getSelfFeePaymentMethod(originalPaymentMethod?: FeePaymentMethod) {
|
|
96
|
+
private getSelfFeePaymentMethod(originalPaymentMethod?: FeePaymentMethod, feeEntrypointOptions?: any) {
|
|
67
97
|
if (!this.address) {
|
|
68
98
|
throw new Error('Instance is not yet constructed. This is a bug!');
|
|
69
99
|
}
|
|
70
|
-
return new AccountEntrypointMetaPaymentMethod(
|
|
71
|
-
this.wallet,
|
|
72
|
-
this.artifact,
|
|
73
|
-
'entrypoint',
|
|
74
|
-
this.address,
|
|
75
|
-
originalPaymentMethod,
|
|
76
|
-
);
|
|
100
|
+
return new AccountEntrypointMetaPaymentMethod(this.account, originalPaymentMethod, feeEntrypointOptions);
|
|
77
101
|
}
|
|
78
102
|
|
|
79
103
|
/**
|
|
@@ -97,7 +121,7 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
|
|
|
97
121
|
const executionPayloads = [deploymentExecutionPayload];
|
|
98
122
|
// If this is a self-deployment, manage the fee accordingly
|
|
99
123
|
if (opts?.deployer?.equals(AztecAddress.ZERO)) {
|
|
100
|
-
const feePaymentMethod = this.getSelfFeePaymentMethod(opts?.fee?.paymentMethod);
|
|
124
|
+
const feePaymentMethod = this.getSelfFeePaymentMethod(opts?.fee?.paymentMethod, opts?.fee?.feeEntrypointOptions);
|
|
101
125
|
const feeExecutionPayload = await feePaymentMethod.getExecutionPayload();
|
|
102
126
|
// Notice they are reversed (fee payment usually goes first):
|
|
103
127
|
// this is because we need to construct the contract BEFORE it can pay for its own fee
|
|
@@ -113,7 +137,7 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
|
|
|
113
137
|
return mergeExecutionPayloads(executionPayloads);
|
|
114
138
|
}
|
|
115
139
|
|
|
116
|
-
override convertDeployOptionsToRequestOptions(options:
|
|
140
|
+
override convertDeployOptionsToRequestOptions(options: DeployAccountOptionsWithoutWait): RequestDeployOptions {
|
|
117
141
|
return {
|
|
118
142
|
...options,
|
|
119
143
|
// Deployer is handled in the request method and forcibly set to undefined,
|
package/src/wallet/wallet.ts
CHANGED
|
@@ -12,13 +12,7 @@ import {
|
|
|
12
12
|
} from '@aztec/stdlib/abi';
|
|
13
13
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
14
14
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
15
|
-
import {
|
|
16
|
-
type ContractClassMetadata,
|
|
17
|
-
ContractClassWithIdSchema,
|
|
18
|
-
type ContractInstanceWithAddress,
|
|
19
|
-
ContractInstanceWithAddressSchema,
|
|
20
|
-
type ContractMetadata,
|
|
21
|
-
} from '@aztec/stdlib/contract';
|
|
15
|
+
import { type ContractInstanceWithAddress, ContractInstanceWithAddressSchema } from '@aztec/stdlib/contract';
|
|
22
16
|
import { Gas } from '@aztec/stdlib/gas';
|
|
23
17
|
import { AbiDecodedSchema, type ApiSchemaFor, optional, schemas, zodFor } from '@aztec/stdlib/schemas';
|
|
24
18
|
import {
|
|
@@ -35,12 +29,15 @@ import type { ExecutionPayload, InTx } from '@aztec/stdlib/tx';
|
|
|
35
29
|
|
|
36
30
|
import { z } from 'zod';
|
|
37
31
|
|
|
38
|
-
import
|
|
39
|
-
FeeEstimationOptions,
|
|
40
|
-
GasSettingsOption,
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
32
|
+
import {
|
|
33
|
+
type FeeEstimationOptions,
|
|
34
|
+
type GasSettingsOption,
|
|
35
|
+
type InteractionWaitOptions,
|
|
36
|
+
NO_WAIT,
|
|
37
|
+
type ProfileInteractionOptions,
|
|
38
|
+
type SendInteractionOptionsWithoutWait,
|
|
39
|
+
type SendReturn,
|
|
40
|
+
type SimulateInteractionOptions,
|
|
44
41
|
} from '../contract/interaction_options.js';
|
|
45
42
|
import type { CallIntent, IntentInnerHash } from '../utils/authwit.js';
|
|
46
43
|
|
|
@@ -60,7 +57,7 @@ export type Aliased<T> = {
|
|
|
60
57
|
|
|
61
58
|
/**
|
|
62
59
|
* Options for simulating interactions with the wallet. Overrides the fee settings of an interaction with
|
|
63
|
-
* a simplified version that only hints at the wallet
|
|
60
|
+
* a simplified version that only hints at the wallet whether the interaction contains a
|
|
64
61
|
* fee payment method or not
|
|
65
62
|
*/
|
|
66
63
|
export type SimulateOptions = Omit<SimulateInteractionOptions, 'fee'> & {
|
|
@@ -70,7 +67,7 @@ export type SimulateOptions = Omit<SimulateInteractionOptions, 'fee'> & {
|
|
|
70
67
|
|
|
71
68
|
/**
|
|
72
69
|
* Options for profiling interactions with the wallet. Overrides the fee settings of an interaction with
|
|
73
|
-
* a simplified version that only hints at the wallet
|
|
70
|
+
* a simplified version that only hints at the wallet whether the interaction contains a
|
|
74
71
|
* fee payment method or not
|
|
75
72
|
*/
|
|
76
73
|
export type ProfileOptions = Omit<ProfileInteractionOptions, 'fee'> & {
|
|
@@ -80,45 +77,54 @@ export type ProfileOptions = Omit<ProfileInteractionOptions, 'fee'> & {
|
|
|
80
77
|
|
|
81
78
|
/**
|
|
82
79
|
* Options for sending/proving interactions with the wallet. Overrides the fee settings of an interaction with
|
|
83
|
-
* a simplified version that only hints at the wallet
|
|
80
|
+
* a simplified version that only hints at the wallet whether the interaction contains a
|
|
84
81
|
* fee payment method or not
|
|
85
82
|
*/
|
|
86
|
-
export type SendOptions =
|
|
83
|
+
export type SendOptions<W extends InteractionWaitOptions = undefined> = Omit<
|
|
84
|
+
SendInteractionOptionsWithoutWait,
|
|
85
|
+
'fee'
|
|
86
|
+
> & {
|
|
87
87
|
/** The fee options */
|
|
88
88
|
fee?: GasSettingsOption;
|
|
89
|
+
/** Whether to wait for the transaction to be mined */
|
|
90
|
+
wait?: W;
|
|
89
91
|
};
|
|
90
92
|
|
|
91
93
|
/**
|
|
92
|
-
* Helper type that represents all methods that can be batched.
|
|
94
|
+
* Helper type that represents all methods that can be batched (all methods except batch itself).
|
|
93
95
|
*/
|
|
94
|
-
export type BatchableMethods =
|
|
95
|
-
Wallet,
|
|
96
|
-
'registerContract' | 'sendTx' | 'registerSender' | 'simulateUtility' | 'simulateTx'
|
|
97
|
-
>;
|
|
96
|
+
export type BatchableMethods = Omit<Wallet, 'batch'>;
|
|
98
97
|
|
|
99
98
|
/**
|
|
100
|
-
*
|
|
101
|
-
* This is what the wallet will accept as arguments to the `batch` method.
|
|
99
|
+
* A method call with its name and arguments.
|
|
102
100
|
*/
|
|
103
|
-
|
|
101
|
+
type BatchedMethodInternal<T extends keyof BatchableMethods> = {
|
|
104
102
|
/** The method name */
|
|
105
103
|
name: T;
|
|
106
104
|
/** The method arguments */
|
|
107
105
|
args: Parameters<BatchableMethods[T]>;
|
|
108
106
|
};
|
|
109
107
|
|
|
108
|
+
/**
|
|
109
|
+
* Union of all possible batched method calls.
|
|
110
|
+
* This ensures type safety: the `args` must match the specific `name`.
|
|
111
|
+
*/
|
|
112
|
+
export type BatchedMethod = {
|
|
113
|
+
[K in keyof BatchableMethods]: BatchedMethodInternal<K>;
|
|
114
|
+
}[keyof BatchableMethods];
|
|
115
|
+
|
|
110
116
|
/**
|
|
111
117
|
* Helper type to extract the return type of a batched method
|
|
112
118
|
*/
|
|
113
119
|
export type BatchedMethodResult<T> =
|
|
114
|
-
T extends
|
|
120
|
+
T extends BatchedMethodInternal<infer K> ? Awaited<ReturnType<BatchableMethods[K]>> : never;
|
|
115
121
|
|
|
116
122
|
/**
|
|
117
123
|
* Wrapper type for batch results that includes the method name for discriminated union deserialization.
|
|
118
124
|
* Each result is wrapped as \{ name: 'methodName', result: ActualResult \} to allow proper deserialization
|
|
119
125
|
* when AztecAddress and TxHash would otherwise be ambiguous (both are hex strings).
|
|
120
126
|
*/
|
|
121
|
-
export type BatchedMethodResultWrapper<T extends BatchedMethod
|
|
127
|
+
export type BatchedMethodResultWrapper<T extends BatchedMethod> = {
|
|
122
128
|
/** The method name */
|
|
123
129
|
name: T['name'];
|
|
124
130
|
/** The method result */
|
|
@@ -128,7 +134,7 @@ export type BatchedMethodResultWrapper<T extends BatchedMethod<keyof BatchableMe
|
|
|
128
134
|
/**
|
|
129
135
|
* Maps a tuple of BatchedMethod to a tuple of their wrapped return types
|
|
130
136
|
*/
|
|
131
|
-
export type BatchResults<T extends readonly BatchedMethod
|
|
137
|
+
export type BatchResults<T extends readonly BatchedMethod[]> = {
|
|
132
138
|
[K in keyof T]: BatchedMethodResultWrapper<T[K]>;
|
|
133
139
|
};
|
|
134
140
|
|
|
@@ -164,18 +170,43 @@ export type PrivateEvent<T> = {
|
|
|
164
170
|
metadata: InTx;
|
|
165
171
|
};
|
|
166
172
|
|
|
173
|
+
/**
|
|
174
|
+
* Contract metadata including deployment and registration status.
|
|
175
|
+
*/
|
|
176
|
+
export type ContractMetadata = {
|
|
177
|
+
/** The contract instance */
|
|
178
|
+
instance?: ContractInstanceWithAddress;
|
|
179
|
+
/** Whether the contract has been initialized (init nullifier exists) */
|
|
180
|
+
isContractInitialized: boolean;
|
|
181
|
+
/** Whether the contract instance is publicly deployed on-chain */
|
|
182
|
+
isContractPublished: boolean;
|
|
183
|
+
/** Whether the contract has been updated to a different class */
|
|
184
|
+
isContractUpdated: boolean;
|
|
185
|
+
/** The updated contract class ID if the contract has been updated */
|
|
186
|
+
updatedContractClassId?: Fr | undefined;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
/**
|
|
190
|
+
* Contract class metadata.
|
|
191
|
+
*/
|
|
192
|
+
export type ContractClassMetadata = {
|
|
193
|
+
/** Whether the artifact is registered in the wallet */
|
|
194
|
+
isArtifactRegistered: boolean;
|
|
195
|
+
/** Whether the contract class is publicly registered on-chain */
|
|
196
|
+
isContractClassPubliclyRegistered: boolean;
|
|
197
|
+
};
|
|
198
|
+
|
|
167
199
|
/**
|
|
168
200
|
* The wallet interface.
|
|
169
201
|
*/
|
|
170
202
|
export type Wallet = {
|
|
171
|
-
getContractClassMetadata(id: Fr, includeArtifact?: boolean): Promise<ContractClassMetadata>;
|
|
172
|
-
getContractMetadata(address: AztecAddress): Promise<ContractMetadata>;
|
|
173
203
|
getPrivateEvents<T>(
|
|
174
204
|
eventMetadata: EventMetadataDefinition,
|
|
175
205
|
eventFilter: PrivateEventFilter,
|
|
176
206
|
): Promise<PrivateEvent<T>[]>;
|
|
177
207
|
getChainInfo(): Promise<ChainInfo>;
|
|
178
|
-
|
|
208
|
+
getContractMetadata(address: AztecAddress): Promise<ContractMetadata>;
|
|
209
|
+
getContractClassMetadata(id: Fr): Promise<ContractClassMetadata>;
|
|
179
210
|
registerSender(address: AztecAddress, alias?: string): Promise<AztecAddress>;
|
|
180
211
|
getAddressBook(): Promise<Aliased<AztecAddress>[]>;
|
|
181
212
|
getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
@@ -187,9 +218,12 @@ export type Wallet = {
|
|
|
187
218
|
simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
|
|
188
219
|
simulateUtility(call: FunctionCall, authwits?: AuthWitness[]): Promise<UtilitySimulationResult>;
|
|
189
220
|
profileTx(exec: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
|
|
190
|
-
sendTx
|
|
191
|
-
|
|
192
|
-
|
|
221
|
+
sendTx<W extends InteractionWaitOptions = undefined>(
|
|
222
|
+
exec: ExecutionPayload,
|
|
223
|
+
opts: SendOptions<W>,
|
|
224
|
+
): Promise<SendReturn<W>>;
|
|
225
|
+
createAuthWit(from: AztecAddress, messageHashOrIntent: IntentInnerHash | CallIntent): Promise<AuthWitness>;
|
|
226
|
+
batch<const T extends readonly BatchedMethod[]>(methods: T): Promise<BatchResults<T>>;
|
|
193
227
|
};
|
|
194
228
|
|
|
195
229
|
export const FunctionCallSchema = z.object({
|
|
@@ -227,11 +261,19 @@ export const WalletSimulationFeeOptionSchema = GasSettingsOptionSchema.extend({
|
|
|
227
261
|
estimateGas: optional(z.boolean()),
|
|
228
262
|
});
|
|
229
263
|
|
|
264
|
+
export const WaitOptsSchema = z.object({
|
|
265
|
+
ignoreDroppedReceiptsFor: optional(z.number()),
|
|
266
|
+
timeout: optional(z.number()),
|
|
267
|
+
interval: optional(z.number()),
|
|
268
|
+
dontThrowOnRevert: optional(z.boolean()),
|
|
269
|
+
});
|
|
270
|
+
|
|
230
271
|
export const SendOptionsSchema = z.object({
|
|
231
272
|
from: schemas.AztecAddress,
|
|
232
273
|
authWitnesses: optional(z.array(AuthWitness.schema)),
|
|
233
274
|
capsules: optional(z.array(Capsule.schema)),
|
|
234
275
|
fee: optional(GasSettingsOptionSchema),
|
|
276
|
+
wait: optional(z.union([z.literal(NO_WAIT), WaitOptsSchema])),
|
|
235
277
|
});
|
|
236
278
|
|
|
237
279
|
export const SimulateOptionsSchema = z.object({
|
|
@@ -250,7 +292,6 @@ export const ProfileOptionsSchema = SimulateOptionsSchema.extend({
|
|
|
250
292
|
});
|
|
251
293
|
|
|
252
294
|
export const MessageHashOrIntentSchema = z.union([
|
|
253
|
-
schemas.Fr,
|
|
254
295
|
z.object({ consumer: schemas.AztecAddress, innerHash: schemas.Fr }),
|
|
255
296
|
z.object({
|
|
256
297
|
caller: schemas.AztecAddress,
|
|
@@ -258,45 +299,6 @@ export const MessageHashOrIntentSchema = z.union([
|
|
|
258
299
|
}),
|
|
259
300
|
]);
|
|
260
301
|
|
|
261
|
-
export const BatchedMethodSchema = z.union([
|
|
262
|
-
z.object({
|
|
263
|
-
name: z.literal('registerSender'),
|
|
264
|
-
args: z.tuple([schemas.AztecAddress, optional(z.string())]),
|
|
265
|
-
}),
|
|
266
|
-
z.object({
|
|
267
|
-
name: z.literal('registerContract'),
|
|
268
|
-
args: z.tuple([ContractInstanceWithAddressSchema, optional(ContractArtifactSchema), optional(schemas.Fr)]),
|
|
269
|
-
}),
|
|
270
|
-
z.object({
|
|
271
|
-
name: z.literal('sendTx'),
|
|
272
|
-
args: z.tuple([ExecutionPayloadSchema, SendOptionsSchema]),
|
|
273
|
-
}),
|
|
274
|
-
z.object({
|
|
275
|
-
name: z.literal('simulateUtility'),
|
|
276
|
-
args: z.tuple([FunctionCallSchema, optional(z.array(AuthWitness.schema))]),
|
|
277
|
-
}),
|
|
278
|
-
z.object({
|
|
279
|
-
name: z.literal('simulateTx'),
|
|
280
|
-
args: z.tuple([ExecutionPayloadSchema, SimulateOptionsSchema]),
|
|
281
|
-
}),
|
|
282
|
-
]);
|
|
283
|
-
|
|
284
|
-
export const ContractMetadataSchema = zodFor<ContractMetadata>()(
|
|
285
|
-
z.object({
|
|
286
|
-
contractInstance: z.union([ContractInstanceWithAddressSchema, z.undefined()]),
|
|
287
|
-
isContractInitialized: z.boolean(),
|
|
288
|
-
isContractPublished: z.boolean(),
|
|
289
|
-
}),
|
|
290
|
-
);
|
|
291
|
-
|
|
292
|
-
export const ContractClassMetadataSchema = zodFor<ContractClassMetadata>()(
|
|
293
|
-
z.object({
|
|
294
|
-
contractClass: z.union([ContractClassWithIdSchema, z.undefined()]),
|
|
295
|
-
isContractClassPubliclyRegistered: z.boolean(),
|
|
296
|
-
artifact: z.union([ContractArtifactSchema, z.undefined()]),
|
|
297
|
-
}),
|
|
298
|
-
);
|
|
299
|
-
|
|
300
302
|
export const EventMetadataDefinitionSchema = z.object({
|
|
301
303
|
eventSelector: schemas.EventSelector,
|
|
302
304
|
abiType: AbiTypeSchema,
|
|
@@ -318,14 +320,30 @@ export const PrivateEventFilterSchema = z.object({
|
|
|
318
320
|
toBlock: optional(BlockNumberPositiveSchema),
|
|
319
321
|
});
|
|
320
322
|
|
|
321
|
-
export const
|
|
323
|
+
export const ContractMetadataSchema = z.object({
|
|
324
|
+
instance: optional(ContractInstanceWithAddressSchema),
|
|
325
|
+
isContractInitialized: z.boolean(),
|
|
326
|
+
isContractPublished: z.boolean(),
|
|
327
|
+
isContractUpdated: z.boolean(),
|
|
328
|
+
updatedContractClassId: optional(schemas.Fr),
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
export const ContractClassMetadataSchema = z.object({
|
|
332
|
+
isArtifactRegistered: z.boolean(),
|
|
333
|
+
isContractClassPubliclyRegistered: z.boolean(),
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Record of all wallet method schemas (excluding batch).
|
|
338
|
+
* This is the single source of truth for method schemas - batch schemas are derived from this.
|
|
339
|
+
*/
|
|
340
|
+
const WalletMethodSchemas = {
|
|
322
341
|
getChainInfo: z
|
|
323
342
|
.function()
|
|
324
343
|
.args()
|
|
325
344
|
.returns(z.object({ chainId: schemas.Fr, version: schemas.Fr })),
|
|
326
|
-
getContractClassMetadata: z.function().args(schemas.Fr, optional(z.boolean())).returns(ContractClassMetadataSchema),
|
|
327
345
|
getContractMetadata: z.function().args(schemas.AztecAddress).returns(ContractMetadataSchema),
|
|
328
|
-
|
|
346
|
+
getContractClassMetadata: z.function().args(schemas.Fr).returns(ContractClassMetadataSchema),
|
|
329
347
|
getPrivateEvents: z
|
|
330
348
|
.function()
|
|
331
349
|
.args(EventMetadataDefinitionSchema, PrivateEventFilterSchema)
|
|
@@ -349,21 +367,51 @@ export const WalletSchema: ApiSchemaFor<Wallet> = {
|
|
|
349
367
|
.args(FunctionCallSchema, optional(z.array(AuthWitness.schema)))
|
|
350
368
|
.returns(UtilitySimulationResult.schema),
|
|
351
369
|
profileTx: z.function().args(ExecutionPayloadSchema, ProfileOptionsSchema).returns(TxProfileResult.schema),
|
|
352
|
-
sendTx: z
|
|
370
|
+
sendTx: z
|
|
371
|
+
.function()
|
|
372
|
+
.args(ExecutionPayloadSchema, SendOptionsSchema)
|
|
373
|
+
.returns(z.union([TxHash.schema, TxReceipt.schema])),
|
|
353
374
|
createAuthWit: z.function().args(schemas.AztecAddress, MessageHashOrIntentSchema).returns(AuthWitness.schema),
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* Creates batch schemas from the individual wallet methods.
|
|
379
|
+
* This allows us to define them once and derive batch schemas automatically,
|
|
380
|
+
* reducing duplication and ensuring consistency.
|
|
381
|
+
*/
|
|
382
|
+
function createBatchSchemas<T extends Record<string, z.ZodFunction<z.ZodTuple<any, any>, z.ZodTypeAny>>>(
|
|
383
|
+
methodSchemas: T,
|
|
384
|
+
) {
|
|
385
|
+
const names = Object.keys(methodSchemas) as (keyof T)[];
|
|
386
|
+
|
|
387
|
+
const namesAndArgs = names.map(name =>
|
|
388
|
+
z.object({
|
|
389
|
+
name: z.literal(name),
|
|
390
|
+
args: methodSchemas[name].parameters(),
|
|
391
|
+
}),
|
|
392
|
+
);
|
|
393
|
+
|
|
394
|
+
const namesAndReturns = names.map(name =>
|
|
395
|
+
z.object({
|
|
396
|
+
name: z.literal(name),
|
|
397
|
+
result: methodSchemas[name].returnType(),
|
|
398
|
+
}),
|
|
399
|
+
);
|
|
400
|
+
|
|
401
|
+
// Type assertion needed because discriminatedUnion expects a tuple type [T, T, ...T[]]
|
|
402
|
+
// but we're building the array dynamically. The runtime behavior is correct.
|
|
403
|
+
return {
|
|
404
|
+
input: z.discriminatedUnion('name', namesAndArgs as [(typeof namesAndArgs)[0], ...typeof namesAndArgs]),
|
|
405
|
+
output: z.discriminatedUnion('name', namesAndReturns as [(typeof namesAndReturns)[0], ...typeof namesAndReturns]),
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
const { input: BatchedMethodSchema, output: BatchedResultSchema } = createBatchSchemas(WalletMethodSchemas);
|
|
410
|
+
|
|
411
|
+
export { BatchedMethodSchema, BatchedResultSchema };
|
|
412
|
+
|
|
413
|
+
export const WalletSchema: ApiSchemaFor<Wallet> = {
|
|
414
|
+
...WalletMethodSchemas,
|
|
354
415
|
// @ts-expect-error - ApiSchemaFor cannot properly type generic methods with readonly arrays
|
|
355
|
-
batch: z
|
|
356
|
-
.function()
|
|
357
|
-
.args(z.array(BatchedMethodSchema))
|
|
358
|
-
.returns(
|
|
359
|
-
z.array(
|
|
360
|
-
z.discriminatedUnion('name', [
|
|
361
|
-
z.object({ name: z.literal('registerSender'), result: schemas.AztecAddress }),
|
|
362
|
-
z.object({ name: z.literal('registerContract'), result: ContractInstanceWithAddressSchema }),
|
|
363
|
-
z.object({ name: z.literal('sendTx'), result: TxHash.schema }),
|
|
364
|
-
z.object({ name: z.literal('simulateUtility'), result: UtilitySimulationResult.schema }),
|
|
365
|
-
z.object({ name: z.literal('simulateTx'), result: TxSimulationResult.schema }),
|
|
366
|
-
]),
|
|
367
|
-
),
|
|
368
|
-
),
|
|
416
|
+
batch: z.function().args(z.array(BatchedMethodSchema)).returns(z.array(BatchedResultSchema)),
|
|
369
417
|
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { AuthWitnessProvider, EntrypointInterface } from '@aztec/entrypoints/interfaces';
|
|
2
|
-
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
-
import type { CompleteAddress } from '@aztec/stdlib/contract';
|
|
5
|
-
/**
|
|
6
|
-
* Handler for interfacing with an account. Knows how to create transaction execution
|
|
7
|
-
* requests and authorize actions for its corresponding account.
|
|
8
|
-
*/
|
|
9
|
-
export interface AccountInterface extends EntrypointInterface, AuthWitnessProvider {
|
|
10
|
-
/** Returns the complete address for this account. */
|
|
11
|
-
getCompleteAddress(): CompleteAddress;
|
|
12
|
-
/** Returns the address for this account. */
|
|
13
|
-
getAddress(): AztecAddress;
|
|
14
|
-
/** Returns the chain id for this account */
|
|
15
|
-
getChainId(): Fr;
|
|
16
|
-
/** Returns the rollup version for this account */
|
|
17
|
-
getVersion(): Fr;
|
|
18
|
-
}
|
|
19
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIj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AAmB,EAAE,mBAAmB;IAChF,qDAAqD;IACrD,kBAAkB,IAAI,eAAe,CAAC;IAEtC,4CAA4C;IAC5C,UAAU,IAAI,YAAY,CAAC;IAE3B,4CAA4C;IAC5C,UAAU,IAAI,EAAE,CAAC;IAEjB,kDAAkD;IAClD,UAAU,IAAI,EAAE,CAAC;CAClB"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import type { FieldsOf } from '@aztec/foundation/types';
|
|
2
|
-
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
|
-
import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
4
|
-
import type { Wallet } from '../wallet/wallet.js';
|
|
5
|
-
import type { ContractBase } from './contract_base.js';
|
|
6
|
-
import { SentTx, type WaitOpts } from './sent_tx.js';
|
|
7
|
-
/** Options related to waiting for a deployment tx. */
|
|
8
|
-
export type DeployedWaitOpts = WaitOpts & {
|
|
9
|
-
/** Wallet to use for creating a contract instance. Uses the one set in the deployer constructor if not set. */
|
|
10
|
-
wallet?: Wallet;
|
|
11
|
-
};
|
|
12
|
-
/** Extends a transaction receipt with a contract instance that represents the newly deployed contract. */
|
|
13
|
-
export type DeployTxReceipt<TContract extends ContractBase = ContractBase> = FieldsOf<TxReceipt> & {
|
|
14
|
-
/** Instance of the newly deployed contract. */
|
|
15
|
-
contract: TContract;
|
|
16
|
-
/** The deployed contract instance with address and metadata. */
|
|
17
|
-
instance: ContractInstanceWithAddress;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* A contract deployment transaction sent to the network, extending SentTx with methods to publish a contract instance.
|
|
21
|
-
*/
|
|
22
|
-
export declare class DeploySentTx<TContract extends ContractBase = ContractBase> extends SentTx {
|
|
23
|
-
private postDeployCtor;
|
|
24
|
-
/** A getter for the deployed contract instance */
|
|
25
|
-
private instanceGetter;
|
|
26
|
-
private log;
|
|
27
|
-
constructor(wallet: Wallet, sendTx: () => Promise<TxHash>, postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
|
|
28
|
-
/** A getter for the deployed contract instance */
|
|
29
|
-
instanceGetter: () => Promise<ContractInstanceWithAddress>);
|
|
30
|
-
/**
|
|
31
|
-
* Returns the contract instance for this deployment.
|
|
32
|
-
* @returns The deployed contract instance with address and metadata.
|
|
33
|
-
*/
|
|
34
|
-
getInstance(): Promise<ContractInstanceWithAddress>;
|
|
35
|
-
/**
|
|
36
|
-
* Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
|
|
37
|
-
* @param opts - Options for configuring the waiting for the tx to be mined.
|
|
38
|
-
* @returns The deployed contract instance.
|
|
39
|
-
*/
|
|
40
|
-
deployed(opts?: DeployedWaitOpts): Promise<TContract>;
|
|
41
|
-
/**
|
|
42
|
-
* Awaits for the tx to be mined and returns the receipt along with a contract instance. Throws if tx is not mined.
|
|
43
|
-
* @param opts - Options for configuring the waiting for the tx to be mined.
|
|
44
|
-
* @returns The transaction receipt with the deployed contract instance.
|
|
45
|
-
*/
|
|
46
|
-
wait(opts?: DeployedWaitOpts): Promise<DeployTxReceipt<TContract>>;
|
|
47
|
-
}
|
|
48
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZGVwbG95X3NlbnRfdHguZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy9jb250cmFjdC9kZXBsb3lfc2VudF90eC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFDQSxPQUFPLEtBQUssRUFBRSxRQUFRLEVBQUUsTUFBTSx5QkFBeUIsQ0FBQztBQUN4RCxPQUFPLEtBQUssRUFBRSwyQkFBMkIsRUFBRSxNQUFNLHdCQUF3QixDQUFDO0FBQzFFLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxTQUFTLEVBQUUsTUFBTSxrQkFBa0IsQ0FBQztBQUUxRCxPQUFPLEtBQUssRUFBRSxNQUFNLEVBQUUsTUFBTSx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AAY,GAAG,YAAY,CAAE,SAAQ,MAAM;IAMnF,OAAO,CAAC,cAAc;IACtB,kDAAkD;IAClD,OAAO,CAAC,cAAc;IAPxB,OAAO,CAAC,GAAG,CAA0C;IAErD,YACE,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,OAAO,CAAC,MAAM,CAAC,EACrB,cAAc,EAAE,CAAC,QAAQ,EAAE,2BAA2B,EAAE,MAAM,EAAE,MAAM,KAAK,SAAS;IAC5F,kDAAkD;IAC1C,cAAc,EAAE,MAAM,OAAO,CAAC,2BAA2B,CAAC,EAGnE;IAED;;;OAGG;IACU,WAAW,IAAI,OAAO,CAAC,2BAA2B,CAAC,CAE/D;IAED;;;;OAIG;IACU,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC,CAIjE;IAED;;;;OAIG;IACmB,IAAI,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC,CAUvF;CACF"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
-
import { SentTx } from './sent_tx.js';
|
|
3
|
-
/**
|
|
4
|
-
* A contract deployment transaction sent to the network, extending SentTx with methods to publish a contract instance.
|
|
5
|
-
*/ export class DeploySentTx extends SentTx {
|
|
6
|
-
postDeployCtor;
|
|
7
|
-
instanceGetter;
|
|
8
|
-
log;
|
|
9
|
-
constructor(wallet, sendTx, postDeployCtor, /** A getter for the deployed contract instance */ instanceGetter){
|
|
10
|
-
super(wallet, sendTx), this.postDeployCtor = postDeployCtor, this.instanceGetter = instanceGetter, this.log = createLogger('aztecjs:deploy_sent_tx');
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Returns the contract instance for this deployment.
|
|
14
|
-
* @returns The deployed contract instance with address and metadata.
|
|
15
|
-
*/ async getInstance() {
|
|
16
|
-
return await this.instanceGetter();
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
|
|
20
|
-
* @param opts - Options for configuring the waiting for the tx to be mined.
|
|
21
|
-
* @returns The deployed contract instance.
|
|
22
|
-
*/ async deployed(opts) {
|
|
23
|
-
const receipt = await this.wait(opts);
|
|
24
|
-
this.log.info(`Contract ${receipt.instance.address.toString()} successfully deployed.`);
|
|
25
|
-
return receipt.contract;
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Awaits for the tx to be mined and returns the receipt along with a contract instance. Throws if tx is not mined.
|
|
29
|
-
* @param opts - Options for configuring the waiting for the tx to be mined.
|
|
30
|
-
* @returns The transaction receipt with the deployed contract instance.
|
|
31
|
-
*/ async wait(opts) {
|
|
32
|
-
const receipt = await super.wait(opts);
|
|
33
|
-
// In the case of DeploySentTx we have a guarantee that this.walletOrNode is a Wallet so we can cast it to Wallet.
|
|
34
|
-
const contractWallet = opts?.wallet ?? this.walletOrNode;
|
|
35
|
-
if (!contractWallet) {
|
|
36
|
-
throw new Error(`A wallet is required for creating a contract instance`);
|
|
37
|
-
}
|
|
38
|
-
const instance = await this.instanceGetter();
|
|
39
|
-
const contract = this.postDeployCtor(instance, contractWallet);
|
|
40
|
-
return {
|
|
41
|
-
...receipt,
|
|
42
|
-
contract,
|
|
43
|
-
instance
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Wallet } from '../wallet/wallet.js';
|
|
2
|
-
import { UnsafeContract } from './unsafe_contract.js';
|
|
3
|
-
/** Returns a Contract wrapper for the contract class registry. */
|
|
4
|
-
export declare function getClassRegistryContract(wallet: Wallet): Promise<UnsafeContract>;
|
|
5
|
-
/** Returns a Contract wrapper for the contract instance registry. */
|
|
6
|
-
export declare function getInstanceRegistryContract(wallet: Wallet): Promise<UnsafeContract>;
|
|
7
|
-
/** Returns a Contract wrapper for the fee juice contract */
|
|
8
|
-
export declare function getFeeJuice(wallet: Wallet): Promise<UnsafeContract>;
|
|
9
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoicHJvdG9jb2xfY29udHJhY3RzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvY29udHJhY3QvcHJvdG9jb2xfY29udHJhY3RzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUVBLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBQ2xELE9BQU8sRUFBRSxjQUFjLEVBQUUsTUFBTSxzQkFBc0IsQ0FBQztBQUV0RCxrRUFBa0U7QUFDbEUsd0JBQXNCLHdCQUF3QixDQUFDLE1BQU0sRUFBRSxNQUFNLDJCQVE1RDtBQUVELHFFQUFxRTtBQUNyRSx3QkFBc0IsMkJBQTJCLENBQUMsTUFBTSxFQUFFLE1BQU0sMkJBTy9EO0FBRUQsNERBQTREO0FBQzVELHdCQUFzQixXQUFXLENBQUMsTUFBTSxFQUFFLE1BQU0sMkJBTy9DIn0=
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"protocol_contracts.d.ts","sourceRoot":"","sources":["../../src/contract/protocol_contracts.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAEtD,kEAAkE;AAClE,wBAAsB,wBAAwB,CAAC,MAAM,EAAE,MAAM,2BAQ5D;AAED,qEAAqE;AACrE,wBAAsB,2BAA2B,CAAC,MAAM,EAAE,MAAM,2BAO/D;AAED,4DAA4D;AAC5D,wBAAsB,WAAW,CAAC,MAAM,EAAE,MAAM,2BAO/C"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
2
|
-
import { UnsafeContract } from './unsafe_contract.js';
|
|
3
|
-
/** Returns a Contract wrapper for the contract class registry. */ export async function getClassRegistryContract(wallet) {
|
|
4
|
-
const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.ContractClassRegistry);
|
|
5
|
-
if (!contractInstance) {
|
|
6
|
-
throw new Error("ContractClassRegistry is not registered in this wallet's instance");
|
|
7
|
-
}
|
|
8
|
-
const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
|
|
9
|
-
return new UnsafeContract(contractInstance, artifact, wallet);
|
|
10
|
-
}
|
|
11
|
-
/** Returns a Contract wrapper for the contract instance registry. */ export async function getInstanceRegistryContract(wallet) {
|
|
12
|
-
const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.ContractInstanceRegistry);
|
|
13
|
-
if (!contractInstance) {
|
|
14
|
-
throw new Error("ContractInstanceRegistry is not registered in this wallet's instance");
|
|
15
|
-
}
|
|
16
|
-
const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
|
|
17
|
-
return new UnsafeContract(contractInstance, artifact, wallet);
|
|
18
|
-
}
|
|
19
|
-
/** Returns a Contract wrapper for the fee juice contract */ export async function getFeeJuice(wallet) {
|
|
20
|
-
const { contractInstance } = await wallet.getContractMetadata(ProtocolContractAddress.FeeJuice);
|
|
21
|
-
if (!contractInstance) {
|
|
22
|
-
throw new Error("FeeJuice is not registered in this wallet's instance");
|
|
23
|
-
}
|
|
24
|
-
const { artifact } = await wallet.getContractClassMetadata(contractInstance.currentContractClassId, true);
|
|
25
|
-
return new UnsafeContract(contractInstance, artifact, wallet);
|
|
26
|
-
}
|