viem 2.57.8 → 2.57.11

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 (219) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/_cjs/actions/public/getTransactionConfirmations.js +6 -1
  3. package/_cjs/actions/public/getTransactionConfirmations.js.map +1 -1
  4. package/_cjs/actions/public/waitForTransactionReceipt.js +4 -1
  5. package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
  6. package/_cjs/actions/public/watchEvent.js +2 -0
  7. package/_cjs/actions/public/watchEvent.js.map +1 -1
  8. package/_cjs/chains/definitions/hyperEvm.js +3 -0
  9. package/_cjs/chains/definitions/hyperEvm.js.map +1 -1
  10. package/_cjs/chains/definitions/hyperliquidEvmTestnet.js +3 -0
  11. package/_cjs/chains/definitions/hyperliquidEvmTestnet.js.map +1 -1
  12. package/_cjs/chains/definitions/monad.js +1 -1
  13. package/_cjs/chains/definitions/monadTestnet.js +1 -1
  14. package/_cjs/chains/definitions/zksyncEraTestnet.js +32 -0
  15. package/_cjs/chains/definitions/zksyncEraTestnet.js.map +1 -0
  16. package/_cjs/chains/index.js +3 -1
  17. package/_cjs/chains/index.js.map +1 -1
  18. package/_cjs/clients/createClient.js +50 -5
  19. package/_cjs/clients/createClient.js.map +1 -1
  20. package/_cjs/clients/transports/fallback.js +2 -2
  21. package/_cjs/clients/transports/fallback.js.map +1 -1
  22. package/_cjs/errors/version.js +1 -1
  23. package/_cjs/errors/version.js.map +1 -1
  24. package/_cjs/experimental/erc7821/actions/supportsExecutionMode.js +1 -1
  25. package/_cjs/experimental/erc7821/actions/supportsExecutionMode.js.map +1 -1
  26. package/_cjs/op-stack/actions/getPortalVersion.js +4 -1
  27. package/_cjs/op-stack/actions/getPortalVersion.js.map +1 -1
  28. package/_cjs/tempo/Abis.js +84 -15
  29. package/_cjs/tempo/Abis.js.map +1 -1
  30. package/_cjs/tempo/Account.js +13 -11
  31. package/_cjs/tempo/Account.js.map +1 -1
  32. package/_cjs/tempo/Addresses.js +3 -3
  33. package/_cjs/tempo/Addresses.js.map +1 -1
  34. package/_cjs/tempo/Decorator.js +4 -0
  35. package/_cjs/tempo/Decorator.js.map +1 -1
  36. package/_cjs/tempo/ExecutionError.js +25 -2
  37. package/_cjs/tempo/ExecutionError.js.map +1 -1
  38. package/_cjs/tempo/Hardfork.js +12 -1
  39. package/_cjs/tempo/Hardfork.js.map +1 -1
  40. package/_cjs/tempo/Selectors.js +4 -2
  41. package/_cjs/tempo/Selectors.js.map +1 -1
  42. package/_cjs/tempo/Transport.js.map +1 -1
  43. package/_cjs/tempo/accounts/Config.js +4 -2
  44. package/_cjs/tempo/accounts/Config.js.map +1 -1
  45. package/_cjs/tempo/accounts/Operation.js +2 -2
  46. package/_cjs/tempo/accounts/Operation.js.map +1 -1
  47. package/_cjs/tempo/actions/accessKey.js +1 -0
  48. package/_cjs/tempo/actions/accessKey.js.map +1 -1
  49. package/_cjs/tempo/actions/accounts.js +122 -7
  50. package/_cjs/tempo/actions/accounts.js.map +1 -1
  51. package/_cjs/tempo/chainConfig.js +31 -3
  52. package/_cjs/tempo/chainConfig.js.map +1 -1
  53. package/_cjs/tempo/index.js.map +1 -1
  54. package/_cjs/tempo/internal/relay/accounts.js +46 -5
  55. package/_cjs/tempo/internal/relay/accounts.js.map +1 -1
  56. package/_cjs/tempo/internal/relay/feePayer.js +4 -4
  57. package/_cjs/tempo/internal/relay/feePayer.js.map +1 -1
  58. package/_cjs/utils/ens/avatar/parseAvatarRecord.js +4 -1
  59. package/_cjs/utils/ens/avatar/parseAvatarRecord.js.map +1 -1
  60. package/_cjs/utils/ens/avatar/utils.js +2 -1
  61. package/_cjs/utils/ens/avatar/utils.js.map +1 -1
  62. package/_cjs/utils/nonceManager.js +2 -2
  63. package/_cjs/utils/nonceManager.js.map +1 -1
  64. package/_cjs/utils/promise/withRetry.js +5 -1
  65. package/_cjs/utils/promise/withRetry.js.map +1 -1
  66. package/_esm/actions/public/getTransactionConfirmations.js +11 -1
  67. package/_esm/actions/public/getTransactionConfirmations.js.map +1 -1
  68. package/_esm/actions/public/waitForTransactionReceipt.js +10 -1
  69. package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
  70. package/_esm/actions/public/watchEvent.js +2 -0
  71. package/_esm/actions/public/watchEvent.js.map +1 -1
  72. package/_esm/chains/definitions/hyperEvm.js +3 -0
  73. package/_esm/chains/definitions/hyperEvm.js.map +1 -1
  74. package/_esm/chains/definitions/hyperliquidEvmTestnet.js +3 -0
  75. package/_esm/chains/definitions/hyperliquidEvmTestnet.js.map +1 -1
  76. package/_esm/chains/definitions/monad.js +1 -1
  77. package/_esm/chains/definitions/monadTestnet.js +1 -1
  78. package/_esm/chains/definitions/zksyncEraTestnet.js +29 -0
  79. package/_esm/chains/definitions/zksyncEraTestnet.js.map +1 -0
  80. package/_esm/chains/index.js +1 -0
  81. package/_esm/chains/index.js.map +1 -1
  82. package/_esm/clients/createClient.js +58 -5
  83. package/_esm/clients/createClient.js.map +1 -1
  84. package/_esm/clients/transports/fallback.js +2 -2
  85. package/_esm/clients/transports/fallback.js.map +1 -1
  86. package/_esm/errors/version.js +1 -1
  87. package/_esm/errors/version.js.map +1 -1
  88. package/_esm/experimental/erc7821/actions/supportsExecutionMode.js +2 -1
  89. package/_esm/experimental/erc7821/actions/supportsExecutionMode.js.map +1 -1
  90. package/_esm/op-stack/actions/getPortalVersion.js +4 -1
  91. package/_esm/op-stack/actions/getPortalVersion.js.map +1 -1
  92. package/_esm/tempo/Abis.js +84 -15
  93. package/_esm/tempo/Abis.js.map +1 -1
  94. package/_esm/tempo/Account.js +18 -12
  95. package/_esm/tempo/Account.js.map +1 -1
  96. package/_esm/tempo/Addresses.js +3 -3
  97. package/_esm/tempo/Addresses.js.map +1 -1
  98. package/_esm/tempo/Decorator.js +4 -0
  99. package/_esm/tempo/Decorator.js.map +1 -1
  100. package/_esm/tempo/ExecutionError.js +25 -2
  101. package/_esm/tempo/ExecutionError.js.map +1 -1
  102. package/_esm/tempo/Hardfork.js +17 -2
  103. package/_esm/tempo/Hardfork.js.map +1 -1
  104. package/_esm/tempo/Selectors.js +3 -1
  105. package/_esm/tempo/Selectors.js.map +1 -1
  106. package/_esm/tempo/Transport.js.map +1 -1
  107. package/_esm/tempo/accounts/Config.js +5 -3
  108. package/_esm/tempo/accounts/Config.js.map +1 -1
  109. package/_esm/tempo/accounts/Operation.js +2 -2
  110. package/_esm/tempo/accounts/Operation.js.map +1 -1
  111. package/_esm/tempo/actions/accessKey.js +1 -0
  112. package/_esm/tempo/actions/accessKey.js.map +1 -1
  113. package/_esm/tempo/actions/accounts.js +279 -8
  114. package/_esm/tempo/actions/accounts.js.map +1 -1
  115. package/_esm/tempo/chainConfig.js +36 -4
  116. package/_esm/tempo/chainConfig.js.map +1 -1
  117. package/_esm/tempo/index.js.map +1 -1
  118. package/_esm/tempo/internal/relay/accounts.js +50 -5
  119. package/_esm/tempo/internal/relay/accounts.js.map +1 -1
  120. package/_esm/tempo/internal/relay/feePayer.js +4 -4
  121. package/_esm/tempo/internal/relay/feePayer.js.map +1 -1
  122. package/_esm/utils/ens/avatar/parseAvatarRecord.js +4 -1
  123. package/_esm/utils/ens/avatar/parseAvatarRecord.js.map +1 -1
  124. package/_esm/utils/ens/avatar/utils.js +2 -1
  125. package/_esm/utils/ens/avatar/utils.js.map +1 -1
  126. package/_esm/utils/nonceManager.js +2 -2
  127. package/_esm/utils/nonceManager.js.map +1 -1
  128. package/_esm/utils/promise/withRetry.js +6 -1
  129. package/_esm/utils/promise/withRetry.js.map +1 -1
  130. package/_types/actions/public/getTransactionConfirmations.d.ts.map +1 -1
  131. package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
  132. package/_types/actions/public/watchEvent.d.ts.map +1 -1
  133. package/_types/chains/definitions/hyperEvm.d.ts +3 -1
  134. package/_types/chains/definitions/hyperEvm.d.ts.map +1 -1
  135. package/_types/chains/definitions/hyperliquidEvmTestnet.d.ts +3 -1
  136. package/_types/chains/definitions/hyperliquidEvmTestnet.d.ts.map +1 -1
  137. package/_types/chains/definitions/monad.d.ts +1 -1
  138. package/_types/chains/definitions/monadTestnet.d.ts +1 -1
  139. package/_types/chains/definitions/zksyncEraTestnet.d.ts +82 -0
  140. package/_types/chains/definitions/zksyncEraTestnet.d.ts.map +1 -0
  141. package/_types/chains/index.d.ts +1 -0
  142. package/_types/chains/index.d.ts.map +1 -1
  143. package/_types/clients/createClient.d.ts +33 -3
  144. package/_types/clients/createClient.d.ts.map +1 -1
  145. package/_types/clients/transports/fallback.d.ts.map +1 -1
  146. package/_types/errors/version.d.ts +1 -1
  147. package/_types/errors/version.d.ts.map +1 -1
  148. package/_types/experimental/erc7821/actions/supportsExecutionMode.d.ts.map +1 -1
  149. package/_types/op-stack/actions/getPortalVersion.d.ts.map +1 -1
  150. package/_types/tempo/Abis.d.ts +621 -307
  151. package/_types/tempo/Abis.d.ts.map +1 -1
  152. package/_types/tempo/Account.d.ts +24 -4
  153. package/_types/tempo/Account.d.ts.map +1 -1
  154. package/_types/tempo/Addresses.d.ts +3 -3
  155. package/_types/tempo/Addresses.d.ts.map +1 -1
  156. package/_types/tempo/Decorator.d.ts +104 -0
  157. package/_types/tempo/Decorator.d.ts.map +1 -1
  158. package/_types/tempo/ExecutionError.d.ts.map +1 -1
  159. package/_types/tempo/Hardfork.d.ts +6 -2
  160. package/_types/tempo/Hardfork.d.ts.map +1 -1
  161. package/_types/tempo/Selectors.d.ts +3 -1
  162. package/_types/tempo/Selectors.d.ts.map +1 -1
  163. package/_types/tempo/Transaction.d.ts +2 -2
  164. package/_types/tempo/Transaction.d.ts.map +1 -1
  165. package/_types/tempo/Transport.d.ts +2 -0
  166. package/_types/tempo/Transport.d.ts.map +1 -1
  167. package/_types/tempo/actions/accessKey.d.ts +3 -2
  168. package/_types/tempo/actions/accessKey.d.ts.map +1 -1
  169. package/_types/tempo/actions/accounts.d.ts +594 -7
  170. package/_types/tempo/actions/accounts.d.ts.map +1 -1
  171. package/_types/tempo/actions/channel.d.ts +42 -0
  172. package/_types/tempo/actions/channel.d.ts.map +1 -1
  173. package/_types/tempo/actions/reward.d.ts +14 -0
  174. package/_types/tempo/actions/reward.d.ts.map +1 -1
  175. package/_types/tempo/actions/token.d.ts +105 -0
  176. package/_types/tempo/actions/token.d.ts.map +1 -1
  177. package/_types/tempo/chainConfig.d.ts.map +1 -1
  178. package/_types/tempo/index.d.ts +5 -1
  179. package/_types/tempo/index.d.ts.map +1 -1
  180. package/_types/tempo/internal/relay/accounts.d.ts.map +1 -1
  181. package/_types/utils/ens/avatar/parseAvatarRecord.d.ts.map +1 -1
  182. package/_types/utils/ens/avatar/utils.d.ts.map +1 -1
  183. package/_types/utils/promise/withRetry.d.ts.map +1 -1
  184. package/actions/public/getTransactionConfirmations.ts +15 -1
  185. package/actions/public/waitForTransactionReceipt.ts +10 -1
  186. package/actions/public/watchEvent.ts +2 -0
  187. package/chains/definitions/hyperEvm.ts +3 -0
  188. package/chains/definitions/hyperliquidEvmTestnet.ts +3 -0
  189. package/chains/definitions/monad.ts +1 -1
  190. package/chains/definitions/monadTestnet.ts +1 -1
  191. package/chains/definitions/zksyncEraTestnet.ts +29 -0
  192. package/chains/index.ts +1 -0
  193. package/clients/createClient.ts +108 -9
  194. package/clients/transports/fallback.ts +8 -5
  195. package/errors/version.ts +1 -1
  196. package/experimental/erc7821/actions/supportsExecutionMode.ts +2 -1
  197. package/op-stack/actions/getPortalVersion.ts +4 -1
  198. package/package.json +2 -2
  199. package/tempo/Abis.ts +84 -15
  200. package/tempo/Account.ts +52 -16
  201. package/tempo/Addresses.ts +4 -4
  202. package/tempo/Decorator.ts +116 -0
  203. package/tempo/ExecutionError.ts +28 -2
  204. package/tempo/Hardfork.ts +16 -2
  205. package/tempo/Selectors.ts +4 -2
  206. package/tempo/Transaction.ts +2 -2
  207. package/tempo/Transport.ts +2 -0
  208. package/tempo/accounts/Config.ts +5 -3
  209. package/tempo/accounts/Operation.ts +2 -2
  210. package/tempo/actions/accessKey.ts +3 -2
  211. package/tempo/actions/accounts.ts +394 -10
  212. package/tempo/chainConfig.ts +46 -4
  213. package/tempo/index.ts +4 -0
  214. package/tempo/internal/relay/accounts.ts +62 -5
  215. package/tempo/internal/relay/feePayer.ts +4 -4
  216. package/utils/ens/avatar/parseAvatarRecord.ts +7 -1
  217. package/utils/ens/avatar/utils.ts +2 -1
  218. package/utils/nonceManager.ts +2 -2
  219. package/utils/promise/withRetry.ts +7 -1
