viem 1.6.7 → 1.7.0
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/dist/cjs/actions/public/estimateFeesPerGas.js +59 -0
- package/dist/cjs/actions/public/estimateFeesPerGas.js.map +1 -0
- package/dist/cjs/actions/public/estimateMaxPriorityFeePerGas.js +44 -0
- package/dist/cjs/actions/public/estimateMaxPriorityFeePerGas.js.map +1 -0
- package/dist/cjs/actions/public/verifyHash.js.map +1 -1
- package/dist/cjs/actions/public/verifyMessage.js.map +1 -1
- package/dist/cjs/actions/public/verifyTypedData.js.map +1 -1
- package/dist/cjs/actions/wallet/deployContract.js.map +1 -1
- package/dist/cjs/actions/wallet/sendTransaction.js.map +1 -1
- package/dist/cjs/actions/wallet/writeContract.js.map +1 -1
- package/dist/cjs/clients/createTestClient.js.map +1 -1
- package/dist/cjs/clients/decorators/public.js +4 -0
- package/dist/cjs/clients/decorators/public.js.map +1 -1
- package/dist/cjs/errors/fee.js +42 -0
- package/dist/cjs/errors/fee.js.map +1 -0
- package/dist/cjs/errors/version.js +1 -1
- package/dist/cjs/index.js +8 -4
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/public.js +5 -1
- package/dist/cjs/public.js.map +1 -1
- package/dist/cjs/utils/transaction/prepareRequest.js +26 -29
- package/dist/cjs/utils/transaction/prepareRequest.js.map +1 -1
- package/dist/esm/actions/public/estimateFeesPerGas.js +77 -0
- package/dist/esm/actions/public/estimateFeesPerGas.js.map +1 -0
- package/dist/esm/actions/public/estimateMaxPriorityFeePerGas.js +64 -0
- package/dist/esm/actions/public/estimateMaxPriorityFeePerGas.js.map +1 -0
- package/dist/esm/actions/public/verifyHash.js.map +1 -1
- package/dist/esm/actions/public/verifyMessage.js.map +1 -1
- package/dist/esm/actions/public/verifyTypedData.js.map +1 -1
- package/dist/esm/actions/wallet/deployContract.js.map +1 -1
- package/dist/esm/actions/wallet/sendTransaction.js.map +1 -1
- package/dist/esm/actions/wallet/writeContract.js.map +1 -1
- package/dist/esm/clients/createTestClient.js.map +1 -1
- package/dist/esm/clients/decorators/public.js +4 -0
- package/dist/esm/clients/decorators/public.js.map +1 -1
- package/dist/esm/errors/fee.js +36 -0
- package/dist/esm/errors/fee.js.map +1 -0
- package/dist/esm/errors/version.js +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/public.js +2 -0
- package/dist/esm/public.js.map +1 -1
- package/dist/esm/utils/transaction/prepareRequest.js +27 -31
- package/dist/esm/utils/transaction/prepareRequest.js.map +1 -1
- package/dist/types/actions/public/estimateFeesPerGas.d.ts +48 -0
- package/dist/types/actions/public/estimateFeesPerGas.d.ts.map +1 -0
- package/dist/types/actions/public/estimateMaxPriorityFeePerGas.d.ts +35 -0
- package/dist/types/actions/public/estimateMaxPriorityFeePerGas.d.ts.map +1 -0
- package/dist/types/actions/public/verifyHash.d.ts +1 -1
- package/dist/types/actions/public/verifyHash.d.ts.map +1 -1
- package/dist/types/actions/public/verifyMessage.d.ts +2 -2
- package/dist/types/actions/public/verifyMessage.d.ts.map +1 -1
- package/dist/types/actions/public/verifyTypedData.d.ts +2 -2
- package/dist/types/actions/public/verifyTypedData.d.ts.map +1 -1
- package/dist/types/actions/wallet/deployContract.d.ts +2 -1
- package/dist/types/actions/wallet/deployContract.d.ts.map +1 -1
- package/dist/types/actions/wallet/sendTransaction.d.ts +2 -1
- package/dist/types/actions/wallet/sendTransaction.d.ts.map +1 -1
- package/dist/types/actions/wallet/writeContract.d.ts +2 -1
- package/dist/types/actions/wallet/writeContract.d.ts.map +1 -1
- package/dist/types/clients/createTestClient.d.ts +1 -1
- package/dist/types/clients/createTestClient.d.ts.map +1 -1
- package/dist/types/clients/decorators/public.d.ts +46 -0
- package/dist/types/clients/decorators/public.d.ts.map +1 -1
- package/dist/types/errors/fee.d.ts +16 -0
- package/dist/types/errors/fee.d.ts.map +1 -0
- package/dist/types/errors/version.d.ts +1 -1
- package/dist/types/index.d.ts +18 -14
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/public.d.ts +2 -0
- package/dist/types/public.d.ts.map +1 -1
- package/dist/types/types/chain.d.ts +63 -10
- package/dist/types/types/chain.d.ts.map +1 -1
- package/dist/types/types/eip1193.d.ts +12 -0
- package/dist/types/types/eip1193.d.ts.map +1 -1
- package/dist/types/types/fee.d.ts +1 -0
- package/dist/types/types/fee.d.ts.map +1 -1
- package/dist/types/utils/transaction/prepareRequest.d.ts +3 -2
- package/dist/types/utils/transaction/prepareRequest.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/actions/public/estimateFeesPerGas.ts +152 -0
- package/src/actions/public/estimateMaxPriorityFeePerGas.ts +96 -0
- package/src/actions/public/verifyHash.ts +1 -1
- package/src/actions/public/verifyMessage.ts +3 -2
- package/src/actions/public/verifyTypedData.ts +3 -2
- package/src/actions/wallet/deployContract.ts +2 -1
- package/src/actions/wallet/sendTransaction.ts +2 -1
- package/src/actions/wallet/writeContract.ts +2 -1
- package/src/clients/createTestClient.ts +2 -1
- package/src/clients/decorators/public.ts +64 -0
- package/src/errors/fee.ts +27 -0
- package/src/errors/version.ts +1 -1
- package/src/index.ts +38 -24
- package/src/public.ts +10 -0
- package/src/types/chain.ts +80 -12
- package/src/types/eip1193.ts +12 -0
- package/src/types/fee.ts +2 -0
- package/src/utils/transaction/prepareRequest.ts +37 -45
- package/chains/dist/cjs/celo/formatters.js +0 -58
- package/chains/dist/cjs/celo/formatters.js.map +0 -1
- package/chains/dist/cjs/celo/parsers.js +0 -72
- package/chains/dist/cjs/celo/parsers.js.map +0 -1
- package/chains/dist/cjs/celo/serializers.js +0 -75
- package/chains/dist/cjs/celo/serializers.js.map +0 -1
- package/chains/dist/cjs/celo/types.js +0 -3
- package/chains/dist/cjs/celo/types.js.map +0 -1
- package/chains/dist/cjs/index.js +0 -135
- package/chains/dist/cjs/index.js.map +0 -1
- package/chains/dist/cjs/optimism/fees.js +0 -7
- package/chains/dist/cjs/optimism/fees.js.map +0 -1
- package/chains/dist/cjs/optimism/formatters.js +0 -52
- package/chains/dist/cjs/optimism/formatters.js.map +0 -1
- package/chains/dist/cjs/optimism/types.js +0 -3
- package/chains/dist/cjs/optimism/types.js.map +0 -1
- package/chains/dist/cjs/types.js +0 -3
- package/chains/dist/cjs/types.js.map +0 -1
- package/chains/dist/cjs/utils.js +0 -49
- package/chains/dist/cjs/utils.js.map +0 -1
- package/chains/dist/tsconfig.build.tsbuildinfo +0 -1
- package/chains/node_modules/.bin/tsc +0 -17
- package/chains/node_modules/.bin/tsserver +0 -17
- package/chains/tsconfig.tsbuildinfo +0 -1
package/src/index.ts
CHANGED
@@ -64,6 +64,14 @@ export type {
|
|
64
64
|
EstimateGasParameters,
|
65
65
|
EstimateGasReturnType,
|
66
66
|
} from './actions/public/estimateGas.js'
|
67
|
+
export type {
|
68
|
+
EstimateFeesPerGasParameters,
|
69
|
+
EstimateFeesPerGasReturnType,
|
70
|
+
} from './actions/public/estimateFeesPerGas.js'
|
71
|
+
export type {
|
72
|
+
EstimateMaxPriorityFeePerGasParameters,
|
73
|
+
EstimateMaxPriorityFeePerGasReturnType,
|
74
|
+
} from './actions/public/estimateMaxPriorityFeePerGas.js'
|
67
75
|
export type { GetAddressesReturnType } from './actions/wallet/getAddresses.js'
|
68
76
|
export type {
|
69
77
|
GetBalanceParameters,
|
@@ -245,6 +253,29 @@ export type {
|
|
245
253
|
WriteContractParameters,
|
246
254
|
WriteContractReturnType,
|
247
255
|
} from './actions/wallet/writeContract.js'
|
256
|
+
export type {
|
257
|
+
Chain,
|
258
|
+
ChainContract,
|
259
|
+
ChainFees,
|
260
|
+
ChainFormatter,
|
261
|
+
/** @deprecated use `ChainFormatter` instead. */
|
262
|
+
ChainFormatter as Formatter,
|
263
|
+
ChainFormatters,
|
264
|
+
/** @deprecated use `ChainFormatters` instead. */
|
265
|
+
ChainFormatters as Formatters,
|
266
|
+
ChainSerializers,
|
267
|
+
/** @deprecated use `ChainSerializers` instead. */
|
268
|
+
ChainSerializers as Serializers,
|
269
|
+
ExtractChainFormatterExclude,
|
270
|
+
/** @deprecated use `ExtractChainFormatterExclude` instead. */
|
271
|
+
ExtractChainFormatterExclude as ExtractFormatterExclude,
|
272
|
+
ExtractChainFormatterParameters,
|
273
|
+
/** @deprecated use `ExtractChainFormatterParameters` instead. */
|
274
|
+
ExtractChainFormatterParameters as ExtractFormatterParameters,
|
275
|
+
ExtractChainFormatterReturnType,
|
276
|
+
/** @deprecated use `ExtractChainFormatterReturnType` instead. */
|
277
|
+
ExtractChainFormatterReturnType as ExtractFormatterReturnType,
|
278
|
+
} from './types/chain.js'
|
248
279
|
export {
|
249
280
|
type Client,
|
250
281
|
type ClientConfig,
|
@@ -435,6 +466,11 @@ export {
|
|
435
466
|
ContractFunctionZeroDataError,
|
436
467
|
RawContractError,
|
437
468
|
} from './errors/contract.js'
|
469
|
+
export {
|
470
|
+
BaseFeeScalarError,
|
471
|
+
Eip1559FeesNotSupportedError,
|
472
|
+
MaxFeePerGasTooLowError,
|
473
|
+
} from './errors/fee.js'
|
438
474
|
export {
|
439
475
|
ChainDisconnectedError,
|
440
476
|
InternalRpcError,
|
@@ -571,30 +607,7 @@ export type {
|
|
571
607
|
Signature,
|
572
608
|
SignableMessage,
|
573
609
|
} from './types/misc.js'
|
574
|
-
export type {
|
575
|
-
Chain,
|
576
|
-
ChainContract,
|
577
|
-
ChainFees,
|
578
|
-
ChainFormatter,
|
579
|
-
/** @deprecated use `ChainFormatter` instead. */
|
580
|
-
ChainFormatter as Formatter,
|
581
|
-
ChainFormatters,
|
582
|
-
/** @deprecated use `ChainFormatters` instead. */
|
583
|
-
ChainFormatters as Formatters,
|
584
|
-
ChainSerializers,
|
585
|
-
/** @deprecated use `ChainSerializers` instead. */
|
586
|
-
ChainSerializers as Serializers,
|
587
|
-
ExtractChainFormatterExclude,
|
588
|
-
/** @deprecated use `ExtractChainFormatterExclude` instead. */
|
589
|
-
ExtractChainFormatterExclude as ExtractFormatterExclude,
|
590
|
-
ExtractChainFormatterParameters,
|
591
|
-
/** @deprecated use `ExtractChainFormatterParameters` instead. */
|
592
|
-
ExtractChainFormatterParameters as ExtractFormatterParameters,
|
593
|
-
ExtractChainFormatterReturnType,
|
594
|
-
/** @deprecated use `ExtractChainFormatterReturnType` instead. */
|
595
|
-
ExtractChainFormatterReturnType as ExtractFormatterReturnType,
|
596
|
-
GetChain,
|
597
|
-
} from './types/chain.js'
|
610
|
+
export type { GetChain } from './types/chain.js'
|
598
611
|
export type {
|
599
612
|
AddEthereumChainParameter,
|
600
613
|
EIP1193EventMap,
|
@@ -621,6 +634,7 @@ export type {
|
|
621
634
|
FeeValues,
|
622
635
|
FeeValuesEIP1559,
|
623
636
|
FeeValuesLegacy,
|
637
|
+
FeeValuesType,
|
624
638
|
} from './types/fee.js'
|
625
639
|
export type { Filter } from './types/filter.js'
|
626
640
|
export type {
|
package/src/public.ts
CHANGED
@@ -53,6 +53,11 @@ export {
|
|
53
53
|
type GetFeeHistoryParameters,
|
54
54
|
type GetFeeHistoryReturnType,
|
55
55
|
} from './actions/public/getFeeHistory.js'
|
56
|
+
export {
|
57
|
+
estimateFeesPerGas,
|
58
|
+
type EstimateFeesPerGasParameters,
|
59
|
+
type EstimateFeesPerGasReturnType,
|
60
|
+
} from './actions/public/estimateFeesPerGas.js'
|
56
61
|
export {
|
57
62
|
getFilterChanges,
|
58
63
|
type GetFilterChangesParameters,
|
@@ -68,6 +73,11 @@ export {
|
|
68
73
|
getGasPrice,
|
69
74
|
type GetGasPriceReturnType,
|
70
75
|
} from './actions/public/getGasPrice.js'
|
76
|
+
export {
|
77
|
+
estimateMaxPriorityFeePerGas,
|
78
|
+
type EstimateMaxPriorityFeePerGasParameters,
|
79
|
+
type EstimateMaxPriorityFeePerGasReturnType,
|
80
|
+
} from './actions/public/estimateMaxPriorityFeePerGas.js'
|
71
81
|
export {
|
72
82
|
getTransaction,
|
73
83
|
type GetTransactionParameters,
|
package/src/types/chain.ts
CHANGED
@@ -1,13 +1,18 @@
|
|
1
1
|
import type { Address } from 'abitype'
|
2
2
|
|
3
|
-
import type {
|
4
|
-
import type {
|
5
|
-
import type {
|
3
|
+
import type { EstimateFeesPerGasReturnType } from '../actions/public/estimateFeesPerGas.js'
|
4
|
+
import type { Client } from '../clients/createClient.js'
|
5
|
+
import type { Transport } from '../clients/transports/createTransport.js'
|
6
|
+
import type { Account } from '../types/account.js'
|
7
|
+
import type { FeeValuesType } from '../types/fee.js'
|
6
8
|
import type {
|
7
9
|
TransactionSerializable,
|
8
10
|
TransactionSerializableGeneric,
|
9
|
-
} from '
|
10
|
-
import type { IsUndefined, Prettify } from '
|
11
|
+
} from '../types/transaction.js'
|
12
|
+
import type { IsUndefined, Prettify } from '../types/utils.js'
|
13
|
+
import type { FormattedBlock } from '../utils/formatters/block.js'
|
14
|
+
import type { PrepareRequestParameters } from '../utils/transaction/prepareRequest.js'
|
15
|
+
import type { SerializeTransactionFn } from '../utils/transaction/serializeTransaction.js'
|
11
16
|
|
12
17
|
export type Chain<
|
13
18
|
formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
|
@@ -16,8 +21,14 @@ export type Chain<
|
|
16
21
|
export type ChainConfig<
|
17
22
|
formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
|
18
23
|
> = {
|
24
|
+
/**
|
25
|
+
* Modifies how chain data structures (ie. Blocks, Transactions, etc)
|
26
|
+
* are formatted & typed.
|
27
|
+
*/
|
19
28
|
formatters?: formatters | undefined
|
29
|
+
/** Modifies how data (ie. Transactions) is serialized. */
|
20
30
|
serializers?: ChainSerializers<formatters> | undefined
|
31
|
+
/** Modifies how fees are derived. */
|
21
32
|
fees?: ChainFees<formatters> | undefined
|
22
33
|
}
|
23
34
|
|
@@ -29,20 +40,42 @@ export type ChainContract = {
|
|
29
40
|
export type ChainFees<
|
30
41
|
formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
|
31
42
|
> = {
|
32
|
-
|
43
|
+
/**
|
44
|
+
* The fee multiplier to use to account for fee fluctuations.
|
45
|
+
* Used in the [`estimateFeesPerGas` Action](/docs/actions/public/estimateFeesPerGas).
|
46
|
+
*
|
47
|
+
* @default 1.2
|
48
|
+
*/
|
49
|
+
baseFeeMultiplier?:
|
50
|
+
| number
|
51
|
+
| ((args: ChainFeesFnParameters<formatters>) => Promise<number> | number)
|
52
|
+
/**
|
53
|
+
* The default `maxPriorityFeePerGas` to use when a priority
|
54
|
+
* fee is not defined upon sending a transaction.
|
55
|
+
*
|
56
|
+
* Overrides the return value in the [`estimateMaxPriorityFeePerGas` Action](/docs/actions/public/estimateMaxPriorityFeePerGas).
|
57
|
+
*/
|
58
|
+
defaultPriorityFee?:
|
33
59
|
| bigint
|
34
|
-
| ((args:
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
60
|
+
| ((args: ChainFeesFnParameters<formatters>) => Promise<bigint> | bigint)
|
61
|
+
/**
|
62
|
+
* Allows customization of fee per gas values (e.g. `maxFeePerGas`/`maxPriorityFeePerGas`).
|
63
|
+
*
|
64
|
+
* Overrides the return value in the [`estimateFeesPerGas` Action](/docs/actions/public/estimateFeesPerGas).
|
65
|
+
*/
|
66
|
+
estimateFeesPerGas?: (
|
67
|
+
args: ChainEstimateFeesPerGasFnParameters<formatters>,
|
68
|
+
) => Promise<EstimateFeesPerGasReturnType> | bigint
|
40
69
|
}
|
41
70
|
|
42
71
|
export type ChainFormatters = {
|
72
|
+
/** Modifies how the Block structure is formatted & typed. */
|
43
73
|
block?: ChainFormatter<'block'>
|
74
|
+
/** Modifies how the Transaction structure is formatted & typed. */
|
44
75
|
transaction?: ChainFormatter<'transaction'>
|
76
|
+
/** Modifies how the TransactionReceipt structure is formatted & typed. */
|
45
77
|
transactionReceipt?: ChainFormatter<'transactionReceipt'>
|
78
|
+
/** Modifies how the TransactionRequest structure is formatted & typed. */
|
46
79
|
transactionRequest?: ChainFormatter<'transactionRequest'>
|
47
80
|
}
|
48
81
|
|
@@ -54,6 +87,7 @@ export type ChainFormatter<type extends string = string> = {
|
|
54
87
|
export type ChainSerializers<
|
55
88
|
formatters extends ChainFormatters | undefined = undefined,
|
56
89
|
> = {
|
90
|
+
/** Modifies how Transactions are serialized. */
|
57
91
|
transaction?: SerializeTransactionFn<
|
58
92
|
formatters extends ChainFormatters
|
59
93
|
? formatters['transactionRequest'] extends ChainFormatter
|
@@ -64,6 +98,40 @@ export type ChainSerializers<
|
|
64
98
|
>
|
65
99
|
}
|
66
100
|
|
101
|
+
/////////////////////////////////////////////////////////////////////
|
102
|
+
// Parameters
|
103
|
+
|
104
|
+
export type ChainFeesFnParameters<
|
105
|
+
formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
|
106
|
+
> = {
|
107
|
+
/** The latest block. */
|
108
|
+
block: Prettify<FormattedBlock<{ formatters: formatters }>>
|
109
|
+
client: Client<Transport, Chain>
|
110
|
+
/**
|
111
|
+
* A transaction request. This value will be undefined if the caller
|
112
|
+
* is outside of a transaction request context (e.g. a direct call to
|
113
|
+
* the `estimateFeesPerGas` Action).
|
114
|
+
*/
|
115
|
+
request?: PrepareRequestParameters<
|
116
|
+
Omit<Chain, 'formatters'> & { formatters: formatters },
|
117
|
+
Account | undefined,
|
118
|
+
undefined
|
119
|
+
>
|
120
|
+
}
|
121
|
+
|
122
|
+
export type ChainEstimateFeesPerGasFnParameters<
|
123
|
+
formatters extends ChainFormatters | undefined = ChainFormatters | undefined,
|
124
|
+
> = {
|
125
|
+
/**
|
126
|
+
* A function to multiply the base fee based on the `baseFeeMultiplier` value.
|
127
|
+
*/
|
128
|
+
multiply(x: bigint): bigint
|
129
|
+
/**
|
130
|
+
* The type of fees to return.
|
131
|
+
*/
|
132
|
+
type: FeeValuesType
|
133
|
+
} & ChainFeesFnParameters<formatters>
|
134
|
+
|
67
135
|
/////////////////////////////////////////////////////////////////////
|
68
136
|
// Utils
|
69
137
|
|
package/src/types/eip1193.ts
CHANGED
@@ -571,6 +571,18 @@ export type PublicRpcSchema = [
|
|
571
571
|
Parameters: [block: BlockNumber | BlockTag]
|
572
572
|
ReturnType: Quantity
|
573
573
|
},
|
574
|
+
/**
|
575
|
+
* @description Returns the current maxPriorityFeePerGas in wei.
|
576
|
+
* @link https://ethereum.github.io/execution-apis/api-documentation/
|
577
|
+
* @example
|
578
|
+
* provider.request({ method: 'eth_maxPriorityFeePerGas' })
|
579
|
+
* // => '0x5f5e100'
|
580
|
+
*/
|
581
|
+
{
|
582
|
+
Method: 'eth_maxPriorityFeePerGas'
|
583
|
+
Parameters?: undefined
|
584
|
+
ReturnType: Quantity
|
585
|
+
},
|
574
586
|
/**
|
575
587
|
* @description Creates a filter to listen for new blocks that can be used with `eth_getFilterChanges`
|
576
588
|
* @link https://eips.ethereum.org/EIPS/eip-1474
|
package/src/types/fee.ts
CHANGED
@@ -2,22 +2,26 @@ import type { Address } from 'abitype'
|
|
2
2
|
|
3
3
|
import type { Account } from '../../accounts/types.js'
|
4
4
|
import { parseAccount } from '../../accounts/utils/parseAccount.js'
|
5
|
+
import { internal_estimateFeesPerGas } from '../../actions/public/estimateFeesPerGas.js'
|
5
6
|
import {
|
6
7
|
type EstimateGasParameters,
|
7
8
|
estimateGas,
|
8
9
|
} from '../../actions/public/estimateGas.js'
|
9
10
|
import { getBlock } from '../../actions/public/getBlock.js'
|
10
|
-
import { getGasPrice } from '../../actions/public/getGasPrice.js'
|
11
11
|
import { getTransactionCount } from '../../actions/public/getTransactionCount.js'
|
12
12
|
import type { SendTransactionParameters } from '../../actions/wallet/sendTransaction.js'
|
13
13
|
import type { Client } from '../../clients/createClient.js'
|
14
14
|
import type { Transport } from '../../clients/transports/createTransport.js'
|
15
15
|
import { AccountNotFoundError } from '../../errors/account.js'
|
16
|
-
import {
|
16
|
+
import {
|
17
|
+
Eip1559FeesNotSupportedError,
|
18
|
+
MaxFeePerGasTooLowError,
|
19
|
+
} from '../../errors/fee.js'
|
17
20
|
import type { GetAccountParameter } from '../../types/account.js'
|
18
|
-
import type { Chain
|
21
|
+
import type { Chain } from '../../types/chain.js'
|
22
|
+
import type { GetChain } from '../../types/chain.js'
|
19
23
|
import type { UnionOmit } from '../../types/utils.js'
|
20
|
-
import type
|
24
|
+
import { type FormattedTransactionRequest } from '../index.js'
|
21
25
|
import { type AssertRequestParameters, assertRequest } from './assertRequest.js'
|
22
26
|
|
23
27
|
export type PrepareRequestParameters<
|
@@ -60,15 +64,7 @@ export async function prepareRequest<
|
|
60
64
|
client: Client<Transport, TChain, TAccount>,
|
61
65
|
args: TArgs,
|
62
66
|
): Promise<PrepareRequestReturnType<TChain, TAccount, TChainOverride, TArgs>> {
|
63
|
-
const {
|
64
|
-
account: account_,
|
65
|
-
chain = client.chain,
|
66
|
-
gas,
|
67
|
-
gasPrice,
|
68
|
-
maxFeePerGas,
|
69
|
-
maxPriorityFeePerGas,
|
70
|
-
nonce,
|
71
|
-
} = args
|
67
|
+
const { account: account_, chain, gas, gasPrice, nonce } = args
|
72
68
|
if (!account_) throw new AccountNotFoundError()
|
73
69
|
const account = parseAccount(account_)
|
74
70
|
|
@@ -86,44 +82,40 @@ export async function prepareRequest<
|
|
86
82
|
typeof block.baseFeePerGas === 'bigint' &&
|
87
83
|
typeof gasPrice === 'undefined'
|
88
84
|
) {
|
89
|
-
let defaultPriorityFee = 1_500_000_000n // 1.5 gwei
|
90
|
-
if (typeof chain?.fees?.defaultPriorityFee !== 'undefined') {
|
91
|
-
defaultPriorityFee =
|
92
|
-
typeof chain.fees.defaultPriorityFee === 'bigint'
|
93
|
-
? chain.fees.defaultPriorityFee
|
94
|
-
: await chain.fees.defaultPriorityFee({
|
95
|
-
block,
|
96
|
-
request: request as PrepareRequestParameters,
|
97
|
-
})
|
98
|
-
}
|
99
|
-
|
100
85
|
// EIP-1559 fees
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
86
|
+
const { maxFeePerGas, maxPriorityFeePerGas } =
|
87
|
+
await internal_estimateFeesPerGas(client, {
|
88
|
+
block,
|
89
|
+
chain,
|
90
|
+
request: request as PrepareRequestParameters,
|
91
|
+
})
|
92
|
+
|
93
|
+
if (
|
94
|
+
typeof args.maxPriorityFeePerGas === 'undefined' &&
|
95
|
+
args.maxFeePerGas &&
|
96
|
+
args.maxFeePerGas < maxPriorityFeePerGas
|
97
|
+
)
|
98
|
+
throw new MaxFeePerGasTooLowError({
|
99
|
+
maxPriorityFeePerGas,
|
100
|
+
})
|
101
|
+
|
102
|
+
request.maxPriorityFeePerGas = maxPriorityFeePerGas
|
103
|
+
request.maxFeePerGas = args.maxFeePerGas ?? maxFeePerGas
|
117
104
|
} else if (typeof gasPrice === 'undefined') {
|
118
105
|
// Legacy fees
|
119
106
|
if (
|
120
|
-
typeof maxFeePerGas !== 'undefined' ||
|
121
|
-
typeof maxPriorityFeePerGas !== 'undefined'
|
107
|
+
typeof args.maxFeePerGas !== 'undefined' ||
|
108
|
+
typeof args.maxPriorityFeePerGas !== 'undefined'
|
122
109
|
)
|
123
|
-
throw new
|
110
|
+
throw new Eip1559FeesNotSupportedError()
|
124
111
|
|
125
|
-
|
126
|
-
|
112
|
+
const { gasPrice: gasPrice_ } = await internal_estimateFeesPerGas(client, {
|
113
|
+
block,
|
114
|
+
chain,
|
115
|
+
request: request as PrepareRequestParameters,
|
116
|
+
type: 'legacy',
|
117
|
+
})
|
118
|
+
request.gasPrice = gasPrice_
|
127
119
|
}
|
128
120
|
|
129
121
|
if (typeof gas === 'undefined')
|
@@ -1,58 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.formattersCelo = void 0;
|
4
|
-
const viem_1 = require("viem");
|
5
|
-
const utils_js_1 = require("../utils.js");
|
6
|
-
exports.formattersCelo = {
|
7
|
-
block: (0, utils_js_1.defineBlock)({
|
8
|
-
exclude: ['difficulty', 'gasLimit', 'mixHash', 'nonce', 'uncles'],
|
9
|
-
format(args) {
|
10
|
-
const transactions = args.transactions?.map((transaction) => {
|
11
|
-
if (typeof transaction === 'string')
|
12
|
-
return transaction;
|
13
|
-
return {
|
14
|
-
...(0, viem_1.formatTransaction)(transaction),
|
15
|
-
feeCurrency: transaction.feeCurrency,
|
16
|
-
gatewayFee: transaction.gatewayFee
|
17
|
-
? (0, viem_1.hexToBigInt)(transaction.gatewayFee)
|
18
|
-
: null,
|
19
|
-
gatewayFeeRecipient: transaction.gatewayFeeRecipient,
|
20
|
-
};
|
21
|
-
});
|
22
|
-
return {
|
23
|
-
randomness: args.randomness,
|
24
|
-
transactions,
|
25
|
-
};
|
26
|
-
},
|
27
|
-
}),
|
28
|
-
transaction: (0, utils_js_1.defineTransaction)({
|
29
|
-
format(args) {
|
30
|
-
return {
|
31
|
-
feeCurrency: args.feeCurrency,
|
32
|
-
gatewayFee: args.gatewayFee ? (0, viem_1.hexToBigInt)(args.gatewayFee) : null,
|
33
|
-
gatewayFeeRecipient: args.gatewayFeeRecipient,
|
34
|
-
};
|
35
|
-
},
|
36
|
-
}),
|
37
|
-
transactionReceipt: (0, utils_js_1.defineTransactionReceipt)({
|
38
|
-
format(args) {
|
39
|
-
return {
|
40
|
-
feeCurrency: args.feeCurrency,
|
41
|
-
gatewayFee: args.gatewayFee ? (0, viem_1.hexToBigInt)(args.gatewayFee) : null,
|
42
|
-
gatewayFeeRecipient: args.gatewayFeeRecipient,
|
43
|
-
};
|
44
|
-
},
|
45
|
-
}),
|
46
|
-
transactionRequest: (0, utils_js_1.defineTransactionRequest)({
|
47
|
-
format(args) {
|
48
|
-
return {
|
49
|
-
feeCurrency: args.feeCurrency,
|
50
|
-
gatewayFee: typeof args.gatewayFee !== 'undefined'
|
51
|
-
? (0, viem_1.numberToHex)(args.gatewayFee)
|
52
|
-
: undefined,
|
53
|
-
gatewayFeeRecipient: args.gatewayFeeRecipient,
|
54
|
-
};
|
55
|
-
},
|
56
|
-
}),
|
57
|
-
};
|
58
|
-
//# sourceMappingURL=formatters.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"formatters.js","sourceRoot":"","sources":["../../../src/celo/formatters.ts"],"names":[],"mappings":";;;AAAA,+BAA6E;AAG7E,0CAKoB;AAaP,QAAA,cAAc,GAAG;IAC5B,KAAK,EAAgB,IAAA,sBAAW,EAAC;QAC/B,OAAO,EAAE,CAAC,YAAY,EAAE,UAAU,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,CAAC;QACjE,MAAM,CACJ,IAEC;YAID,MAAM,YAAY,GAAG,IAAI,CAAC,YAAY,EAAE,GAAG,CAAC,CAAC,WAAW,EAAE,EAAE;gBAC1D,IAAI,OAAO,WAAW,KAAK,QAAQ;oBAAE,OAAO,WAAW,CAAA;gBACvD,OAAO;oBACL,GAAG,IAAA,wBAAiB,EAAC,WAAW,CAAC;oBACjC,WAAW,EAAE,WAAW,CAAC,WAAW;oBACpC,UAAU,EAAE,WAAW,CAAC,UAAU;wBAChC,CAAC,CAAC,IAAA,kBAAW,EAAC,WAAW,CAAC,UAAU,CAAC;wBACrC,CAAC,CAAC,IAAI;oBACR,mBAAmB,EAAE,WAAW,CAAC,mBAAmB;iBACrD,CAAA;YACH,CAAC,CAA+B,CAAA;YAChC,OAAO;gBACL,UAAU,EAAE,IAAI,CAAC,UAAU;gBAC3B,YAAY;aACb,CAAA;QACH,CAAC;KACF,CAAC;IACF,WAAW,EAAgB,IAAA,4BAAiB,EAAC;QAC3C,MAAM,CAAC,IAAiC;YACtC,OAAO;gBACL,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,kBAAW,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI;gBACjE,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;aAC9C,CAAA;QACH,CAAC;KACF,CAAC;IACF,kBAAkB,EAAgB,IAAA,mCAAwB,EAAC;QACzD,MAAM,CACJ,IAAwC;YAExC,OAAO;gBACL,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,UAAU,EAAE,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,IAAA,kBAAW,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,IAAI;gBACjE,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;aAC9C,CAAA;QACH,CAAC;KACF,CAAC;IACF,kBAAkB,EAAgB,IAAA,mCAAwB,EAAC;QACzD,MAAM,CACJ,IAAqC;YAErC,OAAO;gBACL,WAAW,EAAE,IAAI,CAAC,WAAW;gBAC7B,UAAU,EACR,OAAO,IAAI,CAAC,UAAU,KAAK,WAAW;oBACpC,CAAC,CAAC,IAAA,kBAAW,EAAC,IAAI,CAAC,UAAU,CAAC;oBAC9B,CAAC,CAAC,SAAS;gBACf,mBAAmB,EAAE,IAAI,CAAC,mBAAmB;aAC9C,CAAA;QACH,CAAC;KACF,CAAC;CACgC,CAAA"}
|
@@ -1,72 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.parseTransactionCelo = void 0;
|
4
|
-
const viem_1 = require("viem");
|
5
|
-
const serializers_js_1 = require("./serializers.js");
|
6
|
-
function parseTransactionCelo(serializedTransaction) {
|
7
|
-
const serializedType = (0, viem_1.sliceHex)(serializedTransaction, 0, 1);
|
8
|
-
if (serializedType === '0x7c')
|
9
|
-
return parseTransactionCIP42(serializedTransaction);
|
10
|
-
return (0, viem_1.parseTransaction)(serializedTransaction);
|
11
|
-
}
|
12
|
-
exports.parseTransactionCelo = parseTransactionCelo;
|
13
|
-
function parseTransactionCIP42(serializedTransaction) {
|
14
|
-
const transactionArray = (0, viem_1.toTransactionArray)(serializedTransaction);
|
15
|
-
const [chainId, nonce, maxPriorityFeePerGas, maxFeePerGas, gas, feeCurrency, gatewayFeeRecipient, gatewayFee, to, value, data, accessList, v, r, s,] = transactionArray;
|
16
|
-
if (transactionArray.length !== 15 && transactionArray.length !== 12) {
|
17
|
-
throw new viem_1.InvalidSerializedTransactionError({
|
18
|
-
attributes: {
|
19
|
-
chainId,
|
20
|
-
nonce,
|
21
|
-
maxPriorityFeePerGas,
|
22
|
-
maxFeePerGas,
|
23
|
-
gas,
|
24
|
-
feeCurrency,
|
25
|
-
to,
|
26
|
-
gatewayFeeRecipient,
|
27
|
-
gatewayFee,
|
28
|
-
value,
|
29
|
-
data,
|
30
|
-
accessList,
|
31
|
-
...(transactionArray.length > 12
|
32
|
-
? {
|
33
|
-
v,
|
34
|
-
r,
|
35
|
-
s,
|
36
|
-
}
|
37
|
-
: {}),
|
38
|
-
},
|
39
|
-
serializedTransaction,
|
40
|
-
type: 'cip42',
|
41
|
-
});
|
42
|
-
}
|
43
|
-
const transaction = {
|
44
|
-
chainId: (0, viem_1.hexToNumber)(chainId),
|
45
|
-
type: 'cip42',
|
46
|
-
};
|
47
|
-
if ((0, viem_1.isHex)(to) && to !== '0x')
|
48
|
-
transaction.to = to;
|
49
|
-
if ((0, viem_1.isHex)(gas) && gas !== '0x')
|
50
|
-
transaction.gas = (0, viem_1.hexToBigInt)(gas);
|
51
|
-
if ((0, viem_1.isHex)(data) && data !== '0x')
|
52
|
-
transaction.data = data;
|
53
|
-
if ((0, viem_1.isHex)(nonce) && nonce !== '0x')
|
54
|
-
transaction.nonce = (0, viem_1.hexToNumber)(nonce);
|
55
|
-
if ((0, viem_1.isHex)(value) && value !== '0x')
|
56
|
-
transaction.value = (0, viem_1.hexToBigInt)(value);
|
57
|
-
if ((0, viem_1.isHex)(feeCurrency) && feeCurrency !== '0x')
|
58
|
-
transaction.feeCurrency = feeCurrency;
|
59
|
-
if ((0, viem_1.isHex)(gatewayFeeRecipient) && gatewayFeeRecipient !== '0x')
|
60
|
-
transaction.gatewayFeeRecipient = gatewayFeeRecipient;
|
61
|
-
if ((0, viem_1.isHex)(gatewayFee) && gatewayFee !== '0x')
|
62
|
-
transaction.gatewayFee = (0, viem_1.hexToBigInt)(gatewayFee);
|
63
|
-
if ((0, viem_1.isHex)(maxFeePerGas) && maxFeePerGas !== '0x')
|
64
|
-
transaction.maxFeePerGas = (0, viem_1.hexToBigInt)(maxFeePerGas);
|
65
|
-
if ((0, viem_1.isHex)(maxPriorityFeePerGas) && maxPriorityFeePerGas !== '0x')
|
66
|
-
transaction.maxPriorityFeePerGas = (0, viem_1.hexToBigInt)(maxPriorityFeePerGas);
|
67
|
-
if (accessList.length !== 0 && accessList !== '0x')
|
68
|
-
transaction.accessList = (0, viem_1.parseAccessList)(accessList);
|
69
|
-
(0, serializers_js_1.assertTransactionCIP42)(transaction);
|
70
|
-
return transaction;
|
71
|
-
}
|
72
|
-
//# sourceMappingURL=parsers.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"parsers.js","sourceRoot":"","sources":["../../../src/celo/parsers.ts"],"names":[],"mappings":";;;AAAA,+BAaa;AAEb,qDAAyD;AAezD,SAAgB,oBAAoB,CAGlC,qBAAkC;IAElC,MAAM,cAAc,GAAG,IAAA,eAAQ,EAAC,qBAAqB,EAAE,CAAC,EAAE,CAAC,CAAC,CAAA;IAE5D,IAAI,cAAc,KAAK,MAAM;QAC3B,OAAO,qBAAqB,CAC1B,qBAAmD,CACL,CAAA;IAElD,OAAO,IAAA,uBAAgB,EACrB,qBAAqB,CACyB,CAAA;AAClD,CAAC;AAfD,oDAeC;AAED,SAAS,qBAAqB,CAC5B,qBAAiD;IAEjD,MAAM,gBAAgB,GAAG,IAAA,yBAAkB,EAAC,qBAAqB,CAAC,CAAA;IAElE,MAAM,CACJ,OAAO,EACP,KAAK,EACL,oBAAoB,EACpB,YAAY,EACZ,GAAG,EACH,WAAW,EACX,mBAAmB,EACnB,UAAU,EACV,EAAE,EACF,KAAK,EACL,IAAI,EACJ,UAAU,EACV,CAAC,EACD,CAAC,EACD,CAAC,EACF,GAAG,gBAAgB,CAAA;IAEpB,IAAI,gBAAgB,CA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AC,WAAW,CAAC,IAAI,WAAW,KAAK,IAAI;QAC5C,WAAW,CAAC,WAAW,GAAG,WAAW,CAAA;IACvC,IAAI,IAAA,YAAK,EAAC,mBAAmB,CAAC,IAAI,mBAAmB,KAAK,IAAI;QAC5D,WAAW,CAAC,mBAAmB,GAAG,mBAAmB,CAAA;IACvD,IAAI,IAAA,YAAK,EAAC,UAAU,CAAC,IAAI,UAAU,KAAK,IAAI;QAC1C,WAAW,CAAC,UAAU,GAAG,IAAA,kBAAW,EAAC,UAAU,CAAC,CAAA;IAClD,IAAI,IAAA,YAAK,EAAC,YAAY,CAAC,IAAI,YAAY,KAAK,IAAI;QAC9C,WAAW,CAAC,YAAY,GAAG,IAAA,kBAAW,EAAC,YAAY,CAAC,CAAA;IACtD,IAAI,IAAA,YAAK,EAAC,oBAAoB,CAAC,IAAI,oBAAoB,KAAK,IAAI;QAC9D,WAAW,CAAC,oBAAoB,GAAG,IAAA,kBAAW,EAAC,oBAAoB,CAAC,CAAA;IACtE,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC,IAAI,UAAU,KAAK,IAAI;QAChD,WAAW,CAAC,UAAU,GAAG,IAAA,sBAAe,EAAC,UAAiC,CAAC,CAAA;IAE7E,IAAA,uCAAsB,EAAC,WAA2C,CAAC,CAAA;IAEnE,OAAO,WAA2C,CAAA;AACpD,CAAC"}
|
@@ -1,75 +0,0 @@
|
|
1
|
-
"use strict";
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.assertTransactionCIP42 = exports.serializersCelo = exports.serializeTransactionCelo = void 0;
|
4
|
-
const viem_1 = require("viem");
|
5
|
-
const serializeTransactionCelo = (tx, signature) => {
|
6
|
-
if (isCIP42(tx))
|
7
|
-
return serializeTransactionCIP42(tx, signature);
|
8
|
-
return (0, viem_1.serializeTransaction)(tx, signature);
|
9
|
-
};
|
10
|
-
exports.serializeTransactionCelo = serializeTransactionCelo;
|
11
|
-
exports.serializersCelo = {
|
12
|
-
transaction: exports.serializeTransactionCelo,
|
13
|
-
};
|
14
|
-
function serializeTransactionCIP42(transaction, signature) {
|
15
|
-
assertTransactionCIP42(transaction);
|
16
|
-
const { chainId, gas, nonce, to, value, maxFeePerGas, maxPriorityFeePerGas, accessList, feeCurrency, gatewayFeeRecipient, gatewayFee, data, } = transaction;
|
17
|
-
const serializedTransaction = [
|
18
|
-
(0, viem_1.toHex)(chainId),
|
19
|
-
nonce ? (0, viem_1.toHex)(nonce) : '0x',
|
20
|
-
maxPriorityFeePerGas ? (0, viem_1.toHex)(maxPriorityFeePerGas) : '0x',
|
21
|
-
maxFeePerGas ? (0, viem_1.toHex)(maxFeePerGas) : '0x',
|
22
|
-
gas ? (0, viem_1.toHex)(gas) : '0x',
|
23
|
-
feeCurrency ?? '0x',
|
24
|
-
gatewayFeeRecipient ?? '0x',
|
25
|
-
gatewayFee ? (0, viem_1.toHex)(gatewayFee) : '0x',
|
26
|
-
to ?? '0x',
|
27
|
-
value ? (0, viem_1.toHex)(value) : '0x',
|
28
|
-
data ?? '0x',
|
29
|
-
(0, viem_1.serializeAccessList)(accessList),
|
30
|
-
];
|
31
|
-
if (signature) {
|
32
|
-
serializedTransaction.push(signature.v === 27n ? '0x' : (0, viem_1.toHex)(1), (0, viem_1.trim)(signature.r), (0, viem_1.trim)(signature.s));
|
33
|
-
}
|
34
|
-
return (0, viem_1.concatHex)([
|
35
|
-
'0x7c',
|
36
|
-
(0, viem_1.toRlp)(serializedTransaction),
|
37
|
-
]);
|
38
|
-
}
|
39
|
-
function isCIP42(transaction) {
|
40
|
-
if ('maxFeePerGas' in transaction &&
|
41
|
-
'maxPriorityFeePerGas' in transaction &&
|
42
|
-
('feeCurrency' in transaction ||
|
43
|
-
'gatewayFee' in transaction ||
|
44
|
-
'gatewayFeeRecipient' in transaction))
|
45
|
-
return true;
|
46
|
-
return false;
|
47
|
-
}
|
48
|
-
const MAX_MAX_FEE_PER_GAS = 115792089237316195423570985008687907853269984665640564039457584007913129639935n;
|
49
|
-
function assertTransactionCIP42(transaction) {
|
50
|
-
const { chainId, maxPriorityFeePerGas, gasPrice, maxFeePerGas, to, feeCurrency, gatewayFee, gatewayFeeRecipient, } = transaction;
|
51
|
-
if (chainId <= 0)
|
52
|
-
throw new viem_1.InvalidChainIdError({ chainId });
|
53
|
-
if (to && !(0, viem_1.isAddress)(to))
|
54
|
-
throw new viem_1.InvalidAddressError({ address: to });
|
55
|
-
if (gasPrice)
|
56
|
-
throw new viem_1.BaseError('`gasPrice` is not a valid CIP-42 Transaction attribute.');
|
57
|
-
if (maxFeePerGas && maxFeePerGas > MAX_MAX_FEE_PER_GAS)
|
58
|
-
throw new viem_1.FeeCapTooHighError({ maxFeePerGas });
|
59
|
-
if (maxPriorityFeePerGas &&
|
60
|
-
maxFeePerGas &&
|
61
|
-
maxPriorityFeePerGas > maxFeePerGas)
|
62
|
-
throw new viem_1.TipAboveFeeCapError({ maxFeePerGas, maxPriorityFeePerGas });
|
63
|
-
if ((gatewayFee && !gatewayFeeRecipient) ||
|
64
|
-
(gatewayFeeRecipient && !gatewayFee)) {
|
65
|
-
throw new viem_1.BaseError('`gatewayFee` and `gatewayFeeRecipient` must be provided together.');
|
66
|
-
}
|
67
|
-
if (feeCurrency && !feeCurrency?.startsWith('0x')) {
|
68
|
-
throw new viem_1.BaseError('`feeCurrency` MUST be a token address for CIP-42 transactions.');
|
69
|
-
}
|
70
|
-
if (!feeCurrency && !gatewayFeeRecipient) {
|
71
|
-
throw new viem_1.BaseError('Either `feeCurrency` or `gatewayFeeRecipient` must be provided for CIP-42 transactions.');
|
72
|
-
}
|
73
|
-
}
|
74
|
-
exports.assertTransactionCIP42 = assertTransactionCIP42;
|
75
|
-
//# sourceMappingURL=serializers.js.map
|
@@ -1 +0,0 @@
|
|
1
|
-
{"version":3,"file":"serializers.js","sourceRoot":"","sources":["../../../src/celo/serializers.ts"],"names":[],"mappings":";;;AAAA,+BAgBa;AASN,MAAM,wBAAwB,GAEjC,CAAC,EAAE,EAAE,SAAS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