viem 2.57.4 → 2.57.5

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 (223) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/_cjs/actions/public/waitForTransactionReceipt.js +5 -2
  3. package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
  4. package/_cjs/actions/wallet/waitForCallsStatus.js +25 -2
  5. package/_cjs/actions/wallet/waitForCallsStatus.js.map +1 -1
  6. package/_cjs/chains/definitions/arcTestnet.js +11 -8
  7. package/_cjs/chains/definitions/arcTestnet.js.map +1 -1
  8. package/_cjs/chains/definitions/qmsTestnet.js +30 -0
  9. package/_cjs/chains/definitions/qmsTestnet.js.map +1 -0
  10. package/_cjs/chains/definitions/tempo.js +1 -1
  11. package/_cjs/chains/definitions/tempoModerato.js +2 -2
  12. package/_cjs/chains/index.js +7 -5
  13. package/_cjs/chains/index.js.map +1 -1
  14. package/_cjs/clients/transports/ipc.js +19 -10
  15. package/_cjs/clients/transports/ipc.js.map +1 -1
  16. package/_cjs/clients/transports/webSocket.js +19 -10
  17. package/_cjs/clients/transports/webSocket.js.map +1 -1
  18. package/_cjs/errors/version.js +1 -1
  19. package/_cjs/tempo/Account.js +40 -40
  20. package/_cjs/tempo/Account.js.map +1 -1
  21. package/_cjs/tempo/Decorator.js +9 -8
  22. package/_cjs/tempo/Decorator.js.map +1 -1
  23. package/_cjs/tempo/ExecutionError.js +1 -1
  24. package/_cjs/tempo/ExecutionError.js.map +1 -1
  25. package/_cjs/tempo/Formatters.js +8 -7
  26. package/_cjs/tempo/Formatters.js.map +1 -1
  27. package/_cjs/tempo/KeyAuthorizationManager.js +25 -16
  28. package/_cjs/tempo/KeyAuthorizationManager.js.map +1 -1
  29. package/_cjs/tempo/Relay.js +9 -4
  30. package/_cjs/tempo/Relay.js.map +1 -1
  31. package/_cjs/tempo/Transaction.js +9 -9
  32. package/_cjs/tempo/Transaction.js.map +1 -1
  33. package/_cjs/tempo/Transport.js +21 -11
  34. package/_cjs/tempo/Transport.js.map +1 -1
  35. package/_cjs/tempo/{multisig → accounts}/Config.js +8 -8
  36. package/_cjs/tempo/{multisig → accounts}/Config.js.map +1 -1
  37. package/_cjs/tempo/{multisig → accounts}/Operation.js +10 -10
  38. package/_cjs/tempo/{multisig → accounts}/Operation.js.map +1 -1
  39. package/_cjs/tempo/{multisig → accounts}/Signature.js +2 -2
  40. package/_cjs/tempo/accounts/Signature.js.map +1 -0
  41. package/_cjs/tempo/actions/accessKey.js +60 -37
  42. package/_cjs/tempo/actions/accessKey.js.map +1 -1
  43. package/_cjs/tempo/actions/{multisig.js → accounts.js} +13 -18
  44. package/_cjs/tempo/actions/accounts.js.map +1 -0
  45. package/_cjs/tempo/actions/index.js +2 -2
  46. package/_cjs/tempo/actions/index.js.map +1 -1
  47. package/_cjs/tempo/chainConfig.js +37 -37
  48. package/_cjs/tempo/chainConfig.js.map +1 -1
  49. package/_cjs/tempo/index.js +3 -3
  50. package/_cjs/tempo/index.js.map +1 -1
  51. package/_cjs/tempo/internal/relay/{multisig.js → accounts.js} +90 -93
  52. package/_cjs/tempo/internal/relay/accounts.js.map +1 -0
  53. package/_cjs/tempo/internal/relay/keyAuthorization.js +296 -0
  54. package/_cjs/tempo/internal/relay/keyAuthorization.js.map +1 -0
  55. package/_cjs/tempo/internal/relay/plugin.js +17 -7
  56. package/_cjs/tempo/internal/relay/plugin.js.map +1 -1
  57. package/_cjs/utils/hash/normalizeSignature.js +1 -1
  58. package/_cjs/utils/hash/normalizeSignature.js.map +1 -1
  59. package/_cjs/utils/rpc/http.js +66 -31
  60. package/_cjs/utils/rpc/http.js.map +1 -1
  61. package/_cjs/utils/rpc/socket.js +1 -1
  62. package/_cjs/utils/rpc/socket.js.map +1 -1
  63. package/_esm/actions/public/waitForTransactionReceipt.js +5 -2
  64. package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
  65. package/_esm/actions/wallet/waitForCallsStatus.js +39 -2
  66. package/_esm/actions/wallet/waitForCallsStatus.js.map +1 -1
  67. package/_esm/chains/definitions/arcTestnet.js +11 -8
  68. package/_esm/chains/definitions/arcTestnet.js.map +1 -1
  69. package/_esm/chains/definitions/qmsTestnet.js +27 -0
  70. package/_esm/chains/definitions/qmsTestnet.js.map +1 -0
  71. package/_esm/chains/definitions/tempo.js +1 -1
  72. package/_esm/chains/definitions/tempoModerato.js +2 -2
  73. package/_esm/chains/index.js +1 -0
  74. package/_esm/chains/index.js.map +1 -1
  75. package/_esm/clients/transports/ipc.js +21 -10
  76. package/_esm/clients/transports/ipc.js.map +1 -1
  77. package/_esm/clients/transports/webSocket.js +21 -10
  78. package/_esm/clients/transports/webSocket.js.map +1 -1
  79. package/_esm/errors/version.js +1 -1
  80. package/_esm/tempo/Account.js +42 -42
  81. package/_esm/tempo/Account.js.map +1 -1
  82. package/_esm/tempo/Client.js +3 -3
  83. package/_esm/tempo/Decorator.js +9 -8
  84. package/_esm/tempo/Decorator.js.map +1 -1
  85. package/_esm/tempo/ExecutionError.js +1 -1
  86. package/_esm/tempo/ExecutionError.js.map +1 -1
  87. package/_esm/tempo/Formatters.js +11 -10
  88. package/_esm/tempo/Formatters.js.map +1 -1
  89. package/_esm/tempo/KeyAuthorizationManager.js +58 -16
  90. package/_esm/tempo/KeyAuthorizationManager.js.map +1 -1
  91. package/_esm/tempo/Relay.js +49 -8
  92. package/_esm/tempo/Relay.js.map +1 -1
  93. package/_esm/tempo/Transaction.js +11 -11
  94. package/_esm/tempo/Transaction.js.map +1 -1
  95. package/_esm/tempo/Transport.js +22 -12
  96. package/_esm/tempo/Transport.js.map +1 -1
  97. package/_esm/tempo/{multisig → accounts}/Config.js +14 -14
  98. package/_esm/tempo/{multisig → accounts}/Config.js.map +1 -1
  99. package/_esm/tempo/{multisig → accounts}/Operation.js +17 -17
  100. package/_esm/tempo/{multisig → accounts}/Operation.js.map +1 -1
  101. package/_esm/tempo/accounts/Signature.js +9 -0
  102. package/_esm/tempo/accounts/Signature.js.map +1 -0
  103. package/_esm/tempo/actions/accessKey.js +93 -38
  104. package/_esm/tempo/actions/accessKey.js.map +1 -1
  105. package/_esm/tempo/actions/{multisig.js → accounts.js} +31 -36
  106. package/_esm/tempo/actions/accounts.js.map +1 -0
  107. package/_esm/tempo/actions/index.js +1 -1
  108. package/_esm/tempo/actions/index.js.map +1 -1
  109. package/_esm/tempo/chainConfig.js +38 -38
  110. package/_esm/tempo/chainConfig.js.map +1 -1
  111. package/_esm/tempo/index.js +2 -1
  112. package/_esm/tempo/index.js.map +1 -1
  113. package/_esm/tempo/internal/relay/{multisig.js → accounts.js} +93 -98
  114. package/_esm/tempo/internal/relay/accounts.js.map +1 -0
  115. package/_esm/tempo/internal/relay/feePayer.js +1 -1
  116. package/_esm/tempo/internal/relay/feePayer.js.map +1 -1
  117. package/_esm/tempo/internal/relay/keyAuthorization.js +334 -0
  118. package/_esm/tempo/internal/relay/keyAuthorization.js.map +1 -0
  119. package/_esm/tempo/internal/relay/plugin.js +15 -6
  120. package/_esm/tempo/internal/relay/plugin.js.map +1 -1
  121. package/_esm/utils/hash/normalizeSignature.js +3 -2
  122. package/_esm/utils/hash/normalizeSignature.js.map +1 -1
  123. package/_esm/utils/rpc/http.js +74 -31
  124. package/_esm/utils/rpc/http.js.map +1 -1
  125. package/_esm/utils/rpc/socket.js +3 -1
  126. package/_esm/utils/rpc/socket.js.map +1 -1
  127. package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
  128. package/_types/actions/wallet/waitForCallsStatus.d.ts.map +1 -1
  129. package/_types/chains/definitions/arcTestnet.d.ts +5 -5
  130. package/_types/chains/definitions/arcTestnet.d.ts.map +1 -1
  131. package/_types/chains/definitions/qmsTestnet.d.ts +50 -0
  132. package/_types/chains/definitions/qmsTestnet.d.ts.map +1 -0
  133. package/_types/chains/definitions/tempo.d.ts +2 -2
  134. package/_types/chains/definitions/tempoModerato.d.ts +4 -4
  135. package/_types/chains/index.d.ts +1 -0
  136. package/_types/chains/index.d.ts.map +1 -1
  137. package/_types/clients/transports/ipc.d.ts.map +1 -1
  138. package/_types/clients/transports/webSocket.d.ts.map +1 -1
  139. package/_types/errors/version.d.ts +1 -1
  140. package/_types/tempo/Account.d.ts +28 -28
  141. package/_types/tempo/Account.d.ts.map +1 -1
  142. package/_types/tempo/Client.d.ts +3 -3
  143. package/_types/tempo/Decorator.d.ts +63 -37
  144. package/_types/tempo/Decorator.d.ts.map +1 -1
  145. package/_types/tempo/Formatters.d.ts.map +1 -1
  146. package/_types/tempo/KeyAuthorizationManager.d.ts +45 -2
  147. package/_types/tempo/KeyAuthorizationManager.d.ts.map +1 -1
  148. package/_types/tempo/Relay.d.ts +62 -12
  149. package/_types/tempo/Relay.d.ts.map +1 -1
  150. package/_types/tempo/Transaction.d.ts +14 -11
  151. package/_types/tempo/Transaction.d.ts.map +1 -1
  152. package/_types/tempo/Transport.d.ts +20 -7
  153. package/_types/tempo/Transport.d.ts.map +1 -1
  154. package/_types/tempo/{multisig → accounts}/Config.d.ts +7 -7
  155. package/_types/tempo/accounts/Config.d.ts.map +1 -0
  156. package/_types/tempo/{multisig → accounts}/Operation.d.ts +7 -7
  157. package/_types/tempo/accounts/Operation.d.ts.map +1 -0
  158. package/_types/tempo/{multisig → accounts}/Signature.d.ts +1 -1
  159. package/_types/tempo/accounts/Signature.d.ts.map +1 -0
  160. package/_types/tempo/actions/accessKey.d.ts +59 -17
  161. package/_types/tempo/actions/accessKey.d.ts.map +1 -1
  162. package/_types/tempo/actions/{multisig.d.ts → accounts.d.ts} +28 -28
  163. package/_types/tempo/actions/{multisig.d.ts.map → accounts.d.ts.map} +1 -1
  164. package/_types/tempo/actions/index.d.ts +1 -1
  165. package/_types/tempo/actions/index.d.ts.map +1 -1
  166. package/_types/tempo/index.d.ts +3 -2
  167. package/_types/tempo/index.d.ts.map +1 -1
  168. package/_types/tempo/internal/relay/accounts.d.ts +15 -0
  169. package/_types/tempo/internal/relay/accounts.d.ts.map +1 -0
  170. package/_types/tempo/internal/relay/keyAuthorization.d.ts +25 -0
  171. package/_types/tempo/internal/relay/keyAuthorization.d.ts.map +1 -0
  172. package/_types/tempo/internal/relay/plugin.d.ts +6 -3
  173. package/_types/tempo/internal/relay/plugin.d.ts.map +1 -1
  174. package/_types/utils/hash/normalizeSignature.d.ts.map +1 -1
  175. package/_types/utils/rpc/http.d.ts.map +1 -1
  176. package/_types/utils/rpc/socket.d.ts.map +1 -1
  177. package/actions/public/waitForTransactionReceipt.ts +8 -2
  178. package/actions/wallet/waitForCallsStatus.ts +41 -2
  179. package/chains/definitions/arcTestnet.ts +11 -8
  180. package/chains/definitions/qmsTestnet.ts +27 -0
  181. package/chains/definitions/tempo.ts +1 -1
  182. package/chains/definitions/tempoModerato.ts +2 -2
  183. package/chains/index.ts +1 -0
  184. package/clients/transports/ipc.ts +38 -29
  185. package/clients/transports/webSocket.ts +42 -33
  186. package/errors/version.ts +1 -1
  187. package/package.json +2 -2
  188. package/tempo/Account.ts +95 -84
  189. package/tempo/Client.ts +3 -3
  190. package/tempo/Decorator.ts +86 -57
  191. package/tempo/ExecutionError.ts +1 -1
  192. package/tempo/Formatters.ts +14 -13
  193. package/tempo/KeyAuthorizationManager.ts +71 -19
  194. package/tempo/Relay.ts +70 -14
  195. package/tempo/Transaction.ts +31 -23
  196. package/tempo/Transport.ts +49 -21
  197. package/tempo/{multisig → accounts}/Config.ts +21 -21
  198. package/tempo/{multisig → accounts}/Operation.ts +26 -26
  199. package/tempo/{multisig → accounts}/Signature.ts +5 -3
  200. package/tempo/actions/accessKey.ts +179 -79
  201. package/tempo/actions/{multisig.ts → accounts.ts} +47 -56
  202. package/tempo/actions/index.ts +1 -1
  203. package/tempo/chainConfig.ts +52 -52
  204. package/tempo/index.ts +5 -4
  205. package/tempo/internal/relay/{multisig.ts → accounts.ts} +118 -118
  206. package/tempo/internal/relay/feePayer.ts +1 -1
  207. package/tempo/internal/relay/keyAuthorization.ts +415 -0
  208. package/tempo/internal/relay/plugin.ts +20 -7
  209. package/utils/hash/normalizeSignature.ts +3 -2
  210. package/utils/rpc/http.ts +76 -30
  211. package/utils/rpc/socket.ts +3 -1
  212. package/_cjs/tempo/actions/multisig.js.map +0 -1
  213. package/_cjs/tempo/internal/relay/multisig.js.map +0 -1
  214. package/_cjs/tempo/multisig/Signature.js.map +0 -1
  215. package/_esm/tempo/actions/multisig.js.map +0 -1
  216. package/_esm/tempo/internal/relay/multisig.js.map +0 -1
  217. package/_esm/tempo/multisig/Signature.js +0 -9
  218. package/_esm/tempo/multisig/Signature.js.map +0 -1
  219. package/_types/tempo/internal/relay/multisig.d.ts +0 -4
  220. package/_types/tempo/internal/relay/multisig.d.ts.map +0 -1
  221. package/_types/tempo/multisig/Config.d.ts.map +0 -1
  222. package/_types/tempo/multisig/Operation.d.ts.map +0 -1
  223. package/_types/tempo/multisig/Signature.d.ts.map +0 -1
