viem 2.43.1 → 2.43.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 (101) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/_cjs/actions/wallet/prepareTransactionRequest.js +4 -5
  3. package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
  4. package/_cjs/chains/definitions/apollo.js +25 -0
  5. package/_cjs/chains/definitions/apollo.js.map +1 -0
  6. package/_cjs/chains/definitions/hpp.js +23 -0
  7. package/_cjs/chains/definitions/hpp.js.map +1 -0
  8. package/_cjs/chains/definitions/hppSepolia.js +23 -0
  9. package/_cjs/chains/definitions/hppSepolia.js.map +1 -0
  10. package/_cjs/chains/definitions/mantraDuKongEVMTestnet.js +2 -2
  11. package/_cjs/chains/definitions/mantraDuKongEVMTestnet.js.map +1 -1
  12. package/_cjs/chains/definitions/moonbeam.js +2 -2
  13. package/_cjs/chains/definitions/moonbeam.js.map +1 -1
  14. package/_cjs/chains/definitions/moonriver.js +2 -2
  15. package/_cjs/chains/definitions/moonriver.js.map +1 -1
  16. package/_cjs/chains/definitions/tempoDevnet.js +3 -3
  17. package/_cjs/chains/definitions/tempoDevnet.js.map +1 -1
  18. package/_cjs/chains/index.js +20 -14
  19. package/_cjs/chains/index.js.map +1 -1
  20. package/_cjs/errors/version.js +1 -1
  21. package/_cjs/tempo/Formatters.js +8 -13
  22. package/_cjs/tempo/Formatters.js.map +1 -1
  23. package/_cjs/tempo/Transaction.js +2 -2
  24. package/_cjs/tempo/Transaction.js.map +1 -1
  25. package/_cjs/tempo/actions/nonce.js.map +1 -1
  26. package/_cjs/tempo/chainConfig.js +37 -28
  27. package/_cjs/tempo/chainConfig.js.map +1 -1
  28. package/_cjs/tempo/index.js +2 -1
  29. package/_cjs/tempo/index.js.map +1 -1
  30. package/_esm/actions/wallet/prepareTransactionRequest.js +4 -5
  31. package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
  32. package/_esm/chains/definitions/apollo.js +22 -0
  33. package/_esm/chains/definitions/apollo.js.map +1 -0
  34. package/_esm/chains/definitions/hpp.js +20 -0
  35. package/_esm/chains/definitions/hpp.js.map +1 -0
  36. package/_esm/chains/definitions/hppSepolia.js +20 -0
  37. package/_esm/chains/definitions/hppSepolia.js.map +1 -0
  38. package/_esm/chains/definitions/mantraDuKongEVMTestnet.js +2 -2
  39. package/_esm/chains/definitions/mantraDuKongEVMTestnet.js.map +1 -1
  40. package/_esm/chains/definitions/moonbeam.js +2 -2
  41. package/_esm/chains/definitions/moonbeam.js.map +1 -1
  42. package/_esm/chains/definitions/moonriver.js +2 -2
  43. package/_esm/chains/definitions/moonriver.js.map +1 -1
  44. package/_esm/chains/definitions/tempoDevnet.js +3 -3
  45. package/_esm/chains/definitions/tempoDevnet.js.map +1 -1
  46. package/_esm/chains/index.js +3 -0
  47. package/_esm/chains/index.js.map +1 -1
  48. package/_esm/errors/version.js +1 -1
  49. package/_esm/tempo/Formatters.js +8 -23
  50. package/_esm/tempo/Formatters.js.map +1 -1
  51. package/_esm/tempo/Transaction.js +2 -2
  52. package/_esm/tempo/Transaction.js.map +1 -1
  53. package/_esm/tempo/actions/nonce.js +2 -44
  54. package/_esm/tempo/actions/nonce.js.map +1 -1
  55. package/_esm/tempo/chainConfig.js +38 -29
  56. package/_esm/tempo/chainConfig.js.map +1 -1
  57. package/_esm/tempo/index.js +1 -1
  58. package/_esm/tempo/index.js.map +1 -1
  59. package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
  60. package/_types/chains/definitions/apollo.d.ts +48 -0
  61. package/_types/chains/definitions/apollo.d.ts.map +1 -0
  62. package/_types/chains/definitions/hpp.d.ts +49 -0
  63. package/_types/chains/definitions/hpp.d.ts.map +1 -0
  64. package/_types/chains/definitions/hppSepolia.d.ts +49 -0
  65. package/_types/chains/definitions/hppSepolia.d.ts.map +1 -0
  66. package/_types/chains/definitions/mantraDuKongEVMTestnet.d.ts +2 -2
  67. package/_types/chains/definitions/moonbeam.d.ts +2 -2
  68. package/_types/chains/definitions/moonriver.d.ts +2 -2
  69. package/_types/chains/definitions/tempoDevnet.d.ts +16 -8
  70. package/_types/chains/definitions/tempoDevnet.d.ts.map +1 -1
  71. package/_types/chains/definitions/tempoLocalnet.d.ts +10 -2
  72. package/_types/chains/definitions/tempoLocalnet.d.ts.map +1 -1
  73. package/_types/chains/definitions/tempoTestnet.d.ts +10 -2
  74. package/_types/chains/definitions/tempoTestnet.d.ts.map +1 -1
  75. package/_types/chains/index.d.ts +3 -0
  76. package/_types/chains/index.d.ts.map +1 -1
  77. package/_types/errors/version.d.ts +1 -1
  78. package/_types/tempo/Formatters.d.ts.map +1 -1
  79. package/_types/tempo/Transaction.d.ts.map +1 -1
  80. package/_types/tempo/actions/nonce.d.ts +2 -44
  81. package/_types/tempo/actions/nonce.d.ts.map +1 -1
  82. package/_types/tempo/chainConfig.d.ts +5 -1
  83. package/_types/tempo/chainConfig.d.ts.map +1 -1
  84. package/_types/tempo/index.d.ts +1 -1
  85. package/_types/tempo/index.d.ts.map +1 -1
  86. package/actions/wallet/prepareTransactionRequest.ts +24 -11
  87. package/chains/definitions/apollo.ts +22 -0
  88. package/chains/definitions/hpp.ts +20 -0
  89. package/chains/definitions/hppSepolia.ts +20 -0
  90. package/chains/definitions/mantraDuKongEVMTestnet.ts +2 -2
  91. package/chains/definitions/moonbeam.ts +2 -2
  92. package/chains/definitions/moonriver.ts +2 -2
  93. package/chains/definitions/tempoDevnet.ts +3 -3
  94. package/chains/index.ts +3 -0
  95. package/errors/version.ts +1 -1
  96. package/package.json +2 -2
  97. package/tempo/Formatters.ts +10 -26
  98. package/tempo/Transaction.ts +4 -2
  99. package/tempo/actions/nonce.ts +2 -44
  100. package/tempo/chainConfig.ts +42 -29
  101. package/tempo/index.ts +1 -1
