@aztec/aztec.js 3.0.3 → 4.0.0-devnet.1-patch.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dest/account/account.d.ts +25 -40
- package/dest/account/account.d.ts.map +1 -1
- package/dest/account/account.js +19 -47
- package/dest/account/account_contract.d.ts +8 -9
- package/dest/account/account_contract.d.ts.map +1 -1
- package/dest/account/account_with_secret_key.d.ts +19 -7
- package/dest/account/account_with_secret_key.d.ts.map +1 -1
- package/dest/account/account_with_secret_key.js +21 -4
- package/dest/account/index.d.ts +3 -2
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +2 -0
- package/dest/account/signerless_account.d.ts +5 -6
- package/dest/account/signerless_account.d.ts.map +1 -1
- package/dest/account/signerless_account.js +8 -11
- package/dest/api/account.d.ts +2 -4
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +1 -3
- package/dest/api/authorization.d.ts +2 -2
- package/dest/api/authorization.d.ts.map +1 -1
- package/dest/api/authorization.js +1 -1
- package/dest/api/contract.d.ts +18 -12
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +16 -10
- package/dest/api/deployment.d.ts +1 -2
- package/dest/api/deployment.d.ts.map +1 -1
- package/dest/api/deployment.js +0 -1
- package/dest/api/events.d.ts +10 -6
- package/dest/api/events.d.ts.map +1 -1
- package/dest/api/events.js +30 -20
- package/dest/api/fields.d.ts +2 -1
- package/dest/api/fields.d.ts.map +1 -1
- package/dest/api/fields.js +1 -0
- package/dest/api/keys.d.ts +1 -1
- package/dest/api/keys.js +1 -1
- package/dest/api/node.d.ts +8 -4
- package/dest/api/node.d.ts.map +1 -1
- package/dest/api/node.js +7 -3
- package/dest/api/protocol.d.ts +7 -1
- package/dest/api/protocol.d.ts.map +1 -1
- package/dest/api/protocol.js +6 -0
- package/dest/api/tx.d.ts +2 -2
- package/dest/api/tx.d.ts.map +1 -1
- package/dest/api/tx.js +1 -1
- package/dest/api/wallet.d.ts +3 -2
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +2 -1
- package/dest/authorization/call_authorization_request.d.ts +22 -1
- package/dest/authorization/call_authorization_request.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.d.ts +8 -10
- package/dest/contract/base_contract_interaction.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.js +5 -17
- package/dest/contract/batch_call.d.ts +1 -1
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +3 -1
- package/dest/contract/contract_base.d.ts +4 -1
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.d.ts +3 -12
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +6 -6
- package/dest/contract/deploy_method.d.ts +63 -16
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +41 -23
- package/dest/contract/interaction_options.d.ts +42 -5
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +8 -1
- package/dest/contract/protocol_contracts/auth-registry.d.ts +27 -0
- package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/auth-registry.js +558 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts +15 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-class-registry.js +127 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +22 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.js +465 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts +21 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/fee-juice.js +426 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts +34 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/multi-call-entrypoint.js +585 -0
- package/dest/contract/protocol_contracts/public-checks.d.ts +26 -0
- package/dest/contract/protocol_contracts/public-checks.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/public-checks.js +593 -0
- package/dest/contract/wait_for_proven.d.ts +2 -2
- package/dest/contract/wait_for_proven.d.ts.map +1 -1
- package/dest/contract/wait_for_proven.js +1 -1
- package/dest/contract/wait_opts.d.ts +16 -0
- package/dest/contract/wait_opts.d.ts.map +1 -0
- package/dest/contract/wait_opts.js +5 -0
- package/dest/deployment/publish_class.js +2 -2
- package/dest/deployment/publish_instance.d.ts +2 -2
- package/dest/deployment/publish_instance.d.ts.map +1 -1
- package/dest/deployment/publish_instance.js +3 -3
- package/dest/ethereum/portal_manager.d.ts +7 -4
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +15 -16
- package/dest/fee/fee_juice_payment_method_with_claim.js +6 -6
- package/dest/fee/private_fee_payment_method.js +10 -10
- package/dest/fee/public_fee_payment_method.js +10 -10
- package/dest/fee/sponsored_fee_payment.js +3 -3
- package/dest/scripts/generate_protocol_contract_types.d.ts +2 -0
- package/dest/scripts/generate_protocol_contract_types.d.ts.map +1 -0
- package/dest/scripts/generate_protocol_contract_types.js +120 -0
- package/dest/utils/authwit.d.ts +8 -6
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +5 -9
- package/dest/utils/node.d.ts +12 -1
- package/dest/utils/node.d.ts.map +1 -1
- package/dest/utils/node.js +46 -0
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +5 -8
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
- package/dest/wallet/account_entrypoint_meta_payment_method.js +28 -43
- package/dest/wallet/account_manager.d.ts +5 -8
- package/dest/wallet/account_manager.d.ts.map +1 -1
- package/dest/wallet/account_manager.js +5 -11
- package/dest/wallet/capabilities.d.ts +444 -0
- package/dest/wallet/capabilities.d.ts.map +1 -0
- package/dest/wallet/capabilities.js +3 -0
- package/dest/wallet/deploy_account_method.d.ts +34 -6
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/deploy_account_method.js +7 -5
- package/dest/wallet/index.d.ts +2 -1
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +1 -0
- package/dest/wallet/wallet.d.ts +1642 -1007
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +201 -107
- package/package.json +24 -13
- package/src/account/account.ts +34 -58
- package/src/account/account_contract.ts +6 -7
- package/src/account/account_with_secret_key.ts +33 -8
- package/src/account/index.ts +2 -1
- package/src/account/signerless_account.ts +13 -12
- package/src/api/account.ts +9 -3
- package/src/api/authorization.ts +1 -0
- package/src/api/contract.ts +24 -9
- package/src/api/deployment.ts +0 -1
- package/src/api/events.ts +35 -27
- package/src/api/fields.ts +1 -0
- package/src/api/keys.ts +2 -2
- package/src/api/node.ts +7 -3
- package/src/api/protocol.ts +7 -0
- package/src/api/tx.ts +2 -0
- package/src/api/wallet.ts +47 -3
- package/src/contract/base_contract_interaction.ts +27 -15
- package/src/contract/batch_call.ts +4 -2
- package/src/contract/contract_function_interaction.ts +13 -6
- package/src/contract/deploy_method.ts +122 -29
- package/src/contract/interaction_options.ts +49 -4
- package/src/contract/protocol_contracts/auth-registry.ts +351 -0
- package/src/contract/protocol_contracts/contract-class-registry.ts +96 -0
- package/src/contract/protocol_contracts/contract-instance-registry.ts +302 -0
- package/src/contract/protocol_contracts/fee-juice.ts +264 -0
- package/src/contract/protocol_contracts/multi-call-entrypoint.ts +332 -0
- package/src/contract/protocol_contracts/public-checks.ts +316 -0
- package/src/contract/wait_for_proven.ts +1 -1
- package/src/contract/wait_opts.ts +21 -0
- package/src/deployment/publish_class.ts +2 -2
- package/src/deployment/publish_instance.ts +3 -6
- package/src/ethereum/portal_manager.ts +17 -21
- package/src/fee/fee_juice_payment_method_with_claim.ts +5 -5
- package/src/fee/private_fee_payment_method.ts +7 -7
- package/src/fee/public_fee_payment_method.ts +8 -8
- package/src/fee/sponsored_fee_payment.ts +3 -3
- package/src/scripts/generate_protocol_contract_types.ts +150 -0
- package/src/utils/authwit.ts +19 -7
- package/src/utils/node.ts +62 -0
- package/src/wallet/account_entrypoint_meta_payment_method.ts +28 -60
- package/src/wallet/account_manager.ts +5 -13
- package/src/wallet/capabilities.ts +491 -0
- package/src/wallet/deploy_account_method.ts +37 -13
- package/src/wallet/index.ts +1 -0
- package/src/wallet/wallet.ts +319 -118
- package/dest/account/interface.d.ts +0 -19
- package/dest/account/interface.d.ts.map +0 -1
- package/dest/account/interface.js +0 -5
- package/dest/contract/deploy_sent_tx.d.ts +0 -48
- package/dest/contract/deploy_sent_tx.d.ts.map +0 -1
- package/dest/contract/deploy_sent_tx.js +0 -46
- package/dest/contract/protocol_contracts.d.ts +0 -9
- package/dest/contract/protocol_contracts.d.ts.map +0 -1
- package/dest/contract/protocol_contracts.js +0 -26
- package/dest/contract/sent_tx.d.ts +0 -50
- package/dest/contract/sent_tx.d.ts.map +0 -1
- package/dest/contract/sent_tx.js +0 -90
- package/dest/contract/unsafe_contract.d.ts +0 -15
- package/dest/contract/unsafe_contract.d.ts.map +0 -1
- package/dest/contract/unsafe_contract.js +0 -6
- package/dest/deployment/broadcast_function.d.ts +0 -24
- package/dest/deployment/broadcast_function.d.ts.map +0 -1
- package/dest/deployment/broadcast_function.js +0 -74
- package/src/account/interface.ts +0 -25
- package/src/contract/deploy_sent_tx.ts +0 -75
- package/src/contract/protocol_contracts.ts +0 -35
- package/src/contract/sent_tx.ts +0 -129
- package/src/contract/unsafe_contract.ts +0 -19
- package/src/deployment/broadcast_function.ts +0 -148
package/dest/utils/node.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { retryUntil } from '@aztec/foundation/retry';
|
|
2
|
+
import { SortedTxStatuses, TxStatus } from '@aztec/stdlib/tx';
|
|
3
|
+
import { DefaultWaitOpts } from '../contract/wait_opts.js';
|
|
2
4
|
export const waitForNode = async (node, logger)=>{
|
|
3
5
|
await retryUntil(async ()=>{
|
|
4
6
|
try {
|
|
@@ -12,4 +14,48 @@ export const waitForNode = async (node, logger)=>{
|
|
|
12
14
|
return undefined;
|
|
13
15
|
}, 'RPC Get Node Info');
|
|
14
16
|
};
|
|
17
|
+
/** Returns true if the receipt status is at least the desired status level. */ function hasReachedStatus(receipt, desiredStatus) {
|
|
18
|
+
return SortedTxStatuses.indexOf(receipt.status) >= SortedTxStatuses.indexOf(desiredStatus);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Waits for a transaction to be mined and returns its receipt.
|
|
22
|
+
* @param node - The Aztec node to query for transaction status
|
|
23
|
+
* @param txHash - The hash of the transaction to wait for
|
|
24
|
+
* @param opts - Optional configuration for waiting behavior
|
|
25
|
+
* @returns The transaction receipt
|
|
26
|
+
* @throws If the transaction fails and dontThrowOnRevert is not set
|
|
27
|
+
*/ export async function waitForTx(node, txHash, opts) {
|
|
28
|
+
const startTime = Date.now();
|
|
29
|
+
const ignoreDroppedReceiptsFor = opts?.ignoreDroppedReceiptsFor ?? DefaultWaitOpts.ignoreDroppedReceiptsFor;
|
|
30
|
+
const waitForStatus = opts?.waitForStatus ?? TxStatus.CHECKPOINTED;
|
|
31
|
+
const receipt = await retryUntil(async ()=>{
|
|
32
|
+
const txReceipt = await node.getTxReceipt(txHash);
|
|
33
|
+
// If receipt is not yet available, try again
|
|
34
|
+
if (txReceipt.isPending()) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
// If the tx was "dropped", either return it or ignore based on timing.
|
|
38
|
+
// We can ignore it at first because the transaction may have been sent to node 1, and now we're asking node 2 for the receipt.
|
|
39
|
+
// If we don't allow a short grace period, we could incorrectly return a TxReceipt with status DROPPED.
|
|
40
|
+
if (txReceipt.isDropped()) {
|
|
41
|
+
const elapsedSeconds = (Date.now() - startTime) / 1000;
|
|
42
|
+
if (!ignoreDroppedReceiptsFor || elapsedSeconds > ignoreDroppedReceiptsFor) {
|
|
43
|
+
return txReceipt;
|
|
44
|
+
}
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
// Check if the receipt has reached the desired status level
|
|
48
|
+
if (!hasReachedStatus(txReceipt, waitForStatus)) {
|
|
49
|
+
return undefined;
|
|
50
|
+
}
|
|
51
|
+
return txReceipt;
|
|
52
|
+
}, 'isMined', opts?.timeout ?? DefaultWaitOpts.timeout, opts?.interval ?? DefaultWaitOpts.interval);
|
|
53
|
+
if (!receipt.isMined()) {
|
|
54
|
+
throw new Error(`Transaction ${txHash.toString()} was ${receipt.status}. Reason: ${receipt.error ?? 'unknown'}`);
|
|
55
|
+
}
|
|
56
|
+
if (!receipt.hasExecutionSucceeded() && !opts?.dontThrowOnRevert) {
|
|
57
|
+
throw new Error(`Transaction ${txHash.toString()} reverted: ${receipt.executionResult}. Reason: ${receipt.error ?? 'unknown'}`);
|
|
58
|
+
}
|
|
59
|
+
return receipt;
|
|
60
|
+
}
|
|
15
61
|
export { createAztecNodeClient } from '@aztec/stdlib/interfaces/client';
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { type ContractArtifact, type FunctionArtifact } from '@aztec/stdlib/abi';
|
|
2
1
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
2
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
4
3
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
4
|
+
import type { Account } from '../account/account.js';
|
|
5
5
|
import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
6
|
-
import type { Wallet } from './index.js';
|
|
7
6
|
/**
|
|
8
7
|
* Fee payment method that allows an account contract to pay for its own deployment
|
|
9
8
|
* It works by rerouting the provided fee payment method through the account's entrypoint,
|
|
@@ -20,15 +19,13 @@ import type { Wallet } from './index.js';
|
|
|
20
19
|
* This class can be seen in action in DeployAccountMethod.ts#getSelfPaymentMethod
|
|
21
20
|
*/
|
|
22
21
|
export declare class AccountEntrypointMetaPaymentMethod implements FeePaymentMethod {
|
|
23
|
-
private
|
|
24
|
-
private artifact;
|
|
25
|
-
private feePaymentNameOrArtifact;
|
|
26
|
-
private accountAddress;
|
|
22
|
+
private account;
|
|
27
23
|
private paymentMethod?;
|
|
28
|
-
|
|
24
|
+
private feeEntrypointOptions?;
|
|
25
|
+
constructor(account: Account, paymentMethod?: FeePaymentMethod | undefined, feeEntrypointOptions?: any);
|
|
29
26
|
getAsset(): Promise<AztecAddress>;
|
|
30
27
|
getExecutionPayload(): Promise<ExecutionPayload>;
|
|
31
28
|
getFeePayer(): Promise<AztecAddress>;
|
|
32
29
|
getGasSettings(): GasSettings | undefined;
|
|
33
30
|
}
|
|
34
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
31
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWNjb3VudF9lbnRyeXBvaW50X21ldGFfcGF5bWVudF9tZXRob2QuZC50cyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uL3NyYy93YWxsZXQvYWNjb3VudF9lbnRyeXBvaW50X21ldGFfcGF5bWVudF9tZXRob2QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBRUEsT0FBTyxFQUFFLFlBQVksRUFBRSxNQUFNLDZCQUE2QixDQUFDO0FBQzNELE9BQU8sS0FBSyxFQUFFLFdBQVcsRUFBRSxNQUFNLG1CQUFtQixDQUFDO0FBQ3JELE9BQU8sRUFBRSxnQkFBZ0IsRUFBRSxNQUFNLGtCQUFrQixDQUFDO0FBRXBELE9BQU8sS0FBSyxFQUFFLE9BQU8sRUFBRSxNQUFNLHVCQUF1QixDQUFDO0FBQ3JELE9BQU8sS0FBSyxFQUFFLGdCQUFnQixFQUFFLE1BQU0sOEJBQThCLENBQUM7QUFFckU7Ozs7Ozs7Ozs7Ozs7O0dBY0c7QUFDSCxxQkFBYSxrQ0FBbUMsWUFBVyxnQkFBZ0I7SUFFdkUsT0FBTyxDQUFDLE9BQU87SUFDZixPQUFPLENBQUMsYUFBYSxDQUFDO0lBQ3RCLE9BQU8sQ0FBQyxvQkFBb0IsQ0FBQztJQUgvQixZQUNVLE9BQU8sRUFBRSxPQUFPLEVBQ2hCLGFBQWEsQ0FBQyw4QkFBa0IsRUFDaEMsb0JBQW9CLENBQUMsS0FBSyxFQUNoQztJQUVKLFFBQVEsSUFBSSxPQUFPLENBQUMsWUFBWSxDQUFDLENBRWhDO0lBRUssbUJBQW1CLElBQUksT0FBTyxDQUFDLGdCQUFnQixDQUFDLENBNkJyRDtJQUVELFdBQVcsSUFBSSxPQUFPLENBQUMsWUFBWSxDQUFDLENBRW5DO0lBRUQsY0FBYyxJQUFJLFdBQVcsR0FBRyxTQUFTLENBRXhDO0NBQ0YifQ==
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account_entrypoint_meta_payment_method.d.ts","sourceRoot":"","sources":["../../src/wallet/account_entrypoint_meta_payment_method.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"account_entrypoint_meta_payment_method.d.ts","sourceRoot":"","sources":["../../src/wallet/account_entrypoint_meta_payment_method.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAC3D,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEpD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AACrD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAErE;;;;;;;;;;;;;;GAcG;AACH,qBAAa,kCAAmC,YAAW,gBAAgB;IAEvE,OAAO,CAAC,OAAO;IACf,OAAO,CAAC,aAAa,CAAC;IACtB,OAAO,CAAC,oBAAoB,CAAC;IAH/B,YACU,OAAO,EAAE,OAAO,EAChB,aAAa,CAAC,8BAAkB,EAChC,oBAAoB,CAAC,KAAK,EAChC;IAEJ,QAAQ,IAAI,OAAO,CAAC,YAAY,CAAC,CAEhC;IAEK,mBAAmB,IAAI,OAAO,CAAC,gBAAgB,CAAC,CA6BrD;IAED,WAAW,IAAI,OAAO,CAAC,YAAY,CAAC,CAEnC;IAED,cAAc,IAAI,WAAW,GAAG,SAAS,CAExC;CACF"}
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
2
|
-
import { EncodedAppEntrypointCalls } from '@aztec/entrypoints/encoding';
|
|
3
2
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
4
|
-
import { FunctionCall, FunctionSelector, encodeArguments, getFunctionArtifactByName } from '@aztec/stdlib/abi';
|
|
5
3
|
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
6
4
|
/**
|
|
7
5
|
* Fee payment method that allows an account contract to pay for its own deployment
|
|
@@ -18,57 +16,44 @@ import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
|
18
16
|
*
|
|
19
17
|
* This class can be seen in action in DeployAccountMethod.ts#getSelfPaymentMethod
|
|
20
18
|
*/ export class AccountEntrypointMetaPaymentMethod {
|
|
21
|
-
|
|
22
|
-
artifact;
|
|
23
|
-
feePaymentNameOrArtifact;
|
|
24
|
-
accountAddress;
|
|
19
|
+
account;
|
|
25
20
|
paymentMethod;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.
|
|
29
|
-
this.feePaymentNameOrArtifact = feePaymentNameOrArtifact;
|
|
30
|
-
this.accountAddress = accountAddress;
|
|
21
|
+
feeEntrypointOptions;
|
|
22
|
+
constructor(account, paymentMethod, feeEntrypointOptions){
|
|
23
|
+
this.account = account;
|
|
31
24
|
this.paymentMethod = paymentMethod;
|
|
25
|
+
this.feeEntrypointOptions = feeEntrypointOptions;
|
|
32
26
|
}
|
|
33
27
|
getAsset() {
|
|
34
28
|
return this.paymentMethod?.getAsset() ?? Promise.resolve(ProtocolContractAddress.FeeJuice);
|
|
35
29
|
}
|
|
36
30
|
async getExecutionPayload() {
|
|
37
|
-
// Get the execution payload for the fee
|
|
38
|
-
|
|
39
|
-
//
|
|
40
|
-
|
|
41
|
-
//
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
accountFeePaymentMethodOptions =
|
|
31
|
+
// Get the execution payload for the fee
|
|
32
|
+
const innerPayload = await this.paymentMethod?.getExecutionPayload() ?? ExecutionPayload.empty();
|
|
33
|
+
// If no fee entrypoint options were provided, compute them based on the wrapped payment method
|
|
34
|
+
// This mimics how the actual account contract works when invoked directly:
|
|
35
|
+
// - If we are the fee payer, are there calls in the inner payload? In that case, those calls can
|
|
36
|
+
// only be claiming fee juice, so we use FEE_JUICE_WITH_CLAIM
|
|
37
|
+
// - If we are the fee payer, but there are no calls, then we assume the account already has
|
|
38
|
+
// fee juice and can pay directly with PREEXISTING_FEE_JUICE
|
|
39
|
+
// - If we are not the fee payer, then EXTERNAL is used
|
|
40
|
+
let options = this.feeEntrypointOptions;
|
|
41
|
+
if (!options) {
|
|
42
|
+
const feePayer = await this.paymentMethod?.getFeePayer() ?? this.account.getAddress();
|
|
43
|
+
const isFeePayer = feePayer.equals(this.account.getAddress());
|
|
44
|
+
let accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.EXTERNAL;
|
|
45
|
+
if (isFeePayer) {
|
|
46
|
+
accountFeePaymentMethodOptions = innerPayload.calls.length === 0 ? AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE : AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM;
|
|
47
|
+
}
|
|
48
|
+
options = {
|
|
49
|
+
feePaymentMethodOptions: accountFeePaymentMethodOptions
|
|
50
|
+
};
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
const args = [
|
|
55
|
-
feeEncodedCalls,
|
|
56
|
-
accountFeePaymentMethodOptions,
|
|
57
|
-
false
|
|
58
|
-
];
|
|
59
|
-
const feePaymentArtifact = typeof this.feePaymentNameOrArtifact === 'string' ? getFunctionArtifactByName(this.artifact, this.feePaymentNameOrArtifact) : this.feePaymentNameOrArtifact;
|
|
60
|
-
const entrypointCall = new FunctionCall(feePaymentArtifact.name, this.accountAddress, await FunctionSelector.fromNameAndParameters(feePaymentArtifact.name, feePaymentArtifact.parameters), feePaymentArtifact.functionType, false, feePaymentArtifact.isStatic, encodeArguments(feePaymentArtifact, args), feePaymentArtifact.returnTypes);
|
|
61
|
-
// Compute the authwitness required to verify the combined payload
|
|
62
|
-
const payloadAuthWitness = await this.wallet.createAuthWit(this.accountAddress, await feeEncodedCalls.hash());
|
|
63
|
-
return new ExecutionPayload([
|
|
64
|
-
entrypointCall
|
|
65
|
-
], [
|
|
66
|
-
payloadAuthWitness,
|
|
67
|
-
...feeAuthwitnesses
|
|
68
|
-
], [], feeEncodedCalls.hashedArguments, feePayer);
|
|
52
|
+
// Use the generic wrapping mechanism from the account interface
|
|
53
|
+
return this.account.wrapExecutionPayload(innerPayload, options);
|
|
69
54
|
}
|
|
70
55
|
getFeePayer() {
|
|
71
|
-
return this.paymentMethod?.getFeePayer() ?? Promise.resolve(this.
|
|
56
|
+
return this.paymentMethod?.getFeePayer() ?? Promise.resolve(this.account.getAddress());
|
|
72
57
|
}
|
|
73
58
|
getGasSettings() {
|
|
74
59
|
return this.paymentMethod?.getGasSettings();
|
|
@@ -3,7 +3,6 @@ import { CompleteAddress, type ContractInstanceWithAddress } from '@aztec/stdlib
|
|
|
3
3
|
import type { AccountContract } from '../account/account_contract.js';
|
|
4
4
|
import { AccountWithSecretKey } from '../account/account_with_secret_key.js';
|
|
5
5
|
import type { Salt } from '../account/index.js';
|
|
6
|
-
import type { AccountInterface } from '../account/interface.js';
|
|
7
6
|
import { DeployAccountMethod } from './deploy_account_method.js';
|
|
8
7
|
import type { Wallet } from './wallet.js';
|
|
9
8
|
/**
|
|
@@ -15,16 +14,14 @@ export declare class AccountManager {
|
|
|
15
14
|
private secretKey;
|
|
16
15
|
private accountContract;
|
|
17
16
|
private instance;
|
|
17
|
+
/**
|
|
18
|
+
* Contract instantiation salt for the account contract
|
|
19
|
+
*/
|
|
18
20
|
readonly salt: Salt;
|
|
19
21
|
private constructor();
|
|
20
22
|
static create(wallet: Wallet, secretKey: Fr, accountContract: AccountContract, salt?: Salt): Promise<AccountManager>;
|
|
21
23
|
protected getPublicKeys(): import("@aztec/stdlib/keys").PublicKeys;
|
|
22
24
|
protected getPublicKeysHash(): Fr | Promise<Fr>;
|
|
23
|
-
/**
|
|
24
|
-
* Returns the entrypoint for this account as defined by its account contract.
|
|
25
|
-
* @returns An entrypoint.
|
|
26
|
-
*/
|
|
27
|
-
getAccountInterface(): Promise<AccountInterface>;
|
|
28
25
|
/**
|
|
29
26
|
* Gets the calculated complete address associated with this account.
|
|
30
27
|
* Does not require the account to have been published for public execution.
|
|
@@ -35,7 +32,7 @@ export declare class AccountManager {
|
|
|
35
32
|
* Returns the secret key used to derive the rest of the privacy keys for this contract
|
|
36
33
|
*/
|
|
37
34
|
getSecretKey(): Fr;
|
|
38
|
-
get address(): import("
|
|
35
|
+
get address(): import("@aztec/stdlib/aztec-address").AztecAddress;
|
|
39
36
|
/**
|
|
40
37
|
* Returns the contract instance definition associated with this account.
|
|
41
38
|
* Does not require the account to have been published for public execution.
|
|
@@ -63,4 +60,4 @@ export declare class AccountManager {
|
|
|
63
60
|
*/
|
|
64
61
|
hasInitializer(): Promise<boolean>;
|
|
65
62
|
}
|
|
66
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
63
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWNjb3VudF9tYW5hZ2VyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvd2FsbGV0L2FjY291bnRfbWFuYWdlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxFQUNMLGVBQWUsRUFDZixLQUFLLDJCQUEyQixFQUVqQyxNQUFNLHdCQUF3QixDQUFDO0FBR2hDLE9BQU8sS0FBSyxFQUFFLGVBQWUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3RFLE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLHVDQUF1QyxDQUFDO0FBQzdFLE9BQU8sS0FBSyxFQUFFLElBQUksRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBRWhELE9BQU8sRUFBRSxtQkFBbUIsRUFBRSxNQUFNLDRCQUE0QixDQUFDO0FBQ2pFLE9BQU8sS0FBSyxFQUFFLE1BQU0sRUFBRSxNQUFNLGFBQWEsQ0FBQztBQUUxQzs7O0dBR0c7QUFDSCxxQkFBYSxjQUFjO0lBRXZCLE9BQU8sQ0FBQyxNQUFNO0lBQ2QsT0FBTyxDQUFDLFNBQVM7SUFDakIsT0FBTyxDQUFDLGVBQWU7SUFDdkIsT0FBTyxDQUFDLFFBQVE7SUFDaEI7O09BRUc7YUFDYSxJQUFJLEVBQUUsSUFBSTtJQVI1QixPQUFPLGVBU0g7SUFFSixPQUFhLE1BQU0sQ0FBQyxNQUFNLEVBQUUsTUFBTSxFQUFFLFNBQVMsRUFBRSxFQUFFLEVBQUUsZUFBZSxFQUFFLGVBQWUsRUFBRSxJQUFJLENBQUMsRUFBRSxJQUFJLDJCQWtCL0Y7SUFFRCxTQUFTLENBQUMsYUFBYSw0Q0FFdEI7SUFFRCxTQUFTLENBQUMsaUJBQWlCLHFCQUUxQjtJQUVEOzs7O09BSUc7SUFDSSxrQkFBa0IsSUFBSSxPQUFPLENBQUMsZUFBZSxDQUFDLENBRXBEO0lBRUQ7O09BRUc7SUFDSSxZQUFZLE9BRWxCO0lBRUQsSUFBSSxPQUFPLHVEQUVWO0lBRUQ7Ozs7T0FJRztJQUNJLFdBQVcsSUFBSSwyQkFBMkIsQ0FFaEQ7SUFFRDs7OztPQUlHO0lBQ1UsVUFBVSxJQUFJLE9BQU8sQ0FBQyxvQkFBb0IsQ0FBQyxDQUl2RDtJQUVEOzs7T0FHRztJQUNILGtCQUFrQixJQUFJLGVBQWUsQ0FFcEM7SUFFRDs7O09BR0c7SUFDVSxlQUFlLElBQUksT0FBTyxDQUFDLG1CQUFtQixDQUFDLENBMEIzRDtJQUVEOztPQUVHO0lBQ1UsY0FBYyxxQkFFMUI7Q0FDRiJ9
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"account_manager.d.ts","sourceRoot":"","sources":["../../src/wallet/account_manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EACL,eAAe,EACf,KAAK,2BAA2B,EAEjC,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"account_manager.d.ts","sourceRoot":"","sources":["../../src/wallet/account_manager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,gCAAgC,CAAC;AACpD,OAAO,EACL,eAAe,EACf,KAAK,2BAA2B,EAEjC,MAAM,wBAAwB,CAAC;AAGhC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,oBAAoB,EAAE,MAAM,uCAAuC,CAAC;AAC7E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,qBAAqB,CAAC;AAEhD,OAAO,EAAE,mBAAmB,EAAE,MAAM,4BAA4B,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAE1C;;;GAGG;AACH,qBAAa,cAAc;IAEvB,OAAO,CAAC,MAAM;IACd,OAAO,CAAC,SAAS;IACjB,OAAO,CAAC,eAAe;IACvB,OAAO,CAAC,QAAQ;IAChB;;OAEG;aACa,IAAI,EAAE,IAAI;IAR5B,OAAO,eASH;IAEJ,OAAa,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,EAAE,eAAe,EAAE,eAAe,EAAE,IAAI,CAAC,EAAE,IAAI,2BAkB/F;IAED,SAAS,CAAC,aAAa,4CAEtB;IAED,SAAS,CAAC,iBAAiB,qBAE1B;IAED;;;;OAIG;IACI,kBAAkB,IAAI,OAAO,CAAC,eAAe,CAAC,CAEpD;IAED;;OAEG;IACI,YAAY,OAElB;IAED,IAAI,OAAO,uDAEV;IAED;;;;OAIG;IACI,WAAW,IAAI,2BAA2B,CAEhD;IAED;;;;OAIG;IACU,UAAU,IAAI,OAAO,CAAC,oBAAoB,CAAC,CAIvD;IAED;;;OAGG;IACH,kBAAkB,IAAI,eAAe,CAEpC;IAED;;;OAGG;IACU,eAAe,IAAI,OAAO,CAAC,mBAAmB,CAAC,CA0B3D;IAED;;OAEG;IACU,cAAc,qBAE1B;CACF"}
|
|
@@ -45,14 +45,6 @@ import { DeployAccountMethod } from './deploy_account_method.js';
|
|
|
45
45
|
return this.getPublicKeys().hash();
|
|
46
46
|
}
|
|
47
47
|
/**
|
|
48
|
-
* Returns the entrypoint for this account as defined by its account contract.
|
|
49
|
-
* @returns An entrypoint.
|
|
50
|
-
*/ async getAccountInterface() {
|
|
51
|
-
const chainInfo = await this.wallet.getChainInfo();
|
|
52
|
-
const completeAddress = await this.getCompleteAddress();
|
|
53
|
-
return this.accountContract.getInterface(completeAddress, chainInfo);
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
48
|
* Gets the calculated complete address associated with this account.
|
|
57
49
|
* Does not require the account to have been published for public execution.
|
|
58
50
|
* @returns The address, partial address, and encryption public key.
|
|
@@ -79,8 +71,9 @@ import { DeployAccountMethod } from './deploy_account_method.js';
|
|
|
79
71
|
* instances to be interacted with from this account.
|
|
80
72
|
* @returns A Wallet instance.
|
|
81
73
|
*/ async getAccount() {
|
|
82
|
-
const
|
|
83
|
-
|
|
74
|
+
const completeAddress = await this.getCompleteAddress();
|
|
75
|
+
const account = this.accountContract.getAccount(completeAddress);
|
|
76
|
+
return new AccountWithSecretKey(account, this.secretKey, this.salt);
|
|
84
77
|
}
|
|
85
78
|
/**
|
|
86
79
|
* Returns the account contract that backs this account.
|
|
@@ -103,7 +96,8 @@ import { DeployAccountMethod } from './deploy_account_method.js';
|
|
|
103
96
|
constructorName: undefined,
|
|
104
97
|
constructorArgs: undefined
|
|
105
98
|
};
|
|
106
|
-
|
|
99
|
+
const account = await this.getAccount();
|
|
100
|
+
return new DeployAccountMethod(this.getPublicKeys(), this.wallet, artifact, (instance)=>Contract.at(instance.address, artifact, this.wallet), new Fr(this.salt), account, constructorArgs, constructorName);
|
|
107
101
|
}
|
|
108
102
|
/**
|
|
109
103
|
* Returns whether this account contract has an initializer function.
|