@@ -1,9 +1,9 @@
1
1
  import type { Address } from 'abitype'
2
2
  import type * as RpcSchema from 'ox/RpcSchema'
3
3
  import {
4
+ AccountConfig,
5
+ AccountOperation,
4
6
  KeyAuthorization,
5
- MultisigConfig,
6
- MultisigOperation,
7
7
  type RpcSchemaTempo,
8
8
  SignatureEnvelope,
9
9
  } from 'ox/tempo'
@@ -21,6 +21,10 @@ import { writeContractSync } from '../../actions/wallet/writeContractSync.js'
21
21
  import type { Client } from '../../clients/createClient.js'
22
22
  import type { Transport } from '../../clients/transports/createTransport.js'
23
23
  import type { BaseErrorType } from '../../errors/base.js'
24
+ import {
25
+ MethodNotFoundRpcError,
26
+ MethodNotSupportedRpcError,
27
+ } from '../../errors/rpc.js'
24
28
  import type { Chain } from '../../types/chain.js'
25
29
  import type { ExtractAbiItem, GetEventArgs } from '../../types/contract.js'
26
30
  import type { Log, Log as viem_Log } from '../../types/log.js'
@@ -31,16 +35,17 @@ import { isAddressEqual } from '../../utils/address/isAddressEqual.js'
31
35
  import * as Abis from '../Abis.js'