@@ -106,31 +106,9 @@ export function formatTransactionRequest(
106
106
  rpc.maxPriorityFeePerGas = undefined
107
107
  }
108
108
 
109
- // JSON-RPC accounts (wallets) don't support Tempo transactions yet,
110
- // we will omit the type to attempt to make them compatible
111
- // with the base transaction structure.
112
- // TODO: `calls` will not be supported by a lot of JSON-RPC accounts (wallet),
113
- // use `wallet_sendCalls` or sequential `eth_sendTransaction` to mimic the
114
- // behavior of `calls`.
115
- if (account?.type === 'json-rpc') {
116
- if (rpc.calls?.length && rpc.calls.length > 1)
117
- throw new Error(
118
- 'Batch calls are not supported with JSON-RPC accounts yet.',
119
- )
120
- rpc.data = rpc.calls?.at(0)?.data
121
- rpc.to = rpc.calls?.at(0)?.to
122
- rpc.type = undefined
123
- }
124
-
125
- // We rely on `calls` for Tempo transactions.
126
- // However, `calls` may not be supported by JSON-RPC accounts (wallets) yet,
127
- // so we will not remove the `data`, `to`, and `value` fields to make it
128
- // compatible with the base transaction structure.
129
- if (account?.type !== 'json-rpc') {
130
- rpc.to = undefined
131
- rpc.data = undefined
132
- rpc.value = undefined
133
- }
109
+ rpc.to = undefined
110
+ rpc.data = undefined
111
+ rpc.value = undefined
134
112
 
