ox 0.14.55 → 0.14.56

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 (95) hide show
  1. package/CHANGELOG.md +29 -0
  2. package/_cjs/tempo/{MultisigConfig.js → AccountConfig.js} +16 -4
  3. package/_cjs/tempo/AccountConfig.js.map +1 -0
  4. package/_cjs/tempo/{MultisigOperation.js → AccountOperation.js} +29 -29
  5. package/_cjs/tempo/AccountOperation.js.map +1 -0
  6. package/_cjs/tempo/{MultisigSimulation.js → AccountSimulation.js} +9 -9
  7. package/_cjs/tempo/AccountSimulation.js.map +1 -0
  8. package/_cjs/tempo/KeyAuthorization.js +12 -11
  9. package/_cjs/tempo/KeyAuthorization.js.map +1 -1
  10. package/_cjs/tempo/SignatureEnvelope.js +64 -64
  11. package/_cjs/tempo/SignatureEnvelope.js.map +1 -1
  12. package/_cjs/tempo/TransactionRequest.js +12 -9
  13. package/_cjs/tempo/TransactionRequest.js.map +1 -1
  14. package/_cjs/tempo/index.js +4 -4
  15. package/_cjs/tempo/index.js.map +1 -1
  16. package/_cjs/version.js +1 -1
  17. package/_esm/tempo/{MultisigConfig.js → AccountConfig.js} +103 -55
  18. package/_esm/tempo/AccountConfig.js.map +1 -0
  19. package/_esm/tempo/{MultisigOperation.js → AccountOperation.js} +64 -64
  20. package/_esm/tempo/AccountOperation.js.map +1 -0
  21. package/_esm/tempo/{MultisigSimulation.js → AccountSimulation.js} +20 -20
  22. package/_esm/tempo/AccountSimulation.js.map +1 -0
  23. package/_esm/tempo/KeyAuthorization.js +13 -12
  24. package/_esm/tempo/KeyAuthorization.js.map +1 -1
  25. package/_esm/tempo/SignatureEnvelope.js +71 -71
  26. package/_esm/tempo/SignatureEnvelope.js.map +1 -1
  27. package/_esm/tempo/TransactionRequest.js +12 -9
  28. package/_esm/tempo/TransactionRequest.js.map +1 -1
  29. package/_esm/tempo/index.js +50 -48
  30. package/_esm/tempo/index.js.map +1 -1
  31. package/_esm/version.js +1 -1
  32. package/_types/tempo/{MultisigConfig.d.ts → AccountConfig.d.ts} +110 -63
  33. package/_types/tempo/AccountConfig.d.ts.map +1 -0
  34. package/_types/tempo/{MultisigOperation.d.ts → AccountOperation.d.ts} +62 -62
  35. package/_types/tempo/AccountOperation.d.ts.map +1 -0
  36. package/_types/tempo/{MultisigSimulation.d.ts → AccountSimulation.d.ts} +21 -21
  37. package/_types/tempo/AccountSimulation.d.ts.map +1 -0
  38. package/_types/tempo/KeyAuthorization.d.ts +14 -14
  39. package/_types/tempo/KeyAuthorization.d.ts.map +1 -1
  40. package/_types/tempo/RpcSchemaTempo.d.ts +13 -13
  41. package/_types/tempo/RpcSchemaTempo.d.ts.map +1 -1
  42. package/_types/tempo/SignatureEnvelope.d.ts +36 -33
  43. package/_types/tempo/SignatureEnvelope.d.ts.map +1 -1
  44. package/_types/tempo/TransactionRequest.d.ts +11 -9
  45. package/_types/tempo/TransactionRequest.d.ts.map +1 -1
  46. package/_types/tempo/index.d.ts +50 -48
  47. package/_types/tempo/index.d.ts.map +1 -1
  48. package/_types/version.d.ts +1 -1
  49. package/package.json +31 -31
  50. package/tempo/AccountConfig/package.json +6 -0
  51. package/tempo/AccountConfig.test-d/package.json +6 -0
  52. package/tempo/{MultisigConfig.test-d.ts → AccountConfig.test-d.ts} +22 -12
  53. package/tempo/{MultisigConfig.test.ts → AccountConfig.test.ts} +155 -37
  54. package/tempo/{MultisigConfig.ts → AccountConfig.ts} +132 -66
  55. package/tempo/AccountOperation/package.json +6 -0
  56. package/tempo/AccountOperation.test-d/package.json +6 -0
  57. package/tempo/AccountOperation.test-d.ts +71 -0
  58. package/tempo/{MultisigOperation.test.ts → AccountOperation.test.ts} +97 -97
  59. package/tempo/{MultisigOperation.ts → AccountOperation.ts} +95 -97
  60. package/tempo/AccountSimulation/package.json +6 -0
  61. package/tempo/AccountSimulation.test-d/package.json +6 -0
  62. package/tempo/{MultisigSimulation.test-d.ts → AccountSimulation.test-d.ts} +7 -9
  63. package/tempo/{MultisigSimulation.test.ts → AccountSimulation.test.ts} +29 -29
  64. package/tempo/{MultisigSimulation.ts → AccountSimulation.ts} +28 -30
  65. package/tempo/KeyAuthorization.test-d.ts +14 -14
  66. package/tempo/KeyAuthorization.test.ts +70 -49
  67. package/tempo/KeyAuthorization.ts +29 -27
  68. package/tempo/RpcSchemaTempo.test-d.ts +19 -19
  69. package/tempo/RpcSchemaTempo.ts +13 -13
  70. package/tempo/SignatureEnvelope.test-d.ts +7 -7
  71. package/tempo/SignatureEnvelope.test.ts +34 -34
  72. package/tempo/SignatureEnvelope.ts +107 -103
  73. package/tempo/Transaction.test.ts +4 -4
  74. package/tempo/TransactionRequest.test-d.ts +16 -7
  75. package/tempo/TransactionRequest.test.ts +25 -17
  76. package/tempo/TransactionRequest.ts +25 -18
  77. package/tempo/{multisig.e2e.test.ts → configurableAccounts.e2e.test.ts} +16 -16
  78. package/tempo/index.ts +50 -48
  79. package/version.ts +1 -1
  80. package/_cjs/tempo/MultisigConfig.js.map +0 -1
  81. package/_cjs/tempo/MultisigOperation.js.map +0 -1
  82. package/_cjs/tempo/MultisigSimulation.js.map +0 -1
  83. package/_esm/tempo/MultisigConfig.js.map +0 -1
  84. package/_esm/tempo/MultisigOperation.js.map +0 -1
  85. package/_esm/tempo/MultisigSimulation.js.map +0 -1
  86. package/_types/tempo/MultisigConfig.d.ts.map +0 -1
  87. package/_types/tempo/MultisigOperation.d.ts.map +0 -1
  88. package/_types/tempo/MultisigSimulation.d.ts.map +0 -1
  89. package/tempo/MultisigConfig/package.json +0 -6
  90. package/tempo/MultisigConfig.test-d/package.json +0 -6
  91. package/tempo/MultisigOperation/package.json +0 -6
  92. package/tempo/MultisigOperation.test-d/package.json +0 -6
  93. package/tempo/MultisigOperation.test-d.ts +0 -71
  94. package/tempo/MultisigSimulation/package.json +0 -6
  95. package/tempo/MultisigSimulation.test-d/package.json +0 -6
@@ -9,39 +9,44 @@ import type { Compute } from '../core/internal/types.js'
9
9
  /** Maximum encoded byte length for one primitive owner approval. */
10
10
  export const maxOwnerSignatureBytes = 2049
11
11
 
12
- /** Maximum number of owners allowed in a native multisig config. */
12
+ /** Maximum number of owners allowed in an account config. */
13
13
  export const maxOwners = 48
14
14
 
15
- /** Maximum number of owner approvals in a native multisig signature. */
15
+ /** Maximum number of owner approvals in a configurable account signature. */
16
16
  export const maxSignatures = 8
17
17
 
18
- /** Maximum threshold accepted by a native multisig config. */
19
- export const maxThreshold = 8
18
+ /**
19
+ * Maximum threshold accepted by an account config.
20
+ *
21
+ * The threshold must also be reachable by at most {@link ox#AccountConfig.maxSignatures}
22
+ * owner approvals.
23
+ */
24
+ export const maxThreshold = 0xff
20
25
 
21
- /** Maximum version accepted by a native multisig config. */
26
+ /** Maximum version accepted by an account config. */
22
27
  export const maxVersion = 2n ** 64n - 1n
23
28
 
24
- /** Tempo signature type byte for native multisig signatures. */
29
+ /** Tempo signature type byte for configurable account signatures. */
25
30
  export const signatureTypeByte = '0x05' as const
