viem 2.19.6 → 2.19.7
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 +14 -0
- package/_cjs/actions/wallet/writeContract.js +27 -6
- package/_cjs/actions/wallet/writeContract.js.map +1 -1
- package/_cjs/chains/definitions/b3.js +27 -0
- package/_cjs/chains/definitions/b3.js.map +1 -0
- package/_cjs/chains/definitions/b3Sepolia.js +1 -1
- package/_cjs/chains/definitions/b3Sepolia.js.map +1 -1
- package/_cjs/chains/definitions/cronoszkEVM.js +23 -0
- package/_cjs/chains/definitions/cronoszkEVM.js.map +1 -0
- package/_cjs/chains/definitions/immutableZkEvm.js +1 -0
- package/_cjs/chains/definitions/immutableZkEvm.js.map +1 -1
- package/_cjs/chains/index.js +11 -7
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/experimental/eip7702/utils/hashAuthorization.js +1 -5
- package/_cjs/experimental/eip7702/utils/hashAuthorization.js.map +1 -1
- package/_cjs/experimental/eip7702/utils/serializeAuthorizationList.js +1 -1
- package/_cjs/experimental/eip7702/utils/serializeAuthorizationList.js.map +1 -1
- package/_cjs/index.js.map +1 -1
- package/_esm/actions/wallet/writeContract.js +27 -6
- package/_esm/actions/wallet/writeContract.js.map +1 -1
- package/_esm/chains/definitions/b3.js +24 -0
- package/_esm/chains/definitions/b3.js.map +1 -0
- package/_esm/chains/definitions/b3Sepolia.js +1 -1
- package/_esm/chains/definitions/b3Sepolia.js.map +1 -1
- package/_esm/chains/definitions/cronoszkEVM.js +20 -0
- package/_esm/chains/definitions/cronoszkEVM.js.map +1 -0
- package/_esm/chains/definitions/immutableZkEvm.js +1 -0
- package/_esm/chains/definitions/immutableZkEvm.js.map +1 -1
- package/_esm/chains/index.js +2 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/experimental/eip7702/utils/hashAuthorization.js +1 -5
- package/_esm/experimental/eip7702/utils/hashAuthorization.js.map +1 -1
- package/_esm/experimental/eip7702/utils/serializeAuthorizationList.js +1 -1
- package/_esm/experimental/eip7702/utils/serializeAuthorizationList.js.map +1 -1
- package/_esm/index.js.map +1 -1
- package/_types/actions/wallet/writeContract.d.ts +4 -1
- package/_types/actions/wallet/writeContract.d.ts.map +1 -1
- package/_types/chains/definitions/b3.d.ts +35 -0
- package/_types/chains/definitions/b3.d.ts.map +1 -0
- package/_types/chains/definitions/b3Sepolia.d.ts +1 -1
- package/_types/chains/definitions/cronoszkEVM.d.ts +35 -0
- package/_types/chains/definitions/cronoszkEVM.d.ts.map +1 -0
- package/_types/chains/definitions/immutableZkEvm.d.ts +1 -0
- package/_types/chains/definitions/immutableZkEvm.d.ts.map +1 -1
- package/_types/chains/index.d.ts +2 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/experimental/eip7702/utils/hashAuthorization.d.ts.map +1 -1
- package/_types/index.d.ts +1 -1
- package/_types/index.d.ts.map +1 -1
- package/actions/wallet/writeContract.ts +54 -12
- package/chains/definitions/b3.ts +25 -0
- package/chains/definitions/b3Sepolia.ts +1 -1
- package/chains/definitions/cronoszkEVM.ts +20 -0
- package/chains/definitions/immutableZkEvm.ts +1 -0
- package/chains/index.ts +2 -0
- package/errors/version.ts +1 -1
- package/experimental/eip7702/utils/hashAuthorization.ts +1 -5
- package/experimental/eip7702/utils/serializeAuthorizationList.ts +1 -1
- package/index.ts +1 -0
- package/package.json +1 -1
@@ -1,8 +1,17 @@
|
|
1
1
|
import type { Abi } from 'abitype'
|
2
2
|
|
3
3
|
import type { Account } from '../../accounts/types.js'
|
4
|
+
import {
|
5
|
+
type ParseAccountErrorType,
|
6
|
+
parseAccount,
|
7
|
+
} from '../../accounts/utils/parseAccount.js'
|
4
8
|
import type { Client } from '../../clients/createClient.js'
|
5
9
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
10
|
+
import {
|
11
|
+
AccountNotFoundError,
|
12
|
+
type AccountNotFoundErrorType,
|
13
|
+
} from '../../errors/account.js'
|
14
|
+
import type { BaseError } from '../../errors/base.js'
|
6
15
|
import type { ErrorType } from '../../errors/utils.js'
|
7
16
|
import type { GetAccountParameter } from '../../types/account.js'
|
8
17
|
import type {
|
@@ -22,6 +31,10 @@ import {
|
|
22
31
|
type EncodeFunctionDataParameters,
|
23
32
|
encodeFunctionData,
|
24
33
|
} from '../../utils/abi/encodeFunctionData.js'
|
34
|
+
import {
|
35
|
+
type GetContractErrorReturnType,
|
36
|
+
getContractError,
|
37
|
+
} from '../../utils/errors/getContractError.js'
|
25
38
|
import type { FormattedTransactionRequest } from '../../utils/formatters/transactionRequest.js'
|
26
39
|
import { getAction } from '../../utils/getAction.js'
|
27
40
|
import type { GetMutabilityAwareValue } from '../public/simulateContract.js'
|
@@ -81,7 +94,9 @@ export type WriteContractReturnType = SendTransactionReturnType
|
|
81
94
|
|
82
95
|
export type WriteContractErrorType =
|
83
96
|
| EncodeFunctionDataErrorType
|
84
|
-
|
|
97
|
+
| AccountNotFoundErrorType
|
98
|
+
| ParseAccountErrorType
|
99
|
+
| GetContractErrorReturnType<SendTransactionErrorType>
|
85
100
|
| ErrorType
|
86
101
|
|
87
102
|
/**
|
@@ -156,20 +171,47 @@ export async function writeContract<
|
|
156
171
|
chainOverride
|
157
172
|
>,
|
158
173
|
): Promise<WriteContractReturnType> {
|
159
|
-
const {
|
160
|
-
|
174
|
+
const {
|
175
|
+
abi,
|
176
|
+
account: account_ = client.account,
|
177
|
+
address,
|
178
|
+
args,
|
179
|
+
dataSuffix,
|
180
|
+
functionName,
|
181
|
+
...request
|
182
|
+
} = parameters as WriteContractParameters
|
183
|
+
|
184
|
+
if (!account_)
|
185
|
+
throw new AccountNotFoundError({
|
186
|
+
docsPath: '/docs/contract/writeContract',
|
187
|
+
})
|
188
|
+
const account = parseAccount(account_)
|
189
|
+
|
161
190
|
const data = encodeFunctionData({
|
162
191
|
abi,
|
163
192
|
args,
|
164
193
|
functionName,
|
165
194
|
} as EncodeFunctionDataParameters)
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
195
|
+
|
196
|
+
try {
|
197
|
+
return await getAction(
|
198
|
+
client,
|
199
|
+
sendTransaction,
|
200
|
+
'sendTransaction',
|
201
|
+
)({
|
202
|
+
data: `${data}${dataSuffix ? dataSuffix.replace('0x', '') : ''}`,
|
203
|
+
to: address,
|
204
|
+
account,
|
205
|
+
...request,
|
206
|
+
})
|
207
|
+
} catch (error) {
|
208
|
+
throw getContractError(error as BaseError, {
|
209
|
+
abi,
|
210
|
+
address,
|
211
|
+
args,
|
212
|
+
docsPath: '/docs/contract/writeContract',
|
213
|
+
functionName,
|
214
|
+
sender: account.address,
|
215
|
+
})
|
216
|
+
}
|
175
217
|
}
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
const sourceId = 8453 // base
|
4
|
+
|
5
|
+
export const b3 = /*#__PURE__*/ defineChain({
|
6
|
+
id: 8333,
|
7
|
+
name: 'B3',
|
8
|
+
nativeCurrency: {
|
9
|
+
name: 'Ether',
|
10
|
+
symbol: 'ETH',
|
11
|
+
decimals: 18,
|
12
|
+
},
|
13
|
+
rpcUrls: {
|
14
|
+
default: {
|
15
|
+
http: ['https://mainnet-rpc.b3.fun/http'],
|
16
|
+
},
|
17
|
+
},
|
18
|
+
blockExplorers: {
|
19
|
+
default: {
|
20
|
+
name: 'Blockscout',
|
21
|
+
url: 'https://explorer.b3.fun',
|
22
|
+
},
|
23
|
+
},
|
24
|
+
sourceId,
|
25
|
+
})
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const cronoszkEVM = /*#__PURE__*/ defineChain({
|
4
|
+
id: 388,
|
5
|
+
name: 'Cronos zkEVM Mainnet',
|
6
|
+
nativeCurrency: {
|
7
|
+
decimals: 18,
|
8
|
+
name: 'Cronos zkEVM CRO',
|
9
|
+
symbol: 'zkCRO',
|
10
|
+
},
|
11
|
+
rpcUrls: {
|
12
|
+
default: { http: ['https://mainnet.zkevm.cronos.org'] },
|
13
|
+
},
|
14
|
+
blockExplorers: {
|
15
|
+
default: {
|
16
|
+
name: 'Cronos zkEVM (Mainnet) Chain Explorer',
|
17
|
+
url: 'https://explorer.zkevm.cronos.org',
|
18
|
+
},
|
19
|
+
},
|
20
|
+
})
|
package/chains/index.ts
CHANGED
@@ -25,6 +25,7 @@ export { auroria } from './definitions/auroria.js'
|
|
25
25
|
export { avalanche } from './definitions/avalanche.js'
|
26
26
|
export { avalancheFuji } from './definitions/avalancheFuji.js'
|
27
27
|
export { b3Sepolia } from './definitions/b3Sepolia.js'
|
28
|
+
export { b3 } from './definitions/b3.js'
|
28
29
|
export { bahamut } from './definitions/bahamut.js'
|
29
30
|
export { base } from './definitions/base.js'
|
30
31
|
export { baseGoerli } from './definitions/baseGoerli.js'
|
@@ -66,6 +67,7 @@ export { confluxESpaceTestnet } from './definitions/confluxESpaceTestnet.js'
|
|
66
67
|
export { coreDao } from './definitions/coreDao.js'
|
67
68
|
export { crab } from './definitions/crab.js'
|
68
69
|
export { cronos } from './definitions/cronos.js'
|
70
|
+
export { cronoszkEVM } from './definitions/cronoszkEVM.js'
|
69
71
|
export { cronoszkEVMTestnet } from './definitions/cronoszkEVMTestnet.js'
|
70
72
|
export { cronosTestnet } from './definitions/cronosTestnet.js'
|
71
73
|
export { crossbell } from './definitions/crossbell.js'
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.19.
|
1
|
+
export const version = '2.19.7'
|
@@ -48,11 +48,7 @@ export function hashAuthorization<to extends To = 'hex'>(
|
|
48
48
|
const hash = keccak256(
|
49
49
|
concatHex([
|
50
50
|
'0x05',
|
51
|
-
toRlp([
|
52
|
-
numberToHex(chainId),
|
53
|
-
contractAddress,
|
54
|
-
[nonce ? numberToHex(nonce) : '0x'],
|
55
|
-
]),
|
51
|
+
toRlp([numberToHex(chainId), contractAddress, numberToHex(nonce)]),
|
56
52
|
]),
|
57
53
|
)
|
58
54
|
if (to === 'bytes') return hexToBytes(hash) as HashAuthorizationReturnType<to>
|
package/index.ts
CHANGED