@walletmesh/aztec-rpc-wallet 0.4.0 → 0.5.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 +12 -0
- package/dist/.tsbuildinfo +1 -1
- package/dist/client/aztec-dapp-wallet.d.ts +6 -6
- package/dist/client/aztec-dapp-wallet.d.ts.map +1 -1
- package/dist/client/aztec-dapp-wallet.js +7 -7
- package/dist/client/aztec-router-provider.d.ts +1 -1
- package/dist/client/aztec-router-provider.d.ts.map +1 -1
- package/dist/client/aztec-router-provider.js +1 -1
- package/dist/client/helpers.d.ts.map +1 -1
- package/dist/client/helpers.js +2 -2
- package/dist/client/register-serializers.js +1 -1
- package/dist/index.d.ts +18 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/types.d.ts +11 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/dist/wallet/create-node.d.ts +1 -1
- package/dist/wallet/create-node.d.ts.map +1 -1
- package/dist/wallet/create-node.js +1 -1
- package/dist/wallet/handlers/account.d.ts +1 -1
- package/dist/wallet/handlers/account.d.ts.map +1 -1
- package/dist/wallet/handlers/account.js +1 -1
- package/dist/wallet/handlers/contract-interaction.d.ts +1 -1
- package/dist/wallet/handlers/contract-interaction.d.ts.map +1 -1
- package/dist/wallet/handlers/contract-interaction.js +4 -4
- package/dist/wallet/handlers/contract.d.ts.map +1 -1
- package/dist/wallet/handlers/contract.js +1 -1
- package/dist/wallet/handlers/event.d.ts +1 -1
- package/dist/wallet/handlers/event.d.ts.map +1 -1
- package/dist/wallet/handlers/event.js +1 -1
- package/dist/wallet/handlers/index.d.ts.map +1 -1
- package/dist/wallet/handlers/index.js +2 -2
- package/dist/wallet/handlers/node.d.ts +1 -1
- package/dist/wallet/handlers/node.d.ts.map +1 -1
- package/dist/wallet/handlers/node.js +1 -1
- package/dist/wallet/handlers/senders.d.ts +1 -1
- package/dist/wallet/handlers/senders.d.ts.map +1 -1
- package/dist/wallet/handlers/senders.js +1 -1
- package/dist/wallet/handlers/transaction.d.ts +5 -4
- package/dist/wallet/handlers/transaction.d.ts.map +1 -1
- package/dist/wallet/handlers/transaction.js +9 -6
- package/dist/wallet/serializers.d.ts +1 -1
- package/dist/wallet/serializers.d.ts.map +1 -1
- package/dist/wallet/serializers.js +25 -25
- package/docs/README.md +1 -1
- package/docs/classes/AztecDappWallet.md +47 -47
- package/docs/classes/AztecRouterProvider.md +4 -4
- package/docs/classes/AztecWalletError.md +31 -7
- package/docs/classes/ContractArtifactCache.md +4 -4
- package/docs/functions/connectAztec.md +2 -2
- package/docs/functions/createAztecWallet.md +2 -2
- package/docs/functions/createAztecWalletNode.md +2 -2
- package/docs/functions/registerAztecSerializers.md +2 -2
- package/docs/functions/registerWalletAztecSerializers.md +2 -2
- package/docs/globals.md +2 -2
- package/docs/interfaces/AztecHandlerContext.md +5 -5
- package/docs/interfaces/AztecWalletContext.md +5 -5
- package/docs/interfaces/AztecWalletMethodMap.md +41 -37
- package/docs/type-aliases/AztecChainId.md +2 -2
- package/docs/variables/ALL_AZTEC_METHODS.md +2 -2
- package/docs/variables/AztecWalletErrorMap.md +2 -2
- package/docs/variables/AztecWalletSerializer.md +2 -2
- package/package.json +11 -9
- package/src/client/aztec-dapp-wallet.test.ts +8 -6
- package/src/client/aztec-dapp-wallet.ts +15 -14
- package/src/client/aztec-router-provider.test.ts +2 -2
- package/src/client/aztec-router-provider.ts +1 -1
- package/src/client/helpers.test.ts +3 -3
- package/src/client/helpers.ts +1 -2
- package/src/client/register-serializers.ts +1 -1
- package/src/contractArtifactCache.test.ts +1 -1
- package/src/index.test.ts +1 -1
- package/src/index.ts +21 -28
- package/src/types.ts +20 -20
- package/src/wallet/create-node.test.ts +3 -3
- package/src/wallet/create-node.ts +3 -4
- package/src/wallet/handlers/account.test.ts +6 -6
- package/src/wallet/handlers/account.ts +2 -2
- package/src/wallet/handlers/contract-interaction.test.ts +6 -7
- package/src/wallet/handlers/contract-interaction.ts +7 -7
- package/src/wallet/handlers/contract.test.ts +5 -5
- package/src/wallet/handlers/contract.ts +1 -1
- package/src/wallet/handlers/event.test.ts +4 -4
- package/src/wallet/handlers/event.ts +2 -2
- package/src/wallet/handlers/index.ts +1 -1
- package/src/wallet/handlers/node.test.ts +5 -6
- package/src/wallet/handlers/node.ts +2 -2
- package/src/wallet/handlers/senders.test.ts +4 -4
- package/src/wallet/handlers/senders.ts +2 -2
- package/src/wallet/handlers/transaction.test.ts +22 -13
- package/src/wallet/handlers/transaction.ts +10 -7
- package/src/wallet/serializers.test.ts +4 -6
- package/src/wallet/serializers.ts +44 -42
@@ -1,5 +1,3 @@
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
2
|
-
import { AztecRouterProvider } from './aztec-router-provider.js';
|
3
1
|
import { AztecAddress, CompleteAddress } from '@aztec/aztec.js';
|
4
2
|
// import { jsonStringify } from '@aztec/foundation/json-rpc'; // Unused
|
5
3
|
import type {
|
@@ -8,6 +6,8 @@ import type {
|
|
8
6
|
JSONRPCTransport,
|
9
7
|
// JSONRPCMethodMap, // Unused
|
10
8
|
} from '@walletmesh/jsonrpc';
|
9
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
10
|
+
import { AztecRouterProvider } from './aztec-router-provider.js';
|
11
11
|
|
12
12
|
// Define a minimal method map for testing purposes
|
13
13
|
// import type { JSONRPCParams } from '@walletmesh/jsonrpc'; // Unused
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
2
|
-
import { ALL_AZTEC_METHODS, connectAztec } from './helpers.js';
|
3
|
-
import { createAztecWallet, type AztecDappWallet } from './aztec-dapp-wallet.js';
|
4
1
|
import type { WalletRouterProvider } from '@walletmesh/router'; // Removed SessionData
|
2
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
3
|
+
import { type AztecDappWallet, createAztecWallet } from './aztec-dapp-wallet.js';
|
4
|
+
import { ALL_AZTEC_METHODS, connectAztec } from './helpers.js';
|
5
5
|
|
6
6
|
// Mock the aztec-dapp-wallet module
|
7
7
|
vi.mock('./aztec-dapp-wallet.js', () => ({
|
package/src/client/helpers.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
1
2
|
import type { AztecChainId } from '../types.js';
|
2
3
|
import type { AztecDappWallet } from './aztec-dapp-wallet.js';
|
3
4
|
import { createAztecWallet } from './aztec-dapp-wallet.js';
|
4
5
|
import type { AztecRouterProvider } from './aztec-router-provider.js';
|
5
|
-
import { createLogger } from '@aztec/foundation/log';
|
6
6
|
|
7
7
|
const logger = createLogger('aztec-rpc-wallet:helpers');
|
8
8
|
|
@@ -88,4 +88,3 @@ export async function connectAztec(
|
|
88
88
|
|
89
89
|
return { sessionId, wallet };
|
90
90
|
}
|
91
|
-
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { WalletRouterProvider } from '@walletmesh/router';
|
2
|
-
import { AztecWalletSerializer } from '../wallet/serializers.js';
|
3
2
|
import type { AztecWalletMethodMap } from '../types.js';
|
3
|
+
import { AztecWalletSerializer } from '../wallet/serializers.js';
|
4
4
|
|
5
5
|
/**
|
6
6
|
* Registers the {@link AztecWalletSerializer} for all relevant Aztec JSON-RPC methods
|
@@ -1,5 +1,5 @@
|
|
1
|
-
import { describe, expect, it, vi, beforeEach, type Mock } from 'vitest';
|
2
1
|
import type { AztecAddress, ContractArtifact, Fr, Wallet } from '@aztec/aztec.js';
|
2
|
+
import { beforeEach, describe, expect, it, type Mock, vi } from 'vitest';
|
3
3
|
import { ContractArtifactCache } from './contractArtifactCache.js';
|
4
4
|
import { AztecWalletError } from './errors.js';
|
5
5
|
|
package/src/index.test.ts
CHANGED
package/src/index.ts
CHANGED
@@ -5,27 +5,12 @@
|
|
5
5
|
* This package provides both wallet-side and dApp-side implementations for Aztec integration.
|
6
6
|
*/
|
7
7
|
|
8
|
-
// Wallet-side exports
|
9
|
-
/**
|
10
|
-
* Creates an Aztec wallet node that can be used with WalletRouter.
|
11
|
-
* This is the wallet-side implementation that handles JSON-RPC requests.
|
12
|
-
* @see {@link createAztecWalletNode}
|
13
|
-
*/
|
14
|
-
export { createAztecWalletNode } from './wallet/create-node.js';
|
15
|
-
|
16
|
-
/**
|
17
|
-
* Context interface provided to all handler functions in the wallet implementation.
|
18
|
-
* @see {@link AztecHandlerContext}
|
19
|
-
*/
|
20
|
-
export type { AztecHandlerContext } from './wallet/handlers/index.js';
|
21
|
-
|
22
8
|
// Client-side exports
|
23
9
|
/**
|
24
10
|
* DApp-side wallet class that implements the aztec.js Wallet interface.
|
25
11
|
* @see {@link AztecDappWallet}
|
26
12
|
*/
|
27
13
|
export { AztecDappWallet, createAztecWallet } from './client/aztec-dapp-wallet.js';
|
28
|
-
|
29
14
|
/**
|
30
15
|
* Extended WalletRouterProvider with built-in Aztec serialization support.
|
31
16
|
* Use this instead of the base WalletRouterProvider for automatic serialization
|
@@ -33,7 +18,6 @@ export { AztecDappWallet, createAztecWallet } from './client/aztec-dapp-wallet.j
|
|
33
18
|
* @see {@link AztecRouterProvider}
|
34
19
|
*/
|
35
20
|
export { AztecRouterProvider } from './client/aztec-router-provider.js';
|
36
|
-
|
37
21
|
/**
|
38
22
|
* Helper constants and functions for connecting to Aztec wallets.
|
39
23
|
* - ALL_AZTEC_METHODS: Complete list of all available Aztec methods
|
@@ -43,13 +27,25 @@ export {
|
|
43
27
|
ALL_AZTEC_METHODS,
|
44
28
|
connectAztec,
|
45
29
|
} from './client/helpers.js';
|
46
|
-
|
47
30
|
/**
|
48
31
|
* Helper function to register Aztec serializers with a WalletRouterProvider.
|
49
32
|
* This enables proper serialization of Aztec types when using the router.
|
50
33
|
* @see {@link registerAztecSerializers}
|
51
34
|
*/
|
52
35
|
export { registerAztecSerializers } from './client/register-serializers.js';
|
36
|
+
// Utilities
|
37
|
+
/**
|
38
|
+
* Cache utility for managing contract artifacts in wallet implementations.
|
39
|
+
* @see {@link ContractArtifactCache}
|
40
|
+
*/
|
41
|
+
export { ContractArtifactCache } from './contractArtifactCache.js';
|
42
|
+
// Error utilities
|
43
|
+
/**
|
44
|
+
* Error handling utilities for Aztec wallet operations.
|
45
|
+
* - AztecWalletError: Custom error class for Aztec wallet errors
|
46
|
+
* - AztecWalletErrorMap: Map of error codes to error messages
|
47
|
+
*/
|
48
|
+
export { AztecWalletError, AztecWalletErrorMap } from './errors.js';
|
53
49
|
|
54
50
|
// Shared types
|
55
51
|
/**
|
@@ -63,21 +59,18 @@ export type {
|
|
63
59
|
AztecWalletContext,
|
64
60
|
AztecWalletMethodMap,
|
65
61
|
} from './types.js';
|
66
|
-
|
67
|
-
// Utilities
|
62
|
+
// Wallet-side exports
|
68
63
|
/**
|
69
|
-
*
|
70
|
-
*
|
64
|
+
* Creates an Aztec wallet node that can be used with WalletRouter.
|
65
|
+
* This is the wallet-side implementation that handles JSON-RPC requests.
|
66
|
+
* @see {@link createAztecWalletNode}
|
71
67
|
*/
|
72
|
-
export {
|
73
|
-
|
74
|
-
// Error utilities
|
68
|
+
export { createAztecWalletNode } from './wallet/create-node.js';
|
75
69
|
/**
|
76
|
-
*
|
77
|
-
*
|
78
|
-
* - AztecWalletErrorMap: Map of error codes to error messages
|
70
|
+
* Context interface provided to all handler functions in the wallet implementation.
|
71
|
+
* @see {@link AztecHandlerContext}
|
79
72
|
*/
|
80
|
-
export {
|
73
|
+
export type { AztecHandlerContext } from './wallet/handlers/index.js';
|
81
74
|
|
82
75
|
// Re-export serializers
|
83
76
|
/**
|
package/src/types.ts
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
import type {
|
2
|
+
AccountWallet,
|
2
3
|
AuthWitness,
|
3
4
|
AztecAddress,
|
5
|
+
CompleteAddress,
|
4
6
|
Fr,
|
7
|
+
L2Block,
|
5
8
|
PXE,
|
9
|
+
Tx,
|
6
10
|
TxExecutionRequest,
|
7
11
|
TxHash,
|
8
12
|
TxReceipt,
|
9
|
-
L2Block,
|
10
|
-
CompleteAddress,
|
11
|
-
AccountWallet,
|
12
|
-
Tx,
|
13
13
|
} from '@aztec/aztec.js';
|
14
14
|
import type { IntentAction, IntentInnerHash } from '@aztec/aztec.js/utils';
|
15
15
|
import type { ExecutionPayload } from '@aztec/entrypoints/payload';
|
@@ -25,25 +25,23 @@ import type { ExecutionPayload } from '@aztec/entrypoints/payload';
|
|
25
25
|
* methods, their parameters, and return types. This is central to the typed RPC system.
|
26
26
|
*/
|
27
27
|
|
28
|
-
import type {
|
29
|
-
PrivateExecutionResult,
|
30
|
-
TxProfileResult,
|
31
|
-
TxProvingResult,
|
32
|
-
TxSimulationResult,
|
33
|
-
UtilitySimulationResult,
|
34
|
-
} from '@aztec/stdlib/tx';
|
35
|
-
|
36
28
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
37
|
-
|
29
|
+
import type { ContractInstanceWithAddress, NodeInfo } from '@aztec/stdlib/contract';
|
30
|
+
import type { GasFees } from '@aztec/stdlib/gas';
|
38
31
|
import type {
|
39
32
|
ContractClassMetadata,
|
40
33
|
ContractMetadata,
|
41
34
|
EventMetadataDefinition,
|
42
35
|
PXEInfo,
|
43
36
|
} from '@aztec/stdlib/interfaces/client';
|
44
|
-
|
45
|
-
|
46
|
-
|
37
|
+
import type {
|
38
|
+
PrivateExecutionResult,
|
39
|
+
SimulationOverrides,
|
40
|
+
TxProfileResult,
|
41
|
+
TxProvingResult,
|
42
|
+
TxSimulationResult,
|
43
|
+
UtilitySimulationResult,
|
44
|
+
} from '@aztec/stdlib/tx';
|
47
45
|
|
48
46
|
import type { WalletMethodMap } from '@walletmesh/router';
|
49
47
|
import type { ContractArtifactCache } from './contractArtifactCache.js';
|
@@ -318,18 +316,20 @@ export interface AztecWalletMethodMap extends WalletMethodMap {
|
|
318
316
|
* @param params - A tuple containing the simulation parameters.
|
319
317
|
* @param params.0 txRequest - The {@link TxExecutionRequest} to simulate.
|
320
318
|
* @param params.1 simulatePublic - Optional: Whether to simulate public parts. Defaults to `false`.
|
321
|
-
* @param params.2
|
322
|
-
* @param params.3
|
323
|
-
* @param params.4
|
319
|
+
* @param params.2 skipTxValidation - Optional: Flag to skip validation. Defaults to `false`.
|
320
|
+
* @param params.3 skipFeeEnforcement - Optional: Flag to skip fee enforcement. Defaults to `false`.
|
321
|
+
* @param params.4 overrides - Optional: {@link SimulationOverrides} for simulation context (includes msgSender).
|
322
|
+
* @param params.5 scopes - Optional: Array of {@link AztecAddress} scopes for the simulation.
|
324
323
|
* @returns result - The {@link TxSimulationResult}.
|
325
324
|
*/
|
326
325
|
aztec_simulateTx: {
|
327
326
|
params: [
|
328
327
|
TxExecutionRequest,
|
329
328
|
(boolean | undefined)?, // simulatePublic
|
330
|
-
(AztecAddress | undefined)?, // msgSender
|
331
329
|
(boolean | undefined)?, // skipTxValidation
|
332
330
|
(boolean | undefined)?, // skipFeeEnforcement
|
331
|
+
(SimulationOverrides | undefined)?, // overrides (includes msgSender)
|
332
|
+
(AztecAddress[] | undefined)?, // scopes
|
333
333
|
];
|
334
334
|
result: TxSimulationResult;
|
335
335
|
};
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
2
|
-
import { createAztecWalletNode } from './create-node.js';
|
3
|
-
import { JSONRPCNode } from '@walletmesh/jsonrpc';
|
4
1
|
import type { AccountWallet, PXE } from '@aztec/aztec.js';
|
5
2
|
import type { JSONRPCTransport } from '@walletmesh/jsonrpc';
|
3
|
+
import { JSONRPCNode } from '@walletmesh/jsonrpc';
|
4
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
6
5
|
import { ContractArtifactCache } from '../contractArtifactCache.js';
|
6
|
+
import { createAztecWalletNode } from './create-node.js';
|
7
7
|
import type { AztecHandlerContext } from './handlers/index.js';
|
8
8
|
|
9
9
|
// Mock dependencies
|
@@ -6,11 +6,10 @@
|
|
6
6
|
*/
|
7
7
|
|
8
8
|
import type { AccountWallet, PXE } from '@aztec/aztec.js';
|
9
|
-
import { JSONRPCNode, type JSONRPCTransport
|
10
|
-
|
11
|
-
import type { AztecWalletMethodMap } from '../types.js';
|
9
|
+
import { type JSONRPCEventMap, JSONRPCNode, type JSONRPCTransport } from '@walletmesh/jsonrpc';
|
12
10
|
import { ContractArtifactCache } from '../contractArtifactCache.js';
|
13
|
-
import {
|
11
|
+
import type { AztecWalletMethodMap } from '../types.js';
|
12
|
+
import { type AztecHandlerContext, createAztecHandlers } from './handlers/index.js';
|
14
13
|
import { registerAztecSerializers } from './serializers.js';
|
15
14
|
|
16
15
|
/**
|
@@ -1,17 +1,17 @@
|
|
1
|
-
import { describe, it, expect, vi, beforeEach } from 'vitest';
|
2
|
-
import { createAccountHandlers } from './account.js';
|
3
1
|
import type {
|
4
2
|
AccountWallet,
|
5
|
-
|
3
|
+
AuthWitness,
|
6
4
|
AztecAddress,
|
7
5
|
CompleteAddress,
|
8
|
-
AuthWitness,
|
9
6
|
FunctionSelector,
|
10
7
|
FunctionType,
|
8
|
+
PXE,
|
11
9
|
} from '@aztec/aztec.js';
|
12
|
-
import type { AztecHandlerContext } from './index.js';
|
13
|
-
import type { ContractArtifactCache } from '../../contractArtifactCache.js';
|
14
10
|
import { Fr } from '@aztec/aztec.js';
|
11
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
12
|
+
import type { ContractArtifactCache } from '../../contractArtifactCache.js';
|
13
|
+
import { createAccountHandlers } from './account.js';
|
14
|
+
import type { AztecHandlerContext } from './index.js';
|
15
15
|
|
16
16
|
// Mock dependencies
|
17
17
|
const createMockWallet = () =>
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import type { AztecHandlerContext } from './index.js';
|
2
|
-
import type { AztecWalletMethodMap } from '../../types.js';
|
3
1
|
import { createLogger } from '@aztec/foundation/log';
|
2
|
+
import type { AztecWalletMethodMap } from '../../types.js';
|
3
|
+
import type { AztecHandlerContext } from './index.js';
|
4
4
|
|
5
5
|
const logger = createLogger('aztec-rpc-wallet:account');
|
6
6
|
|
@@ -1,10 +1,9 @@
|
|
1
|
-
import {
|
1
|
+
import { AztecAddress, FeeJuicePaymentMethod, Fr, TxHash, type TxReceipt } from '@aztec/aztec.js';
|
2
|
+
import type { ExecutionPayload } from '@aztec/entrypoints/payload';
|
3
|
+
import { GasFees } from '@aztec/stdlib/gas';
|
4
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
2
5
|
import { createContractInteractionHandlers } from './contract-interaction.js';
|
3
6
|
import type { AztecHandlerContext } from './index.js';
|
4
|
-
import { AztecAddress, Fr, type TxReceipt, TxHash } from '@aztec/aztec.js';
|
5
|
-
import { GasFees } from '@aztec/stdlib/gas';
|
6
|
-
import { FeeJuicePaymentMethod } from '@aztec/aztec.js';
|
7
|
-
import type { ExecutionPayload } from '@aztec/entrypoints/payload';
|
8
7
|
|
9
8
|
// Mock the aztec.js module
|
10
9
|
vi.mock('@aztec/aztec.js', async () => {
|
@@ -39,7 +38,7 @@ describe('createContractInteractionHandlers', () => {
|
|
39
38
|
mockContext = {
|
40
39
|
wallet: {
|
41
40
|
getAddress: vi.fn().mockReturnValue(mockAddress),
|
42
|
-
getCurrentBaseFees: vi.fn().mockResolvedValue(new GasFees(
|
41
|
+
getCurrentBaseFees: vi.fn().mockResolvedValue(new GasFees(100n, 100n)),
|
43
42
|
createTxExecutionRequest: vi.fn().mockResolvedValue({}),
|
44
43
|
simulateTx: vi.fn().mockResolvedValue({ privateExecutionResult: {} }),
|
45
44
|
proveTx: vi.fn().mockResolvedValue({ toTx: vi.fn().mockReturnValue({}) }),
|
@@ -225,7 +224,7 @@ describe('createContractInteractionHandlers', () => {
|
|
225
224
|
const callOrder: string[] = [];
|
226
225
|
vi.mocked(mockContext.wallet.getCurrentBaseFees).mockImplementation(async () => {
|
227
226
|
callOrder.push('getCurrentBaseFees');
|
228
|
-
return new GasFees(
|
227
|
+
return new GasFees(100n, 100n);
|
229
228
|
});
|
230
229
|
vi.mocked(mockDeployMethod.prove).mockImplementation(async () => {
|
231
230
|
callOrder.push('prove');
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import type
|
2
|
-
import type { AztecWalletMethodMap } from '../../types.js';
|
3
|
-
import { Contract, FeeJuicePaymentMethod, Fr, type DeployOptions, type TxHash } from '@aztec/aztec.js';
|
4
|
-
import type { ExecutionPayload } from '@aztec/entrypoints/payload';
|
1
|
+
import { Contract, type DeployOptions, FeeJuicePaymentMethod, Fr, type TxHash } from '@aztec/aztec.js';
|
5
2
|
import type { FeeOptions, TxExecutionOptions } from '@aztec/entrypoints/interfaces';
|
6
|
-
import {
|
3
|
+
import type { ExecutionPayload } from '@aztec/entrypoints/payload';
|
7
4
|
import { createLogger } from '@aztec/foundation/log';
|
5
|
+
import { GasSettings } from '@aztec/stdlib/gas';
|
8
6
|
import type { TxExecutionRequest, TxSimulationResult } from '@aztec/stdlib/tx';
|
7
|
+
import type { AztecWalletMethodMap } from '../../types.js';
|
8
|
+
import type { AztecHandlerContext } from './index.js';
|
9
9
|
|
10
10
|
const logger = createLogger('aztec-rpc-wallet:contract-interaction:handler');
|
11
11
|
|
@@ -239,8 +239,8 @@ export function createContractInteractionHandlers() {
|
|
239
239
|
contractAddressSalt,
|
240
240
|
fee: await getFeeOptions(ctx),
|
241
241
|
};
|
242
|
-
if (txOpts.
|
243
|
-
opts.
|
242
|
+
if (txOpts.txNonce) {
|
243
|
+
opts.txNonce = txOpts.txNonce;
|
244
244
|
}
|
245
245
|
if (txOpts.cancellable) {
|
246
246
|
opts.cancellable = txOpts.cancellable;
|
@@ -1,12 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import type { AccountWallet, PXE, AztecAddress } from '@aztec/aztec.js';
|
1
|
+
import type { AccountWallet, AztecAddress, PXE } from '@aztec/aztec.js';
|
2
|
+
import { Fr } from '@aztec/aztec.js';
|
4
3
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
5
4
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
6
5
|
import type { ContractClassMetadata, ContractMetadata } from '@aztec/stdlib/interfaces/client';
|
7
|
-
import
|
6
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
8
7
|
import type { ContractArtifactCache } from '../../contractArtifactCache.js';
|
9
|
-
import {
|
8
|
+
import { createContractHandlers } from './contract.js';
|
9
|
+
import type { AztecHandlerContext } from './index.js';
|
10
10
|
|
11
11
|
// Mock dependencies
|
12
12
|
const createMockWallet = () =>
|
@@ -1,8 +1,8 @@
|
|
1
|
+
import { createLogger } from '@aztec/foundation/log';
|
1
2
|
import type { ContractArtifact } from '@aztec/stdlib/abi';
|
2
3
|
import type { ContractInstanceWithAddress } from '@aztec/stdlib/contract';
|
3
4
|
import type { AztecWalletMethodMap } from '../../types.js';
|
4
5
|
import type { AztecHandlerContext } from './index.js';
|
5
|
-
import { createLogger } from '@aztec/foundation/log';
|
6
6
|
|
7
7
|
const logger = createLogger('aztec-rpc-wallet:contract');
|
8
8
|
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import {
|
2
|
-
import { createEventHandlers } from './event.js';
|
3
|
-
import type { AccountWallet, PXE, AztecAddress } from '@aztec/aztec.js';
|
1
|
+
import type { AccountWallet, AztecAddress, PXE } from '@aztec/aztec.js';
|
4
2
|
import type { EventMetadataDefinition } from '@aztec/stdlib/interfaces/client';
|
5
|
-
import
|
3
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
6
4
|
import type { ContractArtifactCache } from '../../contractArtifactCache.js';
|
5
|
+
import { createEventHandlers } from './event.js';
|
6
|
+
import type { AztecHandlerContext } from './index.js';
|
7
7
|
|
8
8
|
// Mock dependencies
|
9
9
|
const createMockWallet = () =>
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import type { AztecHandlerContext } from './index.js';
|
2
|
-
import type { AztecWalletMethodMap } from '../../types.js';
|
3
1
|
import { createLogger } from '@aztec/foundation/log';
|
2
|
+
import type { AztecWalletMethodMap } from '../../types.js';
|
3
|
+
import type { AztecHandlerContext } from './index.js';
|
4
4
|
|
5
5
|
const logger = createLogger('aztec-rpc-wallet:event');
|
6
6
|
|
@@ -4,12 +4,12 @@ import type { ContractArtifactCache } from '../../contractArtifactCache.js';
|
|
4
4
|
import type { AztecWalletMethodMap } from '../../types.js';
|
5
5
|
|
6
6
|
import { createAccountHandlers } from './account.js';
|
7
|
-
import { createTransactionHandlers } from './transaction.js';
|
8
7
|
import { createContractHandlers } from './contract.js';
|
9
8
|
import { createContractInteractionHandlers } from './contract-interaction.js';
|
10
9
|
import { createEventHandlers } from './event.js';
|
11
10
|
import { createNodeHandlers } from './node.js';
|
12
11
|
import { createSenderHandlers } from './senders.js';
|
12
|
+
import { createTransactionHandlers } from './transaction.js';
|
13
13
|
|
14
14
|
/**
|
15
15
|
* Defines the context object that is passed to all Aztec wallet JSON-RPC method handlers.
|
@@ -1,13 +1,12 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import type { AccountWallet, PXE } from '@aztec/aztec.js';
|
1
|
+
import type { AccountWallet, L2Block, PXE } from '@aztec/aztec.js';
|
2
|
+
import { Fr } from '@aztec/aztec.js';
|
4
3
|
import type { NodeInfo } from '@aztec/stdlib/contract';
|
5
4
|
import type { GasFees } from '@aztec/stdlib/gas';
|
6
5
|
import type { PXEInfo } from '@aztec/stdlib/interfaces/client';
|
7
|
-
import
|
8
|
-
import type { AztecHandlerContext } from './index.js';
|
6
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
9
7
|
import type { ContractArtifactCache } from '../../contractArtifactCache.js';
|
10
|
-
import {
|
8
|
+
import type { AztecHandlerContext } from './index.js';
|
9
|
+
import { createNodeHandlers } from './node.js';
|
11
10
|
|
12
11
|
// Mock dependencies
|
13
12
|
const createMockWallet = () =>
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import type { AztecHandlerContext } from './index.js';
|
2
|
-
import type { AztecWalletMethodMap } from '../../types.js';
|
3
1
|
import { createLogger } from '@aztec/foundation/log';
|
2
|
+
import type { AztecWalletMethodMap } from '../../types.js';
|
3
|
+
import type { AztecHandlerContext } from './index.js';
|
4
4
|
|
5
5
|
const logger = createLogger('aztec-rpc-wallet:node');
|
6
6
|
|
@@ -1,8 +1,8 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import type { AccountWallet, PXE, AztecAddress } from '@aztec/aztec.js';
|
4
|
-
import type { AztecHandlerContext } from './index.js';
|
1
|
+
import type { AccountWallet, AztecAddress, PXE } from '@aztec/aztec.js';
|
2
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
5
3
|
import type { ContractArtifactCache } from '../../contractArtifactCache.js';
|
4
|
+
import type { AztecHandlerContext } from './index.js';
|
5
|
+
import { createSenderHandlers } from './senders.js';
|
6
6
|
|
7
7
|
// Mock dependencies
|
8
8
|
const createMockWallet = () =>
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import type { AztecHandlerContext } from './index.js';
|
2
|
-
import type { AztecWalletMethodMap } from '../../types.js';
|
3
1
|
import { createLogger } from '@aztec/foundation/log';
|
2
|
+
import type { AztecWalletMethodMap } from '../../types.js';
|
3
|
+
import type { AztecHandlerContext } from './index.js';
|
4
4
|
|
5
5
|
const logger = createLogger('aztec-rpc-wallet:senders');
|
6
6
|
|
@@ -1,19 +1,27 @@
|
|
1
|
-
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
1
|
+
import type {
|
2
|
+
AccountWallet,
|
3
|
+
AuthWitness,
|
4
|
+
AztecAddress,
|
5
|
+
PXE,
|
6
|
+
Tx,
|
7
|
+
TxExecutionRequest,
|
8
|
+
TxHash,
|
9
|
+
TxReceipt,
|
10
|
+
} from '@aztec/aztec.js';
|
9
11
|
import { Fr } from '@aztec/aztec.js';
|
10
12
|
import type {
|
11
13
|
PrivateExecutionResult,
|
14
|
+
TxProfileResult,
|
12
15
|
TxProvingResult,
|
13
16
|
TxSimulationResult,
|
14
|
-
TxProfileResult,
|
15
17
|
UtilitySimulationResult,
|
16
18
|
} from '@aztec/stdlib/tx';
|
19
|
+
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
20
|
+
import type { ContractArtifactCache } from '../../contractArtifactCache.js';
|
21
|
+
// import type { FeeOptions, TxExecutionOptions } from '@aztec/entrypoints/interfaces'; // Unused
|
22
|
+
// import type { ExecutionPayload } from '@aztec/entrypoints/payload'; // Unused
|
23
|
+
import type { AztecHandlerContext } from './index.js';
|
24
|
+
import { createTransactionHandlers } from './transaction.js';
|
17
25
|
|
18
26
|
// Mock dependencies
|
19
27
|
const createMockWallet = () =>
|
@@ -175,9 +183,10 @@ describe('Transaction Handlers', () => {
|
|
175
183
|
txRequest: { exec: { calls: [] } },
|
176
184
|
} as unknown as TxExecutionRequest;
|
177
185
|
const simulatePublic = true;
|
178
|
-
const msgSender = '0x1234567890abcdef' as unknown as AztecAddress;
|
179
186
|
const skipTxValidation = true;
|
180
187
|
const skipFeeEnforcement = true;
|
188
|
+
const msgSender = '0x1234567890abcdef' as unknown as AztecAddress;
|
189
|
+
const overrides = { msgSender };
|
181
190
|
|
182
191
|
const expectedSimulation = {
|
183
192
|
txRequest,
|
@@ -190,17 +199,17 @@ describe('Transaction Handlers', () => {
|
|
190
199
|
const result = await handlers.aztec_simulateTx(context, [
|
191
200
|
txRequest,
|
192
201
|
simulatePublic,
|
193
|
-
msgSender,
|
194
202
|
skipTxValidation,
|
195
203
|
skipFeeEnforcement,
|
204
|
+
overrides,
|
196
205
|
]);
|
197
206
|
|
198
207
|
expect(mockWallet.simulateTx).toHaveBeenCalledWith(
|
199
208
|
txRequest,
|
200
209
|
simulatePublic,
|
201
|
-
msgSender,
|
202
210
|
skipTxValidation,
|
203
211
|
skipFeeEnforcement,
|
212
|
+
overrides,
|
204
213
|
);
|
205
214
|
expect(result).toBe(expectedSimulation);
|
206
215
|
});
|
@@ -226,7 +235,7 @@ describe('Transaction Handlers', () => {
|
|
226
235
|
undefined,
|
227
236
|
]);
|
228
237
|
|
229
|
-
expect(mockWallet.simulateTx).toHaveBeenCalledWith(txRequest, false, undefined,
|
238
|
+
expect(mockWallet.simulateTx).toHaveBeenCalledWith(txRequest, false, undefined, false, undefined);
|
230
239
|
expect(result).toBe(expectedSimulation);
|
231
240
|
});
|
232
241
|
|
@@ -1,6 +1,6 @@
|
|
1
|
-
import type { AztecHandlerContext } from './index.js';
|
2
|
-
import type { AztecWalletMethodMap } from '../../types.js';
|
3
1
|
import { createLogger } from '@aztec/foundation/log';
|
2
|
+
import type { AztecWalletMethodMap } from '../../types.js';
|
3
|
+
import type { AztecHandlerContext } from './index.js';
|
4
4
|
|
5
5
|
const logger = createLogger('aztec-rpc-wallet:transaction');
|
6
6
|
|
@@ -139,9 +139,10 @@ export function createTransactionHandlers() {
|
|
139
139
|
* Defined by {@link AztecWalletMethodMap.aztec_simulateTx.params}.
|
140
140
|
* @param paramsTuple.0 - The {@link TxExecutionRequest} to simulate.
|
141
141
|
* @param paramsTuple.1 - Optional: Boolean indicating whether to simulate public parts of the transaction. Defaults to `false`.
|
142
|
-
* @param paramsTuple.2 - Optional:
|
143
|
-
* @param paramsTuple.3 - Optional: Boolean flag to skip
|
144
|
-
* @param paramsTuple.4 - Optional:
|
142
|
+
* @param paramsTuple.2 - Optional: Boolean flag to skip transaction validation during simulation.
|
143
|
+
* @param paramsTuple.3 - Optional: Boolean flag to skip fee enforcement during simulation.
|
144
|
+
* @param paramsTuple.4 - Optional: {@link SimulationOverrides} for simulation context (includes msgSender).
|
145
|
+
* @param paramsTuple.5 - Optional: Array of {@link AztecAddress} scopes for the simulation.
|
145
146
|
* @returns A promise that resolves to the {@link TxSimulationResult}.
|
146
147
|
* Type defined by {@link AztecWalletMethodMap.aztec_simulateTx.result}.
|
147
148
|
* @throws {Error} If the `txRequest` parameter is missing or invalid.
|
@@ -153,9 +154,9 @@ export function createTransactionHandlers() {
|
|
153
154
|
const [
|
154
155
|
txRequest,
|
155
156
|
simulatePublicInput, // simulatePublic is optional in PXE interface
|
156
|
-
msgSender,
|
157
157
|
skipTxValidation,
|
158
158
|
skipFeeEnforcementInput, // skipFeeEnforcement is optional in PXE interface
|
159
|
+
overrides, // SimulationOverrides which may contain msgSender
|
159
160
|
] = paramsTuple;
|
160
161
|
// Handle optional params with defaults if necessary, matching PXE behavior
|
161
162
|
const simulatePublic = simulatePublicInput === undefined ? false : simulatePublicInput;
|
@@ -166,12 +167,14 @@ export function createTransactionHandlers() {
|
|
166
167
|
// txRequest is mandatory
|
167
168
|
throw new Error('Invalid txRequest parameter received in tuple');
|
168
169
|
}
|
170
|
+
|
171
|
+
// Call with the parameters that the underlying wallet expects
|
169
172
|
return await ctx.wallet.simulateTx(
|
170
173
|
txRequest,
|
171
174
|
simulatePublic,
|
172
|
-
msgSender,
|
173
175
|
skipTxValidation,
|
174
176
|
skipFeeEnforcement,
|
177
|
+
overrides,
|
175
178
|
);
|
176
179
|
},
|
177
180
|
|