@aztec/aztec.js 0.0.1-commit.24de95ac → 0.0.1-commit.3469e52
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 +26 -42
- package/dest/account/account.d.ts.map +1 -1
- package/dest/account/account.js +19 -47
- package/dest/account/account_contract.d.ts +9 -10
- package/dest/account/account_contract.d.ts.map +1 -1
- package/dest/account/account_with_secret_key.d.ts +20 -9
- 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 +4 -3
- package/dest/account/index.d.ts.map +1 -1
- package/dest/account/index.js +2 -0
- package/dest/account/signerless_account.d.ts +7 -9
- package/dest/account/signerless_account.d.ts.map +1 -1
- package/dest/account/signerless_account.js +8 -11
- package/dest/api/abi.d.ts +1 -1
- package/dest/api/account.d.ts +3 -4
- package/dest/api/account.d.ts.map +1 -1
- package/dest/api/account.js +2 -3
- package/dest/api/addresses.d.ts +1 -1
- 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/block.d.ts +2 -2
- package/dest/api/block.d.ts.map +1 -1
- package/dest/api/block.js +1 -1
- package/dest/api/contract.d.ts +3 -3
- package/dest/api/contract.d.ts.map +1 -1
- package/dest/api/contract.js +1 -1
- package/dest/api/crypto.d.ts +1 -1
- package/dest/api/deployment.d.ts +1 -1
- package/dest/api/eth_address.d.ts +1 -1
- package/dest/api/ethereum.d.ts +1 -1
- package/dest/api/events.d.ts +1 -1
- package/dest/api/fee.d.ts +1 -1
- package/dest/api/fee_testing.d.ts +1 -1
- package/dest/api/fields.d.ts +3 -2
- package/dest/api/fields.d.ts.map +1 -1
- package/dest/api/fields.js +2 -1
- package/dest/api/keys.d.ts +1 -1
- package/dest/api/log.d.ts +1 -1
- package/dest/api/messaging.d.ts +1 -1
- package/dest/api/node.d.ts +1 -1
- package/dest/api/note.d.ts +2 -2
- package/dest/api/note.d.ts.map +1 -1
- package/dest/api/note.js +1 -1
- 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/trees.d.ts +1 -1
- 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/utils.d.ts +1 -1
- package/dest/api/wallet.d.ts +2 -3
- package/dest/api/wallet.d.ts.map +1 -1
- package/dest/api/wallet.js +1 -2
- package/dest/authorization/call_authorization_request.d.ts +2 -2
- package/dest/authorization/call_authorization_request.d.ts.map +1 -1
- package/dest/contract/base_contract_interaction.d.ts +2 -3
- 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 +8 -9
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +54 -34
- package/dest/contract/checker.d.ts +1 -1
- package/dest/contract/contract.d.ts +2 -2
- package/dest/contract/contract.d.ts.map +1 -1
- package/dest/contract/contract.js +4 -5
- package/dest/contract/contract_base.d.ts +6 -10
- package/dest/contract/contract_base.d.ts.map +1 -1
- package/dest/contract/contract_base.js +5 -12
- package/dest/contract/contract_function_interaction.d.ts +3 -3
- package/dest/contract/contract_function_interaction.d.ts.map +1 -1
- package/dest/contract/contract_function_interaction.js +9 -6
- package/dest/contract/deploy_method.d.ts +9 -8
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +14 -11
- package/dest/contract/deploy_sent_tx.d.ts +12 -7
- package/dest/contract/deploy_sent_tx.d.ts.map +1 -1
- package/dest/contract/deploy_sent_tx.js +10 -4
- package/dest/contract/get_gas_limits.d.ts +1 -1
- package/dest/contract/interaction_options.d.ts +4 -4
- package/dest/contract/interaction_options.d.ts.map +1 -1
- package/dest/contract/interaction_options.js +4 -10
- package/dest/contract/protocol_contracts/auth-registry.d.ts +36 -0
- package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/auth-registry.js +976 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts +35 -0
- package/dest/contract/protocol_contracts/contract-class-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-class-registry.js +797 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts +31 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/contract-instance-registry.js +871 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts +30 -0
- package/dest/contract/protocol_contracts/fee-juice.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/fee-juice.js +840 -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 +576 -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 +592 -0
- package/dest/contract/sent_tx.d.ts +2 -3
- package/dest/contract/sent_tx.d.ts.map +1 -1
- package/dest/contract/sent_tx.js +1 -1
- package/dest/contract/wait_for_proven.d.ts +2 -2
- package/dest/contract/wait_for_proven.d.ts.map +1 -1
- package/dest/deployment/broadcast_function.d.ts +1 -1
- package/dest/deployment/broadcast_function.js +4 -4
- package/dest/deployment/contract_deployer.d.ts +1 -1
- package/dest/deployment/contract_deployer.d.ts.map +1 -1
- package/dest/deployment/contract_deployer.js +1 -1
- package/dest/deployment/publish_class.d.ts +1 -1
- package/dest/deployment/publish_class.js +3 -3
- 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 -6
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- package/dest/ethereum/portal_manager.js +48 -22
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts +2 -2
- package/dest/fee/fee_juice_payment_method_with_claim.d.ts.map +1 -1
- package/dest/fee/fee_juice_payment_method_with_claim.js +3 -3
- package/dest/fee/fee_payment_method.d.ts +2 -2
- package/dest/fee/fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.d.ts +2 -2
- package/dest/fee/private_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/private_fee_payment_method.js +4 -4
- package/dest/fee/public_fee_payment_method.d.ts +2 -2
- package/dest/fee/public_fee_payment_method.d.ts.map +1 -1
- package/dest/fee/public_fee_payment_method.js +4 -4
- package/dest/fee/sponsored_fee_payment.d.ts +2 -2
- package/dest/fee/sponsored_fee_payment.d.ts.map +1 -1
- package/dest/fee/sponsored_fee_payment.js +2 -2
- 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/abi_types.d.ts +2 -2
- package/dest/utils/abi_types.d.ts.map +1 -1
- package/dest/utils/authwit.d.ts +9 -7
- package/dest/utils/authwit.d.ts.map +1 -1
- package/dest/utils/authwit.js +25 -14
- package/dest/utils/cross_chain.d.ts +2 -2
- package/dest/utils/cross_chain.d.ts.map +1 -1
- package/dest/utils/fee_juice.d.ts +2 -2
- package/dest/utils/fee_juice.js +2 -2
- package/dest/utils/field_compressed_string.d.ts +1 -1
- package/dest/utils/field_compressed_string.d.ts.map +1 -1
- package/dest/utils/field_compressed_string.js +1 -1
- package/dest/utils/node.d.ts +2 -2
- package/dest/utils/node.d.ts.map +1 -1
- package/dest/utils/pub_key.d.ts +2 -2
- package/dest/utils/pub_key.d.ts.map +1 -1
- package/dest/utils/pub_key.js +1 -1
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts +6 -9
- package/dest/wallet/account_entrypoint_meta_payment_method.d.ts.map +1 -1
- package/dest/wallet/account_entrypoint_meta_payment_method.js +29 -44
- package/dest/wallet/account_manager.d.ts +3 -9
- package/dest/wallet/account_manager.d.ts.map +1 -1
- package/dest/wallet/account_manager.js +6 -12
- package/dest/wallet/deploy_account_method.d.ts +20 -6
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/deploy_account_method.js +9 -7
- package/dest/wallet/index.d.ts +1 -2
- package/dest/wallet/index.d.ts.map +1 -1
- package/dest/wallet/index.js +0 -1
- package/dest/wallet/wallet.d.ts +273 -1499
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +71 -114
- package/package.json +16 -13
- package/src/account/account.ts +35 -60
- package/src/account/account_contract.ts +7 -8
- package/src/account/account_with_secret_key.ts +34 -9
- package/src/account/index.ts +3 -2
- package/src/account/signerless_account.ts +15 -15
- package/src/api/account.ts +10 -3
- package/src/api/authorization.ts +1 -0
- package/src/api/block.ts +1 -1
- package/src/api/contract.ts +2 -1
- package/src/api/fields.ts +2 -1
- package/src/api/note.ts +1 -1
- package/src/api/protocol.ts +7 -0
- package/src/api/tx.ts +2 -0
- package/src/api/wallet.ts +5 -9
- package/src/authorization/call_authorization_request.ts +1 -1
- package/src/contract/base_contract_interaction.ts +2 -3
- package/src/contract/batch_call.ts +67 -48
- package/src/contract/contract.ts +7 -5
- package/src/contract/contract_base.ts +5 -15
- package/src/contract/contract_function_interaction.ts +10 -11
- package/src/contract/deploy_method.ts +20 -18
- package/src/contract/deploy_sent_tx.ts +17 -10
- package/src/contract/interaction_options.ts +4 -10
- package/src/contract/protocol_contracts/auth-registry.ts +554 -0
- package/src/contract/protocol_contracts/contract-class-registry.ts +442 -0
- package/src/contract/protocol_contracts/contract-instance-registry.ts +502 -0
- package/src/contract/protocol_contracts/fee-juice.ts +466 -0
- package/src/contract/protocol_contracts/multi-call-entrypoint.ts +338 -0
- package/src/contract/protocol_contracts/public-checks.ts +324 -0
- package/src/contract/sent_tx.ts +2 -3
- package/src/deployment/broadcast_function.ts +4 -4
- package/src/deployment/contract_deployer.ts +3 -2
- package/src/deployment/publish_class.ts +3 -3
- package/src/deployment/publish_instance.ts +3 -6
- package/src/ethereum/portal_manager.ts +65 -34
- package/src/fee/fee_juice_payment_method_with_claim.ts +4 -2
- package/src/fee/fee_payment_method.ts +1 -1
- package/src/fee/private_fee_payment_method.ts +5 -3
- package/src/fee/public_fee_payment_method.ts +5 -3
- package/src/fee/sponsored_fee_payment.ts +3 -1
- package/src/scripts/generate_protocol_contract_types.ts +150 -0
- package/src/utils/abi_types.ts +1 -1
- package/src/utils/authwit.ts +24 -18
- package/src/utils/cross_chain.ts +1 -1
- package/src/utils/fee_juice.ts +2 -2
- package/src/utils/field_compressed_string.ts +1 -1
- package/src/utils/pub_key.ts +2 -2
- package/src/wallet/account_entrypoint_meta_payment_method.ts +29 -60
- package/src/wallet/account_manager.ts +7 -15
- package/src/wallet/deploy_account_method.ts +23 -13
- package/src/wallet/index.ts +0 -1
- package/src/wallet/wallet.ts +177 -142
- 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/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/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/wallet/base_wallet.d.ts +0 -91
- package/dest/wallet/base_wallet.d.ts.map +0 -1
- package/dest/wallet/base_wallet.js +0 -238
- package/src/account/interface.ts +0 -25
- package/src/contract/protocol_contracts.ts +0 -35
- package/src/contract/unsafe_contract.ts +0 -19
- package/src/wallet/base_wallet.ts +0 -350
package/src/utils/authwit.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ChainInfo } from '@aztec/entrypoints/interfaces';
|
|
2
|
-
import { Fr } from '@aztec/foundation/
|
|
2
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
3
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
4
4
|
import { type ABIParameterVisibility, type FunctionAbi, type FunctionCall, FunctionType } from '@aztec/stdlib/abi';
|
|
5
5
|
import { AuthWitness, computeInnerAuthWitHash, computeOuterAuthWitHash } from '@aztec/stdlib/auth-witness';
|
|
@@ -22,7 +22,7 @@ export type IntentInnerHash = {
|
|
|
22
22
|
/** The consumer */
|
|
23
23
|
consumer: AztecAddress;
|
|
24
24
|
/** The action to approve */
|
|
25
|
-
innerHash:
|
|
25
|
+
innerHash: Fr;
|
|
26
26
|
};
|
|
27
27
|
|
|
28
28
|
/** Intent with a call */
|
|
@@ -42,8 +42,8 @@ export type ContractFunctionInteractionCallIntent = {
|
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
/** Identifies ContractFunctionInteractionCallIntents */
|
|
45
|
-
function
|
|
46
|
-
messageHashOrIntent: Fr |
|
|
45
|
+
export function isContractFunctionInteractionCallIntent(
|
|
46
|
+
messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
|
|
47
47
|
): messageHashOrIntent is ContractFunctionInteractionCallIntent {
|
|
48
48
|
return (
|
|
49
49
|
'caller' in messageHashOrIntent &&
|
|
@@ -81,7 +81,7 @@ export const computeAuthWitMessageHash = async (
|
|
|
81
81
|
const version = metadata.version;
|
|
82
82
|
|
|
83
83
|
if ('caller' in intent) {
|
|
84
|
-
const call =
|
|
84
|
+
const call = isContractFunctionInteractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
|
|
85
85
|
return computeOuterAuthWitHash(
|
|
86
86
|
call.to,
|
|
87
87
|
chainId,
|
|
@@ -102,14 +102,12 @@ export const computeAuthWitMessageHash = async (
|
|
|
102
102
|
* @returns The message hash for the intent
|
|
103
103
|
*/
|
|
104
104
|
export async function getMessageHashFromIntent(
|
|
105
|
-
messageHashOrIntent: Fr |
|
|
105
|
+
messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
|
|
106
106
|
chainInfo: ChainInfo,
|
|
107
107
|
) {
|
|
108
108
|
let messageHash: Fr;
|
|
109
109
|
const { chainId, version } = chainInfo;
|
|
110
|
-
if (
|
|
111
|
-
messageHash = Fr.fromBuffer(messageHashOrIntent);
|
|
112
|
-
} else if (messageHashOrIntent instanceof Fr) {
|
|
110
|
+
if (messageHashOrIntent instanceof Fr) {
|
|
113
111
|
messageHash = messageHashOrIntent;
|
|
114
112
|
} else {
|
|
115
113
|
messageHash = await computeAuthWitMessageHash(messageHashOrIntent, { chainId, version });
|
|
@@ -156,12 +154,9 @@ export async function lookupValidity(
|
|
|
156
154
|
}> {
|
|
157
155
|
let innerHash, consumer;
|
|
158
156
|
if ('caller' in intent) {
|
|
159
|
-
const call =
|
|
157
|
+
const call = isContractFunctionInteractionCallIntent(intent) ? await intent.action.getFunctionCall() : intent.call;
|
|
160
158
|
innerHash = await computeInnerAuthWitHashFromAction(intent.caller, call);
|
|
161
159
|
consumer = call.to;
|
|
162
|
-
} else if (Buffer.isBuffer(intent.innerHash)) {
|
|
163
|
-
innerHash = Fr.fromBuffer(intent.innerHash);
|
|
164
|
-
consumer = intent.consumer;
|
|
165
160
|
} else {
|
|
166
161
|
({ innerHash, consumer } = intent);
|
|
167
162
|
}
|
|
@@ -174,9 +169,20 @@ export async function lookupValidity(
|
|
|
174
169
|
name: 'lookup_validity',
|
|
175
170
|
isInitializer: false,
|
|
176
171
|
functionType: FunctionType.UTILITY,
|
|
177
|
-
|
|
172
|
+
isOnlySelf: false,
|
|
178
173
|
isStatic: false,
|
|
179
|
-
parameters: [
|
|
174
|
+
parameters: [
|
|
175
|
+
{
|
|
176
|
+
name: 'consumer',
|
|
177
|
+
type: {
|
|
178
|
+
fields: [{ name: 'inner', type: { kind: 'field' } }],
|
|
179
|
+
kind: 'struct',
|
|
180
|
+
path: 'aztec::protocol_types::address::aztec_address::AztecAddress',
|
|
181
|
+
},
|
|
182
|
+
visibility: 'private' as ABIParameterVisibility,
|
|
183
|
+
},
|
|
184
|
+
{ name: 'inner_hash', type: { kind: 'field' }, visibility: 'private' as ABIParameterVisibility },
|
|
185
|
+
],
|
|
180
186
|
returnTypes: [{ kind: 'boolean' }],
|
|
181
187
|
errorTypes: {},
|
|
182
188
|
} as FunctionAbi;
|
|
@@ -194,7 +200,7 @@ export async function lookupValidity(
|
|
|
194
200
|
name: 'utility_is_consumable',
|
|
195
201
|
isInitializer: false,
|
|
196
202
|
functionType: FunctionType.UTILITY,
|
|
197
|
-
|
|
203
|
+
isOnlySelf: false,
|
|
198
204
|
isStatic: false,
|
|
199
205
|
parameters: [
|
|
200
206
|
{
|
|
@@ -240,7 +246,7 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
|
|
|
240
246
|
static async create(
|
|
241
247
|
wallet: Wallet,
|
|
242
248
|
from: AztecAddress,
|
|
243
|
-
messageHashOrIntent: Fr |
|
|
249
|
+
messageHashOrIntent: Fr | IntentInnerHash | CallIntent | ContractFunctionInteractionCallIntent,
|
|
244
250
|
authorized: boolean,
|
|
245
251
|
) {
|
|
246
252
|
const chainInfo = await wallet.getChainInfo();
|
|
@@ -291,7 +297,7 @@ export class SetPublicAuthwitContractInteraction extends ContractFunctionInterac
|
|
|
291
297
|
name: 'set_authorized',
|
|
292
298
|
isInitializer: false,
|
|
293
299
|
functionType: FunctionType.PUBLIC,
|
|
294
|
-
|
|
300
|
+
isOnlySelf: true,
|
|
295
301
|
isStatic: false,
|
|
296
302
|
parameters: [
|
|
297
303
|
{
|
package/src/utils/cross_chain.ts
CHANGED
package/src/utils/fee_juice.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
3
3
|
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
4
|
import { deriveStorageSlotInMap } from '@aztec/stdlib/hash';
|
|
@@ -6,7 +6,7 @@ import type { AztecNode } from '@aztec/stdlib/interfaces/client';
|
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* Returns the owner's fee juice balance.
|
|
9
|
-
* Note: This is used only
|
|
9
|
+
* Note: This is used only e2e_local_network_example test. TODO: Consider nuking.
|
|
10
10
|
*/
|
|
11
11
|
export async function getFeeJuiceBalance(owner: AztecAddress, node: AztecNode): Promise<bigint> {
|
|
12
12
|
const slot = await deriveStorageSlotInMap(new Fr(1), owner);
|
package/src/utils/pub_key.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Grumpkin } from '@aztec/foundation/crypto';
|
|
2
|
-
import type { GrumpkinScalar } from '@aztec/foundation/
|
|
1
|
+
import { Grumpkin } from '@aztec/foundation/crypto/grumpkin';
|
|
2
|
+
import type { GrumpkinScalar } from '@aztec/foundation/curves/grumpkin';
|
|
3
3
|
import type { PublicKey } from '@aztec/stdlib/keys';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -1,20 +1,11 @@
|
|
|
1
1
|
import { AccountFeePaymentMethodOptions } from '@aztec/entrypoints/account';
|
|
2
|
-
import { EncodedAppEntrypointCalls } from '@aztec/entrypoints/encoding';
|
|
3
|
-
import { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
4
2
|
import { ProtocolContractAddress } from '@aztec/protocol-contracts';
|
|
5
|
-
import {
|
|
6
|
-
type ContractArtifact,
|
|
7
|
-
type FunctionArtifact,
|
|
8
|
-
FunctionCall,
|
|
9
|
-
FunctionSelector,
|
|
10
|
-
encodeArguments,
|
|
11
|
-
getFunctionArtifactByName,
|
|
12
|
-
} from '@aztec/stdlib/abi';
|
|
13
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
14
4
|
import type { GasSettings } from '@aztec/stdlib/gas';
|
|
5
|
+
import { ExecutionPayload } from '@aztec/stdlib/tx';
|
|
15
6
|
|
|
7
|
+
import type { Account } from '../account/account.js';
|
|
16
8
|
import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
17
|
-
import type { Wallet } from './index.js';
|
|
18
9
|
|
|
19
10
|
/**
|
|
20
11
|
* Fee payment method that allows an account contract to pay for its own deployment
|
|
@@ -33,11 +24,9 @@ import type { Wallet } from './index.js';
|
|
|
33
24
|
*/
|
|
34
25
|
export class AccountEntrypointMetaPaymentMethod implements FeePaymentMethod {
|
|
35
26
|
constructor(
|
|
36
|
-
private
|
|
37
|
-
private artifact: ContractArtifact,
|
|
38
|
-
private feePaymentNameOrArtifact: string | FunctionArtifact,
|
|
39
|
-
private accountAddress: AztecAddress,
|
|
27
|
+
private account: Account,
|
|
40
28
|
private paymentMethod?: FeePaymentMethod,
|
|
29
|
+
private feeEntrypointOptions?: any,
|
|
41
30
|
) {}
|
|
42
31
|
|
|
43
32
|
getAsset(): Promise<AztecAddress> {
|
|
@@ -45,58 +34,38 @@ export class AccountEntrypointMetaPaymentMethod implements FeePaymentMethod {
|
|
|
45
34
|
}
|
|
46
35
|
|
|
47
36
|
async getExecutionPayload(): Promise<ExecutionPayload> {
|
|
48
|
-
// Get the execution payload for the fee
|
|
49
|
-
|
|
50
|
-
// FeeJuice balance
|
|
51
|
-
const { calls: feeCalls, authWitnesses: feeAuthwitnesses } =
|
|
52
|
-
(await this.paymentMethod?.getExecutionPayload()) ?? ExecutionPayload.empty();
|
|
53
|
-
// Encode the calls for the fee
|
|
54
|
-
const feePayer = (await this.paymentMethod?.getFeePayer()) ?? this.accountAddress;
|
|
55
|
-
const isFeePayer = feePayer.equals(this.accountAddress);
|
|
56
|
-
let accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.EXTERNAL;
|
|
57
|
-
if (isFeePayer) {
|
|
58
|
-
// If the account is the fee payer, and the incoming fee payload has calls
|
|
59
|
-
// it can only be FeeJuicePaymentMethodWithClaim
|
|
60
|
-
// If the payload has no calls, it's paying using
|
|
61
|
-
// its own fee juice balance
|
|
62
|
-
accountFeePaymentMethodOptions =
|
|
63
|
-
feeCalls.length === 0
|
|
64
|
-
? AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE
|
|
65
|
-
: AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM;
|
|
66
|
-
}
|
|
67
|
-
const feeEncodedCalls = await EncodedAppEntrypointCalls.create(feeCalls);
|
|
37
|
+
// Get the execution payload for the fee
|
|
38
|
+
const innerPayload = (await this.paymentMethod?.getExecutionPayload()) ?? ExecutionPayload.empty();
|
|
68
39
|
|
|
69
|
-
//
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
40
|
+
// If no fee entrypoint options were provided, compute them based on the wrapped payment method
|
|
41
|
+
// This mimics how the actual account contract works when invoked directly:
|
|
42
|
+
// - If we are the fee payer, are there calls in the inner payload? In that case, those calls can
|
|
43
|
+
// only be claiming fee juice, so we use FEE_JUICE_WITH_CLAIM
|
|
44
|
+
// - If we are the fee payer, but there are no calls, then we assume the account already has
|
|
45
|
+
// fee juice and can pay directly with PREEXISTING_FEE_JUICE
|
|
46
|
+
// - If we are not the fee payer, then EXTERNAL is used
|
|
47
|
+
let options = this.feeEntrypointOptions;
|
|
48
|
+
if (!options) {
|
|
49
|
+
const feePayer = (await this.paymentMethod?.getFeePayer()) ?? this.account.getAddress();
|
|
50
|
+
const isFeePayer = feePayer.equals(this.account.getAddress());
|
|
75
51
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
encodeArguments(feePaymentArtifact, args),
|
|
84
|
-
feePaymentArtifact.returnTypes,
|
|
85
|
-
);
|
|
52
|
+
let accountFeePaymentMethodOptions = AccountFeePaymentMethodOptions.EXTERNAL;
|
|
53
|
+
if (isFeePayer) {
|
|
54
|
+
accountFeePaymentMethodOptions =
|
|
55
|
+
innerPayload.calls.length === 0
|
|
56
|
+
? AccountFeePaymentMethodOptions.PREEXISTING_FEE_JUICE
|
|
57
|
+
: AccountFeePaymentMethodOptions.FEE_JUICE_WITH_CLAIM;
|
|
58
|
+
}
|
|
86
59
|
|
|
87
|
-
|
|
88
|
-
|
|
60
|
+
options = { feePaymentMethodOptions: accountFeePaymentMethodOptions };
|
|
61
|
+
}
|
|
89
62
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
[payloadAuthWitness, ...feeAuthwitnesses],
|
|
93
|
-
[],
|
|
94
|
-
feeEncodedCalls.hashedArguments,
|
|
95
|
-
);
|
|
63
|
+
// Use the generic wrapping mechanism from the account interface
|
|
64
|
+
return this.account.wrapExecutionPayload(innerPayload, options);
|
|
96
65
|
}
|
|
97
66
|
|
|
98
67
|
getFeePayer(): Promise<AztecAddress> {
|
|
99
|
-
return this.paymentMethod?.getFeePayer() ?? Promise.resolve(this.
|
|
68
|
+
return this.paymentMethod?.getFeePayer() ?? Promise.resolve(this.account.getAddress());
|
|
100
69
|
}
|
|
101
70
|
|
|
102
71
|
getGasSettings(): GasSettings | undefined {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Fr } from '@aztec/foundation/
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
2
|
import {
|
|
3
3
|
CompleteAddress,
|
|
4
4
|
type ContractInstanceWithAddress,
|
|
@@ -9,7 +9,6 @@ import { deriveKeys } from '@aztec/stdlib/keys';
|
|
|
9
9
|
import type { AccountContract } from '../account/account_contract.js';
|
|
10
10
|
import { AccountWithSecretKey } from '../account/account_with_secret_key.js';
|
|
11
11
|
import type { Salt } from '../account/index.js';
|
|
12
|
-
import type { AccountInterface } from '../account/interface.js';
|
|
13
12
|
import { Contract } from '../contract/contract.js';
|
|
14
13
|
import { DeployAccountMethod } from './deploy_account_method.js';
|
|
15
14
|
import type { Wallet } from './wallet.js';
|
|
@@ -58,16 +57,6 @@ export class AccountManager {
|
|
|
58
57
|
return this.getPublicKeys().hash();
|
|
59
58
|
}
|
|
60
59
|
|
|
61
|
-
/**
|
|
62
|
-
* Returns the entrypoint for this account as defined by its account contract.
|
|
63
|
-
* @returns An entrypoint.
|
|
64
|
-
*/
|
|
65
|
-
public async getAccountInterface(): Promise<AccountInterface> {
|
|
66
|
-
const chainInfo = await this.wallet.getChainInfo();
|
|
67
|
-
const completeAddress = await this.getCompleteAddress();
|
|
68
|
-
return this.accountContract.getInterface(completeAddress, chainInfo);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
60
|
/**
|
|
72
61
|
* Gets the calculated complete address associated with this account.
|
|
73
62
|
* Does not require the account to have been published for public execution.
|
|
@@ -103,8 +92,9 @@ export class AccountManager {
|
|
|
103
92
|
* @returns A Wallet instance.
|
|
104
93
|
*/
|
|
105
94
|
public async getAccount(): Promise<AccountWithSecretKey> {
|
|
106
|
-
const
|
|
107
|
-
|
|
95
|
+
const completeAddress = await this.getCompleteAddress();
|
|
96
|
+
const account = this.accountContract.getAccount(completeAddress);
|
|
97
|
+
return new AccountWithSecretKey(account, this.secretKey, this.salt);
|
|
108
98
|
}
|
|
109
99
|
|
|
110
100
|
/**
|
|
@@ -134,12 +124,14 @@ export class AccountManager {
|
|
|
134
124
|
constructorArgs: undefined,
|
|
135
125
|
};
|
|
136
126
|
|
|
127
|
+
const account = await this.getAccount();
|
|
137
128
|
return new DeployAccountMethod(
|
|
138
129
|
this.getPublicKeys(),
|
|
139
130
|
this.wallet,
|
|
140
131
|
artifact,
|
|
141
|
-
|
|
132
|
+
instance => Contract.at(instance.address, artifact, this.wallet),
|
|
142
133
|
new Fr(this.salt),
|
|
134
|
+
account,
|
|
143
135
|
constructorArgs,
|
|
144
136
|
constructorName,
|
|
145
137
|
);
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Fr } from '@aztec/foundation/fields';
|
|
1
|
+
import { Fr } from '@aztec/foundation/curves/bn254';
|
|
3
2
|
import type { ContractArtifact, FunctionArtifact } from '@aztec/stdlib/abi';
|
|
4
3
|
import { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
4
|
+
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
|
5
5
|
import type { PublicKeys } from '@aztec/stdlib/keys';
|
|
6
|
+
import { ExecutionPayload, mergeExecutionPayloads } from '@aztec/stdlib/tx';
|
|
6
7
|
|
|
8
|
+
import type { Account } from '../account/account.js';
|
|
7
9
|
import type { Contract } from '../contract/contract.js';
|
|
8
10
|
import type { ContractBase } from '../contract/contract_base.js';
|
|
9
11
|
import {
|
|
@@ -12,15 +14,27 @@ import {
|
|
|
12
14
|
type RequestDeployOptions,
|
|
13
15
|
type SimulateDeployOptions,
|
|
14
16
|
} from '../contract/deploy_method.js';
|
|
17
|
+
import type { FeePaymentMethodOption } from '../contract/interaction_options.js';
|
|
15
18
|
import type { FeePaymentMethod } from '../fee/fee_payment_method.js';
|
|
16
19
|
import { AccountEntrypointMetaPaymentMethod } from './account_entrypoint_meta_payment_method.js';
|
|
17
20
|
import type { Wallet } from './index.js';
|
|
18
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Extended fee payment method option for account deployments that includes entrypoint wrapping options
|
|
24
|
+
*/
|
|
25
|
+
export type DeployAccountFeePaymentMethodOption = FeePaymentMethodOption & {
|
|
26
|
+
/** Optional entrypoint-specific options for wrapping execution payloads */
|
|
27
|
+
feeEntrypointOptions?: unknown;
|
|
28
|
+
};
|
|
29
|
+
|
|
19
30
|
/**
|
|
20
31
|
* The configuration options for the request method. Omits the contractAddressSalt, since
|
|
21
32
|
* for account contracts that is fixed in the constructor
|
|
22
33
|
*/
|
|
23
|
-
export type RequestDeployAccountOptions = Omit<RequestDeployOptions, 'contractAddressSalt'
|
|
34
|
+
export type RequestDeployAccountOptions = Omit<RequestDeployOptions, 'contractAddressSalt' | 'fee'> & {
|
|
35
|
+
/** Fee options specific to account deployment */
|
|
36
|
+
fee?: DeployAccountFeePaymentMethodOption;
|
|
37
|
+
};
|
|
24
38
|
|
|
25
39
|
/**
|
|
26
40
|
* The configuration options for the send/prove methods. Omits:
|
|
@@ -44,8 +58,9 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
|
|
|
44
58
|
publicKeys: PublicKeys,
|
|
45
59
|
wallet: Wallet,
|
|
46
60
|
artifact: ContractArtifact,
|
|
47
|
-
postDeployCtor: (
|
|
61
|
+
postDeployCtor: (instance: ContractInstanceWithAddress, wallet: Wallet) => TContract,
|
|
48
62
|
private salt: Fr,
|
|
63
|
+
private account: Account,
|
|
49
64
|
args: any[] = [],
|
|
50
65
|
constructorNameOrArtifact?: string | FunctionArtifact,
|
|
51
66
|
) {
|
|
@@ -60,19 +75,14 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
|
|
|
60
75
|
* For more details on how the fee payment routing works see documentation of AccountEntrypointMetaPaymentMethod class.
|
|
61
76
|
*
|
|
62
77
|
* @param originalPaymentMethod - originalPaymentMethod The original payment method to be wrapped.
|
|
78
|
+
* @param feeEntrypointOptions - Optional entrypoint-specific options for wrapping. If not provided, will be auto-computed based on the payment method.
|
|
63
79
|
* @returns A FeePaymentMethod that routes the original one through the account's entrypoint (AccountEntrypointMetaPaymentMethod)
|
|
64
80
|
*/
|
|
65
|
-
private getSelfFeePaymentMethod(originalPaymentMethod?: FeePaymentMethod) {
|
|
81
|
+
private getSelfFeePaymentMethod(originalPaymentMethod?: FeePaymentMethod, feeEntrypointOptions?: any) {
|
|
66
82
|
if (!this.address) {
|
|
67
83
|
throw new Error('Instance is not yet constructed. This is a bug!');
|
|
68
84
|
}
|
|
69
|
-
return new AccountEntrypointMetaPaymentMethod(
|
|
70
|
-
this.wallet,
|
|
71
|
-
this.artifact,
|
|
72
|
-
'entrypoint',
|
|
73
|
-
this.address,
|
|
74
|
-
originalPaymentMethod,
|
|
75
|
-
);
|
|
85
|
+
return new AccountEntrypointMetaPaymentMethod(this.account, originalPaymentMethod, feeEntrypointOptions);
|
|
76
86
|
}
|
|
77
87
|
|
|
78
88
|
/**
|
|
@@ -96,7 +106,7 @@ export class DeployAccountMethod<TContract extends ContractBase = Contract> exte
|
|
|
96
106
|
const executionPayloads = [deploymentExecutionPayload];
|
|
97
107
|
// If this is a self-deployment, manage the fee accordingly
|
|
98
108
|
if (opts?.deployer?.equals(AztecAddress.ZERO)) {
|
|
99
|
-
const feePaymentMethod = this.getSelfFeePaymentMethod(opts?.fee?.paymentMethod);
|
|
109
|
+
const feePaymentMethod = this.getSelfFeePaymentMethod(opts?.fee?.paymentMethod, opts?.fee?.feeEntrypointOptions);
|
|
100
110
|
const feeExecutionPayload = await feePaymentMethod.getExecutionPayload();
|
|
101
111
|
// Notice they are reversed (fee payment usually goes first):
|
|
102
112
|
// this is because we need to construct the contract BEFORE it can pay for its own fee
|
package/src/wallet/index.ts
CHANGED