viem 2.47.12 → 2.47.15
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 +24 -0
- package/_cjs/actions/public/fillTransaction.js +7 -4
- package/_cjs/actions/public/fillTransaction.js.map +1 -1
- package/_cjs/actions/wallet/prepareTransactionRequest.js +3 -0
- package/_cjs/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_cjs/actions/wallet/sendTransaction.js.map +1 -1
- package/_cjs/actions/wallet/sendTransactionSync.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/tempo/Decorator.js +5 -0
- package/_cjs/tempo/Decorator.js.map +1 -1
- package/_cjs/tempo/Formatters.js +2 -0
- package/_cjs/tempo/Formatters.js.map +1 -1
- package/_cjs/tempo/actions/index.js +2 -1
- package/_cjs/tempo/actions/index.js.map +1 -1
- package/_cjs/tempo/actions/simulate.js +157 -0
- package/_cjs/tempo/actions/simulate.js.map +1 -0
- package/_esm/actions/public/fillTransaction.js +7 -4
- package/_esm/actions/public/fillTransaction.js.map +1 -1
- package/_esm/actions/wallet/prepareTransactionRequest.js +3 -0
- package/_esm/actions/wallet/prepareTransactionRequest.js.map +1 -1
- package/_esm/actions/wallet/sendTransaction.js.map +1 -1
- package/_esm/actions/wallet/sendTransactionSync.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/tempo/Decorator.js +5 -0
- package/_esm/tempo/Decorator.js.map +1 -1
- package/_esm/tempo/Formatters.js +2 -0
- package/_esm/tempo/Formatters.js.map +1 -1
- package/_esm/tempo/actions/index.js +1 -0
- package/_esm/tempo/actions/index.js.map +1 -1
- package/_esm/tempo/actions/simulate.js +233 -0
- package/_esm/tempo/actions/simulate.js.map +1 -0
- package/_types/actions/public/fillTransaction.d.ts +2 -0
- package/_types/actions/public/fillTransaction.d.ts.map +1 -1
- package/_types/actions/wallet/prepareTransactionRequest.d.ts +4 -1
- package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
- package/_types/actions/wallet/sendTransaction.d.ts.map +1 -1
- package/_types/actions/wallet/sendTransactionSync.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/tempo/Capabilities.d.ts +43 -0
- package/_types/tempo/Capabilities.d.ts.map +1 -1
- package/_types/tempo/Decorator.d.ts +79 -0
- package/_types/tempo/Decorator.d.ts.map +1 -1
- package/_types/tempo/Formatters.d.ts.map +1 -1
- package/_types/tempo/actions/index.d.ts +1 -0
- package/_types/tempo/actions/index.d.ts.map +1 -1
- package/_types/tempo/actions/simulate.d.ts +193 -0
- package/_types/tempo/actions/simulate.d.ts.map +1 -0
- package/_types/types/eip1193.d.ts +2 -0
- package/_types/types/eip1193.d.ts.map +1 -1
- package/actions/public/fillTransaction.ts +11 -4
- package/actions/wallet/prepareTransactionRequest.ts +10 -1
- package/actions/wallet/sendTransaction.ts +6 -3
- package/actions/wallet/sendTransactionSync.ts +6 -3
- package/errors/version.ts +1 -1
- package/package.json +2 -2
- package/tempo/Capabilities.ts +52 -0
- package/tempo/Decorator.ts +92 -0
- package/tempo/Formatters.ts +2 -0
- package/tempo/actions/index.ts +1 -0
- package/tempo/actions/simulate.ts +452 -0
- package/types/eip1193.ts +2 -0
|
@@ -31,6 +31,7 @@ import {
|
|
|
31
31
|
} from '../../errors/fee.js'
|
|
32
32
|
import type { DeriveAccount, GetAccountParameter } from '../../types/account.js'
|
|
33
33
|
import type { Block } from '../../types/block.js'
|
|
34
|
+
import type { ExtractCapabilities } from '../../types/capabilities.js'
|
|
34
35
|
import type {
|
|
35
36
|
Chain,
|
|
36
37
|
DeriveChain,
|
|
@@ -191,7 +192,12 @@ export type PrepareTransactionRequestReturnType<
|
|
|
191
192
|
: (typeof defaultParameters)[number]
|
|
192
193
|
>
|
|
193
194
|
> &
|
|
194
|
-
(unknown extends request['kzg'] ? {} : Pick<request, 'kzg'>)
|
|
195
|
+
(unknown extends request['kzg'] ? {} : Pick<request, 'kzg'>) & {
|
|
196
|
+
// TODO(v3): Extract `prepareTransactionRequest` response into a named object of `{ capabilities, request }.
|
|
197
|
+
_capabilities?:
|
|
198
|
+
| ExtractCapabilities<'fillTransaction', 'ReturnType'>
|
|
199
|
+
| undefined
|
|
200
|
+
}
|
|
195
201
|
>
|
|
196
202
|
|
|
197
203
|
export type PrepareTransactionRequestErrorType =
|
|
@@ -426,6 +432,9 @@ export async function prepareTransactionRequest<
|
|
|
426
432
|
rest.feePayerSignature !== null
|
|
427
433
|
? { feePayerSignature: rest.feePayerSignature }
|
|
428
434
|
: {}),
|
|
435
|
+
...(result.capabilities
|
|
436
|
+
? { _capabilities: result.capabilities }
|
|
437
|
+
: {}),
|
|
429
438
|
}
|
|
430
439
|
})
|
|
431
440
|
.catch((e) => {
|
|
@@ -336,9 +336,12 @@ export async function sendTransaction<
|
|
|
336
336
|
} as any)
|
|
337
337
|
|
|
338
338
|
const serializer = chain?.serializers?.transaction
|
|
339
|
-
const serializedTransaction = (await account.signTransaction(
|
|
340
|
-
|
|
341
|
-
|
|
339
|
+
const serializedTransaction = (await account.signTransaction(
|
|
340
|
+
request as never,
|
|
341
|
+
{
|
|
342
|
+
serializer,
|
|
343
|
+
},
|
|
344
|
+
)) as Hash
|
|
342
345
|
return await getAction(
|
|
343
346
|
client,
|
|
344
347
|
sendRawTransaction,
|
|
@@ -375,9 +375,12 @@ export async function sendTransactionSync<
|
|
|
375
375
|
} as any)
|
|
376
376
|
|
|
377
377
|
const serializer = chain?.serializers?.transaction
|
|
378
|
-
const serializedTransaction = (await account.signTransaction(
|
|
379
|
-
|
|
380
|
-
|
|
378
|
+
const serializedTransaction = (await account.signTransaction(
|
|
379
|
+
request as never,
|
|
380
|
+
{
|
|
381
|
+
serializer,
|
|
382
|
+
},
|
|
383
|
+
)) as Hash
|
|
381
384
|
return (await getAction(
|
|
382
385
|
client,
|
|
383
386
|
sendRawTransactionSync,
|
package/errors/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.47.
|
|
1
|
+
export const version = '2.47.15'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "viem",
|
|
3
3
|
"description": "TypeScript Interface for Ethereum",
|
|
4
|
-
"version": "2.47.
|
|
4
|
+
"version": "2.47.15",
|
|
5
5
|
"main": "./_cjs/index.js",
|
|
6
6
|
"module": "./_esm/index.js",
|
|
7
7
|
"types": "./_types/index.d.ts",
|
|
@@ -217,7 +217,7 @@
|
|
|
217
217
|
"@scure/bip39": "1.6.0",
|
|
218
218
|
"abitype": "1.2.3",
|
|
219
219
|
"isows": "1.0.7",
|
|
220
|
-
"ox": "0.14.
|
|
220
|
+
"ox": "0.14.15",
|
|
221
221
|
"ws": "8.18.3"
|
|
222
222
|
},
|
|
223
223
|
"license": "MIT",
|
package/tempo/Capabilities.ts
CHANGED
|
@@ -1,9 +1,61 @@
|
|
|
1
|
+
import type { Address } from 'abitype'
|
|
1
2
|
import type { DefaultCapabilitiesSchema } from '../types/capabilities.js'
|
|
3
|
+
import type { Hex } from '../types/misc.js'
|
|
2
4
|
import type { ExactPartial } from '../types/utils.js'
|
|
3
5
|
import type { TransactionRequestTempo } from './Transaction.js'
|
|
4
6
|
|
|
5
7
|
export type Schema = Omit<DefaultCapabilitiesSchema, 'sendCalls'> & {
|
|
8
|
+
fillTransaction: {
|
|
9
|
+
ReturnType: FillTransactionCapabilities
|
|
10
|
+
}
|
|
6
11
|
sendCalls: {
|
|
7
12
|
Request: ExactPartial<TransactionRequestTempo>
|
|
8
13
|
}
|
|
9
14
|
}
|
|
15
|
+
|
|
16
|
+
export type FillTransactionCapabilities = {
|
|
17
|
+
autoSwap?:
|
|
18
|
+
| {
|
|
19
|
+
maxIn: SwapAmount
|
|
20
|
+
minOut: SwapAmount
|
|
21
|
+
slippage: number
|
|
22
|
+
}
|
|
23
|
+
| undefined
|
|
24
|
+
balanceDiffs?: Readonly<Record<Address, readonly BalanceDiff[]>> | undefined
|
|
25
|
+
fee?:
|
|
26
|
+
| {
|
|
27
|
+
amount: Hex
|
|
28
|
+
decimals: number
|
|
29
|
+
formatted: string
|
|
30
|
+
symbol: string
|
|
31
|
+
}
|
|
32
|
+
| undefined
|
|
33
|
+
sponsor?:
|
|
34
|
+
| {
|
|
35
|
+
address: Address
|
|
36
|
+
name?: string | undefined
|
|
37
|
+
url?: string | undefined
|
|
38
|
+
}
|
|
39
|
+
| undefined
|
|
40
|
+
sponsored?: boolean | undefined
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export type BalanceDiff = {
|
|
44
|
+
address: Address
|
|
45
|
+
decimals: number
|
|
46
|
+
direction: 'incoming' | 'outgoing'
|
|
47
|
+
formatted: string
|
|
48
|
+
name: string
|
|
49
|
+
recipients: readonly Address[]
|
|
50
|
+
symbol: string
|
|
51
|
+
value: Hex
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type SwapAmount = {
|
|
55
|
+
decimals: number
|
|
56
|
+
formatted: string
|
|
57
|
+
name: string
|
|
58
|
+
symbol: string
|
|
59
|
+
token: Address
|
|
60
|
+
value: Hex
|
|
61
|
+
}
|
package/tempo/Decorator.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Address } from 'abitype'
|
|
1
2
|
import type { Account } from '../accounts/types.js'
|
|
2
3
|
import type { Client } from '../clients/createClient.js'
|
|
3
4
|
import type { Transport } from '../clients/transports/createTransport.js'
|
|
@@ -10,6 +11,7 @@ import * as feeActions from './actions/fee.js'
|
|
|
10
11
|
import * as nonceActions from './actions/nonce.js'
|
|
11
12
|
import * as policyActions from './actions/policy.js'
|
|
12
13
|
import * as rewardActions from './actions/reward.js'
|
|
14
|
+
import * as simulateActions from './actions/simulate.js'
|
|
13
15
|
import * as tokenActions from './actions/token.js'
|
|
14
16
|
import * as validatorActions from './actions/validator.js'
|
|
15
17
|
|
|
@@ -2136,6 +2138,90 @@ export type Decorator<
|
|
|
2136
2138
|
parameters: rewardActions.watchRewardRecipientSet.Parameters,
|
|
2137
2139
|
) => () => void
|
|
2138
2140
|
}
|
|
2141
|
+
simulate: {
|
|
2142
|
+
/**
|
|
2143
|
+
* Simulates a set of calls on block(s) via `tempo_simulateV1`.
|
|
2144
|
+
*
|
|
2145
|
+
* @example
|
|
2146
|
+
* ```ts
|
|
2147
|
+
* import { createClient, http, parseUnits } from 'viem'
|
|
2148
|
+
* import { tempo } from 'viem/chains'
|
|
2149
|
+
* import { Actions, tempoActions } from 'viem/tempo'
|
|
2150
|
+
*
|
|
2151
|
+
* const client = createClient({
|
|
2152
|
+
* account: '0x...',
|
|
2153
|
+
* chain: tempo,
|
|
2154
|
+
* transport: http(),
|
|
2155
|
+
* }).extend(tempoActions())
|
|
2156
|
+
*
|
|
2157
|
+
* const { blocks, tokenMetadata } = await client.simulate.simulateBlocks({
|
|
2158
|
+
* blocks: [{
|
|
2159
|
+
* calls: [
|
|
2160
|
+
* Actions.token.transfer.call({
|
|
2161
|
+
* token: '0x20c0...01',
|
|
2162
|
+
* to: '0x...',
|
|
2163
|
+
* amount: parseUnits('100', 6),
|
|
2164
|
+
* }),
|
|
2165
|
+
* ],
|
|
2166
|
+
* }],
|
|
2167
|
+
* traceTransfers: true,
|
|
2168
|
+
* })
|
|
2169
|
+
* ```
|
|
2170
|
+
*
|
|
2171
|
+
* @param parameters - Parameters.
|
|
2172
|
+
* @returns Simulated blocks and token metadata.
|
|
2173
|
+
*/
|
|
2174
|
+
simulateBlocks: <const calls extends readonly unknown[]>(
|
|
2175
|
+
parameters: simulateActions.simulateBlocks.Parameters<calls>,
|
|
2176
|
+
) => Promise<simulateActions.simulateBlocks.ReturnType<calls>>
|
|
2177
|
+
/**
|
|
2178
|
+
* Simulates execution of a batch of calls via `tempo_simulateV1`.
|
|
2179
|
+
*
|
|
2180
|
+
* @example
|
|
2181
|
+
* ```ts
|
|
2182
|
+
* import { createClient, http, parseUnits } from 'viem'
|
|
2183
|
+
* import { tempo } from 'viem/chains'
|
|
2184
|
+
* import { Actions, Addresses, tempoActions } from 'viem/tempo'
|
|
2185
|
+
*
|
|
2186
|
+
* const client = createClient({
|
|
2187
|
+
* account: '0x...',
|
|
2188
|
+
* chain: tempo,
|
|
2189
|
+
* transport: http(),
|
|
2190
|
+
* }).extend(tempoActions())
|
|
2191
|
+
*
|
|
2192
|
+
* const { results, tokenMetadata } = await client.simulate.simulateCalls({
|
|
2193
|
+
* calls: [
|
|
2194
|
+
* Actions.token.approve.call({
|
|
2195
|
+
* token: '0x20c0...01',
|
|
2196
|
+
* spender: Addresses.stablecoinDex,
|
|
2197
|
+
* amount: parseUnits('100', 6),
|
|
2198
|
+
* }),
|
|
2199
|
+
* Actions.dex.buy.call({
|
|
2200
|
+
* tokenIn: '0x20c0...01',
|
|
2201
|
+
* tokenOut: '0x20c0...02',
|
|
2202
|
+
* amountOut: parseUnits('10', 6),
|
|
2203
|
+
* maxAmountIn: parseUnits('100', 6),
|
|
2204
|
+
* }),
|
|
2205
|
+
* Actions.token.transfer.call({
|
|
2206
|
+
* token: '0x20c0...02',
|
|
2207
|
+
* to: '0x...',
|
|
2208
|
+
* amount: parseUnits('10', 6),
|
|
2209
|
+
* }),
|
|
2210
|
+
* ],
|
|
2211
|
+
* traceTransfers: true,
|
|
2212
|
+
* })
|
|
2213
|
+
* ```
|
|
2214
|
+
*
|
|
2215
|
+
* @param parameters - Parameters.
|
|
2216
|
+
* @returns Results, block, and token metadata.
|
|
2217
|
+
*/
|
|
2218
|
+
simulateCalls: <
|
|
2219
|
+
const calls extends readonly unknown[],
|
|
2220
|
+
account extends Account | Address | undefined = undefined,
|
|
2221
|
+
>(
|
|
2222
|
+
parameters: simulateActions.simulateCalls.Parameters<calls, account>,
|
|
2223
|
+
) => Promise<simulateActions.simulateCalls.ReturnType<calls>>
|
|
2224
|
+
}
|
|
2139
2225
|
token: {
|
|
2140
2226
|
/**
|
|
2141
2227
|
* Approves a spender to transfer TIP20 tokens on behalf of the caller.
|
|
@@ -3866,6 +3952,12 @@ export function decorator() {
|
|
|
3866
3952
|
watchRewardRecipientSet: (parameters) =>
|
|
3867
3953
|
rewardActions.watchRewardRecipientSet(client, parameters),
|
|
3868
3954
|
},
|
|
3955
|
+
simulate: {
|
|
3956
|
+
simulateBlocks: (parameters) =>
|
|
3957
|
+
simulateActions.simulateBlocks(client, parameters),
|
|
3958
|
+
simulateCalls: (parameters) =>
|
|
3959
|
+
simulateActions.simulateCalls(client, parameters),
|
|
3960
|
+
},
|
|
3869
3961
|
token: {
|
|
3870
3962
|
approve: (parameters) => tokenActions.approve(client, parameters),
|
|
3871
3963
|
approveSync: (parameters) =>
|
package/tempo/Formatters.ts
CHANGED
package/tempo/actions/index.ts
CHANGED
|
@@ -7,5 +7,6 @@ export * as fee from './fee.js'
|
|
|
7
7
|
export * as nonce from './nonce.js'
|
|
8
8
|
export * as policy from './policy.js'
|
|
9
9
|
export * as reward from './reward.js'
|
|
10
|
+
export * as simulate from './simulate.js'
|
|
10
11
|
export * as token from './token.js'
|
|
11
12
|
export * as validator from './validator.js'
|