viem 2.21.27 → 2.21.29
Sign up to get free protection for your applications and to get access to all the features.
- package/CHANGELOG.md +20 -0
- package/_cjs/account-abstraction/utils/errors/getUserOperationError.js +1 -1
- package/_cjs/account-abstraction/utils/errors/getUserOperationError.js.map +1 -1
- package/_cjs/actions/wallet/sendTransaction.js +35 -11
- package/_cjs/actions/wallet/sendTransaction.js.map +1 -1
- package/_cjs/actions/wallet/writeContract.js +3 -3
- package/_cjs/actions/wallet/writeContract.js.map +1 -1
- package/_cjs/chains/definitions/bifrost.js +22 -0
- package/_cjs/chains/definitions/bifrost.js.map +1 -0
- package/_cjs/chains/definitions/dymension.js +27 -0
- package/_cjs/chains/definitions/dymension.js.map +1 -0
- package/_cjs/chains/definitions/kakarotStarknetSepolia.js +1 -1
- package/_cjs/chains/definitions/kakarotStarknetSepolia.js.map +1 -1
- package/_cjs/chains/index.js +13 -9
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/errors/base.js +1 -1
- package/_cjs/errors/base.js.map +1 -1
- package/_cjs/errors/rpc.js +1 -1
- package/_cjs/errors/rpc.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/experimental/eip5792/actions/getCapabilities.js +2 -3
- package/_cjs/experimental/eip5792/actions/getCapabilities.js.map +1 -1
- package/_cjs/experimental/eip5792/decorators/eip5792.js.map +1 -1
- package/_cjs/op-stack/actions/proveWithdrawal.js +1 -1
- package/_cjs/op-stack/actions/proveWithdrawal.js.map +1 -1
- package/_cjs/utils/abi/encodeEventTopics.js +1 -1
- package/_cjs/utils/abi/encodeEventTopics.js.map +1 -1
- package/_cjs/utils/ccip.js +2 -0
- package/_cjs/utils/ccip.js.map +1 -1
- package/_cjs/utils/encoding/toHex.js +1 -3
- package/_cjs/utils/encoding/toHex.js.map +1 -1
- package/_esm/account-abstraction/utils/errors/getUserOperationError.js +1 -1
- package/_esm/account-abstraction/utils/errors/getUserOperationError.js.map +1 -1
- package/_esm/actions/wallet/sendTransaction.js +37 -11
- package/_esm/actions/wallet/sendTransaction.js.map +1 -1
- package/_esm/actions/wallet/writeContract.js +3 -3
- package/_esm/actions/wallet/writeContract.js.map +1 -1
- package/_esm/chains/definitions/bifrost.js +19 -0
- package/_esm/chains/definitions/bifrost.js.map +1 -0
- package/_esm/chains/definitions/dymension.js +24 -0
- package/_esm/chains/definitions/dymension.js.map +1 -0
- package/_esm/chains/definitions/kakarotStarknetSepolia.js +1 -1
- package/_esm/chains/definitions/kakarotStarknetSepolia.js.map +1 -1
- package/_esm/chains/index.js +3 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/errors/base.js +1 -1
- package/_esm/errors/base.js.map +1 -1
- package/_esm/errors/rpc.js +1 -1
- package/_esm/errors/rpc.js.map +1 -1
- package/_esm/errors/version.js +1 -1
- package/_esm/experimental/eip5792/actions/getCapabilities.js +2 -3
- package/_esm/experimental/eip5792/actions/getCapabilities.js.map +1 -1
- package/_esm/experimental/eip5792/decorators/eip5792.js.map +1 -1
- package/_esm/op-stack/actions/proveWithdrawal.js +1 -1
- package/_esm/op-stack/actions/proveWithdrawal.js.map +1 -1
- package/_esm/utils/abi/encodeEventTopics.js +1 -1
- package/_esm/utils/abi/encodeEventTopics.js.map +1 -1
- package/_esm/utils/ccip.js +2 -0
- package/_esm/utils/ccip.js.map +1 -1
- package/_esm/utils/encoding/toHex.js +1 -3
- package/_esm/utils/encoding/toHex.js.map +1 -1
- package/_types/actions/wallet/prepareTransactionRequest.d.ts +1 -1
- package/_types/actions/wallet/prepareTransactionRequest.d.ts.map +1 -1
- package/_types/actions/wallet/sendTransaction.d.ts +2 -1
- package/_types/actions/wallet/sendTransaction.d.ts.map +1 -1
- package/_types/actions/wallet/writeContract.d.ts +2 -2
- package/_types/actions/wallet/writeContract.d.ts.map +1 -1
- package/_types/chains/definitions/bifrost.d.ts +37 -0
- package/_types/chains/definitions/bifrost.d.ts.map +1 -0
- package/_types/chains/definitions/dymension.d.ts +38 -0
- package/_types/chains/definitions/dymension.d.ts.map +1 -0
- package/_types/chains/definitions/kakarotStarknetSepolia.d.ts +1 -1
- package/_types/chains/definitions/kakarotStarknetSepolia.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/transaction.d.ts +1 -1
- package/_types/errors/transaction.d.ts.map +1 -1
- package/_types/errors/version.d.ts +1 -1
- package/_types/experimental/eip5792/actions/getCapabilities.d.ts +6 -9
- package/_types/experimental/eip5792/actions/getCapabilities.d.ts.map +1 -1
- package/_types/experimental/eip5792/decorators/eip5792.d.ts +1 -1
- package/_types/experimental/eip5792/decorators/eip5792.d.ts.map +1 -1
- package/_types/types/account.d.ts +4 -8
- package/_types/types/account.d.ts.map +1 -1
- package/_types/utils/ccip.d.ts.map +1 -1
- package/_types/utils/encoding/toHex.d.ts.map +1 -1
- package/_types/utils/errors/getTransactionError.d.ts +1 -1
- package/_types/utils/errors/getTransactionError.d.ts.map +1 -1
- package/account-abstraction/utils/errors/getUserOperationError.ts +1 -1
- package/actions/wallet/prepareTransactionRequest.ts +1 -1
- package/actions/wallet/sendTransaction.ts +50 -15
- package/actions/wallet/writeContract.ts +5 -5
- package/chains/definitions/bifrost.ts +19 -0
- package/chains/definitions/dymension.ts +24 -0
- package/chains/definitions/kakarotStarknetSepolia.ts +1 -1
- package/chains/index.ts +3 -0
- package/errors/base.ts +1 -1
- package/errors/rpc.ts +1 -1
- package/errors/transaction.ts +1 -1
- package/errors/version.ts +1 -1
- package/experimental/eip5792/actions/getCapabilities.ts +10 -21
- package/experimental/eip5792/decorators/eip5792.ts +1 -3
- package/op-stack/actions/proveWithdrawal.ts +1 -1
- package/package.json +1 -1
- package/types/account.ts +17 -6
- package/utils/abi/encodeEventTopics.ts +1 -1
- package/utils/ccip.ts +3 -0
- package/utils/encoding/toHex.ts +2 -3
- package/utils/errors/getTransactionError.ts +1 -1
@@ -1,3 +1,5 @@
|
|
1
|
+
import type { Address } from 'abitype'
|
2
|
+
|
1
3
|
import type { Account } from '../../accounts/types.js'
|
2
4
|
import {
|
3
5
|
type ParseAccountErrorType,
|
@@ -40,6 +42,7 @@ import {
|
|
40
42
|
formatTransactionRequest,
|
41
43
|
} from '../../utils/formatters/transactionRequest.js'
|
42
44
|
import { getAction } from '../../utils/getAction.js'
|
45
|
+
import { LruMap } from '../../utils/lru.js'
|
43
46
|
import {
|
44
47
|
type AssertRequestErrorType,
|
45
48
|
type AssertRequestParameters,
|
@@ -56,6 +59,8 @@ import {
|
|
56
59
|
sendRawTransaction,
|
57
60
|
} from './sendRawTransaction.js'
|
58
61
|
|
62
|
+
const supportsWalletNamespace = new LruMap<boolean>(128)
|
63
|
+
|
59
64
|
export type SendTransactionRequest<
|
60
65
|
chain extends Chain | undefined = Chain | undefined,
|
61
66
|
chainOverride extends Chain | undefined = Chain | undefined,
|
@@ -73,7 +78,7 @@ export type SendTransactionParameters<
|
|
73
78
|
chainOverride
|
74
79
|
> = SendTransactionRequest<chain, chainOverride>,
|
75
80
|
> = request &
|
76
|
-
GetAccountParameter<account> &
|
81
|
+
GetAccountParameter<account, Account | Address, true, true> &
|
77
82
|
GetChainParameter<chain, chainOverride> &
|
78
83
|
GetTransactionRequestKzgParameter<request>
|
79
84
|
|
@@ -166,11 +171,11 @@ export async function sendTransaction<
|
|
166
171
|
...rest
|
167
172
|
} = parameters
|
168
173
|
|
169
|
-
if (
|
174
|
+
if (typeof account_ === 'undefined')
|
170
175
|
throw new AccountNotFoundError({
|
171
176
|
docsPath: '/docs/actions/wallet/sendTransaction',
|
172
177
|
})
|
173
|
-
const account = parseAccount(account_)
|
178
|
+
const account = account_ ? parseAccount(account_) : null
|
174
179
|
|
175
180
|
try {
|
176
181
|
assertRequest(parameters as AssertRequestParameters)
|
@@ -194,7 +199,7 @@ export async function sendTransaction<
|
|
194
199
|
return undefined
|
195
200
|
})()
|
196
201
|
|
197
|
-
if (account
|
202
|
+
if (account?.type === 'json-rpc' || account === null) {
|
198
203
|
let chainId: number | undefined
|
199
204
|
if (chain !== null) {
|
200
205
|
chainId = await getAction(client, getChainId, 'getChainId')({})
|
@@ -215,7 +220,7 @@ export async function sendTransaction<
|
|
215
220
|
blobs,
|
216
221
|
chainId,
|
217
222
|
data,
|
218
|
-
from: account
|
223
|
+
from: account?.address,
|
219
224
|
gas,
|
220
225
|
gasPrice,
|
221
226
|
maxFeePerBlobGas,
|
@@ -225,16 +230,46 @@ export async function sendTransaction<
|
|
225
230
|
to,
|
226
231
|
value,
|
227
232
|
} as TransactionRequest)
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
233
|
+
|
234
|
+
const method = supportsWalletNamespace.get(client.uid)
|
235
|
+
? 'wallet_sendTransaction'
|
236
|
+
: 'eth_sendTransaction'
|
237
|
+
|
238
|
+
try {
|
239
|
+
return await client.request(
|
240
|
+
{
|
241
|
+
method,
|
242
|
+
params: [request],
|
243
|
+
},
|
244
|
+
{ retryCount: 0 },
|
245
|
+
)
|
246
|
+
} catch (e) {
|
247
|
+
const error = e as BaseError
|
248
|
+
// If the transport does not support the method or input, attempt to use the
|
249
|
+
// `wallet_sendTransaction` method.
|
250
|
+
if (
|
251
|
+
error.name === 'InvalidInputRpcError' ||
|
252
|
+
error.name === 'InvalidParamsRpcError' ||
|
253
|
+
error.name === 'MethodNotFoundRpcError' ||
|
254
|
+
error.name === 'MethodNotSupportedRpcError'
|
255
|
+
)
|
256
|
+
return await client
|
257
|
+
.request(
|
258
|
+
{
|
259
|
+
method: 'wallet_sendTransaction',
|
260
|
+
params: [request],
|
261
|
+
},
|
262
|
+
{ retryCount: 0 },
|
263
|
+
)
|
264
|
+
.then((hash) => {
|
265
|
+
supportsWalletNamespace.set(client.uid, true)
|
266
|
+
return hash
|
267
|
+
})
|
268
|
+
throw error
|
269
|
+
}
|
235
270
|
}
|
236
271
|
|
237
|
-
if (account
|
272
|
+
if (account?.type === 'local') {
|
238
273
|
// Prepare the request for signing (assign appropriate fees, etc.)
|
239
274
|
const request = await getAction(
|
240
275
|
client,
|
@@ -273,7 +308,7 @@ export async function sendTransaction<
|
|
273
308
|
})
|
274
309
|
}
|
275
310
|
|
276
|
-
if (account
|
311
|
+
if (account?.type === 'smart')
|
277
312
|
throw new AccountTypeNotSupportedError({
|
278
313
|
metaMessages: [
|
279
314
|
'Consider using the `sendUserOperation` Action instead.',
|
@@ -284,7 +319,7 @@ export async function sendTransaction<
|
|
284
319
|
|
285
320
|
throw new AccountTypeNotSupportedError({
|
286
321
|
docsPath: '/docs/actions/wallet/sendTransaction',
|
287
|
-
type: (account as
|
322
|
+
type: (account as any)?.type,
|
288
323
|
})
|
289
324
|
} catch (err) {
|
290
325
|
if (err instanceof AccountTypeNotSupportedError) throw err
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import type { Abi } from 'abitype'
|
1
|
+
import type { Abi, Address } from 'abitype'
|
2
2
|
|
3
3
|
import type { Account } from '../../accounts/types.js'
|
4
4
|
import {
|
@@ -71,7 +71,7 @@ export type WriteContractParameters<
|
|
71
71
|
> &
|
72
72
|
GetChainParameter<chain, chainOverride> &
|
73
73
|
Prettify<
|
74
|
-
GetAccountParameter<account> &
|
74
|
+
GetAccountParameter<account, Account | Address, true, true> &
|
75
75
|
GetMutabilityAwareValue<
|
76
76
|
abi,
|
77
77
|
'nonpayable' | 'payable',
|
@@ -181,11 +181,11 @@ export async function writeContract<
|
|
181
181
|
...request
|
182
182
|
} = parameters as WriteContractParameters
|
183
183
|
|
184
|
-
if (
|
184
|
+
if (typeof account_ === 'undefined')
|
185
185
|
throw new AccountNotFoundError({
|
186
186
|
docsPath: '/docs/contract/writeContract',
|
187
187
|
})
|
188
|
-
const account = parseAccount(account_)
|
188
|
+
const account = account_ ? parseAccount(account_) : null
|
189
189
|
|
190
190
|
const data = encodeFunctionData({
|
191
191
|
abi,
|
@@ -211,7 +211,7 @@ export async function writeContract<
|
|
211
211
|
args,
|
212
212
|
docsPath: '/docs/contract/writeContract',
|
213
213
|
functionName,
|
214
|
-
sender: account
|
214
|
+
sender: account?.address,
|
215
215
|
})
|
216
216
|
}
|
217
217
|
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
import { defineChain } from '../../utils/chain/defineChain.js'
|
2
|
+
|
3
|
+
export const bifrost = /*#__PURE__*/ defineChain({
|
4
|
+
id: 3068,
|
5
|
+
name: 'Bifrost Mainnet',
|
6
|
+
nativeCurrency: { name: 'BFC', symbol: 'BFC', decimals: 18 },
|
7
|
+
rpcUrls: {
|
8
|
+
default: {
|
9
|
+
http: ['https://public-01.mainnet.bifrostnetwork.com/rpc'],
|
10
|
+
},
|
11
|
+
},
|
12
|
+
blockExplorers: {
|
13
|
+
default: {
|
14
|
+
name: 'Bifrost Blockscout',
|
15
|
+
url: 'https://explorer.mainnet.bifrostnetwork.com',
|
16
|
+
},
|
17
|
+
},
|
18
|
+
testnet: false,
|
19
|
+
})
|
@@ -0,0 +1,24 @@
|
|
1
|
+
import { defineChain } from '../utils.js'
|
2
|
+
|
3
|
+
export const dymension = /*#__PURE__*/ defineChain({
|
4
|
+
id: 1100,
|
5
|
+
name: 'Dymension',
|
6
|
+
nativeCurrency: {
|
7
|
+
name: 'DYM',
|
8
|
+
symbol: 'DYM',
|
9
|
+
decimals: 18,
|
10
|
+
},
|
11
|
+
rpcUrls: {
|
12
|
+
default: {
|
13
|
+
http: ['https://dymension-evm-rpc.publicnode.com'],
|
14
|
+
webSocket: ['wss://dymension-evm-rpc.publicnode.com'],
|
15
|
+
},
|
16
|
+
},
|
17
|
+
blockExplorers: {
|
18
|
+
default: {
|
19
|
+
name: 'Dym FYI',
|
20
|
+
url: 'https://dym.fyi',
|
21
|
+
},
|
22
|
+
},
|
23
|
+
testnet: false,
|
24
|
+
})
|
package/chains/index.ts
CHANGED
@@ -40,6 +40,7 @@ export { bearNetworkChainTestnet } from './definitions/bearNetworkChainTestnet.j
|
|
40
40
|
export { berachainTestnet } from './definitions/berachainTestnet.js'
|
41
41
|
export { berachainTestnetbArtio } from './definitions/berachainTestnetbArtio.js'
|
42
42
|
export { bevmMainnet } from './definitions/bevmMainnet.js'
|
43
|
+
export { bifrost } from './definitions/bifrost.js'
|
43
44
|
export { bitkub } from './definitions/bitkub.js'
|
44
45
|
export { bitkubTestnet } from './definitions/bitkubTestnet.js'
|
45
46
|
export { bitlayer } from './definitions/bitlayer.js'
|
@@ -99,6 +100,7 @@ export { dosChain } from './definitions/dosChain.js'
|
|
99
100
|
export { dosChainTestnet } from './definitions/dosChainTestnet.js'
|
100
101
|
export { dreyerxMainnet } from './definitions/dreyerxMainnet.js'
|
101
102
|
export { dreyerxTestnet } from './definitions/dreyerxTestnet.js'
|
103
|
+
export { dymension } from './definitions/dymension.js'
|
102
104
|
export { edgeless } from './definitions/edgeless.js'
|
103
105
|
export { edgelessTestnet } from './definitions/edgelessTestnet.js'
|
104
106
|
export { edgeware } from './definitions/edgeware.js'
|
@@ -176,6 +178,7 @@ export { immutableZkEvmTestnet } from './definitions/immutableZkEvmTestnet.js'
|
|
176
178
|
export { inEVM } from './definitions/inEVM.js'
|
177
179
|
export { iota } from './definitions/iota.js'
|
178
180
|
export { iotaTestnet } from './definitions/iotaTestnet.js'
|
181
|
+
/** @deprecated Use `kakarotStarknetSepolia` instead. */
|
179
182
|
export { kakarotSepolia } from './definitions/kakarotSepolia.js'
|
180
183
|
export { kakarotStarknetSepolia } from './definitions/kakarotStarknetSepolia.js'
|
181
184
|
export { kava } from './definitions/kava.js'
|
package/errors/base.ts
CHANGED
package/errors/rpc.ts
CHANGED
@@ -56,7 +56,7 @@ export class RpcError<code_ extends number = RpcErrorCode> extends BaseError {
|
|
56
56
|
})
|
57
57
|
this.name = name || cause.name
|
58
58
|
this.code = (
|
59
|
-
cause instanceof RpcRequestError ? cause.code : code ?? unknownErrorCode
|
59
|
+
cause instanceof RpcRequestError ? cause.code : (code ?? unknownErrorCode)
|
60
60
|
) as code_
|
61
61
|
}
|
62
62
|
}
|
package/errors/transaction.ts
CHANGED
@@ -160,7 +160,7 @@ export class TransactionExecutionError extends BaseError {
|
|
160
160
|
to,
|
161
161
|
value,
|
162
162
|
}: Omit<SendTransactionParameters, 'account' | 'chain'> & {
|
163
|
-
account: Account
|
163
|
+
account: Account | null
|
164
164
|
chain?: Chain | undefined
|
165
165
|
docsPath?: string | undefined
|
166
166
|
},
|
package/errors/version.ts
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export const version = '2.21.
|
1
|
+
export const version = '2.21.29'
|
@@ -1,9 +1,11 @@
|
|
1
|
+
import type { Address } from 'abitype'
|
2
|
+
|
1
3
|
import { parseAccount } from '../../../accounts/utils/parseAccount.js'
|
2
4
|
import type { Client } from '../../../clients/createClient.js'
|
3
5
|
import type { Transport } from '../../../clients/transports/createTransport.js'
|
4
6
|
import { AccountNotFoundError } from '../../../errors/account.js'
|
5
7
|
import type { ErrorType } from '../../../errors/utils.js'
|
6
|
-
import type { Account
|
8
|
+
import type { Account } from '../../../types/account.js'
|
7
9
|
import type { Chain } from '../../../types/chain.js'
|
8
10
|
import type {
|
9
11
|
WalletCapabilities,
|
@@ -12,9 +14,9 @@ import type {
|
|
12
14
|
import type { Prettify } from '../../../types/utils.js'
|
13
15
|
import type { RequestErrorType } from '../../../utils/buildRequest.js'
|
14
16
|
|
15
|
-
export type GetCapabilitiesParameters
|
16
|
-
account
|
17
|
-
|
17
|
+
export type GetCapabilitiesParameters = {
|
18
|
+
account?: Account | Address | undefined
|
19
|
+
}
|
18
20
|
|
19
21
|
export type GetCapabilitiesReturnType = Prettify<
|
20
22
|
WalletCapabilitiesRecord<WalletCapabilities, number>
|
@@ -42,24 +44,11 @@ export type GetCapabilitiesErrorType = RequestErrorType | ErrorType
|
|
42
44
|
* })
|
43
45
|
* const capabilities = await getCapabilities(client)
|
44
46
|
*/
|
45
|
-
export async function getCapabilities<
|
46
|
-
|
47
|
-
|
48
|
-
>(
|
49
|
-
...parameters: account extends Account
|
50
|
-
?
|
51
|
-
| [client: Client<Transport, chain, account>]
|
52
|
-
| [
|
53
|
-
client: Client<Transport, chain, account>,
|
54
|
-
parameters: GetCapabilitiesParameters<account>,
|
55
|
-
]
|
56
|
-
: [
|
57
|
-
client: Client<Transport, chain, account>,
|
58
|
-
parameters: GetCapabilitiesParameters<account>,
|
59
|
-
]
|
47
|
+
export async function getCapabilities<chain extends Chain | undefined>(
|
48
|
+
client: Client<Transport, chain>,
|
49
|
+
parameters: GetCapabilitiesParameters = {},
|
60
50
|
): Promise<GetCapabilitiesReturnType> {
|
61
|
-
const
|
62
|
-
const account_raw = args?.account ?? client.account
|
51
|
+
const account_raw = parameters?.account ?? client.account
|
63
52
|
|
64
53
|
if (!account_raw) throw new AccountNotFoundError()
|
65
54
|
const account = parseAccount(account_raw)
|
@@ -80,9 +80,7 @@ export type Eip5792Actions<
|
|
80
80
|
* })
|
81
81
|
*/
|
82
82
|
getCapabilities: (
|
83
|
-
|
84
|
-
? [] | [parameters: GetCapabilitiesParameters<account>]
|
85
|
-
: [parameters: GetCapabilitiesParameters<undefined>]
|
83
|
+
parameters?: GetCapabilitiesParameters,
|
86
84
|
) => Promise<GetCapabilitiesReturnType>
|
87
85
|
/**
|
88
86
|
* Requests the connected wallet to send a batch of calls.
|
package/package.json
CHANGED
package/types/account.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { Address } from 'abitype'
|
2
2
|
|
3
3
|
import type { Account, JsonRpcAccount } from '../accounts/types.js'
|
4
|
-
import type { IsUndefined, Prettify } from './utils.js'
|
4
|
+
import type { IsUndefined, MaybeRequired, Prettify } from './utils.js'
|
5
5
|
|
6
6
|
export type DeriveAccount<
|
7
7
|
account extends Account | undefined,
|
@@ -12,11 +12,22 @@ export type GetAccountParameter<
|
|
12
12
|
account extends Account | undefined = Account | undefined,
|
13
13
|
accountOverride extends Account | Address | undefined = Account | Address,
|
14
14
|
required extends boolean = true,
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
nullish extends boolean = false,
|
16
|
+
> = MaybeRequired<
|
17
|
+
{
|
18
|
+
account?:
|
19
|
+
| accountOverride
|
20
|
+
| Account
|
21
|
+
| Address
|
22
|
+
| (nullish extends true ? null : never)
|
23
|
+
| undefined
|
24
|
+
},
|
25
|
+
IsUndefined<account> extends true
|
26
|
+
? required extends true
|
27
|
+
? true
|
28
|
+
: false
|
29
|
+
: false
|
30
|
+
>
|
20
31
|
|
21
32
|
export type ParseAccount<
|
22
33
|
accountOrAddress extends Account | Address | undefined =
|
@@ -105,7 +105,7 @@ export function encodeEventTopics<
|
|
105
105
|
const args_ = Array.isArray(args)
|
106
106
|
? args
|
107
107
|
: Object.values(args).length > 0
|
108
|
-
? indexedInputs?.map((x: any) => (args as any)[x.name]) ?? []
|
108
|
+
? (indexedInputs?.map((x: any) => (args as any)[x.name]) ?? [])
|
109
109
|
: []
|
110
110
|
|
111
111
|
if (args_.length > 0) {
|
package/utils/ccip.ts
CHANGED
@@ -136,12 +136,15 @@ export async function ccipRequest({
|
|
136
136
|
const url = urls[i]
|
137
137
|
const method = url.includes('{data}') ? 'GET' : 'POST'
|
138
138
|
const body = method === 'POST' ? { data, sender } : undefined
|
139
|
+
const headers =
|
140
|
+
method === 'POST' ? { 'Content-Type': 'application/json' } : {}
|
139
141
|
|
140
142
|
try {
|
141
143
|
const response = await fetch(
|
142
144
|
url.replace('{sender}', sender).replace('{data}', data),
|
143
145
|
{
|
144
146
|
body: JSON.stringify(body),
|
147
|
+
headers,
|
145
148
|
method,
|
146
149
|
},
|
147
150
|
)
|
package/utils/encoding/toHex.ts
CHANGED
@@ -208,9 +208,8 @@ export function numberToHex(
|
|
208
208
|
})
|
209
209
|
}
|
210
210
|
|
211
|
-
const hex = `0x${(
|
212
|
-
? (1n << BigInt(size * 8)) + BigInt(value)
|
213
|
-
: value
|
211
|
+
const hex = `0x${(
|
212
|
+
signed && value < 0 ? (1n << BigInt(size * 8)) + BigInt(value) : value
|
214
213
|
).toString(16)}` as Hex
|
215
214
|
if (size) return pad(hex, { size }) as Hex
|
216
215
|
return hex
|