@walletmesh/aztec-rpc-wallet 0.2.0 → 0.3.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/aztecRemoteWallet.d.ts +4 -8
- package/dist/aztecRemoteWallet.d.ts.map +1 -1
- package/dist/aztecRemoteWallet.js +5 -29
- package/dist/contractArtifactCache.d.ts.map +1 -1
- package/dist/contractArtifactCache.js +20 -9
- package/dist/handlers/aztecAccountWallet.d.ts.map +1 -1
- package/dist/handlers/aztecAccountWallet.js +11 -44
- package/dist/serializers/account.d.ts +16 -16
- package/dist/serializers/account.d.ts.map +1 -1
- package/dist/serializers/account.js +43 -43
- package/dist/serializers/contract.d.ts +22 -76
- package/dist/serializers/contract.d.ts.map +1 -1
- package/dist/serializers/contract.js +68 -120
- package/dist/serializers/index.d.ts +0 -4
- package/dist/serializers/index.d.ts.map +1 -1
- package/dist/serializers/index.js +15 -20
- package/dist/serializers/log.d.ts +16 -16
- package/dist/serializers/log.d.ts.map +1 -1
- package/dist/serializers/log.js +43 -43
- package/dist/serializers/note.d.ts +12 -12
- package/dist/serializers/note.d.ts.map +1 -1
- package/dist/serializers/note.js +32 -32
- package/dist/serializers/transaction.d.ts +25 -26
- package/dist/serializers/transaction.d.ts.map +1 -1
- package/dist/serializers/transaction.js +92 -44
- package/dist/types.d.ts +7 -30
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +1 -1
- package/docs/README.md +264 -0
- package/docs/classes/AztecChainProvider.md +553 -0
- package/docs/classes/AztecChainWallet.md +409 -0
- package/docs/classes/AztecProvider.md +1112 -0
- package/docs/classes/AztecWalletError.md +213 -0
- package/docs/classes/ContractArtifactCache.md +81 -0
- package/docs/globals.md +34 -0
- package/docs/interfaces/AztecWalletBaseMethodMap.md +135 -0
- package/docs/interfaces/AztecWalletEventMap.md +17 -0
- package/docs/interfaces/AztecWalletMethodMap.md +1012 -0
- package/docs/type-aliases/AztecChainId.md +11 -0
- package/docs/type-aliases/AztecChainWalletMiddleware.md +13 -0
- package/docs/type-aliases/AztecWalletContext.md +29 -0
- package/docs/type-aliases/AztecWalletMethodHandler.md +37 -0
- package/docs/type-aliases/AztecWalletMiddleware.md +13 -0
- package/docs/type-aliases/AztecWalletRouterClient.md +13 -0
- package/docs/type-aliases/TransactionFunctionCall.md +33 -0
- package/docs/type-aliases/TransactionParams.md +27 -0
- package/docs/variables/AztecWalletErrorMap.md +13 -0
- package/package.json +9 -9
- package/src/aztecRemoteWallet.test.ts +22 -61
- package/src/aztecRemoteWallet.ts +8 -35
- package/src/chainProvider.test.ts +117 -38
- package/src/contractArtifactCache.test.ts +28 -45
- package/src/contractArtifactCache.ts +20 -10
- package/src/handlers/aztecAccountWallet.test.ts +12 -86
- package/src/handlers/aztecAccountWallet.ts +19 -77
- package/src/provider.test.ts +0 -2
- package/src/serializers/account.test.ts +19 -20
- package/src/serializers/account.ts +52 -52
- package/src/serializers/contract.test.ts +4 -140
- package/src/serializers/contract.ts +93 -166
- package/src/serializers/index.test.ts +30 -28
- package/src/serializers/index.ts +15 -21
- package/src/serializers/log.test.ts +42 -48
- package/src/serializers/log.ts +54 -54
- package/src/serializers/note.test.ts +43 -16
- package/src/serializers/note.ts +39 -39
- package/src/serializers/transaction.test.ts +48 -41
- package/src/serializers/transaction.ts +146 -58
- package/src/types.ts +7 -7
- package/src/wallet.test.ts +3 -3
- package/dist/serializers/transaction-utils.d.ts +0 -51
- package/dist/serializers/transaction-utils.d.ts.map +0 -1
- package/dist/serializers/transaction-utils.js +0 -103
- package/src/serializers/transaction-utils.ts +0 -174
@@ -1,174 +0,0 @@
|
|
1
|
-
/**
|
2
|
-
* @module transaction-utils
|
3
|
-
* Utilities for serializing and deserializing Aztec transaction execution requests.
|
4
|
-
* These utilities handle the conversion between native Aztec types and JSON-RPC compatible formats.
|
5
|
-
*/
|
6
|
-
|
7
|
-
import { HashedValues, FunctionCall, AuthWitness } from '@aztec/circuit-types';
|
8
|
-
import { AztecAddress, Fr, FunctionSelector, GasSettings } from '@aztec/circuits.js';
|
9
|
-
import type { FunctionType, AbiType } from '@aztec/foundation/abi';
|
10
|
-
import type { ExecutionRequestInit } from '@aztec/aztec.js/entrypoint';
|
11
|
-
import { NoFeePaymentMethod } from '@aztec/aztec.js';
|
12
|
-
|
13
|
-
/**
|
14
|
-
* Interface representing the serialized form of a function call.
|
15
|
-
* This structure maps the native FunctionCall type to a JSON-serializable format
|
16
|
-
* where complex Aztec types are converted to strings.
|
17
|
-
*
|
18
|
-
* @property name - The name of the function being called
|
19
|
-
* @property to - The target contract address as a string
|
20
|
-
* @property selector - The function selector as a string
|
21
|
-
* @property type - The function type (public/private)
|
22
|
-
* @property isStatic - Whether the function is static (read-only)
|
23
|
-
* @property args - Array of function arguments as strings
|
24
|
-
* @property returnTypes - Array of return type definitions
|
25
|
-
*/
|
26
|
-
interface SerializedFunctionCall {
|
27
|
-
name: string;
|
28
|
-
to: string;
|
29
|
-
selector: string;
|
30
|
-
type: FunctionType;
|
31
|
-
isStatic: boolean;
|
32
|
-
args: string[];
|
33
|
-
returnTypes: AbiType[];
|
34
|
-
}
|
35
|
-
|
36
|
-
/**
|
37
|
-
* Interface representing the serialized form of an execution request initialization.
|
38
|
-
* This structure maps the ExecutionRequestInit type to a JSON-serializable format
|
39
|
-
* where complex Aztec types are converted to strings.
|
40
|
-
*
|
41
|
-
* @property calls - Array of serialized function calls
|
42
|
-
* @property authWitnesses - Optional array of authentication witness strings
|
43
|
-
* @property hashedArguments - Optional array of hashed argument values as base64 strings
|
44
|
-
* @property fee - Fee settings including gas configuration
|
45
|
-
* @property nonce - Optional transaction nonce as a string
|
46
|
-
* @property cancellable - Optional flag indicating if the transaction can be cancelled
|
47
|
-
*/
|
48
|
-
interface SerializedExecutionRequestInit {
|
49
|
-
calls: SerializedFunctionCall[];
|
50
|
-
authWitnesses?: string[];
|
51
|
-
hashedArguments?: string[];
|
52
|
-
fee: {
|
53
|
-
gasSettings: string;
|
54
|
-
};
|
55
|
-
nonce?: string;
|
56
|
-
cancellable?: boolean;
|
57
|
-
}
|
58
|
-
|
59
|
-
/**
|
60
|
-
* Serializes an ExecutionRequestInit object to a string for JSON-RPC transport.
|
61
|
-
* This function converts a native Aztec transaction execution request into a format
|
62
|
-
* that can be safely transmitted over JSON-RPC, handling the conversion of complex
|
63
|
-
* types like addresses, field elements, and function selectors to strings.
|
64
|
-
*
|
65
|
-
* Note: The fee payment method is not serialized as it contains async methods.
|
66
|
-
* The deserializer will use a default NoFeePaymentMethod which should be replaced
|
67
|
-
* by the caller with an appropriate implementation.
|
68
|
-
*
|
69
|
-
* @param init - The ExecutionRequestInit object to serialize, containing:
|
70
|
-
* - calls: Array of function calls to execute
|
71
|
-
* - fee: Gas settings and payment method
|
72
|
-
* - authWitnesses: Optional authentication proofs
|
73
|
-
* - hashedArguments: Optional pre-hashed arguments
|
74
|
-
* - nonce: Optional transaction nonce
|
75
|
-
* - cancellable: Optional cancellation flag
|
76
|
-
* @returns A JSON string representation of the serialized data, with all complex
|
77
|
-
* Aztec types converted to string representations
|
78
|
-
* @throws If any of the complex types cannot be serialized
|
79
|
-
*/
|
80
|
-
export function serializeExecutionRequestInit(init: ExecutionRequestInit): string {
|
81
|
-
const serialized: SerializedExecutionRequestInit = {
|
82
|
-
calls: init.calls.map((call) => ({
|
83
|
-
name: call.name,
|
84
|
-
to: call.to.toString(),
|
85
|
-
selector: call.selector.toString(),
|
86
|
-
type: call.type,
|
87
|
-
isStatic: call.isStatic,
|
88
|
-
args: call.args.map((arg) => arg.toString()),
|
89
|
-
returnTypes: call.returnTypes,
|
90
|
-
})),
|
91
|
-
fee: {
|
92
|
-
gasSettings: init.fee.gasSettings.toBuffer().toString('base64'),
|
93
|
-
},
|
94
|
-
};
|
95
|
-
|
96
|
-
if (init.authWitnesses) {
|
97
|
-
serialized.authWitnesses = init.authWitnesses.map((w) => w.toString());
|
98
|
-
}
|
99
|
-
|
100
|
-
if (init.hashedArguments) {
|
101
|
-
serialized.hashedArguments = init.hashedArguments.map((ha) => ha.toBuffer().toString('base64'));
|
102
|
-
}
|
103
|
-
|
104
|
-
if (init.nonce) {
|
105
|
-
serialized.nonce = init.nonce.toString();
|
106
|
-
}
|
107
|
-
|
108
|
-
if (init.cancellable !== undefined) {
|
109
|
-
serialized.cancellable = init.cancellable;
|
110
|
-
}
|
111
|
-
|
112
|
-
return JSON.stringify(serialized);
|
113
|
-
}
|
114
|
-
|
115
|
-
/**
|
116
|
-
* Deserializes a string into an ExecutionRequestInit object for use in the Aztec protocol.
|
117
|
-
* This function reconstructs a native Aztec transaction execution request from its
|
118
|
-
* JSON-RPC serialized form, converting string representations back into their
|
119
|
-
* appropriate Aztec types.
|
120
|
-
*
|
121
|
-
* Note: A default NoFeePaymentMethod is used for the fee payment method.
|
122
|
-
* The caller should override this with the appropriate implementation based on
|
123
|
-
* their fee payment requirements.
|
124
|
-
*
|
125
|
-
* @param data - The serialized string data containing:
|
126
|
-
* - calls: Array of serialized function calls
|
127
|
-
* - fee: Serialized gas settings
|
128
|
-
* - authWitnesses: Optional serialized authentication proofs
|
129
|
-
* - hashedArguments: Optional serialized hashed arguments
|
130
|
-
* - nonce: Optional serialized nonce
|
131
|
-
* - cancellable: Optional cancellation flag
|
132
|
-
* @returns The deserialized ExecutionRequestInit object with all string representations
|
133
|
-
* converted back to their native Aztec types
|
134
|
-
* @throws If any of the serialized data cannot be properly deserialized into valid Aztec types
|
135
|
-
*/
|
136
|
-
export function deserializeExecutionRequestInit(data: string): ExecutionRequestInit {
|
137
|
-
const parsed: SerializedExecutionRequestInit = JSON.parse(data);
|
138
|
-
|
139
|
-
const result: ExecutionRequestInit = {
|
140
|
-
calls: parsed.calls.map(
|
141
|
-
(call) =>
|
142
|
-
new FunctionCall(
|
143
|
-
call.name,
|
144
|
-
AztecAddress.fromString(call.to),
|
145
|
-
FunctionSelector.fromString(call.selector),
|
146
|
-
call.type,
|
147
|
-
call.isStatic,
|
148
|
-
call.args.map((arg) => Fr.fromString(arg)),
|
149
|
-
call.returnTypes,
|
150
|
-
),
|
151
|
-
),
|
152
|
-
fee: {
|
153
|
-
gasSettings: GasSettings.fromBuffer(Buffer.from(parsed.fee.gasSettings, 'base64')),
|
154
|
-
paymentMethod: new NoFeePaymentMethod(), // Default, caller should override
|
155
|
-
},
|
156
|
-
};
|
157
|
-
|
158
|
-
if (parsed.authWitnesses) {
|
159
|
-
result.authWitnesses = parsed.authWitnesses.map((w) => AuthWitness.fromString(w));
|
160
|
-
}
|
161
|
-
if (parsed.hashedArguments) {
|
162
|
-
result.hashedArguments = parsed.hashedArguments.map((ha) =>
|
163
|
-
HashedValues.fromBuffer(Buffer.from(ha, 'base64')),
|
164
|
-
);
|
165
|
-
}
|
166
|
-
if (parsed.nonce) {
|
167
|
-
result.nonce = Fr.fromString(parsed.nonce);
|
168
|
-
}
|
169
|
-
if (parsed.cancellable !== undefined) {
|
170
|
-
result.cancellable = parsed.cancellable;
|
171
|
-
}
|
172
|
-
|
173
|
-
return result;
|
174
|
-
}
|