@@ -56,7 +56,7 @@ export type ClientConfig<
56
56
  experimental_blockTag?: BlockTag | undefined
57
57
  /**
58
58
  * Time (in ms) that cached data will remain in memory.
59
- * @default chain.blockTime / 3
59
+ * @default min(pollingInterval, chain.blockTime / 2)
60
60
  */
61
61
  cacheTime?: number | undefined
62
62
  /**
@@ -85,7 +85,7 @@ export type ClientConfig<
85
85
  name?: string | undefined
86
86
  /**
87
87
  * Frequency (in ms) for polling enabled actions & events.
88
- * @default chain.blockTime / 3
88
+ * @default chain.blockTime / 2 (min 500, max 4_000)
89
89
  */
90
90
  pollingInterval?: number | undefined
91
91
  /**
@@ -172,6 +172,40 @@ export type Client<
172
172
  Prettify<client> & (extended extends Extended ? extended : unknown),
173
173
  tokens
174
174
  >
175
+ /**
176
+ * Creates a Client with the same configuration, transport, and extensions
177
+ * that does not share in-flight requests, caches, or batches with other Clients.
178
+ *
179
+ * Use a scope for each unit of work that must not wait on another's
180
+ * requests, such as each request handled by a server or Worker. Calls with
181
+ * the same `signal` return the same Client.
182
+ *
183
+ * @example
184
+ * ```ts
185
+ * import { createPublicClient, http } from 'viem'
186
+ * import { mainnet } from 'viem/chains'
187
+ *
188
+ * const client = createPublicClient({ chain: mainnet, transport: http() })
189
+ *
190
+ * export default {
191
+ * async fetch(request: Request) {
192
+ * const scoped = client.scope({ signal: request.signal })
193
+ * return Response.json({ blockNumber: String(await scoped.getBlockNumber()) })
194
+ * },
195
+ * }
196
+ * ```
197
+ */
198
+ scope: (
199
+ options?:
200
+ | {
201
+ /**
202
+ * Signal that aborts the scoped Client's requests and identifies the
203
+ * scope. Requests made with their own `signal` use it instead.
204
+ */
205
+ signal?: AbortSignal | undefined
206
+ }
207
+ | undefined,
208
+ ) => Client<transport, chain, account, rpcSchema, extended, tokens>
175
209
  }
