viem 2.21.33 → 2.21.35
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +26 -0
- package/_cjs/actions/public/waitForTransactionReceipt.js +94 -91
- package/_cjs/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_cjs/chains/definitions/base.js +5 -0
- package/_cjs/chains/definitions/base.js.map +1 -1
- package/_cjs/chains/definitions/genesys.js +24 -0
- package/_cjs/chains/definitions/genesys.js.map +1 -0
- package/_cjs/chains/definitions/iota.js +6 -0
- package/_cjs/chains/definitions/iota.js.map +1 -1
- package/_cjs/chains/definitions/unichainSepolia.js +18 -0
- package/_cjs/chains/definitions/unichainSepolia.js.map +1 -1
- package/_cjs/chains/definitions/velas.js +22 -0
- package/_cjs/chains/definitions/velas.js.map +1 -0
- package/_cjs/chains/definitions/worldchain.js +38 -1
- package/_cjs/chains/definitions/worldchain.js.map +1 -1
- package/_cjs/chains/definitions/worldchainSepolia.js +37 -1
- package/_cjs/chains/definitions/worldchainSepolia.js.map +1 -1
- package/_cjs/chains/definitions/xdc.js +5 -5
- package/_cjs/chains/definitions/xdc.js.map +1 -1
- package/_cjs/chains/index.js +11 -7
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/typedData.js +10 -1
- package/_cjs/errors/typedData.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js +5 -4
- package/_cjs/index.js.map +1 -1
- package/_cjs/linea/actions/estimateGas.js +1 -4
- package/_cjs/linea/actions/estimateGas.js.map +1 -1
- package/_cjs/op-stack/chains.js +7 -1
- package/_cjs/op-stack/chains.js.map +1 -1
- package/_cjs/utils/promise/createBatchScheduler.js +8 -11
- package/_cjs/utils/promise/createBatchScheduler.js.map +1 -1
- package/_cjs/utils/promise/withResolvers.js +13 -0
- package/_cjs/utils/promise/withResolvers.js.map +1 -0
- package/_cjs/utils/typedData.js +6 -2
- package/_cjs/utils/typedData.js.map +1 -1
- package/_esm/actions/public/waitForTransactionReceipt.js +109 -106
- package/_esm/actions/public/waitForTransactionReceipt.js.map +1 -1
- package/_esm/chains/definitions/base.js +5 -0
- package/_esm/chains/definitions/base.js.map +1 -1
- package/_esm/chains/definitions/genesys.js +21 -0
- package/_esm/chains/definitions/genesys.js.map +1 -0
- package/_esm/chains/definitions/iota.js +6 -0
- package/_esm/chains/definitions/iota.js.map +1 -1
- package/_esm/chains/definitions/unichainSepolia.js +18 -0
- package/_esm/chains/definitions/unichainSepolia.js.map +1 -1
- package/_esm/chains/definitions/velas.js +19 -0
- package/_esm/chains/definitions/velas.js.map +1 -0
- package/_esm/chains/definitions/worldchain.js +38 -1
- package/_esm/chains/definitions/worldchain.js.map +1 -1
- package/_esm/chains/definitions/worldchainSepolia.js +37 -1
- package/_esm/chains/definitions/worldchainSepolia.js.map +1 -1
- package/_esm/chains/definitions/xdc.js +5 -5
- package/_esm/chains/definitions/xdc.js.map +1 -1
- package/_esm/chains/index.js +2 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/typedData.js +8 -0
- package/_esm/errors/typedData.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/index.js +1 -1
- package/_esm/index.js.map +1 -1
- package/_esm/linea/actions/estimateGas.js +1 -4
- package/_esm/linea/actions/estimateGas.js.map +1 -1
- package/_esm/op-stack/chains.js +3 -0
- package/_esm/op-stack/chains.js.map +1 -1
- package/_esm/utils/promise/createBatchScheduler.js +8 -11
- package/_esm/utils/promise/createBatchScheduler.js.map +1 -1
- package/_esm/utils/promise/withResolvers.js +11 -0
- package/_esm/utils/promise/withResolvers.js.map +1 -0
- package/_esm/utils/typedData.js +7 -3
- package/_esm/utils/typedData.js.map +1 -1
- package/_types/actions/public/waitForTransactionReceipt.d.ts.map +1 -1
- package/_types/chains/definitions/base.d.ts +5 -0
- package/_types/chains/definitions/base.d.ts.map +1 -1
- package/_types/chains/definitions/genesys.d.ts +37 -0
- package/_types/chains/definitions/genesys.d.ts.map +1 -0
- package/_types/chains/definitions/iota.d.ts +6 -10
- package/_types/chains/definitions/iota.d.ts.map +1 -1
- package/_types/chains/definitions/unichainSepolia.d.ts +267 -2
- package/_types/chains/definitions/unichainSepolia.d.ts.map +1 -1
- package/_types/chains/definitions/velas.d.ts +37 -0
- package/_types/chains/definitions/velas.d.ts.map +1 -0
- package/_types/chains/definitions/worldchain.d.ts +286 -14
- package/_types/chains/definitions/worldchain.d.ts.map +1 -1
- package/_types/chains/definitions/worldchainSepolia.d.ts +285 -14
- package/_types/chains/definitions/worldchainSepolia.d.ts.map +1 -1
- package/_types/chains/definitions/xdc.d.ts +5 -5
- package/_types/chains/index.d.ts +2 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/typedData.d.ts +10 -0
- package/_types/errors/typedData.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/index.d.ts +1 -1
- package/_types/index.d.ts.map +1 -1
- package/_types/linea/actions/estimateGas.d.ts.map +1 -1
- package/_types/op-stack/chains.d.ts +3 -0
- package/_types/op-stack/chains.d.ts.map +1 -1
- package/_types/utils/promise/createBatchScheduler.d.ts.map +1 -1
- package/_types/utils/promise/withResolvers.d.ts +9 -0
- package/_types/utils/promise/withResolvers.d.ts.map +1 -0
- package/_types/utils/typedData.d.ts.map +1 -1
- package/actions/public/waitForTransactionReceipt.ts +162 -156
- package/chains/definitions/base.ts +5 -0
- package/chains/definitions/genesys.ts +21 -0
- package/chains/definitions/iota.ts +6 -0
- package/chains/definitions/unichainSepolia.ts +18 -0
- package/chains/definitions/velas.ts +19 -0
- package/chains/definitions/worldchain.ts +39 -1
- package/chains/definitions/worldchainSepolia.ts +38 -1
- package/chains/definitions/xdc.ts +5 -5
- package/chains/index.ts +2 -0
- package/errors/typedData.ts +20 -0
- package/errors/version.ts +1 -1
- package/index.ts +2 -0
- package/linea/actions/estimateGas.ts +1 -11
- package/op-stack/chains.ts +3 -0
- package/package.json +1 -1
- package/utils/promise/createBatchScheduler.ts +12 -16
- package/utils/promise/withResolvers.ts +19 -0
- package/utils/typedData.ts +8 -2
package/chains/index.ts
CHANGED
@@ -151,6 +151,7 @@ export { fuseSparknet } from './definitions/fuseSparknet.js'
|
|
151
151
|
export { fusion } from './definitions/fusion.js'
|
152
152
|
export { fusionTestnet } from './definitions/fusionTestnet.js'
|
153
153
|
export { garnet } from './definitions/garnet.js'
|
154
|
+
export { genesys } from './definitions/genesys.js'
|
154
155
|
export { gnosis } from './definitions/gnosis.js'
|
155
156
|
export { gnosisChiado } from './definitions/gnosisChiado.js'
|
156
157
|
export { gobi } from './definitions/gobi.js'
|
@@ -378,6 +379,7 @@ export { uniqueOpal } from './definitions/uniqueOpal.js'
|
|
378
379
|
export { uniqueQuartz } from './definitions/uniqueQuartz.js'
|
379
380
|
export { unreal } from './definitions/unreal.js'
|
380
381
|
export { vechain } from './definitions/vechain.js'
|
382
|
+
export { velas } from './definitions/velas.js'
|
381
383
|
export { viction } from './definitions/viction.js'
|
382
384
|
export { victionTestnet } from './definitions/victionTestnet.js'
|
383
385
|
export { vision } from './definitions/vision.js'
|
package/errors/typedData.ts
CHANGED
@@ -1,5 +1,25 @@
|
|
1
|
+
import type { TypedData } from 'abitype'
|
2
|
+
|
1
3
|
import { BaseError } from './base.js'
|
2
4
|
|
5
|
+
export type InvalidPrimaryTypeErrorType = InvalidPrimaryTypeError & {
|
6
|
+
name: 'InvalidPrimaryTypeError'
|
7
|
+
}
|
8
|
+
export class InvalidPrimaryTypeError extends BaseError {
|
9
|
+
constructor({
|
10
|
+
primaryType,
|
11
|
+
types,
|
12
|
+
}: { primaryType: string; types: TypedData | Record<string, unknown> }) {
|
13
|
+
super(
|
14
|
+
`Invalid primary type \`${primaryType}\` must be one of \`${JSON.stringify(Object.keys(types))}\`.`,
|
15
|
+
{
|
16
|
+
docsPath: '/api/glossary/Errors#typeddatainvalidprimarytypeerror',
|
17
|
+
metaMessages: ['Check that the primary type is a key in `types`.'],
|
18
|
+
},
|
19
|
+
)
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
3
23
|
export type InvalidStructTypeErrorType = InvalidStructTypeError & {
|
4
24
|
name: 'InvalidStructTypeError'
|
5
25
|
}
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.21.
|
1
|
+
export const version = '2.21.35'
|
package/index.ts
CHANGED
@@ -918,6 +918,8 @@ export {
|
|
918
918
|
type StateAssignmentConflictErrorType,
|
919
919
|
} from './errors/stateOverride.js'
|
920
920
|
export {
|
921
|
+
type InvalidPrimaryTypeErrorType,
|
922
|
+
InvalidPrimaryTypeError,
|
921
923
|
type InvalidStructTypeErrorType,
|
922
924
|
InvalidStructTypeError,
|
923
925
|
} from './errors/typedData.js'
|
@@ -1,10 +1,6 @@
|
|
1
1
|
import type { Account } from '../../accounts/types.js'
|
2
2
|
import { parseAccount } from '../../accounts/utils/parseAccount.js'
|
3
3
|
import type { EstimateGasParameters as EstimateGasParameters_base } from '../../actions/public/estimateGas.js'
|
4
|
-
import {
|
5
|
-
type PrepareTransactionRequestParameters,
|
6
|
-
prepareTransactionRequest,
|
7
|
-
} from '../../actions/wallet/prepareTransactionRequest.js'
|
8
4
|
import type { Client } from '../../clients/createClient.js'
|
9
5
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
10
6
|
import { AccountNotFoundError } from '../../errors/account.js'
|
@@ -82,13 +78,7 @@ export async function estimateGas<
|
|
82
78
|
to,
|
83
79
|
value,
|
84
80
|
...rest
|
85
|
-
} =
|
86
|
-
account?.type === 'local'
|
87
|
-
? ((await prepareTransactionRequest(
|
88
|
-
client,
|
89
|
-
args as PrepareTransactionRequestParameters,
|
90
|
-
)) as EstimateGasParameters)
|
91
|
-
: args
|
81
|
+
} = args
|
92
82
|
|
93
83
|
const blockNumberHex = blockNumber ? numberToHex(blockNumber) : undefined
|
94
84
|
const block = blockNumberHex || blockTag
|
package/op-stack/chains.ts
CHANGED
@@ -16,6 +16,9 @@ export { shape } from '../chains/definitions/shape.js'
|
|
16
16
|
export { snax } from '../chains/definitions/snax.js'
|
17
17
|
export { snaxTestnet } from '../chains/definitions/snaxTestnet.js'
|
18
18
|
export { soneiumMinato } from '../chains/definitions/soneiumMinato.js'
|
19
|
+
export { unichainSepolia } from '../chains/definitions/unichainSepolia.js'
|
20
|
+
export { worldchain } from '../chains/definitions/worldchain.js'
|
21
|
+
export { worldchainSepolia } from '../chains/definitions/worldchainSepolia.js'
|
19
22
|
export { zora } from '../chains/definitions/zora.js'
|
20
23
|
export { zoraSepolia } from '../chains/definitions/zoraSepolia.js'
|
21
24
|
export { zoraTestnet } from '../chains/definitions/zoraTestnet.js'
|
package/package.json
CHANGED
@@ -1,17 +1,17 @@
|
|
1
1
|
import type { ErrorType } from '../../errors/utils.js'
|
2
|
+
import { type PromiseWithResolvers, withResolvers } from './withResolvers.js'
|
2
3
|
|
3
4
|
type Resolved<returnType extends readonly unknown[] = any> = [
|
4
5
|
result: returnType[number],
|
5
6
|
results: returnType,
|
6
7
|
]
|
7
8
|
|
8
|
-
type
|
9
|
-
|
10
|
-
|
9
|
+
type SchedulerItem = {
|
10
|
+
args: unknown
|
11
|
+
resolve: PromiseWithResolvers<unknown>['resolve']
|
12
|
+
reject: PromiseWithResolvers<unknown>['reject']
|
11
13
|
}
|
12
14
|
|
13
|
-
type SchedulerItem = { args: unknown; pendingPromise: PendingPromise }
|
14
|
-
|
15
15
|
type BatchResultsCompareFn<result = unknown> = (a: result, b: result) => number
|
16
16
|
|
17
17
|
type CreateBatchSchedulerArguments<
|
@@ -65,14 +65,14 @@ export function createBatchScheduler<
|
|
65
65
|
.then((data) => {
|
66
66
|
if (sort && Array.isArray(data)) data.sort(sort)
|
67
67
|
for (let i = 0; i < scheduler.length; i++) {
|
68
|
-
const {
|
69
|
-
|
68
|
+
const { resolve } = scheduler[i]
|
69
|
+
resolve?.([data[i], data])
|
70
70
|
}
|
71
71
|
})
|
72
72
|
.catch((err) => {
|
73
73
|
for (let i = 0; i < scheduler.length; i++) {
|
74
|
-
const {
|
75
|
-
|
74
|
+
const { reject } = scheduler[i]
|
75
|
+
reject?.(err)
|
76
76
|
}
|
77
77
|
})
|
78
78
|
}
|
@@ -90,11 +90,7 @@ export function createBatchScheduler<
|
|
90
90
|
return {
|
91
91
|
flush,
|
92
92
|
async schedule(args: parameters) {
|
93
|
-
const
|
94
|
-
const promise = new Promise<Resolved<returnType>>((resolve, reject) => {
|
95
|
-
pendingPromise.resolve = resolve
|
96
|
-
pendingPromise.reject = reject
|
97
|
-
})
|
93
|
+
const { promise, resolve, reject } = withResolvers()
|
98
94
|
|
99
95
|
const split = shouldSplitBatch?.([...getBatchedArgs(), args])
|
100
96
|
|
@@ -102,11 +98,11 @@ export function createBatchScheduler<
|
|
102
98
|
|
103
99
|
const hasActiveScheduler = getScheduler().length > 0
|
104
100
|
if (hasActiveScheduler) {
|
105
|
-
setScheduler({ args,
|
101
|
+
setScheduler({ args, resolve, reject })
|
106
102
|
return promise
|
107
103
|
}
|
108
104
|
|
109
|
-
setScheduler({ args,
|
105
|
+
setScheduler({ args, resolve, reject })
|
110
106
|
setTimeout(exec, wait)
|
111
107
|
return promise
|
112
108
|
},
|
@@ -0,0 +1,19 @@
|
|
1
|
+
/** @internal */
|
2
|
+
export type PromiseWithResolvers<type> = {
|
3
|
+
promise: Promise<type>
|
4
|
+
resolve: (value: type | PromiseLike<type>) => void
|
5
|
+
reject: (reason?: unknown) => void
|
6
|
+
}
|
7
|
+
|
8
|
+
/** @internal */
|
9
|
+
export function withResolvers<type>(): PromiseWithResolvers<type> {
|
10
|
+
let resolve: PromiseWithResolvers<type>['resolve'] = () => undefined
|
11
|
+
let reject: PromiseWithResolvers<type>['reject'] = () => undefined
|
12
|
+
|
13
|
+
const promise = new Promise<type>((resolve_, reject_) => {
|
14
|
+
resolve = resolve_
|
15
|
+
reject = reject_
|
16
|
+
})
|
17
|
+
|
18
|
+
return { promise, resolve, reject }
|
19
|
+
}
|
package/utils/typedData.ts
CHANGED
@@ -2,7 +2,10 @@ import type { TypedData, TypedDataDomain, TypedDataParameter } from 'abitype'
|
|
2
2
|
|
3
3
|
import { BytesSizeMismatchError } from '../errors/abi.js'
|
4
4
|
import { InvalidAddressError } from '../errors/address.js'
|
5
|
-
import {
|
5
|
+
import {
|
6
|
+
InvalidPrimaryTypeError,
|
7
|
+
InvalidStructTypeError,
|
8
|
+
} from '../errors/typedData.js'
|
6
9
|
import type { ErrorType } from '../errors/utils.js'
|
7
10
|
import type { Hex } from '../types/misc.js'
|
8
11
|
import type { TypedDataDefinition } from '../types/typedData.js'
|
@@ -121,7 +124,10 @@ export function validateTypedData<
|
|
121
124
|
if (types.EIP712Domain && domain) validateData(types.EIP712Domain, domain)
|
122
125
|
|
123
126
|
// Validate message types.
|
124
|
-
if (primaryType !== 'EIP712Domain')
|
127
|
+
if (primaryType !== 'EIP712Domain') {
|
128
|
+
if (types[primaryType]) validateData(types[primaryType], message)
|
129
|
+
else throw new InvalidPrimaryTypeError({ primaryType, types })
|
130
|
+
}
|
125
131
|
}
|
126
132
|
|
127
133
|
export type GetTypesForEIP712DomainErrorType = ErrorType
|