viem 2.54.0 → 2.54.2
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 +30 -0
- package/_cjs/account-abstraction/actions/bundler/estimateUserOperationGas.js +1 -2
- package/_cjs/account-abstraction/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/_cjs/chains/definitions/marsCredit.js +23 -0
- package/_cjs/chains/definitions/marsCredit.js.map +1 -0
- package/_cjs/chains/index.js +10 -8
- package/_cjs/chains/index.js.map +1 -1
- package/_cjs/clients/createClient.js +1 -0
- package/_cjs/clients/createClient.js.map +1 -1
- package/_cjs/errors/encoding.js +13 -1
- package/_cjs/errors/encoding.js.map +1 -1
- package/_cjs/errors/version.js +1 -1
- package/_cjs/index.js +8 -6
- package/_cjs/index.js.map +1 -1
- package/_cjs/tempo/Abis.js +49 -1
- package/_cjs/tempo/Abis.js.map +1 -1
- package/_cjs/tempo/Addresses.js +3 -1
- package/_cjs/tempo/Addresses.js.map +1 -1
- package/_cjs/tempo/Client.js +3 -1
- package/_cjs/tempo/Client.js.map +1 -1
- package/_cjs/tempo/Decorator.js.map +1 -1
- package/_cjs/tempo/Selectors.js +8 -1
- package/_cjs/tempo/Selectors.js.map +1 -1
- package/_cjs/tempo/actions/receivePolicy.js +29 -5
- package/_cjs/tempo/actions/receivePolicy.js.map +1 -1
- package/_cjs/tempo/actions/virtualAddress.js +2 -5
- package/_cjs/tempo/actions/virtualAddress.js.map +1 -1
- package/_cjs/tempo/actions/zone.js +69 -48
- package/_cjs/tempo/actions/zone.js.map +1 -1
- package/_cjs/tokens/definitions/cirbtc.js +16 -0
- package/_cjs/tokens/definitions/cirbtc.js.map +1 -0
- package/_cjs/tokens/definitions/eurc.js +24 -0
- package/_cjs/tokens/definitions/eurc.js.map +1 -0
- package/_cjs/tokens/definitions/usdc.js +18 -0
- package/_cjs/tokens/definitions/usdc.js.map +1 -1
- package/_cjs/tokens/definitions/usyc.js +18 -0
- package/_cjs/tokens/definitions/usyc.js.map +1 -0
- package/_cjs/tokens/index.js +9 -1
- package/_cjs/tokens/index.js.map +1 -1
- package/_cjs/tokens/sets.js +102 -0
- package/_cjs/tokens/sets.js.map +1 -0
- package/_cjs/utils/encoding/fromRlp.js +9 -0
- package/_cjs/utils/encoding/fromRlp.js.map +1 -1
- package/_esm/account-abstraction/actions/bundler/estimateUserOperationGas.js +1 -2
- package/_esm/account-abstraction/actions/bundler/estimateUserOperationGas.js.map +1 -1
- package/_esm/chains/definitions/marsCredit.js +20 -0
- package/_esm/chains/definitions/marsCredit.js.map +1 -0
- package/_esm/chains/index.js +1 -0
- package/_esm/chains/index.js.map +1 -1
- package/_esm/clients/createClient.js +5 -3
- package/_esm/clients/createClient.js.map +1 -1
- package/_esm/errors/encoding.js +10 -0
- package/_esm/errors/encoding.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/tempo/Abis.js +48 -0
- package/_esm/tempo/Abis.js.map +1 -1
- package/_esm/tempo/Addresses.js +2 -0
- package/_esm/tempo/Addresses.js.map +1 -1
- package/_esm/tempo/Client.js +3 -1
- package/_esm/tempo/Client.js.map +1 -1
- package/_esm/tempo/Decorator.js.map +1 -1
- package/_esm/tempo/Selectors.js +7 -0
- package/_esm/tempo/Selectors.js.map +1 -1
- package/_esm/tempo/actions/receivePolicy.js +32 -5
- package/_esm/tempo/actions/receivePolicy.js.map +1 -1
- package/_esm/tempo/actions/virtualAddress.js +2 -6
- package/_esm/tempo/actions/virtualAddress.js.map +1 -1
- package/_esm/tempo/actions/zone.js +96 -49
- package/_esm/tempo/actions/zone.js.map +1 -1
- package/_esm/tokens/definitions/cirbtc.js +21 -0
- package/_esm/tokens/definitions/cirbtc.js.map +1 -0
- package/_esm/tokens/definitions/eurc.js +29 -0
- package/_esm/tokens/definitions/eurc.js.map +1 -0
- package/_esm/tokens/definitions/usdc.js +18 -0
- package/_esm/tokens/definitions/usdc.js.map +1 -1
- package/_esm/tokens/definitions/usyc.js +23 -0
- package/_esm/tokens/definitions/usyc.js.map +1 -0
- package/_esm/tokens/index.js +4 -0
- package/_esm/tokens/index.js.map +1 -1
- package/_esm/tokens/sets.js +104 -0
- package/_esm/tokens/sets.js.map +1 -0
- package/_esm/utils/encoding/fromRlp.js +12 -1
- package/_esm/utils/encoding/fromRlp.js.map +1 -1
- package/_types/account-abstraction/actions/bundler/estimateUserOperationGas.d.ts.map +1 -1
- package/_types/chains/definitions/marsCredit.d.ts +50 -0
- package/_types/chains/definitions/marsCredit.d.ts.map +1 -0
- package/_types/chains/index.d.ts +1 -0
- package/_types/chains/index.d.ts.map +1 -1
- package/_types/clients/createClient.d.ts +4 -3
- package/_types/clients/createClient.d.ts.map +1 -1
- package/_types/errors/encoding.d.ts +17 -0
- package/_types/errors/encoding.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/tempo/Abis.d.ts +119 -0
- package/_types/tempo/Abis.d.ts.map +1 -1
- package/_types/tempo/Addresses.d.ts +2 -0
- package/_types/tempo/Addresses.d.ts.map +1 -1
- package/_types/tempo/Client.d.ts.map +1 -1
- package/_types/tempo/Decorator.d.ts +4 -0
- package/_types/tempo/Decorator.d.ts.map +1 -1
- package/_types/tempo/Selectors.d.ts +7 -0
- package/_types/tempo/Selectors.d.ts.map +1 -1
- package/_types/tempo/actions/receivePolicy.d.ts +1 -1
- package/_types/tempo/actions/receivePolicy.d.ts.map +1 -1
- package/_types/tempo/actions/virtualAddress.d.ts.map +1 -1
- package/_types/tempo/actions/zone.d.ts +63 -3
- package/_types/tempo/actions/zone.d.ts.map +1 -1
- package/_types/tokens/definitions/cirbtc.d.ts +21 -0
- package/_types/tokens/definitions/cirbtc.d.ts.map +1 -0
- package/_types/tokens/definitions/eurc.d.ts +29 -0
- package/_types/tokens/definitions/eurc.d.ts.map +1 -0
- package/_types/tokens/definitions/usdc.d.ts +18 -0
- package/_types/tokens/definitions/usdc.d.ts.map +1 -1
- package/_types/tokens/definitions/usyc.d.ts +23 -0
- package/_types/tokens/definitions/usyc.d.ts.map +1 -0
- package/_types/tokens/index.d.ts +4 -0
- package/_types/tokens/index.d.ts.map +1 -1
- package/_types/tokens/sets.d.ts +607 -0
- package/_types/tokens/sets.d.ts.map +1 -0
- package/_types/utils/encoding/fromRlp.d.ts +3 -3
- package/_types/utils/encoding/fromRlp.d.ts.map +1 -1
- package/account-abstraction/actions/bundler/estimateUserOperationGas.ts +1 -2
- package/chains/definitions/marsCredit.ts +20 -0
- package/chains/index.ts +1 -0
- package/clients/createClient.ts +5 -3
- package/errors/encoding.ts +26 -0
- package/errors/version.ts +1 -1
- package/index.ts +4 -0
- package/package.json +2 -2
- package/tempo/Abis.ts +49 -0
- package/tempo/Addresses.ts +2 -0
- package/tempo/Client.ts +3 -1
- package/tempo/Decorator.ts +3 -0
- package/tempo/Selectors.ts +8 -0
- package/tempo/actions/receivePolicy.ts +39 -4
- package/tempo/actions/virtualAddress.ts +2 -8
- package/tempo/actions/zone.ts +164 -74
- package/tokens/definitions/cirbtc.ts +21 -0
- package/tokens/definitions/eurc.ts +29 -0
- package/tokens/definitions/usdc.ts +18 -0
- package/tokens/definitions/usyc.ts +23 -0
- package/tokens/index.ts +4 -0
- package/tokens/sets.ts +109 -0
- package/utils/encoding/fromRlp.ts +18 -1
|
@@ -33,29 +33,47 @@ export const usdc = /*#__PURE__*/ defineToken({
|
|
|
33
33
|
addresses: {
|
|
34
34
|
1: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', // mainnet
|
|
35
35
|
10: '0x0b2C639c533813f4Aa9D7837CAf62653d097Ff85', // optimism
|
|
36
|
+
25: '0x3D7F2C478aAfdB65542BCB44bCeeC05849999d2D', // cronos
|
|
37
|
+
50: '0xfA2958CB79b0491CC627c1557F441eF849Ca8eb1', // xdc
|
|
38
|
+
51: '0xb5AB69F7bBada22B28e79C8FFAECe55eF1c771D4', // xdcTestnet
|
|
36
39
|
130: '0x078D782b760474a361dDA0AF3839290b0EF57AD6', // unichain
|
|
37
40
|
137: '0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359', // polygon
|
|
41
|
+
143: '0x754704Bc059F8C67012fEd69BC8A327a5aafb603', // monad
|
|
38
42
|
146: '0x29219dd400f2Bf60E5a23d13Be72B486D4038894', // sonic
|
|
43
|
+
300: '0xAe045DE5638162fa134807Cb558E15A3F5A7F853', // zksyncSepoliaTestnet
|
|
44
|
+
324: '0x1d17CBcF0D6D143135aE902365D2E5e2A16538D4', // zksync
|
|
45
|
+
338: '0xEb33dc5fac03833e132593659e1dE7256aB59794', // cronosTestnet
|
|
39
46
|
480: '0x79A02482A880bCE3F13e09Da970dC34db4CD24d1', // worldchain
|
|
47
|
+
998: '0x2B3370eE501B4a559b57D449569354196457D8Ab', // hyperliquidEvmTestnet
|
|
48
|
+
999: '0xb88339CB7199b77E23DB6E890353E22632Ba630f', // hyperEvm
|
|
40
49
|
1301: '0x31d0220469e10c4E71834a79b1f276d740d3768F', // unichainSepolia
|
|
41
50
|
1328: '0x4fCF1784B31630811181f670Aea7A7bEF803eaED', // seiTestnet
|
|
42
51
|
1329: '0xe15fC38F6D8c56aF07bbCBe3BAf5708A2Bf42392', // sei
|
|
52
|
+
1439: '0x0C382e685bbeeFE5d3d9C29e29E341fEE8E84C5d', // injectiveTestnet
|
|
53
|
+
1776: '0xa00C59fF5a080D2b954d0c75e46E22a0c371235a', // injective
|
|
54
|
+
2818: '0xCfb1186F4e93D60E60a8bDd997427D1F33bc372B', // morph
|
|
43
55
|
4801: '0x66145f38cBAC35Ca6F1Dfb4914dF98F1614aeA88', // worldchainSepolia
|
|
44
56
|
8453: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', // base
|
|
57
|
+
10143: '0x534b2f3A21130d7a60830c2Df862319e593943A3', // monadTestnet
|
|
45
58
|
42161: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', // arbitrum
|
|
59
|
+
42220: '0xcebA9300f2b948710d2653dD7B07f33A8B32118C', // celo
|
|
46
60
|
43113: '0x5425890298aed601595a70AB815c96711a31Bc65', // avalancheFuji
|
|
47
61
|
43114: '0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E', // avalanche
|
|
48
62
|
57054: '0xA4879Fed32Ecbef99399e5cbC247E533421C4eC6', // sonicBlazeTestnet
|
|
49
63
|
57073: '0x2D270e6886d130D724215A266106e6832161EAEd', // ink
|
|
50
64
|
59141: '0xFEce4462D57bD51A6A552365A011b95f0E16d9B7', // lineaSepolia
|
|
51
65
|
59144: '0x176211869cA2b568f2A7D4EE941E073a821EE1ff', // linea
|
|
66
|
+
64165: '0x0BA304580ee7c9a980CF72e55f5Ed2E9fd30Bc51', // sonicTestnet
|
|
52
67
|
80002: '0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582', // polygonAmoy
|
|
53
68
|
81224: '0xd996633a415985DBd7D6D12f4A4343E31f5037cf', // codex
|
|
54
69
|
84532: '0x036CbD53842c5426634e7929541eC2318f3dCF7e', // baseSepolia
|
|
70
|
+
98866: '0x222365EF19F7947e5484218551B56bb3965Aa7aF', // plumeMainnet
|
|
71
|
+
98867: '0xcB5f30e335672893c7eb944B374c196392C19D18', // plumeSepolia
|
|
55
72
|
421614: '0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d', // arbitrumSepolia
|
|
56
73
|
763373: '0xFabab97dCE620294D2B0b0e46C68964e326300Ac', // inkSepolia
|
|
57
74
|
812242: '0x6d7f141b6819C2c9CC2f818e6ad549E7Ca090F8f', // codexTestnet
|
|
58
75
|
5042002: '0x3600000000000000000000000000000000000000', // arcTestnet
|
|
76
|
+
11142220: '0x01C5C0122039549AD1493B8220cABEdD739BC44E', // celoSepolia
|
|
59
77
|
11155111: '0x1c7D4B196Cb0C7B01d743Fbc6116a902379C7238', // sepolia
|
|
60
78
|
11155420: '0x5fd84259d66Cd46123540766Be93DFE6D43130D7', // optimismSepolia
|
|
61
79
|
},
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineToken } from '../defineToken.js'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* [USYC](https://developers.circle.com/tokenized/usyc/overview) token, with
|
|
5
|
+
* canonical contract addresses across supported EVM chains.
|
|
6
|
+
*
|
|
7
|
+
* Pass to a Client's `tokens` array, call with a chain id to produce a
|
|
8
|
+
* [token config](/docs/chains/tokens), or read the metadata and `addresses`
|
|
9
|
+
* map directly.
|
|
10
|
+
*/
|
|
11
|
+
export const usyc = /*#__PURE__*/ defineToken({
|
|
12
|
+
addresses: {
|
|
13
|
+
1: '0x136471a34f6ef19fE571EFFC1CA711fdb8E49f2b', // mainnet
|
|
14
|
+
56: '0x8D0fA28f221eB5735BC71d3a0Da67EE5bC821311', // bsc
|
|
15
|
+
97: '0x109656Aba6F175c634c63C9874f29CeAAAB8E606', // bscTestnet
|
|
16
|
+
5042002: '0xe9185F0c5F296Ed1797AaE4238D26CCaBEadb86C', // arcTestnet
|
|
17
|
+
11155111: '0x38D3A3f8717F4DB1CcB4Ad7D8C755919440848A3', // sepolia
|
|
18
|
+
},
|
|
19
|
+
currency: 'USD',
|
|
20
|
+
decimals: 6,
|
|
21
|
+
name: 'US Yield Coin',
|
|
22
|
+
symbol: 'USYC',
|
|
23
|
+
})
|
package/tokens/index.ts
CHANGED
|
@@ -5,9 +5,11 @@ export { betausd } from './definitions/betausd.js'
|
|
|
5
5
|
export { brla } from './definitions/brla.js'
|
|
6
6
|
export { cbbtc } from './definitions/cbbtc.js'
|
|
7
7
|
export { chfau } from './definitions/chfau.js'
|
|
8
|
+
export { cirbtc } from './definitions/cirbtc.js'
|
|
8
9
|
export { cusd } from './definitions/cusd.js'
|
|
9
10
|
export { dlusd } from './definitions/dlusd.js'
|
|
10
11
|
export { eurau } from './definitions/eurau.js'
|
|
12
|
+
export { eurc } from './definitions/eurc.js'
|
|
11
13
|
export { eurce } from './definitions/eurce.js'
|
|
12
14
|
export { frxusd } from './definitions/frxusd.js'
|
|
13
15
|
export { gbpa } from './definitions/gbpa.js'
|
|
@@ -28,4 +30,6 @@ export { usdc } from './definitions/usdc.js'
|
|
|
28
30
|
export { usdce } from './definitions/usdce.js'
|
|
29
31
|
export { usde } from './definitions/usde.js'
|
|
30
32
|
export { usdt0 } from './definitions/usdt0.js'
|
|
33
|
+
export { usyc } from './definitions/usyc.js'
|
|
31
34
|
export { wsrusd } from './definitions/wsrusd.js'
|
|
35
|
+
export { tokens } from './sets.js'
|
package/tokens/sets.ts
ADDED
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Generated with `pnpm gen:tokenlist`. Do not modify manually.
|
|
2
|
+
|
|
3
|
+
import type { Tokens } from './defineToken.js'
|
|
4
|
+
import { alphausd } from './definitions/alphausd.js'
|
|
5
|
+
import { betausd } from './definitions/betausd.js'
|
|
6
|
+
import { brla } from './definitions/brla.js'
|
|
7
|
+
import { cbbtc } from './definitions/cbbtc.js'
|
|
8
|
+
import { chfau } from './definitions/chfau.js'
|
|
9
|
+
import { cirbtc } from './definitions/cirbtc.js'
|
|
10
|
+
import { cusd } from './definitions/cusd.js'
|
|
11
|
+
import { dlusd } from './definitions/dlusd.js'
|
|
12
|
+
import { eurau } from './definitions/eurau.js'
|
|
13
|
+
import { eurc } from './definitions/eurc.js'
|
|
14
|
+
import { eurce } from './definitions/eurce.js'
|
|
15
|
+
import { frxusd } from './definitions/frxusd.js'
|
|
16
|
+
import { gbpa } from './definitions/gbpa.js'
|
|
17
|
+
import { gusd } from './definitions/gusd.js'
|
|
18
|
+
import { iusd } from './definitions/iusd.js'
|
|
19
|
+
import { pathusd } from './definitions/pathusd.js'
|
|
20
|
+
import { reusd } from './definitions/reusd.js'
|
|
21
|
+
import { rusd } from './definitions/rusd.js'
|
|
22
|
+
import { sbc } from './definitions/sbc.js'
|
|
23
|
+
import { siusd } from './definitions/siusd.js'
|
|
24
|
+
import { stcusd } from './definitions/stcusd.js'
|
|
25
|
+
import { susde } from './definitions/susde.js'
|
|
26
|
+
import { syrupusdc } from './definitions/syrupusdc.js'
|
|
27
|
+
import { thetausd } from './definitions/thetausd.js'
|
|
28
|
+
import { usd1 } from './definitions/usd1.js'
|
|
29
|
+
import { usdb } from './definitions/usdb.js'
|
|
30
|
+
import { usdc } from './definitions/usdc.js'
|
|
31
|
+
import { usdce } from './definitions/usdce.js'
|
|
32
|
+
import { usde } from './definitions/usde.js'
|
|
33
|
+
import { usdt0 } from './definitions/usdt0.js'
|
|
34
|
+
import { usyc } from './definitions/usyc.js'
|
|
35
|
+
import { wsrusd } from './definitions/wsrusd.js'
|
|
36
|
+
|
|
37
|
+
/** Every token definition. */
|
|
38
|
+
const all = [
|
|
39
|
+
alphausd,
|
|
40
|
+
betausd,
|
|
41
|
+
brla,
|
|
42
|
+
cbbtc,
|
|
43
|
+
chfau,
|
|
44
|
+
cirbtc,
|
|
45
|
+
cusd,
|
|
46
|
+
dlusd,
|
|
47
|
+
eurau,
|
|
48
|
+
eurc,
|
|
49
|
+
eurce,
|
|
50
|
+
frxusd,
|
|
51
|
+
gbpa,
|
|
52
|
+
gusd,
|
|
53
|
+
iusd,
|
|
54
|
+
pathusd,
|
|
55
|
+
reusd,
|
|
56
|
+
rusd,
|
|
57
|
+
sbc,
|
|
58
|
+
siusd,
|
|
59
|
+
stcusd,
|
|
60
|
+
susde,
|
|
61
|
+
syrupusdc,
|
|
62
|
+
thetausd,
|
|
63
|
+
usd1,
|
|
64
|
+
usdb,
|
|
65
|
+
usdc,
|
|
66
|
+
usdce,
|
|
67
|
+
usde,
|
|
68
|
+
usdt0,
|
|
69
|
+
usyc,
|
|
70
|
+
wsrusd,
|
|
71
|
+
] as const satisfies Tokens
|
|
72
|
+
|
|
73
|
+
/** Tokens flagged as popular. */
|
|
74
|
+
const popular = [usdc] as const satisfies Tokens
|
|
75
|
+
|
|
76
|
+
/** All tokens available on Tempo chains. */
|
|
77
|
+
const tempo = [
|
|
78
|
+
alphausd,
|
|
79
|
+
betausd,
|
|
80
|
+
brla,
|
|
81
|
+
cbbtc,
|
|
82
|
+
chfau,
|
|
83
|
+
cusd,
|
|
84
|
+
dlusd,
|
|
85
|
+
eurau,
|
|
86
|
+
eurce,
|
|
87
|
+
frxusd,
|
|
88
|
+
gbpa,
|
|
89
|
+
gusd,
|
|
90
|
+
iusd,
|
|
91
|
+
pathusd,
|
|
92
|
+
reusd,
|
|
93
|
+
rusd,
|
|
94
|
+
sbc,
|
|
95
|
+
siusd,
|
|
96
|
+
stcusd,
|
|
97
|
+
susde,
|
|
98
|
+
syrupusdc,
|
|
99
|
+
thetausd,
|
|
100
|
+
usd1,
|
|
101
|
+
usdb,
|
|
102
|
+
usdce,
|
|
103
|
+
usde,
|
|
104
|
+
usdt0,
|
|
105
|
+
wsrusd,
|
|
106
|
+
] as const satisfies Tokens
|
|
107
|
+
|
|
108
|
+
/** Curated token sets that can be passed to a Client's `tokens` property. */
|
|
109
|
+
export const tokens = { all, popular, tempo }
|
|
@@ -4,6 +4,10 @@ import {
|
|
|
4
4
|
type InvalidHexValueErrorType,
|
|
5
5
|
RlpDepthLimitExceededError,
|
|
6
6
|
type RlpDepthLimitExceededErrorType,
|
|
7
|
+
RlpListBoundaryExceededError,
|
|
8
|
+
type RlpListBoundaryExceededErrorType,
|
|
9
|
+
RlpTrailingBytesError,
|
|
10
|
+
type RlpTrailingBytesErrorType,
|
|
7
11
|
} from '../../errors/encoding.js'
|
|
8
12
|
import type { ErrorType } from '../../errors/utils.js'
|
|
9
13
|
import type { ByteArray, Hex } from '../../types/misc.js'
|
|
@@ -31,6 +35,7 @@ export type FromRlpErrorType =
|
|
|
31
35
|
| HexToBytesErrorType
|
|
32
36
|
| InvalidHexValueErrorType
|
|
33
37
|
| RlpDepthLimitExceededErrorType
|
|
38
|
+
| RlpTrailingBytesErrorType
|
|
34
39
|
| ErrorType
|
|
35
40
|
|
|
36
41
|
export function fromRlp<to extends To = 'hex'>(
|
|
@@ -51,6 +56,12 @@ export function fromRlp<to extends To = 'hex'>(
|
|
|
51
56
|
})
|
|
52
57
|
const result = fromRlpCursor(cursor, to)
|
|
53
58
|
|
|
59
|
+
// RLP payloads encode exactly one item (Yellow Paper, Appendix B).
|
|
60
|
+
if (cursor.position < cursor.bytes.length)
|
|
61
|
+
throw new RlpTrailingBytesError({
|
|
62
|
+
count: cursor.bytes.length - cursor.position,
|
|
63
|
+
})
|
|
64
|
+
|
|
54
65
|
return result as FromRlpReturnType<to>
|
|
55
66
|
}
|
|
56
67
|
|
|
@@ -105,7 +116,7 @@ function readLength(cursor: Cursor, prefix: number, offset: number) {
|
|
|
105
116
|
throw new BaseError('Invalid RLP prefix')
|
|
106
117
|
}
|
|
107
118
|
|
|
108
|
-
type ReadListErrorType = ErrorType
|
|
119
|
+
type ReadListErrorType = RlpListBoundaryExceededErrorType | ErrorType
|
|
109
120
|
|
|
110
121
|
function readList<to extends To>(
|
|
111
122
|
cursor: Cursor,
|
|
@@ -117,5 +128,11 @@ function readList<to extends To>(
|
|
|
117
128
|
const value: FromRlpReturnType<to>[] = []
|
|
118
129
|
while (cursor.position - position < length)
|
|
119
130
|
value.push(fromRlpCursor(cursor, to, recursiveDepth))
|
|
131
|
+
// Items must consume exactly the declared list length.
|
|
132
|
+
if (cursor.position - position !== length)
|
|
133
|
+
throw new RlpListBoundaryExceededError({
|
|
134
|
+
consumed: cursor.position - position,
|
|
135
|
+
declared: length,
|
|
136
|
+
})
|
|
120
137
|
return value
|
|
121
138
|
}
|