176
210
 
177
211
  type Client_Base<
@@ -199,7 +233,7 @@ type Client_Base<
199
233
  key: string
200
234
  /** A name for the client. */
201
235
  name: string
202
- /** Frequency (in ms) for polling enabled actions & events. Defaults to 4_000 milliseconds. */
236
+ /** Frequency (in ms) for polling enabled actions & events. */
203
237
  pollingInterval: number
204
238
  /** Request function wrapped with friendly error handling */
205
239
  request: EIP1193RequestFn<
@@ -284,7 +318,8 @@ export function createClient(parameters: ClientConfig): Client {
284
318
  4_000,
285
319
  )
286
320
  const pollingInterval = parameters.pollingInterval ?? defaultPollingInterval
287
- const cacheTime = parameters.cacheTime ?? pollingInterval
321
+ const cacheTime =
322
+ parameters.cacheTime ?? Math.min(pollingInterval, Math.floor(blockTime / 2))
288
323
 
289
324
  const account = parameters.account
290
325
  ? parseAccount(parameters.account)
@@ -314,11 +349,25 @@ export function createClient(parameters: ClientConfig): Client {
314
349
  ...(experimental_blockTag ? { experimental_blockTag } : {}),
315
350
  }
316
351
 
317
- function extend(base: typeof client) {
318
- type ExtendFn = (base: typeof client) => unknown
352
+ return decorate(client)
353
+ }
354
+
355
+ /** Built-in `scope` functions, which an extension named `scope` takes precedence over. */
356
+ const scopes_builtin = new WeakSet<object>()
357
+
358
+ let scopeId = 0
359
+
360
+ /**
361
+ * Attaches `extend` and `scope` to a base Client. Base keys other than
362
+ * `scope` are reserved, so extensions cannot override them.
363
+ */
364
+ function decorate<client extends Client_Base>(client: client): Client {
365
+ type ExtendFn = (base: client) => unknown
366
+
367
+ function extend(base: client, extensions: readonly ExtendFn[]) {
319
368
  return (extendFn: ExtendFn) => {
320
369
  const extended = extendFn(base) as Extended
321
- for (const key in client) delete extended[key]
370
+ for (const key in client) if (key !== 'scope') delete extended[key]
322
371
  const combined = { ...base, ...extended }
323
372
  // For keys that exist on both the base client and the extension and
324
373
  // resolve to plain objects (e.g. namespaces like `token`), shallow-merge
@@ -331,11 +380,61 @@ export function createClient(parameters: ClientConfig): Client {
331
380
  if (isPlainObject(a) && isPlainObject(b))
332
381
  (combined as Record<string, unknown>)[key] = { ...a, ...b }
333
382
  }
334
- return Object.assign(combined, { extend: extend(combined as any) })
383
+ const next = [...extensions, extendFn]
384
+ const { scope: scope_combined } = combined as { scope?: unknown }
385
+ return Object.assign(combined, {
386
+ extend: extend(combined as any, next),
387
+ scope:
388
+ typeof scope_combined === 'function' &&
389
+ scopes_builtin.has(scope_combined)
390
+ ? scope(next)
391
+ : scope_combined,
392
+ })
393
+ }
394
+ }
395
+
396
+ function scope(extensions: readonly ExtendFn[]) {
397
+ // Memoized by signal, so callers sharing one signal share one scope.
398
+ const scopes = new WeakMap<AbortSignal, Client>()
399
+ const fn = (options: { signal?: AbortSignal | undefined } = {}) => {
400
+ const cached = options.signal && scopes.get(options.signal)
401
+ if (cached) return cached
402
+
403
+ const id = `scope.${scopeId++}`
404
+ // A scope-owned signal keys transport queues, such as HTTP batches, to the scope.
405
+ const controller = new AbortController()
406
+ const { signal } = options
407
+ if (signal?.aborted) controller.abort(signal.reason)
408
+ else
409
+ signal?.addEventListener(
410
+ 'abort',
411
+ () => controller.abort(signal.reason),
412
+ {
413
+ once: true,
414
+ },
415
+ )
416
+ const request: EIP1193RequestFn = (args, options_request) =>
417
+ client.request(args as never, {
418
+ ...options_request,
419
+ signal: options_request?.signal ?? controller.signal,
420
+ // The request `uid` keys in-flight request deduplication.
421
+ uid: options_request?.uid ?? id,
422
+ })
423
+ const scoped = extensions.reduce<Client>(
424
+ (base, extendFn) => base.extend(extendFn as never),
425
+ decorate({ ...client, request, uid: id }),
426
+ )
427
+ if (signal) scopes.set(signal, scoped)
428
+ return scoped
335
429
  }
430
+ scopes_builtin.add(fn)
431
+ return fn
336
432
  }
337
433
 
338
- return Object.assign(client, { extend: extend(client) as any })
434
+ return Object.assign(client, {
435
+ extend: extend(client, []),
436
+ scope: scope([]),
437
+ }) as any
339
438
  }
