ox 0.14.42 → 0.14.44

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.
Files changed (74) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/_cjs/tempo/MultisigConfig.js +9 -2
  3. package/_cjs/tempo/MultisigConfig.js.map +1 -1
  4. package/_cjs/tempo/MultisigSimulation.js +115 -0
  5. package/_cjs/tempo/MultisigSimulation.js.map +1 -0
  6. package/_cjs/tempo/SignatureEnvelope.js +12 -21
  7. package/_cjs/tempo/SignatureEnvelope.js.map +1 -1
  8. package/_cjs/tempo/TransactionRequest.js +7 -7
  9. package/_cjs/tempo/TransactionRequest.js.map +1 -1
  10. package/_cjs/tempo/index.js +2 -2
  11. package/_cjs/tempo/index.js.map +1 -1
  12. package/_cjs/version.js +1 -1
  13. package/_esm/tempo/MultisigConfig.js +14 -4
  14. package/_esm/tempo/MultisigConfig.js.map +1 -1
  15. package/_esm/tempo/MultisigSimulation.js +145 -0
  16. package/_esm/tempo/MultisigSimulation.js.map +1 -0
  17. package/_esm/tempo/SignatureEnvelope.js +12 -21
  18. package/_esm/tempo/SignatureEnvelope.js.map +1 -1
  19. package/_esm/tempo/TransactionRequest.js +7 -7
  20. package/_esm/tempo/TransactionRequest.js.map +1 -1
  21. package/_esm/tempo/index.js +4 -4
  22. package/_esm/tempo/index.js.map +1 -1
  23. package/_esm/version.js +1 -1
  24. package/_types/tempo/KeyAuthorization.d.ts +1 -1
  25. package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
  26. package/_types/tempo/MultisigConfig.d.ts +5 -3
  27. package/_types/tempo/MultisigConfig.d.ts.map +1 -1
  28. package/_types/tempo/MultisigOperation.d.ts +2 -2
  29. package/_types/tempo/MultisigOperation.d.ts.map +1 -1
  30. package/_types/tempo/MultisigSimulation.d.ts +132 -0
  31. package/_types/tempo/MultisigSimulation.d.ts.map +1 -0
  32. package/_types/tempo/SignatureEnvelope.d.ts +10 -34
  33. package/_types/tempo/SignatureEnvelope.d.ts.map +1 -1
  34. package/_types/tempo/TransactionRequest.d.ts +9 -9
  35. package/_types/tempo/TransactionRequest.d.ts.map +1 -1
  36. package/_types/tempo/index.d.ts +4 -4
  37. package/_types/tempo/index.d.ts.map +1 -1
  38. package/_types/version.d.ts +1 -1
  39. package/package.json +9 -9
  40. package/tempo/AuthorizationTempo.test.ts +4 -0
  41. package/tempo/KeyAuthorization.test-d.ts +1 -12
  42. package/tempo/KeyAuthorization.test.ts +37 -9
  43. package/tempo/KeyAuthorization.ts +3 -3
  44. package/tempo/MultisigConfig.test.ts +21 -5
  45. package/tempo/MultisigConfig.ts +18 -6
  46. package/tempo/MultisigOperation.test.ts +37 -37
  47. package/tempo/MultisigOperation.ts +2 -2
  48. package/tempo/MultisigSimulation/package.json +6 -0
  49. package/tempo/MultisigSimulation.test-d/package.json +6 -0
  50. package/tempo/MultisigSimulation.test-d.ts +33 -0
  51. package/tempo/MultisigSimulation.test.ts +284 -0
  52. package/tempo/MultisigSimulation.ts +266 -0
  53. package/tempo/RpcSchemaTempo.test-d.ts +4 -4
  54. package/tempo/SignatureEnvelope.test-d.ts +8 -44
  55. package/tempo/SignatureEnvelope.test.ts +106 -65
  56. package/tempo/SignatureEnvelope.ts +27 -61
  57. package/tempo/Transaction.test.ts +61 -0
  58. package/tempo/TransactionRequest.test-d.ts +9 -9
  59. package/tempo/TransactionRequest.test.ts +122 -49
  60. package/tempo/TransactionRequest.ts +20 -16
  61. package/tempo/index.ts +4 -4
  62. package/tempo/multisig.e2e.test.ts +71 -21
  63. package/version.ts +1 -1
  64. package/_cjs/tempo/MultisigWitness.js +0 -92
  65. package/_cjs/tempo/MultisigWitness.js.map +0 -1
  66. package/_esm/tempo/MultisigWitness.js +0 -123
  67. package/_esm/tempo/MultisigWitness.js.map +0 -1
  68. package/_types/tempo/MultisigWitness.d.ts +0 -106
  69. package/_types/tempo/MultisigWitness.d.ts.map +0 -1
  70. package/tempo/MultisigWitness/package.json +0 -6
  71. package/tempo/MultisigWitness.test-d/package.json +0 -6
  72. package/tempo/MultisigWitness.test-d.ts +0 -42
  73. package/tempo/MultisigWitness.test.ts +0 -289
  74. package/tempo/MultisigWitness.ts +0 -210
