viem 2.56.0 → 2.56.2

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 (250) hide show
  1. package/CHANGELOG.md +16 -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 +990 -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/actions/accessKey.js +102 -8
  28. package/_cjs/tempo/actions/accessKey.js.map +1 -1
  29. package/_cjs/tempo/actions/amm.js +6 -0
  30. package/_cjs/tempo/actions/amm.js.map +1 -1
  31. package/_cjs/tempo/actions/channel.js +12 -0
  32. package/_cjs/tempo/actions/channel.js.map +1 -1
  33. package/_cjs/tempo/actions/dex.js +10 -0
  34. package/_cjs/tempo/actions/dex.js.map +1 -1
  35. package/_cjs/tempo/actions/earn/deployment.js +13 -1
  36. package/_cjs/tempo/actions/earn/deployment.js.map +1 -1
  37. package/_cjs/tempo/actions/earn.js +17 -0
  38. package/_cjs/tempo/actions/earn.js.map +1 -1
  39. package/_cjs/tempo/actions/fee.js +4 -0
  40. package/_cjs/tempo/actions/fee.js.map +1 -1
  41. package/_cjs/tempo/actions/multisig.js +86 -28
  42. package/_cjs/tempo/actions/multisig.js.map +1 -1
  43. package/_cjs/tempo/actions/policy.js +8 -0
  44. package/_cjs/tempo/actions/policy.js.map +1 -1
  45. package/_cjs/tempo/actions/receivePolicy.js +6 -0
  46. package/_cjs/tempo/actions/receivePolicy.js.map +1 -1
  47. package/_cjs/tempo/actions/reward.js +4 -0
  48. package/_cjs/tempo/actions/reward.js.map +1 -1
  49. package/_cjs/tempo/actions/token.js +32 -0
  50. package/_cjs/tempo/actions/token.js.map +1 -1
  51. package/_cjs/tempo/actions/virtualAddress.js +2 -0
  52. package/_cjs/tempo/actions/virtualAddress.js.map +1 -1
  53. package/_cjs/tempo/actions/zone.js +7 -5
  54. package/_cjs/tempo/actions/zone.js.map +1 -1
  55. package/_cjs/tempo/chainConfig.js +180 -69
  56. package/_cjs/tempo/chainConfig.js.map +1 -1
  57. package/_cjs/tempo/index.js +5 -2
  58. package/_cjs/tempo/index.js.map +1 -1
  59. package/_cjs/tempo/internal/utils.js +2 -1
  60. package/_cjs/tempo/internal/utils.js.map +1 -1
  61. package/_cjs/tempo/multisig/Config.js +80 -0
  62. package/_cjs/tempo/multisig/Config.js.map +1 -0
  63. package/_cjs/tempo/multisig/Operation.js +163 -0
  64. package/_cjs/tempo/multisig/Operation.js.map +1 -0
  65. package/_cjs/utils/encoding/fromHex.js +1 -1
  66. package/_cjs/utils/encoding/fromHex.js.map +1 -1
  67. package/_cjs/utils/hash/isHash.js +1 -2
  68. package/_cjs/utils/hash/isHash.js.map +1 -1
  69. package/_esm/actions/wallet/sendTransaction.js +9 -1
  70. package/_esm/actions/wallet/sendTransaction.js.map +1 -1
  71. package/_esm/actions/wallet/sendTransactionSync.js +9 -1
  72. package/_esm/actions/wallet/sendTransactionSync.js.map +1 -1
  73. package/_esm/errors/version.js +1 -1
  74. package/_esm/tempo/Abis.js +11 -23
  75. package/_esm/tempo/Abis.js.map +1 -1
  76. package/_esm/tempo/Account.js +66 -61
  77. package/_esm/tempo/Account.js.map +1 -1
  78. package/_esm/tempo/Client.js +22 -3
  79. package/_esm/tempo/Client.js.map +1 -1
  80. package/_esm/tempo/Decorator.js +2 -1
  81. package/_esm/tempo/Decorator.js.map +1 -1
  82. package/_esm/tempo/Formatters.js +32 -11
  83. package/_esm/tempo/Formatters.js.map +1 -1
  84. package/_esm/tempo/Multisig.js +1020 -0
  85. package/_esm/tempo/Multisig.js.map +1 -0
  86. package/_esm/tempo/Selectors.js +2 -3
  87. package/_esm/tempo/Selectors.js.map +1 -1
  88. package/_esm/tempo/{Storage.js → Store.js} +37 -26
  89. package/_esm/tempo/Store.js.map +1 -0
  90. package/_esm/tempo/Transaction.js +16 -31
  91. package/_esm/tempo/Transaction.js.map +1 -1
  92. package/_esm/tempo/Transport.js +71 -6
  93. package/_esm/tempo/Transport.js.map +1 -1
  94. package/_esm/tempo/actions/accessKey.js +104 -20
  95. package/_esm/tempo/actions/accessKey.js.map +1 -1
  96. package/_esm/tempo/actions/amm.js +6 -0
  97. package/_esm/tempo/actions/amm.js.map +1 -1
  98. package/_esm/tempo/actions/channel.js +12 -0
  99. package/_esm/tempo/actions/channel.js.map +1 -1
  100. package/_esm/tempo/actions/dex.js +10 -0
  101. package/_esm/tempo/actions/dex.js.map +1 -1
  102. package/_esm/tempo/actions/earn/deployment.js +13 -1
  103. package/_esm/tempo/actions/earn/deployment.js.map +1 -1
  104. package/_esm/tempo/actions/earn.js +17 -0
  105. package/_esm/tempo/actions/earn.js.map +1 -1
  106. package/_esm/tempo/actions/fee.js +4 -0
  107. package/_esm/tempo/actions/fee.js.map +1 -1
  108. package/_esm/tempo/actions/multisig.js +129 -63
  109. package/_esm/tempo/actions/multisig.js.map +1 -1
  110. package/_esm/tempo/actions/policy.js +8 -0
  111. package/_esm/tempo/actions/policy.js.map +1 -1
  112. package/_esm/tempo/actions/receivePolicy.js +6 -0
  113. package/_esm/tempo/actions/receivePolicy.js.map +1 -1
  114. package/_esm/tempo/actions/reward.js +4 -0
  115. package/_esm/tempo/actions/reward.js.map +1 -1
  116. package/_esm/tempo/actions/token.js +32 -0
  117. package/_esm/tempo/actions/token.js.map +1 -1
  118. package/_esm/tempo/actions/virtualAddress.js +2 -0
  119. package/_esm/tempo/actions/virtualAddress.js.map +1 -1
  120. package/_esm/tempo/actions/zone.js +8 -6
  121. package/_esm/tempo/actions/zone.js.map +1 -1
  122. package/_esm/tempo/chainConfig.js +188 -86
  123. package/_esm/tempo/chainConfig.js.map +1 -1
  124. package/_esm/tempo/index.js +5 -3
  125. package/_esm/tempo/index.js.map +1 -1
  126. package/_esm/tempo/internal/utils.js +2 -1
  127. package/_esm/tempo/internal/utils.js.map +1 -1
  128. package/_esm/tempo/multisig/Config.js +84 -0
  129. package/_esm/tempo/multisig/Config.js.map +1 -0
  130. package/_esm/tempo/multisig/Operation.js +170 -0
  131. package/_esm/tempo/multisig/Operation.js.map +1 -0
  132. package/_esm/utils/encoding/fromHex.js +1 -1
  133. package/_esm/utils/encoding/fromHex.js.map +1 -1
  134. package/_esm/utils/hash/isHash.js +1 -2
  135. package/_esm/utils/hash/isHash.js.map +1 -1
  136. package/_types/actions/wallet/sendTransaction.d.ts.map +1 -1
  137. package/_types/actions/wallet/sendTransactionSync.d.ts.map +1 -1
  138. package/_types/chains/definitions/tempo.d.ts +72 -92
  139. package/_types/chains/definitions/tempo.d.ts.map +1 -1
  140. package/_types/chains/definitions/tempoDevnet.d.ts +72 -92
  141. package/_types/chains/definitions/tempoDevnet.d.ts.map +1 -1
  142. package/_types/chains/definitions/tempoLocalnet.d.ts +72 -92
  143. package/_types/chains/definitions/tempoLocalnet.d.ts.map +1 -1
  144. package/_types/chains/definitions/tempoModerato.d.ts +72 -92
  145. package/_types/chains/definitions/tempoModerato.d.ts.map +1 -1
  146. package/_types/errors/version.d.ts +1 -1
  147. package/_types/tempo/Abis.d.ts +54 -108
  148. package/_types/tempo/Abis.d.ts.map +1 -1
  149. package/_types/tempo/Account.d.ts +47 -20
  150. package/_types/tempo/Account.d.ts.map +1 -1
  151. package/_types/tempo/Client.d.ts +23 -1
  152. package/_types/tempo/Client.d.ts.map +1 -1
  153. package/_types/tempo/Decorator.d.ts +30 -5
  154. package/_types/tempo/Decorator.d.ts.map +1 -1
  155. package/_types/tempo/Formatters.d.ts.map +1 -1
  156. package/_types/tempo/Multisig.d.ts +32 -0
  157. package/_types/tempo/Multisig.d.ts.map +1 -0
  158. package/_types/tempo/Selectors.d.ts +2 -3
  159. package/_types/tempo/Selectors.d.ts.map +1 -1
  160. package/_types/tempo/Store.d.ts +62 -0
  161. package/_types/tempo/Store.d.ts.map +1 -0
  162. package/_types/tempo/Transaction.d.ts +12 -31
  163. package/_types/tempo/Transaction.d.ts.map +1 -1
  164. package/_types/tempo/Transport.d.ts +37 -5
  165. package/_types/tempo/Transport.d.ts.map +1 -1
  166. package/_types/tempo/Zone.d.ts +468 -598
  167. package/_types/tempo/Zone.d.ts.map +1 -1
  168. package/_types/tempo/actions/accessKey.d.ts +38 -8
  169. package/_types/tempo/actions/accessKey.d.ts.map +1 -1
  170. package/_types/tempo/actions/amm.d.ts.map +1 -1
  171. package/_types/tempo/actions/channel.d.ts.map +1 -1
  172. package/_types/tempo/actions/dex.d.ts.map +1 -1
  173. package/_types/tempo/actions/earn/deployment.d.ts +3 -3
  174. package/_types/tempo/actions/earn/deployment.d.ts.map +1 -1
  175. package/_types/tempo/actions/earn.d.ts.map +1 -1
  176. package/_types/tempo/actions/fee.d.ts.map +1 -1
  177. package/_types/tempo/actions/multisig.d.ts +139 -136
  178. package/_types/tempo/actions/multisig.d.ts.map +1 -1
  179. package/_types/tempo/actions/policy.d.ts.map +1 -1
  180. package/_types/tempo/actions/receivePolicy.d.ts.map +1 -1
  181. package/_types/tempo/actions/reward.d.ts.map +1 -1
  182. package/_types/tempo/actions/token.d.ts.map +1 -1
  183. package/_types/tempo/actions/virtualAddress.d.ts.map +1 -1
  184. package/_types/tempo/actions/zone.d.ts +4 -4
  185. package/_types/tempo/actions/zone.d.ts.map +1 -1
  186. package/_types/tempo/chainConfig.d.ts +38 -48
  187. package/_types/tempo/chainConfig.d.ts.map +1 -1
  188. package/_types/tempo/index.d.ts +8 -3
  189. package/_types/tempo/index.d.ts.map +1 -1
  190. package/_types/tempo/internal/types.d.ts +1 -1
  191. package/_types/tempo/internal/types.d.ts.map +1 -1
  192. package/_types/tempo/internal/utils.d.ts +1 -0
  193. package/_types/tempo/internal/utils.d.ts.map +1 -1
  194. package/_types/tempo/multisig/Config.d.ts +42 -0
  195. package/_types/tempo/multisig/Config.d.ts.map +1 -0
  196. package/_types/tempo/multisig/Operation.d.ts +32 -0
  197. package/_types/tempo/multisig/Operation.d.ts.map +1 -0
  198. package/_types/types/chain.d.ts +10 -0
  199. package/_types/types/chain.d.ts.map +1 -1
  200. package/_types/utils/hash/isHash.d.ts +1 -2
  201. package/_types/utils/hash/isHash.d.ts.map +1 -1
  202. package/actions/wallet/sendTransaction.ts +9 -1
  203. package/actions/wallet/sendTransactionSync.ts +9 -1
  204. package/errors/version.ts +1 -1
  205. package/package.json +2 -2
  206. package/tempo/Abis.ts +11 -23
  207. package/tempo/Account.ts +136 -105
  208. package/tempo/Client.ts +46 -3
  209. package/tempo/Decorator.ts +40 -8
  210. package/tempo/Formatters.ts +39 -21
  211. package/tempo/Multisig.ts +1349 -0
  212. package/tempo/Selectors.ts +2 -3
  213. package/tempo/Store.ts +170 -0
  214. package/tempo/Transaction.ts +39 -64
  215. package/tempo/Transport.ts +125 -10
  216. package/tempo/actions/accessKey.ts +210 -23
  217. package/tempo/actions/amm.ts +7 -0
  218. package/tempo/actions/channel.ts +12 -0
  219. package/tempo/actions/dex.ts +10 -0
  220. package/tempo/actions/earn/deployment.ts +16 -3
  221. package/tempo/actions/earn.ts +19 -0
  222. package/tempo/actions/fee.ts +4 -0
  223. package/tempo/actions/multisig.ts +192 -94
  224. package/tempo/actions/policy.ts +8 -0
  225. package/tempo/actions/receivePolicy.ts +6 -0
  226. package/tempo/actions/reward.ts +5 -0
  227. package/tempo/actions/token.ts +33 -0
  228. package/tempo/actions/virtualAddress.ts +2 -0
  229. package/tempo/actions/zone.ts +10 -8
  230. package/tempo/chainConfig.ts +259 -100
  231. package/tempo/index.ts +9 -1
  232. package/tempo/internal/types.ts +3 -2
  233. package/tempo/internal/utils.ts +2 -0
  234. package/tempo/multisig/Config.ts +131 -0
  235. package/tempo/multisig/Operation.ts +211 -0
  236. package/types/chain.ts +14 -0
  237. package/utils/encoding/fromHex.ts +1 -1
  238. package/utils/hash/isHash.ts +2 -3
  239. package/_cjs/tempo/Storage.js.map +0 -1
  240. package/_cjs/tempo/internal/multisig.js +0 -56
  241. package/_cjs/tempo/internal/multisig.js.map +0 -1
  242. package/_esm/tempo/Storage.js.map +0 -1
  243. package/_esm/tempo/internal/multisig.js +0 -56
  244. package/_esm/tempo/internal/multisig.js.map +0 -1
  245. package/_types/tempo/Storage.d.ts +0 -42
  246. package/_types/tempo/Storage.d.ts.map +0 -1
  247. package/_types/tempo/internal/multisig.d.ts +0 -13
  248. package/_types/tempo/internal/multisig.d.ts.map +0 -1
  249. package/tempo/Storage.ts +0 -115
  250. package/tempo/internal/multisig.ts +0 -72
