viem 2.38.1 → 2.38.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 +24 -0
- package/_cjs/actions/wallet/sendRawTransactionSync.js +6 -2
- package/_cjs/actions/wallet/sendRawTransactionSync.js.map +1 -1
- package/_cjs/actions/wallet/sendTransactionSync.js +7 -2
- package/_cjs/actions/wallet/sendTransactionSync.js.map +1 -1
- package/_cjs/actions/wallet/writeContractSync.js.map +1 -1
- package/_cjs/chains/definitions/kiiTestnet.js +27 -0
- package/_cjs/chains/definitions/kiiTestnet.js.map +1 -0
- package/_cjs/chains/definitions/linea.js +1 -0
- package/_cjs/chains/definitions/linea.js.map +1 -1
- package/_cjs/chains/definitions/plasma.js +1 -0
- package/_cjs/chains/definitions/plasma.js.map +1 -1
- package/_cjs/chains/definitions/polygon.js +1 -0
- package/_cjs/chains/definitions/polygon.js.map +1 -1
- package/_cjs/chains/definitions/scroll.js +1 -0
- package/_cjs/chains/definitions/scroll.js.map +1 -1
- package/_cjs/chains/definitions/surgeTestnet.js +23 -0
- package/_cjs/chains/definitions/surgeTestnet.js.map +1 -0
- package/_cjs/chains/definitions/swanProximaTestnet.js +1 -1
- package/_cjs/chains/definitions/swanProximaTestnet.js.map +1 -1
- package/_cjs/chains/definitions/vana.js +31 -0
- package/_cjs/chains/definitions/vana.js.map +1 -0
- package/_cjs/chains/definitions/vanaMoksha.js +32 -0
- package/_cjs/chains/definitions/vanaMoksha.js.map +1 -0
- package/_cjs/chains/index.js +15 -7
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/transaction.js +23 -1
- package/_cjs/errors/transaction.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_esm/actions/wallet/sendRawTransactionSync.js +6 -2
- package/_esm/actions/wallet/sendRawTransactionSync.js.map +1 -1
- package/_esm/actions/wallet/sendTransactionSync.js +7 -2
- package/_esm/actions/wallet/sendTransactionSync.js.map +1 -1
- package/_esm/actions/wallet/writeContractSync.js.map +1 -1
- package/_esm/chains/definitions/kiiTestnet.js +24 -0
- package/_esm/chains/definitions/kiiTestnet.js.map +1 -0
- package/_esm/chains/definitions/linea.js +1 -0
- package/_esm/chains/definitions/linea.js.map +1 -1
- package/_esm/chains/definitions/plasma.js +1 -0
- package/_esm/chains/definitions/plasma.js.map +1 -1
- package/_esm/chains/definitions/polygon.js +1 -0
- package/_esm/chains/definitions/polygon.js.map +1 -1
- package/_esm/chains/definitions/scroll.js +1 -0
- package/_esm/chains/definitions/scroll.js.map +1 -1
- package/_esm/chains/definitions/surgeTestnet.js +20 -0
- package/_esm/chains/definitions/surgeTestnet.js.map +1 -0
- package/_esm/chains/definitions/swanProximaTestnet.js +1 -1
- package/_esm/chains/definitions/swanProximaTestnet.js.map +1 -1
- package/_esm/chains/definitions/vana.js +28 -0
- package/_esm/chains/definitions/vana.js.map +1 -0
- package/_esm/chains/definitions/vanaMoksha.js +29 -0
- package/_esm/chains/definitions/vanaMoksha.js.map +1 -0
- package/_esm/chains/index.js +4 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/transaction.js +21 -0
- package/_esm/errors/transaction.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_types/actions/wallet/sendRawTransactionSync.d.ts +3 -1
- package/_types/actions/wallet/sendRawTransactionSync.d.ts.map +1 -1
- package/_types/actions/wallet/sendTransactionSync.d.ts +4 -1
- package/_types/actions/wallet/sendTransactionSync.d.ts.map +1 -1
- package/_types/actions/wallet/writeContractSync.d.ts +1 -1
- package/_types/actions/wallet/writeContractSync.d.ts.map +1 -1
- package/_types/chains/definitions/kiiTestnet.d.ts +40 -0
- package/_types/chains/definitions/kiiTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/linea.d.ts +1 -1
- package/_types/chains/definitions/linea.d.ts.map +1 -1
- package/_types/chains/definitions/plasma.d.ts +1 -1
- package/_types/chains/definitions/plasma.d.ts.map +1 -1
- package/_types/chains/definitions/polygon.d.ts +1 -1
- package/_types/chains/definitions/polygon.d.ts.map +1 -1
- package/_types/chains/definitions/scroll.d.ts +1 -1
- package/_types/chains/definitions/scroll.d.ts.map +1 -1
- package/_types/chains/definitions/surgeTestnet.d.ts +40 -0
- package/_types/chains/definitions/surgeTestnet.d.ts.map +1 -0
- package/_types/chains/definitions/swanProximaTestnet.d.ts +1 -1
- package/_types/chains/definitions/vana.d.ts +37 -0
- package/_types/chains/definitions/vana.d.ts.map +1 -0
- package/_types/chains/definitions/vanaMoksha.d.ts +37 -0
- package/_types/chains/definitions/vanaMoksha.d.ts.map +1 -0
- package/_types/chains/index.d.ts +4 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/transaction.d.ts +10 -1
- package/_types/errors/transaction.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/types/calls.d.ts +2 -1
- package/_types/types/calls.d.ts.map +1 -1
- package/actions/wallet/sendRawTransactionSync.ts +13 -2
- package/actions/wallet/sendTransactionSync.ts +13 -1
- package/actions/wallet/writeContractSync.ts +4 -1
- package/chains/definitions/kiiTestnet.ts +24 -0
- package/chains/definitions/linea.ts +1 -0
- package/chains/definitions/plasma.ts +1 -0
- package/chains/definitions/polygon.ts +1 -0
- package/chains/definitions/scroll.ts +1 -0
- package/chains/definitions/surgeTestnet.ts +20 -0
- package/chains/definitions/swanProximaTestnet.ts +1 -1
- package/chains/definitions/vana.ts +28 -0
- package/chains/definitions/vanaMoksha.ts +29 -0
- package/chains/index.ts +4 -0
- package/errors/transaction.ts +27 -1
- package/errors/version.ts +1 -1
- package/package.json +1 -1
- package/types/calls.ts +2 -1
|
@@ -15,6 +15,10 @@ import {
|
|
|
15
15
|
type AccountTypeNotSupportedErrorType,
|
|
16
16
|
} from '../../errors/account.js'
|
|
17
17
|
import { BaseError } from '../../errors/base.js'
|
|
18
|
+
import {
|
|
19
|
+
TransactionReceiptRevertedError,
|
|
20
|
+
type TransactionReceiptRevertedErrorType,
|
|
21
|
+
} from '../../errors/transaction.js'
|
|
18
22
|
import type { ErrorType } from '../../errors/utils.js'
|
|
19
23
|
import type { GetAccountParameter } from '../../types/account.js'
|
|
20
24
|
import type {
|
|
@@ -91,6 +95,8 @@ export type SendTransactionSyncParameters<
|
|
|
91
95
|
GetTransactionRequestKzgParameter<request> & {
|
|
92
96
|
/** Polling interval (ms) to poll for the transaction receipt. @default client.pollingInterval */
|
|
93
97
|
pollingInterval?: number | undefined
|
|
98
|
+
/** Whether to throw an error if the transaction was detected as reverted. @default true */
|
|
99
|
+
throwOnReceiptRevert?: boolean | undefined
|
|
94
100
|
/** Timeout (ms) to wait for a response. @default Math.max(chain.blockTime * 3, 5_000) */
|
|
95
101
|
timeout?: number | undefined
|
|
96
102
|
}
|
|
@@ -111,6 +117,7 @@ export type SendTransactionSyncErrorType =
|
|
|
111
117
|
| SendRawTransactionSyncErrorType
|
|
112
118
|
| RecoverAuthorizationAddressErrorType
|
|
113
119
|
| SignTransactionErrorType
|
|
120
|
+
| TransactionReceiptRevertedErrorType
|
|
114
121
|
| RequestErrorType
|
|
115
122
|
>
|
|
116
123
|
| WaitForTransactionReceiptErrorType
|
|
@@ -184,6 +191,7 @@ export async function sendTransactionSync<
|
|
|
184
191
|
maxPriorityFeePerGas,
|
|
185
192
|
nonce,
|
|
186
193
|
pollingInterval,
|
|
194
|
+
throwOnReceiptRevert,
|
|
187
195
|
type,
|
|
188
196
|
value,
|
|
189
197
|
...rest
|
|
@@ -314,7 +322,7 @@ export async function sendTransactionSync<
|
|
|
314
322
|
}
|
|
315
323
|
})()
|
|
316
324
|
|
|
317
|
-
|
|
325
|
+
const receipt = await getAction(
|
|
318
326
|
client,
|
|
319
327
|
waitForTransactionReceipt,
|
|
320
328
|
'waitForTransactionReceipt',
|
|
@@ -324,6 +332,9 @@ export async function sendTransactionSync<
|
|
|
324
332
|
pollingInterval,
|
|
325
333
|
timeout,
|
|
326
334
|
})
|
|
335
|
+
if (throwOnReceiptRevert && receipt.status === 'reverted')
|
|
336
|
+
throw new TransactionReceiptRevertedError({ receipt })
|
|
337
|
+
return receipt
|
|
327
338
|
}
|
|
328
339
|
|
|
329
340
|
if (account?.type === 'local') {
|
|
@@ -363,6 +374,7 @@ export async function sendTransactionSync<
|
|
|
363
374
|
'sendRawTransactionSync',
|
|
364
375
|
)({
|
|
365
376
|
serializedTransaction,
|
|
377
|
+
throwOnReceiptRevert,
|
|
366
378
|
})) as never
|
|
367
379
|
}
|
|
368
380
|
|
|
@@ -39,7 +39,10 @@ export type WriteContractSyncParameters<
|
|
|
39
39
|
account,
|
|
40
40
|
chainOverride
|
|
41
41
|
> &
|
|
42
|
-
Pick<
|
|
42
|
+
Pick<
|
|
43
|
+
SendTransactionSyncParameters<chain>,
|
|
44
|
+
'pollingInterval' | 'throwOnReceiptRevert' | 'timeout'
|
|
45
|
+
>
|
|
43
46
|
|
|
44
47
|
export type WriteContractSyncReturnType<
|
|
45
48
|
chain extends Chain | undefined = Chain | undefined,
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
|
2
|
+
|
|
3
|
+
export const kiiTestnetOro = /*#__PURE__*/ defineChain({
|
|
4
|
+
id: 1336,
|
|
5
|
+
name: 'Kii Testnet Oro',
|
|
6
|
+
network: 'kii-testnet-oro',
|
|
7
|
+
nativeCurrency: {
|
|
8
|
+
name: 'Kii',
|
|
9
|
+
symbol: 'KII',
|
|
10
|
+
decimals: 18,
|
|
11
|
+
},
|
|
12
|
+
rpcUrls: {
|
|
13
|
+
default: {
|
|
14
|
+
http: ['https://json-rpc.uno.sentry.testnet.v3.kiivalidator.com'],
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
blockExplorers: {
|
|
18
|
+
default: {
|
|
19
|
+
name: 'KiiExplorer',
|
|
20
|
+
url: 'https://explorer.kiichain.io/testnet',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
testnet: true,
|
|
24
|
+
})
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
|
2
|
+
|
|
3
|
+
export const surgeTestnet = /*#__PURE__*/ defineChain({
|
|
4
|
+
id: 763_375,
|
|
5
|
+
name: 'Surge Testnet',
|
|
6
|
+
nativeCurrency: { name: 'Ether', symbol: 'ETH', decimals: 18 },
|
|
7
|
+
rpcUrls: {
|
|
8
|
+
default: {
|
|
9
|
+
http: ['https://l2-rpc.hoodi.surge.wtf'],
|
|
10
|
+
webSocket: ['wss://l2-ws.hoodi.surge.wtf'],
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
blockExplorers: {
|
|
14
|
+
default: {
|
|
15
|
+
name: 'Surge Testnet Blockscout',
|
|
16
|
+
url: 'https://explorer.hoodi.surge.wtf',
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
testnet: true,
|
|
20
|
+
})
|
|
@@ -5,7 +5,7 @@ export const swanProximaTestnet = /*#__PURE__*/ defineChain({
|
|
|
5
5
|
name: 'Swan Proxima Testnet',
|
|
6
6
|
nativeCurrency: { name: 'Swan Ether', symbol: 'sETH', decimals: 18 },
|
|
7
7
|
rpcUrls: {
|
|
8
|
-
default: { http: ['https://rpc-proxima.swanchain.io
|
|
8
|
+
default: { http: ['https://rpc-proxima.swanchain.io'] },
|
|
9
9
|
},
|
|
10
10
|
blockExplorers: {
|
|
11
11
|
default: {
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
|
2
|
+
|
|
3
|
+
export const vana = /*#__PURE__*/ defineChain({
|
|
4
|
+
id: 1480,
|
|
5
|
+
name: 'Vana',
|
|
6
|
+
blockTime: 6_000,
|
|
7
|
+
nativeCurrency: {
|
|
8
|
+
decimals: 18,
|
|
9
|
+
name: 'Vana',
|
|
10
|
+
symbol: 'VANA',
|
|
11
|
+
},
|
|
12
|
+
rpcUrls: {
|
|
13
|
+
default: { http: ['https://rpc.vana.org/'] },
|
|
14
|
+
},
|
|
15
|
+
blockExplorers: {
|
|
16
|
+
default: {
|
|
17
|
+
name: 'Vana Block Explorer',
|
|
18
|
+
url: 'https://vanascan.io',
|
|
19
|
+
apiUrl: 'https://vanascan.io/api',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
contracts: {
|
|
23
|
+
multicall3: {
|
|
24
|
+
address: '0xD8d2dFca27E8797fd779F8547166A2d3B29d360E',
|
|
25
|
+
blockCreated: 716763,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
})
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
|
2
|
+
|
|
3
|
+
export const vanaMoksha = /*#__PURE__*/ defineChain({
|
|
4
|
+
id: 14800,
|
|
5
|
+
name: 'Vana Moksha Testnet',
|
|
6
|
+
blockTime: 6_000,
|
|
7
|
+
nativeCurrency: {
|
|
8
|
+
decimals: 18,
|
|
9
|
+
name: 'Vana',
|
|
10
|
+
symbol: 'VANA',
|
|
11
|
+
},
|
|
12
|
+
rpcUrls: {
|
|
13
|
+
default: { http: ['https://rpc.moksha.vana.org'] },
|
|
14
|
+
},
|
|
15
|
+
blockExplorers: {
|
|
16
|
+
default: {
|
|
17
|
+
name: 'Vana Moksha Testnet',
|
|
18
|
+
url: 'https://moksha.vanascan.io',
|
|
19
|
+
apiUrl: 'https://moksha.vanascan.io/api',
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
contracts: {
|
|
23
|
+
multicall3: {
|
|
24
|
+
address: '0xD8d2dFca27E8797fd779F8547166A2d3B29d360E',
|
|
25
|
+
blockCreated: 732283,
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
testnet: true,
|
|
29
|
+
})
|
package/chains/index.ts
CHANGED
|
@@ -311,6 +311,7 @@ export { katana } from './definitions/katana.js'
|
|
|
311
311
|
export { kava } from './definitions/kava.js'
|
|
312
312
|
export { kavaTestnet } from './definitions/kavaTestnet.js'
|
|
313
313
|
export { kcc } from './definitions/kcc.js'
|
|
314
|
+
export { kiiTestnetOro } from './definitions/kiiTestnet.js'
|
|
314
315
|
export { kinto } from './definitions/kinto.js'
|
|
315
316
|
/** @deprecated Use `kaia` instead. */
|
|
316
317
|
export { klaytn } from './definitions/klaytn.js'
|
|
@@ -560,6 +561,7 @@ export { superlumio } from './definitions/superlumio.js'
|
|
|
560
561
|
export { superposition } from './definitions/superposition.js'
|
|
561
562
|
export { superseed } from './definitions/superseed.js'
|
|
562
563
|
export { superseedSepolia } from './definitions/superseedSepolia.js'
|
|
564
|
+
export { surgeTestnet } from './definitions/surgeTestnet.js'
|
|
563
565
|
export { swan } from './definitions/swan.js'
|
|
564
566
|
export { swanProximaTestnet } from './definitions/swanProximaTestnet.js'
|
|
565
567
|
export { swanSaturnTestnet } from './definitions/swanSaturnTestnet.js'
|
|
@@ -607,6 +609,8 @@ export { unique } from './definitions/unique.js'
|
|
|
607
609
|
export { uniqueOpal } from './definitions/uniqueOpal.js'
|
|
608
610
|
export { uniqueQuartz } from './definitions/uniqueQuartz.js'
|
|
609
611
|
export { unreal } from './definitions/unreal.js'
|
|
612
|
+
export { vana } from './definitions/vana.js'
|
|
613
|
+
export { vanaMoksha } from './definitions/vanaMoksha.js'
|
|
610
614
|
export { vanar } from './definitions/vanar.js'
|
|
611
615
|
export { vechain } from './definitions/vechain.js'
|
|
612
616
|
export { velas } from './definitions/velas.js'
|
package/errors/transaction.ts
CHANGED
|
@@ -3,7 +3,10 @@ import type { SendTransactionParameters } from '../actions/wallet/sendTransactio
|
|
|
3
3
|
import type { BlockTag } from '../types/block.js'
|
|
4
4
|
import type { Chain } from '../types/chain.js'
|
|
5
5
|
import type { Hash, Hex } from '../types/misc.js'
|
|
6
|
-
import type {
|
|
6
|
+
import type {
|
|
7
|
+
TransactionReceipt,
|
|
8
|
+
TransactionType,
|
|
9
|
+
} from '../types/transaction.js'
|
|
7
10
|
import { formatEther } from '../utils/unit/formatEther.js'
|
|
8
11
|
import { formatGwei } from '../utils/unit/formatGwei.js'
|
|
9
12
|
|
|
@@ -245,6 +248,29 @@ export class TransactionReceiptNotFoundError extends BaseError {
|
|
|
245
248
|
}
|
|
246
249
|
}
|
|
247
250
|
|
|
251
|
+
export type TransactionReceiptRevertedErrorType =
|
|
252
|
+
TransactionReceiptRevertedError & {
|
|
253
|
+
name: 'TransactionReceiptRevertedError'
|
|
254
|
+
}
|
|
255
|
+
export class TransactionReceiptRevertedError extends BaseError {
|
|
256
|
+
receipt: TransactionReceipt
|
|
257
|
+
|
|
258
|
+
constructor({ receipt }: { receipt: TransactionReceipt }) {
|
|
259
|
+
super(`Transaction with hash "${receipt.transactionHash}" reverted.`, {
|
|
260
|
+
metaMessages: [
|
|
261
|
+
'The receipt marked the transaction as "reverted". This could mean that the function on the contract you are trying to call threw an error.',
|
|
262
|
+
' ',
|
|
263
|
+
'You can attempt to extract the revert reason by:',
|
|
264
|
+
'- calling the `simulateContract` or `simulateCalls` Action with the `abi` and `functionName` of the contract',
|
|
265
|
+
'- using the `call` Action with raw `data`',
|
|
266
|
+
],
|
|
267
|
+
name: 'TransactionReceiptRevertedError',
|
|
268
|
+
})
|
|
269
|
+
|
|
270
|
+
this.receipt = receipt
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
|
|
248
274
|
export type WaitForTransactionReceiptTimeoutErrorType =
|
|
249
275
|
WaitForTransactionReceiptTimeoutError & {
|
|
250
276
|
name: 'WaitForTransactionReceiptTimeoutError'
|
package/errors/version.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = '2.38.
|
|
1
|
+
export const version = '2.38.3'
|
package/package.json
CHANGED
package/types/calls.ts
CHANGED
|
@@ -21,9 +21,10 @@ export type Call<
|
|
|
21
21
|
GetMulticallContractParameters<call, AbiStateMutability>,
|
|
22
22
|
'address'
|
|
23
23
|
> & {
|
|
24
|
+
data?: Hex | undefined
|
|
25
|
+
dataSuffix?: Hex | undefined
|
|
24
26
|
to: Address
|
|
25
27
|
value?: bigint | undefined
|
|
26
|
-
dataSuffix?: Hex | undefined
|
|
27
28
|
},
|
|
28
29
|
extraProperties
|
|
29
30
|
>
|