@walletmesh/aztec-rpc-wallet 0.3.0 → 0.4.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/CHANGELOG.md +26 -0
- package/README.md +290 -228
- package/dist/.tsbuildinfo +1 -1
- package/dist/client/aztec-dapp-wallet.d.ts +401 -0
- package/dist/client/aztec-dapp-wallet.d.ts.map +1 -0
- package/dist/client/aztec-dapp-wallet.js +705 -0
- package/dist/client/aztec-router-provider.d.ts +58 -0
- package/dist/client/aztec-router-provider.d.ts.map +1 -0
- package/dist/client/aztec-router-provider.js +62 -0
- package/dist/client/helpers.d.ts +44 -0
- package/dist/client/helpers.d.ts.map +1 -0
- package/dist/client/helpers.js +79 -0
- package/dist/client/register-serializers.d.ts +41 -0
- package/dist/client/register-serializers.d.ts.map +1 -0
- package/dist/client/register-serializers.js +97 -0
- package/dist/contractArtifactCache.d.ts +49 -32
- package/dist/contractArtifactCache.d.ts.map +1 -1
- package/dist/contractArtifactCache.js +47 -34
- package/dist/errors.d.ts +50 -8
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +50 -10
- package/dist/index.d.ts +53 -40
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -17
- package/dist/types.d.ts +345 -268
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +10 -8
- package/dist/wallet/create-node.d.ts +73 -0
- package/dist/wallet/create-node.d.ts.map +1 -0
- package/dist/wallet/create-node.js +99 -0
- package/dist/wallet/handlers/account.d.ts +67 -0
- package/dist/wallet/handlers/account.d.ts.map +1 -0
- package/dist/wallet/handlers/account.js +85 -0
- package/dist/wallet/handlers/contract-interaction.d.ts +77 -0
- package/dist/wallet/handlers/contract-interaction.d.ts.map +1 -0
- package/dist/wallet/handlers/contract-interaction.js +219 -0
- package/dist/wallet/handlers/contract.d.ts +96 -0
- package/dist/wallet/handlers/contract.d.ts.map +1 -0
- package/dist/wallet/handlers/contract.js +146 -0
- package/dist/wallet/handlers/event.d.ts +62 -0
- package/dist/wallet/handlers/event.d.ts.map +1 -0
- package/dist/wallet/handlers/event.js +85 -0
- package/dist/wallet/handlers/index.d.ts +88 -0
- package/dist/wallet/handlers/index.d.ts.map +1 -0
- package/dist/wallet/handlers/index.js +47 -0
- package/dist/wallet/handlers/node.d.ts +117 -0
- package/dist/wallet/handlers/node.d.ts.map +1 -0
- package/dist/wallet/handlers/node.js +196 -0
- package/dist/wallet/handlers/senders.d.ts +70 -0
- package/dist/wallet/handlers/senders.d.ts.map +1 -0
- package/dist/wallet/handlers/senders.js +92 -0
- package/dist/wallet/handlers/transaction.d.ts +123 -0
- package/dist/wallet/handlers/transaction.d.ts.map +1 -0
- package/dist/wallet/handlers/transaction.js +191 -0
- package/dist/wallet/serializers.d.ts +75 -0
- package/dist/wallet/serializers.d.ts.map +1 -0
- package/dist/wallet/serializers.js +501 -0
- package/docs/README.md +290 -229
- package/docs/classes/AztecDappWallet.md +1304 -0
- package/docs/classes/AztecRouterProvider.md +1058 -0
- package/docs/classes/AztecWalletError.md +124 -47
- package/docs/classes/ContractArtifactCache.md +48 -31
- package/docs/functions/connectAztec.md +62 -0
- package/docs/functions/createAztecWallet.md +46 -0
- package/docs/functions/createAztecWalletNode.md +96 -0
- package/docs/functions/registerAztecSerializers.md +61 -0
- package/docs/functions/registerWalletAztecSerializers.md +39 -0
- package/docs/globals.md +16 -14
- package/docs/interfaces/AztecHandlerContext.md +54 -0
- package/docs/interfaces/AztecWalletContext.md +50 -0
- package/docs/interfaces/AztecWalletMethodMap.md +471 -470
- package/docs/type-aliases/AztecChainId.md +16 -3
- package/docs/variables/ALL_AZTEC_METHODS.md +20 -0
- package/docs/variables/AztecWalletErrorMap.md +9 -4
- package/docs/variables/AztecWalletSerializer.md +45 -0
- package/package.json +9 -9
- package/src/client/aztec-dapp-wallet.test.ts +628 -0
- package/src/client/aztec-dapp-wallet.ts +879 -0
- package/src/client/aztec-router-provider.test.ts +235 -0
- package/src/client/aztec-router-provider.ts +64 -0
- package/src/client/helpers.test.ts +187 -0
- package/src/client/helpers.ts +91 -0
- package/src/client/register-serializers.ts +108 -0
- package/src/contractArtifactCache.test.ts +21 -10
- package/src/contractArtifactCache.ts +54 -35
- package/src/errors.ts +58 -10
- package/src/index.test.ts +2 -6
- package/src/index.ts +73 -37
- package/src/types.ts +379 -217
- package/src/wallet/create-node.test.ts +332 -0
- package/src/wallet/create-node.ts +120 -0
- package/src/wallet/handlers/account.test.ts +172 -0
- package/src/wallet/handlers/account.ts +99 -0
- package/src/wallet/handlers/contract-interaction.test.ts +248 -0
- package/src/wallet/handlers/contract-interaction.ts +269 -0
- package/src/wallet/handlers/contract.test.ts +245 -0
- package/src/wallet/handlers/contract.ts +174 -0
- package/src/wallet/handlers/event.test.ts +216 -0
- package/src/wallet/handlers/event.ts +99 -0
- package/src/wallet/handlers/index.ts +84 -0
- package/src/wallet/handlers/node.test.ts +304 -0
- package/src/wallet/handlers/node.ts +230 -0
- package/src/wallet/handlers/senders.test.ts +172 -0
- package/src/wallet/handlers/senders.ts +106 -0
- package/src/wallet/handlers/transaction.test.ts +371 -0
- package/src/wallet/handlers/transaction.ts +239 -0
- package/src/wallet/serializers.test.ts +253 -0
- package/src/wallet/serializers.ts +586 -0
- package/typedoc.json +23 -1
- package/dist/aztecRemoteWallet.d.ts +0 -70
- package/dist/aztecRemoteWallet.d.ts.map +0 -1
- package/dist/aztecRemoteWallet.js +0 -335
- package/dist/chainProvider.d.ts +0 -56
- package/dist/chainProvider.d.ts.map +0 -1
- package/dist/chainProvider.js +0 -98
- package/dist/handlers/aztecAccountWallet.d.ts +0 -4
- package/dist/handlers/aztecAccountWallet.d.ts.map +0 -1
- package/dist/handlers/aztecAccountWallet.js +0 -296
- package/dist/handlers/transactions.d.ts +0 -21
- package/dist/handlers/transactions.d.ts.map +0 -1
- package/dist/handlers/transactions.js +0 -98
- package/dist/handlers.d.ts +0 -27
- package/dist/handlers.d.ts.map +0 -1
- package/dist/handlers.js +0 -55
- package/dist/provider.d.ts +0 -105
- package/dist/provider.d.ts.map +0 -1
- package/dist/provider.js +0 -160
- package/dist/serializers/account.d.ts +0 -164
- package/dist/serializers/account.d.ts.map +0 -1
- package/dist/serializers/account.js +0 -244
- package/dist/serializers/contract.d.ts +0 -62
- package/dist/serializers/contract.d.ts.map +0 -1
- package/dist/serializers/contract.js +0 -130
- package/dist/serializers/index.d.ts +0 -21
- package/dist/serializers/index.d.ts.map +0 -1
- package/dist/serializers/index.js +0 -154
- package/dist/serializers/log.d.ts +0 -66
- package/dist/serializers/log.d.ts.map +0 -1
- package/dist/serializers/log.js +0 -222
- package/dist/serializers/note.d.ts +0 -124
- package/dist/serializers/note.d.ts.map +0 -1
- package/dist/serializers/note.js +0 -208
- package/dist/serializers/transaction.d.ts +0 -99
- package/dist/serializers/transaction.d.ts.map +0 -1
- package/dist/serializers/transaction.js +0 -275
- package/dist/wallet.d.ts +0 -62
- package/dist/wallet.d.ts.map +0 -1
- package/dist/wallet.js +0 -77
- package/docs/classes/AztecChainProvider.md +0 -553
- package/docs/classes/AztecChainWallet.md +0 -409
- package/docs/classes/AztecProvider.md +0 -1112
- package/docs/interfaces/AztecWalletBaseMethodMap.md +0 -135
- package/docs/interfaces/AztecWalletEventMap.md +0 -17
- package/docs/type-aliases/AztecChainWalletMiddleware.md +0 -13
- package/docs/type-aliases/AztecWalletContext.md +0 -29
- package/docs/type-aliases/AztecWalletMethodHandler.md +0 -37
- package/docs/type-aliases/AztecWalletMiddleware.md +0 -13
- package/docs/type-aliases/AztecWalletRouterClient.md +0 -13
- package/docs/type-aliases/TransactionFunctionCall.md +0 -33
- package/docs/type-aliases/TransactionParams.md +0 -27
- package/src/aztecRemoteWallet.test.ts +0 -504
- package/src/aztecRemoteWallet.ts +0 -467
- package/src/chainProvider.test.ts +0 -401
- package/src/chainProvider.ts +0 -116
- package/src/handlers/aztecAccountWallet.test.ts +0 -649
- package/src/handlers/aztecAccountWallet.ts +0 -532
- package/src/handlers/transactions.ts +0 -124
- package/src/handlers.test.ts +0 -270
- package/src/handlers.ts +0 -70
- package/src/provider.test.ts +0 -274
- package/src/provider.ts +0 -189
- package/src/serializers/account.test.ts +0 -125
- package/src/serializers/account.ts +0 -301
- package/src/serializers/contract.test.ts +0 -24
- package/src/serializers/contract.ts +0 -183
- package/src/serializers/index.test.ts +0 -136
- package/src/serializers/index.ts +0 -191
- package/src/serializers/log.test.ts +0 -286
- package/src/serializers/log.ts +0 -292
- package/src/serializers/note.test.ts +0 -125
- package/src/serializers/note.ts +0 -250
- package/src/serializers/transaction.test.ts +0 -320
- package/src/serializers/transaction.ts +0 -409
- package/src/wallet.test.ts +0 -275
- package/src/wallet.ts +0 -94
package/dist/types.d.ts.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,YAAY,EACZ,EAAE,EACF,GAAG,EACH,kBAAkB,EAClB,MAAM,EACN,SAAS,EACT,OAAO,EACP,eAAe,EACf,aAAa,EACb,EAAE,EACH,MAAM,iBAAiB,CAAC;AACzB,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC3E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAEnE;;;;;;;;;GASG;AAEH,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EACf,eAAe,EACf,kBAAkB,EAClB,uBAAuB,EACxB,MAAM,kBAAkB,CAAC;AAE1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAE1D,OAAO,KAAK,EACV,qBAAqB,EACrB,gBAAgB,EAChB,uBAAuB,EACvB,OAAO,EACR,MAAM,iCAAiC,C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AC;YACf,eAAe,EAAE,YAAY,CAAC;SAC/B,CAAC;KACH,CAAC;IAEF;;;;;OAKG;IACH,kBAAkB,EAAE;QAClB,MAAM,EAAE,CAAC,gBAAgB,EAAE,gBAAgB,CAAC,CAAC;QAC7C,MAAM,EAAE,kBAAkB,CAAC;KAC5B,CAAC;CACH"}
|
package/dist/types.js
CHANGED
@@ -1,8 +1,10 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
/**
|
2
|
+
* A constant array defining a set of base wallet methods.
|
3
|
+
* These methods might be intended for initial wallet discovery or basic connection negotiation.
|
4
|
+
* Note: Current connection helpers like `connectAztec` default to `ALL_AZTEC_METHODS`.
|
5
|
+
* The `aztec_connect` method listed here is not currently defined in {@link AztecWalletMethodMap}.
|
6
|
+
*
|
7
|
+
* @readonly
|
8
|
+
*/
|
9
|
+
export const BASE_WALLET_METHODS = ['wm_getSupportedMethods', 'aztec_connect', 'aztec_getAddress'];
|
10
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi9zcmMvdHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBMEZBOzs7Ozs7O0dBT0c7QUFDSCxNQUFNLENBQUMsTUFBTSxtQkFBbUIsR0FBRyxDQUFDLHdCQUF3QixFQUFFLGVBQWUsRUFBRSxrQkFBa0IsQ0FBVSxDQUFDIn0=
|
@@ -0,0 +1,73 @@
|
|
1
|
+
/**
|
2
|
+
* @module aztec-rpc-wallet/wallet/create-node
|
3
|
+
*
|
4
|
+
* Factory module for creating Aztec wallet nodes that integrate with the WalletRouter system.
|
5
|
+
* This module provides the wallet-side implementation for handling Aztec JSON-RPC requests.
|
6
|
+
*/
|
7
|
+
import type { AccountWallet, PXE } from '@aztec/aztec.js';
|
8
|
+
import { JSONRPCNode, type JSONRPCTransport, type JSONRPCEventMap } from '@walletmesh/jsonrpc';
|
9
|
+
import type { AztecWalletMethodMap } from '../types.js';
|
10
|
+
import { type AztecHandlerContext } from './handlers/index.js';
|
11
|
+
/**
|
12
|
+
* Creates and configures a {@link JSONRPCNode} to serve as an Aztec wallet endpoint.
|
13
|
+
* This node is intended to be used on the wallet-side (e.g., in a browser extension
|
14
|
+
* or a backend service managing user accounts) and can be connected to a
|
15
|
+
* {@link WalletRouter} instance.
|
16
|
+
*
|
17
|
+
* The created node is equipped with:
|
18
|
+
* - Handlers for all Aztec RPC methods defined in {@link AztecWalletMethodMap}.
|
19
|
+
* - Serializers for Aztec-specific data types, ensuring correct data exchange
|
20
|
+
* over JSON-RPC.
|
21
|
+
* - A context ({@link AztecHandlerContext}) providing handlers with access to the
|
22
|
+
* necessary {@link AccountWallet}, {@link PXE} client, and a {@link ContractArtifactCache}.
|
23
|
+
*
|
24
|
+
* @param wallet - An instance of {@link AccountWallet} from `aztec.js`, representing
|
25
|
+
* the user's Aztec account and signing capabilities.
|
26
|
+
* @param pxe - An instance of {@link PXE} (Private Execution Environment) client from
|
27
|
+
* `aztec.js`, used for interacting with the Aztec network (e.g., simulating
|
28
|
+
* transactions, getting node info).
|
29
|
+
* @param transport - A {@link JSONRPCTransport} instance that the node will use for
|
30
|
+
* sending and receiving JSON-RPC messages. This transport typically
|
31
|
+
* connects to a corresponding transport on the client/dApp side,
|
32
|
+
* often via the {@link WalletRouter}.
|
33
|
+
* @returns A fully configured {@link JSONRPCNode} instance, typed with
|
34
|
+
* {@link AztecWalletMethodMap} and {@link AztecHandlerContext}, ready to
|
35
|
+
* process Aztec wallet requests.
|
36
|
+
*
|
37
|
+
* @example
|
38
|
+
* ```typescript
|
39
|
+
* import { createAztecWalletNode } from '@walletmesh/aztec-rpc-wallet';
|
40
|
+
* import { WalletRouter, createLocalTransportPair } from '@walletmesh/router';
|
41
|
+
* import { MyAccountWallet, MyPXE, MyRouterTransport, MyPermissionManager } from './my-setup'; // User's setup
|
42
|
+
*
|
43
|
+
* // 1. Initialize Aztec AccountWallet and PXE
|
44
|
+
* const accountWallet = new MyAccountWallet();
|
45
|
+
* const pxe = new MyPXE();
|
46
|
+
*
|
47
|
+
* // 2. Create a local transport pair for communication between router and wallet node
|
48
|
+
* const [routerSideTransport, walletNodeSideTransport] = createLocalTransportPair();
|
49
|
+
*
|
50
|
+
* // 3. Create the Aztec Wallet Node
|
51
|
+
* const aztecNode = createAztecWalletNode(accountWallet, pxe, walletNodeSideTransport);
|
52
|
+
* // aztecNode will start listening for requests on walletNodeSideTransport
|
53
|
+
*
|
54
|
+
* // 4. Create and configure the WalletRouter
|
55
|
+
* const routerTransport = new MyRouterTransport(); // Transport for dApp to router communication
|
56
|
+
* const permissionManager = new MyPermissionManager();
|
57
|
+
* const router = new WalletRouter(
|
58
|
+
* routerTransport,
|
59
|
+
* new Map([['aztec:testnet', routerSideTransport]]), // Route 'aztec:testnet' to our node
|
60
|
+
* permissionManager
|
61
|
+
* );
|
62
|
+
*
|
63
|
+
* // The system is now set up. DApps can connect to 'routerTransport'
|
64
|
+
* // and send requests to 'aztec:testnet', which will be handled by 'aztecNode'.
|
65
|
+
* ```
|
66
|
+
* @see {@link JSONRPCNode}
|
67
|
+
* @see {@link AztecWalletMethodMap}
|
68
|
+
* @see {@link AztecHandlerContext}
|
69
|
+
* @see {@link createAztecHandlers}
|
70
|
+
* @see {@link registerAztecSerializers} (wallet-side version)
|
71
|
+
*/
|
72
|
+
export declare function createAztecWalletNode(wallet: AccountWallet, pxe: PXE, transport: JSONRPCTransport): JSONRPCNode<AztecWalletMethodMap, JSONRPCEventMap, AztecHandlerContext>;
|
73
|
+
//# sourceMappingURL=create-node.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"create-node.d.ts","sourceRoot":"","sources":["../../src/wallet/create-node.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,WAAW,EAAE,KAAK,gBAAgB,EAAE,KAAK,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAE/F,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAExD,OAAO,EAAuB,KAAK,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAGpF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,aAAa,EACrB,GAAG,EAAE,GAAG,EACR,SAAS,EAAE,gBAAgB,GAC1B,WAAW,CAAC,oBAAoB,EAAE,eAAe,EAAE,mBAAmB,CAAC,CAuCzE"}
|
@@ -0,0 +1,99 @@
|
|
1
|
+
/**
|
2
|
+
* @module aztec-rpc-wallet/wallet/create-node
|
3
|
+
*
|
4
|
+
* Factory module for creating Aztec wallet nodes that integrate with the WalletRouter system.
|
5
|
+
* This module provides the wallet-side implementation for handling Aztec JSON-RPC requests.
|
6
|
+
*/
|
7
|
+
import { JSONRPCNode } from '@walletmesh/jsonrpc';
|
8
|
+
import { ContractArtifactCache } from '../contractArtifactCache.js';
|
9
|
+
import { createAztecHandlers } from './handlers/index.js';
|
10
|
+
import { registerAztecSerializers } from './serializers.js';
|
11
|
+
/**
|
12
|
+
* Creates and configures a {@link JSONRPCNode} to serve as an Aztec wallet endpoint.
|
13
|
+
* This node is intended to be used on the wallet-side (e.g., in a browser extension
|
14
|
+
* or a backend service managing user accounts) and can be connected to a
|
15
|
+
* {@link WalletRouter} instance.
|
16
|
+
*
|
17
|
+
* The created node is equipped with:
|
18
|
+
* - Handlers for all Aztec RPC methods defined in {@link AztecWalletMethodMap}.
|
19
|
+
* - Serializers for Aztec-specific data types, ensuring correct data exchange
|
20
|
+
* over JSON-RPC.
|
21
|
+
* - A context ({@link AztecHandlerContext}) providing handlers with access to the
|
22
|
+
* necessary {@link AccountWallet}, {@link PXE} client, and a {@link ContractArtifactCache}.
|
23
|
+
*
|
24
|
+
* @param wallet - An instance of {@link AccountWallet} from `aztec.js`, representing
|
25
|
+
* the user's Aztec account and signing capabilities.
|
26
|
+
* @param pxe - An instance of {@link PXE} (Private Execution Environment) client from
|
27
|
+
* `aztec.js`, used for interacting with the Aztec network (e.g., simulating
|
28
|
+
* transactions, getting node info).
|
29
|
+
* @param transport - A {@link JSONRPCTransport} instance that the node will use for
|
30
|
+
* sending and receiving JSON-RPC messages. This transport typically
|
31
|
+
* connects to a corresponding transport on the client/dApp side,
|
32
|
+
* often via the {@link WalletRouter}.
|
33
|
+
* @returns A fully configured {@link JSONRPCNode} instance, typed with
|
34
|
+
* {@link AztecWalletMethodMap} and {@link AztecHandlerContext}, ready to
|
35
|
+
* process Aztec wallet requests.
|
36
|
+
*
|
37
|
+
* @example
|
38
|
+
* ```typescript
|
39
|
+
* import { createAztecWalletNode } from '@walletmesh/aztec-rpc-wallet';
|
40
|
+
* import { WalletRouter, createLocalTransportPair } from '@walletmesh/router';
|
41
|
+
* import { MyAccountWallet, MyPXE, MyRouterTransport, MyPermissionManager } from './my-setup'; // User's setup
|
42
|
+
*
|
43
|
+
* // 1. Initialize Aztec AccountWallet and PXE
|
44
|
+
* const accountWallet = new MyAccountWallet();
|
45
|
+
* const pxe = new MyPXE();
|
46
|
+
*
|
47
|
+
* // 2. Create a local transport pair for communication between router and wallet node
|
48
|
+
* const [routerSideTransport, walletNodeSideTransport] = createLocalTransportPair();
|
49
|
+
*
|
50
|
+
* // 3. Create the Aztec Wallet Node
|
51
|
+
* const aztecNode = createAztecWalletNode(accountWallet, pxe, walletNodeSideTransport);
|
52
|
+
* // aztecNode will start listening for requests on walletNodeSideTransport
|
53
|
+
*
|
54
|
+
* // 4. Create and configure the WalletRouter
|
55
|
+
* const routerTransport = new MyRouterTransport(); // Transport for dApp to router communication
|
56
|
+
* const permissionManager = new MyPermissionManager();
|
57
|
+
* const router = new WalletRouter(
|
58
|
+
* routerTransport,
|
59
|
+
* new Map([['aztec:testnet', routerSideTransport]]), // Route 'aztec:testnet' to our node
|
60
|
+
* permissionManager
|
61
|
+
* );
|
62
|
+
*
|
63
|
+
* // The system is now set up. DApps can connect to 'routerTransport'
|
64
|
+
* // and send requests to 'aztec:testnet', which will be handled by 'aztecNode'.
|
65
|
+
* ```
|
66
|
+
* @see {@link JSONRPCNode}
|
67
|
+
* @see {@link AztecWalletMethodMap}
|
68
|
+
* @see {@link AztecHandlerContext}
|
69
|
+
* @see {@link createAztecHandlers}
|
70
|
+
* @see {@link registerAztecSerializers} (wallet-side version)
|
71
|
+
*/
|
72
|
+
export function createAztecWalletNode(wallet, pxe, transport) {
|
73
|
+
// Initialize the contract artifact cache for this wallet
|
74
|
+
const cache = new ContractArtifactCache(wallet);
|
75
|
+
// Create the handler context that will be passed to all method handlers
|
76
|
+
// This context provides access to the wallet, PXE, and cache instances
|
77
|
+
const context = { wallet, pxe, cache };
|
78
|
+
// Create the JSON-RPC node with typed method map and handler context
|
79
|
+
const node = new JSONRPCNode(transport, context);
|
80
|
+
// Register all Aztec method handlers
|
81
|
+
// The createAztecHandlers function returns a map of all available Aztec methods
|
82
|
+
const handlers = createAztecHandlers();
|
83
|
+
for (const [methodStr, handlerFunc] of Object.entries(handlers)) {
|
84
|
+
const typedMethodKey = methodStr;
|
85
|
+
// Cast the handler to the specific type expected by registerMethod
|
86
|
+
// This relies on createAztecHandlers() providing correctly typed handlers
|
87
|
+
// for each method string.
|
88
|
+
// methodStr is already a string, which is expected by the first param of registerMethod.
|
89
|
+
// typedMethodKey is used for strong typing of params and result.
|
90
|
+
node.registerMethod(methodStr, // Use the string key here
|
91
|
+
handlerFunc);
|
92
|
+
}
|
93
|
+
// Register serializers for all Aztec types
|
94
|
+
// This enables proper serialization/deserialization of Aztec objects over JSON-RPC
|
95
|
+
registerAztecSerializers(node);
|
96
|
+
// Return the configured node
|
97
|
+
return node;
|
98
|
+
}
|
99
|
+
//# s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yxTQUFTLEVBQUUsV0FBVyxDQUFDLElBQUksTUFBTSxDQUFDLE9BQU8sQ0FBQyxRQUFRLENBQUMsRUFBRSxDQUFDO1FBQ2hFLE1BQU0sY0FBYyxHQUFHLFNBQXVDLENBQUM7UUFDL0QsbUVBQW1FO1FBQ25FLDBFQUEwRTtRQUMxRSwwQkFBMEI7UUFDMUIseUZBQXlGO1FBQ3pGLGlFQUFpRTtRQUNqRSxJQUFJLENBQUMsY0FBYyxDQUNqQixTQUFTLEVBQUUsMEJBQTBCO1FBQ3JDLFdBR21FLENBQ3BFLENBQUM7SUFDSixDQUFDO0lBRUQsMkNBQTJDO0lBQzNDLG1GQUFtRjtJQUNuRix3QkFBd0IsQ0FBQyxJQUFJLENBQUMsQ0FBQztJQUUvQiw2QkFBNkI7SUFDN0IsT0FBTyxJQUFJLENBQUM7QUFDZCxDQUFDIn0=
|
@@ -0,0 +1,67 @@
|
|
1
|
+
import type { AztecHandlerContext } from './index.js';
|
2
|
+
import type { AztecWalletMethodMap } from '../../types.js';
|
3
|
+
/**
|
4
|
+
* Creates handlers for account-related Aztec wallet JSON-RPC methods.
|
5
|
+
* These handlers are responsible for managing wallet identity, retrieving addresses,
|
6
|
+
* and creating authorization witnesses.
|
7
|
+
*
|
8
|
+
* Each handler function receives an {@link AztecHandlerContext} which provides access
|
9
|
+
* to the core {@link AccountWallet} instance, the {@link PXE} client, and a
|
10
|
+
* {@link ContractArtifactCache}.
|
11
|
+
*
|
12
|
+
* @returns An object where keys are account-related method names
|
13
|
+
* (e.g., "aztec_getAddress", "aztec_createAuthWit") and values are their
|
14
|
+
* corresponding handler functions.
|
15
|
+
* @see {@link AztecWalletMethodMap} for method definitions.
|
16
|
+
*/
|
17
|
+
export declare function createAccountHandlers(): {
|
18
|
+
/**
|
19
|
+
* Handles the "aztec_getAddress" JSON-RPC method.
|
20
|
+
* Retrieves the primary {@link AztecAddress} of the account associated with the
|
21
|
+
* {@link AccountWallet} in the current context.
|
22
|
+
*
|
23
|
+
* @param ctx - The {@link AztecHandlerContext} containing the `wallet` instance.
|
24
|
+
* @param _paramsTuple - Parameters for this method (expected to be an empty array).
|
25
|
+
* Defined by {@link AztecWalletMethodMap.aztec_getAddress.params}.
|
26
|
+
* @returns A promise that resolves to the {@link AztecAddress} of the wallet.
|
27
|
+
* Type defined by {@link AztecWalletMethodMap.aztec_getAddress.result}.
|
28
|
+
*/
|
29
|
+
aztec_getAddress: (ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["aztec_getAddress"]["params"]) => Promise<AztecWalletMethodMap["aztec_getAddress"]["result"]>;
|
30
|
+
/**
|
31
|
+
* Handles the "aztec_getCompleteAddress" JSON-RPC method.
|
32
|
+
* Retrieves the {@link CompleteAddress} (which includes public keys and partial address)
|
33
|
+
* of the account associated with the {@link AccountWallet} in the current context.
|
34
|
+
*
|
35
|
+
* The complete address typically contains:
|
36
|
+
* - The {@link AztecAddress}
|
37
|
+
* - Public keys (e.g., nullifier key, incoming viewing key)
|
38
|
+
* - Partial address
|
39
|
+
*
|
40
|
+
* @param ctx - The {@link AztecHandlerContext} containing the `wallet` instance.
|
41
|
+
* @param _paramsTuple - Parameters for this method (expected to be an empty array).
|
42
|
+
* Defined by {@link AztecWalletMethodMap.aztec_getCompleteAddress.params}.
|
43
|
+
* @returns A promise that resolves to the {@link CompleteAddress} of the wallet.
|
44
|
+
* Type defined by {@link AztecWalletMethodMap.aztec_getCompleteAddress.result}.
|
45
|
+
*/
|
46
|
+
aztec_getCompleteAddress: (ctx: AztecHandlerContext, _paramsTuple: AztecWalletMethodMap["aztec_getCompleteAddress"]["params"]) => Promise<AztecWalletMethodMap["aztec_getCompleteAddress"]["result"]>;
|
47
|
+
/**
|
48
|
+
* Handles the "aztec_createAuthWit" JSON-RPC method.
|
49
|
+
* Creates an {@link AuthWitness} for a given message hash or intent, using the
|
50
|
+
* {@link AccountWallet} in the current context.
|
51
|
+
*
|
52
|
+
* Authorization witnesses are used to delegate actions, allowing a contract or another
|
53
|
+
* entity to perform operations on behalf of the wallet owner (e.g., for token approvals).
|
54
|
+
*
|
55
|
+
* @param ctx - The {@link AztecHandlerContext} containing the `wallet` instance.
|
56
|
+
* @param paramsTuple - A tuple containing the intent to authorize.
|
57
|
+
* Defined by {@link AztecWalletMethodMap.aztec_createAuthWit.params}.
|
58
|
+
* @param paramsTuple.0 - The intent to authorize, which can be a message hash ({@link Fr} or `Buffer`),
|
59
|
+
* an {@link IntentInnerHash}, or an {@link IntentAction}.
|
60
|
+
* @returns A promise that resolves to the created {@link AuthWitness}.
|
61
|
+
* Type defined by {@link AztecWalletMethodMap.aztec_createAuthWit.result}.
|
62
|
+
* @throws {Error} If the `intent` parameter is missing or invalid, though type checking
|
63
|
+
* and serializer validation should ideally catch this earlier.
|
64
|
+
*/
|
65
|
+
aztec_createAuthWit: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_createAuthWit"]["params"]) => Promise<AztecWalletMethodMap["aztec_createAuthWit"]["result"]>;
|
66
|
+
};
|
67
|
+
//# sourceMappingURL=account.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"account.d.ts","sourceRoot":"","sources":["../../../src/wallet/handlers/account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAK3D;;;;;;;;;;;;;GAaG;AACH,wBAAgB,qBAAqB;IAEjC;;;;;;;;;;OAUG;4BAEI,mBAAmB,gBACV,oBAAoB,CAAC,kBAAkB,CAAC,CAAC,QAAQ,CAAC,KAC/D,OAAO,CAAC,oBAAoB,CAAC,kBAAkB,CAAC,CAAC,QAAQ,CAAC,CAAC;IAK9D;;;;;;;;;;;;;;;OAeG;oCAEI,mBAAmB,gBACV,oBAAoB,CAAC,0BAA0B,CAAC,CAAC,QAAQ,CAAC,KACvE,OAAO,CAAC,oBAAoB,CAAC,0BAA0B,CAAC,CAAC,QAAQ,CAAC,CAAC;IAKtE;;;;;;;;;;;;;;;;;OAiBG;+BAEI,mBAAmB,eACX,oBAAoB,CAAC,qBAAqB,CAAC,CAAC,QAAQ,CAAC,KACjE,OAAO,CAAC,oBAAoB,CAAC,qBAAqB,CAAC,CAAC,QAAQ,CAAC,CAAC;EAYpE"}
|
@@ -0,0 +1,85 @@
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
2
|
+
const logger = createLogger('aztec-rpc-wallet:account');
|
3
|
+
/**
|
4
|
+
* Creates handlers for account-related Aztec wallet JSON-RPC methods.
|
5
|
+
* These handlers are responsible for managing wallet identity, retrieving addresses,
|
6
|
+
* and creating authorization witnesses.
|
7
|
+
*
|
8
|
+
* Each handler function receives an {@link AztecHandlerContext} which provides access
|
9
|
+
* to the core {@link AccountWallet} instance, the {@link PXE} client, and a
|
10
|
+
* {@link ContractArtifactCache}.
|
11
|
+
*
|
12
|
+
* @returns An object where keys are account-related method names
|
13
|
+
* (e.g., "aztec_getAddress", "aztec_createAuthWit") and values are their
|
14
|
+
* corresponding handler functions.
|
15
|
+
* @see {@link AztecWalletMethodMap} for method definitions.
|
16
|
+
*/
|
17
|
+
export function createAccountHandlers() {
|
18
|
+
return {
|
19
|
+
/**
|
20
|
+
* Handles the "aztec_getAddress" JSON-RPC method.
|
21
|
+
* Retrieves the primary {@link AztecAddress} of the account associated with the
|
22
|
+
* {@link AccountWallet} in the current context.
|
23
|
+
*
|
24
|
+
* @param ctx - The {@link AztecHandlerContext} containing the `wallet` instance.
|
25
|
+
* @param _paramsTuple - Parameters for this method (expected to be an empty array).
|
26
|
+
* Defined by {@link AztecWalletMethodMap.aztec_getAddress.params}.
|
27
|
+
* @returns A promise that resolves to the {@link AztecAddress} of the wallet.
|
28
|
+
* Type defined by {@link AztecWalletMethodMap.aztec_getAddress.result}.
|
29
|
+
*/
|
30
|
+
aztec_getAddress: async (ctx, _paramsTuple) => {
|
31
|
+
logger.debug('[HANDLER] aztec_getAddress');
|
32
|
+
return ctx.wallet.getAddress();
|
33
|
+
},
|
34
|
+
/**
|
35
|
+
* Handles the "aztec_getCompleteAddress" JSON-RPC method.
|
36
|
+
* Retrieves the {@link CompleteAddress} (which includes public keys and partial address)
|
37
|
+
* of the account associated with the {@link AccountWallet} in the current context.
|
38
|
+
*
|
39
|
+
* The complete address typically contains:
|
40
|
+
* - The {@link AztecAddress}
|
41
|
+
* - Public keys (e.g., nullifier key, incoming viewing key)
|
42
|
+
* - Partial address
|
43
|
+
*
|
44
|
+
* @param ctx - The {@link AztecHandlerContext} containing the `wallet` instance.
|
45
|
+
* @param _paramsTuple - Parameters for this method (expected to be an empty array).
|
46
|
+
* Defined by {@link AztecWalletMethodMap.aztec_getCompleteAddress.params}.
|
47
|
+
* @returns A promise that resolves to the {@link CompleteAddress} of the wallet.
|
48
|
+
* Type defined by {@link AztecWalletMethodMap.aztec_getCompleteAddress.result}.
|
49
|
+
*/
|
50
|
+
aztec_getCompleteAddress: async (ctx, _paramsTuple) => {
|
51
|
+
logger.debug('[HANDLER] aztec_getCompleteAddress');
|
52
|
+
return ctx.wallet.getCompleteAddress();
|
53
|
+
},
|
54
|
+
/**
|
55
|
+
* Handles the "aztec_createAuthWit" JSON-RPC method.
|
56
|
+
* Creates an {@link AuthWitness} for a given message hash or intent, using the
|
57
|
+
* {@link AccountWallet} in the current context.
|
58
|
+
*
|
59
|
+
* Authorization witnesses are used to delegate actions, allowing a contract or another
|
60
|
+
* entity to perform operations on behalf of the wallet owner (e.g., for token approvals).
|
61
|
+
*
|
62
|
+
* @param ctx - The {@link AztecHandlerContext} containing the `wallet` instance.
|
63
|
+
* @param paramsTuple - A tuple containing the intent to authorize.
|
64
|
+
* Defined by {@link AztecWalletMethodMap.aztec_createAuthWit.params}.
|
65
|
+
* @param paramsTuple.0 - The intent to authorize, which can be a message hash ({@link Fr} or `Buffer`),
|
66
|
+
* an {@link IntentInnerHash}, or an {@link IntentAction}.
|
67
|
+
* @returns A promise that resolves to the created {@link AuthWitness}.
|
68
|
+
* Type defined by {@link AztecWalletMethodMap.aztec_createAuthWit.result}.
|
69
|
+
* @throws {Error} If the `intent` parameter is missing or invalid, though type checking
|
70
|
+
* and serializer validation should ideally catch this earlier.
|
71
|
+
*/
|
72
|
+
aztec_createAuthWit: async (ctx, paramsTuple) => {
|
73
|
+
const [intent] = paramsTuple;
|
74
|
+
logger.debug(`[HANDLER] aztec_createAuthWit: intent type = ${typeof intent}`);
|
75
|
+
// Intent is not optional in the tuple type.
|
76
|
+
// Add runtime check for robustness if needed.
|
77
|
+
if (intent === undefined) {
|
78
|
+
// Basic check, though TS should prevent this if tuple type is correct
|
79
|
+
throw new Error('Invalid intent parameter received in tuple');
|
80
|
+
}
|
81
|
+
return await ctx.wallet.createAuthWit(intent);
|
82
|
+
},
|
83
|
+
};
|
84
|
+
}
|
85
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiYWNjb3VudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uL3NyYy93YWxsZXQvaGFuZGxlcnMvYWNjb3VudC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFFQSxPQUFPLEVBQUUsWUFBWSxFQUFFLE1BQU0sdUJBQXVCLENBQUM7QUFFckQsTUFBTSxNQUFNLEdBQUcsWUFBWSxDQUFDLDBCQUEwQixDQUFDLENBQUM7QUFFeEQ7Ozs7Ozs7Ozs7Ozs7R0FhRztBQUNILE1BQU0sVUFBVSxxQkFBcUI7SUFDbkMsT0FBTztRQUNMOzs7Ozs7Ozs7O1dBVUc7UUFDSCxnQkFBZ0IsRUFBRSxLQUFLLEVBQ3JCLEdBQXdCLEVBQ3hCLFlBQWdFLEVBQ0gsRUFBRTtZQUMvRCxNQUFNLENBQUMsS0FBSyxDQUFDLDRCQUE0QixDQUFDLENBQUM7WUFDM0MsT0FBTyxHQUFHLENBQUMsTUFBTSxDQUFDLFVBQVUsRUFBRSxDQUFDO1FBQ2pDLENBQUM7UUFFRDs7Ozs7Ozs7Ozs7Ozs7O1dBZUc7UUFDSCx3QkFBd0IsRUFBRSxLQUFLLEVBQzdCLEdBQXdCLEVBQ3hCLFlBQXdFLEVBQ0gsRUFBRTtZQUN2RSxNQUFNLENBQUMsS0FBSyxDQUFDLG9DQUFvQyxDQUFDLENBQUM7WUFDbkQsT0FBTyxHQUFHLENBQUMsTUFBTSxDQUFDLGtCQUFrQixFQUFFLENBQUM7UUFDekMsQ0FBQztRQUVEOzs7Ozs7Ozs7Ozs7Ozs7OztXQWlCRztRQUNILG1CQUFtQixFQUFFLEtBQUssRUFDeEIsR0FBd0IsRUFDeEIsV0FBa0UsRUFDRixFQUFFO1lBQ2xFLE1BQU0sQ0FBQyxNQUFNLENBQUMsR0FBRyxXQUFXLENBQUM7WUFDN0IsTUFBTSxDQUFDLEtBQUssQ0FBQyxnREFBZ0QsT0FBTyxNQUFNLEVBQUUsQ0FBQyxDQUFDO1lBQzlFLDRDQUE0QztZQUM1Qyw4Q0FBOEM7WUFDOUMsSUFBSSxNQUFNLEtBQUssU0FBUyxFQUFFLENBQUM7Z0JBQ3pCLHNFQUFzRTtnQkFDdEUsTUFBTSxJQUFJLEtBQUssQ0FBQyw0Q0FBNEMsQ0FBQyxDQUFDO1lBQ2hFLENBQUM7WUFDRCxPQUFPLE1BQU0sR0FBRyxDQUFDLE1BQU0sQ0FBQyxhQUFhLENBQUMsTUFBTSxDQUFDLENBQUM7UUFDaEQsQ0FBQztLQUNGLENBQUM7QUFDSixDQUFDIn0=
|
@@ -0,0 +1,77 @@
|
|
1
|
+
import type { AztecHandlerContext } from './index.js';
|
2
|
+
import type { AztecWalletMethodMap } from '../../types.js';
|
3
|
+
/**
|
4
|
+
* @module @walletmesh/aztec-rpc-wallet/wallet/handlers/contract-interaction
|
5
|
+
* This module provides handlers for WalletMesh-specific high-level contract
|
6
|
+
* interaction and deployment methods (e.g., `aztec_wmExecuteTx`, `aztec_wmDeployContract`).
|
7
|
+
* These methods simplify common contract operations for dApp developers by accepting
|
8
|
+
* an {@link ExecutionPayload} or deployment parameters, with the wallet-side
|
9
|
+
* handling more of the transaction construction, simulation, proving, and sending flow.
|
10
|
+
*/
|
11
|
+
/**
|
12
|
+
* Creates handlers for WalletMesh-specific contract interaction and deployment JSON-RPC methods.
|
13
|
+
*
|
14
|
+
* These handlers manage high-level contract operations such as:
|
15
|
+
* - `aztec_wmExecuteTx`: Executing a pre-constructed {@link ExecutionPayload}.
|
16
|
+
* - `aztec_wmSimulateTx`: Simulating an {@link ExecutionPayload}.
|
17
|
+
* - `aztec_wmDeployContract`: Deploying a new contract from its artifact and arguments.
|
18
|
+
*
|
19
|
+
* The primary goal of these "wm" (WalletMesh) methods is to simplify the dApp's
|
20
|
+
* interaction with the wallet by abstracting parts of the standard Aztec transaction
|
21
|
+
* lifecycle (e.g., fee estimation, `createTxExecutionRequest`, `proveTx`, `sendTx`).
|
22
|
+
* The wallet takes on more responsibility, which can lead to a better user experience
|
23
|
+
* as the wallet can provide more context or apply its own policies.
|
24
|
+
*
|
25
|
+
* @returns An object where keys are "wm" prefixed method names and values are their
|
26
|
+
* corresponding handler functions.
|
27
|
+
* @see {@link AztecWalletMethodMap} for method definitions.
|
28
|
+
*/
|
29
|
+
export declare function createContractInteractionHandlers(): {
|
30
|
+
/**
|
31
|
+
* Handles the "aztec_wmExecuteTx" JSON-RPC method.
|
32
|
+
* This WalletMesh-specific method takes an {@link ExecutionPayload} and handles
|
33
|
+
* the full lifecycle of simulating, proving, and sending the transaction.
|
34
|
+
*
|
35
|
+
* @param ctx - The {@link AztecHandlerContext}.
|
36
|
+
* @param paramsTuple - A tuple containing the {@link ExecutionPayload}.
|
37
|
+
* Defined by {@link AztecWalletMethodMap.aztec_wmExecuteTx.params}.
|
38
|
+
* @param paramsTuple.0 - The {@link ExecutionPayload} to execute.
|
39
|
+
* @returns A promise that resolves to the {@link TxHash} of the sent transaction.
|
40
|
+
* Type defined by {@link AztecWalletMethodMap.aztec_wmExecuteTx.result}.
|
41
|
+
*/
|
42
|
+
aztec_wmExecuteTx: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_wmExecuteTx"]["params"]) => Promise<AztecWalletMethodMap["aztec_wmExecuteTx"]["result"]>;
|
43
|
+
/**
|
44
|
+
* Handles the "aztec_wmSimulateTx" JSON-RPC method.
|
45
|
+
* This WalletMesh-specific method takes an {@link ExecutionPayload} and simulates
|
46
|
+
* the transaction, returning the {@link TxSimulationResult}.
|
47
|
+
*
|
48
|
+
* @param ctx - The {@link AztecHandlerContext}.
|
49
|
+
* @param paramsTuple - A tuple containing the {@link ExecutionPayload}.
|
50
|
+
* Defined by {@link AztecWalletMethodMap.aztec_wmSimulateTx.params}.
|
51
|
+
* @param paramsTuple.0 - The {@link ExecutionPayload} to simulate.
|
52
|
+
* @returns A promise that resolves to the {@link TxSimulationResult}.
|
53
|
+
* Type defined by {@link AztecWalletMethodMap.aztec_wmSimulateTx.result}.
|
54
|
+
*/
|
55
|
+
aztec_wmSimulateTx: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_wmSimulateTx"]["params"]) => Promise<AztecWalletMethodMap["aztec_wmSimulateTx"]["result"]>;
|
56
|
+
/**
|
57
|
+
* Handles the "aztec_wmDeployContract" JSON-RPC method.
|
58
|
+
* This WalletMesh-specific method deploys a new contract using its {@link ContractArtifact}
|
59
|
+
* and constructor arguments. It manages the deployment transaction lifecycle, including
|
60
|
+
* computing the contract address, proving, and sending the deployment transaction.
|
61
|
+
*
|
62
|
+
* Fee configuration is determined internally by the `getFeeOptions` helper.
|
63
|
+
*
|
64
|
+
* @param ctx - The {@link AztecHandlerContext}.
|
65
|
+
* @param paramsTuple - A tuple containing the deployment parameters (artifact, args, constructorName).
|
66
|
+
* Defined by {@link AztecWalletMethodMap.aztec_wmDeployContract.params}.
|
67
|
+
* @param paramsTuple.0.artifact - The {@link ContractArtifact} of the contract to deploy.
|
68
|
+
* @param paramsTuple.0.args - An array of arguments for the contract's constructor.
|
69
|
+
* @param paramsTuple.0.constructorName - Optional name of the constructor function if the artifact has multiple.
|
70
|
+
* @returns A promise that resolves to an object containing the `txHash` ({@link TxHash})
|
71
|
+
* of the deployment transaction and the `contractAddress` ({@link AztecAddress})
|
72
|
+
* of the newly deployed contract.
|
73
|
+
* Type defined by {@link AztecWalletMethodMap.aztec_wmDeployContract.result}.
|
74
|
+
*/
|
75
|
+
aztec_wmDeployContract: (ctx: AztecHandlerContext, paramsTuple: AztecWalletMethodMap["aztec_wmDeployContract"]["params"]) => Promise<AztecWalletMethodMap["aztec_wmDeployContract"]["result"]>;
|
76
|
+
};
|
77
|
+
//# sourceMappingURL=contract-interaction.d.ts.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"contract-interaction.d.ts","sourceRoot":"","sources":["../../../src/wallet/handlers/contract-interaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAU3D;;;;;;;GAOG;AAEH;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,iCAAiC;IA6H7C;;;;;;;;;;;OAWG;6BAEI,mBAAmB,eACX,oBAAoB,CAAC,mBAAmB,CAAC,CAAC,QAAQ,CAAC,KAC/D,OAAO,CAAC,oBAAoB,CAAC,mBAAmB,CAAC,CAAC,QAAQ,CAAC,CAAC;IAK/D;;;;;;;;;;;OAWG;8BAEI,mBAAmB,eACX,oBAAoB,CAAC,oBAAoB,CAAC,CAAC,QAAQ,CAAC,KAChE,OAAO,CAAC,oBAAoB,CAAC,oBAAoB,CAAC,CAAC,QAAQ,CAAC,CAAC;IAKhE;;;;;;;;;;;;;;;;;;OAkBG;kCAEI,mBAAmB,eACX,oBAAoB,CAAC,wBAAwB,CAAC,CAAC,QAAQ,CAAC,KACpE,OAAO,CAAC,oBAAoB,CAAC,wBAAwB,CAAC,CAAC,QAAQ,CAAC,CAAC;EA2CvE"}
|