@aztec/aztec.js 0.0.1-commit.6d3c34e → 0.0.1-commit.7ac86ea28
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 +3 -3
- package/dest/contract/batch_call.d.ts.map +1 -1
- package/dest/contract/batch_call.js +8 -5
- 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 +10 -7
- package/dest/contract/deploy_method.d.ts +76 -17
- package/dest/contract/deploy_method.d.ts.map +1 -1
- package/dest/contract/deploy_method.js +55 -29
- package/dest/contract/interaction_options.d.ts +49 -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 +36 -0
- package/dest/contract/protocol_contracts/auth-registry.d.ts.map +1 -0
- package/dest/contract/protocol_contracts/auth-registry.js +997 -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 +139 -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 +593 -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 +601 -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 +3 -1
- package/dest/ethereum/portal_manager.d.ts.map +1 -1
- 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 +452 -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 +46 -7
- package/dest/wallet/deploy_account_method.d.ts.map +1 -1
- package/dest/wallet/deploy_account_method.js +33 -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 +1740 -2496
- package/dest/wallet/wallet.d.ts.map +1 -1
- package/dest/wallet/wallet.js +211 -108
- 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 +48 -3
- package/src/contract/base_contract_interaction.ts +27 -15
- package/src/contract/batch_call.ts +8 -13
- package/src/contract/contract_function_interaction.ts +17 -7
- package/src/contract/deploy_method.ts +145 -35
- package/src/contract/interaction_options.ts +56 -4
- package/src/contract/protocol_contracts/auth-registry.ts +551 -0
- package/src/contract/protocol_contracts/contract-class-registry.ts +99 -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 +334 -0
- package/src/contract/protocol_contracts/public-checks.ts +318 -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/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 +500 -0
- package/src/wallet/deploy_account_method.ts +74 -13
- package/src/wallet/index.ts +1 -0
- package/src/wallet/wallet.ts +344 -130
- 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
|
@@ -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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWNjb3VudF9tYW5hZ2VyLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvd2FsbGV0L2FjY291bnRfbWFuYWdlci50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEVBQUUsRUFBRSxFQUFFLE1BQU0sZ0NBQWdDLENBQUM7QUFDcEQsT0FBTyxFQUNMLGVBQWUsRUFDZixLQUFLLDJCQUEyQixFQUVqQyxNQUFNLHdCQUF3QixDQUFDO0FBR2hDLE9BQU8sS0FBSyxFQUFFLGVBQWUsRUFBRSxNQUFNLGdDQUFnQyxDQUFDO0FBQ3RFLE9BQU8sRUFBRSxvQkFBb0IsRUFBRSxNQUFNLHVDQUF1QyxDQUFDO0FBQzdFLE9BQU8sS0FBSyxFQUFFLElBQUksRUFBRSxNQUFNLHFCQUFxQixDQUFDO0FBRWhELE9BQU8sRUFBRSxtQkF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":["../../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.
|
|
@@ -0,0 +1,452 @@
|
|
|
1
|
+
import type { Fr } from '@aztec/foundation/curves/bn254';
|
|
2
|
+
import type { AztecAddress } from '@aztec/stdlib/aztec-address';
|
|
3
|
+
import type { Aliased } from './wallet.js';
|
|
4
|
+
/**
|
|
5
|
+
* Current capability manifest version.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CAPABILITY_VERSION: "1.0";
|
|
8
|
+
/**
|
|
9
|
+
* Pattern for matching contract functions with wildcards.
|
|
10
|
+
*
|
|
11
|
+
* Used in simulation and transaction capabilities to specify which
|
|
12
|
+
* contract functions are allowed.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* // Allow any function on a specific contract
|
|
16
|
+
* \{ contract: ammAddress, function: '*' \}
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Allow only 'swap' function on a specific contract
|
|
20
|
+
* \{ contract: ammAddress, function: 'swap' \}
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* // Allow 'transfer' on any contract
|
|
24
|
+
* \{ contract: '*', function: 'transfer' \}
|
|
25
|
+
*/
|
|
26
|
+
export interface ContractFunctionPattern {
|
|
27
|
+
/** Contract address or '*' for any contract */
|
|
28
|
+
contract: AztecAddress | '*';
|
|
29
|
+
/** Function name or '*' for any function */
|
|
30
|
+
function: string;
|
|
31
|
+
/**
|
|
32
|
+
* Additional addresses whose private state and keys are accessible
|
|
33
|
+
* when calling this function, beyond the sender's.
|
|
34
|
+
* - undefined: No additional scopes allowed
|
|
35
|
+
* - AztecAddress[]: Only these specific addresses allowed as additional scopes
|
|
36
|
+
* - '*': All known address allowed as an additional scope
|
|
37
|
+
*/
|
|
38
|
+
additionalScopes?: AztecAddress[] | '*';
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Account access capability - grants access to user accounts.
|
|
42
|
+
*
|
|
43
|
+
* Maps to wallet methods:
|
|
44
|
+
* - getAccounts (when canGet: true)
|
|
45
|
+
* - createAuthWit (when canCreateAuthWit: true)
|
|
46
|
+
*
|
|
47
|
+
* The wallet decides which accounts to reveal to the app.
|
|
48
|
+
* Apps don't specify which accounts they want - they just request
|
|
49
|
+
* the capability and the wallet shows them the available accounts.
|
|
50
|
+
*/
|
|
51
|
+
export interface AccountsCapability {
|
|
52
|
+
/** Discriminator for capability type */
|
|
53
|
+
type: 'accounts';
|
|
54
|
+
/** Can get accounts from wallet. Maps to: getAccounts */
|
|
55
|
+
canGet?: boolean;
|
|
56
|
+
/** Can create auth witnesses for accounts. Maps to: createAuthWit */
|
|
57
|
+
canCreateAuthWit?: boolean;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Granted account access capability.
|
|
61
|
+
*
|
|
62
|
+
* Extends the request with specific accounts that were granted by the wallet.
|
|
63
|
+
*/
|
|
64
|
+
export interface GrantedAccountsCapability extends AccountsCapability {
|
|
65
|
+
/** Specific accounts granted by the wallet with their aliases. The wallet adds this when granting the capability. */
|
|
66
|
+
accounts: Aliased<AztecAddress>[];
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Contract interaction capability - for registering and querying contracts.
|
|
70
|
+
*
|
|
71
|
+
* Maps to wallet methods:
|
|
72
|
+
* - registerContract (when canRegister: true)
|
|
73
|
+
* - getContractMetadata (when canGetMetadata: true)
|
|
74
|
+
*
|
|
75
|
+
* Matching is done by contract address, not class ID. This allows updating
|
|
76
|
+
* existing contracts with new artifacts (e.g., when contract is upgraded
|
|
77
|
+
* to a new contractClassId on-chain).
|
|
78
|
+
*
|
|
79
|
+
* Note: For querying contract class metadata, use ContractClassesCapability instead.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* // Register and query specific contracts
|
|
83
|
+
* \{
|
|
84
|
+
* type: 'contracts',
|
|
85
|
+
* contracts: [ammAddress, tokenAddress],
|
|
86
|
+
* canRegister: true,
|
|
87
|
+
* canGetMetadata: true
|
|
88
|
+
* \}
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* // Query any contract (read-only)
|
|
92
|
+
* \{
|
|
93
|
+
* type: 'contracts',
|
|
94
|
+
* contracts: '*',
|
|
95
|
+
* canGetMetadata: true
|
|
96
|
+
* \}
|
|
97
|
+
*/
|
|
98
|
+
export interface ContractsCapability {
|
|
99
|
+
/** Discriminator for capability type */
|
|
100
|
+
type: 'contracts';
|
|
101
|
+
/**
|
|
102
|
+
* Which contracts this applies to:
|
|
103
|
+
* - '*': Any contract address
|
|
104
|
+
* - AztecAddress[]: Specific contract addresses
|
|
105
|
+
*/
|
|
106
|
+
contracts: '*' | AztecAddress[];
|
|
107
|
+
/**
|
|
108
|
+
* Can register contracts and update existing registrations.
|
|
109
|
+
* Maps to: registerContract
|
|
110
|
+
*
|
|
111
|
+
* When true, allows:
|
|
112
|
+
* - Registering new contract instances at specified addresses
|
|
113
|
+
* - Re-registering existing contracts with updated artifacts (e.g., after upgrade)
|
|
114
|
+
*/
|
|
115
|
+
canRegister?: boolean;
|
|
116
|
+
/** Can query contract metadata. Maps to: getContractMetadata */
|
|
117
|
+
canGetMetadata?: boolean;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Granted contract interaction capability.
|
|
121
|
+
*
|
|
122
|
+
* The wallet may reduce the scope (e.g., from '*' to specific addresses).
|
|
123
|
+
*/
|
|
124
|
+
export interface GrantedContractsCapability extends ContractsCapability {
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Contract class capability - for querying contract class metadata.
|
|
128
|
+
*
|
|
129
|
+
* Maps to wallet methods:
|
|
130
|
+
* - getContractClassMetadata
|
|
131
|
+
*
|
|
132
|
+
* Contract classes are identified by their class ID (Fr), not by contract address.
|
|
133
|
+
* Multiple contract instances can share the same class. This capability grants
|
|
134
|
+
* permission to query metadata for specific contract classes.
|
|
135
|
+
*
|
|
136
|
+
* Apps typically acquire this permission automatically when registering a contract
|
|
137
|
+
* with an artifact (the wallet auto-grants permission for that contract's class ID).
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* // Query specific contract classes
|
|
141
|
+
* \{
|
|
142
|
+
* type: 'contractClasses',
|
|
143
|
+
* classes: [classId1, classId2],
|
|
144
|
+
* canGetMetadata: true
|
|
145
|
+
* \}
|
|
146
|
+
*
|
|
147
|
+
* @example
|
|
148
|
+
* // Query any contract class (wildcard)
|
|
149
|
+
* \{
|
|
150
|
+
* type: 'contractClasses',
|
|
151
|
+
* classes: '*',
|
|
152
|
+
* canGetMetadata: true
|
|
153
|
+
* \}
|
|
154
|
+
*/
|
|
155
|
+
export interface ContractClassesCapability {
|
|
156
|
+
/** Discriminator for capability type */
|
|
157
|
+
type: 'contractClasses';
|
|
158
|
+
/**
|
|
159
|
+
* Which contract classes this applies to:
|
|
160
|
+
* - '*': Any contract class ID
|
|
161
|
+
* - Fr[]: Specific contract class IDs
|
|
162
|
+
*/
|
|
163
|
+
classes: '*' | Fr[];
|
|
164
|
+
/** Can query contract class metadata. Maps to: getContractClassMetadata */
|
|
165
|
+
canGetMetadata: boolean;
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Granted contract class capability.
|
|
169
|
+
*
|
|
170
|
+
* The wallet may reduce the scope (e.g., from '*' to specific class IDs).
|
|
171
|
+
*/
|
|
172
|
+
export interface GrantedContractClassesCapability extends ContractClassesCapability {
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Transaction simulation capability - for simulating transactions and executing utilities.
|
|
176
|
+
*
|
|
177
|
+
* Maps to wallet methods:
|
|
178
|
+
* - simulateTx (when transactions scope specified)
|
|
179
|
+
* - executeUtility (when utilities scope specified)
|
|
180
|
+
* - profileTx (when transactions scope specified)
|
|
181
|
+
*
|
|
182
|
+
* @example
|
|
183
|
+
* // Simulate any transaction on specific contracts
|
|
184
|
+
* \{
|
|
185
|
+
* type: 'simulation',
|
|
186
|
+
* transactions: \{
|
|
187
|
+
* scope: [
|
|
188
|
+
* \{ contract: ammAddress, function: '*' \},
|
|
189
|
+
* \{ contract: tokenAddress, function: 'transfer' \}
|
|
190
|
+
* ]
|
|
191
|
+
* \}
|
|
192
|
+
* \}
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* // Simulate any transaction and execute any utility call
|
|
196
|
+
* \{
|
|
197
|
+
* type: 'simulation',
|
|
198
|
+
* transactions: \{ scope: '*' \},
|
|
199
|
+
* utilities: \{ scope: '*' \}
|
|
200
|
+
* \}
|
|
201
|
+
*/
|
|
202
|
+
export interface SimulationCapability {
|
|
203
|
+
/** Discriminator for capability type */
|
|
204
|
+
type: 'simulation';
|
|
205
|
+
/** Transaction simulation scope. Maps to: simulateTx, profileTx */
|
|
206
|
+
transactions?: {
|
|
207
|
+
/**
|
|
208
|
+
* Which contracts/functions to allow:
|
|
209
|
+
* - '*': Any transaction
|
|
210
|
+
* - ContractFunctionPattern[]: Specific contract functions
|
|
211
|
+
*/
|
|
212
|
+
scope: '*' | ContractFunctionPattern[];
|
|
213
|
+
};
|
|
214
|
+
/** Utility execution scope (unconstrained calls). Maps to: executeUtility */
|
|
215
|
+
utilities?: {
|
|
216
|
+
/**
|
|
217
|
+
* Which contracts/functions to allow:
|
|
218
|
+
* - '*': Any utility call
|
|
219
|
+
* - ContractFunctionPattern[]: Specific contract functions
|
|
220
|
+
*/
|
|
221
|
+
scope: '*' | ContractFunctionPattern[];
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Granted transaction simulation capability.
|
|
226
|
+
*
|
|
227
|
+
* The wallet may reduce the scope (e.g., from '*' to specific patterns).
|
|
228
|
+
*/
|
|
229
|
+
export interface GrantedSimulationCapability extends SimulationCapability {
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Transaction execution capability - for sending transactions.
|
|
233
|
+
*
|
|
234
|
+
* Maps to wallet methods:
|
|
235
|
+
* - sendTx
|
|
236
|
+
*
|
|
237
|
+
* Policy enforcement (rate limits, spending limits) should be handled
|
|
238
|
+
* at the contract level in Aztec, not at the wallet level.
|
|
239
|
+
*
|
|
240
|
+
* @example
|
|
241
|
+
* // Send specific transactions with approval
|
|
242
|
+
* \{
|
|
243
|
+
* type: 'transaction',
|
|
244
|
+
* scope: [
|
|
245
|
+
* \{ contract: ammAddress, function: 'swap' \},
|
|
246
|
+
* \{ contract: ammAddress, function: 'addLiquidity' \}
|
|
247
|
+
* ]
|
|
248
|
+
* \}
|
|
249
|
+
*
|
|
250
|
+
* @example
|
|
251
|
+
* // Send any transaction
|
|
252
|
+
* \{
|
|
253
|
+
* type: 'transaction',
|
|
254
|
+
* scope: '*'
|
|
255
|
+
* \}
|
|
256
|
+
*/
|
|
257
|
+
export interface TransactionCapability {
|
|
258
|
+
/** Discriminator for capability type */
|
|
259
|
+
type: 'transaction';
|
|
260
|
+
/**
|
|
261
|
+
* Which contracts/functions to allow:
|
|
262
|
+
* - '*': Any transaction
|
|
263
|
+
* - ContractFunctionPattern[]: Specific patterns
|
|
264
|
+
*/
|
|
265
|
+
scope: '*' | ContractFunctionPattern[];
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Granted transaction execution capability.
|
|
269
|
+
*
|
|
270
|
+
* The wallet may reduce the scope (e.g., from '*' to specific patterns).
|
|
271
|
+
*/
|
|
272
|
+
export interface GrantedTransactionCapability extends TransactionCapability {
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Data access capability - for querying private data.
|
|
276
|
+
*
|
|
277
|
+
* Maps to wallet methods:
|
|
278
|
+
* - getAddressBook (when addressBook: true)
|
|
279
|
+
* - getPrivateEvents (when privateEvents specified)
|
|
280
|
+
*
|
|
281
|
+
* @example
|
|
282
|
+
* // Access address book and events from specific contract
|
|
283
|
+
* \{
|
|
284
|
+
* type: 'data',
|
|
285
|
+
* addressBook: true,
|
|
286
|
+
* privateEvents: \{
|
|
287
|
+
* contracts: [ammAddress],
|
|
288
|
+
* events: ['Swap', 'LiquidityAdded']
|
|
289
|
+
* \}
|
|
290
|
+
* \}
|
|
291
|
+
*
|
|
292
|
+
* @example
|
|
293
|
+
* // Access all events from any contract
|
|
294
|
+
* \{
|
|
295
|
+
* type: 'data',
|
|
296
|
+
* privateEvents: \{
|
|
297
|
+
* contracts: '*',
|
|
298
|
+
* events: '*'
|
|
299
|
+
* \}
|
|
300
|
+
* \}
|
|
301
|
+
*/
|
|
302
|
+
export interface DataCapability {
|
|
303
|
+
/** Discriminator for capability type */
|
|
304
|
+
type: 'data';
|
|
305
|
+
/** Access to address book. Maps to: getAddressBook */
|
|
306
|
+
addressBook?: boolean;
|
|
307
|
+
/** Access to private events. Maps to: getPrivateEvents */
|
|
308
|
+
privateEvents?: {
|
|
309
|
+
/**
|
|
310
|
+
* Which contracts to allow event queries from:
|
|
311
|
+
* - '*': Any contract
|
|
312
|
+
* - AztecAddress[]: Specific contracts
|
|
313
|
+
*/
|
|
314
|
+
contracts: '*' | AztecAddress[];
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
/**
|
|
318
|
+
* Granted data access capability.
|
|
319
|
+
*
|
|
320
|
+
* The wallet may reduce the scope (e.g., from '*' to specific contracts).
|
|
321
|
+
*/
|
|
322
|
+
export interface GrantedDataCapability extends DataCapability {
|
|
323
|
+
}
|
|
324
|
+
/**
|
|
325
|
+
* Union type of all capability scopes (app request).
|
|
326
|
+
*
|
|
327
|
+
* Capabilities group wallet operations by their security sensitivity
|
|
328
|
+
* and functional cohesion, making permission requests understandable
|
|
329
|
+
* to users.
|
|
330
|
+
*/
|
|
331
|
+
export type Capability = AccountsCapability | ContractsCapability | ContractClassesCapability | SimulationCapability | TransactionCapability | DataCapability;
|
|
332
|
+
/**
|
|
333
|
+
* Union type of all granted capabilities (wallet response).
|
|
334
|
+
*
|
|
335
|
+
* The wallet may augment capabilities with additional information:
|
|
336
|
+
* - AccountsCapability: adds specific accounts granted
|
|
337
|
+
* - Other capabilities: may reduce scope (e.g., '*' to specific addresses)
|
|
338
|
+
*/
|
|
339
|
+
export type GrantedCapability = GrantedAccountsCapability | GrantedContractsCapability | GrantedContractClassesCapability | GrantedSimulationCapability | GrantedTransactionCapability | GrantedDataCapability;
|
|
340
|
+
/**
|
|
341
|
+
* Application capability manifest.
|
|
342
|
+
*
|
|
343
|
+
* Sent by dApp to declare all operations it needs. This reduces authorization
|
|
344
|
+
* friction from multiple dialogs to a single comprehensive permission request.
|
|
345
|
+
*
|
|
346
|
+
* @example
|
|
347
|
+
* // DEX application manifest
|
|
348
|
+
* const manifest: AppCapabilities = \{
|
|
349
|
+
* version: CAPABILITY_VERSION,
|
|
350
|
+
* metadata: \{
|
|
351
|
+
* name: 'MyDEX',
|
|
352
|
+
* version: '1.0.0',
|
|
353
|
+
* description: 'Decentralized exchange for private token swaps',
|
|
354
|
+
* url: 'https://example.com',
|
|
355
|
+
* icon: 'https://example.com/icon.png'
|
|
356
|
+
* \},
|
|
357
|
+
* capabilities: [
|
|
358
|
+
* \{
|
|
359
|
+
* type: 'accounts',
|
|
360
|
+
* canGet: true,
|
|
361
|
+
* canCreateAuthWit: true
|
|
362
|
+
* \},
|
|
363
|
+
* \{
|
|
364
|
+
* type: 'contracts',
|
|
365
|
+
* contracts: [ammAddress, tokenAAddress, tokenBAddress],
|
|
366
|
+
* canRegister: true,
|
|
367
|
+
* canGetMetadata: true
|
|
368
|
+
* \},
|
|
369
|
+
* \{
|
|
370
|
+
* type: 'simulation',
|
|
371
|
+
* transactions: \{
|
|
372
|
+
* scope: [\{ contract: ammAddress, function: '*' \}]
|
|
373
|
+
* \}
|
|
374
|
+
* \},
|
|
375
|
+
* \{
|
|
376
|
+
* type: 'transaction',
|
|
377
|
+
* scope: [\{ contract: ammAddress, function: 'swap' \}]
|
|
378
|
+
* \}
|
|
379
|
+
* ]
|
|
380
|
+
* \};
|
|
381
|
+
*/
|
|
382
|
+
export interface AppCapabilities {
|
|
383
|
+
/**
|
|
384
|
+
* Manifest version for forward compatibility.
|
|
385
|
+
* Currently only '1.0' is supported.
|
|
386
|
+
*/
|
|
387
|
+
version: typeof CAPABILITY_VERSION;
|
|
388
|
+
/** Application metadata for display in authorization dialogs. */
|
|
389
|
+
metadata: {
|
|
390
|
+
/** Human-readable app name */
|
|
391
|
+
name: string;
|
|
392
|
+
/** App version */
|
|
393
|
+
version: string;
|
|
394
|
+
/** Optional description of what the app does */
|
|
395
|
+
description?: string;
|
|
396
|
+
/** Optional website URL */
|
|
397
|
+
url?: string;
|
|
398
|
+
/** Optional icon URL or data URI */
|
|
399
|
+
icon?: string;
|
|
400
|
+
};
|
|
401
|
+
/**
|
|
402
|
+
* Requested capabilities grouped by scope.
|
|
403
|
+
*/
|
|
404
|
+
capabilities: Capability[];
|
|
405
|
+
}
|
|
406
|
+
/**
|
|
407
|
+
* Wallet capability response.
|
|
408
|
+
*
|
|
409
|
+
* Returned by wallet after user reviews and approves/denies the capability request.
|
|
410
|
+
*
|
|
411
|
+
* The wallet can modify requested capabilities:
|
|
412
|
+
* - Reduce scope (e.g., restrict to specific contracts instead of '*')
|
|
413
|
+
* - Add information (e.g., specify which accounts are granted)
|
|
414
|
+
* - Deny capabilities (by omitting them from the `granted` array)
|
|
415
|
+
*
|
|
416
|
+
* @example
|
|
417
|
+
* // App requests
|
|
418
|
+
* const manifest: AppCapabilities = \{
|
|
419
|
+
* version: '1.0',
|
|
420
|
+
* metadata: \{ name: 'MyDApp', version: '1.0.0' \},
|
|
421
|
+
* capabilities: [
|
|
422
|
+
* \{ type: 'accounts', canGet: true \},
|
|
423
|
+
* \{ type: 'contracts', contracts: '*', canRegister: true \}
|
|
424
|
+
* ]
|
|
425
|
+
* \};
|
|
426
|
+
*
|
|
427
|
+
* // Wallet responds with specific accounts and restricted contracts
|
|
428
|
+
* const response = await wallet.requestCapabilities(manifest);
|
|
429
|
+
* console.log(response.granted);
|
|
430
|
+
* // [
|
|
431
|
+
* // \{ type: 'accounts', canGet: true, accounts: [addr1, addr2] \},
|
|
432
|
+
* // \{ type: 'contracts', contracts: [specificContract], canRegister: true \}
|
|
433
|
+
* // ]
|
|
434
|
+
*/
|
|
435
|
+
export interface WalletCapabilities {
|
|
436
|
+
/** Response version for forward compatibility. */
|
|
437
|
+
version: typeof CAPABILITY_VERSION;
|
|
438
|
+
/**
|
|
439
|
+
* Capabilities granted by the wallet.
|
|
440
|
+
* Capabilities not in this array were implicitly denied.
|
|
441
|
+
* Empty array means the user denied all capabilities.
|
|
442
|
+
*/
|
|
443
|
+
granted: GrantedCapability[];
|
|
444
|
+
/** Wallet implementation details. */
|
|
445
|
+
wallet: {
|
|
446
|
+
/** Wallet name/implementation */
|
|
447
|
+
name: string;
|
|
448
|
+
/** Wallet version */
|
|
449
|
+
version: string;
|
|
450
|
+
};
|
|
451
|
+
}
|
|
452
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2FwYWJpbGl0aWVzLmQudHMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi9zcmMvd2FsbGV0L2NhcGFiaWxpdGllcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssRUFBRSxFQUFFLEVBQUUsTUFBTSxnQ0FBZ0MsQ0FBQztBQUN6RCxPQUFPLEtBQUssRUFBRSxZQUFZLEVBQUUsTUFBTSw2QkFBNkIsQ0FBQztBQUVoRSxPQUFPLEtBQUssRUFBRSxPQUFPLEVBQUUsTUFBTSxhQUFhLENBQUM7QUFFM0M7O0dBRUc7QUFDSCxlQUFPLE1BQU0sa0JBQWtCLE9BQWlCLENBQUM7QUFFakQ7Ozs7Ozs7Ozs7Ozs7Ozs7O0dBaUJHO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