@aztec/aztec.js 0.24.0 → 0.26.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/account_manager/index.d.ts +4 -2
- package/dest/account_manager/index.d.ts.map +1 -1
- package/dest/account_manager/index.js +15 -6
- package/dest/api/fee.d.ts +2 -1
- package/dest/api/fee.d.ts.map +1 -1
- package/dest/api/fee.js +3 -2
- package/dest/contract/base_contract_interaction.d.ts +5 -0
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +1 -1
- package/dest/contract/batch_call.d.ts +3 -2
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +4 -3
- package/dest/contract/contract.d.ts +4 -2
- package/dest/contract/contract.d.ts.map +1 -1
- package/dest/contract/contract.js +7 -5
- package/dest/contract/contract_function_interaction.d.ts +2 -2
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +4 -4
- package/dest/contract/deploy_method.d.ts +37 -12
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +79 -35
- package/dest/contract/deploy_sent_tx.d.ts +3 -3
- package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
- package/dest/contract/deploy_sent_tx.js +4 -7
- package/dest/contract/sent_tx.d.ts.map +1 -1
- package/dest/contract/sent_tx.js +10 -10
- package/dest/deployment/contract_deployer.d.ts +4 -3
- package/dest/deployment/contract_deployer.d.ts.map +1 -1
- package/dest/deployment/contract_deployer.js +5 -4
- package/dest/deployment/register_class.d.ts +1 -1
- package/dest/deployment/register_class.d.ts.map +1 -1
- package/dest/deployment/register_class.js +4 -3
- package/dest/fee/fee_payment_method.d.ts +1 -5
- package/dest/fee/fee_payment_method.d.ts.map +1 -1
- package/dest/fee/native_fee_payment_method.d.ts +3 -3
- package/dest/fee/native_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/native_fee_payment_method.js +5 -6
- package/dest/fee/{generic_fee_payment_method.d.ts → private_fee_payment_method.d.ts} +8 -14
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -0
- package/dest/fee/private_fee_payment_method.js +62 -0
- package/dest/fee/public_fee_payment_method.d.ts +52 -0
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -0
- package/dest/fee/public_fee_payment_method.js +62 -0
- package/dest/index.d.ts +4 -3
- package/dest/index.d.ts.map +1 -1
- package/dest/index.js +5 -4
- package/dest/rpc_clients/pxe_client.d.ts.map +1 -1
- package/dest/rpc_clients/pxe_client.js +15 -15
- package/dest/utils/authwit.d.ts +30 -4
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +35 -5
- package/dest/utils/cheat_codes.js +2 -2
- package/dest/utils/index.d.ts +0 -1
- package/dest/utils/index.d.ts.map +1 -1
- package/dest/utils/index.js +1 -2
- package/dest/utils/l2_contracts.js +2 -2
- package/dest/wallet/account_wallet.d.ts +8 -1
- package/dest/wallet/account_wallet.d.ts.map +1 -1
- package/dest/wallet/account_wallet.js +32 -8
- package/dest/wallet/base_wallet.d.ts +5 -3
- package/dest/wallet/base_wallet.d.ts.map +1 -1
- package/dest/wallet/base_wallet.js +9 -3
- package/dest/wallet/signerless_wallet.js +2 -2
- package/package.json +7 -7
- package/src/account_manager/index.ts +20 -5
- package/src/api/fee.ts +2 -1
- package/src/contract/base_contract_interaction.ts +6 -0
- package/src/contract/batch_call.ts +4 -3
- package/src/contract/contract.ts +12 -4
- package/src/contract/contract_function_interaction.ts +3 -3
- package/src/contract/deploy_method.ts +105 -64
- package/src/contract/deploy_sent_tx.ts +4 -7
- package/src/contract/sent_tx.ts +9 -9
- package/src/deployment/contract_deployer.ts +15 -3
- package/src/deployment/register_class.ts +6 -2
- package/src/fee/fee_payment_method.ts +1 -6
- package/src/fee/native_fee_payment_method.ts +5 -6
- package/src/fee/{generic_fee_payment_method.ts → private_fee_payment_method.ts} +27 -29
- package/src/fee/public_fee_payment_method.ts +79 -0
- package/src/index.ts +8 -2
- package/src/rpc_clients/pxe_client.ts +15 -14
- package/src/utils/authwit.ts +45 -7
- package/src/utils/cheat_codes.ts +1 -1
- package/src/utils/index.ts +0 -1
- package/src/utils/l2_contracts.ts +1 -1
- package/src/wallet/account_wallet.ts +31 -7
- package/src/wallet/base_wallet.ts +10 -4
- package/src/wallet/signerless_wallet.ts +1 -1
- package/dest/fee/generic_fee_payment_method.d.ts.map +0 -1
- package/dest/fee/generic_fee_payment_method.js +0 -73
- package/dest/utils/secrets.d.ts +0 -8
- package/dest/utils/secrets.d.ts.map +0 -1
- package/dest/utils/secrets.js +0 -10
- package/src/utils/secrets.ts +0 -11
|
@@ -8,6 +8,9 @@ export class BaseWallet {
|
|
|
8
8
|
getContractInstance(address) {
|
|
9
9
|
return this.pxe.getContractInstance(address);
|
|
10
10
|
}
|
|
11
|
+
getContractClass(id) {
|
|
12
|
+
return this.pxe.getContractClass(id);
|
|
13
|
+
}
|
|
11
14
|
addCapsule(capsule) {
|
|
12
15
|
return this.pxe.addCapsule(capsule);
|
|
13
16
|
}
|
|
@@ -41,8 +44,8 @@ export class BaseWallet {
|
|
|
41
44
|
sendTx(tx) {
|
|
42
45
|
return this.pxe.sendTx(tx);
|
|
43
46
|
}
|
|
44
|
-
|
|
45
|
-
return this.pxe.
|
|
47
|
+
getTxEffect(txHash) {
|
|
48
|
+
return this.pxe.getTxEffect(txHash);
|
|
46
49
|
}
|
|
47
50
|
getTxReceipt(txHash) {
|
|
48
51
|
return this.pxe.getTxReceipt(txHash);
|
|
@@ -89,5 +92,8 @@ export class BaseWallet {
|
|
|
89
92
|
addAuthWitness(authWitness) {
|
|
90
93
|
return this.pxe.addAuthWitness(authWitness);
|
|
91
94
|
}
|
|
95
|
+
isContractClassPubliclyRegistered(id) {
|
|
96
|
+
return this.pxe.isContractClassPubliclyRegistered(id);
|
|
97
|
+
}
|
|
92
98
|
}
|
|
93
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
99
|
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SUFDRCxjQUFjO1FBQ1osT0FBTyxJQUFJLENBQUMsR0FBRyxDQUFDLGNBQWMsRUFBRSxDQUFDO0lBQ25DLENBQUM7SUFDRCxXQUFXO1FBQ1QsT0FBTyxJQUFJLENBQUMsR0FBRyxDQUFDLFdBQVcsRUFBRSxDQUFDO0lBQ2hDLENBQUM7SUFDRCx5QkFBeUI7UUFDdkIsT0FBTyxJQUFJLENBQUMsR0FBRyxDQUFDLHlCQUF5QixFQUFFLENBQUM7SUFDOUMsQ0FBQztJQUNELDBCQUEwQixDQUFDLE9BQXFCO1FBQzlDLE9BQU8sSUFBSSxDQUFDLEdBQUcsQ0FBQywwQkFBMEIsQ0FBQyxPQUFPLENBQUMsQ0FBQztJQUN0RCxDQUFDO0lBQ0QsYUFBYTtRQUNYLE9BQU8sSUFBSSxDQUFDLEdBQUcsQ0FBQyxhQUFhLEVBQUUsQ0FBQztJQUNsQyxDQUFDO0lBQ0QsY0FBYyxDQUFDLFdBQXdCO1FBQ3JDLE9BQU8sSUFBSSxDQUFDLEdBQUcsQ0FBQyxjQUFjLENBQUMsV0FBVyxDQUFDLENBQUM7SUFDOUMsQ0FBQztJQUNELGlDQUFpQyxDQUFDLEVBQU07UUFDdEMsT0FBTyxJQUFJLENBQUMsR0FBRyxDQUFDLGlDQUFpQyxDQUFDLEVBQUUsQ0FBQyxDQUFDO0lBQ3hELENBQUM7Q0FDRiJ9
|
|
@@ -7,7 +7,7 @@ import { BaseWallet } from './base_wallet.js';
|
|
|
7
7
|
export class SignerlessWallet extends BaseWallet {
|
|
8
8
|
async createTxExecutionRequest(executions) {
|
|
9
9
|
if (executions.length !== 1) {
|
|
10
|
-
throw new Error(`Unexpected number of executions. Expected 1 but received ${executions.length}
|
|
10
|
+
throw new Error(`Unexpected number of executions. Expected 1 but received ${executions.length}.`);
|
|
11
11
|
}
|
|
12
12
|
const [execution] = executions;
|
|
13
13
|
const packedArguments = PackedArguments.fromArgs(execution.args);
|
|
@@ -22,4 +22,4 @@ export class SignerlessWallet extends BaseWallet {
|
|
|
22
22
|
throw new Error('Method not implemented.');
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
25
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic2lnbmVybGVzc193YWxsZXQuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvd2FsbGV0L3NpZ25lcmxlc3Nfd2FsbGV0LnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBLE9BQU8sRUFBNkIsZUFBZSxFQUFFLGtCQUFrQixFQUFFLE1BQU0sc0JBQXNCLENBQUM7QUFDdEcsT0FBTyxFQUF1QixTQUFTLEVBQUUsTUFBTSxvQkFBb0IsQ0FBQztBQUVwRSxPQUFPLEVBQUUsVUFBVSxFQUFFLE1BQU0sa0JBQWtCLENBQUM7QUFFOUM7O0dBRUc7QUFDSCxNQUFNLE9BQU8sZ0JBQWlCLFNBQVEsVUFBVTtJQUM5QyxLQUFLLENBQUMsd0JBQXdCLENBQUMsVUFBMEI7UUFDdkQsSUFBSSxVQUFVLENBQUMsTUFBTSxLQUFLLENBQUMsRUFBRSxDQUFDO1lBQzVCLE1BQU0sSUFBSSxLQUFLLENBQUMsNERBQTRELFVBQVUsQ0FBQyxNQUFNLEdBQUcsQ0FBQyxDQUFDO1FBQ3BHLENBQUM7UUFDRCxNQUFNLENBQUMsU0FBUyxDQUFDLEdBQUcsVUFBVSxDQUFDO1FBQy9CLE1BQU0sZUFBZSxHQUFHLGVBQWUsQ0FBQyxRQUFRLENBQUMsU0FBUyxDQUFDLElBQUksQ0FBQyxDQUFDO1FBQ2pFLE1BQU0sRUFBRSxPQUFPLEVBQUUsZUFBZSxFQUFFLEdBQUcsTUFBTSxJQUFJLENBQUMsR0FBRyxDQUFDLFdBQVcsRUFBRSxDQUFDO1FBQ2xFLE1BQU0sU0FBUyxHQUFHLFNBQVMsQ0FBQyxLQUFLLENBQUMsT0FBTyxFQUFFLGVBQWUsQ0FBQyxDQUFDO1FBQzVELE9BQU8sT0FBTyxDQUFDLE9BQU8sQ0FDcEIsSUFBSSxrQkFBa0IsQ0FDcEIsU0FBUyxDQUFDLEVBQUUsRUFDWixTQUFTLENBQUMsWUFBWSxFQUN0QixlQUFlLENBQUMsSUFBSSxFQUNwQixTQUFTLEVBQ1QsQ0FBQyxlQUFlLENBQUMsRUFDakIsRUFBRSxDQUNILENBQ0YsQ0FBQztJQUNKLENBQUM7SUFFRCxrQkFBa0I7UUFDaEIsTUFBTSxJQUFJLEtBQUssQ0FBQyx5QkFBeUIsQ0FBQyxDQUFDO0lBQzdDLENBQUM7SUFFRCxpQkFBaUIsQ0FBQyxRQUFZO1FBQzVCLE1BQU0sSUFBSSxLQUFLLENBQUMseUJBQXlCLENBQUMsQ0FBQztJQUM3QyxDQUFDO0NBQ0YifQ==
|
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.
|
|
4
|
+
"version": "0.26.2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./dest/index.js",
|
|
@@ -49,12 +49,12 @@
|
|
|
49
49
|
"rootDir": "./src"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@aztec/circuit-types": "0.
|
|
53
|
-
"@aztec/circuits.js": "0.
|
|
54
|
-
"@aztec/ethereum": "0.
|
|
55
|
-
"@aztec/foundation": "0.
|
|
56
|
-
"@aztec/protocol-contracts": "0.
|
|
57
|
-
"@aztec/types": "0.
|
|
52
|
+
"@aztec/circuit-types": "0.26.2",
|
|
53
|
+
"@aztec/circuits.js": "0.26.2",
|
|
54
|
+
"@aztec/ethereum": "0.26.2",
|
|
55
|
+
"@aztec/foundation": "0.26.2",
|
|
56
|
+
"@aztec/protocol-contracts": "0.26.2",
|
|
57
|
+
"@aztec/types": "0.26.2",
|
|
58
58
|
"tslib": "^2.4.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
@@ -6,11 +6,12 @@ import { ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
|
6
6
|
import { AccountContract } from '../account/contract.js';
|
|
7
7
|
import { Salt } from '../account/index.js';
|
|
8
8
|
import { AccountInterface } from '../account/interface.js';
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
9
|
+
import { DeployMethod } from '../contract/deploy_method.js';
|
|
10
|
+
import { DefaultWaitOpts, WaitOpts } from '../contract/sent_tx.js';
|
|
11
|
+
import { ContractDeployer } from '../deployment/contract_deployer.js';
|
|
11
12
|
import { waitForAccountSynch } from '../utils/account.js';
|
|
12
13
|
import { generatePublicKey } from '../utils/index.js';
|
|
13
|
-
import { AccountWalletWithPrivateKey } from '../wallet/index.js';
|
|
14
|
+
import { AccountWalletWithPrivateKey, SignerlessWallet } from '../wallet/index.js';
|
|
14
15
|
import { DeployAccountSentTx } from './deploy_account_sent_tx.js';
|
|
15
16
|
|
|
16
17
|
/**
|
|
@@ -25,6 +26,7 @@ export class AccountManager {
|
|
|
25
26
|
private completeAddress?: CompleteAddress;
|
|
26
27
|
private instance?: ContractInstanceWithAddress;
|
|
27
28
|
private encryptionPublicKey?: PublicKey;
|
|
29
|
+
// TODO(@spalladino): Update to the new deploy method and kill the legacy one.
|
|
28
30
|
private deployMethod?: DeployMethod;
|
|
29
31
|
|
|
30
32
|
constructor(
|
|
@@ -130,7 +132,15 @@ export class AccountManager {
|
|
|
130
132
|
}
|
|
131
133
|
await this.#register();
|
|
132
134
|
const encryptionPublicKey = this.getEncryptionPublicKey();
|
|
133
|
-
|
|
135
|
+
// We use a signerless wallet so we hit the account contract directly and it deploys itself.
|
|
136
|
+
// If we used getWallet, the deployment would get routed via the account contract entrypoint
|
|
137
|
+
// instead of directly hitting the initializer.
|
|
138
|
+
const deployWallet = new SignerlessWallet(this.pxe);
|
|
139
|
+
const deployer = new ContractDeployer(
|
|
140
|
+
this.accountContract.getContractArtifact(),
|
|
141
|
+
deployWallet,
|
|
142
|
+
encryptionPublicKey,
|
|
143
|
+
);
|
|
134
144
|
const args = this.accountContract.getDeploymentArgs();
|
|
135
145
|
this.deployMethod = deployer.deploy(...args);
|
|
136
146
|
}
|
|
@@ -139,6 +149,7 @@ export class AccountManager {
|
|
|
139
149
|
|
|
140
150
|
/**
|
|
141
151
|
* Deploys the account contract that backs this account.
|
|
152
|
+
* Does not register the associated class nor publicly deploy the instance.
|
|
142
153
|
* Uses the salt provided in the constructor or a randomly generated one.
|
|
143
154
|
* Note that if the Account is constructed with an explicit complete address
|
|
144
155
|
* it is assumed that the account contract has already been deployed and this method will throw.
|
|
@@ -148,7 +159,11 @@ export class AccountManager {
|
|
|
148
159
|
public async deploy(): Promise<DeployAccountSentTx> {
|
|
149
160
|
const deployMethod = await this.getDeployMethod();
|
|
150
161
|
const wallet = await this.getWallet();
|
|
151
|
-
const sentTx = deployMethod.send({
|
|
162
|
+
const sentTx = deployMethod.send({
|
|
163
|
+
contractAddressSalt: this.salt,
|
|
164
|
+
skipClassRegistration: true,
|
|
165
|
+
skipPublicDeployment: true,
|
|
166
|
+
});
|
|
152
167
|
return new DeployAccountSentTx(wallet, sentTx.getTxHash());
|
|
153
168
|
}
|
|
154
169
|
|
package/src/api/fee.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
2
|
-
export { GenericFeePaymentMethod } from '../fee/generic_fee_payment_method.js';
|
|
3
2
|
export { NativeFeePaymentMethod } from '../fee/native_fee_payment_method.js';
|
|
3
|
+
export { PrivateFeePaymentMethod } from '../fee/private_fee_payment_method.js';
|
|
4
|
+
export { PublicFeePaymentMethod } from '../fee/public_fee_payment_method.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { PXE, Tx, TxExecutionRequest } from '@aztec/circuit-types';
|
|
2
2
|
|
|
3
|
+
import { FeeOptions } from '../account/interface.js';
|
|
3
4
|
import { SentTx } from './sent_tx.js';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -11,6 +12,11 @@ export type SendMethodOptions = {
|
|
|
11
12
|
* Wether to skip the simulation of the public part of the transaction.
|
|
12
13
|
*/
|
|
13
14
|
skipPublicSimulation?: boolean;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* The fee options for the transaction.
|
|
18
|
+
*/
|
|
19
|
+
fee?: FeeOptions;
|
|
14
20
|
};
|
|
15
21
|
|
|
16
22
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { FunctionCall, TxExecutionRequest } from '@aztec/circuit-types';
|
|
2
2
|
|
|
3
3
|
import { Wallet } from '../account/index.js';
|
|
4
|
-
import { BaseContractInteraction } from './base_contract_interaction.js';
|
|
4
|
+
import { BaseContractInteraction, SendMethodOptions } from './base_contract_interaction.js';
|
|
5
5
|
|
|
6
6
|
/** A batch of function calls to be sent as a single transaction through a wallet. */
|
|
7
7
|
export class BatchCall extends BaseContractInteraction {
|
|
@@ -12,11 +12,12 @@ export class BatchCall extends BaseContractInteraction {
|
|
|
12
12
|
/**
|
|
13
13
|
* Create a transaction execution request that represents this batch, encoded and authenticated by the
|
|
14
14
|
* user's wallet, ready to be simulated.
|
|
15
|
+
* @param opts - An optional object containing additional configuration for the transaction.
|
|
15
16
|
* @returns A Promise that resolves to a transaction instance.
|
|
16
17
|
*/
|
|
17
|
-
public async create(): Promise<TxExecutionRequest> {
|
|
18
|
+
public async create(opts?: SendMethodOptions): Promise<TxExecutionRequest> {
|
|
18
19
|
if (!this.txRequest) {
|
|
19
|
-
this.txRequest = await this.wallet.createTxExecutionRequest(this.calls);
|
|
20
|
+
this.txRequest = await this.wallet.createTxExecutionRequest(this.calls, opts?.fee);
|
|
20
21
|
}
|
|
21
22
|
return this.txRequest;
|
|
22
23
|
}
|
package/src/contract/contract.ts
CHANGED
|
@@ -36,10 +36,11 @@ export class Contract extends ContractBase {
|
|
|
36
36
|
* @param wallet - The wallet for executing the deployment.
|
|
37
37
|
* @param artifact - Build artifact of the contract to deploy
|
|
38
38
|
* @param args - Arguments for the constructor.
|
|
39
|
+
* @param constructorName - The name of the constructor function to call.
|
|
39
40
|
*/
|
|
40
|
-
public static deploy(wallet: Wallet, artifact: ContractArtifact, args: any[]) {
|
|
41
|
+
public static deploy(wallet: Wallet, artifact: ContractArtifact, args: any[], constructorName?: string) {
|
|
41
42
|
const postDeployCtor = (address: AztecAddress, wallet: Wallet) => Contract.at(address, artifact, wallet);
|
|
42
|
-
return new DeployMethod(Point.ZERO, wallet, artifact, postDeployCtor, args);
|
|
43
|
+
return new DeployMethod(Point.ZERO, wallet, artifact, postDeployCtor, args, constructorName);
|
|
43
44
|
}
|
|
44
45
|
|
|
45
46
|
/**
|
|
@@ -48,9 +49,16 @@ export class Contract extends ContractBase {
|
|
|
48
49
|
* @param wallet - The wallet for executing the deployment.
|
|
49
50
|
* @param artifact - Build artifact of the contract.
|
|
50
51
|
* @param args - Arguments for the constructor.
|
|
52
|
+
* @param constructorName - The name of the constructor function to call.
|
|
51
53
|
*/
|
|
52
|
-
public static deployWithPublicKey(
|
|
54
|
+
public static deployWithPublicKey(
|
|
55
|
+
publicKey: PublicKey,
|
|
56
|
+
wallet: Wallet,
|
|
57
|
+
artifact: ContractArtifact,
|
|
58
|
+
args: any[],
|
|
59
|
+
constructorName?: string,
|
|
60
|
+
) {
|
|
53
61
|
const postDeployCtor = (address: AztecAddress, wallet: Wallet) => Contract.at(address, artifact, wallet);
|
|
54
|
-
return new DeployMethod(publicKey, wallet, artifact, postDeployCtor, args);
|
|
62
|
+
return new DeployMethod(publicKey, wallet, artifact, postDeployCtor, args, constructorName);
|
|
55
63
|
}
|
|
56
64
|
}
|
|
@@ -38,14 +38,15 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
38
38
|
/**
|
|
39
39
|
* Create a transaction execution request that represents this call, encoded and authenticated by the
|
|
40
40
|
* user's wallet, ready to be simulated.
|
|
41
|
+
* @param opts - An optional object containing additional configuration for the transaction.
|
|
41
42
|
* @returns A Promise that resolves to a transaction instance.
|
|
42
43
|
*/
|
|
43
|
-
public async create(): Promise<TxExecutionRequest> {
|
|
44
|
+
public async create(opts?: SendMethodOptions): Promise<TxExecutionRequest> {
|
|
44
45
|
if (this.functionDao.functionType === FunctionType.UNCONSTRAINED) {
|
|
45
46
|
throw new Error("Can't call `create` on an unconstrained function.");
|
|
46
47
|
}
|
|
47
48
|
if (!this.txRequest) {
|
|
48
|
-
this.txRequest = await this.wallet.createTxExecutionRequest([this.request()]);
|
|
49
|
+
this.txRequest = await this.wallet.createTxExecutionRequest([this.request()], opts?.fee);
|
|
49
50
|
}
|
|
50
51
|
return this.txRequest;
|
|
51
52
|
}
|
|
@@ -53,7 +54,6 @@ export class ContractFunctionInteraction extends BaseContractInteraction {
|
|
|
53
54
|
/**
|
|
54
55
|
* Returns an execution request that represents this operation. Useful as a building
|
|
55
56
|
* block for constructing batch requests.
|
|
56
|
-
* @param options - An optional object containing additional configuration for the transaction.
|
|
57
57
|
* @returns An execution request wrapped in promise.
|
|
58
58
|
*/
|
|
59
59
|
public request(): FunctionCall {
|
|
@@ -1,21 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FunctionCall, PublicKey, Tx, TxExecutionRequest } from '@aztec/circuit-types';
|
|
2
2
|
import {
|
|
3
3
|
AztecAddress,
|
|
4
|
-
ContractDeploymentData,
|
|
5
|
-
FunctionData,
|
|
6
|
-
TxContext,
|
|
7
4
|
computePartialAddress,
|
|
5
|
+
getContractClassFromArtifact,
|
|
8
6
|
getContractInstanceFromDeployParams,
|
|
9
7
|
} from '@aztec/circuits.js';
|
|
10
|
-
import { ContractArtifact, FunctionArtifact
|
|
8
|
+
import { ContractArtifact, FunctionArtifact } from '@aztec/foundation/abi';
|
|
11
9
|
import { EthAddress } from '@aztec/foundation/eth-address';
|
|
12
10
|
import { Fr } from '@aztec/foundation/fields';
|
|
11
|
+
import { createDebugLogger } from '@aztec/foundation/log';
|
|
13
12
|
import { ContractInstanceWithAddress } from '@aztec/types/contracts';
|
|
14
13
|
|
|
15
14
|
import { Wallet } from '../account/index.js';
|
|
15
|
+
import { deployInstance } from '../deployment/deploy_instance.js';
|
|
16
|
+
import { registerContractClass } from '../deployment/register_class.js';
|
|
16
17
|
import { BaseContractInteraction, SendMethodOptions } from './base_contract_interaction.js';
|
|
17
18
|
import { type Contract } from './contract.js';
|
|
18
19
|
import { ContractBase } from './contract_base.js';
|
|
20
|
+
import { ContractFunctionInteraction } from './contract_function_interaction.js';
|
|
19
21
|
import { DeploySentTx } from './deploy_sent_tx.js';
|
|
20
22
|
|
|
21
23
|
/**
|
|
@@ -23,36 +25,43 @@ import { DeploySentTx } from './deploy_sent_tx.js';
|
|
|
23
25
|
* Allows specifying a portal contract, contract address salt, and additional send method options.
|
|
24
26
|
*/
|
|
25
27
|
export type DeployOptions = {
|
|
26
|
-
/**
|
|
27
|
-
* The Ethereum address of the Portal contract.
|
|
28
|
-
*/
|
|
28
|
+
/** The Ethereum address of the Portal contract. */
|
|
29
29
|
portalContract?: EthAddress;
|
|
30
|
-
/**
|
|
31
|
-
* An optional salt value used to deterministically calculate the contract address.
|
|
32
|
-
*/
|
|
30
|
+
/** An optional salt value used to deterministically calculate the contract address. */
|
|
33
31
|
contractAddressSalt?: Fr;
|
|
32
|
+
/** Set to true to *not* include the sender in the address computation. */
|
|
33
|
+
universalDeploy?: boolean;
|
|
34
|
+
/** Skip contract class registration. */
|
|
35
|
+
skipClassRegistration?: boolean;
|
|
36
|
+
/** Skip public deployment and only initialize the contract. */
|
|
37
|
+
skipPublicDeployment?: boolean;
|
|
34
38
|
} & SendMethodOptions;
|
|
35
39
|
|
|
40
|
+
// TODO(@spalladino): Add unit tests for this class!
|
|
41
|
+
|
|
36
42
|
/**
|
|
37
|
-
*
|
|
38
|
-
* Extends the
|
|
43
|
+
* Contract interaction for deployment. Handles class registration, public instance deployment,
|
|
44
|
+
* and initialization of the contract. Extends the BaseContractInteraction class.
|
|
39
45
|
*/
|
|
40
46
|
export class DeployMethod<TContract extends ContractBase = Contract> extends BaseContractInteraction {
|
|
41
47
|
/** The contract instance to be deployed. */
|
|
42
|
-
|
|
48
|
+
private instance?: ContractInstanceWithAddress = undefined;
|
|
43
49
|
|
|
44
50
|
/** Constructor function to call. */
|
|
45
51
|
private constructorArtifact: FunctionArtifact;
|
|
46
52
|
|
|
53
|
+
private log = createDebugLogger('aztec:js:deploy_method');
|
|
54
|
+
|
|
47
55
|
constructor(
|
|
48
56
|
private publicKey: PublicKey,
|
|
49
|
-
protected
|
|
57
|
+
protected wallet: Wallet,
|
|
50
58
|
private artifact: ContractArtifact,
|
|
51
59
|
private postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>,
|
|
52
60
|
private args: any[] = [],
|
|
61
|
+
constructorName: string = 'constructor',
|
|
53
62
|
) {
|
|
54
|
-
super(
|
|
55
|
-
const constructorArtifact = artifact.functions.find(f => f.name ===
|
|
63
|
+
super(wallet);
|
|
64
|
+
const constructorArtifact = artifact.functions.find(f => f.name === constructorName);
|
|
56
65
|
if (!constructorArtifact) {
|
|
57
66
|
throw new Error('Cannot find constructor in the artifact.');
|
|
58
67
|
}
|
|
@@ -68,55 +77,71 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
68
77
|
* @param options - An object containing optional deployment settings, including portalContract, contractAddressSalt, and from.
|
|
69
78
|
* @returns A Promise resolving to an object containing the signed transaction data and other relevant information.
|
|
70
79
|
*/
|
|
71
|
-
public async create(options: DeployOptions = {}) {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
const deployParams = [this.artifact, this.args, contractAddressSalt, this.publicKey, portalContract] as const;
|
|
78
|
-
const instance = getContractInstanceFromDeployParams(...deployParams);
|
|
79
|
-
const address = instance.address;
|
|
80
|
-
|
|
81
|
-
const contractDeploymentData = new ContractDeploymentData(
|
|
82
|
-
this.publicKey,
|
|
83
|
-
instance.initializationHash,
|
|
84
|
-
instance.contractClassId,
|
|
85
|
-
contractAddressSalt,
|
|
86
|
-
portalContract,
|
|
87
|
-
);
|
|
88
|
-
|
|
89
|
-
const txContext = new TxContext(
|
|
90
|
-
false,
|
|
91
|
-
false,
|
|
92
|
-
true,
|
|
93
|
-
contractDeploymentData,
|
|
94
|
-
new Fr(chainId),
|
|
95
|
-
new Fr(protocolVersion),
|
|
96
|
-
);
|
|
97
|
-
const args = encodeArguments(this.constructorArtifact, this.args);
|
|
98
|
-
const functionData = FunctionData.fromAbi(this.constructorArtifact);
|
|
99
|
-
const execution = { args, functionData, to: address };
|
|
100
|
-
const packedArguments = PackedArguments.fromArgs(execution.args);
|
|
101
|
-
|
|
102
|
-
const txRequest = TxExecutionRequest.from({
|
|
103
|
-
origin: execution.to,
|
|
104
|
-
functionData: execution.functionData,
|
|
105
|
-
argsHash: packedArguments.hash,
|
|
106
|
-
txContext,
|
|
107
|
-
packedArguments: [packedArguments],
|
|
108
|
-
authWitnesses: [],
|
|
109
|
-
});
|
|
110
|
-
|
|
111
|
-
this.txRequest = txRequest;
|
|
112
|
-
this.instance = instance;
|
|
113
|
-
|
|
114
|
-
// TODO: Should we add the contracts to the DB here, or once the tx has been sent or mined?
|
|
115
|
-
await this.pxe.addContracts([{ artifact: this.artifact, instance }]);
|
|
116
|
-
|
|
80
|
+
public async create(options: DeployOptions = {}): Promise<TxExecutionRequest> {
|
|
81
|
+
if (!this.txRequest) {
|
|
82
|
+
this.txRequest = await this.wallet.createTxExecutionRequest(await this.request(options));
|
|
83
|
+
// TODO: Should we add the contracts to the DB here, or once the tx has been sent or mined?
|
|
84
|
+
await this.pxe.addContracts([{ artifact: this.artifact, instance: this.instance! }]);
|
|
85
|
+
}
|
|
117
86
|
return this.txRequest;
|
|
118
87
|
}
|
|
119
88
|
|
|
89
|
+
/**
|
|
90
|
+
* Returns an array of function calls that represent this operation. Useful as a building
|
|
91
|
+
* block for constructing batch requests.
|
|
92
|
+
* @param options - Deployment options.
|
|
93
|
+
* @returns An array of function calls.
|
|
94
|
+
* @remarks This method does not have the same return type as the `request` in the ContractInteraction object,
|
|
95
|
+
* it returns a promise for an array instead of a function call directly.
|
|
96
|
+
*/
|
|
97
|
+
public async request(options: DeployOptions = {}): Promise<FunctionCall[]> {
|
|
98
|
+
const { address } = this.getInstance(options);
|
|
99
|
+
const constructorCall = new ContractFunctionInteraction(this.wallet, address, this.constructorArtifact, this.args);
|
|
100
|
+
return [...(await this.getDeploymentFunctionCalls(options)), constructorCall.request()];
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Returns calls for registration of the class and deployment of the instance, depending on the provided options.
|
|
105
|
+
* @param options - Deployment options.
|
|
106
|
+
* @returns A function call array with potentially requests to the class registerer and instance deployer.
|
|
107
|
+
*/
|
|
108
|
+
protected async getDeploymentFunctionCalls(options: DeployOptions = {}): Promise<FunctionCall[]> {
|
|
109
|
+
const calls: FunctionCall[] = [];
|
|
110
|
+
|
|
111
|
+
// Set contract instance object so it's available for populating the DeploySendTx object
|
|
112
|
+
const instance = this.getInstance(options);
|
|
113
|
+
|
|
114
|
+
// Obtain contract class from artifact and check it matches the reported one by the instance.
|
|
115
|
+
// TODO(@spalladino): We're unnecessarily calculating the contract class multiple times here.
|
|
116
|
+
const contractClass = getContractClassFromArtifact(this.artifact);
|
|
117
|
+
if (!instance.contractClassId.equals(contractClass.id)) {
|
|
118
|
+
throw new Error(
|
|
119
|
+
`Contract class mismatch when deploying contract: got ${instance.contractClassId.toString()} from instance and ${contractClass.id.toString()} from artifact`,
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
// Register the contract class if it hasn't been published already.
|
|
124
|
+
if (!options.skipClassRegistration) {
|
|
125
|
+
if (await this.pxe.isContractClassPubliclyRegistered(contractClass.id)) {
|
|
126
|
+
this.log(
|
|
127
|
+
`Skipping registration of already registered contract class ${contractClass.id.toString()} for ${instance.address.toString()}`,
|
|
128
|
+
);
|
|
129
|
+
} else {
|
|
130
|
+
this.log(
|
|
131
|
+
`Creating request for registering contract class ${contractClass.id.toString()} as part of deployment for ${instance.address.toString()}`,
|
|
132
|
+
);
|
|
133
|
+
calls.push((await registerContractClass(this.wallet, this.artifact)).request());
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
// Deploy the contract via the instance deployer.
|
|
138
|
+
if (!options.skipPublicDeployment) {
|
|
139
|
+
calls.push(deployInstance(this.wallet, instance, { universalDeploy: options.universalDeploy }).request());
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
return calls;
|
|
143
|
+
}
|
|
144
|
+
|
|
120
145
|
/**
|
|
121
146
|
* Send the contract deployment transaction using the provided options.
|
|
122
147
|
* This function extends the 'send' method from the ContractFunctionInteraction class,
|
|
@@ -127,7 +152,23 @@ export class DeployMethod<TContract extends ContractBase = Contract> extends Bas
|
|
|
127
152
|
*/
|
|
128
153
|
public send(options: DeployOptions = {}): DeploySentTx<TContract> {
|
|
129
154
|
const txHashPromise = super.send(options).getTxHash();
|
|
130
|
-
return new DeploySentTx(this.pxe, txHashPromise, this.postDeployCtor, this.
|
|
155
|
+
return new DeploySentTx(this.pxe, txHashPromise, this.postDeployCtor, this.getInstance(options));
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
/**
|
|
159
|
+
* Builds the contract instance to be deployed and returns it.
|
|
160
|
+
*
|
|
161
|
+
* @param options - An object containing various deployment options.
|
|
162
|
+
* @returns An instance object.
|
|
163
|
+
*/
|
|
164
|
+
public getInstance(options: DeployOptions = {}): ContractInstanceWithAddress {
|
|
165
|
+
if (!this.instance) {
|
|
166
|
+
const portalContract = options.portalContract ?? EthAddress.ZERO;
|
|
167
|
+
const contractAddressSalt = options.contractAddressSalt ?? Fr.random();
|
|
168
|
+
const deployParams = [this.artifact, this.args, contractAddressSalt, this.publicKey, portalContract] as const;
|
|
169
|
+
this.instance = getContractInstanceFromDeployParams(...deployParams);
|
|
170
|
+
}
|
|
171
|
+
return this.instance;
|
|
131
172
|
}
|
|
132
173
|
|
|
133
174
|
/**
|
|
@@ -29,7 +29,7 @@ export class DeploySentTx<TContract extends Contract = Contract> extends SentTx
|
|
|
29
29
|
txHashPromise: Promise<TxHash>,
|
|
30
30
|
private postDeployCtor: (address: AztecAddress, wallet: Wallet) => Promise<TContract>,
|
|
31
31
|
/** The deployed contract instance */
|
|
32
|
-
public instance
|
|
32
|
+
public instance: ContractInstanceWithAddress,
|
|
33
33
|
) {
|
|
34
34
|
super(wallet, txHashPromise);
|
|
35
35
|
}
|
|
@@ -51,19 +51,16 @@ export class DeploySentTx<TContract extends Contract = Contract> extends SentTx
|
|
|
51
51
|
*/
|
|
52
52
|
public async wait(opts?: DeployedWaitOpts): Promise<DeployTxReceipt<TContract>> {
|
|
53
53
|
const receipt = await super.wait(opts);
|
|
54
|
-
const contract = await this.getContractObject(opts?.wallet
|
|
54
|
+
const contract = await this.getContractObject(opts?.wallet);
|
|
55
55
|
return { ...receipt, contract };
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
protected getContractObject(wallet?: Wallet
|
|
58
|
+
protected getContractObject(wallet?: Wallet): Promise<TContract> {
|
|
59
59
|
const isWallet = (pxe: PXE | Wallet): pxe is Wallet => !!(pxe as Wallet).createTxExecutionRequest;
|
|
60
60
|
const contractWallet = wallet ?? (isWallet(this.pxe) && this.pxe);
|
|
61
61
|
if (!contractWallet) {
|
|
62
62
|
throw new Error(`A wallet is required for creating a contract instance`);
|
|
63
63
|
}
|
|
64
|
-
|
|
65
|
-
throw new Error(`Contract address is missing from transaction receipt`);
|
|
66
|
-
}
|
|
67
|
-
return this.postDeployCtor(address, contractWallet) as Promise<TContract>;
|
|
64
|
+
return this.postDeployCtor(this.instance.address, contractWallet) as Promise<TContract>;
|
|
68
65
|
}
|
|
69
66
|
}
|
package/src/contract/sent_tx.ts
CHANGED
|
@@ -37,8 +37,8 @@ export class SentTx {
|
|
|
37
37
|
*
|
|
38
38
|
* @returns A promise that resolves to the transaction hash of the SentTx instance.
|
|
39
39
|
*/
|
|
40
|
-
public
|
|
41
|
-
return
|
|
40
|
+
public getTxHash(): Promise<TxHash> {
|
|
41
|
+
return this.txHashPromise;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -68,15 +68,15 @@ export class SentTx {
|
|
|
68
68
|
}
|
|
69
69
|
if (opts?.debug) {
|
|
70
70
|
const txHash = await this.getTxHash();
|
|
71
|
-
const tx = (await this.pxe.
|
|
71
|
+
const tx = (await this.pxe.getTxEffect(txHash))!;
|
|
72
72
|
const visibleNotes = await this.pxe.getNotes({ txHash });
|
|
73
73
|
receipt.debugInfo = {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
74
|
+
noteHashes: tx.noteHashes.filter(n => !n.isZero()),
|
|
75
|
+
nullifiers: tx.nullifiers.filter(n => !n.isZero()),
|
|
76
|
+
publicDataWrites: tx.publicDataWrites.filter(p => !p.isEmpty()),
|
|
77
|
+
l2ToL1Msgs: tx.l2ToL1Msgs.filter(l => !l.isZero()),
|
|
78
|
+
contractsLeaves: tx.contractLeaves.filter(c => !c.isZero()),
|
|
79
|
+
contractData: tx.contractData.filter(c => !c.isEmpty()),
|
|
80
80
|
visibleNotes,
|
|
81
81
|
};
|
|
82
82
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PublicKey } from '@aztec/circuit-types';
|
|
2
2
|
import { AztecAddress } from '@aztec/circuits.js';
|
|
3
3
|
import { ContractArtifact } from '@aztec/foundation/abi';
|
|
4
4
|
import { Point } from '@aztec/foundation/fields';
|
|
@@ -12,7 +12,12 @@ import { Contract } from '../contract/index.js';
|
|
|
12
12
|
* @remarks Keeping this around even though we have Aztec.nr contract types because it can be useful for non-TS users.
|
|
13
13
|
*/
|
|
14
14
|
export class ContractDeployer {
|
|
15
|
-
constructor(
|
|
15
|
+
constructor(
|
|
16
|
+
private artifact: ContractArtifact,
|
|
17
|
+
private wallet: Wallet,
|
|
18
|
+
private publicKey?: PublicKey,
|
|
19
|
+
private constructorName?: string,
|
|
20
|
+
) {}
|
|
16
21
|
|
|
17
22
|
/**
|
|
18
23
|
* Deploy a contract using the provided ABI and constructor arguments.
|
|
@@ -25,6 +30,13 @@ export class ContractDeployer {
|
|
|
25
30
|
*/
|
|
26
31
|
public deploy(...args: any[]) {
|
|
27
32
|
const postDeployCtor = (address: AztecAddress, wallet: Wallet) => Contract.at(address, this.artifact, wallet);
|
|
28
|
-
return new DeployMethod(
|
|
33
|
+
return new DeployMethod(
|
|
34
|
+
this.publicKey ?? Point.ZERO,
|
|
35
|
+
this.wallet,
|
|
36
|
+
this.artifact,
|
|
37
|
+
postDeployCtor,
|
|
38
|
+
args,
|
|
39
|
+
this.constructorName,
|
|
40
|
+
);
|
|
29
41
|
}
|
|
30
42
|
}
|
|
@@ -6,10 +6,14 @@ import { Wallet } from '../wallet/index.js';
|
|
|
6
6
|
import { getRegistererContract } from './protocol_contracts.js';
|
|
7
7
|
|
|
8
8
|
/** Sets up a call to register a contract class given its artifact. */
|
|
9
|
-
export function registerContractClass(
|
|
9
|
+
export async function registerContractClass(
|
|
10
|
+
wallet: Wallet,
|
|
11
|
+
artifact: ContractArtifact,
|
|
12
|
+
): Promise<ContractFunctionInteraction> {
|
|
10
13
|
const { artifactHash, privateFunctionsRoot, publicBytecodeCommitment, packedBytecode } =
|
|
11
14
|
getContractClassFromArtifact(artifact);
|
|
12
15
|
const encodedBytecode = bufferAsFields(packedBytecode, MAX_PACKED_PUBLIC_BYTECODE_SIZE_IN_FIELDS);
|
|
13
16
|
const registerer = getRegistererContract(wallet);
|
|
14
|
-
|
|
17
|
+
await wallet.addCapsule(encodedBytecode);
|
|
18
|
+
return registerer.methods.register(artifactHash, privateFunctionsRoot, publicBytecodeCommitment);
|
|
15
19
|
}
|
|
@@ -15,16 +15,11 @@ export interface FeePaymentMethod {
|
|
|
15
15
|
*/
|
|
16
16
|
getPaymentContract(): AztecAddress;
|
|
17
17
|
|
|
18
|
-
/**
|
|
19
|
-
* Whether the fee payment is private or not
|
|
20
|
-
*/
|
|
21
|
-
isPrivateFeePayment(): boolean;
|
|
22
|
-
|
|
23
18
|
/**
|
|
24
19
|
* Creates a function call to pay the fee in the given asset.
|
|
25
20
|
* TODO(fees) replace maxFee with gas limits
|
|
26
21
|
* @param maxFee - The maximum fee to be paid in the given asset.
|
|
27
22
|
* @returns The function call to pay the fee.
|
|
28
23
|
*/
|
|
29
|
-
getFunctionCalls(maxFee: Fr): FunctionCall[]
|
|
24
|
+
getFunctionCalls(maxFee: Fr): Promise<FunctionCall[]>;
|
|
30
25
|
}
|