@@ -1,7 +1,11 @@
1
- import { type MultisigWitness, TransactionRequest } from 'ox/tempo'
1
+ import {
2
+ MultisigConfig,
3
+ type MultisigSimulation,
4
+ TransactionRequest,
5
+ } from 'ox/tempo'
2
6
  import { describe, expect, test } from 'vitest'
3
7
 
4
- const multisigWitnessRpc = {
8
+ const multisigSimulationRpc = {
5
9
  account: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
6
10
  approvals: [
7
11
  {
@@ -10,8 +14,7 @@ const multisigWitnessRpc = {
10
14
  type: 'primitive',
11
15
  },
12
16
  {
13
- type: 'multisig',
14
- witness: {
17
+ spec: {
15
18
  account: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
16
19
  approvals: [
17
20
  {
@@ -20,7 +23,25 @@ const multisigWitnessRpc = {
20
23
  owner: '0x2222222222222222222222222222222222222222',
21
24
  },
22
25
  ],
23
- config: {
26
+ config:
27
+ '0xf83ba022222222222222222222222222222222222222222222222222222222222222220101d7d694222222222222222222222222222222222222222201',
28
+ },
29
+ type: 'multisig',
30
+ },
31
+ ],
32
+ config:
33
+ '0xf852a011111111111111111111111111111111111111111111111111111111111111118002eed694111111111111111111111111111111111111111101d694bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb01',
34
+ } as const satisfies MultisigSimulation.Rpc
35
+
36
+ const multisigSimulation = {
37
+ account: multisigSimulationRpc.account,
38
+ approvals: [
39
+ multisigSimulationRpc.approvals[0],
40
+ {
41
+ spec: {
42
+ account: multisigSimulationRpc.approvals[1].spec.account,
43
+ approvals: multisigSimulationRpc.approvals[1].spec.approvals,
44
+ config: MultisigConfig.from({
24
45
  owners: [
25
46
  {
26
47
  owner: '0x2222222222222222222222222222222222222222',
@@ -29,12 +50,13 @@ const multisigWitnessRpc = {
29
50
  ],
30
51
  salt: `0x${'22'.repeat(32)}`,
31
52
  threshold: 1,
32
- version: 1,
33
- },
53
+ version: 1n,
54
+ }),
34
55
  },
56
+ type: 'multisig',
35
57
  },
36
58
  ],
37
- config: {
59
+ config: MultisigConfig.from({
38
60
  owners: [
39
61
  {
40
62
  owner: '0x1111111111111111111111111111111111111111',
@@ -47,27 +69,8 @@ const multisigWitnessRpc = {
47
69
  ],
48
70
  salt: `0x${'11'.repeat(32)}`,
49
71
  threshold: 2,
50
- version: 0,
51
- },
52
- } as const satisfies MultisigWitness.Rpc
53
-
54
- const multisigWitness = {
55
- ...multisigWitnessRpc,
56
- approvals: [
57
- multisigWitnessRpc.approvals[0],
58
- {
59
- ...multisigWitnessRpc.approvals[1],
60
- witness: {
61
- ...multisigWitnessRpc.approvals[1].witness,
62
- config: {
63
- ...multisigWitnessRpc.approvals[1].witness.config,
64
- version: 1n,
65
- },
66
- },
67
- },
68
- ],
69
- config: { ...multisigWitnessRpc.config, version: 0n },
70
- } as const satisfies MultisigWitness.MultisigWitness
72
+ }),
73
+ } as const satisfies MultisigSimulation.Spec
71
74
 
72
75
  describe('fromRpc', () => {
73
76
  test('default', () => {
@@ -137,19 +140,64 @@ describe('fromRpc', () => {
137
140
  expect(request.nonceKey).toBe(255n)
138
141
  })
139
142
 
140
- test('behavior: multisig witness', () => {
143
+ test('behavior: multisig simulation', () => {
141
144
  const request = TransactionRequest.fromRpc({
142
145
  from: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
143
- multisigWitness: multisigWitnessRpc,
146
+ multisigSimulation: multisigSimulationRpc,
144
147
  type: '0x76',
145
148
  })
146
149
 
147
- expect(request.multisigWitness?.config.version).toBe(0n)
148
- const nested = request.multisigWitness?.approvals[1]
149
- expect(nested?.type).toBe('multisig')
150
- if (nested?.type !== 'multisig') throw new Error('expected multisig')
151
- expect(nested.witness.config.version).toBe(1n)
152
- expect(nested.witness.approvals[0]?.keyType).toBe('webAuthn')
150
+ expect(request.multisigSimulation).toMatchInlineSnapshot(`
151
+ {
152
+ "account": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
153
+ "approvals": [
154
+ {
155
+ "keyType": "secp256k1",
156
+ "owner": "0x1111111111111111111111111111111111111111",
157
+ "type": "primitive",
158
+ },
159
+ {
160
+ "spec": {
161
+ "account": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
162
+ "approvals": [
163
+ {
164
+ "keyData": "0x0578",
165
+ "keyType": "webAuthn",
166
+ "owner": "0x2222222222222222222222222222222222222222",
167
+ },
168
+ ],
169
+ "config": {
170
+ "owners": [
171
+ {
172
+ "owner": "0x2222222222222222222222222222222222222222",
173
+ "weight": 1,
174
+ },
175
+ ],
176
+ "salt": "0x2222222222222222222222222222222222222222222222222222222222222222",
177
+ "threshold": 1,
178
+ "version": 1n,
179
+ },
180
+ },
181
+ "type": "multisig",
182
+ },
183
+ ],
184
+ "config": {
185
+ "owners": [
186
+ {
187
+ "owner": "0x1111111111111111111111111111111111111111",
188
+ "weight": 1,
189
+ },
190
+ {
191
+ "owner": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
192
+ "weight": 1,
193
+ },
194
+ ],
195
+ "salt": "0x1111111111111111111111111111111111111111111111111111111111111111",
196
+ "threshold": 2,
197
+ "version": 0n,
198
+ },
199
+ }
200
+ `)
153
201
  })
154
202
 
155
203
  test('behavior: empty', () => {
@@ -206,18 +254,43 @@ describe('toRpc', () => {
206
254
  `)
207
255
  })
208
256
 
209
- test('behavior: multisig witness', () => {
257
+ test('behavior: multisig simulation', () => {
210
258
  const request = TransactionRequest.toRpc({
211
259
  from: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
212
- multisigWitness,
260
+ multisigSimulation,
213
261
  })
214
262
 
215
- expect(request.multisigWitness?.config.version).toBe(0)
216
- const nested = request.multisigWitness?.approvals[1]
217
- expect(nested?.type).toBe('multisig')
218
- if (nested?.type !== 'multisig') throw new Error('expected multisig')
219
- expect(nested.witness.config.version).toBe(1)
220
- expect(request.type).toBe('0x76')
263
+ expect(request).toMatchInlineSnapshot(`
264
+ {
265
+ "from": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
266
+ "multisigSimulation": {
267
+ "account": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
268
+ "approvals": [
269
+ {
270
+ "keyType": "secp256k1",
271
+ "owner": "0x1111111111111111111111111111111111111111",
272
+ "type": "primitive",
273
+ },
274
+ {
275
+ "spec": {
276
+ "account": "0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
277
+ "approvals": [
278
+ {
279
+ "keyData": "0x0578",
280
+ "keyType": "webAuthn",
281
+ "owner": "0x2222222222222222222222222222222222222222",
282
+ },
283
+ ],
284
+ "config": "0xf83ba022222222222222222222222222222222222222222222222222222222222222220101d7d694222222222222222222222222222222222222222201",
285
+ },
286
+ "type": "multisig",
287
+ },
288
+ ],
289
+ "config": "0xf852a011111111111111111111111111111111111111111111111111111111111111118002eed694111111111111111111111111111111111111111101d694bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb01",
290
+ },
291
+ "type": "0x76",
292
+ }
293
+ `)
221
294
  })
222
295
  })
223
296
 
@@ -241,7 +314,7 @@ describe('roundtrip', () => {
241
314
  nonceKey: 255n,
242
315
  gas: 100000n,
243
316
  maxFeePerGas: 1000000000n,
244
- multisigWitness,
317
+ multisigSimulation,
245
318
  }
246
319
 
247
320
  const rpc = TransactionRequest.toRpc(original)
@@ -262,7 +335,7 @@ describe('roundtrip', () => {
262
335
  expect(converted.nonceKey).toBe(original.nonceKey)
263
336
  expect(converted.gas).toBe(original.gas)
264
337
  expect(converted.maxFeePerGas).toBe(original.maxFeePerGas)
265
- expect(converted.multisigWitness).toEqual(original.multisigWitness)
338
+ expect(converted.multisigSimulation).toEqual(original.multisigSimulation)
266
339
  expect(converted.type).toBe('tempo')
267
340
  })
268
341
 
@@ -280,7 +353,7 @@ describe('roundtrip', () => {
280
353
  validAfter: '0x32',
281
354
  nonceKey: '0xff',
282
355
  gas: '0x186a0',
283
- multisigWitness: multisigWitnessRpc,
356
+ multisigSimulation: multisigSimulationRpc,
284
357
  type: '0x76',
285
358
  }
286
359
 
@@ -293,7 +366,7 @@ describe('roundtrip', () => {
293
366
  expect(rpc.validAfter).toBe(original.validAfter)
294
367
  expect(rpc.nonceKey).toBe(original.nonceKey)
295
368
  expect(rpc.gas).toBe(original.gas)
296
- expect(rpc.multisigWitness).toEqual(original.multisigWitness)
369
+ expect(rpc.multisigSimulation).toEqual(original.multisigSimulation)
297
370
  expect(rpc.type).toBe('0x76')
298
371
  })
299
372
  })
@@ -4,7 +4,7 @@ import type { Compute } from '../core/internal/types.js'
4
4
  import * as ox_TransactionRequest from '../core/TransactionRequest.js'
5
5
  import * as AuthorizationTempo from './AuthorizationTempo.js'
6
6
  import * as KeyAuthorization from './KeyAuthorization.js'
7
- import * as MultisigWitness from './MultisigWitness.js'
7
+ import * as MultisigSimulation from './MultisigSimulation.js'
8
8
  import * as TempoAddress from './TempoAddress.js'
9
9
  import * as TokenId from './TokenId.js'
10
10
  import * as Transaction from './Transaction.js'
@@ -34,27 +34,27 @@ export type TransactionRequest<
34
34
  | AuthorizationTempo.ListSigned<bigintType, numberType>
35
35
  | undefined
36
36
  calls?: readonly Call<bigintType, addressType>[] | undefined
37
+ feePayer?: boolean | undefined
38
+ feeToken?: TokenId.TokenIdOrAddress<addressType> | undefined
37
39
  keyAuthorization?: KeyAuthorization.KeyAuthorization<true> | undefined
38
40
  keyData?: Hex.Hex | undefined
39
41
  keyType?: KeyType | undefined
40
- feePayer?: boolean | undefined
41
- feeToken?: TokenId.TokenIdOrAddress<addressType> | undefined
42
- multisigWitness?: MultisigWitness.MultisigWitness<bigintType> | undefined
42
+ multisigSimulation?: MultisigSimulation.Spec | undefined
43
43
  nonceKey?: 'random' | bigintType | undefined
44
- validBefore?: numberType | undefined
45
44
  validAfter?: numberType | undefined
45
+ validBefore?: numberType | undefined
46
46
  }
47
47
  >
48
48
 
49
49
  /** RPC representation of a {@link ox#TransactionRequest.TransactionRequest}. */
50
50
  export type Rpc = Omit<
51
51
  TransactionRequest<Hex.Hex, Hex.Hex, string, Hex.Hex>,
52
- 'authorizationList' | 'feeToken' | 'keyAuthorization' | 'multisigWitness'
52
+ 'authorizationList' | 'feeToken' | 'keyAuthorization' | 'multisigSimulation'
53
53
  > & {
54
54
  authorizationList?: AuthorizationTempo.ListRpc | undefined
55
55
  feeToken?: Hex.Hex | undefined
56
56
  keyAuthorization?: KeyAuthorization.Rpc | undefined
57
- multisigWitness?: MultisigWitness.Rpc | undefined
57
+ multisigSimulation?: MultisigSimulation.Rpc | undefined
58
58
  nonceKey?: Hex.Hex | undefined
59
59
  }
60
60
 
@@ -79,7 +79,7 @@ export type Rpc = Omit<
79
79
  * @returns A transaction request.
80
80
  */
81
81
  export function fromRpc(request: Rpc): TransactionRequest {
82
- const { authorizationList: _, multisigWitness: __, ...rest } = request
82
+ const { authorizationList: _, multisigSimulation: __, ...rest } = request
83
83
  const request_ = ox_TransactionRequest.fromRpc(
84
84
  rest as any,
85
85
  ) as TransactionRequest
@@ -110,8 +110,10 @@ export function fromRpc(request: Rpc): TransactionRequest {
110
110
  request_.keyAuthorization = KeyAuthorization.fromRpc(
111
111
  request.keyAuthorization,
112
112
  )
113
- if (request.multisigWitness)
114
- request_.multisigWitness = MultisigWitness.fromRpc(request.multisigWitness)
113
+ if (request.multisigSimulation)
114
+ request_.multisigSimulation = MultisigSimulation.fromRpc(
115
+ request.multisigSimulation,
116
+ )
115
117
  if (typeof request.validBefore !== 'undefined')
116
118
  request_.validBefore = Hex.toNumber(request.validBefore as Hex.Hex)
117
119
  if (typeof request.validAfter !== 'undefined')
@@ -125,9 +127,9 @@ export function fromRpc(request: Rpc): TransactionRequest {
125
127
  export declare namespace fromRpc {
126
128
  export type ErrorType =
127
129
  | AuthorizationTempo.fromRpcList.ErrorType
128
- | MultisigWitness.fromRpc.ErrorType
129
- | Hex.toNumber.ErrorType
130
130
  | Hex.toBigInt.ErrorType
131
+ | Hex.toNumber.ErrorType
132
+ | MultisigSimulation.fromRpc.ErrorType
131
133
  | Errors.GlobalErrorType
132
134
  }
133
135
 
@@ -210,8 +212,10 @@ export function toRpc(request: TransactionRequest): Rpc {
210
212
  request_rpc.keyAuthorization = KeyAuthorization.toRpc(
211
213
  request.keyAuthorization,
212
214
  )
213
- if (request.multisigWitness)
214
- request_rpc.multisigWitness = MultisigWitness.toRpc(request.multisigWitness)
215
+ if (request.multisigSimulation)
216
+ request_rpc.multisigSimulation = MultisigSimulation.toRpc(
217
+ request.multisigSimulation,
218
+ )
215
219
  if (typeof request.validBefore !== 'undefined')
216
220
  request_rpc.validBefore = Hex.fromNumber(request.validBefore)
217
221
  if (typeof request.validAfter !== 'undefined')
@@ -230,7 +234,7 @@ export function toRpc(request: TransactionRequest): Rpc {
230
234
  typeof request.feePayer !== 'undefined' ||
231
235
  typeof request.feeToken !== 'undefined' ||
232
236
  typeof request.keyAuthorization !== 'undefined' ||
233
- typeof request.multisigWitness !== 'undefined' ||
237
+ typeof request.multisigSimulation !== 'undefined' ||
234
238
  typeof request.nonceKey !== 'undefined' ||
235
239
  typeof request.validBefore !== 'undefined' ||
236
240
  typeof request.validAfter !== 'undefined' ||
@@ -249,7 +253,7 @@ export function toRpc(request: TransactionRequest): Rpc {
249
253
  export declare namespace toRpc {
250
254
  export type ErrorType =
251
255
  | AuthorizationTempo.toRpcList.ErrorType
252
- | MultisigWitness.toRpc.ErrorType
256
+ | MultisigSimulation.toRpc.ErrorType
253
257
  | Hex.fromNumber.ErrorType
254
258
  | Errors.GlobalErrorType
255
259
  }
package/tempo/index.ts CHANGED
@@ -160,14 +160,14 @@ export * as MultisigConfig from './MultisigConfig.js'
160
160
  */
161
161
  export * as MultisigOperation from './MultisigOperation.js'
162
162
  /**
163
- * Native multisig RPC simulation witness utilities.
163
+ * Native multisig RPC simulation utilities.
164
164
  *
165
- * Converts complete root and nested owner witnesses between their domain and
166
- * Tempo JSON-RPC representations.
165
+ * Converts complete root and nested owner specs between their domain and Tempo
166
+ * JSON-RPC representations.
167
167
  *
168
168
  * @category Reference
169
169
  */
170
- export * as MultisigWitness from './MultisigWitness.js'
170
+ export * as MultisigSimulation from './MultisigSimulation.js'
171
171
  /**
172
172
  * Utilities for constructing period durations (in seconds) for recurring spending limits.
173
173
  *
@@ -2,7 +2,12 @@ import { AbiFunction, Address, Hex, Secp256k1, Value } from 'ox'
2
2
  import { getTransactionCount } from 'viem/actions'
3
3
  import { describe, expect, test } from 'vitest'
4
4
  import { chain, client, fundAddress } from '../../test/tempo/config.js'
5
- import { KeyAuthorization, MultisigConfig, SignatureEnvelope } from './index.js'
5
+ import {
6
+ KeyAuthorization,
7
+ MultisigConfig,
8
+ SignatureEnvelope,
9
+ TransactionRequest,
10
+ } from './index.js'
6
11
  import * as Transaction from './Transaction.js'
7
12
  import * as TransactionReceipt from './TransactionReceipt.js'
8
13
  import * as TxEnvelopeTempo from './TxEnvelopeTempo.js'
@@ -135,6 +140,51 @@ describe('behavior: multisig (TIP-1061)', () => {
135
140
  })
136
141
  }
137
142
 
143
+ test('behavior: fills a multisig simulation', async () => {
144
+ const { account, initialConfig, ownerKeys } = setup({
145
+ count: 2,
146
+ threshold: 2,
147
+ })
148
+ await fundAddress(client, { address: account })
149
+
150
+ const request = TransactionRequest.toRpc({
151
+ calls: [{ to: '0x0000000000000000000000000000000000000000' }],
152
+ from: account,
153
+ multisigSimulation: {
154
+ account,
155
+ approvals: ownerKeys.map((owner) => ({
156
+ keyType: 'secp256k1',
157
+ owner: owner.address,
158
+ type: 'primitive',
159
+ })),
160
+ config: initialConfig,
161
+ },
162
+ })
163
+ expect(request.multisigSimulation?.config).toBeTypeOf('string')
164
+
165
+ const response = await client.request({
166
+ method: 'eth_fillTransaction',
167
+ params: [request as never],
168
+ })
169
+ const transaction = TransactionRequest.fromRpc(
170
+ response.tx as TransactionRequest.Rpc,
171
+ )
172
+
173
+ expect(Hex.validate(response.raw)).toBe(true)
174
+ expect(transaction.calls).toHaveLength(1)
175
+ expect(transaction.calls?.[0]?.to).toBe(
176
+ '0x0000000000000000000000000000000000000000',
177
+ )
178
+ expect(transaction.chainId).toBe(chainId)
179
+ expect(transaction.feeToken).toBeNull()
180
+ expect(transaction.gas).toBeGreaterThan(0n)
181
+ expect(transaction.maxFeePerGas).toBeTypeOf('bigint')
182
+ expect(transaction.maxPriorityFeePerGas).toBeTypeOf('bigint')
183
+ expect(transaction.nonce ?? 0n).toBe(0n)
184
+ expect(transaction.nonceKey ?? 0n).toBe(0n)
185
+ expect(transaction.type).toBe('tempo')
186
+ })
187
+
138
188
  test('examples: bootstrap, initialized, and configuration rotation', async () => {
139
189
  const { account, initialConfig, ownerKeys } = setup({
140
190
  count: 3,
@@ -601,30 +651,30 @@ describe('behavior: multisig (TIP-1061)', () => {
601
651
  .then((tx) => TransactionReceipt.fromRpc(tx as any)))!
602
652
  expect(bootstrap_receipt.status).toBe('success')
603
653
 
604
- // Multisig accounts authorize access keys through AccountKeychain.
605
- const authorizeKey = AbiFunction.from(
606
- 'function authorizeKey(address keyId, uint8 signatureType, (uint64 expiry, bool enforceLimits, (address token, uint256 amount, uint64 period)[] limits, bool allowAnyCalls, (address target, (bytes4 selector, address[] recipients)[] selectorRules)[] allowedCalls) config)',
607
- )
654
+ const keyAuthorization = KeyAuthorization.from({
655
+ account,
656
+ address: access.address,
657
+ chainId: BigInt(chainId),
658
+ isAdmin: false,
659
+ type: 'secp256k1',
660
+ })
661
+ const keyAuthorizationSigned = KeyAuthorization.from(keyAuthorization, {
662
+ signature: SignatureEnvelope.from({
663
+ account,
664
+ config: initialConfig,
665
+ signatures: approve({
666
+ config: initialConfig,
667
+ payload: KeyAuthorization.getSignPayload(keyAuthorization),
668
+ signers: ownerKeys,
669
+ }),
670
+ }),
671
+ })
608
672
 
609
673
  const authorize = TxEnvelopeTempo.from({
610
- calls: [
611
- {
612
- to: '0xaaaaaaaa00000000000000000000000000000000',
613
- data: AbiFunction.encodeData(authorizeKey, [
614
- access.address,
615
- 0, // secp256k1
616
- {
617
- expiry: 18446744073709551615n, // u64 max (never expires)
618
- enforceLimits: false,
619
- limits: [],
620
- allowAnyCalls: true,
621
- allowedCalls: [],
622
- },
623
- ]),
624
- },
625
- ],
674
+ calls: [{ to: '0x0000000000000000000000000000000000000000' }],
626
675
  chainId,
627
676
  feeToken: '0x20c0000000000000000000000000000000000001',
677
+ keyAuthorization: keyAuthorizationSigned,
628
678
  nonce: 1n,
629
679
  gas: 5_000_000n,
630
680
  maxFeePerGas: Value.fromGwei('20'),
package/version.ts CHANGED
@@ -1,2 +1,2 @@
1
1
  /** @internal */
2
- export const version = '0.14.42'
2
+ export const version = '0.14.44'
@@ -1,92 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.InvalidWitnessError = void 0;
4
- exports.fromRpc = fromRpc;
5
- exports.toRpc = toRpc;
6
- const Errors = require("../core/Errors.js");
7
- const Hex = require("../core/Hex.js");
8
- const MultisigConfig = require("./MultisigConfig.js");
9
- function fromRpc(witness) {
10
- const { account, approvals, config } = witness;
11
- assertApprovalCount(approvals);
12
- return {
13
- account,
14
- approvals: approvals.map((approval) => {
15
- if (approval.type === 'primitive')
16
- return approval;
17
- assertApprovalCount(approval.witness.approvals);
18
- return {
19
- type: 'multisig',
20
- witness: {
21
- account: approval.witness.account,
22
- approvals: approval.witness.approvals,
23
- config: MultisigConfig.from(approval.witness.config),
24
- },
25
- };
26
- }),
27
- config: MultisigConfig.from(config),
28
- };
29
- }
30
- function toRpc(witness) {
31
- const { account, approvals, config } = witness;
32
- assertApprovalCount(approvals);
33
- return {
34
- account,
35
- approvals: approvals.map((approval) => {
36
- if (approval.type === 'primitive')
37
- return {
38
- ...approval,
39
- ...(typeof approval.keyData !== 'undefined'
40
- ? { keyData: shimKeyData(approval.keyData) }
41
- : {}),
42
- };
43
- assertApprovalCount(approval.witness.approvals);
44
- return {
45
- type: 'multisig',
46
- witness: {
47
- account: approval.witness.account,
48
- approvals: approval.witness.approvals.map((approval) => ({
49
- ...approval,
50
- ...(typeof approval.keyData !== 'undefined'
51
- ? { keyData: shimKeyData(approval.keyData) }
52
- : {}),
53
- })),
54
- config: configToRpc(approval.witness.config),
55
- },
56
- };
57
- }),
58
- config: configToRpc(config),
59
- };
60
- }
61
- function assertApprovalCount(approvals) {
62
- if (approvals.length > MultisigConfig.maxSignatures)
63
- throw new InvalidWitnessError({
64
- reason: `approval count exceeds ${MultisigConfig.maxSignatures}`,
65
- });
66
- }
67
- function configToRpc(config) {
68
- const value = MultisigConfig.from(config);
69
- return {
70
- ...value,
71
- version: Hex.toNumber(Hex.fromNumber(Number(value.version))),
72
- };
73
- }
74
- function shimKeyData(data) {
75
- const size = Hex.size(data);
76
- if (size <= 4)
77
- return data;
78
- return Hex.fromNumber(size, { size: 2 });
79
- }
80
- class InvalidWitnessError extends Errors.BaseError {
81
- constructor(options) {
82
- super(`Invalid multisig witness: ${options.reason}.`);
83
- Object.defineProperty(this, "name", {
84
- enumerable: true,
85
- configurable: true,
86
- writable: true,
87
- value: 'MultisigWitness.InvalidWitnessError'
88
- });
89
- }
90
- }
91
- exports.InvalidWitnessError = InvalidWitnessError;
92
- //# sourceMappingURL=MultisigWitness.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MultisigWitness.js","sourceRoot":"","sources":["../../tempo/MultisigWitness.ts"],"names":[],"mappings":";;;AA+EA,0BAmBC;AAwBD,sBA8BC;AAvJD,4CAA2C;AAC3C,sCAAqC;AAErC,sDAAqD;AA2ErD,SAAgB,OAAO,CAAC,OAAY;IAClC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,GAAG,OAAO,CAAA;IAC9C,mBAA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