@@ -3,6 +3,7 @@
3
3
  import type { Address } from 'abitype'
4
4
  import * as Hex from 'ox/Hex'
5
5
  import {
6
+ MultisigOperation,
6
7
  Transaction as ox_Transaction,
7
8
  TransactionRequest as ox_TransactionRequest,
8
9
  } from 'ox/tempo'
@@ -11,7 +12,7 @@ import { parseAccount } from '../accounts/utils/parseAccount.js'
11
12
  import { formatTransaction as viem_formatTransaction } from '../utils/formatters/transaction.js'
12
13
  import { formatTransactionReceipt as viem_formatTransactionReceipt } from '../utils/formatters/transactionReceipt.js'
13
14
  import { formatTransactionRequest as viem_formatTransactionRequest } from '../utils/formatters/transactionRequest.js'
14
- import type { Account } from './Account.js'
15
+ import type { Account, MultisigAccount } from './Account.js'
15
16
  import {
16
17
  isTempo,
17
18
  type Transaction,
@@ -32,6 +33,7 @@ export function formatTransaction(
32
33
  transaction.blockTimestamp == null
33
34
  ? undefined
34
35
  : BigInt(transaction.blockTimestamp)
36
+ const multisig = transaction.multisig
35
37
  const {
36
38
  feePayerSignature,
37
39
  gasPrice: _,
@@ -51,6 +53,7 @@ export function formatTransaction(
51
53
  yParity: feePayerSignature.yParity,
52
54
  }
53
55
  : undefined,
56
+ multisig: formatMultisig(multisig),
54
57
  nonce: Number(nonce),
55
58
  typeHex:
56
59
  ox_Transaction.toRpcType[
@@ -63,7 +66,23 @@ export function formatTransaction(
63
66
  export function formatTransactionReceipt(
64
67
  receipt: TransactionReceiptRpc,
65
68
  ): TransactionReceipt {
66
- return viem_formatTransactionReceipt(receipt as never)
69
+ const transactionReceipt = viem_formatTransactionReceipt(receipt as never)
70
+ return {
71
+ ...transactionReceipt,
72
+ multisig: formatMultisig(receipt.multisig),
73
+ ...(receipt.status === 'pending'
74
+ ? { status: 'pending', type: 'tempo' }
75
+ : {}),
76
+ } as never
77
+ }
78
+
79
+ /** Formats a transaction operation attached to an RPC result. */
80
+ function formatMultisig(value: MultisigOperation.TransactionRpc | undefined) {
81
+ if (!value) return undefined
82
+ const operation = MultisigOperation.fromRpc(value)
83
+ if (operation.type !== 'transaction')
84
+ throw new Error('Expected a multisig transaction operation.')
85
+ return operation
67
86
  }
68
87
 
69
88
  export function formatTransactionRequest(
@@ -79,12 +98,22 @@ export function formatTransactionRequest(
79
98
  keyData?: Hex.Hex | undefined
80
99
  keyId?: Address | undefined
81
100
  keyType?: 'p256' | 'secp256k1' | 'webAuthn' | undefined
82
- multisig?: unknown
101
+ owner?: viem_Account | MultisigAccount | Address | undefined
83
102
  signatures?: unknown
84
103
  }
85
104
  const account = request.account
86
105
  ? parseAccount<Account | viem_Account | Address>(request.account)
87
106
  : undefined
107
+ const owner = request.owner
108
+ ? parseAccount<Account | MultisigAccount | viem_Account | Address>(
109
+ request.owner,
110
+ )
111
+ : undefined
112
+
113
+ if (owner?.type === 'json-rpc')
114
+ throw new Error(
115
+ 'A local owner account is required to approve a multisig transaction.',
116
+ )
88
117
 
89
118
  // If the request is not a Tempo transaction, route to Viem formatter.
90
119
  if (!isTempo(request))
@@ -119,16 +148,7 @@ export function formatTransactionRequest(
119
148
  delete request.feeToken
120
149
 
121
150
  // Client-only TIP-1061 fields drive local signing and envelope assembly.
122
- // `multisigInit` and `multisigSignatureCount` remain wire fields for gas modeling.
123
- const {
124
- multisig: _multisig,
125
- multisigInit,
126
- multisigOwnerStates: _multisigOwnerStates,
127
- multisigSignatureCount,
128
- multisigVersion: _multisigVersion,
129
- signatures: _signatures,
130
- ...rpcRequest
131
- } = request
151
+ const { owner: _owner, signatures: _signatures, ...rpcRequest } = request
132
152
 
133
153
  const rpc = ox_TransactionRequest.toRpc({
134
154
  ...rpcRequest,
@@ -144,9 +164,9 @@ export function formatTransactionRequest(
144
164
  rpc.data = undefined
145
165
  rpc.value = undefined
146
166
 
167
+ const signer = owner ?? account
147
168
  const [keyType, keyData] = (() => {
148
- const type =
149
- account && 'keyType' in account ? account.keyType : account?.source
169
+ const type = signer && 'keyType' in signer ? signer.keyType : signer?.source
150
170
  if (!type) return [request.keyType, shimKeyData(request.keyData)]
151
171
  if (type === 'webAuthn')
152
172
  // Send a 2-byte big-endian length hint (1400 = 0x0578) instead of a
@@ -159,22 +179,20 @@ export function formatTransactionRequest(
159
179
  })()
160
180
 
161
181
  const keyId =
162
- account && 'accessKeyAddress' in account
163
- ? account.accessKeyAddress
182
+ signer && 'accessKeyAddress' in signer
183
+ ? signer.accessKeyAddress
164
184
  : request.keyId
165
185
 
166
186
  if (account) rpc.from = account.address
167
187
 
168
188
  return {
169
189
  ...rpc,
170
- ...(multisigInit ? { multisigInit } : {}),
171
- ...(typeof multisigSignatureCount !== 'undefined'
172
- ? { multisigSignatureCount }
173
- : {}),
174
190
  ...(request.capabilities ? { capabilities: request.capabilities } : {}),
175
191
  ...(keyData ? { keyData } : {}),
176
192
  ...(keyId ? { keyId } : {}),
177
193
  ...(keyType ? { keyType } : {}),
194
+ // Keep the key visible to `extract`; the undefined value never reaches JSON-RPC.
195
+ ...(request.owner ? { owner: undefined } : {}),
178
196
  ...(typeof request.feePayer !== 'undefined'
179
197
  ? {
180
198
  feePayer: