viem 3.0.0-next.13 → 3.0.0-next.14

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 (194) hide show
  1. package/dist/chains/definitions/arcTestnet.d.ts +5 -5
  2. package/dist/chains/definitions/arcTestnet.d.ts.map +1 -1
  3. package/dist/chains/definitions/arcTestnet.js +11 -8
  4. package/dist/chains/definitions/arcTestnet.js.map +1 -1
  5. package/dist/chains/definitions/qmsTestnet.d.ts +27 -0
  6. package/dist/chains/definitions/qmsTestnet.d.ts.map +1 -0
  7. package/dist/chains/definitions/qmsTestnet.js +23 -0
  8. package/dist/chains/definitions/qmsTestnet.js.map +1 -0
  9. package/dist/chains/definitions/tempo.d.ts +1 -1
  10. package/dist/chains/definitions/tempo.js +1 -1
  11. package/dist/chains/definitions/tempoModerato.d.ts +2 -2
  12. package/dist/chains/definitions/tempoModerato.js +2 -2
  13. package/dist/chains/index.d.ts +1 -0
  14. package/dist/chains/index.d.ts.map +1 -1
  15. package/dist/chains/index.js +1 -0
  16. package/dist/chains/index.js.map +1 -1
  17. package/dist/core/actions/transaction/waitForReceipt.d.ts +1 -1
  18. package/dist/core/actions/transaction/waitForReceipt.d.ts.map +1 -1
  19. package/dist/core/actions/transaction/waitForReceipt.js +5 -2
  20. package/dist/core/actions/transaction/waitForReceipt.js.map +1 -1
  21. package/dist/core/actions/wallet/waitForCallsStatus.d.ts.map +1 -1
  22. package/dist/core/actions/wallet/waitForCallsStatus.js +24 -1
  23. package/dist/core/actions/wallet/waitForCallsStatus.js.map +1 -1
  24. package/dist/internal/inference.d.ts +3 -3
  25. package/dist/internal/inference.d.ts.map +1 -1
  26. package/dist/tempo/Abis.d.ts +1935 -899
  27. package/dist/tempo/Abis.d.ts.map +1 -1
  28. package/dist/tempo/Abis.js +215 -0
  29. package/dist/tempo/Abis.js.map +1 -1
  30. package/dist/tempo/Account.d.ts +30 -30
  31. package/dist/tempo/Account.d.ts.map +1 -1
  32. package/dist/tempo/Account.js +43 -43
  33. package/dist/tempo/Account.js.map +1 -1
  34. package/dist/tempo/Addresses.d.ts +2 -0
  35. package/dist/tempo/Addresses.d.ts.map +1 -1
  36. package/dist/tempo/Addresses.js +2 -0
  37. package/dist/tempo/Addresses.js.map +1 -1
  38. package/dist/tempo/Decorator.d.ts +33 -10
  39. package/dist/tempo/Decorator.d.ts.map +1 -1
  40. package/dist/tempo/Decorator.js +9 -8
  41. package/dist/tempo/Decorator.js.map +1 -1
  42. package/dist/tempo/ExecutionError.js +1 -1
  43. package/dist/tempo/ExecutionError.js.map +1 -1
  44. package/dist/tempo/KeyAuthorizationManager.d.ts +24 -13
  45. package/dist/tempo/KeyAuthorizationManager.d.ts.map +1 -1
  46. package/dist/tempo/KeyAuthorizationManager.js +44 -25
  47. package/dist/tempo/KeyAuthorizationManager.js.map +1 -1
  48. package/dist/tempo/Relay.d.ts +61 -12
  49. package/dist/tempo/Relay.d.ts.map +1 -1
  50. package/dist/tempo/Relay.js +48 -8
  51. package/dist/tempo/Relay.js.map +1 -1
  52. package/dist/tempo/Selectors.d.ts +12 -0
  53. package/dist/tempo/Selectors.d.ts.map +1 -1
  54. package/dist/tempo/Selectors.js +12 -0
  55. package/dist/tempo/Selectors.js.map +1 -1
  56. package/dist/tempo/Transport.d.ts +19 -6
  57. package/dist/tempo/Transport.d.ts.map +1 -1
  58. package/dist/tempo/Transport.js +18 -12
  59. package/dist/tempo/Transport.js.map +1 -1
  60. package/dist/tempo/{multisig → accounts}/Config.d.ts +8 -8
  61. package/dist/tempo/accounts/Config.d.ts.map +1 -0
  62. package/dist/tempo/{multisig → accounts}/Config.js +14 -14
  63. package/dist/tempo/{multisig → accounts}/Config.js.map +1 -1
  64. package/dist/tempo/{multisig → accounts}/Operation.d.ts +8 -8
  65. package/dist/tempo/{multisig → accounts}/Operation.d.ts.map +1 -1
  66. package/dist/tempo/{multisig → accounts}/Operation.js +17 -17
  67. package/dist/tempo/{multisig → accounts}/Operation.js.map +1 -1
  68. package/dist/tempo/{multisig → accounts}/Signature.d.ts +1 -1
  69. package/dist/tempo/accounts/Signature.d.ts.map +1 -0
  70. package/dist/tempo/accounts/Signature.js +9 -0
  71. package/dist/tempo/accounts/Signature.js.map +1 -0
  72. package/dist/tempo/actions/accessKey/index.d.ts +1 -0
  73. package/dist/tempo/actions/accessKey/index.d.ts.map +1 -1
  74. package/dist/tempo/actions/accessKey/index.js +1 -0
  75. package/dist/tempo/actions/accessKey/index.js.map +1 -1
  76. package/dist/tempo/actions/accessKey/prepareAuthorization.d.ts +4 -4
  77. package/dist/tempo/actions/accessKey/prepareAuthorization.d.ts.map +1 -1
  78. package/dist/tempo/actions/accessKey/prepareAuthorization.js +10 -10
  79. package/dist/tempo/actions/accessKey/prepareAuthorization.js.map +1 -1
  80. package/dist/tempo/actions/accessKey/saveAuthorization.d.ts +40 -0
  81. package/dist/tempo/actions/accessKey/saveAuthorization.d.ts.map +1 -0
  82. package/dist/tempo/actions/accessKey/saveAuthorization.js +32 -0
  83. package/dist/tempo/actions/accessKey/saveAuthorization.js.map +1 -0
  84. package/dist/tempo/actions/accessKey/signAuthorization.d.ts +17 -13
  85. package/dist/tempo/actions/accessKey/signAuthorization.d.ts.map +1 -1
  86. package/dist/tempo/actions/accessKey/signAuthorization.js +43 -30
  87. package/dist/tempo/actions/accessKey/signAuthorization.js.map +1 -1
  88. package/dist/tempo/actions/{multisig → accounts}/getConfig.d.ts +5 -5
  89. package/dist/tempo/actions/accounts/getConfig.d.ts.map +1 -0
  90. package/dist/tempo/actions/{multisig → accounts}/getConfig.js +5 -5
  91. package/dist/tempo/actions/accounts/getConfig.js.map +1 -0
  92. package/dist/tempo/actions/{multisig → accounts}/getConfigCommitment.d.ts +3 -3
  93. package/dist/tempo/actions/{multisig → accounts}/getConfigCommitment.d.ts.map +1 -1
  94. package/dist/tempo/actions/{multisig → accounts}/getConfigCommitment.js +2 -2
  95. package/dist/tempo/actions/{multisig → accounts}/getConfigCommitment.js.map +1 -1
  96. package/dist/tempo/actions/{multisig → accounts}/getOperation.d.ts +4 -4
  97. package/dist/tempo/actions/{multisig → accounts}/getOperation.d.ts.map +1 -1
  98. package/dist/tempo/actions/{multisig → accounts}/getOperation.js +4 -4
  99. package/dist/tempo/actions/accounts/getOperation.js.map +1 -0
  100. package/dist/tempo/actions/{multisig → accounts}/index.d.ts.map +1 -1
  101. package/dist/tempo/actions/{multisig → accounts}/index.js.map +1 -1
  102. package/dist/tempo/actions/{multisig → accounts}/updateConfig.d.ts +12 -12
  103. package/dist/tempo/actions/{multisig → accounts}/updateConfig.d.ts.map +1 -1
  104. package/dist/tempo/actions/{multisig → accounts}/updateConfig.js +16 -21
  105. package/dist/tempo/actions/{multisig → accounts}/updateConfig.js.map +1 -1
  106. package/dist/tempo/actions/{multisig → accounts}/updateConfigSync.d.ts +6 -6
  107. package/dist/tempo/actions/{multisig → accounts}/updateConfigSync.d.ts.map +1 -1
  108. package/dist/tempo/actions/{multisig → accounts}/updateConfigSync.js +6 -6
  109. package/dist/tempo/actions/{multisig → accounts}/updateConfigSync.js.map +1 -1
  110. package/dist/tempo/actions/index.d.ts +2 -2
  111. package/dist/tempo/actions/index.d.ts.map +1 -1
  112. package/dist/tempo/actions/index.js +2 -2
  113. package/dist/tempo/actions/index.js.map +1 -1
  114. package/dist/tempo/chainConfig.d.ts +16 -16
  115. package/dist/tempo/chainConfig.d.ts.map +1 -1
  116. package/dist/tempo/chainConfig.js +52 -52
  117. package/dist/tempo/chainConfig.js.map +1 -1
  118. package/dist/tempo/index.d.ts +2 -2
  119. package/dist/tempo/index.d.ts.map +1 -1
  120. package/dist/tempo/index.js +2 -2
  121. package/dist/tempo/index.js.map +1 -1
  122. package/dist/tempo/internal/relay/accounts.d.ts +15 -0
  123. package/dist/tempo/internal/relay/accounts.d.ts.map +1 -0
  124. package/dist/tempo/internal/relay/{multisig.js → accounts.js} +96 -101
  125. package/dist/tempo/internal/relay/accounts.js.map +1 -0
  126. package/dist/tempo/internal/relay/feePayer.js +5 -5
  127. package/dist/tempo/internal/relay/feePayer.js.map +1 -1
  128. package/dist/tempo/internal/relay/keyAuthorization.d.ts +25 -0
  129. package/dist/tempo/internal/relay/keyAuthorization.d.ts.map +1 -0
  130. package/dist/tempo/internal/relay/keyAuthorization.js +339 -0
  131. package/dist/tempo/internal/relay/keyAuthorization.js.map +1 -0
  132. package/dist/tempo/internal/relay/plugin.d.ts +6 -3
  133. package/dist/tempo/internal/relay/plugin.d.ts.map +1 -1
  134. package/dist/tempo/internal/relay/plugin.js +15 -6
  135. package/dist/tempo/internal/relay/plugin.js.map +1 -1
  136. package/dist/tempo/internal/relay/utils.d.ts +8 -0
  137. package/dist/tempo/internal/relay/utils.d.ts.map +1 -1
  138. package/dist/utils/RpcClient.d.ts.map +1 -1
  139. package/dist/utils/RpcClient.js +36 -19
  140. package/dist/utils/RpcClient.js.map +1 -1
  141. package/dist/version.d.ts +1 -1
  142. package/dist/version.js +1 -1
  143. package/package.json +2 -2
  144. package/src/chains/definitions/arcTestnet.ts +11 -8
  145. package/src/chains/definitions/qmsTestnet.ts +23 -0
  146. package/src/chains/definitions/tempo.ts +1 -1
  147. package/src/chains/definitions/tempoModerato.ts +2 -2
  148. package/src/chains/index.ts +1 -0
  149. package/src/core/actions/transaction/waitForReceipt.ts +5 -3
  150. package/src/core/actions/wallet/waitForCallsStatus.ts +25 -1
  151. package/src/internal/inference.ts +3 -3
  152. package/src/tempo/Abis.ts +216 -0
  153. package/src/tempo/Account.ts +97 -87
  154. package/src/tempo/Addresses.ts +2 -0
  155. package/src/tempo/Decorator.ts +55 -28
  156. package/src/tempo/ExecutionError.ts +1 -1
  157. package/src/tempo/KeyAuthorizationManager.ts +53 -31
  158. package/src/tempo/Relay.ts +69 -14
  159. package/src/tempo/Selectors.ts +13 -0
  160. package/src/tempo/Transport.ts +46 -20
  161. package/src/tempo/{multisig → accounts}/Config.ts +21 -21
  162. package/src/tempo/{multisig → accounts}/Operation.ts +26 -26
  163. package/src/tempo/{multisig → accounts}/Signature.ts +5 -3
  164. package/src/tempo/actions/accessKey/index.ts +1 -0
  165. package/src/tempo/actions/accessKey/prepareAuthorization.ts +16 -15
  166. package/src/tempo/actions/accessKey/saveAuthorization.ts +51 -0
  167. package/src/tempo/actions/accessKey/signAuthorization.ts +73 -51
  168. package/src/tempo/actions/{multisig → accounts}/getConfig.ts +7 -7
  169. package/src/tempo/actions/{multisig → accounts}/getConfigCommitment.ts +3 -3
  170. package/src/tempo/actions/{multisig → accounts}/getOperation.ts +6 -6
  171. package/src/tempo/actions/{multisig → accounts}/updateConfig.ts +21 -26
  172. package/src/tempo/actions/{multisig → accounts}/updateConfigSync.ts +7 -7
  173. package/src/tempo/actions/index.ts +2 -3
  174. package/src/tempo/chainConfig.ts +87 -85
  175. package/src/tempo/index.ts +4 -4
  176. package/src/tempo/internal/relay/{multisig.ts → accounts.ts} +121 -121
  177. package/src/tempo/internal/relay/feePayer.ts +5 -5
  178. package/src/tempo/internal/relay/keyAuthorization.ts +419 -0
  179. package/src/tempo/internal/relay/plugin.ts +20 -7
  180. package/src/utils/RpcClient.ts +38 -21
  181. package/src/version.ts +1 -1
  182. package/dist/tempo/actions/multisig/getConfig.d.ts.map +0 -1
  183. package/dist/tempo/actions/multisig/getConfig.js.map +0 -1
  184. package/dist/tempo/actions/multisig/getOperation.js.map +0 -1
  185. package/dist/tempo/internal/relay/multisig.d.ts +0 -4
  186. package/dist/tempo/internal/relay/multisig.d.ts.map +0 -1
  187. package/dist/tempo/internal/relay/multisig.js.map +0 -1
  188. package/dist/tempo/multisig/Config.d.ts.map +0 -1
  189. package/dist/tempo/multisig/Signature.d.ts.map +0 -1
  190. package/dist/tempo/multisig/Signature.js +0 -9
  191. package/dist/tempo/multisig/Signature.js.map +0 -1
  192. /package/dist/tempo/actions/{multisig → accounts}/index.d.ts +0 -0
  193. /package/dist/tempo/actions/{multisig → accounts}/index.js +0 -0
  194. /package/src/tempo/actions/{multisig → accounts}/index.ts +0 -0