135
113
  const [keyType, keyData] = (() => {
136
114
  const type =
@@ -143,10 +121,16 @@ export function formatTransactionRequest(
143
121
  return [undefined, undefined]
144
122
  })()
145
123
 
124
+ const keyId =
125
+ account && 'accessKeyAddress' in account
126
+ ? account.accessKeyAddress
127
+ : undefined
128
+
146
129
  return {
147
130
  ...rpc,
148
- ...(keyType ? { keyType } : {}),
149
131
  ...(keyData ? { keyData } : {}),
132
+ ...(keyId ? { keyId } : {}),
133
+ ...(keyType ? { keyType } : {}),
150
134
  ...(request.feePayer
151
135
  ? {
152
136
  feePayer:
@@ -159,9 +159,11 @@ export type TransactionType = viem_TransactionType | 'tempo'
159
159
  export function getType(
160
160
  transaction: Record<string, unknown>,
161
161
  ): Transaction['type'] {
162
+ const account = transaction.account as
163
+ | { keyType?: string | undefined }
164
+ | undefined
162
165
  if (
163
- (transaction.account &&
164
- (transaction.account as { keyType?: string })?.keyType !== 'secp256k1') ||
166
+ (account?.keyType && account.keyType !== 'secp256k1') ||
165
167
  typeof transaction.calls !== 'undefined' ||
166
168
  typeof transaction.feePayer !== 'undefined' ||
167
169
  typeof transaction.feeToken !== 'undefined' ||
@@ -111,27 +111,7 @@ export namespace getNonce {
111
111
  }
112
112
 
113
113
  /**
114
- * Gets the number of active nonce keys for an account.
115
- *
116
- * @example
117
- * ```ts
118
- * import { createClient, http } from 'viem'
119
- * import { tempo } from 'tempo.ts/chains'
120
- * import { Actions } from 'tempo.ts/viem'
121
- *
122
- * const client = createClient({
123
- * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
124
- * transport: http(),
125
- * })
126
- *
127
- * const count = await Actions.nonce.getNonceKeyCount(client, {
128
- * account: '0x...',
129
- * })
130
- * ```
131
- *
132
- * @param client - Client.
133
- * @param parameters - Parameters.
134
- * @returns The number of active nonce keys.
114
+ * @deprecated This function has been deprecated post-AllegroModerato. It will be removed in a future version.
135
115
  */
136
116
  export async function getNonceKeyCount<
137
117
  chain extends Chain | undefined,
@@ -203,29 +183,7 @@ export namespace getNonceKeyCount {
203
183
  }
204
184
 
205
185
  /**
206
- * Watches for nonce incremented events.
207
- *
208
- * @example
209
- * ```ts
210
- * import { createClient, http } from 'viem'
211
- * import { tempo } from 'tempo.ts/chains'
212
- * import { Actions } from 'tempo.ts/viem'
213
- *
214
- * const client = createClient({
215
- * chain: tempo({ feeToken: '0x20c0000000000000000000000000000000000001' }),
216
- * transport: http(),
217
- * })
218
- *
219
- * const unwatch = Actions.nonce.watchNonceIncremented(client, {
220
- * onNonceIncremented: (args, log) => {
221
- * console.log('Nonce incremented:', args)
222
- * },
223
- * })
224
- * ```
225
- *
226
- * @param client - Client.
227
- * @param parameters - Parameters.
228
- * @returns A function to unsubscribe from the event.
186
+ * @deprecated This function has been deprecated post-AllegroModerato. It will be removed in a future version.
229
187
  */
230
188
  export function watchNonceIncremented<
231
189
  chain extends Chain | undefined,
@@ -31,41 +31,54 @@ export const chainConfig = {
31
31
  format: Formatters.formatTransactionRequest,
32
32
  }),
33
33
  },
34
- async prepareTransactionRequest(r) {
35
- const request = r as Transaction.TransactionRequest & {
36
- account?: Account | undefined
37
- chain?:
38
- | (Chain & { feeToken?: TokenId.TokenIdOrAddress | undefined })
39
- | undefined
40
- }
34
+ prepareTransactionRequest: [
35
+ async (r, { phase }) => {
36
+ const request = r as Transaction.TransactionRequest & {
37
+ account?: Account | undefined
38
+ chain?:
39
+ | (Chain & { feeToken?: TokenId.TokenIdOrAddress | undefined })
40
+ | undefined
41
+ }
42
+
43
+ if (phase === 'afterFillParameters') {
44
+ if (typeof request.nonceKey === 'bigint' && request.nonceKey > 0n)
45
+ request.gas = (request.gas ?? 0n) + 40_000n
46
+ return request as unknown as typeof r
47
+ }
41
48
 
42
- request.nonceKey = (() => {
43
- if (typeof request.nonceKey !== 'undefined') return request.nonceKey
49
+ request.nonceKey = (() => {
50
+ if (
51
+ typeof request.nonceKey !== 'undefined' &&
52
+ request.nonceKey !== 'random'
53
+ )
54
+ return request.nonceKey
44
55
 
45
- const address = request.account?.address ?? request.from
46
- if (!address) return undefined
47
- if (!request.chain) return undefined
48
- const nonceKey = NonceKeyStore.getNonceKey(NonceKeyStore.store, {
49
- address,
50
- chainId: request.chain.id,
51
- })
56
+ const address = request.account?.address ?? request.from
57
+ if (!address) return undefined
58
+ if (!request.chain) return undefined
59
+ const nonceKey = NonceKeyStore.getNonceKey(NonceKeyStore.store, {
60
+ address,
61
+ chainId: request.chain.id,
62
+ })
52
63
 
53
- if (nonceKey === 0n) return undefined
54
- return nonceKey
55
- })()
64
+ if (nonceKey === 0n) return undefined
65
+ return nonceKey
66
+ })()
56
67
 
57
- request.nonce = (() => {
58
- if (typeof request.nonce === 'number') return request.nonce
59
- // TODO: remove this line once `eth_fillTransaction` supports nonce keys.
60
- if (request.nonceKey) return 0
61
- return undefined
62
- })()
68
+ request.nonce = (() => {
69
+ if (typeof request.nonce === 'number') return request.nonce
70
+ // TODO: remove this line once `eth_fillTransaction` supports nonce keys.
71
+ if (request.nonceKey) return 0
72
+ return undefined
73
+ })()
63
74
 
64
- if (!request.feeToken && request.chain?.feeToken)
65
- request.feeToken = request.chain.feeToken
75
+ if (!request.feeToken && request.chain?.feeToken)
76
+ request.feeToken = request.chain.feeToken
66
77
 
67
- return request as unknown as typeof r
68
- },
78
+ return request as unknown as typeof r
79
+ },
80
+ { runAt: ['beforeFillTransaction', 'afterFillParameters'] },
81
+ ],
69
82
  serializers: {
70
83
  // TODO: casting to satisfy viem – viem v3 to have more flexible serializer type.
71
84
  transaction: ((transaction, signature) =>
package/tempo/index.ts CHANGED
@@ -54,6 +54,6 @@ export type {
54
54
  } from './Transaction.js'
55
55
  export * as Transaction from './Transaction.js'
56
56
  export * as Transport from './Transport.js'
57
- export { withFeePayer } from './Transport.js'
57
+ export { walletNamespaceCompat, withFeePayer } from './Transport.js'
58
58
  export * as WebAuthnP256 from './WebAuthnP256.js'
59
59
  export * as WebCryptoP256 from './WebCryptoP256.js'