26
31
 
27
32
  /** Zero 32-byte salt (the default when no salt is provided). */
28
33
  export const zeroSalt = `0x${'00'.repeat(32)}` as const
29
34
 
30
- /** Domain prefix for the native multisig account address derivation. */
35
+ /** Domain prefix for the configurable account address derivation. */
31
36
  const accountDomain = 'tempo:multisig:account'
32
37
 
33
- /** Domain prefix for native multisig configuration commitments. */
38
+ /** Domain prefix for account configuration commitments. */
34
39
  const configDomain = 'tempo:multisig:config'
35
40
 
36
41
  /** Keccak-256 of the canonical recovery wallet creation code. */
37
42
  const recoveryWalletInitCodeHash =
38
43
  '0x583cc63a2e37f645b43eac911b1a6d6de08b83abdc308c61364edda8cfc3bd37'
39
44
 
40
- /** Domain prefix for native multisig owner approvals. */
45
+ /** Domain prefix for configurable account owner approvals. */
41
46
  const signatureDomain = 'tempo:multisig:signature'
42
47
 
43
48
  /**
44
- * Complete native multisig configuration witness.
49
+ * Complete account configuration witness.
45
50
  */
46
51
  export type Config<bigintType = bigint, numberType = number> = Compute<{
47
52
  /** Weighted owner list, strictly ascending by owner address. */
@@ -54,7 +59,7 @@ export type Config<bigintType = bigint, numberType = number> = Compute<{
54
59
  version: bigintType
55
60
  }>
56
61
 
57
- /** Input accepted when constructing a native multisig configuration. */
62
+ /** Input accepted when constructing an account configuration. */
58
63
  export type Input<
59
64
  versionType extends bigint | number = bigint | number,
60
65
  numberType = number,
@@ -63,7 +68,7 @@ export type Input<
63
68
  owners: readonly Owner<numberType>[]
64
69
  /**
65
70
  * Caller-chosen 32-byte salt mixed into the derived account address.
66
- * Defaults to the zero salt (`MultisigConfig.zeroSalt`) when omitted.
71
+ * Defaults to the zero salt (`AccountConfig.zeroSalt`) when omitted.
67
72
  */
68
73
  salt?: Hex.Hex | undefined
69
74
  /** Minimum total owner weight required to authorize a transaction. */
@@ -72,7 +77,7 @@ export type Input<
72
77
  version?: versionType | undefined
73
78
  }>
74
79
 