340
439
 
341
440
  /** Whether `value` is a plain object (`{}`), as opposed to a function, array,
@@ -125,7 +125,7 @@ export function fallback<const transports extends readonly Transport[]>(
125
125
  {
126
126
  key,
127
127
  name,
128
- async request({ method, params }) {
128
+ async request({ method, params }, options) {
129
129
  let includes: boolean | undefined
130
130
 
131
131
  const fetch = async (i = 0): Promise<any> => {
@@ -136,10 +136,13 @@ export function fallback<const transports extends readonly Transport[]>(
136
136
  timeout,
137
137
  })
138
138
  try {
139
- const response = await transport.request({
140
- method,
141
- params,
142
- } as any)
139
+ const response = await transport.request(
140
+ {
141
+ method,
142
+ params,
143
+ } as any,
144
+ options,
145
+ )
143
146
 
144
147
  onResponse({
145
148
  method,
package/errors/version.ts CHANGED
@@ -1 +1 @@
1
- export const version = '2.57.8'
1
+ export const version = '2.57.11'
@@ -64,7 +64,8 @@ export async function supportsExecutionMode<
64
64
  args: [mode],
65
65
  }),
66
66
  {
67
- cacheKey: `supportsExecutionMode.${address}.${mode}`,
67
+ // Distinct from the key `execute` uses, since `execute` wraps this action in its own cache.
68
+ cacheKey: `supportsExecutionMode.${address}.${mode}.${client.uid}`,
68
69
  },
69
70
  )
70
71
  } catch {
@@ -78,7 +78,10 @@ export async function getPortalVersion<
78
78
  address: portalAddress,
79
79
  functionName: 'version',
80
80
  }),
81
- { cacheKey: ['portalVersion', portalAddress].join('.'), cacheTime: 300 },
81
+ {
82
+ cacheKey: ['portalVersion', client.uid, portalAddress].join('.'),
83
+ cacheTime: 300,
84
+ },
82
85
  )
83
86
 
84
87
  const [major, minor, patch] = version.split('.').map(Number)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "viem",
3
3
  "description": "TypeScript Interface for Ethereum",
4
- "version": "2.57.8",
4
+ "version": "2.57.11",
5
5
  "main": "./_cjs/index.js",
6
6
  "module": "./_esm/index.js",
7
7
  "types": "./_types/index.d.ts",
@@ -229,7 +229,7 @@
229
229
  "@scure/bip39": "1.6.0",
230
230
  "abitype": "1.2.3",
231
231
  "isows": "1.0.7",
232
- "ox": "0.14.56",
232
+ "ox": "0.14.57",
233
233
  "ws": "8.21.0"
234
234
  },
235
235
  "license": "MIT",
package/tempo/Abis.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // Generated with `pnpm gen:tempo-abis`. Do not modify manually.
2
- // Source: tempoxyz/tempo@6ef1f812c9ddcbe90a88ada73944012520942d26
2
+ // Source: tempoxyz/tempo@e539a1dac2921670585a08215e516d8b98aa527a
3
3
 
4
4
  export const accountKeychain = [
5
5
  {
@@ -444,7 +444,7 @@ export const addressRegistry = [
444
444
  { name: 'VirtualAddressUnregistered', type: 'error', inputs: [] },
445
445
  ] as const
446
446
 
447
- export const nativeMultisig = [
447
+ export const configurableAccount = [
448
448
  {
449
449
  name: 'deriveAccount',
450
450
  type: 'function',
@@ -505,7 +505,24 @@ export const nativeMultisig = [
505
505
  outputs: [],
506
506
  },
507
507
  {
508
- name: 'MultisigConfigUpdated',
508
+ name: 'upgradeAccount',
509
+ type: 'function',
510
+ stateMutability: 'nonpayable',
511
+ inputs: [
512
+ { type: 'uint8', name: 'threshold' },
513
+ {
514
+ type: 'tuple[]',
515
+ name: 'owners',
516
+ components: [
517
+ { type: 'address', name: 'owner' },
518
+ { type: 'uint8', name: 'weight' },
519
+ ],
520
+ },
521
+ ],
522
+ outputs: [{ type: 'bytes32', name: 'commitment' }],
523
+ },
524
+ {
525
+ name: 'ConfigurableAccountConfigUpdated',
509
526
  type: 'event',
510
527
  inputs: [
511
528
  { type: 'address', name: 'account', indexed: true },
@@ -522,15 +539,37 @@ export const nativeMultisig = [
522
539
  },
523
540
  ],
524
541
  },
542
+ {
543
+ name: 'AccountUpgraded',
544
+ type: 'event',
545
+ inputs: [
546
+ { type: 'address', name: 'account', indexed: true },
547
+ { type: 'bytes32', name: 'commitment', indexed: true },
548
+ { type: 'bytes32', name: 'salt' },
549
+ { type: 'uint8', name: 'threshold' },
550
+ {
551
+ type: 'tuple[]',
552
+ name: 'owners',
553
+ components: [
554
+ { type: 'address', name: 'owner' },
555
+ { type: 'uint8', name: 'weight' },
556
+ ],
557
+ },
558
+ ],
559
+ },
525
560
  { name: 'InvalidAccount', type: 'error', inputs: [] },
526
561
  { name: 'InvalidConfig', type: 'error', inputs: [] },
527
562
  { name: 'InvalidThreshold', type: 'error', inputs: [] },
528
- { name: 'InvalidMultisigOwner', type: 'error', inputs: [] },
563
+ { name: 'InvalidConfigurableAccountOwner', type: 'error', inputs: [] },
529
564
  { name: 'InvalidWeight', type: 'error', inputs: [] },
530
565
  { name: 'TooManyOwners', type: 'error', inputs: [] },
531
566
  { name: 'DuplicateOwner', type: 'error', inputs: [] },
532
567
  { name: 'InvalidOwnerOrder', type: 'error', inputs: [] },
533
- { name: 'UnauthorizedMultisigCaller', type: 'error', inputs: [] },
568
+ { name: 'UnauthorizedConfigurableAccountCaller', type: 'error', inputs: [] },
569
+ { name: 'PrimitiveRootRequired', type: 'error', inputs: [] },
570
+ { name: 'UpgradeMustBeOnlyCall', type: 'error', inputs: [] },
571
+ { name: 'AccountAlreadyConfigurable', type: 'error', inputs: [] },
572
+ { name: 'AccountHasCode', type: 'error', inputs: [] },
534
573
  ] as const
535
574
 
536
575
  export const currentCommittee = [
@@ -705,6 +744,17 @@ export const signatureVerifier = [
705
744
  ],
706
745
  outputs: [{ type: 'bool' }],
707
746
  },
747
+ {
748
+ name: 'verifyConfigurableAccount',
749
+ type: 'function',
750
+ stateMutability: 'view',
751
+ inputs: [
752
+ { type: 'address', name: 'account' },
753
+ { type: 'bytes32', name: 'hash' },
754
+ { type: 'bytes', name: 'signature' },
755
+ ],
756
+ outputs: [{ type: 'bool' }],
757
+ },
708
758
  { name: 'InvalidFormat', type: 'error', inputs: [] },
709
759
  { name: 'InvalidSignature', type: 'error', inputs: [] },
710
760
  ] as const
@@ -1710,6 +1760,11 @@ export const tip20ChannelReserve = [
1710
1760
  { name: 'CaptureAmountInvalid', type: 'error', inputs: [] },
1711
1761
  { name: 'CloseNotReady', type: 'error', inputs: [] },
1712
1762
  { name: 'DepositOverflow', type: 'error', inputs: [] },
1763
+ {
1764
+ name: 'RootKeyRetired',
1765
+ type: 'error',
1766
+ inputs: [{ type: 'address', name: 'account' }],
1767
+ },
1713
1768
  ] as const
1714
1769
 
1715
1770
  export const tip20Factory = [
@@ -2314,6 +2369,11 @@ export const tip20 = [
2314
2369
  { name: 'InvalidSignature', type: 'error', inputs: [] },
2315
2370
  { name: 'LogoURITooLong', type: 'error', inputs: [] },
2316
2371
  { name: 'InvalidLogoURI', type: 'error', inputs: [] },
2372
+ {
2373
+ name: 'RootKeyRetired',
2374
+ type: 'error',
2375
+ inputs: [{ type: 'address', name: 'account' }],
2376
+ },
2317
2377
  {
2318
2378
  name: 'hasRole',
2319
2379
  type: 'function',
@@ -9861,10 +9921,10 @@ export const directPropAmm = [
9861
9921
  export const core = [
9862
9922
  ...accountKeychain,
9863
9923
  ...addressRegistry,
9924
+ ...configurableAccount,
9864
9925
  ...currentCommittee,
9865
9926
  ...feeAmm,
9866
9927
  ...feeManager,
9867
- ...nativeMultisig,
9868
9928
  ...nonce,
9869
9929
  ...receivePolicyGuard,
9870
9930
  ...signatureVerifier,
@@ -9946,6 +10006,19 @@ export const coreErrors = [
9946
10006
  { name: 'InvalidMasterAddress', type: 'error', inputs: [] },
9947
10007
  { name: 'ProofOfWorkFailed', type: 'error', inputs: [] },
9948
10008
  { name: 'VirtualAddressUnregistered', type: 'error', inputs: [] },
10009
+ { name: 'InvalidAccount', type: 'error', inputs: [] },
10010
+ { name: 'InvalidConfig', type: 'error', inputs: [] },
10011
+ { name: 'InvalidThreshold', type: 'error', inputs: [] },
10012
+ { name: 'InvalidConfigurableAccountOwner', type: 'error', inputs: [] },
10013
+ { name: 'InvalidWeight', type: 'error', inputs: [] },
10014
+ { name: 'TooManyOwners', type: 'error', inputs: [] },
10015
+ { name: 'DuplicateOwner', type: 'error', inputs: [] },
10016
+ { name: 'InvalidOwnerOrder', type: 'error', inputs: [] },
10017
+ { name: 'UnauthorizedConfigurableAccountCaller', type: 'error', inputs: [] },
10018
+ { name: 'PrimitiveRootRequired', type: 'error', inputs: [] },
10019
+ { name: 'UpgradeMustBeOnlyCall', type: 'error', inputs: [] },
10020
+ { name: 'AccountAlreadyConfigurable', type: 'error', inputs: [] },
10021
+ { name: 'AccountHasCode', type: 'error', inputs: [] },
9949
10022
  { name: 'Unauthorized', type: 'error', inputs: [] },
9950
10023
  { name: 'IdenticalAddresses', type: 'error', inputs: [] },
9951
10024
  { name: 'InvalidToken', type: 'error', inputs: [] },
@@ -9956,15 +10029,6 @@ export const coreErrors = [
9956
10029
  { name: 'InvalidSwapCalculation', type: 'error', inputs: [] },
9957
10030
  { name: 'InsufficientFeeTokenBalance', type: 'error', inputs: [] },
9958
10031
  { name: 'CannotChangeWithinBlock', type: 'error', inputs: [] },
9959
- { name: 'InvalidAccount', type: 'error', inputs: [] },
9960
- { name: 'InvalidConfig', type: 'error', inputs: [] },
9961
- { name: 'InvalidThreshold', type: 'error', inputs: [] },
9962
- { name: 'InvalidMultisigOwner', type: 'error', inputs: [] },
9963
- { name: 'InvalidWeight', type: 'error', inputs: [] },
9964
- { name: 'TooManyOwners', type: 'error', inputs: [] },
9965
- { name: 'DuplicateOwner', type: 'error', inputs: [] },
9966
- { name: 'InvalidOwnerOrder', type: 'error', inputs: [] },
9967
- { name: 'UnauthorizedMultisigCaller', type: 'error', inputs: [] },
9968
10032
  { name: 'ProtocolNonceNotSupported', type: 'error', inputs: [] },
9969
10033
  { name: 'InvalidNonceKey', type: 'error', inputs: [] },
9970
10034
  { name: 'NonceOverflow', type: 'error', inputs: [] },
@@ -10026,6 +10090,11 @@ export const coreErrors = [
10026
10090
  { name: 'PermitExpired', type: 'error', inputs: [] },
10027
10091
  { name: 'LogoURITooLong', type: 'error', inputs: [] },
10028
10092
  { name: 'InvalidLogoURI', type: 'error', inputs: [] },
10093
+ {
10094
+ name: 'RootKeyRetired',
10095
+ type: 'error',
10096
+ inputs: [{ type: 'address', name: 'account' }],
10097
+ },
10029
10098
  { name: 'ChannelAlreadyExists', type: 'error', inputs: [] },
10030
10099
  { name: 'ChannelNotFound', type: 'error', inputs: [] },
10031
10100
  { name: 'NotPayer', type: 'error', inputs: [] },
package/tempo/Account.ts CHANGED
@@ -24,7 +24,7 @@ import { keccak256 } from '../utils/hash/keccak256.js'
24
24
  import { hashMessage } from '../utils/signature/hashMessage.js'
25
25
  import { hashTypedData } from '../utils/signature/hashTypedData.js'
26
26
  import type { SerializeTransactionFn } from '../utils/transaction/serializeTransaction.js'
27
- import { nativeMultisigFactory } from './Addresses.js'
27
+ import { configurableAccountRecoveryFactory } from './Addresses.js'
28
28
  import { parseApproval } from './accounts/Signature.js'
29
29
  import type { KeyAuthorizationManager } from './KeyAuthorizationManager.js'
30
30
  import * as Transaction from './Transaction.js'
@@ -281,8 +281,10 @@ export declare namespace fromSecp256k1 {
281
281
  *
282
282
  * The returned account does not hold a key itself. Omit `address` or set it to
283
283
  * `infer` to derive an account address from its initial config. For a current
284
- * config, set `address` to the stable account address. Pass the address directly
285
- * for an address-only account.
284
+ * config, set `address` to the stable account address. For an account
285
+ * upgraded in place with `Actions.accounts.upgrade`, set `address` to the
286
+ * upgraded account and pass the installed owners and threshold as `upgrade`.
287
+ * Pass the address directly for an address-only account.
286
288
  *
287
289
  * Owners can be accounts or addresses directly, or weighted `{ owner, weight }`
288
290
  * entries. Direct owners default to weight `1`, and `threshold` defaults to `1`.
@@ -309,7 +311,7 @@ export declare namespace fromSecp256k1 {
309
311
  * const transaction = await client.signTransaction(request)
310
312
  * ```
311
313
  *
312
- * @param value Initial config, current config, or account address.
314
+ * @param value Initial config, current config, upgrade config, or account address.
313
315
  * @returns Configurable account.
314
316
  */
