ox 0.14.44 → 0.14.45

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 (66) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/_cjs/tempo/KeyAuthorization.js +43 -10
  3. package/_cjs/tempo/KeyAuthorization.js.map +1 -1
  4. package/_cjs/tempo/MultisigConfig.js +33 -11
  5. package/_cjs/tempo/MultisigConfig.js.map +1 -1
  6. package/_cjs/tempo/MultisigOperation.js +18 -94
  7. package/_cjs/tempo/MultisigOperation.js.map +1 -1
  8. package/_cjs/tempo/MultisigSimulation.js +18 -46
  9. package/_cjs/tempo/MultisigSimulation.js.map +1 -1
  10. package/_cjs/tempo/SignatureEnvelope.js +72 -109
  11. package/_cjs/tempo/SignatureEnvelope.js.map +1 -1
  12. package/_cjs/tempo/TransactionRequest.js +5 -1
  13. package/_cjs/tempo/TransactionRequest.js.map +1 -1
  14. package/_cjs/tempo/index.js.map +1 -1
  15. package/_cjs/version.js +1 -1
  16. package/_esm/tempo/KeyAuthorization.js +42 -9
  17. package/_esm/tempo/KeyAuthorization.js.map +1 -1
  18. package/_esm/tempo/MultisigConfig.js +41 -22
  19. package/_esm/tempo/MultisigConfig.js.map +1 -1
  20. package/_esm/tempo/MultisigOperation.js +20 -100
  21. package/_esm/tempo/MultisigOperation.js.map +1 -1
  22. package/_esm/tempo/MultisigSimulation.js +18 -46
  23. package/_esm/tempo/MultisigSimulation.js.map +1 -1
  24. package/_esm/tempo/SignatureEnvelope.js +107 -169
  25. package/_esm/tempo/SignatureEnvelope.js.map +1 -1
  26. package/_esm/tempo/TransactionRequest.js +5 -1
  27. package/_esm/tempo/TransactionRequest.js.map +1 -1
  28. package/_esm/tempo/index.js +3 -1
  29. package/_esm/tempo/index.js.map +1 -1
  30. package/_esm/version.js +1 -1
  31. package/_types/tempo/KeyAuthorization.d.ts +48 -38
  32. package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
  33. package/_types/tempo/MultisigConfig.d.ts +15 -14
  34. package/_types/tempo/MultisigConfig.d.ts.map +1 -1
  35. package/_types/tempo/MultisigOperation.d.ts +3 -2
  36. package/_types/tempo/MultisigOperation.d.ts.map +1 -1
  37. package/_types/tempo/MultisigSimulation.d.ts +2 -49
  38. package/_types/tempo/MultisigSimulation.d.ts.map +1 -1
  39. package/_types/tempo/SignatureEnvelope.d.ts +69 -128
  40. package/_types/tempo/SignatureEnvelope.d.ts.map +1 -1
  41. package/_types/tempo/TransactionRequest.d.ts +5 -2
  42. package/_types/tempo/TransactionRequest.d.ts.map +1 -1
  43. package/_types/tempo/index.d.ts +3 -1
  44. package/_types/tempo/index.d.ts.map +1 -1
  45. package/_types/version.d.ts +1 -1
  46. package/package.json +1 -1
  47. package/tempo/AuthorizationTempo.test.ts +8 -4
  48. package/tempo/KeyAuthorization.test-d.ts +68 -33
  49. package/tempo/KeyAuthorization.test.ts +89 -8
  50. package/tempo/KeyAuthorization.ts +124 -61
  51. package/tempo/MultisigConfig.test.ts +34 -26
  52. package/tempo/MultisigConfig.ts +54 -24
  53. package/tempo/MultisigOperation.test.ts +79 -550
  54. package/tempo/MultisigOperation.ts +31 -146
  55. package/tempo/MultisigSimulation.test-d.ts +2 -2
  56. package/tempo/MultisigSimulation.test.ts +21 -110
  57. package/tempo/MultisigSimulation.ts +25 -99
  58. package/tempo/SignatureEnvelope.test-d.ts +29 -67
  59. package/tempo/SignatureEnvelope.test.ts +301 -568
  60. package/tempo/SignatureEnvelope.ts +156 -274
  61. package/tempo/TransactionRequest.test-d.ts +6 -5
  62. package/tempo/TransactionRequest.test.ts +17 -80
  63. package/tempo/TransactionRequest.ts +23 -3
  64. package/tempo/index.ts +3 -1
  65. package/tempo/multisig.e2e.test.ts +322 -861
  66. package/version.ts +1 -1
@@ -10,11 +10,12 @@ test('transaction requests use domain multisig simulation specs', () => {
10
10
  bigint | undefined
11
11
  >()
12
12
 
13
- const approval = request.multisigSimulation?.approvals[0]
14
- if (approval?.type === 'multisig')
15
- expectTypeOf(approval.spec.approvals[0]?.keyType).toEqualTypeOf<
16
- MultisigSimulation.NestedPrimitiveApproval['keyType']
17
- >()
13
+ expectTypeOf(request.multisigSimulation?.approvals[0]?.keyType).toEqualTypeOf<
14
+ MultisigSimulation.PrimitiveApproval['keyType']
15
+ >()
16
+ expectTypeOf(request.keyAuthorizationSimulation).toEqualTypeOf<
17
+ MultisigSimulation.Spec | undefined
18
+ >()
18
19
  })
19
20
 
20
21
  test('RPC requests use encoded multisig configurations', () => {
@@ -6,27 +6,11 @@ import {
6
6
  import { describe, expect, test } from 'vitest'
7
7
 
8
8
  const multisigSimulationRpc = {
9
- account: '0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa',
10
9
  approvals: [
11
10
  {
12
- keyType: 'secp256k1',
11
+ keyType: 'webAuthn',
12
+ keyData: '0x0005',
13
13
  owner: '0x1111111111111111111111111111111111111111',
14
- type: 'primitive',
15
- },
16
- {
17
- spec: {
18
- account: '0xbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb',
19
- approvals: [
20
- {
21
- keyData: '0x0578',
22
- keyType: 'webAuthn',
23
- owner: '0x2222222222222222222222222222222222222222',
24
- },
25
- ],
26
- config:
27
- '0xf83ba022222222222222222222222222222222222222222222222222222222222222220101d7d694222222222222222222222222222222222222222201',
28
- },
29
- type: 'multisig',
30
14
  },
31
15
  ],
32
16
  config:
@@ -34,26 +18,11 @@ const multisigSimulationRpc = {
34
18
  } as const satisfies MultisigSimulation.Rpc
35
19
 
36
20
  const multisigSimulation = {
37
- account: multisigSimulationRpc.account,
38
21
  approvals: [
39
- multisigSimulationRpc.approvals[0],
40
22
  {
41
- spec: {
42
- account: multisigSimulationRpc.approvals[1].spec.account,
43
- approvals: multisigSimulationRpc.approvals[1].spec.approvals,
44
- config: MultisigConfig.from({
45
- owners: [
46
- {
47
- owner: '0x2222222222222222222222222222222222222222',
48
- weight: 1,
49
- },
50
- ],
51
- salt: `0x${'22'.repeat(32)}`,
52
- threshold: 1,
53
- version: 1n,
54
- }),
55
- },
56
- type: 'multisig',
23
+ keyType: 'webAuthn',
24
+ keyData: '0x0005',
25
+ owner: '0x1111111111111111111111111111111111111111',
57
26
  },
58
27
  ],
59
28
  config: MultisigConfig.from({
@@ -149,36 +118,11 @@ describe('fromRpc', () => {
149
118
 
150
119
  expect(request.multisigSimulation).toMatchInlineSnapshot(`
151
120
  {
152
- "account": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
153
121
  "approvals": [
154
122
  {
155
- "keyType": "secp256k1",
123
+ "keyData": "0x0005",
124
+ "keyType": "webAuthn",
156
125
  "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
126
  },
183
127
  ],
184
128
  "config": {
@@ -264,26 +208,11 @@ describe('toRpc', () => {
264
208
  {
265
209
  "from": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
266
210
  "multisigSimulation": {
267
- "account": "0xaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
268
211
  "approvals": [
269
212
  {
270
- "keyType": "secp256k1",
213
+ "keyData": "0x0005",
214
+ "keyType": "webAuthn",
271
215
  "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
216
  },
288
217
  ],
289
218
  "config": "0xf852a011111111111111111111111111111111111111111111111111111111111111118002eed694111111111111111111111111111111111111111101d694bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb01",
@@ -314,6 +243,7 @@ describe('roundtrip', () => {
314
243
  nonceKey: 255n,
315
244
  gas: 100000n,
316
245
  maxFeePerGas: 1000000000n,
246
+ keyAuthorizationSimulation: multisigSimulation,
317
247
  multisigSimulation,
318
248
  }
319
249
 
@@ -335,6 +265,9 @@ describe('roundtrip', () => {
335
265
  expect(converted.nonceKey).toBe(original.nonceKey)
336
266
  expect(converted.gas).toBe(original.gas)
337
267
  expect(converted.maxFeePerGas).toBe(original.maxFeePerGas)
268
+ expect(converted.keyAuthorizationSimulation).toEqual(
269
+ original.keyAuthorizationSimulation,
270
+ )
338
271
  expect(converted.multisigSimulation).toEqual(original.multisigSimulation)
339
272
  expect(converted.type).toBe('tempo')
340
273
  })
@@ -353,6 +286,7 @@ describe('roundtrip', () => {
353
286
  validAfter: '0x32',
354
287
  nonceKey: '0xff',
355
288
  gas: '0x186a0',
289
+ keyAuthorizationSimulation: multisigSimulationRpc,
356
290
  multisigSimulation: multisigSimulationRpc,
357
291
  type: '0x76',
358
292
  }
@@ -366,6 +300,9 @@ describe('roundtrip', () => {
366
300
  expect(rpc.validAfter).toBe(original.validAfter)
367
301
  expect(rpc.nonceKey).toBe(original.nonceKey)
368
302
  expect(rpc.gas).toBe(original.gas)
303
+ expect(rpc.keyAuthorizationSimulation).toEqual(
304
+ original.keyAuthorizationSimulation,
305
+ )
369
306
  expect(rpc.multisigSimulation).toEqual(original.multisigSimulation)
370
307
  expect(rpc.type).toBe('0x76')
371
308
  })
@@ -5,12 +5,13 @@ 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
7
  import * as MultisigSimulation from './MultisigSimulation.js'
8
+ import type * as SignatureEnvelope from './SignatureEnvelope.js'
8
9
  import * as TempoAddress from './TempoAddress.js'
9
10
  import * as TokenId from './TokenId.js'
10
11
  import * as Transaction from './Transaction.js'
11
12
  import type { Call } from './TxEnvelopeTempo.js'
12
13
 
13
- type KeyType = 'secp256k1' | 'p256' | 'webAuthn'
14
+ type KeyType = SignatureEnvelope.Type | 'multisig'
14
15
 
15
16
  /**
16
17
  * A Transaction Request that is generic to all transaction types.
@@ -37,6 +38,7 @@ export type TransactionRequest<
37
38
  feePayer?: boolean | undefined
38
39
  feeToken?: TokenId.TokenIdOrAddress<addressType> | undefined
39
40
  keyAuthorization?: KeyAuthorization.KeyAuthorization<true> | undefined
41
+ keyAuthorizationSimulation?: MultisigSimulation.Spec | undefined
40
42
  keyData?: Hex.Hex | undefined
41
43
  keyType?: KeyType | undefined
42
44
  multisigSimulation?: MultisigSimulation.Spec | undefined
@@ -49,11 +51,16 @@ export type TransactionRequest<
49
51
  /** RPC representation of a {@link ox#TransactionRequest.TransactionRequest}. */
50
52
  export type Rpc = Omit<
51
53
  TransactionRequest<Hex.Hex, Hex.Hex, string, Hex.Hex>,
52
- 'authorizationList' | 'feeToken' | 'keyAuthorization' | 'multisigSimulation'
54
+ | 'authorizationList'
55
+ | 'feeToken'
56
+ | 'keyAuthorization'
57
+ | 'multisigSimulation'
58
+ | 'keyAuthorizationSimulation'
53
59
  > & {
54
60
  authorizationList?: AuthorizationTempo.ListRpc | undefined
55
61
  feeToken?: Hex.Hex | undefined
56
62
  keyAuthorization?: KeyAuthorization.Rpc | undefined
63
+ keyAuthorizationSimulation?: MultisigSimulation.Rpc | undefined
57
64
  multisigSimulation?: MultisigSimulation.Rpc | undefined
58
65
  nonceKey?: Hex.Hex | undefined
59
66
  }
@@ -79,7 +86,12 @@ export type Rpc = Omit<
79
86
  * @returns A transaction request.
80
87
  */
81
88
  export function fromRpc(request: Rpc): TransactionRequest {
82
- const { authorizationList: _, multisigSimulation: __, ...rest } = request
89
+ const {
90
+ authorizationList: _,
91
+ multisigSimulation: __,
92
+ keyAuthorizationSimulation: ___,
93
+ ...rest
94
+ } = request
83
95
  const request_ = ox_TransactionRequest.fromRpc(
84
96
  rest as any,
85
97
  ) as TransactionRequest
@@ -110,6 +122,10 @@ export function fromRpc(request: Rpc): TransactionRequest {
110
122
  request_.keyAuthorization = KeyAuthorization.fromRpc(
111
123
  request.keyAuthorization,
112
124
  )
125
+ if (request.keyAuthorizationSimulation)
126
+ request_.keyAuthorizationSimulation = MultisigSimulation.fromRpc(
127
+ request.keyAuthorizationSimulation,
128
+ )
113
129
  if (request.multisigSimulation)
114
130
  request_.multisigSimulation = MultisigSimulation.fromRpc(
115
131
  request.multisigSimulation,
@@ -212,6 +228,10 @@ export function toRpc(request: TransactionRequest): Rpc {
212
228
  request_rpc.keyAuthorization = KeyAuthorization.toRpc(
213
229
  request.keyAuthorization,
214
230
  )
231
+ if (request.keyAuthorizationSimulation)
232
+ request_rpc.keyAuthorizationSimulation = MultisigSimulation.toRpc(
233
+ request.keyAuthorizationSimulation,
234
+ )
215
235
  if (request.multisigSimulation)
216
236
  request_rpc.multisigSimulation = MultisigSimulation.toRpc(
217
237
  request.multisigSimulation,
package/tempo/index.ts CHANGED
@@ -144,7 +144,9 @@ export * as KeyAuthorization from './KeyAuthorization.js'
144
144
  * ],
145
145
  * })
146
146
  *
147
- * const account = MultisigConfig.getAddress(initialConfig)
147
+ * const account = MultisigConfig.getAddress(initialConfig, {
148
+ * factory: '0x7171717171717171717171717171717171717171'
149
+ * })
148
150
  * ```
149
151
  *
150
152
  * @category Reference