@@ -1,6 +1,6 @@
1
1
  import type { Hex } from 'ox'
2
2
  import { Address, Hash, Json } from 'ox'
3
- import { MultisigConfig } from 'ox/tempo'
3
+ import { AccountConfig } from 'ox/tempo'
4
4
  import { BaseError } from '../../core/Errors.js'
5
5
  import { nativeMultisigFactory } from '../Addresses.js'
6
6
  import type * as Store from '../Store.js'
@@ -11,11 +11,11 @@ const maxStoredValueLength = 65_536
11
11
  /** Zero commitment used before an account is initialized. */
12
12
  const zeroCommitment = `0x${'00'.repeat(32)}` as const
13
13
 
14
- /** Reads a cached multisig config. */
14
+ /** Reads a cached account config. */
15
15
  export async function read(
16
16
  store: Store.Store,
17
17
  options: read.Options,
18
- ): Promise<MultisigConfig.Config | null> {
18
+ ): Promise<AccountConfig.Config | null> {
19
19
  const { address, commitment } = options
20
20
  const value = await store.getItem(key({ address, commitment }))
21
21
  if (value === null || value === undefined) return null
@@ -27,27 +27,27 @@ export async function read(
27
27
  export declare namespace read {
28
28
  /** Parameters for {@link read}. */
29
29
  export type Options = {
30
- /** Multisig account address. */
30
+ /** Configurable account address. */
31
31
  address: Address.Address
32
32
  /** Config commitment observed onchain. */
33
33
  commitment: Hex.Hex
34
34
  }
35
35
  }
36
36
 
37
- /** Writes a validated multisig config. */
37
+ /** Writes a validated account config. */
38
38
  export async function write(
39
39
  store: Store.Store,
40
40
  options: write.Options,
41
41
  ): Promise<void> {
42
42
  const { address, commitment } = options
43
- const config = MultisigConfig.from(options.config)
43
+ const config = AccountConfig.from(options.config)
44
44
  assertKey({ address, commitment, config })
45
45
  const value = serialize(config)
46
46
  await store.setItem(key({ address, commitment }), value)
47
47
  // Initialization commits the version-zero config without changing its version.
48
48
  if (commitment.toLowerCase() === zeroCommitment)
49
49
  await store.setItem(
50
- key({ address, commitment: MultisigConfig.getCommitment(config) }),
50
+ key({ address, commitment: AccountConfig.getCommitment(config) }),
51
51
  value,
52
52
  )
53
53
  }
@@ -55,12 +55,12 @@ export async function write(
55
55
  export declare namespace write {
56
56
  /** Parameters for {@link write}. */
57
57
  export type Options = {
58
- /** Multisig account address. */
58
+ /** Configurable account address. */
59
59
  address: Address.Address
60
60
  /** Config commitment used for lookup. */
61
61
  commitment: Hex.Hex
62
62
  /** Complete config. */
63
- config: MultisigConfig.Config
63
+ config: AccountConfig.Config
64
64
  }
65
65
  }
66
66
 
@@ -68,7 +68,7 @@ export declare namespace write {
68
68
  function assertKey(options: {
69
69
  address: Address.Address
70
70
  commitment: Hex.Hex
71
- config: MultisigConfig.Config
71
+ config: AccountConfig.Config
72
72
  }) {
73
73
  const { address, commitment, config } = options
74
74
  if (!Address.validate(address) || !Hash.validate(commitment))
@@ -76,7 +76,7 @@ function assertKey(options: {
76
76
  if (config.version === 0n) {
77
77
  if (
78
78
  !Address.isEqual(
79
- MultisigConfig.getAddress(config, { factory: nativeMultisigFactory }),
79
+ AccountConfig.getAddress(config, { factory: nativeMultisigFactory }),
80
80
  address,
81
81
  )
82
82
  )
@@ -84,17 +84,17 @@ function assertKey(options: {
84
84
  if (commitment.toLowerCase() === zeroCommitment) return
85
85
  }
86
86
  if (
87
- MultisigConfig.getCommitment(config).toLowerCase() !==
87
+ AccountConfig.getCommitment(config).toLowerCase() !==
88
88
  commitment.toLowerCase()
89
89
  )
90
90
  throw new InvalidStoreValueError()
91
91
  }
92
92
 
93
- /** Deserializes a multisig config from storage. */
94
- function deserialize(value: string): MultisigConfig.Config {
93
+ /** Deserializes an account config from storage. */
94
+ function deserialize(value: string): AccountConfig.Config {
95
95
  try {
96
96
  if (value.length > maxStoredValueLength) throw new InvalidStoreValueError()
97
- return MultisigConfig.fromRpc(Json.parse(value) as never)
97
+ return AccountConfig.fromRpc(Json.parse(value) as never)
98
98
  } catch (cause) {
99
99
  if (cause instanceof InvalidStoreValueError) throw cause
100
100
  throw new InvalidStoreValueError({ cause })
@@ -107,10 +107,10 @@ function key(options: { address: Address.Address; commitment: Hex.Hex }) {
107
107
  return `multisig:config:${address.toLowerCase()}:${commitment.toLowerCase()}`
108
108
  }
109
109
 
110
- /** Serializes a multisig config for storage. */
111
- function serialize(config: MultisigConfig.Config): string {
110
+ /** Serializes an account config for storage. */
111
+ function serialize(config: AccountConfig.Config): string {
112
112
  try {
113
- const value = Json.stringify(MultisigConfig.toRpc(config))
113
+ const value = Json.stringify(AccountConfig.toRpc(config))
114
114
  if (value.length > maxStoredValueLength) throw new InvalidStoreValueError()
115
115
  return value
116
116
  } catch (cause) {
@@ -119,12 +119,12 @@ function serialize(config: MultisigConfig.Config): string {
119
119
  }
120
120
  }
121
121
 
122
- /** Thrown when a stored multisig config is malformed or mismatched. */
122
+ /** Thrown when a stored account config is malformed or mismatched. */
123
123
  export class InvalidStoreValueError extends BaseError<Error | undefined> {
124
- override name = 'Multisig.Config.InvalidStoreValueError'
124
+ override name = 'Accounts.Config.InvalidStoreValueError'
125
125
  /** Creates an invalid store value error. */
126
126
  constructor(options: InvalidStoreValueError.Options = {}) {
127
- super('Stored multisig config is malformed or mismatched.', {
127
+ super('Stored account config is malformed or mismatched.', {
128
128
  cause: options.cause as Error | undefined,
129
129
  })
130
130
  }
@@ -1,6 +1,6 @@
1
1
  import type { Hex } from 'ox'
2
2
  import { Json } from 'ox'
3
- import { MultisigOperation, SignatureEnvelope, TxEnvelopeTempo } from 'ox/tempo'
3
+ import { AccountOperation, SignatureEnvelope, TxEnvelopeTempo } from 'ox/tempo'
4
4
  import { BaseError } from '../../core/Errors.js'
5
5
  import type * as Store from '../Store.js'
6
6
 
@@ -13,11 +13,11 @@ const maxUpdateAttempts = 32
13
13
  /** Bounds abandoned operation state while allowing long-lived approval ceremonies. */
14
14
  const pendingOperationTtl = 30 * 24 * 60 * 60 * 1_000
15
15
 
16
- /** Reads a persisted multisig operation. */
16
+ /** Reads a persisted account operation. */
17
17
  export async function read(
18
18
  store: Store.Store,
19
19
  hash: Hex.Hex,
20
- ): Promise<MultisigOperation.Operation | null> {
20
+ ): Promise<AccountOperation.Operation | null> {
21
21
  const value = await store.getItem(operationKey(hash))
22
22
  if (value === null || value === undefined) return null
23
23
  const operation = deserialize(value)
@@ -26,14 +26,14 @@ export async function read(
26
26
  return operation
27
27
  }
28
28
 
29
- /** Atomically updates a multisig operation. */
29
+ /** Atomically updates an account operation. */
30
30
  export async function update(
31
31
  store: Store.Atomic,
32
32
  hash: Hex.Hex,
33
33
  update: (
34
- operation: MultisigOperation.Operation | null,
35
- ) => MultisigOperation.Operation | Promise<MultisigOperation.Operation>,
36
- ): Promise<MultisigOperation.Operation> {
34
+ operation: AccountOperation.Operation | null,
35
+ ) => AccountOperation.Operation | Promise<AccountOperation.Operation>,
36
+ ): Promise<AccountOperation.Operation> {
37
37
  const key = operationKey(hash)
38
38
  for (let attempt = 0; attempt < maxUpdateAttempts; attempt++) {
39
39
  const value = (await store.getItem(key)) ?? null
@@ -41,9 +41,9 @@ export async function update(
41
41
  if (current && current.hash.toLowerCase() !== hash.toLowerCase())
42
42
  throw new InvalidStoreValueError()
43
43
  const value_ = await update(current)
44
- let next: MultisigOperation.Operation
44
+ let next: AccountOperation.Operation
45
45
  try {
46
- next = MultisigOperation.from(value_)
46
+ next = AccountOperation.from(value_)
47
47
  } catch (cause) {
48
48
  throw new InvalidStoreValueError({ cause })
49
49
  }
@@ -62,7 +62,7 @@ export async function update(
62
62
  /** Reads a submission hash without rebuilding its envelope from mutable configurations. */
63
63
  export async function readSubmission(
64
64
  store: Store.Store,
65
- operation: MultisigOperation.TransactionOperation,
65
+ operation: AccountOperation.TransactionOperation,
66
66
  submissionId: Hex.Hex,
67
67
  ): Promise<Hex.Hex | null> {
68
68
  const value = await store.getItem(submissionKey(operation.hash, submissionId))
@@ -72,9 +72,9 @@ export async function readSubmission(
72
72
  const transaction = TxEnvelopeTempo.deserialize(
73
73
  value as TxEnvelopeTempo.Serialized,
74
74
  )
75
- if (transaction.signature?.type !== 'multisig')
75
+ if (transaction.signature?.type !== 'configurable')
76
76
  throw new InvalidStoreValueError()
77
- const serialized = MultisigOperation.serializeTransaction(operation, {
77
+ const serialized = AccountOperation.serializeTransaction(operation, {
78
78
  approvals: transaction.signature.signatures.map((signature) =>
79
79
  SignatureEnvelope.serialize(signature),
80
80
  ),
@@ -123,11 +123,11 @@ export async function writeSubmission(
123
123
  }
124
124
  }
125
125
 
126
- /** Deserializes a multisig operation from storage. */
127
- function deserialize(value: string): MultisigOperation.Operation {
126
+ /** Deserializes an account operation from storage. */
127
+ function deserialize(value: string): AccountOperation.Operation {
128
128
  try {
129
129
  if (value.length > maxStoredValueLength) throw new InvalidStoreValueError()
130
- const operation = MultisigOperation.from(Json.parse(value) as never)
130
+ const operation = AccountOperation.from(Json.parse(value) as never)
131
131
  assertHash(operation)
132
132
  return operation
133
133
  } catch (cause) {
@@ -136,10 +136,10 @@ function deserialize(value: string): MultisigOperation.Operation {
136
136
  }
137
137
  }
138
138
 
139
- /** Serializes a multisig operation for storage. */
140
- function serialize(operation: MultisigOperation.Operation): string {
139
+ /** Serializes an account operation for storage. */
140
+ function serialize(operation: AccountOperation.Operation): string {
141
141
  try {
142
- const operation_ = MultisigOperation.from(operation)
142
+ const operation_ = AccountOperation.from(operation)
143
143
  assertHash(operation_)
144
144
  const value = Json.stringify(operation_)
145
145
  if (value.length > maxStoredValueLength) throw new InvalidStoreValueError()
@@ -151,8 +151,8 @@ function serialize(operation: MultisigOperation.Operation): string {
151
151
  }
152
152
 
153
153
  /** Verifies that the operation hash commits to its stored payload. */
154
- function assertHash(operation: MultisigOperation.Operation) {
155
- const hash = MultisigOperation.getHash(
154
+ function assertHash(operation: AccountOperation.Operation) {
155
+ const hash = AccountOperation.getHash(
156
156
  operation.type === 'transaction'
157
157
  ? {
158
158
  account: operation.account,
@@ -181,12 +181,12 @@ function submissionKey(hash: Hex.Hex, submissionId: Hex.Hex) {
181
181
  return `multisig:submission:${hash.toLowerCase()}:${submissionId.toLowerCase()}`
182
182
  }
183
183
 
184
- /** Thrown when a stored multisig operation is malformed or unsupported. */
184
+ /** Thrown when a stored account operation is malformed or unsupported. */
185
185
  export class InvalidStoreValueError extends BaseError<Error | undefined> {
186
- override name = 'Multisig.Operation.InvalidStoreValueError'
186
+ override name = 'Accounts.Operation.InvalidStoreValueError'
187
187
  /** Creates an invalid store value error. */
188
188
  constructor(options: InvalidStoreValueError.Options = {}) {
189
- super('Stored multisig operation is malformed or unsupported.', {
189
+ super('Stored account operation is malformed or unsupported.', {
190
190
  cause: options.cause as Error | undefined,
191
191
  })
192
192
  }
@@ -200,13 +200,13 @@ export declare namespace InvalidStoreValueError {
200
200
  }
201
201
  }
202
202
 
203
- /** Thrown when a multisig operation cannot be updated due to contention. */
203
+ /** Thrown When an account operation cannot be updated due to contention. */
204
204
  export class StoreConflictError extends BaseError<Error | undefined> {
205
- override name = 'Multisig.Operation.StoreConflictError'
205
+ override name = 'Accounts.Operation.StoreConflictError'
206
206
  /** Creates a store conflict error. */
207
207
  constructor() {
208
208
  super(
209
- 'Multisig operation could not be updated after repeated conflicts.',
209
+ 'Account operation could not be updated after repeated conflicts.',
210
210
  {},
211
211
  )
212
212
  }
@@ -1,11 +1,13 @@
1
1
  import { SignatureEnvelope } from 'ox/tempo'
2
2
 
3
- /** Parses a primitive multisig owner approval. */
3
+ /** Parses a primitive owner approval. */
4
4
  export function parseApproval(
5
5
  signature: SignatureEnvelope.Serialized,
6
6
  ): SignatureEnvelope.Primitive {
7
7
  const approval = SignatureEnvelope.from(signature)
8
- if (approval.type === 'multisig' || approval.type === 'keychain')
9
- throw new Error('Multisig owners must use primitive signatures.')
8
+ if (approval.type === 'configurable' || approval.type === 'keychain')
9
+ throw new Error(
10
+ 'Configurable account owners must use primitive signatures.',
11
+ )
10
12
  return approval
11
13
  }
@@ -9,6 +9,7 @@ export { isAdmin } from './isAdmin.js'
9
9
  export { isWitnessBurned } from './isWitnessBurned.js'
10
10
  export { revoke } from './revoke.js'
11
11
  export { revokeSync } from './revokeSync.js'
12
+ export { saveAuthorization } from './saveAuthorization.js'
12
13
  export { signAuthorization } from './signAuthorization.js'
13
14
  export { updateLimit } from './updateLimit.js'
14
15
  export { updateLimitSync } from './updateLimitSync.js'
@@ -1,5 +1,5 @@
1
1
  import { Address, type Hex } from 'ox'
2
- import { KeyAuthorization, MultisigConfig } from 'ox/tempo'
2
+ import { AccountConfig, KeyAuthorization } from 'ox/tempo'
3
3
  import * as CoreAccount from '../../../core/Account.js'
4
4
  import type * as Chain from '../../../core/Chain.js'
5
5
  import type * as Client from '../../../core/Client.js'
@@ -8,7 +8,7 @@ import {
8
8
  getKeyAuthorizationSignPayload,
9
9
  resolveAccessKey,
10
10
  signKeyAuthorization,
11
- type MultisigAccount,
11
+ type ConfigurableAccount,
12
12
  } from '../../Account.js'
13
13
 
14
14
  /**
@@ -42,13 +42,14 @@ export async function prepareAuthorization<
42
42
  if (!account_) throw new Error('account is required.')
43
43
  if (!chainId) throw new Error('chainId is required.')
44
44
  const parsed = CoreAccount.from(account_)
45
- const multisigState = await (async () => {
46
- if ('multisig' in parameters) return parameters.multisig
47
- if (!('source' in parsed) || parsed.source !== 'multisig') return undefined
48
- const account = parsed as MultisigAccount
45
+ const configurableState = await (async () => {
46
+ if ('configurable' in parameters) return parameters.configurable
47
+ if (!('source' in parsed) || parsed.source !== 'configurable')
48
+ return undefined
49
+ const account = parsed as ConfigurableAccount
49
50
  if (!account.config)
50
51
  throw new Error(
51
- 'A multisig config is required to prepare a key authorization.',
52
+ 'An account config is required to prepare a key authorization.',
52
53
  )
53
54
  return { config: account.config }
54
55
  })()
@@ -61,10 +62,10 @@ export async function prepareAuthorization<
61
62
  },
62
63
  )
63
64
  const signPayload =
64
- 'source' in parsed && parsed.source === 'multisig' && multisigState
65
- ? MultisigConfig.getSignPayload({
65
+ 'source' in parsed && parsed.source === 'configurable' && configurableState
66
+ ? AccountConfig.getSignPayload({
66
67
  account: parsed.address,
67
- config: multisigState.config,
68
+ config: configurableState.config,
68
69
  payload: authorizationSignPayload,
69
70
  })
70
71
  : authorizationSignPayload
@@ -72,7 +73,7 @@ export async function prepareAuthorization<
72
73
  ...parameters,
73
74
  account: parsed,
74
75
  chainId,
75
- multisig: multisigState,
76
+ configurable: configurableState,
76
77
  signPayload,
77
78
  } as prepareAuthorization.ReturnType
78
79
  }
@@ -103,8 +104,8 @@ export namespace prepareAuthorization {
103
104
  limits?:
104
105
  | { token: Address.Address; limit: bigint; period?: number | undefined }[]
105
106
  | undefined
106
- /** @internal Prepared multisig state. */
107
- multisig?: signKeyAuthorization.Parameters['multisig']
107
+ /** @internal Prepared configurable account state. */
108
+ configurable?: signKeyAuthorization.Parameters['configurable']
108
109
  /** Call scopes restricting which contracts/selectors this key can call. */
109
110
  scopes?: KeyAuthorization.Scope[] | undefined
110
111
  /**
@@ -124,8 +125,8 @@ export namespace prepareAuthorization {
124
125
  Omit<Options<CoreAccount.Account | undefined>, 'account' | 'chainId'> & {
125
126
  account: CoreAccount.Account
126
127
  chainId: number
127
- multisig: signKeyAuthorization.Parameters['multisig']
128
- /** Payload that the authorizing account or multisig owners sign. */
128
+ configurable: signKeyAuthorization.Parameters['configurable']
129
+ /** Payload that the authorizing account or owners sign. */
129
130
  signPayload: Hex.Hex
130
131
  }
131
132
  >
@@ -0,0 +1,51 @@
1
+ import type { Errors } from 'ox'
2
+ import { KeyAuthorization } from 'ox/tempo'
3
+ import type * as Client from '../../../core/Client.js'
4
+
5
+ /**
6
+ * Saves a signed key authorization to a relay with key authorization storage.
7
+ *
8
+ * The relay attaches the authorization to the access key's next transaction until
9
+ * the key is active onchain. Use this for authorizations signed outside
10
+ * `signAuthorization`, such as on another device. Requires a relay running the
11
+ * `Relay.keyAuthorization` plugin.
12
+ *
13
+ * @example
14
+ * ```ts
15
+ * import { Actions, Client, http, withRelay } from 'viem/tempo'
16
+ *
17
+ * const client = Client.create({
18
+ * transport: withRelay(http(), http('https://relay.example.com'), {
19
+ * keyAuthorization: true,
20
+ * }),
21
+ * })
22
+ *
23
+ * await Actions.accessKey.saveAuthorization(client, { keyAuthorization })
24
+ * ```
25
+ *
26
+ * @param client - Client.
27
+ * @param options - Options.
28
+ */
29
+ export async function saveAuthorization(
30
+ client: Client.Client,
31
+ options: saveAuthorization.Options,
32
+ ): Promise<saveAuthorization.ReturnType> {
33
+ await client.request({
34
+ method: 'relay_saveKeyAuthorization',
35
+ params: [KeyAuthorization.toRpc(options.keyAuthorization)],
36
+ })
37
+ }
38
+
39
+ export declare namespace saveAuthorization {
40
+ /** Options for {@link saveAuthorization}. */
41
+ export type Options = {
42
+ /** Signed key authorization to save. */
43
+ keyAuthorization: KeyAuthorization.Signed
44
+ }
45
+
46
+ /** Return value for {@link saveAuthorization}. */
47
+ export type ReturnType = void
48
+
49
+ /** Error type for {@link saveAuthorization}. */
50
+ export type ErrorType = Errors.GlobalErrorType
51
+ }
@@ -1,23 +1,20 @@
1
- import { parseApproval } from '../../multisig/Signature.js'
2
- import { Address, type Errors, type Hex } from 'ox'
3
- import {
4
- KeyAuthorization,
5
- MultisigOperation,
6
- SignatureEnvelope,
7
- } from 'ox/tempo'
1
+ import { parseApproval } from '../../accounts/Signature.js'
2
+ import { Address, type Errors, type Hex, RpcResponse } from 'ox'
3
+ import { AccountOperation, KeyAuthorization, SignatureEnvelope } from 'ox/tempo'
8
4
  import * as CoreAccount from '../../../core/Account.js'
9
5
  import type * as Chain from '../../../core/Chain.js'
10
6
  import type * as Client from '../../../core/Client.js'
11
7
  import type { Compute, OneOf } from '../../../core/internal/types.js'
12
8
  import {
13
- fromMultisig,
9
+ fromConfig,
14
10
  resolveAccessKey,
15
11
  signKeyAuthorization,
16
- type MultisigAccount,
12
+ type ConfigurableAccount,
17
13
  type RootAccount,
18
14
  } from '../../Account.js'
19
- import { getConfig } from '../multisig/getConfig.js'
15
+ import { getConfig } from '../accounts/getConfig.js'
20
16
  import { prepareAuthorization } from './prepareAuthorization.js'
17
+ import { saveAuthorization } from './saveAuthorization.js'
21
18
 
22
19
  /**
23
20
  * Signs a key authorization for an access key.
@@ -25,9 +22,13 @@ import { prepareAuthorization } from './prepareAuthorization.js'
25
22
  * Use {@link prepareAuthorization} before this action when signing requires
26
23
  * transient user activation.
27
24
  *
25
+ * When the client transport is a relay with the `Relay.keyAuthorization` plugin,
26
+ * an authorization signed by the account is saved to the relay, which attaches it
27
+ * to the access key's next transaction.
28
+ *
28
29
  * @param client - Client.
29
30
  * @param parameters - Authorization fields, or a stored operation hash.
30
- * @returns A signed key authorization with multisig operation metadata when coordinated.
31
+ * @returns A signed key authorization with account operation metadata when coordinated.
31
32
  */
32
33
  export function signAuthorization<
33
34
  chain extends Chain.Chain | undefined,
@@ -61,13 +62,13 @@ export async function signAuthorization<
61
62
  const owner_ = parameters_.owner
62
63
  if (!owner_ || typeof owner_ === 'string')
63
64
  throw new Error(
64
- 'A local owner account is required to approve a multisig key authorization.',
65
+ 'A local owner account is required to approve a configurable account key authorization.',
65
66
  )
66
67
  const owner = owner_
67
68
  const sign = owner.sign
68
69
  if (!sign)
69
70
  throw new Error(
70
- 'A local owner account is required to approve a multisig key authorization.',
71
+ 'A local owner account is required to approve a configurable account key authorization.',
71
72
  )
72
73
 
73
74
  const request = await (async () => {
@@ -90,16 +91,16 @@ export async function signAuthorization<
90
91
  const config = await getConfig(client, { address })
91
92
  if (config) return config
92
93
  throw new Error(
93
- `No current multisig config is cached for account ${address}. Provide the current config.`,
94
+ `No current account config is cached for account ${address}. Provide the current config.`,
94
95
  )
95
96
  })()
96
97
  const account = (() => {
97
- if (config.version !== 0n) return fromMultisig({ address, ...config })
98
+ if (config.version !== 0n) return fromConfig({ address, ...config })
98
99
  const { version: _, ...initialConfig } = config
99
- return fromMultisig({ address: 'infer', ...initialConfig })
100
+ return fromConfig({ address: 'infer', ...initialConfig })
100
101
  })()
101
102
  if (!Address.isEqual(account.address, address))
102
- throw new Error('Initial multisig config does not match the account.')
103
+ throw new Error('Initial account config does not match the account.')
103
104
  const prepared = await prepareAuthorization(client, {
104
105
  ...authorization,
105
106
  account,
@@ -127,41 +128,43 @@ export async function signAuthorization<
127
128
  })()
128
129
 
129
130
  const operation = await client.request({
130
- method: 'multisig_approveKeyAuthorization',
131
+ method: 'account_approveKeyAuthorization',
131
132
  params: [request],
132
133
  })
133
- const multisig = MultisigOperation.fromRpc(
134
- operation as MultisigOperation.KeyAuthorizationRpc,
134
+ const operation_ = AccountOperation.fromRpc(
135
+ operation as AccountOperation.KeyAuthorizationRpc,
135
136
  )
136
137
  const keyAuthorization = KeyAuthorization.deserialize(
137
138
  await (async () => {
138
- if (multisig.status === 'success') return multisig.keyAuthorization
139
- const approvals = await MultisigOperation.selectApprovals({
140
- account: multisig.account,
141
- approvals: multisig.approvals,
142
- config: multisig.config,
143
- hash: multisig.hash,
139
+ if (operation_.status === 'success') return operation_.keyAuthorization
140
+ const approvals = await AccountOperation.selectApprovals({
141
+ account: operation_.account,
142
+ approvals: operation_.approvals,
143
+ config: operation_.config,
144
+ hash: operation_.hash,
144
145
  })
145
- return MultisigOperation.serializeKeyAuthorization(
146
- multisig.keyAuthorization,
146
+ return AccountOperation.serializeKeyAuthorization(
147
+ operation_.keyAuthorization,
147
148
  {
148
- account: multisig.account,
149
+ account: operation_.account,
149
150
  approvals:
150
151
  approvals.selectedApprovals.length > 0
151
152
  ? approvals.selectedApprovals
152
153
  : approvals.approvals.slice(0, 1),
153
- config: multisig.config,
154
+ config: operation_.config,
154
155
  },
155
156
  )
156
157
  })(),
157
158
  )
158
159
  if (!keyAuthorization.signature)
159
- throw new Error('Expected a signed multisig key authorization.')
160
+ throw new Error(
161
+ 'Expected a signed configurable account key authorization.',
162
+ )
160
163
  return {
161
164
  ...keyAuthorization,
162
- hash: multisig.hash,
163
- multisig,
164
- status: multisig.status,
165
+ hash: operation_.hash,
166
+ operation: operation_,
167
+ status: operation_.status,
165
168
  } as signAuthorization.CoordinatedReturnType
166
169
  }
167
170
 
@@ -177,26 +180,45 @@ export async function signAuthorization<
177
180
  accessKey,
178
181
  account: account_,
179
182
  chainId,
180
- multisig: multisigState,
183
+ configurable: configurableState,
181
184
  signPayload: _,
182
185
  ...rest
183
186
  } = prepared
184
- return signKeyAuthorization(account_ as CoreAccount.Local, {
185
- chainId: BigInt(chainId),
186
- key: accessKey,
187
- multisig: multisigState,
188
- ...rest,
189
- })
187
+ const keyAuthorization = await signKeyAuthorization(
188
+ account_ as CoreAccount.Local,
189
+ {
190
+ chainId: BigInt(chainId),
191
+ key: accessKey,
192
+ configurable: configurableState,
193
+ ...rest,
194
+ },
195
+ )
196
+ // Admin-signed authorizations can only be submitted by the admin key.
197
+ if (
198
+ 'keyAuthorization' in client.transport &&
199
+ client.transport.keyAuthorization &&
200
+ !('source' in account_ && account_.source === 'accessKey')
201
+ )
202
+ await saveAuthorization(client, { keyAuthorization }).catch((error) => {
203
+ // Remote relays without key authorization storage do not expose this method.
204
+ if (
205
+ error instanceof RpcResponse.MethodNotFoundError ||
206
+ error instanceof RpcResponse.MethodNotSupportedError
207
+ )
208
+ return
209
+ throw error
210
+ })
211
+ return keyAuthorization
190
212
  }
191
213
 
192
214
  export namespace signAuthorization {
193
215
  /** Initial coordinated key authorization parameters. */
194
216
  export type CoordinatedInitialOptions = Omit<
195
217
  prepareAuthorization.Options<CoreAccount.Account>,
196
- 'account' | 'multisig'
218
+ 'account' | 'configurable'
197
219
  > & {
198
- /** Multisig account being authorized. */
199
- account: Address.Address | MultisigAccount
220
+ /** Configurable account being authorized. */
221
+ account: Address.Address | ConfigurableAccount
200
222
  /** Local owner that approves the authorization. */
201
223
  owner: RootAccount
202
224
  }
@@ -205,7 +227,7 @@ export namespace signAuthorization {
205
227
  export type CoordinatedOptions = OneOf<
206
228
  | CoordinatedInitialOptions
207
229
  | {
208
- /** Stored multisig operation hash. */
230
+ /** Stored account operation hash. */
209
231
  hash: Hex.Hex
210
232
  /** Local owner that approves the authorization. */
211
233
  owner: RootAccount
@@ -218,7 +240,7 @@ export namespace signAuthorization {
218
240
  | CoreAccount.Account
219
241
  | undefined,
220
242
  > = prepareAuthorization.Options<account> & {
221
- /** Serialized approvals from external multisig owners. */
243
+ /** Serialized approvals from external owners. */
222
244
  signatures?: readonly SignatureEnvelope.Serialized[] | undefined
223
245
  }
224
246
 
@@ -235,12 +257,12 @@ export namespace signAuthorization {
235
257
  /** Coordinated return value for {@link signAuthorization}. */
236
258
  export type CoordinatedReturnType = Compute<
237
259
  ReturnType & {
238
- /** Deterministic multisig operation hash. */
260
+ /** Deterministic account operation hash. */
239
261
  hash: Hex.Hex
240
- /** Current multisig operation. */
241
- multisig: MultisigOperation.KeyAuthorizationOperation
242
- /** Current multisig operation status. */
243
- status: MultisigOperation.KeyAuthorizationOperation['status']
262
+ /** Current account operation. */
263
+ operation: AccountOperation.KeyAuthorizationOperation
264
+ /** Current account operation status. */
265
+ status: AccountOperation.KeyAuthorizationOperation['status']
244
266
  }
245
267
  >
246
268