viem 2.56.1 → 2.56.3

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 (254) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/_cjs/actions/wallet/sendTransaction.js +9 -1
  3. package/_cjs/actions/wallet/sendTransaction.js.map +1 -1
  4. package/_cjs/actions/wallet/sendTransactionSync.js +9 -1
  5. package/_cjs/actions/wallet/sendTransactionSync.js.map +1 -1
  6. package/_cjs/errors/version.js +1 -1
  7. package/_cjs/tempo/Abis.js +11 -23
  8. package/_cjs/tempo/Abis.js.map +1 -1
  9. package/_cjs/tempo/Account.js +66 -61
  10. package/_cjs/tempo/Account.js.map +1 -1
  11. package/_cjs/tempo/Client.js +10 -2
  12. package/_cjs/tempo/Client.js.map +1 -1
  13. package/_cjs/tempo/Decorator.js +2 -1
  14. package/_cjs/tempo/Decorator.js.map +1 -1
  15. package/_cjs/tempo/Formatters.js +29 -9
  16. package/_cjs/tempo/Formatters.js.map +1 -1
  17. package/_cjs/tempo/Multisig.js +1093 -0
  18. package/_cjs/tempo/Multisig.js.map +1 -0
  19. package/_cjs/tempo/Selectors.js +2 -3
  20. package/_cjs/tempo/Selectors.js.map +1 -1
  21. package/_cjs/tempo/{Storage.js → Store.js} +34 -9
  22. package/_cjs/tempo/Store.js.map +1 -0
  23. package/_cjs/tempo/Transaction.js +15 -30
  24. package/_cjs/tempo/Transaction.js.map +1 -1
  25. package/_cjs/tempo/Transport.js +51 -5
  26. package/_cjs/tempo/Transport.js.map +1 -1
  27. package/_cjs/tempo/Zone.js.map +1 -1
  28. package/_cjs/tempo/actions/accessKey.js +102 -8
  29. package/_cjs/tempo/actions/accessKey.js.map +1 -1
  30. package/_cjs/tempo/actions/amm.js +6 -0
  31. package/_cjs/tempo/actions/amm.js.map +1 -1
  32. package/_cjs/tempo/actions/channel.js +12 -0
  33. package/_cjs/tempo/actions/channel.js.map +1 -1
  34. package/_cjs/tempo/actions/dex.js +10 -0
  35. package/_cjs/tempo/actions/dex.js.map +1 -1
  36. package/_cjs/tempo/actions/earn/deployment.js +13 -1
  37. package/_cjs/tempo/actions/earn/deployment.js.map +1 -1
  38. package/_cjs/tempo/actions/earn.js +17 -0
  39. package/_cjs/tempo/actions/earn.js.map +1 -1
  40. package/_cjs/tempo/actions/fee.js +4 -0
  41. package/_cjs/tempo/actions/fee.js.map +1 -1
  42. package/_cjs/tempo/actions/multisig.js +86 -28
  43. package/_cjs/tempo/actions/multisig.js.map +1 -1
  44. package/_cjs/tempo/actions/policy.js +8 -0
  45. package/_cjs/tempo/actions/policy.js.map +1 -1
  46. package/_cjs/tempo/actions/receivePolicy.js +6 -0
  47. package/_cjs/tempo/actions/receivePolicy.js.map +1 -1
  48. package/_cjs/tempo/actions/reward.js +4 -0
  49. package/_cjs/tempo/actions/reward.js.map +1 -1
  50. package/_cjs/tempo/actions/token.js +32 -0
  51. package/_cjs/tempo/actions/token.js.map +1 -1
  52. package/_cjs/tempo/actions/virtualAddress.js +2 -0
  53. package/_cjs/tempo/actions/virtualAddress.js.map +1 -1
  54. package/_cjs/tempo/actions/zone.js +7 -5
  55. package/_cjs/tempo/actions/zone.js.map +1 -1
  56. package/_cjs/tempo/chainConfig.js +180 -69
  57. package/_cjs/tempo/chainConfig.js.map +1 -1
  58. package/_cjs/tempo/index.js +5 -2
  59. package/_cjs/tempo/index.js.map +1 -1
  60. package/_cjs/tempo/internal/utils.js +2 -1
  61. package/_cjs/tempo/internal/utils.js.map +1 -1
  62. package/_cjs/tempo/multisig/Config.js +80 -0
  63. package/_cjs/tempo/multisig/Config.js.map +1 -0
  64. package/_cjs/tempo/multisig/Operation.js +163 -0
  65. package/_cjs/tempo/multisig/Operation.js.map +1 -0
  66. package/_cjs/utils/encoding/fromHex.js +1 -1
  67. package/_cjs/utils/encoding/fromHex.js.map +1 -1
  68. package/_cjs/utils/hash/isHash.js +1 -2
  69. package/_cjs/utils/hash/isHash.js.map +1 -1
  70. package/_esm/actions/wallet/sendTransaction.js +9 -1
  71. package/_esm/actions/wallet/sendTransaction.js.map +1 -1
  72. package/_esm/actions/wallet/sendTransactionSync.js +9 -1
  73. package/_esm/actions/wallet/sendTransactionSync.js.map +1 -1
  74. package/_esm/errors/version.js +1 -1
  75. package/_esm/tempo/Abis.js +11 -23
  76. package/_esm/tempo/Abis.js.map +1 -1
  77. package/_esm/tempo/Account.js +66 -61
  78. package/_esm/tempo/Account.js.map +1 -1
  79. package/_esm/tempo/Client.js +22 -3
  80. package/_esm/tempo/Client.js.map +1 -1
  81. package/_esm/tempo/Decorator.js +2 -1
  82. package/_esm/tempo/Decorator.js.map +1 -1
  83. package/_esm/tempo/Formatters.js +32 -11
  84. package/_esm/tempo/Formatters.js.map +1 -1
  85. package/_esm/tempo/Multisig.js +1126 -0
  86. package/_esm/tempo/Multisig.js.map +1 -0
  87. package/_esm/tempo/Selectors.js +2 -3
  88. package/_esm/tempo/Selectors.js.map +1 -1
  89. package/_esm/tempo/{Storage.js → Store.js} +37 -26
  90. package/_esm/tempo/Store.js.map +1 -0
  91. package/_esm/tempo/Transaction.js +16 -31
  92. package/_esm/tempo/Transaction.js.map +1 -1
  93. package/_esm/tempo/Transport.js +71 -6
  94. package/_esm/tempo/Transport.js.map +1 -1
  95. package/_esm/tempo/Zone.js +1 -2
  96. package/_esm/tempo/Zone.js.map +1 -1
  97. package/_esm/tempo/actions/accessKey.js +104 -20
  98. package/_esm/tempo/actions/accessKey.js.map +1 -1
  99. package/_esm/tempo/actions/amm.js +6 -0
  100. package/_esm/tempo/actions/amm.js.map +1 -1
  101. package/_esm/tempo/actions/channel.js +12 -0
  102. package/_esm/tempo/actions/channel.js.map +1 -1
  103. package/_esm/tempo/actions/dex.js +10 -0
  104. package/_esm/tempo/actions/dex.js.map +1 -1
  105. package/_esm/tempo/actions/earn/deployment.js +13 -1
  106. package/_esm/tempo/actions/earn/deployment.js.map +1 -1
  107. package/_esm/tempo/actions/earn.js +17 -0
  108. package/_esm/tempo/actions/earn.js.map +1 -1
  109. package/_esm/tempo/actions/fee.js +4 -0
  110. package/_esm/tempo/actions/fee.js.map +1 -1
  111. package/_esm/tempo/actions/multisig.js +129 -63
  112. package/_esm/tempo/actions/multisig.js.map +1 -1
  113. package/_esm/tempo/actions/policy.js +8 -0
  114. package/_esm/tempo/actions/policy.js.map +1 -1
  115. package/_esm/tempo/actions/receivePolicy.js +6 -0
  116. package/_esm/tempo/actions/receivePolicy.js.map +1 -1
  117. package/_esm/tempo/actions/reward.js +4 -0
  118. package/_esm/tempo/actions/reward.js.map +1 -1
  119. package/_esm/tempo/actions/token.js +32 -0
  120. package/_esm/tempo/actions/token.js.map +1 -1
  121. package/_esm/tempo/actions/virtualAddress.js +2 -0
  122. package/_esm/tempo/actions/virtualAddress.js.map +1 -1
  123. package/_esm/tempo/actions/zone.js +8 -6
  124. package/_esm/tempo/actions/zone.js.map +1 -1
  125. package/_esm/tempo/chainConfig.js +188 -86
  126. package/_esm/tempo/chainConfig.js.map +1 -1
  127. package/_esm/tempo/index.js +5 -3
  128. package/_esm/tempo/index.js.map +1 -1
  129. package/_esm/tempo/internal/utils.js +2 -1
  130. package/_esm/tempo/internal/utils.js.map +1 -1
  131. package/_esm/tempo/multisig/Config.js +84 -0
  132. package/_esm/tempo/multisig/Config.js.map +1 -0
  133. package/_esm/tempo/multisig/Operation.js +170 -0
  134. package/_esm/tempo/multisig/Operation.js.map +1 -0
  135. package/_esm/utils/encoding/fromHex.js +1 -1
  136. package/_esm/utils/encoding/fromHex.js.map +1 -1
  137. package/_esm/utils/hash/isHash.js +1 -2
  138. package/_esm/utils/hash/isHash.js.map +1 -1
  139. package/_types/actions/wallet/sendTransaction.d.ts.map +1 -1
  140. package/_types/actions/wallet/sendTransactionSync.d.ts.map +1 -1
  141. package/_types/chains/definitions/tempo.d.ts +72 -92
  142. package/_types/chains/definitions/tempo.d.ts.map +1 -1
  143. package/_types/chains/definitions/tempoDevnet.d.ts +72 -92
  144. package/_types/chains/definitions/tempoDevnet.d.ts.map +1 -1
  145. package/_types/chains/definitions/tempoLocalnet.d.ts +72 -92
  146. package/_types/chains/definitions/tempoLocalnet.d.ts.map +1 -1
  147. package/_types/chains/definitions/tempoModerato.d.ts +72 -92
  148. package/_types/chains/definitions/tempoModerato.d.ts.map +1 -1
  149. package/_types/errors/version.d.ts +1 -1
  150. package/_types/tempo/Abis.d.ts +54 -108
  151. package/_types/tempo/Abis.d.ts.map +1 -1
  152. package/_types/tempo/Account.d.ts +47 -20
  153. package/_types/tempo/Account.d.ts.map +1 -1
  154. package/_types/tempo/Client.d.ts +23 -1
  155. package/_types/tempo/Client.d.ts.map +1 -1
  156. package/_types/tempo/Decorator.d.ts +30 -5
  157. package/_types/tempo/Decorator.d.ts.map +1 -1
  158. package/_types/tempo/Formatters.d.ts.map +1 -1
  159. package/_types/tempo/Multisig.d.ts +37 -0
  160. package/_types/tempo/Multisig.d.ts.map +1 -0
  161. package/_types/tempo/Selectors.d.ts +2 -3
  162. package/_types/tempo/Selectors.d.ts.map +1 -1
  163. package/_types/tempo/Store.d.ts +62 -0
  164. package/_types/tempo/Store.d.ts.map +1 -0
  165. package/_types/tempo/Transaction.d.ts +12 -31
  166. package/_types/tempo/Transaction.d.ts.map +1 -1
  167. package/_types/tempo/Transport.d.ts +37 -5
  168. package/_types/tempo/Transport.d.ts.map +1 -1
  169. package/_types/tempo/Zone.d.ts +35 -6799
  170. package/_types/tempo/Zone.d.ts.map +1 -1
  171. package/_types/tempo/actions/accessKey.d.ts +38 -8
  172. package/_types/tempo/actions/accessKey.d.ts.map +1 -1
  173. package/_types/tempo/actions/amm.d.ts.map +1 -1
  174. package/_types/tempo/actions/channel.d.ts.map +1 -1
  175. package/_types/tempo/actions/dex.d.ts.map +1 -1
  176. package/_types/tempo/actions/earn/deployment.d.ts +3 -3
  177. package/_types/tempo/actions/earn/deployment.d.ts.map +1 -1
  178. package/_types/tempo/actions/earn.d.ts.map +1 -1
  179. package/_types/tempo/actions/fee.d.ts.map +1 -1
  180. package/_types/tempo/actions/multisig.d.ts +139 -136
  181. package/_types/tempo/actions/multisig.d.ts.map +1 -1
  182. package/_types/tempo/actions/policy.d.ts.map +1 -1
  183. package/_types/tempo/actions/receivePolicy.d.ts.map +1 -1
  184. package/_types/tempo/actions/reward.d.ts.map +1 -1
  185. package/_types/tempo/actions/token.d.ts.map +1 -1
  186. package/_types/tempo/actions/virtualAddress.d.ts.map +1 -1
  187. package/_types/tempo/actions/zone.d.ts +4 -4
  188. package/_types/tempo/actions/zone.d.ts.map +1 -1
  189. package/_types/tempo/chainConfig.d.ts +38 -48
  190. package/_types/tempo/chainConfig.d.ts.map +1 -1
  191. package/_types/tempo/index.d.ts +5 -5
  192. package/_types/tempo/index.d.ts.map +1 -1
  193. package/_types/tempo/internal/types.d.ts +1 -1
  194. package/_types/tempo/internal/types.d.ts.map +1 -1
  195. package/_types/tempo/internal/utils.d.ts +1 -0
  196. package/_types/tempo/internal/utils.d.ts.map +1 -1
  197. package/_types/tempo/multisig/Config.d.ts +42 -0
  198. package/_types/tempo/multisig/Config.d.ts.map +1 -0
  199. package/_types/tempo/multisig/Operation.d.ts +32 -0
  200. package/_types/tempo/multisig/Operation.d.ts.map +1 -0
  201. package/_types/types/chain.d.ts +10 -0
  202. package/_types/types/chain.d.ts.map +1 -1
  203. package/_types/utils/hash/isHash.d.ts +1 -2
  204. package/_types/utils/hash/isHash.d.ts.map +1 -1
  205. package/actions/wallet/sendTransaction.ts +9 -1
  206. package/actions/wallet/sendTransactionSync.ts +9 -1
  207. package/errors/version.ts +1 -1
  208. package/package.json +2 -2
  209. package/tempo/Abis.ts +11 -23
  210. package/tempo/Account.ts +136 -105
  211. package/tempo/Client.ts +46 -3
  212. package/tempo/Decorator.ts +40 -8
  213. package/tempo/Formatters.ts +39 -21
  214. package/tempo/Multisig.ts +1490 -0
  215. package/tempo/Selectors.ts +2 -3
  216. package/tempo/Store.ts +170 -0
  217. package/tempo/Transaction.ts +39 -64
  218. package/tempo/Transport.ts +125 -10
  219. package/tempo/Zone.ts +30 -4
  220. package/tempo/actions/accessKey.ts +210 -23
  221. package/tempo/actions/amm.ts +7 -0
  222. package/tempo/actions/channel.ts +12 -0
  223. package/tempo/actions/dex.ts +10 -0
  224. package/tempo/actions/earn/deployment.ts +16 -3
  225. package/tempo/actions/earn.ts +19 -0
  226. package/tempo/actions/fee.ts +4 -0
  227. package/tempo/actions/multisig.ts +192 -94
  228. package/tempo/actions/policy.ts +8 -0
  229. package/tempo/actions/receivePolicy.ts +6 -0
  230. package/tempo/actions/reward.ts +5 -0
  231. package/tempo/actions/token.ts +33 -0
  232. package/tempo/actions/virtualAddress.ts +2 -0
  233. package/tempo/actions/zone.ts +10 -8
  234. package/tempo/chainConfig.ts +259 -100
  235. package/tempo/index.ts +5 -4
  236. package/tempo/internal/types.ts +3 -2
  237. package/tempo/internal/utils.ts +2 -0
  238. package/tempo/multisig/Config.ts +131 -0
  239. package/tempo/multisig/Operation.ts +211 -0
  240. package/types/chain.ts +14 -0
  241. package/utils/encoding/fromHex.ts +1 -1
  242. package/utils/hash/isHash.ts +2 -3
  243. package/_cjs/tempo/Storage.js.map +0 -1
  244. package/_cjs/tempo/internal/multisig.js +0 -56
  245. package/_cjs/tempo/internal/multisig.js.map +0 -1
  246. package/_esm/tempo/Storage.js.map +0 -1
  247. package/_esm/tempo/internal/multisig.js +0 -56
  248. package/_esm/tempo/internal/multisig.js.map +0 -1
  249. package/_types/tempo/Storage.d.ts +0 -42
  250. package/_types/tempo/Storage.d.ts.map +0 -1
  251. package/_types/tempo/internal/multisig.d.ts +0 -13
  252. package/_types/tempo/internal/multisig.d.ts.map +0 -1
  253. package/tempo/Storage.ts +0 -115
  254. package/tempo/internal/multisig.ts +0 -72