32
36
  import type {
33
37
  AccessKeyAccount,
34
- MultisigAccount,
38
+ ConfigurableAccount,
35
39
  RootAccount,
36
40
  } from '../Account.js'
37
41
  import {
38
- fromMultisig,
42
+ fromConfig,
39
43
  getKeyAuthorizationSignPayload,
40
44
  resolveAccessKey,
41
45
  signKeyAuthorization,
42
46
  } from '../Account.js'
43
47
  import * as Addresses from '../Addresses.js'
48
+ import { parseApproval } from '../accounts/Signature.js'
44
49
  import * as Hardfork from '../Hardfork.js'
45
50
  import type {
46
51
  GetAccountParameter,
@@ -48,9 +53,8 @@ import type {
48
53
  WriteParameters,
49
54
  } from '../internal/types.js'
50
55
  import { defineCall } from '../internal/utils.js'
51
- import { parseApproval } from '../multisig/Signature.js'
52
56
  import type { TransactionReceipt } from '../Transaction.js'
53
- import { getConfig } from './multisig.js'
57
+ import { getConfig } from './accounts.js'
54
58
 
55
59
  /** @internal */
56
60
  const signatureTypes = {
@@ -174,7 +178,7 @@ export namespace authorize {
174
178
  const account_ = rest.account ?? client.account
175
179
  if (!account_) throw new Error('account is required.')
176
180
  if (!chainId) throw new Error('chainId is required.')
177
- const keyAuthorization = await signAuthorization(client, {
181
+ const keyAuthorization = await signLocal(client, {
178
182
  account: account_,
179
183
  accessKey,
180
184
  chainId,
@@ -1058,13 +1062,13 @@ export async function prepareAuthorization<
1058
1062
  if (!account_) throw new Error('account is required.')
1059
1063
  if (!chainId) throw new Error('chainId is required.')
1060
1064
  const parsed = parseAccount(account_)
1061
- const multisigState = await (async () => {
1062
- if ('multisig' in parameters) return parameters.multisig
1063
- if (parsed.source !== 'multisig') return undefined
1064
- const account = parsed as MultisigAccount
1065
+ const configurableState = await (async () => {
1066
+ if ('configurable' in parameters) return parameters.configurable
1067
+ if (parsed.source !== 'configurable') return undefined
1068
+ const account = parsed as ConfigurableAccount
1065
1069
  if (!account.config)
1066
1070
  throw new Error(
1067
- 'A multisig config is required to prepare a key authorization.',
1071
+ 'An account config is required to prepare a key authorization.',
1068
1072
  )
1069
1073
  return { config: account.config }
1070
1074
  })()
@@ -1077,10 +1081,10 @@ export async function prepareAuthorization<
1077
1081
  },
1078
1082
  )
1079
1083
  const signPayload =
1080
- parsed.source === 'multisig' && multisigState
1081
- ? MultisigConfig.getSignPayload({
1084
+ parsed.source === 'configurable' && configurableState
1085
+ ? AccountConfig.getSignPayload({
1082
1086
  account: parsed.address,
1083
- config: multisigState.config,
1087
+ config: configurableState.config,
1084
1088
  payload: authorizationSignPayload,
1085
1089
  })
1086
1090
  : authorizationSignPayload
@@ -1088,7 +1092,7 @@ export async function prepareAuthorization<
1088
1092
  ...parameters,
1089
1093
  account: parsed,
1090
1094
  chainId,
1091
- multisig: multisigState,
1095
+ configurable: configurableState,
1092
1096
  signPayload,
1093
1097
  } as never
1094
1098
  }
@@ -1115,8 +1119,8 @@ export namespace prepareAuthorization {
1115
1119
  limits?:
1116
1120
  | { token: Address; limit: bigint; period?: number | undefined }[]
1117
1121
  | undefined
1118
- /** @internal Prepared multisig state. */
1119
- multisig?: signKeyAuthorization.Parameters['multisig']
1122
+ /** @internal Prepared configurable account state. */
1123
+ configurable?: signKeyAuthorization.Parameters['configurable']
1120
1124
  /** Call scopes restricting which contracts/selectors this key can call. */
1121
1125
  scopes?: KeyAuthorization.Scope[] | undefined
1122
1126
  /**
@@ -1136,22 +1140,81 @@ export namespace prepareAuthorization {
1136
1140
  Omit<Parameters<Account | undefined>, 'account' | 'chainId'> & {
1137
1141
  account: Account
1138
1142
  chainId: number
1139
- multisig: signKeyAuthorization.Parameters['multisig']
1140
- /** Payload that the authorizing account or multisig owners sign. */
1143
+ configurable: signKeyAuthorization.Parameters['configurable']
1144
+ /** Payload that the authorizing account or owners sign. */
1141
1145
  signPayload: Hex
1142
1146
  }
1143
1147
  >
1144
1148
  }
1145
1149
 
1150
+ /**
1151
+ * Saves a signed key authorization to a relay with key authorization storage.
1152
+ *
1153
+ * The relay attaches the authorization to the access key's next transaction until
1154
+ * the key is active onchain. Use this for authorizations signed outside
1155
+ * {@link signAuthorization}, such as on another device. Requires a relay running the
1156
+ * `Relay.keyAuthorization` plugin.
1157
+ *
1158
+ * @example
1159
+ * ```ts
1160
+ * import { createClient, http } from 'viem'
1161
+ * import { tempo } from 'viem/chains'
1162
+ * import { Actions, withRelay } from 'viem/tempo'
1163
+ *
1164
+ * const client = createClient({
1165
+ * chain: tempo,
1166
+ * transport: withRelay(http(), http('https://relay.example.com'), {
1167
+ * keyAuthorization: true,
1168
+ * }),
1169
+ * })
1170
+ *
1171
+ * await Actions.accessKey.saveAuthorization(client, {
1172
+ * keyAuthorization,
1173
+ * })
1174
+ * ```
1175
+ *
1176
+ * @param client - Client.
1177
+ * @param parameters - Parameters.
1178
+ */
1179
+ export async function saveAuthorization<
1180
+ chain extends Chain | undefined,
1181
+ account extends Account | undefined,
1182
+ >(
1183
+ client: Client<Transport, chain, account>,
1184
+ parameters: saveAuthorization.Parameters,
1185
+ ): Promise<saveAuthorization.ReturnValue> {
1186
+ const { keyAuthorization } = parameters
1187
+ await client.request<relay_saveKeyAuthorization>({
1188
+ method: 'relay_saveKeyAuthorization',
1189
+ params: [KeyAuthorization.toRpc(keyAuthorization)],
1190
+ })
1191
+ }
1192
+
1193
+ export namespace saveAuthorization {
1194
+ export type Parameters = {
1195
+ /** Signed key authorization to save. */
1196
+ keyAuthorization: KeyAuthorization.Signed
1197
+ }
1198
+
1199
+ export type ReturnValue = void
1200
+
1201
+ // TODO: exhaustive error type
1202
+ export type ErrorType = BaseErrorType
1203
+ }
1204
+
1146
1205
  /**
1147
1206
  * Signs a key authorization for an access key.
1148
1207
  *
1149
1208
  * Use {@link prepareAuthorization} before this action when signing requires
1150
1209
  * transient user activation.
1151
1210
  *
1211
+ * When the client transport is a relay with the `Relay.keyAuthorization` plugin,
1212
+ * an authorization signed by the account is saved to the relay, which attaches it
1213
+ * to the access key's next transaction.
1214
+ *
1152
1215
  * @param client - Client.
1153
1216
  * @param parameters - Authorization fields, or a stored operation hash.
1154
- * @returns A signed key authorization with multisig operation metadata when coordinated.
1217
+ * @returns A signed key authorization with account operation metadata when coordinated.
1155
1218
  */
1156
1219
  export function signAuthorization<
1157
1220
  chain extends Chain | undefined,
@@ -1185,13 +1248,13 @@ export async function signAuthorization<
1185
1248
  const owner_ = parameters_.owner
1186
1249
  if (!owner_ || typeof owner_ === 'string')
1187
1250
  throw new Error(
1188
- 'A local owner account is required to approve a multisig key authorization.',
1251
+ 'A local owner account is required to approve a configurable account key authorization.',
1189
1252
  )
1190
1253
  const owner = parseAccount(owner_)
1191
1254
  const sign = owner.sign
1192
1255
  if (!sign)
1193
1256
  throw new Error(
1194
- 'A local owner account is required to approve a multisig key authorization.',
1257
+ 'A local owner account is required to approve a configurable account key authorization.',
1195
1258
  )
1196
1259
 
1197
1260
  const request = await (async () => {
@@ -1214,16 +1277,16 @@ export async function signAuthorization<
1214
1277
  const config = await getConfig(client, { address })
1215
1278
  if (config) return config
1216
1279
  throw new Error(
1217
- `No current multisig config is cached for account ${address}. Provide the current config.`,
1280
+ `No current account config is cached for account ${address}. Provide the current config.`,
1218
1281
  )
1219
1282
  })()
1220
1283
  const account = (() => {
1221
- if (config.version !== 0n) return fromMultisig({ address, ...config })
1284
+ if (config.version !== 0n) return fromConfig({ address, ...config })
1222
1285
  const { version: _, ...initialConfig } = config
1223
- return fromMultisig({ address: 'infer', ...initialConfig })
1286
+ return fromConfig({ address: 'infer', ...initialConfig })
1224
1287
  })()
1225
1288
  if (!isAddressEqual(account.address, address))
1226
- throw new Error('Initial multisig config does not match the account.')
1289
+ throw new Error('Initial account config does not match the account.')
1227
1290
  const prepared = await prepareAuthorization(client, {
1228
1291
  ...authorization,
1229
1292
  account,
@@ -1250,79 +1313,81 @@ export async function signAuthorization<
1250
1313
  return { keyAuthorization: KeyAuthorization.toRpc(keyAuthorization) }
1251
1314
  })()
1252
1315
 
1253
- type multisig_approveKeyAuthorization = Extract<
1254
- RpcSchema.ToViem<RpcSchemaTempo.Multisig>[number],
1255
- { Method: 'multisig_approveKeyAuthorization' }
1316
+ type account_approveKeyAuthorization = Extract<
1317
+ RpcSchema.ToViem<RpcSchemaTempo.Account>[number],
1318
+ { Method: 'account_approveKeyAuthorization' }
1256
1319
  >
1257
- const operation = await client.request<multisig_approveKeyAuthorization>({
1258
- method: 'multisig_approveKeyAuthorization',
1320
+ const operation = await client.request<account_approveKeyAuthorization>({
1321
+ method: 'account_approveKeyAuthorization',
1259
1322
  params: [request],
1260
1323
  })
1261
- const multisig = MultisigOperation.fromRpc(operation)
1324
+ const operation_ = AccountOperation.fromRpc(operation)
1262
1325
  const keyAuthorization = KeyAuthorization.deserialize(
1263
1326
  await (async () => {
1264
- if (multisig.status === 'success') return multisig.keyAuthorization
1265
- const approvals = await MultisigOperation.selectApprovals({
1266
- account: multisig.account,
1267
- approvals: multisig.approvals,
1268
- config: multisig.config,
1269
- hash: multisig.hash,
1327
+ if (operation_.status === 'success') return operation_.keyAuthorization
1328
+ const approvals = await AccountOperation.selectApprovals({
1329
+ account: operation_.account,
1330
+ approvals: operation_.approvals,
1331
+ config: operation_.config,
1332
+ hash: operation_.hash,
1270
1333
  })
1271
- return MultisigOperation.serializeKeyAuthorization(
1272
- multisig.keyAuthorization,
1334
+ return AccountOperation.serializeKeyAuthorization(
1335
+ operation_.keyAuthorization,
1273
1336
  {
1274
- account: multisig.account,
1337
+ account: operation_.account,
1275
1338
  approvals:
1276
1339
  approvals.selectedApprovals.length > 0
1277
1340
  ? approvals.selectedApprovals
1278
1341
  : approvals.approvals.slice(0, 1),
1279
- config: multisig.config,
1342
+ config: operation_.config,
1280
1343
  },
1281
1344
  )
1282
1345
  })(),
1283
1346
  )
1284
1347
  if (!keyAuthorization.signature)
1285
- throw new Error('Expected a signed multisig key authorization.')
1348
+ throw new Error(
1349
+ 'Expected a signed configurable account key authorization.',
1350
+ )
1286
1351
  return {
1287
1352
  ...keyAuthorization,
1288
- hash: multisig.hash,
1289
- multisig,
1290
- status: multisig.status,
1353
+ hash: operation_.hash,
1354
+ operation: operation_,
1355
+ status: operation_.status,
1291
1356
  } as never
1292
1357
  }
1293
1358
 
1294
- const prepared = (
1295
- 'signPayload' in parameters
1296
- ? parameters
1297
- : await prepareAuthorization(
1298
- client,
1299
- parameters as signAuthorization.LocalParameters<account>,
1300
- )
1301
- ) as prepareAuthorization.ReturnValue
1302
- const {
1303
- accessKey,
1304
- account: account_,
1305
- chainId,
1306
- multisig: multisigState,
1307
- signPayload: _,
1308
- ...rest
1309
- } = prepared
1310
- return signKeyAuthorization(account_ as never, {
1311
- chainId: BigInt(chainId),
1312
- key: accessKey,
1313
- multisig: multisigState,
1314
- ...rest,
1315
- }) as never
1359
+ const keyAuthorization = await signLocal(
1360
+ client,
1361
+ parameters as signAuthorization.LocalParameters<account>,
1362
+ )
1363
+ const signer = parameters.account ?? client.account
1364
+ // Relays with key authorization storage attach it to the access key's next
1365
+ // transaction. Admin-signed authorizations can only be submitted by the admin key.
1366
+ if (
1367
+ (client.transport as { keyAuthorization?: boolean }).keyAuthorization &&
1368
+ signer &&
1369
+ parseAccount(signer).source !== 'accessKey'
1370
+ )
1371
+ await saveAuthorization(client, { keyAuthorization }).catch((error) => {
1372
+ // Remote relays without key authorization storage do not expose this method.
1373
+ if (
1374
+ error instanceof MethodNotFoundRpcError ||
1375
+ error instanceof MethodNotSupportedRpcError
1376
+ )
1377
+ return
1378
+ throw error
1379
+ })
1380
+ return keyAuthorization
1316
1381
  }
1317
1382
 
1318
1383
  export namespace signAuthorization {
1319
1384
  /** Initial coordinated key authorization parameters. */
1320
1385
  export type CoordinatedInitialParameters = Omit<
1321
1386
  prepareAuthorization.Parameters<Account>,
1322
- 'account' | 'multisig'
1387
+ 'account' | 'configurable'
1323
1388
  > & {
1324
- /** Multisig account being authorized. */
1325
- account: Address | MultisigAccount
1389
+ /** Configurable account being authorized. */
1390
+ account: Address | ConfigurableAccount
1326
1391
  /** Local owner that approves the authorization. */
1327
1392
  owner: RootAccount
1328
1393
  }
@@ -1331,7 +1396,7 @@ export namespace signAuthorization {
1331
1396
  export type CoordinatedParameters = OneOf<
1332
1397
  | CoordinatedInitialParameters
1333
1398
  | {
1334
- /** Stored multisig operation hash. */
1399
+ /** Stored account operation hash. */
1335
1400
  hash: Hex
1336
1401
  /** Local owner that approves the authorization. */
1337
1402
  owner: RootAccount
@@ -1342,7 +1407,7 @@ export namespace signAuthorization {
1342
1407
  export type LocalParameters<
1343
1408
  account extends Account | undefined = Account | undefined,
1344
1409
  > = prepareAuthorization.Parameters<account> & {
1345
- /** Serialized approvals from external multisig owners. */
1410
+ /** Serialized approvals from external owners. */
1346
1411
  signatures?: readonly SignatureEnvelope.Serialized[] | undefined
1347
1412
  }
1348
1413
 
@@ -1357,12 +1422,12 @@ export namespace signAuthorization {
1357
1422
  /** Coordinated return value for {@link signAuthorization}. */
1358
1423
  export type CoordinatedReturnValue = Compute<
1359
1424
  ReturnValue & {
1360
- /** Deterministic multisig operation hash. */
1425
+ /** Deterministic account operation hash. */
1361
1426
  hash: Hex
1362
- /** Current multisig operation. */
1363
- multisig: MultisigOperation.KeyAuthorizationOperation
1364
- /** Current multisig operation status. */
1365
- status: MultisigOperation.KeyAuthorizationOperation['status']
1427
+ /** Current account operation. */
1428
+ operation: AccountOperation.KeyAuthorizationOperation
1429
+ /** Current account operation status. */
1430
+ status: AccountOperation.KeyAuthorizationOperation['status']
1366
1431
  }
1367
1432
  >
1368
1433
 
@@ -1370,6 +1435,41 @@ export namespace signAuthorization {
1370
1435
  export type ErrorType = BaseErrorType
1371
1436
  }
1372
1437
 
1438
+ /** Signs a key authorization locally without saving it to a relay. */
1439
+ async function signLocal<
1440
+ chain extends Chain | undefined,
1441
+ account extends Account | undefined,
1442
+ >(
1443
+ client: Client<Transport, chain, account>,
1444
+ parameters: signAuthorization.LocalParameters<account>,
1445
+ ): Promise<signAuthorization.ReturnValue> {
1446
+ const prepared = (
1447
+ 'signPayload' in parameters
1448
+ ? parameters
1449
+ : await prepareAuthorization(client, parameters)
1450
+ ) as prepareAuthorization.ReturnValue
1451
+ const {
1452
+ accessKey,
1453
+ account: account_,
1454
+ chainId,
1455
+ configurable: configurableState,
1456
+ signPayload: _,
1457
+ ...rest
1458
+ } = prepared
1459
+ return signKeyAuthorization(account_ as never, {
1460
+ chainId: BigInt(chainId),
1461
+ key: accessKey,
1462
+ configurable: configurableState,
1463
+ ...rest,
1464
+ })
1465
+ }
1466
+
1467
+ type relay_saveKeyAuthorization = {
1468
+ Method: 'relay_saveKeyAuthorization'
1469
+ Parameters: [KeyAuthorization.Rpc]
1470
+ ReturnType: null
1471
+ }
1472
+
1373
1473
  /**
1374
1474
  * Updates the spending limit for a specific token on an authorized access key.
1375
1475
  *