315
317
  export function fromConfig(
@@ -318,6 +320,9 @@ export function fromConfig(
318
320
  export function fromConfig(
319
321
  value: fromConfig.CurrentConfig,
320
322
  ): ConfigurableAccount<AccountConfig.Config>
323
+ export function fromConfig(
324
+ value: fromConfig.UpgradeConfig,
325
+ ): ConfigurableAccount<AccountConfig.Config>
321
326
  export function fromConfig(
322
327
  address: Address.Address,
323
328
  ): ConfigurableAccount<undefined>
@@ -325,7 +330,12 @@ export function fromConfig(value: fromConfig.Parameters): ConfigurableAccount
325
330
  export function fromConfig(value: fromConfig.Parameters): ConfigurableAccount {
326
331
  const configInput = (() => {
327
332
  if (typeof value === 'string') return undefined
328
- const { address: _, ...config } = value
333
+ if ('upgrade' in value) return value.upgrade
334
+ const {
335
+ address: _,
336
+ factory: __,
337
+ ...config
338
+ } = value as fromConfig.InitialConfig
329
339
  return config
330
340
  })()
331
341
  const config = (() => {
@@ -335,16 +345,16 @@ export function fromConfig(value: fromConfig.Parameters): ConfigurableAccount {
335
345
  ? { owner: value, weight: 1 }
336
346
  : value,
337
347
  )
338
- return AccountConfig.from({
339
- ...configInput,
340
- owners: ownerEntries.map(({ owner, weight }) => ({
341
- owner: typeof owner === 'string' ? owner : owner.address,
342
- weight,
343
- })),
344
- threshold: configInput.threshold ?? 1,
345
- })
348
+ const owners = ownerEntries.map(({ owner, weight }) => ({
349
+ owner: typeof owner === 'string' ? owner : owner.address,
350
+ weight,
351
+ }))
352
+ const threshold = configInput.threshold ?? 1
353
+ if (typeof value !== 'string' && 'upgrade' in value)
354
+ return AccountConfig.fromUpgrade(value.address, { owners, threshold })
355
+ return AccountConfig.from({ ...configInput, owners, threshold })
346
356
  })()
347
- if (typeof value !== 'string') {
357
+ if (typeof value !== 'string' && !('upgrade' in value)) {
348
358
  if (
349
359
  (value.address === undefined || value.address === 'infer') &&
350
360
  config!.version !== 0n
@@ -362,7 +372,7 @@ export function fromConfig(value: fromConfig.Parameters): ConfigurableAccount {
362
372
  if (typeof value === 'string') return value
363
373
  if (value.address === undefined || value.address === 'infer')
364
374
  return AccountConfig.getAddress(config!, {
365
- factory: nativeMultisigFactory,
375
+ factory: value.factory ?? configurableAccountRecoveryFactory,
366
376
  })
367
377
  return value.address
368
378
  })(),
@@ -484,6 +494,11 @@ export declare namespace fromConfig {
484
494
  export type InitialConfig = {
485
495
  /** Derives the stable account address from this initial config. */
486
496
  address?: 'infer' | undefined
497
+ /**
498
+ * Recovery factory used to derive the address.
499
+ * @default `Addresses.configurableAccountRecoveryFactory`
500
+ */
501
+ factory?: Address.Address | undefined
487
502
  /** Weighted owners. */
488
503
  owners: readonly Owner[]
489
504
  /** Caller-chosen 32-byte salt. */
@@ -505,7 +520,24 @@ export declare namespace fromConfig {
505
520
  })
506
521
 
507
522
  /** Parameters for {@link fromConfig}. */
508
- export type Parameters = Address.Address | CurrentConfig | InitialConfig
523
+ export type Parameters =
524
+ | Address.Address
525
+ | CurrentConfig
526
+ | InitialConfig
527
+ | UpgradeConfig
528
+
529
+ /** Account upgraded in place and the owners and threshold it installed. */
530
+ export type UpgradeConfig = {
531
+ /** Upgraded account address. */
532
+ address: Address.Address
533
+ /** Owners and threshold installed by the upgrade. */
534
+ upgrade: {
535
+ /** Weighted owners. */
536
+ owners: readonly Owner[]
537
+ /** Minimum owner weight required for authorization. */
538
+ threshold?: number | undefined
539
+ }
540
+ }
509
541
  }
510
542
 
511
543
  export type ConfigurableAccount<
@@ -1110,6 +1142,10 @@ declare namespace fromAccessKey {
1110
1142
  export type ReturnValue = AccessKeyAccount
1111
1143
  }
1112
1144
 
1145
+ // TODO: support configurable accounts as access keys (TIP-1111): authorize a
1146
+ // configurable account with key type `configurable`, sign as it with a keychain
1147
+ // envelope wrapping its configurable signature, and accept those envelopes in the
1148
+ // relay fee payer.
1113
1149
  /** @internal */
1114
1150
  export function resolveAccessKey(
1115
1151
  accessKey: resolveAccessKey.Parameters,
@@ -12,13 +12,13 @@ export const accountImplementation =
12
12
  export const accountKeychain = '0xaAAAaaAA00000000000000000000000000000000'
13
13
  export const accountRegistrar = '0x7702ac0000000000000000000000000000000000'
14
14
  export const addressRegistry = '0xfdc0000000000000000000000000000000000000'
15
+ export const configurableAccount = '0xAACC000000000000000000000000000000000000'
16
+ /** Default configurable account recovery factory. Temporary until the production address is finalized. */
17
+ export const configurableAccountRecoveryFactory =
18
+ '0x7171717171717171717171717171717171717171'
15
19
  /** Current consensus committee precompile address, used with `Abis.currentCommittee` to read committee members. */
16
20
  export const currentCommittee = '0xC077e00000000000000000000000000000000000'
17
21
  export const feeManager = '0xfeec000000000000000000000000000000000000'
18
- export const nativeMultisig = '0xAACC000000000000000000000000000000000000'
19
- /** Temporary recovery factory until the production address is finalized. */
20
- export const nativeMultisigFactory =
21
- '0x7171717171717171717171717171717171717171'
22
22
  export const nonceManager = '0x4e4F4E4345000000000000000000000000000000'
23
23
  export const ousd = '0x20c0000000000000000000006a37DA5C996874BE'
24
24
  export const pathUsd = '0x20c0000000000000000000000000000000000000'