@aztec/aztec.js 0.0.1-commit.d1f2d6c → 0.0.1-commit.d431d1c
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/api/block.d.ts +2 -2
- package/dest/api/block.d.ts.map +1 -1
- package/dest/api/block.js +1 -1
- package/dest/api/contract.d.ts +10 -16
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +8 -14
- package/dest/api/node.d.ts +4 -8
- package/dest/api/node.d.ts.map +1 -1
- package/dest/api/node.js +3 -7
- 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/contract/base_contract_interaction.d.ts +10 -8
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +17 -5
- package/dest/contract/deploy_method.d.ts +16 -63
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +19 -36
- package/dest/contract/deploy_sent_tx.d.ts +48 -0
- package/dest/contract/deploy_sent_tx.d.ts.map +1 -0
- package/dest/contract/deploy_sent_tx.js +46 -0
- package/dest/contract/interaction_options.d.ts +5 -42
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +1 -8
- package/dest/contract/protocol_contracts/auth-registry.d.ts +1 -1
- package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/auth-registry.js +13 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts +1 -1
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/contract-class-registry.js +13 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +1 -1
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/contract-instance-registry.js +13 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts +1 -1
- package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/fee-juice.js +13 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +1 -1
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/multi-call-entrypoint.js +13 -0
- package/dest/contract/protocol_contracts/public-checks.d.ts +1 -1
- package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -1
- package/dest/contract/protocol_contracts/public-checks.js +13 -0
- package/dest/contract/sent_tx.d.ts +50 -0
- package/dest/contract/sent_tx.d.ts.map +1 -0
- package/dest/contract/sent_tx.js +90 -0
- package/dest/contract/wait_for_proven.js +1 -1
- package/dest/utils/authwit.d.ts +6 -6
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +6 -2
- package/dest/utils/node.d.ts +1 -12
- package/dest/utils/node.d.ts.map +1 -1
- package/dest/utils/node.js +0 -46
- package/dest/wallet/deploy_account_method.d.ts +5 -19
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/wallet.d.ts +18 -63
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +3 -16
- package/package.json +9 -9
- package/src/api/block.ts +1 -1
- package/src/api/contract.ts +7 -22
- package/src/api/node.ts +3 -7
- package/src/api/tx.ts +0 -2
- package/src/api/wallet.ts +0 -5
- package/src/contract/base_contract_interaction.ts +15 -27
- package/src/contract/deploy_method.ts +23 -115
- package/src/contract/deploy_sent_tx.ts +75 -0
- package/src/contract/interaction_options.ts +4 -49
- package/src/contract/protocol_contracts/auth-registry.ts +9 -0
- package/src/contract/protocol_contracts/contract-class-registry.ts +9 -0
- package/src/contract/protocol_contracts/contract-instance-registry.ts +9 -0
- package/src/contract/protocol_contracts/fee-juice.ts +9 -0
- package/src/contract/protocol_contracts/multi-call-entrypoint.ts +9 -0
- package/src/contract/protocol_contracts/public-checks.ts +9 -0
- package/src/contract/sent_tx.ts +129 -0
- package/src/contract/wait_for_proven.ts +1 -1
- package/src/utils/authwit.ts +4 -16
- package/src/utils/node.ts +0 -62
- package/src/wallet/deploy_account_method.ts +4 -19
- package/src/wallet/wallet.ts +11 -31
- package/dest/contract/wait_opts.d.ts +0 -16
- package/dest/contract/wait_opts.d.ts.map +0 -1
- package/dest/contract/wait_opts.js +0 -5
- package/src/contract/wait_opts.ts +0 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/wallet/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAA6B,MAAM,iCAAiC,CAAC;AACzF,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACzD,OAAO,EAGL,KAAK,gBAAgB,EAErB,KAAK,uBAAuB,EAC5B,KAAK,YAAY,EACjB,YAAY,EACb,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,KAAK,2BAA2B,EAAqC,MAAM,wBAAwB,CAAC;AAC7G,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAoB,KAAK,YAAY,EAA6B,MAAM,uBAAuB,CAAC;AACvG,OAAO,EACL,OAAO,EACP,YAAY,EACZ,MAAM,EACN,eAAe,
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/wallet/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,WAAW,EAA6B,MAAM,iCAAiC,CAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAG/B,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;IAMpC,CAAC;AAEH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;EAIxC,CAAC;AAEH,eAAO,MAAM,kBAAkB,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,CAK7C,CAAC;AAEF,eAAO,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;EAMnC,CAAC;AAEH,eAAO,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAMjC,CAAC;AAEH,eAAO,MAAM,2BAA2B;;;;;;;;;EAGtC,CAAC;AAyEH,QAAA,MAAe,mBAAmB;;;;;;;;;;;;;;;;;;QAAU,mBAAmB;;;;;;;;;;;;;;;;;;MAA4C,CAAC;AAE5G,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,CAAC;AAEpD,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,MAAM,CAI7C,CAAC"}
|
package/dest/wallet/wallet.js
CHANGED
|
@@ -6,7 +6,6 @@ import { Gas } from '@aztec/stdlib/gas';
|
|
|
6
6
|
import { AbiDecodedSchema, optional, schemas, zodFor } from '@aztec/stdlib/schemas';
|
|
7
7
|
import { Capsule, HashedValues, TxHash, TxProfileResult, TxReceipt, TxSimulationResult, UtilitySimulationResult, inTxSchema } from '@aztec/stdlib/tx';
|
|
8
8
|
import { z } from 'zod';
|
|
9
|
-
import { NO_WAIT } from '../contract/interaction_options.js';
|
|
10
9
|
export const FunctionCallSchema = z.object({
|
|
11
10
|
name: z.string(),
|
|
12
11
|
to: schemas.AztecAddress,
|
|
@@ -42,21 +41,11 @@ export const WalletSimulationFeeOptionSchema = GasSettingsOptionSchema.extend({
|
|
|
42
41
|
estimatedGasPadding: optional(z.number()),
|
|
43
42
|
estimateGas: optional(z.boolean())
|
|
44
43
|
});
|
|
45
|
-
export const WaitOptsSchema = z.object({
|
|
46
|
-
ignoreDroppedReceiptsFor: optional(z.number()),
|
|
47
|
-
timeout: optional(z.number()),
|
|
48
|
-
interval: optional(z.number()),
|
|
49
|
-
dontThrowOnRevert: optional(z.boolean())
|
|
50
|
-
});
|
|
51
44
|
export const SendOptionsSchema = z.object({
|
|
52
45
|
from: schemas.AztecAddress,
|
|
53
46
|
authWitnesses: optional(z.array(AuthWitness.schema)),
|
|
54
47
|
capsules: optional(z.array(Capsule.schema)),
|
|
55
|
-
fee: optional(GasSettingsOptionSchema)
|
|
56
|
-
wait: optional(z.union([
|
|
57
|
-
z.literal(NO_WAIT),
|
|
58
|
-
WaitOptsSchema
|
|
59
|
-
]))
|
|
48
|
+
fee: optional(GasSettingsOptionSchema)
|
|
60
49
|
});
|
|
61
50
|
export const SimulateOptionsSchema = z.object({
|
|
62
51
|
from: schemas.AztecAddress,
|
|
@@ -120,6 +109,7 @@ export const ContractClassMetadataSchema = z.object({
|
|
|
120
109
|
chainId: schemas.Fr,
|
|
121
110
|
version: schemas.Fr
|
|
122
111
|
})),
|
|
112
|
+
getTxReceipt: z.function().args(TxHash.schema).returns(TxReceipt.schema),
|
|
123
113
|
getContractMetadata: z.function().args(schemas.AztecAddress).returns(ContractMetadataSchema),
|
|
124
114
|
getContractClassMetadata: z.function().args(schemas.Fr).returns(ContractClassMetadataSchema),
|
|
125
115
|
getPrivateEvents: z.function().args(EventMetadataDefinitionSchema, PrivateEventFilterSchema).returns(z.array(PrivateEventSchema)),
|
|
@@ -136,10 +126,7 @@ export const ContractClassMetadataSchema = z.object({
|
|
|
136
126
|
simulateTx: z.function().args(ExecutionPayloadSchema, SimulateOptionsSchema).returns(TxSimulationResult.schema),
|
|
137
127
|
simulateUtility: z.function().args(FunctionCallSchema, optional(z.array(AuthWitness.schema))).returns(UtilitySimulationResult.schema),
|
|
138
128
|
profileTx: z.function().args(ExecutionPayloadSchema, ProfileOptionsSchema).returns(TxProfileResult.schema),
|
|
139
|
-
sendTx: z.function().args(ExecutionPayloadSchema, SendOptionsSchema).returns(
|
|
140
|
-
TxHash.schema,
|
|
141
|
-
TxReceipt.schema
|
|
142
|
-
])),
|
|
129
|
+
sendTx: z.function().args(ExecutionPayloadSchema, SendOptionsSchema).returns(TxHash.schema),
|
|
143
130
|
createAuthWit: z.function().args(schemas.AztecAddress, MessageHashOrIntentSchema).returns(AuthWitness.schema)
|
|
144
131
|
};
|
|
145
132
|
/**
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aztec/aztec.js",
|
|
3
3
|
"homepage": "https://github.com/AztecProtocol/aztec-packages/tree/master/yarn-project/aztec.js",
|
|
4
|
-
"version": "0.0.1-commit.
|
|
4
|
+
"version": "0.0.1-commit.d431d1c",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./abi": "./dest/api/abi.js",
|
|
@@ -85,20 +85,20 @@
|
|
|
85
85
|
]
|
|
86
86
|
},
|
|
87
87
|
"dependencies": {
|
|
88
|
-
"@aztec/constants": "0.0.1-commit.
|
|
89
|
-
"@aztec/entrypoints": "0.0.1-commit.
|
|
90
|
-
"@aztec/ethereum": "0.0.1-commit.
|
|
91
|
-
"@aztec/foundation": "0.0.1-commit.
|
|
92
|
-
"@aztec/l1-artifacts": "0.0.1-commit.
|
|
93
|
-
"@aztec/protocol-contracts": "0.0.1-commit.
|
|
94
|
-
"@aztec/stdlib": "0.0.1-commit.
|
|
88
|
+
"@aztec/constants": "0.0.1-commit.d431d1c",
|
|
89
|
+
"@aztec/entrypoints": "0.0.1-commit.d431d1c",
|
|
90
|
+
"@aztec/ethereum": "0.0.1-commit.d431d1c",
|
|
91
|
+
"@aztec/foundation": "0.0.1-commit.d431d1c",
|
|
92
|
+
"@aztec/l1-artifacts": "0.0.1-commit.d431d1c",
|
|
93
|
+
"@aztec/protocol-contracts": "0.0.1-commit.d431d1c",
|
|
94
|
+
"@aztec/stdlib": "0.0.1-commit.d431d1c",
|
|
95
95
|
"axios": "^1.12.0",
|
|
96
96
|
"tslib": "^2.4.0",
|
|
97
97
|
"viem": "npm:@aztec/viem@2.38.2",
|
|
98
98
|
"zod": "^3.23.8"
|
|
99
99
|
},
|
|
100
100
|
"devDependencies": {
|
|
101
|
-
"@aztec/builder": "0.0.1-commit.
|
|
101
|
+
"@aztec/builder": "0.0.1-commit.d431d1c",
|
|
102
102
|
"@jest/globals": "^30.0.0",
|
|
103
103
|
"@types/jest": "^30.0.0",
|
|
104
104
|
"@types/node": "^22.15.17",
|
package/src/api/block.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { Body,
|
|
1
|
+
export { Body, L2BlockNew } from '@aztec/stdlib/block';
|
|
2
2
|
export { getTimestampRangeForEpoch } from '@aztec/stdlib/epoch-helpers';
|
package/src/api/contract.ts
CHANGED
|
@@ -10,21 +10,13 @@
|
|
|
10
10
|
* or can be queried via `simulate()`.
|
|
11
11
|
*
|
|
12
12
|
* ```ts
|
|
13
|
-
*
|
|
14
|
-
* const contract = await Contract.deploy(wallet, MyContractArtifact, [...constructorArgs]).send({ from: accountAddress });
|
|
13
|
+
* const contract = await Contract.deploy(wallet, MyContractArtifact, [...constructorArgs]).send().deployed();
|
|
15
14
|
* console.log(`Contract deployed at ${contract.address}`);
|
|
16
|
-
*
|
|
17
|
-
* // Or get the full receipt with contract and instance
|
|
18
|
-
* const receipt = await Contract.deploy(wallet, MyContractArtifact, [...constructorArgs]).send({
|
|
19
|
-
* from: accountAddress,
|
|
20
|
-
* wait: { returnReceipt: true }
|
|
21
|
-
* });
|
|
22
|
-
* console.log(`Contract deployed at ${receipt.contract.address}`);
|
|
23
15
|
* ```
|
|
24
16
|
*
|
|
25
17
|
* ```ts
|
|
26
18
|
* const contract = Contract.at(address, MyContractArtifact, wallet);
|
|
27
|
-
* await contract.methods.mint(1000, owner).send(
|
|
19
|
+
* await contract.methods.mint(1000, owner).send().wait();
|
|
28
20
|
* console.log(`Total supply is now ${await contract.methods.totalSupply().simulate()}`);
|
|
29
21
|
* ```
|
|
30
22
|
*
|
|
@@ -33,8 +25,9 @@
|
|
|
33
25
|
* a transaction to the network via the `send` method, but you can also `simulate` it without sending,
|
|
34
26
|
* or obtaining the `request` for aggregating into a {@link BatchCall}.
|
|
35
27
|
*
|
|
36
|
-
* The `send`
|
|
37
|
-
*
|
|
28
|
+
* The result of `send`ing a transaction is a {@link SentTx} object, from which you can get the
|
|
29
|
+
* transaction hash, or simply `wait` until the transaction is mined and the local PXE
|
|
30
|
+
* has synchronized its changes.
|
|
38
31
|
*
|
|
39
32
|
* @remarks If you are using typescript, consider using the
|
|
40
33
|
* {@link https://docs.aztec.network/developers/aztec-nr/how_to_compile_contract#use-generated-interfaces | autogenerated type-safe interfaces}
|
|
@@ -46,35 +39,27 @@ export { Contract } from '../contract/contract.js';
|
|
|
46
39
|
export { ContractFunctionInteraction } from '../contract/contract_function_interaction.js';
|
|
47
40
|
|
|
48
41
|
export {
|
|
49
|
-
NO_WAIT,
|
|
50
|
-
type NoWait,
|
|
51
42
|
type RequestInteractionOptions,
|
|
52
43
|
type SendInteractionOptions,
|
|
53
44
|
type ProfileInteractionOptions,
|
|
54
45
|
type SimulateInteractionOptions,
|
|
55
46
|
type InteractionFeeOptions,
|
|
56
|
-
type InteractionWaitOptions,
|
|
57
47
|
type GasSettingsOption,
|
|
58
|
-
type SendReturn,
|
|
59
|
-
type SimulationReturn,
|
|
60
48
|
toProfileOptions,
|
|
61
49
|
toSendOptions,
|
|
62
50
|
toSimulateOptions,
|
|
63
51
|
} from '../contract/interaction_options.js';
|
|
64
52
|
|
|
65
|
-
export { DefaultWaitOpts, type WaitOpts } from '../contract/
|
|
53
|
+
export { DefaultWaitOpts, SentTx, type WaitOpts } from '../contract/sent_tx.js';
|
|
66
54
|
export { ContractBase, type ContractMethod, type ContractStorageLayout } from '../contract/contract_base.js';
|
|
67
55
|
export { BatchCall } from '../contract/batch_call.js';
|
|
68
56
|
export {
|
|
69
57
|
type DeployOptions,
|
|
70
|
-
type DeployReturn,
|
|
71
|
-
type DeployTxReceipt,
|
|
72
|
-
type DeployWaitOptions,
|
|
73
|
-
type DeployInteractionWaitOptions,
|
|
74
58
|
DeployMethod,
|
|
75
59
|
type RequestDeployOptions,
|
|
76
60
|
type SimulateDeployOptions,
|
|
77
61
|
} from '../contract/deploy_method.js';
|
|
62
|
+
export { DeploySentTx } from '../contract/deploy_sent_tx.js';
|
|
78
63
|
export { waitForProven, type WaitForProvenOpts, DefaultWaitForProvenOpts } from '../contract/wait_for_proven.js';
|
|
79
64
|
export { getGasLimits } from '../contract/get_gas_limits.js';
|
|
80
65
|
|
package/src/api/node.ts
CHANGED
|
@@ -3,22 +3,18 @@
|
|
|
3
3
|
*
|
|
4
4
|
* The primary function is {@link createAztecNodeClient}, which creates a JSON-RPC client
|
|
5
5
|
* that connects to a running Aztec node instance. Use {@link waitForNode} to wait for
|
|
6
|
-
* the node to be ready before proceeding
|
|
7
|
-
* to be mined.
|
|
6
|
+
* the node to be ready before proceeding.
|
|
8
7
|
*
|
|
9
8
|
* @example
|
|
10
9
|
* ```ts
|
|
11
|
-
* import { createAztecNodeClient, waitForNode
|
|
10
|
+
* import { createAztecNodeClient, waitForNode } from '@aztec/aztec.js/node';
|
|
12
11
|
*
|
|
13
12
|
* const node = createAztecNodeClient('http://localhost:8080');
|
|
14
13
|
* await waitForNode(node);
|
|
15
14
|
* const blockNumber = await node.getBlockNumber();
|
|
16
|
-
*
|
|
17
|
-
* // Wait for a transaction
|
|
18
|
-
* const receipt = await waitForTx(node, txHash);
|
|
19
15
|
* ```
|
|
20
16
|
*
|
|
21
17
|
* @packageDocumentation
|
|
22
18
|
*/
|
|
23
|
-
export { createAztecNodeClient, waitForNode,
|
|
19
|
+
export { createAztecNodeClient, waitForNode, type AztecNode } from '../utils/node.js';
|
|
24
20
|
export { type NodeInfo } from '@aztec/stdlib/contract';
|
package/src/api/tx.ts
CHANGED
package/src/api/wallet.ts
CHANGED
|
@@ -11,13 +11,10 @@ export {
|
|
|
11
11
|
type Wallet,
|
|
12
12
|
type PrivateEvent,
|
|
13
13
|
type PrivateEventFilter,
|
|
14
|
-
type ContractMetadata,
|
|
15
|
-
type ContractClassMetadata,
|
|
16
14
|
FunctionCallSchema,
|
|
17
15
|
ExecutionPayloadSchema,
|
|
18
16
|
GasSettingsOptionSchema,
|
|
19
17
|
WalletSimulationFeeOptionSchema,
|
|
20
|
-
WaitOptsSchema,
|
|
21
18
|
SendOptionsSchema,
|
|
22
19
|
SimulateOptionsSchema,
|
|
23
20
|
ProfileOptionsSchema,
|
|
@@ -26,8 +23,6 @@ export {
|
|
|
26
23
|
EventMetadataDefinitionSchema,
|
|
27
24
|
PrivateEventSchema,
|
|
28
25
|
PrivateEventFilterSchema,
|
|
29
|
-
ContractClassMetadataSchema,
|
|
30
|
-
ContractMetadataSchema,
|
|
31
26
|
WalletSchema,
|
|
32
27
|
} from '../wallet/wallet.js';
|
|
33
28
|
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
3
|
-
import type { Capsule, ExecutionPayload
|
|
3
|
+
import type { Capsule, ExecutionPayload } from '@aztec/stdlib/tx';
|
|
4
4
|
|
|
5
5
|
import type { Wallet } from '../wallet/wallet.js';
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
type RequestInteractionOptions,
|
|
9
|
-
type SendInteractionOptions,
|
|
10
|
-
type SendInteractionOptionsWithoutWait,
|
|
11
|
-
type SendReturn,
|
|
12
|
-
toSendOptions,
|
|
13
|
-
} from './interaction_options.js';
|
|
6
|
+
import { type RequestInteractionOptions, type SendInteractionOptions, toSendOptions } from './interaction_options.js';
|
|
7
|
+
import { SentTx } from './sent_tx.js';
|
|
14
8
|
|
|
15
9
|
/**
|
|
16
10
|
* Base class for an interaction with a contract, be it a deployment, a function call, or a batch.
|
|
@@ -36,26 +30,20 @@ export abstract class BaseContractInteraction {
|
|
|
36
30
|
// docs:start:send
|
|
37
31
|
/**
|
|
38
32
|
* Sends a transaction to the contract function with the specified options.
|
|
39
|
-
*
|
|
33
|
+
* This function throws an error if called on a utility function.
|
|
34
|
+
* It creates and signs the transaction if necessary, and returns a SentTx instance,
|
|
35
|
+
* which can be used to track the transaction status, receipt, and events.
|
|
40
36
|
* @param options - An object containing 'from' property representing
|
|
41
|
-
* the AztecAddress of the sender
|
|
42
|
-
* @returns
|
|
37
|
+
* the AztecAddress of the sender and optional fee configuration
|
|
38
|
+
* @returns A SentTx instance for tracking the transaction status and information.
|
|
43
39
|
*/
|
|
44
|
-
|
|
45
|
-
public send<TReturn = TxReceipt>(options: SendInteractionOptionsWithoutWait): Promise<TReturn>;
|
|
46
|
-
// Generic overload for explicit wait values
|
|
47
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
48
|
-
public send<TReturn = TxReceipt, W extends InteractionWaitOptions = undefined>(
|
|
49
|
-
options: SendInteractionOptions<W>,
|
|
50
|
-
): Promise<SendReturn<W, TReturn>>;
|
|
51
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
52
|
-
public async send<TReturn = TxReceipt>(
|
|
53
|
-
options: SendInteractionOptions<InteractionWaitOptions>,
|
|
54
|
-
): Promise<SendReturn<typeof options.wait, TReturn>> {
|
|
40
|
+
public send(options: SendInteractionOptions): SentTx {
|
|
55
41
|
// docs:end:send
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
42
|
+
const sendTx = async () => {
|
|
43
|
+
const executionPayload = await this.request(options);
|
|
44
|
+
const sendOptions = toSendOptions(options);
|
|
45
|
+
return this.wallet.sendTx(executionPayload, sendOptions);
|
|
46
|
+
};
|
|
47
|
+
return new SentTx(this.wallet, sendTx);
|
|
60
48
|
}
|
|
61
49
|
}
|
|
@@ -9,46 +9,27 @@ import {
|
|
|
9
9
|
getContractInstanceFromInstantiationParams,
|
|
10
10
|
} from '@aztec/stdlib/contract';
|
|
11
11
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
12
|
-
import { type Capsule,
|
|
12
|
+
import { type Capsule, type TxProfileResult, collectOffchainEffects } 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 {
|
|
17
|
+
import type { 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';
|
|
21
22
|
import { getGasLimits } from './get_gas_limits.js';
|
|
22
23
|
import {
|
|
23
|
-
NO_WAIT,
|
|
24
|
-
type NoWait,
|
|
25
24
|
type ProfileInteractionOptions,
|
|
26
25
|
type RequestInteractionOptions,
|
|
27
|
-
type
|
|
26
|
+
type SendInteractionOptions,
|
|
28
27
|
type SimulationInteractionFeeOptions,
|
|
29
28
|
type SimulationReturn,
|
|
30
29
|
toProfileOptions,
|
|
31
30
|
toSendOptions,
|
|
32
31
|
toSimulateOptions,
|
|
33
32
|
} from './interaction_options.js';
|
|
34
|
-
import type { WaitOpts } from './wait_opts.js';
|
|
35
|
-
|
|
36
|
-
/**
|
|
37
|
-
* Wait options specific to deployment transactions.
|
|
38
|
-
* Extends WaitOpts with a flag to return the full receipt instead of just the contract.
|
|
39
|
-
*/
|
|
40
|
-
export type DeployWaitOptions = WaitOpts & {
|
|
41
|
-
/** If true, return the full DeployTxReceipt instead of just the contract. Defaults to false. */
|
|
42
|
-
returnReceipt?: boolean;
|
|
43
|
-
};
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
* Type for wait options in deployment interactions.
|
|
47
|
-
* - NO_WAIT symbol: Don't wait, return TxHash immediately
|
|
48
|
-
* - DeployWaitOptions: Wait with custom options
|
|
49
|
-
* - undefined: Wait with default options
|
|
50
|
-
*/
|
|
51
|
-
export type DeployInteractionWaitOptions = NoWait | DeployWaitOptions | undefined;
|
|
52
33
|
|
|
53
34
|
/**
|
|
54
35
|
* Options for deploying a contract on the Aztec network.
|
|
@@ -74,34 +55,21 @@ export type RequestDeployOptions = RequestInteractionOptions & {
|
|
|
74
55
|
};
|
|
75
56
|
|
|
76
57
|
/**
|
|
77
|
-
*
|
|
58
|
+
* Extends the deployment options with the required parameters to send the transaction
|
|
78
59
|
*/
|
|
79
|
-
export type
|
|
60
|
+
export type DeployOptions = Omit<RequestDeployOptions, 'deployer'> & {
|
|
80
61
|
/**
|
|
81
62
|
* Set to true to *not* include the sender in the address computation. This option
|
|
82
63
|
* is mutually exclusive with "deployer"
|
|
83
64
|
*/
|
|
84
65
|
universalDeploy?: boolean;
|
|
85
|
-
} & Pick<
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Extends the deployment options with the required parameters to send the transaction.
|
|
89
|
-
*/
|
|
90
|
-
export type DeployOptions<W extends DeployInteractionWaitOptions = undefined> = DeployOptionsWithoutWait & {
|
|
91
|
-
/**
|
|
92
|
-
* Options for waiting for the transaction to be mined.
|
|
93
|
-
* - undefined (default): wait with default options and return the contract instance
|
|
94
|
-
* - DeployWaitOptions: wait with custom options and return contract or receipt based on returnReceipt flag
|
|
95
|
-
* - NO_WAIT: return TxHash immediately without waiting
|
|
96
|
-
*/
|
|
97
|
-
wait?: W;
|
|
98
|
-
};
|
|
66
|
+
} & Pick<SendInteractionOptions, 'from' | 'fee'>;
|
|
99
67
|
|
|
100
68
|
/**
|
|
101
69
|
* Options for simulating the deployment of a contract
|
|
102
70
|
* Allows skipping certain validations and computing gas estimations
|
|
103
71
|
*/
|
|
104
|
-
export type SimulateDeployOptions = Omit<
|
|
72
|
+
export type SimulateDeployOptions = Omit<DeployOptions, 'fee'> & {
|
|
105
73
|
/** The fee options for the transaction. */
|
|
106
74
|
fee?: SimulationInteractionFeeOptions;
|
|
107
75
|
/** Simulate without checking for the validity of the resulting transaction,
|
|
@@ -115,29 +83,6 @@ export type SimulateDeployOptions = Omit<DeployOptionsWithoutWait, 'fee'> & {
|
|
|
115
83
|
includeMetadata?: boolean;
|
|
116
84
|
};
|
|
117
85
|
|
|
118
|
-
/** Receipt for a deployment transaction with the deployed contract instance. */
|
|
119
|
-
export type DeployTxReceipt<TContract extends ContractBase = ContractBase> = TxReceipt & {
|
|
120
|
-
/** Type-safe wrapper around the deployed contract instance, linked to the deployment wallet */
|
|
121
|
-
contract: TContract;
|
|
122
|
-
/** The deployed contract instance with address and metadata. */
|
|
123
|
-
instance: ContractInstanceWithAddress;
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Represents the result type of deploying a contract.
|
|
128
|
-
* - If wait is NO_WAIT, returns TxHash immediately.
|
|
129
|
-
* - If wait has returnReceipt: true, returns DeployTxReceipt after waiting.
|
|
130
|
-
* - Otherwise (undefined or DeployWaitOptions without returnReceipt), returns TContract after waiting.
|
|
131
|
-
*/
|
|
132
|
-
export type DeployReturn<TContract extends ContractBase, W extends DeployInteractionWaitOptions> = W extends NoWait
|
|
133
|
-
? TxHash
|
|
134
|
-
: W extends {
|
|
135
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
136
|
-
returnReceipt: true;
|
|
137
|
-
}
|
|
138
|
-
? DeployTxReceipt<TContract>
|
|
139
|
-
: TContract;
|
|
140
|
-
|
|
141
86
|
/**
|
|
142
87
|
* Contract interaction for deployment.
|
|
143
88
|
* Handles class publication, instance publication, and initialization of the contract.
|
|
@@ -147,6 +92,8 @@ export type DeployReturn<TContract extends ContractBase, W extends DeployInterac
|
|
|
147
92
|
* then technically the contract has already been "created", and all of the contract's
|
|
148
93
|
* functions (private and utility) can be interacted-with immediately, without any
|
|
149
94
|
* "deployment tx".
|
|
95
|
+
*
|
|
96
|
+
* Extends the BaseContractInteraction class.
|
|
150
97
|
*/
|
|
151
98
|
export class DeployMethod<TContract extends ContractBase = ContractBase> extends BaseContractInteraction {
|
|
152
99
|
/** The contract instance to be deployed. */
|
|
@@ -195,30 +142,13 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
195
142
|
return finalExecutionPayload;
|
|
196
143
|
}
|
|
197
144
|
|
|
198
|
-
convertDeployOptionsToRequestOptions(options:
|
|
145
|
+
convertDeployOptionsToRequestOptions(options: DeployOptions): RequestDeployOptions {
|
|
199
146
|
return {
|
|
200
147
|
...options,
|
|
201
148
|
deployer: !options?.universalDeploy ? options.from : undefined,
|
|
202
149
|
};
|
|
203
150
|
}
|
|
204
151
|
|
|
205
|
-
/**
|
|
206
|
-
* Converts DeployOptions to SendOptions, stripping out the returnReceipt flag if present.
|
|
207
|
-
* @param options - Deploy options with wait parameter
|
|
208
|
-
* @returns Send options with wait parameter
|
|
209
|
-
*/
|
|
210
|
-
private convertDeployOptionsToSendOptions<W extends DeployInteractionWaitOptions>(
|
|
211
|
-
options: DeployOptions<W>,
|
|
212
|
-
// eslint-disable-next-line jsdoc/require-jsdoc
|
|
213
|
-
): SendOptions<W extends { returnReceipt: true } ? WaitOpts : W> {
|
|
214
|
-
return {
|
|
215
|
-
...toSendOptions({
|
|
216
|
-
...options,
|
|
217
|
-
wait: options.wait as any,
|
|
218
|
-
}),
|
|
219
|
-
} as any;
|
|
220
|
-
}
|
|
221
|
-
|
|
222
152
|
/**
|
|
223
153
|
* Adds this contract to the wallet and returns the Contract object.
|
|
224
154
|
* @param options - Deployment options.
|
|
@@ -302,42 +232,20 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
302
232
|
|
|
303
233
|
/**
|
|
304
234
|
* Send a contract deployment transaction (initialize and/or publish) using the provided options.
|
|
305
|
-
*
|
|
235
|
+
* This function extends the 'send' method from the ContractFunctionInteraction class,
|
|
236
|
+
* allowing us to send a transaction specifically for contract deployment.
|
|
306
237
|
*
|
|
307
238
|
* @param options - An object containing various deployment options such as contractAddressSalt and from.
|
|
308
|
-
* @returns
|
|
239
|
+
* @returns A SentTx object that returns the receipt and the deployed contract instance.
|
|
309
240
|
*/
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
public override async send(options: DeployOptions<DeployInteractionWaitOptions>): Promise<any> {
|
|
319
|
-
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
320
|
-
const sendOptions = this.convertDeployOptionsToSendOptions(options);
|
|
321
|
-
|
|
322
|
-
if (options.wait === NO_WAIT) {
|
|
323
|
-
const txHash = await this.wallet.sendTx(executionPayload, sendOptions as SendOptions<NoWait>);
|
|
324
|
-
this.log.debug(`Sent deployment tx ${txHash.hash} of ${this.artifact.name} contract`);
|
|
325
|
-
return txHash;
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
const receipt = await this.wallet.sendTx(executionPayload, sendOptions as SendOptions<WaitOpts | undefined>);
|
|
329
|
-
this.log.debug(`Deployed ${this.artifact.name} contract in tx ${receipt.txHash}`);
|
|
330
|
-
|
|
331
|
-
// Attach contract instance
|
|
332
|
-
const instance = await this.getInstance(options);
|
|
333
|
-
const contract = this.postDeployCtor(instance, this.wallet) as TContract;
|
|
334
|
-
|
|
335
|
-
// Return full receipt if requested, otherwise just the contract
|
|
336
|
-
if (options.wait && typeof options.wait === 'object' && options.wait.returnReceipt) {
|
|
337
|
-
return { ...receipt, contract, instance };
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
return contract;
|
|
241
|
+
public override send(options: DeployOptions): DeploySentTx<TContract> {
|
|
242
|
+
const sendTx = async () => {
|
|
243
|
+
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
244
|
+
const sendOptions = toSendOptions(options);
|
|
245
|
+
return this.wallet.sendTx(executionPayload, sendOptions);
|
|
246
|
+
};
|
|
247
|
+
this.log.debug(`Sent deployment tx of ${this.artifact.name} contract`);
|
|
248
|
+
return new DeploySentTx(this.wallet, sendTx, this.postDeployCtor, () => this.getInstance(options));
|
|
341
249
|
}
|
|
342
250
|
|
|
343
251
|
/**
|
|
@@ -388,7 +296,7 @@ export class DeployMethod<TContract extends ContractBase = ContractBase> extends
|
|
|
388
296
|
*
|
|
389
297
|
* @returns An object containing the function return value and profile result.
|
|
390
298
|
*/
|
|
391
|
-
public async profile(options:
|
|
299
|
+
public async profile(options: DeployOptions & ProfileInteractionOptions): Promise<TxProfileResult> {
|
|
392
300
|
const executionPayload = await this.request(this.convertDeployOptionsToRequestOptions(options));
|
|
393
301
|
return await this.wallet.profileTx(executionPayload, {
|
|
394
302
|
...toProfileOptions(options),
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
|
2
|
+
import type { FieldsOf } from '@aztec/foundation/types';
|
|
3
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
4
|
+
import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
5
|
+
|
|
6
|
+
import type { Wallet } from '../wallet/wallet.js';
|
|
7
|
+
import type { ContractBase } from './contract_base.js';
|
|
8
|
+
import { SentTx, type WaitOpts } from './sent_tx.js';
|
|
9
|
+
|
|
10
|
+
/** Options related to waiting for a deployment tx. */
|
|
11
|
+
export type DeployedWaitOpts = WaitOpts & {
|
|
12
|
+
/** Wallet to use for creating a contract instance. Uses the one set in the deployer constructor if not set. */
|
|
13
|
+
wallet?: Wallet;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/** Extends a transaction receipt with a contract instance that represents the newly deployed contract. */
|
|
17
|
+
export type DeployTxReceipt<TContract extends ContractBase = ContractBase> = FieldsOf<TxReceipt> & {
|
|
18
|
+
/** Instance of the newly deployed contract. */
|
|
19
|
+
contract: TContract;
|
|
20
|
+
/** The deployed contract instance with address and metadata. */
|
|
21
|
+
instance: ContractInstanceWithAddress;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* A contract deployment transaction sent to the network, extending SentTx with methods to publish a contract instance.
|
|
26
|
+
*/
|
|
27
|
+
export class DeploySentTx<TContract extends ContractBase = ContractBase> extends SentTx {
|
|
28
|
+
private log = createLogger('aztecjs:deploy_sent_tx');
|
|
29
|
+
|
|
30
|
+
constructor(
|
|
31
|
+
wallet: Wallet,
|
|
32
|
+
sendTx: () => Promise<TxHash>,
|
|
33
|
+
private postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
|
|
34
|
+
/** A getter for the deployed contract instance */
|
|
35
|
+
private instanceGetter: () => Promise<ContractInstanceWithAddress>,
|
|
36
|
+
) {
|
|
37
|
+
super(wallet, sendTx);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Returns the contract instance for this deployment.
|
|
42
|
+
* @returns The deployed contract instance with address and metadata.
|
|
43
|
+
*/
|
|
44
|
+
public async getInstance(): Promise<ContractInstanceWithAddress> {
|
|
45
|
+
return await this.instanceGetter();
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
|
|
50
|
+
* @param opts - Options for configuring the waiting for the tx to be mined.
|
|
51
|
+
* @returns The deployed contract instance.
|
|
52
|
+
*/
|
|
53
|
+
public async deployed(opts?: DeployedWaitOpts): Promise<TContract> {
|
|
54
|
+
const receipt = await this.wait(opts);
|
|
55
|
+
this.log.info(`Contract ${receipt.instance.address.toString()} successfully deployed.`);
|
|
56
|
+
return receipt.contract;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Awaits for the tx to be mined and returns the receipt along with a contract instance. Throws if tx is not mined.
|
|
61
|
+
* @param opts - Options for configuring the waiting for the tx to be mined.
|
|
62
|
+
* @returns The transaction receipt with the deployed contract instance.
|
|
63
|
+
*/
|
|
64
|
+
public override async wait(opts?: DeployedWaitOpts): Promise<DeployTxReceipt<TContract>> {
|
|
65
|
+
const receipt = await super.wait(opts);
|
|
66
|
+
// In the case of DeploySentTx we have a guarantee that this.walletOrNode is a Wallet so we can cast it to Wallet.
|
|
67
|
+
const contractWallet = opts?.wallet ?? (this.walletOrNode as Wallet);
|
|
68
|
+
if (!contractWallet) {
|
|
69
|
+
throw new Error(`A wallet is required for creating a contract instance`);
|
|
70
|
+
}
|
|
71
|
+
const instance = await this.instanceGetter();
|
|
72
|
+
const contract = this.postDeployCtor(instance, contractWallet) as TContract;
|
|
73
|
+
return { ...receipt, contract, instance };
|
|
74
|
+
}
|
|
75
|
+
}
|