@@ -51,9 +51,8 @@ export const addressRegistry = {
51
51
 
52
52
  export const nativeMultisig = {
53
53
  deriveAccount: '0xce8e071c',
54
- getConfig: '0xe48a5f7b',
55
- isMultisigAccount: '0x9fbf029a',
56
- updateConfig: '0xe175d479',
54
+ getConfigCommitment: '0x5bd93359',
55
+ updateConfig: '0x64203645',
57
56
  } as const satisfies FunctionSelectors<typeof Abis.nativeMultisig>
58
57
 
59
58
  export const currentCommittee = {
package/tempo/Store.ts ADDED
@@ -0,0 +1,170 @@
1
+ import type { MaybePromise } from '../types/utils.js'
2
+
3
+ export type Store = {
4
+ /** Atomically replaces `expected` with `value` when supported. */
5
+ compareAndSet?: CompareAndSet | undefined
6
+ /** Reads a value. */
7
+ getItem(key: string): MaybePromise<string | null | undefined>
8
+ /** Removes a value. */
9
+ removeItem(key: string): MaybePromise<void>
10
+ /** Writes a value. */
11
+ setItem(key: string, value: string): MaybePromise<void>
12
+ }
13
+
14
+ /** Atomic compare-and-set operation. */
15
+ export type CompareAndSet = (
16
+ key: string,
17
+ expected: string | null,
18
+ value: string,
19
+ options?: CompareAndSet.Options | undefined,
20
+ ) => MaybePromise<boolean>
21
+
22
+ export declare namespace CompareAndSet {
23
+ /** Compare-and-set options. */
24
+ export type Options = {
25
+ /** Unix timestamp in milliseconds after which the value expires. */
26
+ expiresAt?: number | undefined
27
+ }
28
+ }
29
+
30
+ /** Store with atomic compare-and-set support. */
31
+ export type Atomic = Store & {
32
+ /** Atomically replaces `expected` with `value` and applies its expiration. */
33
+ compareAndSet: CompareAndSet
34
+ }
35
+
36
+ /**
37
+ * Wraps a base store with an optional key prefix and request deduplication.
38
+ * Concurrent `getItem` calls for the same key share one in-flight promise.
39
+ *
40
+ * @example
41
+ * ```ts
42
+ * import { Store } from 'viem/tempo'
43
+ *
44
+ * const store = Store.from(Store.memory(), { key: 'tempo' })
45
+ * await store.setItem('foo', 'bar')
46
+ * // stored under "tempo:foo"
47
+ * ```
48
+ */
49
+ export function from(store: Atomic, options?: from.Options | undefined): Atomic
50
+ export function from(store: Store, options?: from.Options | undefined): Store
51
+ export function from(store: Store, options: from.Options = {}): Store {
52
+ const { key } = options
53
+ const prefix = key ? `${key}:` : ''
54
+ const inflight = new Map<string, Promise<string | null | undefined>>()
55
+ const compareAndSet = store.compareAndSet?.bind(store)
56
+ return {
57
+ ...(compareAndSet
58
+ ? {
59
+ compareAndSet(k, expected, value, options) {
60
+ const fullKey = `${prefix}${k}`
61
+ inflight.delete(fullKey)
62
+ return compareAndSet(fullKey, expected, value, options)
63
+ },
64
+ }
65
+ : {}),
66
+ getItem(k) {
67
+ const fullKey = `${prefix}${k}`
68
+ const existing = inflight.get(fullKey)
69
+ if (existing) return existing
70
+ const result = Promise.resolve(store.getItem(fullKey)).finally(() => {
71
+ inflight.delete(fullKey)
72
+ })
73
+ inflight.set(fullKey, result)
74
+ return result
75
+ },
76
+ setItem(k, value) {
77
+ const fullKey = `${prefix}${k}`
78
+ inflight.delete(fullKey)
79
+ return store.setItem(fullKey, value)
80
+ },
81
+ removeItem(k) {
82
+ const fullKey = `${prefix}${k}`
83
+ inflight.delete(fullKey)
84
+ return store.removeItem(fullKey)
85
+ },
86
+ }
87
+ }
88
+
89
+ export declare namespace from {
90
+ /** Store options. */
91
+ type Options = {
92
+ /** Key prefix prepended to all store keys. */
93
+ key?: string | undefined
94
+ }
95
+ }
96
+
97
+ /** Creates an in-memory store backed by a `Map`. */
98
+ export function memory(options: from.Options = {}): Atomic {
99
+ const store = new Map<
100
+ string,
101
+ { expiresAt: number | undefined; value: string }
102
+ >()
103
+ const get = (key: string) => {
104
+ const entry = store.get(key)
105
+ if (!entry) return undefined
106
+ if (entry.expiresAt === undefined || entry.expiresAt > Date.now())
107
+ return entry
108
+ store.delete(key)
109
+ return undefined
110
+ }
111
+ return from(
112
+ {
113
+ compareAndSet(key, expected, value, options) {
114
+ if ((get(key)?.value ?? null) !== expected) return false
115
+ store.set(key, { expiresAt: options?.expiresAt, value })
116
+ return true
117
+ },
118
+ getItem(key) {
119
+ return get(key)?.value ?? null
120
+ },
121
+ setItem(key, value) {
122
+ store.set(key, { expiresAt: undefined, value })
123
+ },
124
+ removeItem(key) {
125
+ store.delete(key)
126
+ },
127
+ },
128
+ options,
129
+ )
130
+ }
131
+
132
+ /** Creates a store backed by `globalThis.sessionStorage`. */
133
+ export function session(options: from.Options = {}): Store {
134
+ return from(
135
+ {
136
+ getItem(key) {
137
+ return globalThis.sessionStorage.getItem(key)
138
+ },
139
+ setItem(key, value) {
140
+ try {
141
+ globalThis.sessionStorage.setItem(key, value)
142
+ } catch {}
143
+ },
144
+ removeItem(key) {
145
+ globalThis.sessionStorage.removeItem(key)
146
+ },
147
+ },
148
+ options,
149
+ )
150
+ }
151
+
152
+ let _default: Store | undefined
153
+
154
+ /**
155
+ * Returns the default store for the current environment.
156
+ *
157
+ * Returns a singleton so that the zone transport and actions share the
158
+ * same instance without requiring explicit plumbing.
159
+ *
160
+ * - Browser: `sessionStorage`
161
+ * - Server/unsupported: in-memory `Map`-based store
162
+ */
163
+ export function defaultStore(): Store {
164
+ if (_default) return _default
165
+ try {
166
+ if (globalThis.sessionStorage) _default = session()
167
+ } catch {}
168
+ _default ??= memory()
169
+ return _default
170
+ }
@@ -6,7 +6,9 @@ import * as Signature from 'ox/Signature'
6
6
  import {
7
7
  type AuthorizationTempo,
8
8
  type KeyAuthorization,
9
- type MultisigConfig,
9
+ MultisigConfig,
10
+ type MultisigOperation,
11
+ type MultisigSimulation,
10
12
  type TransactionReceipt as ox_TransactionReceipt,
11
13
  SignatureEnvelope,
12
14
  type TempoAddress,
@@ -40,6 +42,7 @@ import {
40
42
  parseTransaction as viem_parseTransaction,
41
43
  } from '../utils/transaction/parseTransaction.js'
42
44
  import { serializeTransaction as viem_serializeTransaction } from '../utils/transaction/serializeTransaction.js'
45
+ import type { MultisigAccount, RootAccount } from './Account.js'
43
46
 
44
47
  export type Transaction<
45
48
  bigintType = bigint,
@@ -57,6 +60,7 @@ export type TransactionRpc<pending extends boolean = false> = OneOf<
57
60
  > & {
58
61
  authorizationList?: AuthorizationTempo.ListRpc | undefined
59
62
  keyAuthorization?: KeyAuthorization.Rpc | null | undefined
63
+ multisig?: MultisigOperation.TransactionRpc | undefined
60
64
  signature: SignatureEnvelope.SignatureEnvelopeRpc
61
65
  })
62
66
  >
@@ -77,6 +81,7 @@ export type TransactionTempo<
77
81
  feeToken?: Address | undefined
78
82
  feePayerSignature?: viem_Signature | undefined
79
83
  keyAuthorization?: KeyAuthorization.Signed<quantity, index> | null | undefined
84
+ multisig?: MultisigOperation.TransactionOperation | undefined
80
85
  nonceKey?: quantity | undefined
81
86
  signature: SignatureEnvelope.SignatureEnvelope
82
87
  type: type
@@ -98,28 +103,23 @@ export type TransactionRequestRpc = OneOf<
98
103
  export type TransactionReceipt<
99
104
  quantity = bigint,
100
105
  index = number,
101
- status = 'success' | 'reverted',
106
+ status = 'success' | 'reverted' | 'pending',
102
107
  type = TransactionType,
108
+ multisig = MultisigOperation.TransactionOperation,
103
109
  > = viem_TransactionReceipt<quantity, index, status, type> & {
104
110
  feePayer?: Address | undefined
105
111
  feeToken?: Address | undefined
112
+ multisig?: multisig | undefined
106
113
  }
107
114
 
108
115
  export type TransactionReceiptRpc = TransactionReceipt<
109
116
  Hex.Hex,
110
117
  Hex.Hex,
111
- ox_TransactionReceipt.RpcStatus,
112
- ox_TransactionReceipt.RpcType
118
+ ox_TransactionReceipt.RpcStatus | 'pending',
119
+ ox_TransactionReceipt.RpcType,
120
+ MultisigOperation.TransactionRpc
113
121
  >
114
122
 
115
- /** @internal */
116
- export type MultisigOwnerState = {
117
- account: Address
118
- config?: Pick<MultisigConfig.Config, 'owners' | 'threshold'> | undefined
119
- initialized: boolean
120
- version: bigint
121
- }
122
-
123
123
  export type TransactionRequestTempo<
124
124
  quantity = bigint,
125
125
  index = number,
@@ -131,23 +131,11 @@ export type TransactionRequestTempo<
131
131
  capabilities?: ExtractCapabilities<'fillTransaction', 'Request'> | undefined
132
132
  feePayer?: Account | true | undefined
133
133
  feeToken?: TempoAddress.Address | bigint | undefined
134
+ hash?: Hex.Hex | undefined
134
135
  keyAuthorization?: KeyAuthorization.Signed<quantity, index> | undefined
135
- multisig?: Address | MultisigConfig.Config<index> | undefined
136
- /** Bootstrap multisig config hint for node-side gas modeling (TIP-1061). Attached automatically when `multisig` is present; the node ignores it for registered senders. */
137
- multisigInit?:
138
- | {
139
- salt: Hex.Hex
140
- threshold: number
141
- owners: readonly { owner: Address; weight: number }[]
142
- }
143
- | undefined
144
- /** @internal Local signing state for nested multisig owner accounts. */
145
- multisigOwnerStates?: readonly MultisigOwnerState[] | undefined
146
- /** Modeled owner approval count for node-side gas modeling (TIP-1061). */
147
- multisigSignatureCount?: number | undefined
148
- /** Current multisig config version. Inferred during request preparation; defaults to `0n` for bootstrap. */
149
- multisigVersion?: bigint | undefined
136
+ multisigSimulation?: MultisigSimulation.Spec | undefined
150
137
  nonceKey?: 'expiring' | quantity | undefined
138
+ owner?: MultisigAccount | RootAccount | undefined
151
139
  signatures?: readonly SignatureEnvelope.Serialized[] | undefined
152
140
  validBefore?: index | undefined
153
141
  validAfter?: index | undefined
@@ -169,12 +157,9 @@ export type TransactionSerializableTempo<
169
157
  feePayerSignature?: viem_Signature | null | undefined
170
158
  from?: Address | undefined
171
159
  keyAuthorization?: KeyAuthorization.Signed<quantity, index> | undefined
172
- multisig?: Address | MultisigConfig.Config<index> | undefined
173
- /** @internal Local signing state for nested multisig owner accounts. */
174
- multisigOwnerStates?: readonly MultisigOwnerState[] | undefined
175
- /** Current multisig config version. Inferred during request preparation; defaults to `0n` for bootstrap. */
176
- multisigVersion?: bigint | undefined
160
+ multisigSimulation?: MultisigSimulation.Spec | undefined
177
161
  nonceKey?: quantity | undefined
162
+ owner?: MultisigAccount | RootAccount | undefined
178
163
  signature?: SignatureEnvelope.SignatureEnvelope<quantity, index> | undefined
179
164
  signatures?: readonly SignatureEnvelope.Serialized[] | undefined
180
165
  validBefore?: index | undefined
@@ -206,9 +191,9 @@ export function getType(
206
191
  typeof transaction.feePayerSignature !== 'undefined' ||
207
192
  typeof transaction.feeToken !== 'undefined' ||
208
193
  typeof transaction.keyAuthorization !== 'undefined' ||
209
- typeof transaction.multisig !== 'undefined' ||
210
- typeof transaction.multisigVersion !== 'undefined' ||
194
+ typeof transaction.multisigSimulation !== 'undefined' ||
211
195
  typeof transaction.nonceKey !== 'undefined' ||
196
+ typeof transaction.owner !== 'undefined' ||
212
197
  typeof transaction.signature !== 'undefined' ||
213
198
  typeof transaction.signatures !== 'undefined' ||
214
199
  typeof transaction.validBefore !== 'undefined' ||
@@ -326,7 +311,14 @@ async function serializeTempo(
326
311
  return undefined
327
312
  })()
328
313
 
329
- const { chainId, feePayer, nonce, ...rest } = transaction
314
+ const {
315
+ chainId,
316
+ feePayer,
317
+ multisigSimulation,
318
+ nonce,
319
+ owner: _owner,
320
+ ...rest
321
+ } = transaction
330
322
 
331
323
  const feePayerSignature = (() => {
332
324
  const feePayerSignature = transaction.feePayerSignature
@@ -344,7 +336,7 @@ async function serializeTempo(
344
336
  transaction.feePayerSignature !== null
345
337
  const hasSenderSignature =
346
338
  typeof signature_provided !== 'undefined' ||
347
- Boolean(transaction.multisig && transaction.signatures)
339
+ Boolean(multisigSimulation && transaction.signatures)
348
340
  // Sponsorship sender signatures omit `feeToken`.
349
341
  const shouldStripFeeTokenForSponsorship =
350
342
  // Relay fills a partial sender envelope first.
@@ -385,41 +377,24 @@ async function serializeTempo(
385
377
  // Combine owner approvals before fee-payer handling.
386
378
  const signature = (() => {
387
379
  if (signature_provided) return signature_provided
388
- if (!transaction.multisig || !transaction.signatures) return undefined
380
+ if (!multisigSimulation || !transaction.signatures) return undefined
389
381
 
390
382
  const payload = TxTempo.getSignPayload(TxTempo.from(transaction_sender_ox))
391
383
  const signatures = transaction.signatures.map((approval) =>
392
384
  SignatureEnvelope.from(approval),
393
385
  )
394
- const sorted =
395
- typeof transaction.multisig === 'string'
396
- ? SignatureEnvelope.sortMultisigApprovals({
397
- account: transaction.multisig,
398
- payload,
399
- signatures,
400
- version: transaction.multisigVersion,
401
- })
402
- : SignatureEnvelope.sortMultisigApprovals({
403
- initialConfig: transaction.multisig,
404
- payload,
405
- signatures,
406
- version: transaction.multisigVersion,
407
- })
408
- const keyAuthorizationSignature = transaction.keyAuthorization?.signature
409
- const keyAuthorizationInitializes =
410
- keyAuthorizationSignature?.type === 'multisig' &&
411
- typeof keyAuthorizationSignature.init !== 'undefined'
412
- if (typeof transaction.multisig === 'string')
413
- return SignatureEnvelope.from({
414
- account: transaction.multisig,
415
- signatures: sorted,
416
- })
386
+ const config = MultisigConfig.from(multisigSimulation.config)
387
+ const account = multisigSimulation.account
388
+ const sorted = SignatureEnvelope.sortMultisigApprovals({
389
+ account,
390
+ config,
391
+ payload,
392
+ signatures,
393
+ })
417
394
  return SignatureEnvelope.from({
418
- initialConfig: transaction.multisig,
395
+ account,
396
+ config,
419
397
  signatures: sorted,
420
- ...(nonce || transaction.nonceKey || keyAuthorizationInitializes
421
- ? {}
422
- : { init: true }),
423
398
  })
424
399
  })()
425
400
 
@@ -17,24 +17,29 @@ import {
17
17
  type HttpTransportConfig,
18
18
  http as http_,
19
19
  } from '../clients/transports/http.js'
20
+ import {
21
+ MethodNotFoundRpcError,
22
+ MethodNotSupportedRpcError,
23
+ } from '../errors/rpc.js'
20
24
  import type { Chain } from '../types/chain.js'
21
25
  import type { ChainConfig } from './chainConfig.js'
22
- import type { Storage } from './Storage.js'
23
- import * as Storage_ from './Storage.js'
26
+ import * as Multisig from './Multisig.js'
27
+ import type { Store } from './Store.js'
28
+ import * as Store_ from './Store.js'
24
29
  import * as Transaction from './Transaction.js'
25
30
 
26
31
  export type HttpConfig = Omit<
27
32
  HttpTransportConfig,
28
33
  'batch' | 'raw' | 'rpcSchema'
29
34
  > & {
30
- /** Storage for reading Zone authorization tokens. Defaults to sessionStorage (web) or memory (server). */
31
- storage?: Storage | undefined
35
+ /** Store for reading Zone authorization tokens. Defaults to sessionStorage (web) or memory (server). */
36
+ store?: Store | undefined
32
37
  }
33
38
 
34
39
  /**
35
40
  * Creates an HTTP transport with support for Zone authentication tokens.
36
41
  *
37
- * Reads the authorization token from Storage and injects the
42
+ * Reads the authorization token from the store and injects the
38
43
  * `X-Authorization-Token` header on every request.
39
44
  *
40
45
  * @example
@@ -52,8 +57,8 @@ export function http(
52
57
  url?: string | undefined,
53
58
  config: HttpConfig = {},
54
59
  ): HttpTransport {
55
- const { storage: storage_, onFetchRequest, ...rest } = config
56
- const storage = storage_ ?? Storage_.defaultStorage()
60
+ const { store: store_, onFetchRequest, ...rest } = config
61
+ const store = store_ ?? Store_.defaultStore()
57
62
 
58
63
  return (config) =>
59
64
  http_(url, {
@@ -64,7 +69,7 @@ export function http(
64
69
 
65
70
  const chainId = config.chain?.id
66
71
  if (chainId) {
67
- const token = (await storage.getItem(`auth:token:${chainId}`)) ?? null
72
+ const token = (await store.getItem(`auth:token:${chainId}`)) ?? null
68
73
  if (token) headers.set('X-Authorization-Token', token)
69
74
  }
70
75
 
@@ -79,7 +84,64 @@ type RelayProxyParameters = {
79
84
  }
80
85
 
81
86
  export type FeePayer = Transport<typeof withFeePayer.type>
82
- export type Relay = Transport<typeof withRelay.type>
87
+ export type Relay = Transport<typeof withRelay.type, { multisig: true }>
88
+
89
+ /**
90
+ * Wraps a transport with native multisig request handling.
91
+ *
92
+ * @example
93
+ * ```ts
94
+ * import { http, Store, withMultisig } from 'viem/tempo'
95
+ *
96
+ * const transport = withMultisig(http(), {
97
+ * store: Store.memory(),
98
+ * })
99
+ * ```
100
+ *
101
+ * @param transport - Transport to wrap.
102
+ * @param parameters - Multisig request handler parameters.
103
+ * @returns The wrapped transport.
104
+ * @experimental
105
+ */
106
+ export function withMultisig<transport extends Transport>(
107
+ transport: transport,
108
+ parameters: withMultisig.Parameters,
109
+ ): withMultisig.ReturnValue<transport> {
110
+ return ((options: Parameters<Transport>[0]) => {
111
+ const value = transport(options)
112
+ return {
113
+ ...value,
114
+ request: Multisig.handleRequest(
115
+ (request, requestOptions) =>
116
+ value.request(request as never, requestOptions),
117
+ parameters,
118
+ ) as typeof value.request,
119
+ value: { ...value.value, multisig: true },
120
+ }
121
+ }) as withMultisig.ReturnValue<transport>
122
+ }
123
+
124
+ export declare namespace withMultisig {
125
+ /** Multisig transport parameters. */
126
+ export type Parameters = Multisig.handleRequest.Parameters
127
+
128
+ /** Multisig transport return type. */
129
+ export type ReturnValue<transport extends Transport = Transport> =
130
+ transport extends Transport<
131
+ infer type,
132
+ infer rpcAttributes,
133
+ infer eip1193RequestFn
134
+ >
135
+ ? Transport<
136
+ type,
137
+ rpcAttributes & {
138
+ /** Whether the transport coordinates native multisig approvals. */
139
+ multisig: true
140
+ },
141
+ eip1193RequestFn
142
+ >
143
+ : never
144
+ }
83
145
 
84
146
  /**
85
147
  * Creates a relay transport that routes requests between
@@ -87,6 +149,8 @@ export type Relay = Transport<typeof withRelay.type>
87
149
  *
88
150
  * All `eth_fillTransaction` requests are sent to the relay with the request's
89
151
  * `feePayer` value preserved so the relay can decide whether to sponsor the transaction.
152
+ * Multisig approvals, configs, operations, and operation-aware transaction
153
+ * lookups are also sent to the relay so it can coordinate approvals in its store.
90
154
  *
91
155
  * The policy parameter controls how the relay handles sponsored transactions:
92
156
  * - `'sign-only'`: Relay co-signs the transaction and returns it to the client transport, which then broadcasts it via the default transport
@@ -108,13 +172,60 @@ export function withRelay(
108
172
  const transport_default = defaultTransport(config)
109
173
  const transport_relay = relayTransport(config)
110
174
 
111
- return createTransport({
175
+ const transport = createTransport({
112
176
  key: withRelay.type,
113
177
  name: 'Relay Proxy',
114
178
  async request({ method, params }, options) {
115
179
  if (method === 'eth_fillTransaction')
116
180
  return transport_relay.request({ method, params }, options) as never
117
181
 
182
+ if (
183
+ method === 'eth_getTransactionByHash' ||
184
+ method === 'eth_getTransactionReceipt'
185
+ ) {
186
+ const result = await transport_default.request(
187
+ { method, params },
188
+ options,
189
+ )
190
+ if (result !== null && typeof result !== 'undefined')
191
+ return result as never
192
+
193
+ const operation = await (async () => {
194
+ try {
195
+ return await transport_relay.request(
196
+ { method: 'multisig_getOperation', params },
197
+ options,
198
+ )
199
+ } catch (error) {
200
+ if (
201
+ error instanceof MethodNotFoundRpcError ||
202
+ error instanceof MethodNotSupportedRpcError
203
+ ) {
204
+ // Relays created before multisig coordination do not expose this method.
205
+ return null
206
+ }
207
+ throw error
208
+ }
209
+ })()
210
+ if (
211
+ !operation ||
212
+ typeof operation !== 'object' ||
213
+ !('type' in operation) ||
214
+ operation.type !== 'transaction'
215
+ )
216
+ return result as never
217
+ return transport_relay.request({ method, params }, options) as never
218
+ }
219
+
220
+ if (
221
+ method === 'multisig_approveKeyAuthorization' ||
222
+ method === 'multisig_approveRawTransaction' ||
223
+ method === 'multisig_approveRawTransactionSync' ||
224
+ method === 'multisig_getConfig' ||
225
+ method === 'multisig_getOperation'
226
+ )
227
+ return transport_relay.request({ method, params }, options) as never
228
+
118
229
  if (
119
230
  method === 'eth_sendRawTransactionSync' ||
120
231
  method === 'eth_sendRawTransaction'
@@ -122,6 +233,9 @@ export function withRelay(
122
233
  const serialized = (params as any)[0] as `0x76${string}`
123
234
  const transaction = Transaction.deserialize(serialized)
124
235
 
236
+ if (transaction.signature?.type === 'multisig')
237
+ return transport_relay.request({ method, params }, options) as never
238
+
125
239
  // Serialized Tempo envelopes encode `feePayer: true` as a missing fee payer
126
240
  // signature until the relay co-signs the transaction.
127
241
  if (transaction.feePayerSignature === null) {
@@ -159,6 +273,7 @@ export function withRelay(
159
273
  },
160
274
  type: withRelay.type,
161
275
  })
276
+ return { ...transport, value: { multisig: true } }
162
277
  }
163
278
  }
164
279
 
package/tempo/Zone.ts CHANGED
@@ -1,9 +1,30 @@
1
- import type { Chain } from '../types/chain.js'
2
- import { defineChain } from '../utils/chain/defineChain.js'
3
- import { chainConfig } from './chainConfig.js'
1
+ import type { Chain, ChainFormatters } from '../types/chain.js'
2
+ import type { Assign } from '../types/utils.js'
3
+ import {
4
+ type DefineChainReturnType,
5
+ defineChain,
6
+ } from '../utils/chain/defineChain.js'
7
+ import { type ChainConfig, chainConfig } from './chainConfig.js'
8
+
9
+ type Defaults = {
10
+ nativeCurrency: {
11
+ decimals: number
12
+ name: string
13
+ symbol: string
14
+ }
15
+ rpcUrls: { default: { http: string[] } }
16
+ supportsTransactionReplacementDetection: boolean
17
+ }
18
+
19
+ type ZoneChain = Chain<ChainFormatters, ChainConfig['extendSchema']> & {
20
+ formatters: ChainConfig['formatters']
21
+ }
4
22
 
5
23
  /** Defines a Tempo Zone chain. */
6
- export function from<const config extends from.Parameters>(config: config) {
24
+ export function from<const config extends from.Parameters>(
25
+ config: config,
26
+ ): from.ReturnValue<config>
27
+ export function from(config: from.Parameters) {
7
28
  const chain = {
8
29
  ...chainConfig,
9
30
  nativeCurrency: {
@@ -23,6 +44,11 @@ export declare namespace from {
23
44
  Partial<Omit<Chain, 'id' | 'name' | 'sourceId'>> & {
24
45
  sourceId: number
25
46
  }
47
+
48
+ type ReturnValue<config extends Parameters = Parameters> = Assign<
49
+ Assign<DefineChainReturnType<ZoneChain>, Defaults>,
50
+ config
51
+ >
26
52
  }
27
53
 
28
54
  export const a = /*#__PURE__*/ from({