75
- /** Native multisig owner entry. */
80
+ /** Account config owner entry. */
76
81
  export type Owner<numberType = number> = {
77
82
  /** Owner address (recovered from the owner's approval). */
78
83
  owner: Address.Address
@@ -80,10 +85,10 @@ export type Owner<numberType = number> = {
80
85
  weight: numberType
81
86
  }
82
87
 
83
- /** JSON-RPC representation of a native multisig configuration. */
88
+ /** JSON-RPC representation of an account configuration. */
84
89
  export type Rpc = Config<Hex.Hex, number>
85
90
 
86
- /** RLP tuple representation of a {@link ox#MultisigConfig.Config}. */
91
+ /** RLP tuple representation of a {@link ox#AccountConfig.Config}. */
87
92
  export type Tuple = readonly [
88
93
  salt: Hex.Hex,
89
94
  version: Hex.Hex,
@@ -92,7 +97,7 @@ export type Tuple = readonly [
92
97
  ]
93
98
 
94
99
  /**
95
- * Asserts that a native multisig {@link ox#MultisigConfig.Config} is valid.
100
+ * Asserts that an {@link ox#AccountConfig.Config} is valid.
96
101
  *
97
102
  * Mirrors the Tempo configuration rules: owners non-empty and
98
103
  * `<= maxOwners`, strictly ascending unique nonzero owner addresses, nonzero
@@ -102,9 +107,9 @@ export type Tuple = readonly [
102
107
  *
103
108
  * @example
104
109
  * ```ts twoslash
105
- * import { MultisigConfig } from 'ox/tempo'
110
+ * import { AccountConfig } from 'ox/tempo'
106
111
  *
107
- * MultisigConfig.assert({
112
+ * AccountConfig.assert({
108
113
  * threshold: 1,
109
114
  * owners: [
110
115
  * { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
@@ -112,7 +117,7 @@ export type Tuple = readonly [
112
117
  * })
113
118
  * ```
114
119
  *
115
- * @param config - The multisig config.
120
+ * @param config - The account config.
116
121
  */
117
122
  export function assert<
118
123
  versionType extends bigint | number = bigint | number,
@@ -183,16 +188,16 @@ export declare namespace assert {
183
188
  }
184
189
 
185
190
  /**
186
- * Normalizes a native multisig {@link ox#MultisigConfig.Config}.
191
+ * Normalizes an {@link ox#AccountConfig.Config}.
187
192
  *
188
193
  * Sorts owners into strictly ascending `owner` address order (the canonical
189
194
  * form required for account derivation) and asserts the config is valid.
190
195
  *
191
196
  * @example
192
197
  * ```ts twoslash
193
- * import { MultisigConfig } from 'ox/tempo'
198
+ * import { AccountConfig } from 'ox/tempo'
194
199
  *
195
- * const config = MultisigConfig.from({
200
+ * const config = AccountConfig.from({
196
201
  * owners: [
197
202
  * { owner: '0x2222222222222222222222222222222222222222', weight: 1 },
198
203
  * { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
@@ -202,8 +207,8 @@ export declare namespace assert {
202
207
  * // owners are now sorted ascending by address
203
208
  * ```
204
209
  *
205
- * @param config - The multisig config.
206
- * @returns The normalized multisig config.
210
+ * @param config - The account config.
211
+ * @returns The normalized account config.
207
212
  */
208
213
  export function from<numberType = number>(
209
214
  config: Input<0 | 0n, numberType> & { version?: 0 | 0n | undefined },
@@ -237,13 +242,13 @@ export function from<numberType = number>(
237
242
  }
238
243
 
239
244
  /**
240
- * Converts a JSON-RPC multisig configuration to its domain representation.
245
+ * Converts a JSON-RPC account configuration to its domain representation.
241
246
  *
242
247
  * @example
243
248
  * ```ts twoslash
244
- * import { MultisigConfig } from 'ox/tempo'
249
+ * import { AccountConfig } from 'ox/tempo'
245
250
  *
246
- * const config = MultisigConfig.fromRpc({
251
+ * const config = AccountConfig.fromRpc({
247
252
  * owners: [
248
253
  * { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
249
254
  * ],
@@ -253,8 +258,8 @@ export function from<numberType = number>(
253
258
  * })
254
259
  * ```
255
260
  *
256
- * @param config - The JSON-RPC multisig configuration.
257
- * @returns The normalized multisig configuration.
261
+ * @param config - The JSON-RPC account configuration.
262
+ * @returns The normalized account configuration.
258
263
  */
259
264
  export function fromRpc(config: Rpc): Config {
260
265
  return from({
@@ -271,14 +276,14 @@ export declare namespace fromRpc {
271
276
  }
272
277
 
273
278
  /**
274
- * Converts an RLP {@link ox#MultisigConfig.Tuple} back to a
275
- * {@link ox#MultisigConfig.Config}.
279
+ * Converts an RLP {@link ox#AccountConfig.Tuple} back to a
280
+ * {@link ox#AccountConfig.Config}.
276
281
  *
277
282
  * @example
278
283
  * ```ts twoslash
279
- * import { MultisigConfig } from 'ox/tempo'
284
+ * import { AccountConfig } from 'ox/tempo'
280
285
  *
281
- * const config = MultisigConfig.fromTuple([
286
+ * const config = AccountConfig.fromTuple([
282
287
  * `0x${'00'.repeat(32)}`,
283
288
  * '0x',
284
289
  * '0x01',
@@ -287,7 +292,7 @@ export declare namespace fromRpc {
287
292
  * ```
288
293
  *
289
294
  * @param tuple - The RLP tuple.
290
- * @returns The multisig config.
295
+ * @returns The account config.
291
296
  */
292
297
  export function fromTuple(tuple: Tuple): Config {
293
298
  const [salt, version, threshold, owners] = tuple
@@ -331,7 +336,7 @@ export function fromTuple(tuple: Tuple): Config {
331
336
  }
332
337
 
333
338
  /**
334
- * Derives the stable native multisig account address.
339
+ * Derives the stable configurable account address.
335
340
  *
336
341
  * The initial config is hashed into a CREATE2 salt using fixed-width
337
342
  * big-endian fields, not RLP. The account uses the chain-configured recovery
@@ -342,23 +347,23 @@ export function fromTuple(tuple: Tuple): Config {
342
347
  *
343
348
  * @example
344
349
  * ```ts twoslash
345
- * import { MultisigConfig } from 'ox/tempo'
350
+ * import { AccountConfig } from 'ox/tempo'
346
351
  *
347
- * const initialConfig = MultisigConfig.from({
352
+ * const initialConfig = AccountConfig.from({
348
353
  * owners: [
349
354
  * { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
350
355
  * ],
351
356
  * threshold: 1,
352
357
  * })
353
358
  *
354
- * const address = MultisigConfig.getAddress(initialConfig, {
359
+ * const address = AccountConfig.getAddress(initialConfig, {
355
360
  * factory: '0x7171717171717171717171717171717171717171'
356
361
  * })
357
362
  * ```
358
363
  *
359
- * @param config - The initial multisig config.
364
+ * @param config - The initial account config.
360
365
  * @param options - The recovery factory configured by the chain.
361
- * @returns The multisig account address.
366
+ * @returns The configurable account address.
362
367
  */
363
368
  export function getAddress(
364
369
  config: Input,
@@ -413,16 +418,16 @@ export declare namespace getAddress {
413
418
  }
414
419
 
415
420
  /**
416
- * Computes the commitment for a native multisig configuration.
421
+ * Computes the commitment for an account configuration.
417
422
  *
418
423
  * The commitment uses raw fixed-width fields, not RLP or ABI encoding:
419
424
  * `keccak256("tempo:multisig:config" || salt || uint64be(version) || uint8(threshold) || uint8(owners.length) || owners)`.
420
425
  *
421
426
  * @example
422
427
  * ```ts twoslash
423
- * import { MultisigConfig } from 'ox/tempo'
428
+ * import { AccountConfig } from 'ox/tempo'
424
429
  *
425
- * const commitment = MultisigConfig.getCommitment({
430
+ * const commitment = AccountConfig.getCommitment({
426
431
  * owners: [
427
432
  * { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
428
433
  * ],
@@ -431,7 +436,7 @@ export declare namespace getAddress {
431
436
  * })
432
437
  * ```
433
438
  *
434
- * @param config - The complete multisig configuration.
439
+ * @param config - The complete account configuration.
435
440
  * @returns The configuration commitment.
436
441
  */
437
442
  export function getCommitment(config: Input): Hex.Hex {
@@ -462,7 +467,7 @@ export declare namespace getCommitment {
462
467
  }
463
468
 
464
469
  /**
465
- * Computes the digest a native multisig owner approves (signs).
470
+ * Computes the digest a configurable account owner approves (signs).
466
471
  *
467
472
  * `keccak256("tempo:multisig:signature" || inner_digest || account || uint64be(version))`,
468
473
  * where `inner_digest` is the transaction sign payload
@@ -474,9 +479,9 @@ export declare namespace getCommitment {
474
479
  *
475
480
  * @example
476
481
  * ```ts twoslash
477
- * import { MultisigConfig, TxEnvelopeTempo } from 'ox/tempo'
482
+ * import { AccountConfig, TxEnvelopeTempo } from 'ox/tempo'
478
483
  *
479
- * const config = MultisigConfig.from({
484
+ * const config = AccountConfig.from({
480
485
  * owners: [
481
486
  * { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
482
487
  * ],
@@ -488,8 +493,8 @@ export declare namespace getCommitment {
488
493
  * calls: [],
489
494
  * })
490
495
  *
491
- * const digest = MultisigConfig.getSignPayload({
492
- * account: MultisigConfig.getAddress(config, {
496
+ * const digest = AccountConfig.getSignPayload({
497
+ * account: AccountConfig.getAddress(config, {
493
498
  * factory: '0x7171717171717171717171717171717171717171'
494
499
  * }),
495
500
  * config,
@@ -518,7 +523,7 @@ export function getSignPayload(value: getSignPayload.Value): Hex.Hex {
518
523
 
519
524
  export declare namespace getSignPayload {
520
525
  type Value = {
521
- /** The native multisig account address. */
526
+ /** The configurable account address. */
522
527
  account: Address.Address
523
528
  /** Configuration whose version applies to the approval. */
524
529
  config: Pick<Config<bigint | number>, 'version'>
@@ -536,13 +541,13 @@ export declare namespace getSignPayload {
536
541
  }
537
542
 
538
543
  /**
539
- * Converts a multisig configuration to its JSON-RPC representation.
544
+ * Converts an account configuration to its JSON-RPC representation.
540
545
  *
541
546
  * @example
542
547
  * ```ts twoslash
543
- * import { MultisigConfig } from 'ox/tempo'
548
+ * import { AccountConfig } from 'ox/tempo'
544
549
  *
545
- * const config = MultisigConfig.toRpc({
550
+ * const config = AccountConfig.toRpc({
546
551
  * owners: [
547
552
  * { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
548
553
  * ],
@@ -550,8 +555,8 @@ export declare namespace getSignPayload {
550
555
  * })
551
556
  * ```
552
557
  *
553
- * @param config - The multisig configuration.
554
- * @returns The JSON-RPC multisig configuration.
558
+ * @param config - The account configuration.
559
+ * @returns The JSON-RPC account configuration.
555
560
  */
556
561
  export function toRpc(config: Input): Rpc {
557
562
  const value = from(config)
@@ -574,7 +579,7 @@ export declare namespace toRpc {
574
579
  }
575
580
 
576
581
  /**
577
- * Converts a {@link ox#MultisigConfig.Config} to its RLP tuple form.
582
+ * Converts a {@link ox#AccountConfig.Config} to its RLP tuple form.
578
583
  *
579
584
  * Tuple shape: `[salt, version, threshold, [[owner, weight], ...]]`. The
580
585
  * 32-byte `salt` encodes as a full fixed-width string; other integers use
@@ -582,9 +587,9 @@ export declare namespace toRpc {
582
587
  *
583
588
  * @example
584
589
  * ```ts twoslash
585
- * import { MultisigConfig } from 'ox/tempo'
590
+ * import { AccountConfig } from 'ox/tempo'
586
591
  *
587
- * const tuple = MultisigConfig.toTuple({
592
+ * const tuple = AccountConfig.toTuple({
588
593
  * owners: [
589
594
  * { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
590
595
  * ],
@@ -592,7 +597,7 @@ export declare namespace toRpc {
592
597
  * })
593
598
  * ```
594
599
  *
595
- * @param config - The multisig config.
600
+ * @param config - The account config.
596
601
  * @returns The RLP tuple.
597
602
  */
598
603
  export function toTuple(config: Input): Tuple {
@@ -613,14 +618,75 @@ export function toTuple(config: Input): Tuple {
613
618
  }
614
619
 
615
620
  /**
616
- * Validates a native multisig {@link ox#MultisigConfig.Config}. Returns `true`
621
+ * Derives the configuration that replaces the current one in an owner update.
622
+ *
623
+ * Mirrors the `updateConfig` precompile ([TIP-1109](https://tips.sh/1109)):
624
+ * keeps the current salt, increments the version by one, and replaces the
625
+ * owners and threshold. Owners are sorted into canonical order and the next
626
+ * configuration is validated. The account address does not change.
627
+ *
628
+ * @example
629
+ * ```ts twoslash
630
+ * import { AccountConfig } from 'ox/tempo'
631
+ *
632
+ * const initialConfig = AccountConfig.from({
633
+ * owners: [
634
+ * { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
635
+ * ],
636
+ * threshold: 1,
637
+ * })
638
+ *
639
+ * const config = AccountConfig.update(initialConfig, {
640
+ * owners: [
641
+ * { owner: '0x2222222222222222222222222222222222222222', weight: 1 },
642
+ * ],
643
+ * threshold: 1,
644
+ * })
645
+ * // config.version === 1n, with the initial salt
646
+ * ```
647
+ *
648
+ * @param config - The current account config.
649
+ * @param options - The replacement owners and threshold.
650
+ * @returns The next account config.
651
+ */
652
+ export function update<numberType = number>(
653
+ config: Input<bigint | number, numberType>,
654
+ options: update.Options<numberType>,
655
+ ): Config<bigint, numberType> {
656
+ const current = from(config)
657
+ if (current.version === maxVersion)
658
+ throw new InvalidConfigError({ reason: 'version overflow' })
659
+ return from({
660
+ owners: options.owners,
661
+ salt: current.salt,
662
+ threshold: options.threshold,
663
+ version: current.version + 1n,
664
+ })
665
+ }
666
+
667
+ export declare namespace update {
668
+ type Options<numberType = number> = {
669
+ /** Replacement weighted owners. Sorted into canonical order. */
670
+ owners: readonly Owner<numberType>[]
671
+ /** Replacement minimum total owner weight required for authorization. */
672
+ threshold: numberType
673
+ }
674
+
675
+ type ErrorType =
676
+ | assert.ErrorType
677
+ | InvalidConfigError
678
+ | Errors.GlobalErrorType
679
+ }
680
+
681
+ /**
682
+ * Validates an {@link ox#AccountConfig.Config}. Returns `true`
617
683
  * if valid, `false` otherwise.
618
684
  *
619
685
  * @example
620
686
  * ```ts twoslash
621
- * import { MultisigConfig } from 'ox/tempo'
687
+ * import { AccountConfig } from 'ox/tempo'
622
688
  *
623
- * const valid = MultisigConfig.validate({
689
+ * const valid = AccountConfig.validate({
624
690
  * owners: [
625
691
  * { owner: '0x1111111111111111111111111111111111111111', weight: 1 },
626
692
  * ],
@@ -629,7 +695,7 @@ export function toTuple(config: Input): Tuple {
629
695
  * // @log: true
630
696
  * ```
631
697
  *
632
- * @param config - The multisig config.
698
+ * @param config - The account config.
633
699
  * @returns Whether the config is valid.
634
700
  */
635
701
  export function validate(config: Input): boolean {
@@ -641,11 +707,11 @@ export function validate(config: Input): boolean {
641
707
  }
642
708
  }
643
709
 
644
- /** Thrown when a native multisig config is invalid. */
710
+ /** Thrown when an account config is invalid. */
645
711
  export class InvalidConfigError extends Errors.BaseError {
646
- override readonly name = 'MultisigConfig.InvalidConfigError'
712
+ override readonly name = 'AccountConfig.InvalidConfigError'
647
713
  constructor({ reason }: { reason: string }) {
648
- super(`Invalid native multisig config: ${reason}.`)
714
+ super(`Invalid account config: ${reason}.`)
649
715
  }
650
716
  }
651
717
 
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "types": "../../_types/tempo/AccountOperation.d.ts",
4
+ "main": "../../_cjs/tempo/AccountOperation.js",
5
+ "module": "../../_esm/tempo/AccountOperation.js"
6
+ }
@@ -0,0 +1,6 @@
1
+ {
2
+ "type": "module",
3
+ "types": "../../_types/tempo/AccountOperation.test-d.d.ts",
4
+ "main": "../../_cjs/tempo/AccountOperation.test-d.js",
5
+ "module": "../../_esm/tempo/AccountOperation.test-d.js"
6
+ }
@@ -0,0 +1,71 @@
1
+ import { expectTypeOf, test } from 'vitest'
2
+ import type * as Hex from '../core/Hex.js'
3
+ import * as AccountOperation from './AccountOperation.js'
4
+ import type * as TxEnvelopeTempo from './TxEnvelopeTempo.js'
5
+
6
+ declare const transaction: AccountOperation.TransactionOperation
7
+ declare const transactionRpc: AccountOperation.TransactionRpc
8
+ declare const keyAuthorization: AccountOperation.KeyAuthorizationOperation
9
+ declare const keyAuthorizationRpc: AccountOperation.KeyAuthorizationRpc
10
+ declare const operation: AccountOperation.Operation
11
+ declare const operationRpc: AccountOperation.Rpc
12
+ declare const getHashOptions: AccountOperation.getHash.Options
13
+ declare const selectApprovalsOptions: AccountOperation.selectApprovals.Options
14
+ declare const serializeTransactionOptions: AccountOperation.serializeTransaction.Options
15
+
16
+ test('preserves operation kinds during validation', () => {
17
+ expectTypeOf(
18
+ AccountOperation.from(transaction),
19
+ ).toEqualTypeOf<AccountOperation.TransactionOperation>()
20
+ expectTypeOf(
21
+ AccountOperation.from(keyAuthorization),
22
+ ).toEqualTypeOf<AccountOperation.KeyAuthorizationOperation>()
23
+ expectTypeOf(
24
+ AccountOperation.from(operation),
25
+ ).toEqualTypeOf<AccountOperation.Operation>()
26
+ })
27
+
28
+ test('preserves operation kinds during RPC conversion', () => {
29
+ expectTypeOf(
30
+ AccountOperation.fromRpc(transactionRpc),
31
+ ).toEqualTypeOf<AccountOperation.TransactionOperation>()
32
+ expectTypeOf(
33
+ AccountOperation.fromRpc(keyAuthorizationRpc),
34
+ ).toEqualTypeOf<AccountOperation.KeyAuthorizationOperation>()
35
+ expectTypeOf(
36
+ AccountOperation.toRpc(transaction),
37
+ ).toEqualTypeOf<AccountOperation.TransactionRpc>()
38
+ expectTypeOf(
39
+ AccountOperation.toRpc(keyAuthorization),
40
+ ).toEqualTypeOf<AccountOperation.KeyAuthorizationRpc>()
41
+ expectTypeOf(
42
+ AccountOperation.fromRpc(operationRpc),
43
+ ).toEqualTypeOf<AccountOperation.Operation>()
44
+ expectTypeOf(
45
+ AccountOperation.toRpc(operation),
46
+ ).toEqualTypeOf<AccountOperation.Rpc>()
47
+ })
48
+
49
+ test('uses JSON-RPC quantities only in RPC operations', () => {
50
+ expectTypeOf<
51
+ AccountOperation.Operation['config']['version']
52
+ >().toEqualTypeOf<bigint>()
53
+ expectTypeOf<
54
+ AccountOperation.Rpc['config']['version']
55
+ >().toEqualTypeOf<Hex.Hex>()
56
+ })
57
+
58
+ test('operation helpers return narrow types', async () => {
59
+ expectTypeOf(
60
+ AccountOperation.getHash(getHashOptions),
61
+ ).toEqualTypeOf<Hex.Hex>()
62
+ expectTypeOf(
63
+ await AccountOperation.selectApprovals(selectApprovalsOptions),
64
+ ).toEqualTypeOf<AccountOperation.selectApprovals.ReturnValue>()
65
+ expectTypeOf(
66
+ AccountOperation.serializeTransaction(
67
+ transaction,
68
+ serializeTransactionOptions,
69
+ ),
70
+ ).toEqualTypeOf<TxEnvelopeTempo.Serialized>()
71
+ })