@aztec/aztec.js 3.0.0-nightly.20251115 → 3.0.0-nightly.20251119
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/contract.d.ts +1 -1
- package/dest/api/contract.js +1 -1
- package/dest/api/wallet.d.ts +1 -1
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/contract/contract.d.ts +1 -1
- package/dest/contract/contract.d.ts.map +1 -1
- package/dest/contract/contract.js +4 -5
- package/dest/contract/contract_base.d.ts +5 -9
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_base.js +5 -12
- package/dest/contract/deploy_method.d.ts +5 -4
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +4 -2
- package/dest/contract/deploy_sent_tx.d.ts +11 -6
- package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
- package/dest/contract/deploy_sent_tx.js +10 -4
- package/dest/contract/unsafe_contract.js +1 -1
- package/dest/deployment/contract_deployer.d.ts.map +1 -1
- package/dest/deployment/contract_deployer.js +1 -1
- package/dest/wallet/account_manager.js +1 -1
- package/dest/wallet/base_wallet.d.ts +3 -3
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +22 -39
- package/dest/wallet/deploy_account_method.d.ts +2 -2
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/wallet.d.ts +2 -9
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +1 -1
- package/package.json +8 -8
- package/src/api/contract.ts +1 -1
- package/src/api/wallet.ts +0 -1
- package/src/contract/contract.ts +7 -5
- package/src/contract/contract_base.ts +5 -15
- package/src/contract/deploy_method.ts +8 -7
- package/src/contract/deploy_sent_tx.ts +17 -10
- package/src/contract/unsafe_contract.ts +1 -1
- package/src/deployment/contract_deployer.ts +3 -2
- package/src/wallet/account_manager.ts +1 -1
- package/src/wallet/base_wallet.ts +24 -43
- package/src/wallet/deploy_account_method.ts +2 -1
- package/src/wallet/wallet.ts +4 -19
package/dest/api/contract.d.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
17
|
* ```ts
|
|
18
|
-
* const contract =
|
|
18
|
+
* const contract = Contract.at(address, MyContractArtifact, wallet);
|
|
19
19
|
* await contract.methods.mint(1000, owner).send().wait();
|
|
20
20
|
* console.log(`Total supply is now ${await contract.methods.totalSupply().simulate()}`);
|
|
21
21
|
* ```
|
package/dest/api/contract.js
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
17
|
* ```ts
|
|
18
|
-
* const contract =
|
|
18
|
+
* const contract = Contract.at(address, MyContractArtifact, wallet);
|
|
19
19
|
* await contract.methods.mint(1000, owner).send().wait();
|
|
20
20
|
* console.log(`Total supply is now ${await contract.methods.totalSupply().simulate()}`);
|
|
21
21
|
* ```
|
package/dest/api/wallet.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { type Aliased, type
|
|
1
|
+
export { type Aliased, type SimulateOptions, type ProfileOptions, type SendOptions, type BatchableMethods, type BatchedMethod, type BatchedMethodResult, type BatchedMethodResultWrapper, type BatchResults, type Wallet, ContractInstantiationDataSchema, FunctionCallSchema, ExecutionPayloadSchema, GasSettingsOptionSchema, WalletSimulationFeeOptionSchema, SendOptionsSchema, SimulateOptionsSchema, ProfileOptionsSchema, InstanceDataSchema, MessageHashOrIntentSchema, BatchedMethodSchema, ContractMetadataSchema, ContractClassMetadataSchema, EventMetadataDefinitionSchema, WalletSchema, } from '../wallet/wallet.js';
|
|
2
2
|
export { type FeeOptions, BaseWallet } from '../wallet/base_wallet.js';
|
|
3
3
|
export { AccountManager } from '../wallet/account_manager.js';
|
|
4
4
|
export { type DeployAccountOptions, DeployAccountMethod } from '../wallet/deploy_account_method.js';
|
package/dest/api/wallet.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/api/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,
|
|
1
|
+
{"version":3,"file":"wallet.d.ts","sourceRoot":"","sources":["../../src/api/wallet.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EAClB,KAAK,mBAAmB,EACxB,KAAK,0BAA0B,EAC/B,KAAK,YAAY,EACjB,KAAK,MAAM,EACX,+BAA+B,EAC/B,kBAAkB,EAClB,sBAAsB,EACtB,uBAAuB,EACvB,+BAA+B,EAC/B,iBAAiB,EACjB,qBAAqB,EACrB,oBAAoB,EACpB,kBAAkB,EAClB,yBAAyB,EACzB,mBAAmB,EACnB,sBAAsB,EACtB,2BAA2B,EAC3B,6BAA6B,EAC7B,YAAY,GACb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,KAAK,UAAU,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAEvE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,KAAK,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC"}
|
|
@@ -19,7 +19,7 @@ export declare class Contract extends ContractBase {
|
|
|
19
19
|
* @param wallet - The wallet to use when interacting with the contract.
|
|
20
20
|
* @returns A promise that resolves to a new Contract instance.
|
|
21
21
|
*/
|
|
22
|
-
static at(address: AztecAddress, artifact: ContractArtifact, wallet: Wallet):
|
|
22
|
+
static at(address: AztecAddress, artifact: ContractArtifact, wallet: Wallet): Contract;
|
|
23
23
|
/**
|
|
24
24
|
* Creates a tx to deploy (initialize and/or publish) a new instance of a contract.
|
|
25
25
|
* @param wallet - The wallet for executing the deployment.
|
|
@@ -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;
|
|
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;WACW,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,EAAE,MAAM,GAAG,QAAQ;IAI7F;;;;;;OAMG;WACW,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,IAAI,EAAE,GAAG,EAAE,EAAE,eAAe,CAAC,EAAE,MAAM;IAMtG;;;;;;;;OAQG;WACW,oBAAoB,CAChC,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,EAC1B,IAAI,EAAE,GAAG,EAAE,EACX,eAAe,CAAC,EAAE,MAAM;CAM3B"}
|
|
@@ -14,9 +14,8 @@ import { DeployMethod } from './deploy_method.js';
|
|
|
14
14
|
* @param artifact - Build artifact of the contract.
|
|
15
15
|
* @param wallet - The wallet to use when interacting with the contract.
|
|
16
16
|
* @returns A promise that resolves to a new Contract instance.
|
|
17
|
-
*/ static
|
|
18
|
-
|
|
19
|
-
return new Contract(instance, artifact, wallet);
|
|
17
|
+
*/ static at(address, artifact, wallet) {
|
|
18
|
+
return new Contract(address, artifact, wallet);
|
|
20
19
|
}
|
|
21
20
|
/**
|
|
22
21
|
* Creates a tx to deploy (initialize and/or publish) a new instance of a contract.
|
|
@@ -25,7 +24,7 @@ import { DeployMethod } from './deploy_method.js';
|
|
|
25
24
|
* @param args - Arguments for the constructor.
|
|
26
25
|
* @param constructorName - The name of the constructor function to call.
|
|
27
26
|
*/ static deploy(wallet, artifact, args, constructorName) {
|
|
28
|
-
const postDeployCtor = (
|
|
27
|
+
const postDeployCtor = (instance, wallet)=>Contract.at(instance.address, artifact, wallet);
|
|
29
28
|
return new DeployMethod(PublicKeys.default(), wallet, artifact, postDeployCtor, args, constructorName);
|
|
30
29
|
}
|
|
31
30
|
/**
|
|
@@ -37,7 +36,7 @@ import { DeployMethod } from './deploy_method.js';
|
|
|
37
36
|
* @param args - Arguments for the constructor.
|
|
38
37
|
* @param constructorName - The name of the constructor function to call.
|
|
39
38
|
*/ static deployWithPublicKeys(publicKeys, wallet, artifact, args, constructorName) {
|
|
40
|
-
const postDeployCtor = (
|
|
39
|
+
const postDeployCtor = (instance, wallet)=>Contract.at(instance.address, artifact, wallet);
|
|
41
40
|
return new DeployMethod(publicKeys, wallet, artifact, postDeployCtor, args, constructorName);
|
|
42
41
|
}
|
|
43
42
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ContractArtifact, type FieldLayout, FunctionSelector } from '@aztec/stdlib/abi';
|
|
2
|
-
import {
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
3
|
import type { Wallet } from '../wallet/wallet.js';
|
|
4
4
|
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
5
5
|
/**
|
|
@@ -22,8 +22,8 @@ export type ContractStorageLayout<T extends string> = {
|
|
|
22
22
|
* Abstract implementation of a contract extended by the Contract class and generated contract types.
|
|
23
23
|
*/
|
|
24
24
|
export declare class ContractBase {
|
|
25
|
-
/** The
|
|
26
|
-
readonly
|
|
25
|
+
/** The contract's address. */
|
|
26
|
+
readonly address: AztecAddress;
|
|
27
27
|
/** The Application Binary Interface for the contract. */
|
|
28
28
|
readonly artifact: ContractArtifact;
|
|
29
29
|
/** The wallet used for interacting with this contract. */
|
|
@@ -35,16 +35,12 @@ export declare class ContractBase {
|
|
|
35
35
|
[name: string]: ContractMethod;
|
|
36
36
|
};
|
|
37
37
|
protected constructor(
|
|
38
|
-
/** The
|
|
39
|
-
|
|
38
|
+
/** The contract's address. */
|
|
39
|
+
address: AztecAddress,
|
|
40
40
|
/** The Application Binary Interface for the contract. */
|
|
41
41
|
artifact: ContractArtifact,
|
|
42
42
|
/** The wallet used for interacting with this contract. */
|
|
43
43
|
wallet: Wallet);
|
|
44
|
-
/** Address of the contract. */
|
|
45
|
-
get address(): import("../api/addresses.js").AztecAddress;
|
|
46
|
-
/** Partial address of the contract. */
|
|
47
|
-
get partialAddress(): Promise<import("@aztec/foundation/schemas").Fr>;
|
|
48
44
|
/**
|
|
49
45
|
* Creates a new instance of the contract wrapper attached to a different wallet.
|
|
50
46
|
* @param wallet - Wallet to use for sending txs.
|
|
@@ -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,WAAW,EAEhB,gBAAgB,EAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"contract_base.d.ts","sourceRoot":"","sources":["../../src/contract/contract_base.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,WAAW,EAEhB,gBAAgB,EAEjB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAEhE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AAEjF;;;GAGG;AACH,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,2BAA2B,CAAC,GAAG;IAC/E;;OAEG;IACH,QAAQ,EAAE,MAAM,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAC3C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,qBAAqB,CAAC,CAAC,SAAS,MAAM,IAAI;KACnD,CAAC,IAAI,CAAC,GAAG,WAAW;CACtB,CAAC;AAEF;;GAEG;AACH,qBAAa,YAAY;IAOrB,8BAA8B;aACd,OAAO,EAAE,YAAY;IACrC,yDAAyD;aACzC,QAAQ,EAAE,gBAAgB;IAC1C,0DAA0D;IACnD,MAAM,EAAE,MAAM;IAXvB;;OAEG;IACI,OAAO,EAAE;QAAE,CAAC,IAAI,EAAE,MAAM,GAAG,cAAc,CAAA;KAAE,CAAM;IAExD,SAAS;IACP,8BAA8B;IACd,OAAO,EAAE,YAAY;IACrC,yDAAyD;IACzC,QAAQ,EAAE,gBAAgB;IAC1C,0DAA0D;IACnD,MAAM,EAAE,MAAM;IAmBvB;;;;OAIG;IACI,UAAU,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;CAGxC"}
|
|
@@ -1,23 +1,22 @@
|
|
|
1
1
|
import { FunctionSelector, getAllFunctionAbis } from '@aztec/stdlib/abi';
|
|
2
|
-
import { computePartialAddress } from '@aztec/stdlib/contract';
|
|
3
2
|
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
4
3
|
/**
|
|
5
4
|
* Abstract implementation of a contract extended by the Contract class and generated contract types.
|
|
6
5
|
*/ export class ContractBase {
|
|
7
|
-
|
|
6
|
+
address;
|
|
8
7
|
artifact;
|
|
9
8
|
wallet;
|
|
10
9
|
/**
|
|
11
10
|
* An object containing contract methods mapped to their respective names.
|
|
12
11
|
*/ methods;
|
|
13
|
-
constructor(/** The
|
|
14
|
-
this.
|
|
12
|
+
constructor(/** The contract's address. */ address, /** The Application Binary Interface for the contract. */ artifact, /** The wallet used for interacting with this contract. */ wallet){
|
|
13
|
+
this.address = address;
|
|
15
14
|
this.artifact = artifact;
|
|
16
15
|
this.wallet = wallet;
|
|
17
16
|
this.methods = {};
|
|
18
17
|
getAllFunctionAbis(artifact).forEach((f)=>{
|
|
19
18
|
const interactionFunction = (...args)=>{
|
|
20
|
-
return new ContractFunctionInteraction(this.wallet, this.
|
|
19
|
+
return new ContractFunctionInteraction(this.wallet, this.address, f, args);
|
|
21
20
|
};
|
|
22
21
|
this.methods[f.name] = Object.assign(interactionFunction, {
|
|
23
22
|
/**
|
|
@@ -29,17 +28,11 @@ import { ContractFunctionInteraction } from './contract_function_interaction.js'
|
|
|
29
28
|
});
|
|
30
29
|
});
|
|
31
30
|
}
|
|
32
|
-
/** Address of the contract. */ get address() {
|
|
33
|
-
return this.instance.address;
|
|
34
|
-
}
|
|
35
|
-
/** Partial address of the contract. */ get partialAddress() {
|
|
36
|
-
return computePartialAddress(this.instance);
|
|
37
|
-
}
|
|
38
31
|
/**
|
|
39
32
|
* Creates a new instance of the contract wrapper attached to a different wallet.
|
|
40
33
|
* @param wallet - Wallet to use for sending txs.
|
|
41
34
|
* @returns A new contract instance.
|
|
42
35
|
*/ withWallet(wallet) {
|
|
43
|
-
return new ContractBase(this.
|
|
36
|
+
return new ContractBase(this.address, this.artifact, wallet);
|
|
44
37
|
}
|
|
45
38
|
}
|
|
@@ -8,7 +8,6 @@ import { type Capsule, type TxProfileResult } from '@aztec/stdlib/tx';
|
|
|
8
8
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
9
9
|
import type { Wallet } from '../wallet/wallet.js';
|
|
10
10
|
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
11
|
-
import type { Contract } from './contract.js';
|
|
12
11
|
import type { ContractBase } from './contract_base.js';
|
|
13
12
|
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
14
13
|
import { type ProfileInteractionOptions, type RequestInteractionOptions, type SendInteractionOptions, type SimulationInteractionFeeOptions, type SimulationReturn } from './interaction_options.js';
|
|
@@ -31,6 +30,8 @@ export type RequestDeployOptions = RequestInteractionOptions & {
|
|
|
31
30
|
skipInstancePublication?: boolean;
|
|
32
31
|
/** Skip contract initialization. */
|
|
33
32
|
skipInitialization?: boolean;
|
|
33
|
+
/** Skip contract registration in the wallet */
|
|
34
|
+
skipRegistration?: boolean;
|
|
34
35
|
};
|
|
35
36
|
/**
|
|
36
37
|
* Extends the deployment options with the required parameters to send the transaction
|
|
@@ -71,16 +72,16 @@ export type SimulateDeployOptions = Omit<DeployOptions, 'fee'> & {
|
|
|
71
72
|
*
|
|
72
73
|
* Extends the BaseContractInteraction class.
|
|
73
74
|
*/
|
|
74
|
-
export declare class DeployMethod<TContract extends ContractBase =
|
|
75
|
+
export declare class DeployMethod<TContract extends ContractBase = ContractBase> extends BaseContractInteraction {
|
|
75
76
|
private publicKeys;
|
|
76
77
|
protected artifact: ContractArtifact;
|
|
77
|
-
protected postDeployCtor: (
|
|
78
|
+
protected postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract;
|
|
78
79
|
private args;
|
|
79
80
|
/** The contract instance to be deployed. */
|
|
80
81
|
private instance?;
|
|
81
82
|
/** Constructor function to call. */
|
|
82
83
|
private constructorArtifact;
|
|
83
|
-
constructor(publicKeys: PublicKeys, wallet: Wallet, artifact: ContractArtifact, postDeployCtor: (
|
|
84
|
+
constructor(publicKeys: PublicKeys, wallet: Wallet, artifact: ContractArtifact, postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract, args?: any[], constructorNameOrArtifact?: string | FunctionArtifact, authWitnesses?: AuthWitness[], capsules?: Capsule[]);
|
|
84
85
|
/**
|
|
85
86
|
* Returns the execution payload that allows this operation to happen on chain.
|
|
86
87
|
* @param options - Configuration options.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy_method.d.ts","sourceRoot":"","sources":["../../src/contract/deploy_method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,gBAAgB,EAAoB,KAAK,gBAAgB,EAAkB,MAAM,mBAAmB,CAAC;AACnH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,KAAK,2BAA2B,EAIjC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,KAAK,OAAO,EAAE,KAAK,eAAe,EAA0B,MAAM,kBAAkB,CAAC;AAC9F,OAAO,EAAE,gBAAgB,EAA0B,MAAM,kBAAkB,CAAC;AAI5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,uBAAuB,EAAE,MAAM,gCAAgC,CAAC;AACzE,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"deploy_method.d.ts","sourceRoot":"","sources":["../../src/contract/deploy_method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,EAAE,KAAK,gBAAgB,EAAoB,KAAK,gBAAgB,EAAkB,MAAM,mBAAmB,CAAC;AACnH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,EACL,KAAK,2BAA2B,EAIjC,MAAM,wBAAwB,CAAC;AAChC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,KAAK,OAAO,EAAE,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B,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAe5G;;;;;;;OAOG;IACa,IAAI,CAAC,OAAO,EAAE,aAAa,GAAG,YAAY,CAAC,SAAS,CAAC;IAUrE;;;;;OAKG;IACU,WAAW,CAAC,OAAO,CAAC,EAAE,oBAAoB,GAAG,OAAO,CAAC,2BAA2B,CAAC;IAa9F;;;;;;OAMG;IACU,QAAQ,CAAC,OAAO,EAAE,qBAAqB,GAAG,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IAgBtF;;;;;OAKG;IACU,OAAO,CAAC,OAAO,EAAE,aAAa,GAAG,yBAAyB,GAAG,OAAO,CAAC,eAAe,CAAC;IASlG,sCAAsC;IACtC,IAAW,OAAO,6BAEjB;IAED,uDAAuD;IACvD,IAAW,cAAc,4BAExB;IAED;;;;OAIG;IACI,IAAI,CAAC,EACV,aAAkB,EAClB,QAAa,GACd,EAAE;QACD,iDAAiD;QACjD,aAAa,CAAC,EAAE,WAAW,EAAE,CAAC;QAC9B,4CAA4C;QAC5C,QAAQ,CAAC,EAAE,OAAO,EAAE,CAAC;KACtB,GAAG,YAAY;CAYjB"}
|
|
@@ -39,7 +39,9 @@ import { toProfileOptions, toSendOptions, toSimulateOptions } from './interactio
|
|
|
39
39
|
* @returns The execution payload for this operation
|
|
40
40
|
*/ async request(options) {
|
|
41
41
|
const publication = await this.getPublicationExecutionPayload(options);
|
|
42
|
-
|
|
42
|
+
if (!options?.skipRegistration) {
|
|
43
|
+
await this.wallet.registerContract(await this.getInstance(options), this.artifact);
|
|
44
|
+
}
|
|
43
45
|
const initialization = await this.getInitializationExecutionPayload(options);
|
|
44
46
|
const feeExecutionPayload = options?.fee?.paymentMethod ? await options.fee.paymentMethod.getExecutionPayload() : undefined;
|
|
45
47
|
const finalExecutionPayload = feeExecutionPayload ? mergeExecutionPayloads([
|
|
@@ -67,7 +69,7 @@ import { toProfileOptions, toSendOptions, toSimulateOptions } from './interactio
|
|
|
67
69
|
*/ async register(options) {
|
|
68
70
|
const instance = await this.getInstance(options);
|
|
69
71
|
await this.wallet.registerContract(instance, this.artifact);
|
|
70
|
-
return this.postDeployCtor(instance
|
|
72
|
+
return this.postDeployCtor(instance, this.wallet);
|
|
71
73
|
}
|
|
72
74
|
/**
|
|
73
75
|
* Returns an execution payload for:
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
2
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
2
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
4
3
|
import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
5
4
|
import type { Wallet } from '../wallet/wallet.js';
|
|
6
|
-
import type { Contract } from './contract.js';
|
|
7
5
|
import type { ContractBase } from './contract_base.js';
|
|
8
6
|
import { SentTx, type WaitOpts } from './sent_tx.js';
|
|
9
7
|
/** Options related to waiting for a deployment tx. */
|
|
@@ -12,21 +10,28 @@ export type DeployedWaitOpts = WaitOpts & {
|
|
|
12
10
|
wallet?: Wallet;
|
|
13
11
|
};
|
|
14
12
|
/** Extends a transaction receipt with a contract instance that represents the newly deployed contract. */
|
|
15
|
-
export type DeployTxReceipt<TContract extends ContractBase =
|
|
13
|
+
export type DeployTxReceipt<TContract extends ContractBase = ContractBase> = FieldsOf<TxReceipt> & {
|
|
16
14
|
/** Instance of the newly deployed contract. */
|
|
17
15
|
contract: TContract;
|
|
16
|
+
/** The deployed contract instance with address and metadata. */
|
|
17
|
+
instance: ContractInstanceWithAddress;
|
|
18
18
|
};
|
|
19
19
|
/**
|
|
20
20
|
* A contract deployment transaction sent to the network, extending SentTx with methods to publish a contract instance.
|
|
21
21
|
*/
|
|
22
|
-
export declare class DeploySentTx<TContract extends
|
|
22
|
+
export declare class DeploySentTx<TContract extends ContractBase = ContractBase> extends SentTx {
|
|
23
23
|
private postDeployCtor;
|
|
24
24
|
/** A getter for the deployed contract instance */
|
|
25
|
-
instanceGetter
|
|
25
|
+
private instanceGetter;
|
|
26
26
|
private log;
|
|
27
|
-
constructor(wallet: Wallet, sendTx: () => Promise<TxHash>, postDeployCtor: (
|
|
27
|
+
constructor(wallet: Wallet, sendTx: () => Promise<TxHash>, postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
|
|
28
28
|
/** A getter for the deployed contract instance */
|
|
29
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>;
|
|
30
35
|
/**
|
|
31
36
|
* Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
|
|
32
37
|
* @param opts - Options for configuring the waiting for the tx to be mined.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy_sent_tx.d.ts","sourceRoot":"","sources":["../../src/contract/deploy_sent_tx.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"deploy_sent_tx.d.ts","sourceRoot":"","sources":["../../src/contract/deploy_sent_tx.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE1D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,KAAK,QAAQ,EAAE,MAAM,cAAc,CAAC;AAErD,sDAAsD;AACtD,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG;IACxC,+GAA+G;IAC/G,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,0GAA0G;AAC1G,MAAM,MAAM,eAAe,CAAC,SAAS,SAAS,YAAY,GAAG,YAAY,IAAI,QAAQ,CAAC,SAAS,CAAC,GAAG;IACjG,+CAA+C;IAC/C,QAAQ,EAAE,SAAS,CAAC;IACpB,gEAAgE;IAChE,QAAQ,EAAE,2BAA2B,CAAC;CACvC,CAAC;AAEF;;GAEG;AACH,qBAAa,YAAY,CAAC,SAAS,SAAS,YAAY,GAAG,YAAY,CAAE,SAAQ,MAAM;IAMnF,OAAO,CAAC,cAAc;IACtB,kDAAkD;IAClD,OAAO,CAAC,cAAc;IAPxB,OAAO,CAAC,GAAG,CAA0C;gBAGnD,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;IAKpE;;;OAGG;IACU,WAAW,IAAI,OAAO,CAAC,2BAA2B,CAAC;IAIhE;;;;OAIG;IACU,QAAQ,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,SAAS,CAAC;IAMlE;;;;OAIG;IACmB,IAAI,CAAC,IAAI,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,eAAe,CAAC,SAAS,CAAC,CAAC;CAWzF"}
|
|
@@ -10,13 +10,18 @@ import { SentTx } from './sent_tx.js';
|
|
|
10
10
|
super(wallet, sendTx), this.postDeployCtor = postDeployCtor, this.instanceGetter = instanceGetter, this.log = createLogger('aztecjs:deploy_sent_tx');
|
|
11
11
|
}
|
|
12
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
|
+
/**
|
|
13
19
|
* Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
|
|
14
20
|
* @param opts - Options for configuring the waiting for the tx to be mined.
|
|
15
21
|
* @returns The deployed contract instance.
|
|
16
22
|
*/ async deployed(opts) {
|
|
17
23
|
const receipt = await this.wait(opts);
|
|
18
|
-
|
|
19
|
-
this.log.info(`Contract ${instance.address.toString()} successfully deployed.`);
|
|
24
|
+
this.log.info(`Contract ${receipt.instance.address.toString()} successfully deployed.`);
|
|
20
25
|
return receipt.contract;
|
|
21
26
|
}
|
|
22
27
|
/**
|
|
@@ -31,10 +36,11 @@ import { SentTx } from './sent_tx.js';
|
|
|
31
36
|
throw new Error(`A wallet is required for creating a contract instance`);
|
|
32
37
|
}
|
|
33
38
|
const instance = await this.instanceGetter();
|
|
34
|
-
const contract =
|
|
39
|
+
const contract = this.postDeployCtor(instance, contractWallet);
|
|
35
40
|
return {
|
|
36
41
|
...receipt,
|
|
37
|
-
contract
|
|
42
|
+
contract,
|
|
43
|
+
instance
|
|
38
44
|
};
|
|
39
45
|
}
|
|
40
46
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ContractBase } from './contract_base.js';
|
|
2
2
|
/** Unsafe constructor for ContractBase that bypasses the check that the instance is registered in the wallet. */ export class UnsafeContract extends ContractBase {
|
|
3
3
|
constructor(/** The deployed contract instance definition. */ instance, /** The Application Binary Interface for the contract. */ artifact, /** The wallet used for interacting with this contract. */ wallet){
|
|
4
|
-
super(instance, artifact, wallet);
|
|
4
|
+
super(instance.address, artifact, wallet);
|
|
5
5
|
}
|
|
6
6
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract_deployer.d.ts","sourceRoot":"","sources":["../../src/deployment/contract_deployer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D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AAE,GAAG,EAAE;CAY7B"}
|
|
@@ -24,7 +24,7 @@ import { DeployMethod } from '../contract/deploy_method.js';
|
|
|
24
24
|
* @param args - The constructor arguments for the contract being deployed.
|
|
25
25
|
* @returns A DeployMethod instance configured with the ABI, PXE, and constructor arguments.
|
|
26
26
|
*/ deploy(...args) {
|
|
27
|
-
const postDeployCtor = (
|
|
27
|
+
const postDeployCtor = (instance, wallet)=>Contract.at(instance.address, this.artifact, wallet);
|
|
28
28
|
return new DeployMethod(this.publicKeys ?? PublicKeys.default(), this.wallet, this.artifact, postDeployCtor, args, this.constructorName);
|
|
29
29
|
}
|
|
30
30
|
}
|
|
@@ -103,7 +103,7 @@ import { DeployAccountMethod } from './deploy_account_method.js';
|
|
|
103
103
|
constructorName: undefined,
|
|
104
104
|
constructorArgs: undefined
|
|
105
105
|
};
|
|
106
|
-
return new DeployAccountMethod(this.getPublicKeys(), this.wallet, artifact, (
|
|
106
|
+
return new DeployAccountMethod(this.getPublicKeys(), this.wallet, artifact, (instance)=>Contract.at(instance.address, artifact, this.wallet), new Fr(this.salt), constructorArgs, constructorName);
|
|
107
107
|
}
|
|
108
108
|
/**
|
|
109
109
|
* Returns whether this account contract has an initializer function.
|
|
@@ -5,7 +5,7 @@ import type { FieldsOf } from '@aztec/foundation/types';
|
|
|
5
5
|
import { type ContractArtifact, type EventMetadataDefinition, type FunctionCall } from '@aztec/stdlib/abi';
|
|
6
6
|
import type { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
7
7
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
8
|
-
import { type ContractClassMetadata, type ContractInstanceWithAddress, type
|
|
8
|
+
import { type ContractClassMetadata, type ContractInstanceWithAddress, type ContractMetadata } from '@aztec/stdlib/contract';
|
|
9
9
|
import { GasSettings } from '@aztec/stdlib/gas';
|
|
10
10
|
import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
11
11
|
import type { TxExecutionRequest, TxHash, TxProfileResult, TxReceipt, TxSimulationResult, UtilitySimulationResult } from '@aztec/stdlib/tx';
|
|
@@ -13,7 +13,7 @@ import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
|
13
13
|
import type { Account } from '../account/account.js';
|
|
14
14
|
import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
15
15
|
import type { CallIntent, IntentInnerHash } from '../utils/authwit.js';
|
|
16
|
-
import type { Aliased, BatchResults, BatchableMethods, BatchedMethod,
|
|
16
|
+
import type { Aliased, BatchResults, BatchableMethods, BatchedMethod, ProfileOptions, SendOptions, SimulateOptions, Wallet } from './wallet.js';
|
|
17
17
|
/**
|
|
18
18
|
* Options to configure fee payment for a transaction
|
|
19
19
|
*/
|
|
@@ -79,7 +79,7 @@ export declare abstract class BaseWallet implements Wallet {
|
|
|
79
79
|
accountFeePaymentMethodOptions: AccountFeePaymentMethodOptions;
|
|
80
80
|
}>;
|
|
81
81
|
registerSender(address: AztecAddress, _alias?: string): Promise<AztecAddress>;
|
|
82
|
-
registerContract(
|
|
82
|
+
registerContract(instance: ContractInstanceWithAddress, artifact?: ContractArtifact, secretKey?: Fr): Promise<ContractInstanceWithAddress>;
|
|
83
83
|
simulateTx(executionPayload: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
|
|
84
84
|
profileTx(executionPayload: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
|
|
85
85
|
sendTx(executionPayload: ExecutionPayload, opts: SendOptions): Promise<TxHash>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base_wallet.d.ts","sourceRoot":"","sources":["../../src/wallet/base_wallet.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,8BAA8B,EAAwC,MAAM,4BAA4B,CAAC;AAClH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAE9C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAA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EAAE,KAAK,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,GAAG,KAAK;IAcrE,eAAe,CACb,IAAI,EAAE,YAAY,EAClB,QAAQ,CAAC,EAAE,WAAW,EAAE,EACxB,MAAM,CAAC,EAAE,YAAY,EAAE,GACtB,OAAO,CAAC,uBAAuB,CAAC;IAInC,wBAAwB,CAAC,EAAE,EAAE,EAAE,EAAE,eAAe,GAAE,OAAe,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAGlG,mBAAmB,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAIrE,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;IAI1C,gBAAgB,CAAC,CAAC,EACtB,eAAe,EAAE,YAAY,EAC7B,QAAQ,EAAE,uBAAuB,EACjC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,EACb,UAAU,GAAE,YAAY,EAAO,GAC9B,OAAO,CAAC,CAAC,EAAE,CAAC;CAShB"}
|
|
@@ -3,7 +3,7 @@ import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
|
3
3
|
import { Fr } from '@aztec/foundation/fields';
|
|
4
4
|
import { createLogger } from '@aztec/foundation/log';
|
|
5
5
|
import { decodeFromAbi } from '@aztec/stdlib/abi';
|
|
6
|
-
import { computePartialAddress, getContractClassFromArtifact
|
|
6
|
+
import { computePartialAddress, getContractClassFromArtifact } from '@aztec/stdlib/contract';
|
|
7
7
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
8
8
|
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
9
9
|
import { mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
@@ -133,50 +133,33 @@ import { inspect } from 'util';
|
|
|
133
133
|
registerSender(address, _alias = '') {
|
|
134
134
|
return this.pxe.registerSender(address);
|
|
135
135
|
}
|
|
136
|
-
async registerContract(
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
instance = instanceData;
|
|
152
|
-
await this.pxe.registerContract({
|
|
153
|
-
artifact,
|
|
154
|
-
instance
|
|
155
|
-
});
|
|
156
|
-
} else if (isContractInstantiationData(instanceData)) {
|
|
136
|
+
async registerContract(instance, artifact, secretKey) {
|
|
137
|
+
const { contractInstance: existingInstance } = await this.pxe.getContractMetadata(instance.address);
|
|
138
|
+
if (existingInstance) {
|
|
139
|
+
// Instance already registered in the wallet
|
|
140
|
+
if (artifact) {
|
|
141
|
+
const thisContractClass = await getContractClassFromArtifact(artifact);
|
|
142
|
+
if (!thisContractClass.id.equals(existingInstance.currentContractClassId)) {
|
|
143
|
+
// wallet holds an outdated version of this contract
|
|
144
|
+
await this.pxe.updateContract(instance.address, artifact);
|
|
145
|
+
instance.currentContractClassId = thisContractClass.id;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
// If no artifact provided, we just use the existing registration
|
|
149
|
+
} else {
|
|
150
|
+
// Instance not registered yet
|
|
157
151
|
if (!artifact) {
|
|
158
|
-
|
|
152
|
+
// Try to get the artifact from the wallet's contract class storage
|
|
153
|
+
const classMetadata = await this.pxe.getContractClassMetadata(instance.currentContractClassId, true);
|
|
154
|
+
if (!classMetadata.artifact) {
|
|
155
|
+
throw new Error(`Cannot register contract at ${instance.address.toString()}: artifact is required but not provided, and wallet does not have the artifact for contract class ${instance.currentContractClassId.toString()}`);
|
|
156
|
+
}
|
|
157
|
+
artifact = classMetadata.artifact;
|
|
159
158
|
}
|
|
160
|
-
instance = await getContractInstanceFromInstantiationParams(artifact, instanceData);
|
|
161
159
|
await this.pxe.registerContract({
|
|
162
160
|
artifact,
|
|
163
161
|
instance
|
|
164
162
|
});
|
|
165
|
-
} else {
|
|
166
|
-
if (!artifact) {
|
|
167
|
-
throw new Error(`Contract artifact must be provided when registering a contract using an address`);
|
|
168
|
-
}
|
|
169
|
-
const { contractInstance: maybeContractInstance } = await this.pxe.getContractMetadata(instanceData);
|
|
170
|
-
if (!maybeContractInstance) {
|
|
171
|
-
throw new Error(`Contract instance at ${instanceData.toString()} has not been registered in the wallet's PXE`);
|
|
172
|
-
}
|
|
173
|
-
instance = maybeContractInstance;
|
|
174
|
-
const thisContractClass = await getContractClassFromArtifact(artifact);
|
|
175
|
-
if (!thisContractClass.id.equals(instance.currentContractClassId)) {
|
|
176
|
-
// wallet holds an outdated version of this contract
|
|
177
|
-
await this.pxe.updateContract(instance.address, artifact);
|
|
178
|
-
instance.currentContractClassId = thisContractClass.id;
|
|
179
|
-
}
|
|
180
163
|
}
|
|
181
164
|
if (secretKey) {
|
|
182
165
|
await this.pxe.registerAccount(secretKey, await computePartialAddress(instance));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import type { ContractArtifact, FunctionArtifact } from '@aztec/stdlib/abi';
|
|
3
|
-
import {
|
|
3
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
4
4
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
5
5
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
6
6
|
import type { Contract } from '../contract/contract.js';
|
|
@@ -29,7 +29,7 @@ export type SimulateDeployAccountOptions = Omit<SimulateDeployOptions, 'contract
|
|
|
29
29
|
*/
|
|
30
30
|
export declare class DeployAccountMethod<TContract extends ContractBase = Contract> extends DeployMethod<TContract> {
|
|
31
31
|
private salt;
|
|
32
|
-
constructor(publicKeys: PublicKeys, wallet: Wallet, artifact: ContractArtifact, postDeployCtor: (
|
|
32
|
+
constructor(publicKeys: PublicKeys, wallet: Wallet, artifact: ContractArtifact, postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract, salt: Fr, args?: any[], constructorNameOrArtifact?: string | FunctionArtifact);
|
|
33
33
|
/**
|
|
34
34
|
* Returns a FeePaymentMethod that routes the original one provided as an argument
|
|
35
35
|
* through the account's entrypoint. This allows an account contract to pay
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deploy_account_method.d.ts","sourceRoot":"","sources":["../../src/wallet/deploy_account_method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"deploy_account_method.d.ts","sourceRoot":"","sources":["../../src/wallet/deploy_account_method.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE5E,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAA0B,MAAM,kBAAkB,CAAC;AAE5E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AACjE,OAAO,EACL,YAAY,EACZ,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,qBAAqB,EAC3B,MAAM,8BAA8B,CAAC;AAGtC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,YAAY,CAAC;AAEzC;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG,IAAI,CAAC,oBAAoB,EAAE,qBAAqB,CAAC,CAAC;AAE5F;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,aAAa,EAAE,qBAAqB,GAAG,iBAAiB,CAAC,CAAC;AAElG;;;GAGG;AACH,MAAM,MAAM,4BAA4B,GAAG,IAAI,CAAC,qBAAqB,EAAE,qBAAqB,CAAC,CAAC;AAE9F;;;GAGG;AACH,qBAAa,mBAAmB,CAAC,SAAS,SAAS,YAAY,GAAG,QAAQ,CAAE,SAAQ,YAAY,CAAC,SAAS,CAAC;IAMvG,OAAO,CAAC,IAAI;gBAJZ,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,gBAAgB,EAC1B,cAAc,EAAE,CAAC,QAAQ,EAAE,2BAA2B,EAAE,MAAM,EAAE,MAAM,KAAK,SAAS,EAC5E,IAAI,EAAE,EAAE,EAChB,IAAI,GAAE,GAAG,EAAO,EAChB,yBAAyB,CAAC,EAAE,MAAM,GAAG,gBAAgB;IAKvD;;;;;;;;;OASG;IACH,OAAO,CAAC,uBAAuB;IAa/B;;;;OAIG;IACmB,OAAO,CAAC,IAAI,CAAC,EAAE,2BAA2B,GAAG,OAAO,CAAC,gBAAgB,CAAC;IAgCnF,oCAAoC,CAAC,OAAO,EAAE,aAAa,GAAG,oBAAoB;CAU5F"}
|
package/dest/wallet/wallet.d.ts
CHANGED
|
@@ -3,14 +3,13 @@ import type { Fr } from '@aztec/foundation/fields';
|
|
|
3
3
|
import { type ContractArtifact, type EventMetadataDefinition, type FunctionCall, FunctionType } from '@aztec/stdlib/abi';
|
|
4
4
|
import { AuthWitness } from '@aztec/stdlib/auth-witness';
|
|
5
5
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
6
|
-
import { type ContractClassMetadata, type ContractInstanceWithAddress, type
|
|
6
|
+
import { type ContractClassMetadata, type ContractInstanceWithAddress, type ContractMetadata } from '@aztec/stdlib/contract';
|
|
7
7
|
import { Gas } from '@aztec/stdlib/gas';
|
|
8
8
|
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
9
9
|
import { type ApiSchemaFor, type ZodFor } from '@aztec/stdlib/schemas';
|
|
10
10
|
import { Capsule, HashedValues, TxHash, TxProfileResult, TxReceipt, TxSimulationResult, UtilitySimulationResult } from '@aztec/stdlib/tx';
|
|
11
11
|
import type { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
12
12
|
import { z } from 'zod';
|
|
13
|
-
import type { Contract } from '../contract/contract.js';
|
|
14
13
|
import type { FeeEstimationOptions, GasSettingsOption, ProfileInteractionOptions, SendInteractionOptions, SimulateInteractionOptions } from '../contract/interaction_options.js';
|
|
15
14
|
import type { CallIntent, IntentInnerHash } from '../utils/authwit.js';
|
|
16
15
|
/**
|
|
@@ -26,10 +25,6 @@ export type Aliased<T> = {
|
|
|
26
25
|
*/
|
|
27
26
|
item: T;
|
|
28
27
|
};
|
|
29
|
-
/**
|
|
30
|
-
* A reduced representation of a Contract, only including its instance and artifact
|
|
31
|
-
*/
|
|
32
|
-
export type ContractInstanceAndArtifact = Pick<Contract, 'artifact' | 'instance'>;
|
|
33
28
|
/**
|
|
34
29
|
* Options for simulating interactions with the wallet. Overrides the fee settings of an interaction with
|
|
35
30
|
* a simplified version that only hints at the wallet wether the interaction contains a
|
|
@@ -104,9 +99,7 @@ export type Wallet = {
|
|
|
104
99
|
registerSender(address: AztecAddress, alias?: string): Promise<AztecAddress>;
|
|
105
100
|
getAddressBook(): Promise<Aliased<AztecAddress>[]>;
|
|
106
101
|
getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
107
|
-
registerContract(
|
|
108
|
-
registerContract(instanceData: AztecAddress | ContractInstanceWithAddress | ContractInstantiationData | ContractInstanceAndArtifact, artifact: ContractArtifact): Promise<ContractInstanceWithAddress>;
|
|
109
|
-
registerContract(instanceData: AztecAddress | ContractInstanceWithAddress | ContractInstantiationData | ContractInstanceAndArtifact, artifact: ContractArtifact | undefined, secretKey: Fr | undefined): Promise<ContractInstanceWithAddress>;
|
|
102
|
+
registerContract(instance: ContractInstanceWithAddress, artifact?: ContractArtifact, secretKey?: Fr): Promise<ContractInstanceWithAddress>;
|
|
110
103
|
simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
|
|
111
104
|
simulateUtility(call: FunctionCall, authwits?: AuthWitness[], scopes?: AztecAddress[]): Promise<UtilitySimulationResult>;
|
|
112
105
|
profileTx(exec: ExecutionPayload, opts: ProfileOptions): Promise<TxProfileResult>;
|
|
@@ -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,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAEL,KAAK,gBAAgB,EAErB,KAAK,uBAAuB,EAE5B,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,EACL,KAAK,qBAAqB,EAE1B,KAAK,2BAA2B,EAEhC,KAAK,
|
|
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,KAAK,EAAE,EAAE,EAAE,MAAM,0BAA0B,CAAC;AACnD,OAAO,EAEL,KAAK,gBAAgB,EAErB,KAAK,uBAAuB,EAE5B,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,EACL,KAAK,qBAAqB,EAE1B,KAAK,2BAA2B,EAEhC,KAAK,gBAAgB,EACtB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAA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,MAAM,2BAA2B;;;;;;;;;;;;oBAjI7B,CAAC;;;;;;;;;;;;;;;;;;;oBAWe,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAAD,CAAC;;;;;EA0Hc,CAAC;AAE3C,eAAO,MAAM,6BAA6B;;;;;;;;;;;;EAIxC,CAAC;AAEH,eAAO,MAAM,YAAY,EAAE,YAAY,CAAC,MAAM,CAgD7C,CAAC"}
|
package/dest/wallet/wallet.js
CHANGED
|
@@ -175,7 +175,7 @@ export const WalletSchema = {
|
|
|
175
175
|
alias: z.string(),
|
|
176
176
|
item: schemas.AztecAddress
|
|
177
177
|
}))),
|
|
178
|
-
registerContract: z.function().args(
|
|
178
|
+
registerContract: z.function().args(ContractInstanceWithAddressSchema, optional(ContractArtifactSchema), optional(schemas.Fr)).returns(ContractInstanceWithAddressSchema),
|
|
179
179
|
simulateTx: z.function().args(ExecutionPayloadSchema, SimulateOptionsSchema).returns(TxSimulationResult.schema),
|
|
180
180
|
simulateUtility: z.function().args(FunctionCallSchema, optional(z.array(AuthWitness.schema)), optional(z.array(schemas.AztecAddress))).returns(UtilitySimulationResult.schema),
|
|
181
181
|
profileTx: z.function().args(ExecutionPayloadSchema, ProfileOptionsSchema).returns(TxProfileResult.schema),
|
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": "3.0.0-nightly.
|
|
4
|
+
"version": "3.0.0-nightly.20251119",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
"./abi": "./dest/api/abi.js",
|
|
@@ -84,13 +84,13 @@
|
|
|
84
84
|
]
|
|
85
85
|
},
|
|
86
86
|
"dependencies": {
|
|
87
|
-
"@aztec/constants": "3.0.0-nightly.
|
|
88
|
-
"@aztec/entrypoints": "3.0.0-nightly.
|
|
89
|
-
"@aztec/ethereum": "3.0.0-nightly.
|
|
90
|
-
"@aztec/foundation": "3.0.0-nightly.
|
|
91
|
-
"@aztec/l1-artifacts": "3.0.0-nightly.
|
|
92
|
-
"@aztec/protocol-contracts": "3.0.0-nightly.
|
|
93
|
-
"@aztec/stdlib": "3.0.0-nightly.
|
|
87
|
+
"@aztec/constants": "3.0.0-nightly.20251119",
|
|
88
|
+
"@aztec/entrypoints": "3.0.0-nightly.20251119",
|
|
89
|
+
"@aztec/ethereum": "3.0.0-nightly.20251119",
|
|
90
|
+
"@aztec/foundation": "3.0.0-nightly.20251119",
|
|
91
|
+
"@aztec/l1-artifacts": "3.0.0-nightly.20251119",
|
|
92
|
+
"@aztec/protocol-contracts": "3.0.0-nightly.20251119",
|
|
93
|
+
"@aztec/stdlib": "3.0.0-nightly.20251119",
|
|
94
94
|
"axios": "^1.12.0",
|
|
95
95
|
"tslib": "^2.4.0",
|
|
96
96
|
"viem": "npm:@spalladino/viem@2.38.2-eip7594.0",
|
package/src/api/contract.ts
CHANGED
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
* ```
|
|
16
16
|
*
|
|
17
17
|
* ```ts
|
|
18
|
-
* const contract =
|
|
18
|
+
* const contract = Contract.at(address, MyContractArtifact, wallet);
|
|
19
19
|
* await contract.methods.mint(1000, owner).send().wait();
|
|
20
20
|
* console.log(`Total supply is now ${await contract.methods.totalSupply().simulate()}`);
|
|
21
21
|
* ```
|
package/src/api/wallet.ts
CHANGED
package/src/contract/contract.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
2
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
4
|
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
4
5
|
|
|
5
6
|
import type { Wallet } from '../wallet/wallet.js';
|
|
@@ -21,9 +22,8 @@ export class Contract extends ContractBase {
|
|
|
21
22
|
* @param wallet - The wallet to use when interacting with the contract.
|
|
22
23
|
* @returns A promise that resolves to a new Contract instance.
|
|
23
24
|
*/
|
|
24
|
-
public static
|
|
25
|
-
|
|
26
|
-
return new Contract(instance, artifact, wallet);
|
|
25
|
+
public static at(address: AztecAddress, artifact: ContractArtifact, wallet: Wallet): Contract {
|
|
26
|
+
return new Contract(address, artifact, wallet);
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
/**
|
|
@@ -34,7 +34,8 @@ export class Contract extends ContractBase {
|
|
|
34
34
|
* @param constructorName - The name of the constructor function to call.
|
|
35
35
|
*/
|
|
36
36
|
public static deploy(wallet: Wallet, artifact: ContractArtifact, args: any[], constructorName?: string) {
|
|
37
|
-
const postDeployCtor = (
|
|
37
|
+
const postDeployCtor = (instance: ContractInstanceWithAddress, wallet: Wallet) =>
|
|
38
|
+
Contract.at(instance.address, artifact, wallet);
|
|
38
39
|
return new DeployMethod(PublicKeys.default(), wallet, artifact, postDeployCtor, args, constructorName);
|
|
39
40
|
}
|
|
40
41
|
|
|
@@ -54,7 +55,8 @@ export class Contract extends ContractBase {
|
|
|
54
55
|
args: any[],
|
|
55
56
|
constructorName?: string,
|
|
56
57
|
) {
|
|
57
|
-
const postDeployCtor = (
|
|
58
|
+
const postDeployCtor = (instance: ContractInstanceWithAddress, wallet: Wallet) =>
|
|
59
|
+
Contract.at(instance.address, artifact, wallet);
|
|
58
60
|
return new DeployMethod(publicKeys, wallet, artifact, postDeployCtor, args, constructorName);
|
|
59
61
|
}
|
|
60
62
|
}
|
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
FunctionSelector,
|
|
6
6
|
getAllFunctionAbis,
|
|
7
7
|
} from '@aztec/stdlib/abi';
|
|
8
|
-
import
|
|
8
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
9
9
|
|
|
10
10
|
import type { Wallet } from '../wallet/wallet.js';
|
|
11
11
|
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
@@ -38,8 +38,8 @@ export class ContractBase {
|
|
|
38
38
|
public methods: { [name: string]: ContractMethod } = {};
|
|
39
39
|
|
|
40
40
|
protected constructor(
|
|
41
|
-
/** The
|
|
42
|
-
public readonly
|
|
41
|
+
/** The contract's address. */
|
|
42
|
+
public readonly address: AztecAddress,
|
|
43
43
|
/** The Application Binary Interface for the contract. */
|
|
44
44
|
public readonly artifact: ContractArtifact,
|
|
45
45
|
/** The wallet used for interacting with this contract. */
|
|
@@ -47,7 +47,7 @@ export class ContractBase {
|
|
|
47
47
|
) {
|
|
48
48
|
getAllFunctionAbis(artifact).forEach((f: FunctionAbi) => {
|
|
49
49
|
const interactionFunction = (...args: any[]) => {
|
|
50
|
-
return new ContractFunctionInteraction(this.wallet, this.
|
|
50
|
+
return new ContractFunctionInteraction(this.wallet, this.address, f, args);
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
this.methods[f.name] = Object.assign(interactionFunction, {
|
|
@@ -62,22 +62,12 @@ export class ContractBase {
|
|
|
62
62
|
});
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
/** Address of the contract. */
|
|
66
|
-
public get address() {
|
|
67
|
-
return this.instance.address;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** Partial address of the contract. */
|
|
71
|
-
public get partialAddress() {
|
|
72
|
-
return computePartialAddress(this.instance);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
65
|
/**
|
|
76
66
|
* Creates a new instance of the contract wrapper attached to a different wallet.
|
|
77
67
|
* @param wallet - Wallet to use for sending txs.
|
|
78
68
|
* @returns A new contract instance.
|
|
79
69
|
*/
|
|
80
70
|
public withWallet(wallet: Wallet): this {
|
|
81
|
-
return new ContractBase(this.
|
|
71
|
+
return new ContractBase(this.address, this.artifact, wallet) as this;
|
|
82
72
|
}
|
|
83
73
|
}
|
|
@@ -16,7 +16,6 @@ import { publishContractClass } from '../deployment/publish_class.js';
|
|
|
16
16
|
import { publishInstance } from '../deployment/publish_instance.js';
|
|
17
17
|
import type { Wallet } from '../wallet/wallet.js';
|
|
18
18
|
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
19
|
-
import type { Contract } from './contract.js';
|
|
20
19
|
import type { ContractBase } from './contract_base.js';
|
|
21
20
|
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
22
21
|
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
@@ -51,6 +50,8 @@ export type RequestDeployOptions = RequestInteractionOptions & {
|
|
|
51
50
|
skipInstancePublication?: boolean;
|
|
52
51
|
/** Skip contract initialization. */
|
|
53
52
|
skipInitialization?: boolean;
|
|
53
|
+
/** Skip contract registration in the wallet */
|
|
54
|
+
skipRegistration?: boolean;
|
|
54
55
|
};
|
|
55
56
|
|
|
56
57
|
/**
|
|
@@ -63,8 +64,6 @@ export type DeployOptions = Omit<RequestDeployOptions, 'deployer'> & {
|
|
|
63
64
|
*/
|
|
64
65
|
universalDeploy?: boolean;
|
|
65
66
|
} & Pick<SendInteractionOptions, 'from' | 'fee'>;
|
|
66
|
-
// docs:end:deploy_options
|
|
67
|
-
// TODO(@spalladino): Add unit tests for this class!
|
|
68
67
|
|
|
69
68
|
/**
|
|
70
69
|
* Options for simulating the deployment of a contract
|
|
@@ -96,7 +95,7 @@ export type SimulateDeployOptions = Omit<DeployOptions, 'fee'> & {
|
|
|
96
95
|
*
|
|
97
96
|
* Extends the BaseContractInteraction class.
|
|
98
97
|
*/
|
|
99
|
-
export class DeployMethod<TContract extends ContractBase =
|
|
98
|
+
export class DeployMethod<TContract extends ContractBase = ContractBase> extends BaseContractInteraction {
|
|
100
99
|
/** The contract instance to be deployed. */
|
|
101
100
|
private instance?: ContractInstanceWithAddress = undefined;
|
|
102
101
|
|
|
@@ -107,7 +106,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
107
106
|
private publicKeys: PublicKeys,
|
|
108
107
|
wallet: Wallet,
|
|
109
108
|
protected artifact: ContractArtifact,
|
|
110
|
-
protected postDeployCtor: (
|
|
109
|
+
protected postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
|
|
111
110
|
private args: any[] = [],
|
|
112
111
|
constructorNameOrArtifact?: string | FunctionArtifact,
|
|
113
112
|
authWitnesses: AuthWitness[] = [],
|
|
@@ -125,7 +124,9 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
125
124
|
public async request(options?: RequestDeployOptions): Promise<ExecutionPayload> {
|
|
126
125
|
const publication = await this.getPublicationExecutionPayload(options);
|
|
127
126
|
|
|
128
|
-
|
|
127
|
+
if (!options?.skipRegistration) {
|
|
128
|
+
await this.wallet.registerContract(await this.getInstance(options), this.artifact);
|
|
129
|
+
}
|
|
129
130
|
|
|
130
131
|
const initialization = await this.getInitializationExecutionPayload(options);
|
|
131
132
|
const feeExecutionPayload = options?.fee?.paymentMethod
|
|
@@ -155,7 +156,7 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
155
156
|
public async register(options?: RequestDeployOptions): Promise<TContract> {
|
|
156
157
|
const instance = await this.getInstance(options);
|
|
157
158
|
await this.wallet.registerContract(instance, this.artifact);
|
|
158
|
-
return this.postDeployCtor(instance
|
|
159
|
+
return this.postDeployCtor(instance, this.wallet);
|
|
159
160
|
}
|
|
160
161
|
|
|
161
162
|
/**
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { createLogger } from '@aztec/foundation/log';
|
|
2
2
|
import type { FieldsOf } from '@aztec/foundation/types';
|
|
3
|
-
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
3
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
5
4
|
import type { TxHash, TxReceipt } from '@aztec/stdlib/tx';
|
|
6
5
|
|
|
7
6
|
import type { Wallet } from '../wallet/wallet.js';
|
|
8
|
-
import type { Contract } from './contract.js';
|
|
9
7
|
import type { ContractBase } from './contract_base.js';
|
|
10
8
|
import { SentTx, type WaitOpts } from './sent_tx.js';
|
|
11
9
|
|
|
@@ -16,27 +14,37 @@ export type DeployedWaitOpts = WaitOpts & {
|
|
|
16
14
|
};
|
|
17
15
|
|
|
18
16
|
/** Extends a transaction receipt with a contract instance that represents the newly deployed contract. */
|
|
19
|
-
export type DeployTxReceipt<TContract extends ContractBase =
|
|
17
|
+
export type DeployTxReceipt<TContract extends ContractBase = ContractBase> = FieldsOf<TxReceipt> & {
|
|
20
18
|
/** Instance of the newly deployed contract. */
|
|
21
19
|
contract: TContract;
|
|
20
|
+
/** The deployed contract instance with address and metadata. */
|
|
21
|
+
instance: ContractInstanceWithAddress;
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
/**
|
|
25
25
|
* A contract deployment transaction sent to the network, extending SentTx with methods to publish a contract instance.
|
|
26
26
|
*/
|
|
27
|
-
export class DeploySentTx<TContract extends
|
|
27
|
+
export class DeploySentTx<TContract extends ContractBase = ContractBase> extends SentTx {
|
|
28
28
|
private log = createLogger('aztecjs:deploy_sent_tx');
|
|
29
29
|
|
|
30
30
|
constructor(
|
|
31
31
|
wallet: Wallet,
|
|
32
32
|
sendTx: () => Promise<TxHash>,
|
|
33
|
-
private postDeployCtor: (
|
|
33
|
+
private postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
|
|
34
34
|
/** A getter for the deployed contract instance */
|
|
35
|
-
|
|
35
|
+
private instanceGetter: () => Promise<ContractInstanceWithAddress>,
|
|
36
36
|
) {
|
|
37
37
|
super(wallet, sendTx);
|
|
38
38
|
}
|
|
39
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
|
+
|
|
40
48
|
/**
|
|
41
49
|
* Awaits for the tx to be mined and returns the contract instance. Throws if tx is not mined.
|
|
42
50
|
* @param opts - Options for configuring the waiting for the tx to be mined.
|
|
@@ -44,8 +52,7 @@ export class DeploySentTx<TContract extends Contract = Contract> extends SentTx
|
|
|
44
52
|
*/
|
|
45
53
|
public async deployed(opts?: DeployedWaitOpts): Promise<TContract> {
|
|
46
54
|
const receipt = await this.wait(opts);
|
|
47
|
-
|
|
48
|
-
this.log.info(`Contract ${instance.address.toString()} successfully deployed.`);
|
|
55
|
+
this.log.info(`Contract ${receipt.instance.address.toString()} successfully deployed.`);
|
|
49
56
|
return receipt.contract;
|
|
50
57
|
}
|
|
51
58
|
|
|
@@ -62,7 +69,7 @@ export class DeploySentTx<TContract extends Contract = Contract> extends SentTx
|
|
|
62
69
|
throw new Error(`A wallet is required for creating a contract instance`);
|
|
63
70
|
}
|
|
64
71
|
const instance = await this.instanceGetter();
|
|
65
|
-
const contract =
|
|
66
|
-
return { ...receipt, contract };
|
|
72
|
+
const contract = this.postDeployCtor(instance, contractWallet) as TContract;
|
|
73
|
+
return { ...receipt, contract, instance };
|
|
67
74
|
}
|
|
68
75
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
|
2
|
-
import {
|
|
2
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
3
3
|
import { PublicKeys } from '@aztec/stdlib/keys';
|
|
4
4
|
|
|
5
5
|
import { Contract } from '../contract/contract.js';
|
|
@@ -28,7 +28,8 @@ export class ContractDeployer {
|
|
|
28
28
|
* @returns A DeployMethod instance configured with the ABI, PXE, and constructor arguments.
|
|
29
29
|
*/
|
|
30
30
|
public deploy(...args: any[]) {
|
|
31
|
-
const postDeployCtor = (
|
|
31
|
+
const postDeployCtor = (instance: ContractInstanceWithAddress, wallet: Wallet) =>
|
|
32
|
+
Contract.at(instance.address, this.artifact, wallet);
|
|
32
33
|
return new DeployMethod(
|
|
33
34
|
this.publicKeys ?? PublicKeys.default(),
|
|
34
35
|
this.wallet,
|
|
@@ -138,7 +138,7 @@ export class AccountManager {
|
|
|
138
138
|
this.getPublicKeys(),
|
|
139
139
|
this.wallet,
|
|
140
140
|
artifact,
|
|
141
|
-
|
|
141
|
+
instance => Contract.at(instance.address, artifact, this.wallet),
|
|
142
142
|
new Fr(this.salt),
|
|
143
143
|
constructorArgs,
|
|
144
144
|
constructorName,
|
|
@@ -20,11 +20,9 @@ import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
|
20
20
|
import {
|
|
21
21
|
type ContractClassMetadata,
|
|
22
22
|
type ContractInstanceWithAddress,
|
|
23
|
-
type ContractInstantiationData,
|
|
24
23
|
type ContractMetadata,
|
|
25
24
|
computePartialAddress,
|
|
26
25
|
getContractClassFromArtifact,
|
|
27
|
-
getContractInstanceFromInstantiationParams,
|
|
28
26
|
} from '@aztec/stdlib/contract';
|
|
29
27
|
import { SimulationError } from '@aztec/stdlib/errors';
|
|
30
28
|
import { Gas, GasSettings } from '@aztec/stdlib/gas';
|
|
@@ -49,7 +47,6 @@ import type {
|
|
|
49
47
|
BatchResults,
|
|
50
48
|
BatchableMethods,
|
|
51
49
|
BatchedMethod,
|
|
52
|
-
ContractInstanceAndArtifact,
|
|
53
50
|
ProfileOptions,
|
|
54
51
|
SendOptions,
|
|
55
52
|
SimulateOptions,
|
|
@@ -226,54 +223,38 @@ export abstract class BaseWallet implements Wallet {
|
|
|
226
223
|
}
|
|
227
224
|
|
|
228
225
|
async registerContract(
|
|
229
|
-
|
|
226
|
+
instance: ContractInstanceWithAddress,
|
|
230
227
|
artifact?: ContractArtifact,
|
|
231
228
|
secretKey?: Fr,
|
|
232
229
|
): Promise<ContractInstanceWithAddress> {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
(instanceData as ContractInstanceAndArtifact).instance !== undefined &&
|
|
245
|
-
(instanceData as ContractInstanceAndArtifact).artifact !== undefined
|
|
246
|
-
);
|
|
247
|
-
}
|
|
248
|
-
let instance: ContractInstanceWithAddress;
|
|
249
|
-
if (isContractInstanceAndArtifact(instanceData)) {
|
|
250
|
-
instance = instanceData.instance;
|
|
251
|
-
await this.pxe.registerContract(instanceData);
|
|
252
|
-
} else if (isInstanceWithAddress(instanceData)) {
|
|
253
|
-
instance = instanceData;
|
|
254
|
-
await this.pxe.registerContract({ artifact, instance });
|
|
255
|
-
} else if (isContractInstantiationData(instanceData)) {
|
|
256
|
-
if (!artifact) {
|
|
257
|
-
throw new Error(`Contract artifact must be provided when registering a contract using instantiation data`);
|
|
230
|
+
const { contractInstance: existingInstance } = await this.pxe.getContractMetadata(instance.address);
|
|
231
|
+
|
|
232
|
+
if (existingInstance) {
|
|
233
|
+
// Instance already registered in the wallet
|
|
234
|
+
if (artifact) {
|
|
235
|
+
const thisContractClass = await getContractClassFromArtifact(artifact);
|
|
236
|
+
if (!thisContractClass.id.equals(existingInstance.currentContractClassId)) {
|
|
237
|
+
// wallet holds an outdated version of this contract
|
|
238
|
+
await this.pxe.updateContract(instance.address, artifact);
|
|
239
|
+
instance.currentContractClassId = thisContractClass.id;
|
|
240
|
+
}
|
|
258
241
|
}
|
|
259
|
-
|
|
260
|
-
await this.pxe.registerContract({ artifact, instance });
|
|
242
|
+
// If no artifact provided, we just use the existing registration
|
|
261
243
|
} else {
|
|
244
|
+
// Instance not registered yet
|
|
262
245
|
if (!artifact) {
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
if (!thisContractClass.id.equals(instance.currentContractClassId)) {
|
|
272
|
-
// wallet holds an outdated version of this contract
|
|
273
|
-
await this.pxe.updateContract(instance.address, artifact);
|
|
274
|
-
instance.currentContractClassId = thisContractClass.id;
|
|
246
|
+
// Try to get the artifact from the wallet's contract class storage
|
|
247
|
+
const classMetadata = await this.pxe.getContractClassMetadata(instance.currentContractClassId, true);
|
|
248
|
+
if (!classMetadata.artifact) {
|
|
249
|
+
throw new Error(
|
|
250
|
+
`Cannot register contract at ${instance.address.toString()}: artifact is required but not provided, and wallet does not have the artifact for contract class ${instance.currentContractClassId.toString()}`,
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
artifact = classMetadata.artifact;
|
|
275
254
|
}
|
|
255
|
+
await this.pxe.registerContract({ artifact, instance });
|
|
276
256
|
}
|
|
257
|
+
|
|
277
258
|
if (secretKey) {
|
|
278
259
|
await this.pxe.registerAccount(secretKey, await computePartialAddress(instance));
|
|
279
260
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fr } from '@aztec/foundation/fields';
|
|
2
2
|
import type { ContractArtifact, FunctionArtifact } from '@aztec/stdlib/abi';
|
|
3
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
4
5
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
5
6
|
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
6
7
|
|
|
@@ -44,7 +45,7 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
|
|
|
44
45
|
publicKeys: PublicKeys,
|
|
45
46
|
wallet: Wallet,
|
|
46
47
|
artifact: ContractArtifact,
|
|
47
|
-
postDeployCtor: (
|
|
48
|
+
postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
|
|
48
49
|
private salt: Fr,
|
|
49
50
|
args: any[] = [],
|
|
50
51
|
constructorNameOrArtifact?: string | FunctionArtifact,
|
package/src/wallet/wallet.ts
CHANGED
|
@@ -16,7 +16,6 @@ import {
|
|
|
16
16
|
ContractClassWithIdSchema,
|
|
17
17
|
type ContractInstanceWithAddress,
|
|
18
18
|
ContractInstanceWithAddressSchema,
|
|
19
|
-
type ContractInstantiationData,
|
|
20
19
|
type ContractMetadata,
|
|
21
20
|
} from '@aztec/stdlib/contract';
|
|
22
21
|
import { Gas } from '@aztec/stdlib/gas';
|
|
@@ -35,7 +34,6 @@ import type { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
|
35
34
|
|
|
36
35
|
import { z } from 'zod';
|
|
37
36
|
|
|
38
|
-
import type { Contract } from '../contract/contract.js';
|
|
39
37
|
import type {
|
|
40
38
|
FeeEstimationOptions,
|
|
41
39
|
GasSettingsOption,
|
|
@@ -59,11 +57,6 @@ export type Aliased<T> = {
|
|
|
59
57
|
item: T;
|
|
60
58
|
};
|
|
61
59
|
|
|
62
|
-
/**
|
|
63
|
-
* A reduced representation of a Contract, only including its instance and artifact
|
|
64
|
-
*/
|
|
65
|
-
export type ContractInstanceAndArtifact = Pick<Contract, 'artifact' | 'instance'>;
|
|
66
|
-
|
|
67
60
|
/**
|
|
68
61
|
* Options for simulating interactions with the wallet. Overrides the fee settings of an interaction with
|
|
69
62
|
* a simplified version that only hints at the wallet wether the interaction contains a
|
|
@@ -157,17 +150,9 @@ export type Wallet = {
|
|
|
157
150
|
getAddressBook(): Promise<Aliased<AztecAddress>[]>;
|
|
158
151
|
getAccounts(): Promise<Aliased<AztecAddress>[]>;
|
|
159
152
|
registerContract(
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
registerContract(
|
|
164
|
-
instanceData: AztecAddress | ContractInstanceWithAddress | ContractInstantiationData | ContractInstanceAndArtifact,
|
|
165
|
-
artifact: ContractArtifact,
|
|
166
|
-
): Promise<ContractInstanceWithAddress>;
|
|
167
|
-
registerContract(
|
|
168
|
-
instanceData: AztecAddress | ContractInstanceWithAddress | ContractInstantiationData | ContractInstanceAndArtifact,
|
|
169
|
-
artifact: ContractArtifact | undefined,
|
|
170
|
-
secretKey: Fr | undefined,
|
|
153
|
+
instance: ContractInstanceWithAddress,
|
|
154
|
+
artifact?: ContractArtifact,
|
|
155
|
+
secretKey?: Fr,
|
|
171
156
|
): Promise<ContractInstanceWithAddress>;
|
|
172
157
|
simulateTx(exec: ExecutionPayload, opts: SimulateOptions): Promise<TxSimulationResult>;
|
|
173
158
|
simulateUtility(
|
|
@@ -326,7 +311,7 @@ export const WalletSchema: ApiSchemaFor<Wallet> = {
|
|
|
326
311
|
.returns(z.array(z.object({ alias: z.string(), item: schemas.AztecAddress }))),
|
|
327
312
|
registerContract: z
|
|
328
313
|
.function()
|
|
329
|
-
.args(
|
|
314
|
+
.args(ContractInstanceWithAddressSchema, optional(ContractArtifactSchema), optional(schemas.Fr))
|
|
330
315
|
.returns(ContractInstanceWithAddressSchema),
|
|
331
316
|
simulateTx: z.function().args(ExecutionPayloadSchema, SimulateOptionsSchema).returns(TxSimulationResult.schema),
|
|
332
317
|
simulateUtility: z
|