ox 1.0.0-beta.0 → 1.0.0-beta.2
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/dist/core/Provider.d.ts +7 -7
- package/dist/core/Provider.d.ts.map +1 -1
- package/dist/core/RpcSchema.d.ts +50 -0
- package/dist/core/RpcSchema.d.ts.map +1 -1
- package/dist/core/RpcSchema.js.map +1 -1
- package/dist/core/RpcTransport.d.ts +2 -2
- package/dist/core/RpcTransport.d.ts.map +1 -1
- package/dist/core/RpcTransport.js.map +1 -1
- package/dist/core/internal/rpcTransport.d.ts +1 -1
- package/dist/core/internal/rpcTransport.d.ts.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/tempo/MultisigConfig.d.ts +79 -16
- package/dist/tempo/MultisigConfig.d.ts.map +1 -1
- package/dist/tempo/MultisigConfig.js +69 -11
- package/dist/tempo/MultisigConfig.js.map +1 -1
- package/dist/tempo/SignatureEnvelope.d.ts +83 -19
- package/dist/tempo/SignatureEnvelope.d.ts.map +1 -1
- package/dist/tempo/SignatureEnvelope.js +99 -30
- package/dist/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/tempo/index.d.ts +2 -2
- package/dist/tempo/index.js +2 -2
- package/dist/zod/RpcSchema.d.ts +144 -25
- package/dist/zod/RpcSchema.d.ts.map +1 -1
- package/dist/zod/RpcSchema.js +85 -13
- package/dist/zod/RpcSchema.js.map +1 -1
- package/dist/zod/internal/rpcSchemas/Eth.d.ts +12 -12
- package/dist/zod/internal/rpcSchemas/Eth.d.ts.map +1 -1
- package/dist/zod/internal/rpcSchemas/Eth.js +14 -12
- package/dist/zod/internal/rpcSchemas/Eth.js.map +1 -1
- package/dist/zod/tempo/AuthorizationTempo.d.ts +6 -6
- package/dist/zod/tempo/KeyAuthorization.d.ts +3 -3
- package/dist/zod/tempo/RpcSchemaTempo.d.ts +6 -6
- package/dist/zod/tempo/SignatureEnvelope.d.ts +3 -3
- package/dist/zod/tempo/SignatureEnvelope.js +1 -1
- package/dist/zod/tempo/SignatureEnvelope.js.map +1 -1
- package/dist/zod/tempo/Transaction.d.ts +6 -6
- package/dist/zod/tempo/TransactionRequest.d.ts +6 -6
- package/dist/zod/tempo/TxEnvelopeTempo.d.ts +9 -9
- package/dist/zod/tempo/ZoneRpcAuthentication.d.ts +3 -3
- package/package.json +1 -1
- package/src/CHANGELOG.md +6 -0
- package/src/core/Provider.ts +7 -7
- package/src/core/RpcSchema.ts +60 -0
- package/src/core/RpcTransport.ts +7 -4
- package/src/core/_test/Provider.test-d.ts +21 -0
- package/src/core/_test/RpcSchema.test-d.ts +87 -1
- package/src/core/_test/RpcTransport.test-d.ts +43 -0
- package/src/core/internal/rpcTransport.ts +1 -1
- package/src/index.ts +2 -0
- package/src/tempo/MultisigConfig.test.ts +21 -12
- package/src/tempo/MultisigConfig.ts +103 -18
- package/src/tempo/SignatureEnvelope.test.ts +124 -26
- package/src/tempo/SignatureEnvelope.ts +150 -48
- package/src/tempo/e2e.test.ts +42 -47
- package/src/tempo/index.ts +2 -2
- package/src/version.ts +1 -1
- package/src/zod/RpcSchema.ts +190 -13
- package/src/zod/_test/RpcSchema.test-d.ts +53 -6
- package/src/zod/_test/RpcSchema.test.ts +138 -18
- package/src/zod/internal/rpcSchemas/Eth.ts +14 -12
- package/src/zod/tempo/SignatureEnvelope.ts +1 -1
- package/src/zod/tempo/_test/RpcSchemaTempo.test.ts +1 -1
- package/src/zod/tempo/_test/SignatureEnvelope.test.ts +23 -0
|
@@ -2,17 +2,28 @@ import type * as core_Address from '../../core/Address.js'
|
|
|
2
2
|
import type * as core_Block from '../../core/Block.js'
|
|
3
3
|
import type * as core_Fee from '../../core/Fee.js'
|
|
4
4
|
import type * as core_Hex from '../../core/Hex.js'
|
|
5
|
-
import type * as z from 'zod/mini'
|
|
6
5
|
import { expectTypeOf, test } from 'vp/test'
|
|
6
|
+
import * as z from 'zod/mini'
|
|
7
7
|
import * as z_RpcSchema from '../RpcSchema.js'
|
|
8
8
|
|
|
9
9
|
test('method items mirror wire (input) and domain (output) shapes', () => {
|
|
10
|
-
// Scalar return types
|
|
10
|
+
// Scalar quantity return types are wire hex on input, native on output.
|
|
11
11
|
expectTypeOf<
|
|
12
12
|
z.input<typeof z_RpcSchema.Eth.eth_blockNumber.returns>
|
|
13
13
|
>().toEqualTypeOf<core_Hex.Hex>()
|
|
14
14
|
expectTypeOf<
|
|
15
15
|
z.output<typeof z_RpcSchema.Eth.eth_blockNumber.returns>
|
|
16
|
+
>().toEqualTypeOf<bigint>()
|
|
17
|
+
expectTypeOf<
|
|
18
|
+
z.output<typeof z_RpcSchema.Eth.eth_chainId.returns>
|
|
19
|
+
>().toEqualTypeOf<number>()
|
|
20
|
+
|
|
21
|
+
// Data/bytecode return types stay as wire hex.
|
|
22
|
+
expectTypeOf<
|
|
23
|
+
z.output<typeof z_RpcSchema.Eth.eth_call.returns>
|
|
24
|
+
>().toEqualTypeOf<core_Hex.Hex>()
|
|
25
|
+
expectTypeOf<
|
|
26
|
+
z.output<typeof z_RpcSchema.Eth.eth_getCode.returns>
|
|
16
27
|
>().toEqualTypeOf<core_Hex.Hex>()
|
|
17
28
|
|
|
18
29
|
// Address arrays.
|
|
@@ -29,10 +40,10 @@ test('method items mirror wire (input) and domain (output) shapes', () => {
|
|
|
29
40
|
>().toEqualTypeOf<core_Fee.FeeHistory>()
|
|
30
41
|
})
|
|
31
42
|
|
|
32
|
-
test('
|
|
43
|
+
test('decode helpers infer params/returns by method', () => {
|
|
33
44
|
// Params: block number is wire hex on input, bigint on output.
|
|
34
45
|
expectTypeOf(
|
|
35
|
-
z_RpcSchema.
|
|
46
|
+
z_RpcSchema.decodeParams(z_RpcSchema.Eth, 'eth_getBlockByNumber', [
|
|
36
47
|
'0x1',
|
|
37
48
|
true,
|
|
38
49
|
]),
|
|
@@ -40,11 +51,47 @@ test('parse helpers infer params/returns by method', () => {
|
|
|
40
51
|
|
|
41
52
|
// Returns: decoded to domain values.
|
|
42
53
|
expectTypeOf(
|
|
43
|
-
z_RpcSchema.
|
|
44
|
-
).toEqualTypeOf<
|
|
54
|
+
z_RpcSchema.decodeReturns(z_RpcSchema.Eth, 'eth_blockNumber', '0x1b4'),
|
|
55
|
+
).toEqualTypeOf<bigint>()
|
|
45
56
|
|
|
46
57
|
// Item lookup preserves the literal method name.
|
|
47
58
|
expectTypeOf(
|
|
48
59
|
z_RpcSchema.parseItem(z_RpcSchema.Eth, 'eth_blockNumber').method,
|
|
49
60
|
).toEqualTypeOf<'eth_blockNumber'>()
|
|
50
61
|
})
|
|
62
|
+
|
|
63
|
+
test('encode helpers infer params/returns by method', () => {
|
|
64
|
+
// Returns: native bigint on input, wire hex on output.
|
|
65
|
+
expectTypeOf(
|
|
66
|
+
z_RpcSchema.encodeReturns(z_RpcSchema.Eth, 'eth_blockNumber', 436n),
|
|
67
|
+
).toEqualTypeOf<core_Hex.Hex>()
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
test('from: namespace returns a decodable namespace', () => {
|
|
71
|
+
const schema = z_RpcSchema.from({
|
|
72
|
+
abe_foo: {
|
|
73
|
+
params: z.tuple([z.number()]),
|
|
74
|
+
returns: z.string(),
|
|
75
|
+
},
|
|
76
|
+
})
|
|
77
|
+
|
|
78
|
+
// Method name taken from the key.
|
|
79
|
+
expectTypeOf(schema.abe_foo.method).toEqualTypeOf<'abe_foo'>()
|
|
80
|
+
|
|
81
|
+
// Usable with decode* methods.
|
|
82
|
+
expectTypeOf(z_RpcSchema.decodeParams(schema, 'abe_foo', [1])).toEqualTypeOf<
|
|
83
|
+
[number]
|
|
84
|
+
>()
|
|
85
|
+
expectTypeOf(
|
|
86
|
+
z_RpcSchema.decodeReturns(schema, 'abe_foo', 'hello'),
|
|
87
|
+
).toEqualTypeOf<string>()
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
test('from: single method returns an Item', () => {
|
|
91
|
+
const item = z_RpcSchema.from({
|
|
92
|
+
method: 'abe_foo',
|
|
93
|
+
params: z.tuple([z.number()]),
|
|
94
|
+
returns: z.string(),
|
|
95
|
+
})
|
|
96
|
+
expectTypeOf(item.method).toEqualTypeOf<'abe_foo'>()
|
|
97
|
+
})
|
|
@@ -6,10 +6,10 @@ const address = '0x0000000000000000000000000000000000000000'
|
|
|
6
6
|
const hash = `0x${'11'.repeat(32)}` as const
|
|
7
7
|
const topic = `0x${'33'.repeat(32)}` as const
|
|
8
8
|
|
|
9
|
-
describe('
|
|
9
|
+
describe('decodeParams', () => {
|
|
10
10
|
test('decodes params (block number / tag coercion)', () => {
|
|
11
11
|
expect(
|
|
12
|
-
z_RpcSchema.
|
|
12
|
+
z_RpcSchema.decodeParams(z_RpcSchema.Eth, 'eth_getBlockByNumber', [
|
|
13
13
|
'0x1b4',
|
|
14
14
|
true,
|
|
15
15
|
]),
|
|
@@ -20,7 +20,7 @@ describe('parseParams', () => {
|
|
|
20
20
|
]
|
|
21
21
|
`)
|
|
22
22
|
expect(
|
|
23
|
-
z_RpcSchema.
|
|
23
|
+
z_RpcSchema.decodeParams(z_RpcSchema.Eth, 'eth_getBlockByNumber', [
|
|
24
24
|
'latest',
|
|
25
25
|
false,
|
|
26
26
|
]),
|
|
@@ -34,7 +34,7 @@ describe('parseParams', () => {
|
|
|
34
34
|
|
|
35
35
|
test('decodes wallet params', () => {
|
|
36
36
|
expect(
|
|
37
|
-
z_RpcSchema.
|
|
37
|
+
z_RpcSchema.decodeParams(
|
|
38
38
|
z_RpcSchema.Wallet,
|
|
39
39
|
'wallet_switchEthereumChain',
|
|
40
40
|
[{ chainId: '0x1' }],
|
|
@@ -49,13 +49,27 @@ describe('parseParams', () => {
|
|
|
49
49
|
})
|
|
50
50
|
})
|
|
51
51
|
|
|
52
|
-
describe('
|
|
52
|
+
describe('decodeReturns', () => {
|
|
53
53
|
test('decodes scalar return types', () => {
|
|
54
54
|
expect(
|
|
55
|
-
z_RpcSchema.
|
|
56
|
-
).toMatchInlineSnapshot(`
|
|
57
|
-
expect(
|
|
58
|
-
.
|
|
55
|
+
z_RpcSchema.decodeReturns(z_RpcSchema.Eth, 'eth_blockNumber', '0x1b4'),
|
|
56
|
+
).toMatchInlineSnapshot(`436n`)
|
|
57
|
+
expect(
|
|
58
|
+
z_RpcSchema.decodeReturns(z_RpcSchema.Eth, 'eth_chainId', '0x1'),
|
|
59
|
+
).toMatchInlineSnapshot(`1`)
|
|
60
|
+
expect(
|
|
61
|
+
z_RpcSchema.decodeReturns(
|
|
62
|
+
z_RpcSchema.Eth,
|
|
63
|
+
'eth_getTransactionCount',
|
|
64
|
+
'0x2',
|
|
65
|
+
),
|
|
66
|
+
).toMatchInlineSnapshot(`2`)
|
|
67
|
+
expect(
|
|
68
|
+
z_RpcSchema.decodeReturns(z_RpcSchema.Eth, 'eth_call', '0x1234'),
|
|
69
|
+
).toMatchInlineSnapshot(`"0x1234"`)
|
|
70
|
+
expect(
|
|
71
|
+
z_RpcSchema.decodeReturns(z_RpcSchema.Eth, 'eth_accounts', [address]),
|
|
72
|
+
).toMatchInlineSnapshot(`
|
|
59
73
|
[
|
|
60
74
|
"0x0000000000000000000000000000000000000000",
|
|
61
75
|
]
|
|
@@ -64,7 +78,7 @@ describe('parseReturns', () => {
|
|
|
64
78
|
|
|
65
79
|
test('decodes fee history return type', () => {
|
|
66
80
|
expect(
|
|
67
|
-
z_RpcSchema.
|
|
81
|
+
z_RpcSchema.decodeReturns(z_RpcSchema.Eth, 'eth_feeHistory', {
|
|
68
82
|
baseFeePerGas: ['0x1', '0x2'],
|
|
69
83
|
gasUsedRatio: [0.5],
|
|
70
84
|
oldestBlock: '0x10',
|
|
@@ -91,7 +105,7 @@ describe('parseReturns', () => {
|
|
|
91
105
|
|
|
92
106
|
test('decodes log return types', () => {
|
|
93
107
|
expect(
|
|
94
|
-
z_RpcSchema.
|
|
108
|
+
z_RpcSchema.decodeReturns(z_RpcSchema.Eth, 'eth_getLogs', [
|
|
95
109
|
{
|
|
96
110
|
address,
|
|
97
111
|
blockHash: hash,
|
|
@@ -125,7 +139,7 @@ describe('parseReturns', () => {
|
|
|
125
139
|
|
|
126
140
|
test('decodes nullable return types', () => {
|
|
127
141
|
expect(
|
|
128
|
-
z_RpcSchema.
|
|
142
|
+
z_RpcSchema.decodeReturns(
|
|
129
143
|
z_RpcSchema.Eth,
|
|
130
144
|
'eth_getTransactionReceipt',
|
|
131
145
|
null,
|
|
@@ -134,6 +148,55 @@ describe('parseReturns', () => {
|
|
|
134
148
|
})
|
|
135
149
|
})
|
|
136
150
|
|
|
151
|
+
describe('encodeParams', () => {
|
|
152
|
+
test('encodes params (native → wire)', () => {
|
|
153
|
+
expect(
|
|
154
|
+
z_RpcSchema.encodeParams(z_RpcSchema.Eth, 'eth_getBlockByNumber', [
|
|
155
|
+
436n,
|
|
156
|
+
true,
|
|
157
|
+
]),
|
|
158
|
+
).toMatchInlineSnapshot(`
|
|
159
|
+
[
|
|
160
|
+
"0x1b4",
|
|
161
|
+
true,
|
|
162
|
+
]
|
|
163
|
+
`)
|
|
164
|
+
})
|
|
165
|
+
})
|
|
166
|
+
|
|
167
|
+
describe('encodeReturns', () => {
|
|
168
|
+
test('encodes scalar return types (native → wire)', () => {
|
|
169
|
+
expect(
|
|
170
|
+
z_RpcSchema.encodeReturns(z_RpcSchema.Eth, 'eth_blockNumber', 436n),
|
|
171
|
+
).toMatchInlineSnapshot(`"0x1b4"`)
|
|
172
|
+
expect(
|
|
173
|
+
z_RpcSchema.encodeReturns(z_RpcSchema.Eth, 'eth_chainId', 1),
|
|
174
|
+
).toMatchInlineSnapshot(`"0x1"`)
|
|
175
|
+
expect(
|
|
176
|
+
z_RpcSchema.encodeReturns(z_RpcSchema.Eth, 'eth_call', '0x1234'),
|
|
177
|
+
).toMatchInlineSnapshot(`"0x1234"`)
|
|
178
|
+
})
|
|
179
|
+
})
|
|
180
|
+
|
|
181
|
+
describe('encodeRequest', () => {
|
|
182
|
+
test('encodes a request (native → wire)', () => {
|
|
183
|
+
expect(
|
|
184
|
+
z_RpcSchema.encodeRequest(z_RpcSchema.Eth, {
|
|
185
|
+
method: 'eth_getBlockByNumber',
|
|
186
|
+
params: [436n, true],
|
|
187
|
+
}),
|
|
188
|
+
).toMatchInlineSnapshot(`
|
|
189
|
+
{
|
|
190
|
+
"method": "eth_getBlockByNumber",
|
|
191
|
+
"params": [
|
|
192
|
+
"0x1b4",
|
|
193
|
+
true,
|
|
194
|
+
],
|
|
195
|
+
}
|
|
196
|
+
`)
|
|
197
|
+
})
|
|
198
|
+
})
|
|
199
|
+
|
|
137
200
|
describe('parseItem', () => {
|
|
138
201
|
test('looks up a method schema', () => {
|
|
139
202
|
expect(
|
|
@@ -150,10 +213,10 @@ describe('parseItem', () => {
|
|
|
150
213
|
})
|
|
151
214
|
})
|
|
152
215
|
|
|
153
|
-
describe('
|
|
216
|
+
describe('decodeRequest', () => {
|
|
154
217
|
test('dispatches by method', () => {
|
|
155
218
|
expect(
|
|
156
|
-
z_RpcSchema.
|
|
219
|
+
z_RpcSchema.decodeRequest(z_RpcSchema.Eth, {
|
|
157
220
|
method: 'eth_getBlockByNumber',
|
|
158
221
|
params: ['0x1', true],
|
|
159
222
|
}),
|
|
@@ -168,7 +231,7 @@ describe('parseRequest', () => {
|
|
|
168
231
|
`)
|
|
169
232
|
})
|
|
170
233
|
|
|
171
|
-
test('parse is an alias of
|
|
234
|
+
test('parse is an alias of decodeRequest', () => {
|
|
172
235
|
expect(
|
|
173
236
|
z_RpcSchema.parse(z_RpcSchema.Wallet, {
|
|
174
237
|
method: 'wallet_switchEthereumChain',
|
|
@@ -188,7 +251,7 @@ describe('parseRequest', () => {
|
|
|
188
251
|
|
|
189
252
|
test('Default dispatches across eth_ and wallet_ methods', () => {
|
|
190
253
|
expect(
|
|
191
|
-
z_RpcSchema.
|
|
254
|
+
z_RpcSchema.decodeRequest(z_RpcSchema.Default, {
|
|
192
255
|
method: 'eth_getBlockByNumber',
|
|
193
256
|
params: ['0x1', true],
|
|
194
257
|
}),
|
|
@@ -202,7 +265,7 @@ describe('parseRequest', () => {
|
|
|
202
265
|
}
|
|
203
266
|
`)
|
|
204
267
|
expect(
|
|
205
|
-
z_RpcSchema.
|
|
268
|
+
z_RpcSchema.decodeRequest(z_RpcSchema.Default, {
|
|
206
269
|
method: 'wallet_switchEthereumChain',
|
|
207
270
|
params: [{ chainId: '0x1' }],
|
|
208
271
|
}),
|
|
@@ -226,10 +289,67 @@ describe('parseRequest', () => {
|
|
|
226
289
|
).success,
|
|
227
290
|
).toMatchInlineSnapshot(`false`)
|
|
228
291
|
expect(() =>
|
|
229
|
-
z_RpcSchema.
|
|
292
|
+
z_RpcSchema.decodeRequest(z_RpcSchema.Eth, {
|
|
230
293
|
method: 'eth_unknownMethod',
|
|
231
294
|
params: [],
|
|
232
295
|
} as never),
|
|
233
296
|
).toThrow()
|
|
234
297
|
})
|
|
235
298
|
})
|
|
299
|
+
|
|
300
|
+
describe('from', () => {
|
|
301
|
+
test('single method returns an Item', () => {
|
|
302
|
+
const item = z_RpcSchema.from({
|
|
303
|
+
method: 'eth_blockNumber',
|
|
304
|
+
params: z.optional(z.tuple([])),
|
|
305
|
+
returns: z.string(),
|
|
306
|
+
})
|
|
307
|
+
expect(item.method).toMatchInlineSnapshot(`"eth_blockNumber"`)
|
|
308
|
+
expect(item.request).toBeDefined()
|
|
309
|
+
})
|
|
310
|
+
|
|
311
|
+
test('namespace normalizes keyed params/returns into Items', () => {
|
|
312
|
+
const schema = z_RpcSchema.from({
|
|
313
|
+
abe_foo: {
|
|
314
|
+
params: z.tuple([z.number()]),
|
|
315
|
+
returns: z.string(),
|
|
316
|
+
},
|
|
317
|
+
})
|
|
318
|
+
|
|
319
|
+
expect(schema.abe_foo.method).toMatchInlineSnapshot(`"abe_foo"`)
|
|
320
|
+
expect(z_RpcSchema.decodeParams(schema, 'abe_foo', [1]))
|
|
321
|
+
.toMatchInlineSnapshot(`
|
|
322
|
+
[
|
|
323
|
+
1,
|
|
324
|
+
]
|
|
325
|
+
`)
|
|
326
|
+
expect(
|
|
327
|
+
z_RpcSchema.decodeReturns(schema, 'abe_foo', 'hello'),
|
|
328
|
+
).toMatchInlineSnapshot(`"hello"`)
|
|
329
|
+
expect(
|
|
330
|
+
z_RpcSchema.decodeRequest(schema, { method: 'abe_foo', params: [1] }),
|
|
331
|
+
).toMatchInlineSnapshot(`
|
|
332
|
+
{
|
|
333
|
+
"method": "abe_foo",
|
|
334
|
+
"params": [
|
|
335
|
+
1,
|
|
336
|
+
],
|
|
337
|
+
}
|
|
338
|
+
`)
|
|
339
|
+
})
|
|
340
|
+
|
|
341
|
+
test('namespace spreads existing ox/zod namespaces', () => {
|
|
342
|
+
const schema = z_RpcSchema.from({
|
|
343
|
+
...z_RpcSchema.Eth,
|
|
344
|
+
abe_foo: {
|
|
345
|
+
params: z.tuple([z.number()]),
|
|
346
|
+
returns: z.string(),
|
|
347
|
+
},
|
|
348
|
+
})
|
|
349
|
+
|
|
350
|
+
expect(schema.eth_blockNumber.method).toMatchInlineSnapshot(
|
|
351
|
+
`"eth_blockNumber"`,
|
|
352
|
+
)
|
|
353
|
+
expect(schema.abe_foo.method).toMatchInlineSnapshot(`"abe_foo"`)
|
|
354
|
+
})
|
|
355
|
+
})
|
|
@@ -7,10 +7,12 @@ import * as z_Fee from '../../Fee.js'
|
|
|
7
7
|
import * as z_Filter from '../../Filter.js'
|
|
8
8
|
import * as z_Hex from '../../Hex.js'
|
|
9
9
|
import * as z_Log from '../../Log.js'
|
|
10
|
+
import * as z_Number from '../../Number.js'
|
|
10
11
|
import * as z_StateOverrides from '../../StateOverrides.js'
|
|
11
12
|
import * as z_Transaction from '../../Transaction.js'
|
|
12
13
|
import * as z_TransactionReceipt from '../../TransactionReceipt.js'
|
|
13
14
|
import * as z_TransactionRequest from '../../TransactionRequest.js'
|
|
15
|
+
import * as z_Uint from '../../Uint.js'
|
|
14
16
|
import * as z from 'zod/mini'
|
|
15
17
|
import { from } from './from.js'
|
|
16
18
|
|
|
@@ -60,13 +62,13 @@ export const eth_accounts = from({
|
|
|
60
62
|
export const eth_blobBaseFee = from({
|
|
61
63
|
method: 'eth_blobBaseFee',
|
|
62
64
|
params: NoParams,
|
|
63
|
-
returns:
|
|
65
|
+
returns: z_Uint.Uint,
|
|
64
66
|
})
|
|
65
67
|
|
|
66
68
|
export const eth_blockNumber = from({
|
|
67
69
|
method: 'eth_blockNumber',
|
|
68
70
|
params: NoParams,
|
|
69
|
-
returns:
|
|
71
|
+
returns: z_Uint.Uint,
|
|
70
72
|
})
|
|
71
73
|
|
|
72
74
|
export const eth_call = from({
|
|
@@ -78,7 +80,7 @@ export const eth_call = from({
|
|
|
78
80
|
export const eth_chainId = from({
|
|
79
81
|
method: 'eth_chainId',
|
|
80
82
|
params: NoParams,
|
|
81
|
-
returns:
|
|
83
|
+
returns: z_Number.Number,
|
|
82
84
|
})
|
|
83
85
|
|
|
84
86
|
export const eth_coinbase = from({
|
|
@@ -90,7 +92,7 @@ export const eth_coinbase = from({
|
|
|
90
92
|
export const eth_estimateGas = from({
|
|
91
93
|
method: 'eth_estimateGas',
|
|
92
94
|
params: Call,
|
|
93
|
-
returns:
|
|
95
|
+
returns: z_Uint.Uint,
|
|
94
96
|
})
|
|
95
97
|
|
|
96
98
|
export const eth_feeHistory = from({
|
|
@@ -106,13 +108,13 @@ export const eth_feeHistory = from({
|
|
|
106
108
|
export const eth_gasPrice = from({
|
|
107
109
|
method: 'eth_gasPrice',
|
|
108
110
|
params: NoParams,
|
|
109
|
-
returns:
|
|
111
|
+
returns: z_Uint.Uint,
|
|
110
112
|
})
|
|
111
113
|
|
|
112
114
|
export const eth_getBalance = from({
|
|
113
115
|
method: 'eth_getBalance',
|
|
114
116
|
params: z.tuple([z_Address.Address, BlockNumberOrTagOrIdentifier]),
|
|
115
|
-
returns:
|
|
117
|
+
returns: z_Uint.Uint,
|
|
116
118
|
})
|
|
117
119
|
|
|
118
120
|
export const eth_getBlockByHash = from({
|
|
@@ -130,13 +132,13 @@ export const eth_getBlockByNumber = from({
|
|
|
130
132
|
export const eth_getBlockTransactionCountByHash = from({
|
|
131
133
|
method: 'eth_getBlockTransactionCountByHash',
|
|
132
134
|
params: z.tuple([z_Hex.Hex]),
|
|
133
|
-
returns:
|
|
135
|
+
returns: z_Number.Number,
|
|
134
136
|
})
|
|
135
137
|
|
|
136
138
|
export const eth_getBlockTransactionCountByNumber = from({
|
|
137
139
|
method: 'eth_getBlockTransactionCountByNumber',
|
|
138
140
|
params: z.tuple([BlockNumberOrTag]),
|
|
139
|
-
returns:
|
|
141
|
+
returns: z_Number.Number,
|
|
140
142
|
})
|
|
141
143
|
|
|
142
144
|
export const eth_getCode = from({
|
|
@@ -200,7 +202,7 @@ export const eth_getTransactionByHash = from({
|
|
|
200
202
|
export const eth_getTransactionCount = from({
|
|
201
203
|
method: 'eth_getTransactionCount',
|
|
202
204
|
params: z.tuple([z_Address.Address, BlockNumberOrTagOrIdentifier]),
|
|
203
|
-
returns:
|
|
205
|
+
returns: z_Number.Number,
|
|
204
206
|
})
|
|
205
207
|
|
|
206
208
|
export const eth_getTransactionReceipt = from({
|
|
@@ -212,19 +214,19 @@ export const eth_getTransactionReceipt = from({
|
|
|
212
214
|
export const eth_getUncleCountByBlockHash = from({
|
|
213
215
|
method: 'eth_getUncleCountByBlockHash',
|
|
214
216
|
params: z.tuple([z_Hex.Hex]),
|
|
215
|
-
returns:
|
|
217
|
+
returns: z_Number.Number,
|
|
216
218
|
})
|
|
217
219
|
|
|
218
220
|
export const eth_getUncleCountByBlockNumber = from({
|
|
219
221
|
method: 'eth_getUncleCountByBlockNumber',
|
|
220
222
|
params: z.tuple([BlockNumberOrTag]),
|
|
221
|
-
returns:
|
|
223
|
+
returns: z_Number.Number,
|
|
222
224
|
})
|
|
223
225
|
|
|
224
226
|
export const eth_maxPriorityFeePerGas = from({
|
|
225
227
|
method: 'eth_maxPriorityFeePerGas',
|
|
226
228
|
params: NoParams,
|
|
227
|
-
returns:
|
|
229
|
+
returns: z_Uint.Uint,
|
|
228
230
|
})
|
|
229
231
|
|
|
230
232
|
export const eth_newBlockFilter = from({
|
|
@@ -140,7 +140,7 @@ export const Keychain = z.object({
|
|
|
140
140
|
/** Native multisig signature envelope schema. */
|
|
141
141
|
export const Multisig = z.object({
|
|
142
142
|
account: z_Address.Address,
|
|
143
|
-
|
|
143
|
+
genesisConfigId: z_Hex.Hex,
|
|
144
144
|
init: z.optional(z_MultisigConfig.Config),
|
|
145
145
|
// `signatures` is recursive; type the getter concretely to break the cycle.
|
|
146
146
|
signatures: z.lazy(
|
|
@@ -19,6 +19,16 @@ const p256 = {
|
|
|
19
19
|
type: 'p256',
|
|
20
20
|
} as const
|
|
21
21
|
|
|
22
|
+
const multisig = {
|
|
23
|
+
account: '0xbe95c3f554e9fc85ec51be69a3d807a0d55bcf2c',
|
|
24
|
+
configId:
|
|
25
|
+
'0x0000000000000000000000000000000000000000000000000000000000000000',
|
|
26
|
+
signatures: [
|
|
27
|
+
core_SignatureEnvelope.serialize(core_SignatureEnvelope.fromRpc(secp256k1)),
|
|
28
|
+
],
|
|
29
|
+
type: 'multisig',
|
|
30
|
+
} as const
|
|
31
|
+
|
|
22
32
|
describe('SignatureEnvelope', () => {
|
|
23
33
|
test('decodes a secp256k1 envelope', () => {
|
|
24
34
|
expect(z.decode(z_SignatureEnvelope.SignatureEnvelope, secp256k1)).toEqual(
|
|
@@ -43,6 +53,12 @@ describe('SignatureEnvelope', () => {
|
|
|
43
53
|
)
|
|
44
54
|
})
|
|
45
55
|
|
|
56
|
+
test('decodes a multisig envelope', () => {
|
|
57
|
+
expect(z.decode(z_SignatureEnvelope.SignatureEnvelope, multisig)).toEqual(
|
|
58
|
+
core_SignatureEnvelope.fromRpc(multisig),
|
|
59
|
+
)
|
|
60
|
+
})
|
|
61
|
+
|
|
46
62
|
test('round-trips secp256k1 via encode', () => {
|
|
47
63
|
const decoded = z.decode(z_SignatureEnvelope.SignatureEnvelope, secp256k1)
|
|
48
64
|
expect(z.encode(z_SignatureEnvelope.SignatureEnvelope, decoded)).toEqual(
|
|
@@ -50,6 +66,13 @@ describe('SignatureEnvelope', () => {
|
|
|
50
66
|
)
|
|
51
67
|
})
|
|
52
68
|
|
|
69
|
+
test('round-trips multisig via encode', () => {
|
|
70
|
+
const decoded = z.decode(z_SignatureEnvelope.SignatureEnvelope, multisig)
|
|
71
|
+
expect(z.encode(z_SignatureEnvelope.SignatureEnvelope, decoded)).toEqual(
|
|
72
|
+
core_SignatureEnvelope.toRpc(decoded),
|
|
73
|
+
)
|
|
74
|
+
})
|
|
75
|
+
|
|
53
76
|
test('rejects an invalid envelope', () => {
|
|
54
77
|
expect(
|
|
55
78
|
z.safeDecode(z_SignatureEnvelope.SignatureEnvelope, {
|