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.
- package/CHANGELOG.md +26 -0
- package/_cjs/actions/wallet/prepareTransactionRequest.js +4 -5
- package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_cjs/chains/definitions/apollo.js +25 -0
- package/_cjs/chains/definitions/apollo.js.map +1 -0
- package/_cjs/chains/definitions/hpp.js +23 -0
- package/_cjs/chains/definitions/hpp.js.map +1 -0
- package/_cjs/chains/definitions/hppSepolia.js +23 -0
- package/_cjs/chains/definitions/hppSepolia.js.map +1 -0
- package/_cjs/chains/definitions/mantraDuKongEVMTestnet.js +2 -2
- package/_cjs/chains/definitions/mantraDuKongEVMTestnet.js.map +1 -1
- package/_cjs/chains/definitions/moonbeam.js +2 -2
- package/_cjs/chains/definitions/moonbeam.js.map +1 -1
- package/_cjs/chains/definitions/moonriver.js +2 -2
- package/_cjs/chains/definitions/moonriver.js.map +1 -1
- package/_cjs/chains/definitions/tempoDevnet.js +3 -3
- package/_cjs/chains/definitions/tempoDevnet.js.map +1 -1
- package/_cjs/chains/index.js +20 -14
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/tempo/Formatters.js +8 -13
- package/_cjs/tempo/Formatters.js.map +1 -1
- package/_cjs/tempo/Transaction.js +2 -2
- package/_cjs/tempo/Transaction.js.map +1 -1
- package/_cjs/tempo/actions/nonce.js.map +1 -1
- package/_cjs/tempo/chainConfig.js +37 -28
- package/_cjs/tempo/chainConfig.js.map +1 -1
- package/_cjs/tempo/index.js +2 -1
- package/_cjs/tempo/index.js.map +1 -1
- package/_esm/actions/wallet/prepareTransactionRequest.js +4 -5
- package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_esm/chains/definitions/apollo.js +22 -0
- package/_esm/chains/definitions/apollo.js.map +1 -0
- package/_esm/chains/definitions/hpp.js +20 -0
- package/_esm/chains/definitions/hpp.js.map +1 -0
- package/_esm/chains/definitions/hppSepolia.js +20 -0
- package/_esm/chains/definitions/hppSepolia.js.map +1 -0
- package/_esm/chains/definitions/mantraDuKongEVMTestnet.js +2 -2
- package/_esm/chains/definitions/mantraDuKongEVMTestnet.js.map +1 -1
- package/_esm/chains/definitions/moonbeam.js +2 -2
- package/_esm/chains/definitions/moonbeam.js.map +1 -1
- package/_esm/chains/definitions/moonriver.js +2 -2
- package/_esm/chains/definitions/moonriver.js.map +1 -1
- package/_esm/chains/definitions/tempoDevnet.js +3 -3
- package/_esm/chains/definitions/tempoDevnet.js.map +1 -1
- package/_esm/chains/index.js +3 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/tempo/Formatters.js +8 -23
- package/_esm/tempo/Formatters.js.map +1 -1
- package/_esm/tempo/Transaction.js +2 -2
- package/_esm/tempo/Transaction.js.map +1 -1
- package/_esm/tempo/actions/nonce.js +2 -44
- package/_esm/tempo/actions/nonce.js.map +1 -1
- package/_esm/tempo/chainConfig.js +38 -29
- package/_esm/tempo/chainConfig.js.map +1 -1
- package/_esm/tempo/index.js +1 -1
- package/_esm/tempo/index.js.map +1 -1
- package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
- package/_types/chains/definitions/apollo.d.ts +48 -0
- package/_types/chains/definitions/apollo.d.ts.map +1 -0
- package/_types/chains/definitions/hpp.d.ts +49 -0
- package/_types/chains/definitions/hpp.d.ts.map +1 -0
- package/_types/chains/definitions/hppSepolia.d.ts +49 -0
- package/_types/chains/definitions/hppSepolia.d.ts.map +1 -0
- package/_types/chains/definitions/mantraDuKongEVMTestnet.d.ts +2 -2
- package/_types/chains/definitions/moonbeam.d.ts +2 -2
- package/_types/chains/definitions/moonriver.d.ts +2 -2
- package/_types/chains/definitions/tempoDevnet.d.ts +16 -8
- package/_types/chains/definitions/tempoDevnet.d.ts.map +1 -1
- package/_types/chains/definitions/tempoLocalnet.d.ts +10 -2
- package/_types/chains/definitions/tempoLocalnet.d.ts.map +1 -1
- package/_types/chains/definitions/tempoTestnet.d.ts +10 -2
- package/_types/chains/definitions/tempoTestnet.d.ts.map +1 -1
- package/_types/chains/index.d.ts +3 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/tempo/Formatters.d.ts.map +1 -1
- package/_types/tempo/Transaction.d.ts.map +1 -1
- package/_types/tempo/actions/nonce.d.ts +2 -44
- package/_types/tempo/actions/nonce.d.ts.map +1 -1
- package/_types/tempo/chainConfig.d.ts +5 -1
- package/_types/tempo/chainConfig.d.ts.map +1 -1
- package/_types/tempo/index.d.ts +1 -1
- package/_types/tempo/index.d.ts.map +1 -1
- package/actions/wallet/prepareTransactionRequest.ts +24 -11
- package/chains/definitions/apollo.ts +22 -0
- package/chains/definitions/hpp.ts +20 -0
- package/chains/definitions/hppSepolia.ts +20 -0
- package/chains/definitions/mantraDuKongEVMTestnet.ts +2 -2
- package/chains/definitions/moonbeam.ts +2 -2
- package/chains/definitions/moonriver.ts +2 -2
- package/chains/definitions/tempoDevnet.ts +3 -3
- package/chains/index.ts +3 -0
- package/errors/version.ts +1 -1
- package/package.json +2 -2
- package/tempo/Formatters.ts +10 -26
- package/tempo/Transaction.ts +4 -2
- package/tempo/actions/nonce.ts +2 -44
- package/tempo/chainConfig.ts +42 -29
- package/tempo/index.ts +1 -1
package/tempo/Formatters.ts
CHANGED
|
@@ -106,31 +106,9 @@ export function formatTransactionRequest(
|
|
|
106
106
|
rpc.maxPriorityFeePerGas = undefined
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
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:
|
package/tempo/Transaction.ts
CHANGED
|
@@ -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
|
-
(
|
|
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' ||
|
package/tempo/actions/nonce.ts
CHANGED
|
@@ -111,27 +111,7 @@ export namespace getNonce {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
/**
|
|
114
|
-
*
|
|
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
|
-
*
|
|
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,
|
package/tempo/chainConfig.ts
CHANGED
|
@@ -31,41 +31,54 @@ export const chainConfig = {
|
|
|
31
31
|
format: Formatters.formatTransactionRequest,
|
|
32
32
|
}),
|
|
33
33
|
},
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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
|
-
|
|
43
|
-
|
|
49
|
+
request.nonceKey = (() => {
|
|
50
|
+
if (
|
|
51
|
+
typeof request.nonceKey !== 'undefined' &&
|
|
52
|
+
request.nonceKey !== 'random'
|
|
53
|
+
)
|
|
54
|
+
return request.nonceKey
|
|
44
55
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
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
|
-
|
|
54
|
-
|
|
55
|
-
|
|
64
|
+
if (nonceKey === 0n) return undefined
|
|
65
|
+
return nonceKey
|
|
66
|
+
})()
|
|
56
67
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
|
|
65
|
-
|
|
75
|
+
if (!request.feeToken && request.chain?.feeToken)
|
|
76
|
+
request.feeToken = request.chain.feeToken
|
|
66
77
|
|
|
67
|
-
|
|
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'
|