@ledgerhq/coin-evm 5.3.4 → 5.3.9
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/lib/adapters/etherscan.d.ts.map +1 -1
- package/lib/adapters/etherscan.js +2 -1
- package/lib/adapters/etherscan.js.map +1 -1
- package/lib/config.d.ts +4 -0
- package/lib/config.d.ts.map +1 -1
- package/lib/config.js.map +1 -1
- package/lib/errors.d.ts +6 -0
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +12 -1
- package/lib/errors.js.map +1 -1
- package/lib/logic/getBlock.js +2 -2
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/network/explorer/etherscan.d.ts.map +1 -1
- package/lib/network/explorer/etherscan.js +38 -24
- package/lib/network/explorer/etherscan.js.map +1 -1
- package/lib/network/explorer/ledger.d.ts.map +1 -1
- package/lib/network/explorer/ledger.js +6 -4
- package/lib/network/explorer/ledger.js.map +1 -1
- package/lib/network/node/rpc.common.d.ts.map +1 -1
- package/lib/network/node/rpc.common.js +30 -6
- package/lib/network/node/rpc.common.js.map +1 -1
- package/lib/network/node/types.d.ts +3 -1
- package/lib/network/node/types.d.ts.map +1 -1
- package/lib/network/node/types.js.map +1 -1
- package/lib/network/withRetries.d.ts.map +1 -1
- package/lib/network/withRetries.js +13 -0
- package/lib/network/withRetries.js.map +1 -1
- package/lib/types/etherscan.d.ts +2 -0
- package/lib/types/etherscan.d.ts.map +1 -1
- package/lib/utils.d.ts +0 -2
- package/lib/utils.d.ts.map +1 -1
- package/lib/utils.js +0 -30
- package/lib/utils.js.map +1 -1
- package/lib-es/adapters/etherscan.d.ts.map +1 -1
- package/lib-es/adapters/etherscan.js +2 -1
- package/lib-es/adapters/etherscan.js.map +1 -1
- package/lib-es/config.d.ts +4 -0
- package/lib-es/config.d.ts.map +1 -1
- package/lib-es/config.js.map +1 -1
- package/lib-es/errors.d.ts +6 -0
- package/lib-es/errors.d.ts.map +1 -1
- package/lib-es/errors.js +10 -0
- package/lib-es/errors.js.map +1 -1
- package/lib-es/logic/getBlock.js +2 -2
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
- package/lib-es/network/explorer/etherscan.js +39 -25
- package/lib-es/network/explorer/etherscan.js.map +1 -1
- package/lib-es/network/explorer/ledger.d.ts.map +1 -1
- package/lib-es/network/explorer/ledger.js +7 -5
- package/lib-es/network/explorer/ledger.js.map +1 -1
- package/lib-es/network/node/rpc.common.d.ts.map +1 -1
- package/lib-es/network/node/rpc.common.js +30 -6
- package/lib-es/network/node/rpc.common.js.map +1 -1
- package/lib-es/network/node/types.d.ts +3 -1
- package/lib-es/network/node/types.d.ts.map +1 -1
- package/lib-es/network/node/types.js.map +1 -1
- package/lib-es/network/withRetries.d.ts.map +1 -1
- package/lib-es/network/withRetries.js +10 -0
- package/lib-es/network/withRetries.js.map +1 -1
- package/lib-es/types/etherscan.d.ts +2 -0
- package/lib-es/types/etherscan.d.ts.map +1 -1
- package/lib-es/utils.d.ts +0 -2
- package/lib-es/utils.d.ts.map +1 -1
- package/lib-es/utils.js +0 -28
- package/lib-es/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/adapters/etherscan.test.ts +67 -0
- package/src/adapters/etherscan.ts +3 -1
- package/src/api/getBlock.integ.test.ts +1 -1
- package/src/api/index.avalanche_c_chain_fuji.integ.test.ts +1 -1
- package/src/api/index.integ.test.ts +7 -12
- package/src/api/index.linea.integ.test.ts +1 -1
- package/src/api/index.monad_testnet.integ.test.ts +1 -1
- package/src/api/index.optimism.integ.test.ts +30 -1
- package/src/api/index.rsk.integ.test.ts +1 -1
- package/src/api/index.shape.integ.test.ts +1 -1
- package/src/api/index.somnia.integ.test.ts +40 -0
- package/src/api/index.zksync.integ.test.ts +42 -0
- package/src/config.ts +4 -0
- package/src/errors.ts +10 -0
- package/src/logic/getBlock.test.ts +49 -0
- package/src/logic/getBlock.ts +3 -2
- package/src/network/explorer/etherscan.test.ts +407 -91
- package/src/network/explorer/etherscan.ts +69 -33
- package/src/network/explorer/ledger.test.ts +24 -13
- package/src/network/explorer/ledger.ts +27 -22
- package/src/network/node/rpc.common.ts +35 -6
- package/src/network/node/rpc.test.ts +73 -0
- package/src/network/node/types.ts +10 -1
- package/src/network/withRetries.test.ts +63 -0
- package/src/network/withRetries.ts +12 -0
- package/src/staking/validators.integ.test.ts +1 -1
- package/src/types/etherscan.ts +2 -0
- package/src/utils.test.ts +0 -86
- package/src/utils.ts +0 -41
package/src/utils.test.ts
CHANGED
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
import {
|
|
5
5
|
buildSmartContractDetails,
|
|
6
6
|
isSmartContractInput,
|
|
7
|
-
nftDisabled,
|
|
8
|
-
nftEnabled,
|
|
9
7
|
parseDecimalIntegerPart,
|
|
10
8
|
safeEncodeEIP55,
|
|
11
9
|
} from './utils'
|
|
@@ -88,87 +86,3 @@ describe('parseDecimalIntegerPart', () => {
|
|
|
88
86
|
}
|
|
89
87
|
)
|
|
90
88
|
})
|
|
91
|
-
|
|
92
|
-
describe('nftEnabled', () => {
|
|
93
|
-
beforeEach(() => {
|
|
94
|
-
process.env.NFT_CURRENCIES = JSON.stringify([])
|
|
95
|
-
})
|
|
96
|
-
|
|
97
|
-
it('should return false when currency is null or undefined', () => {
|
|
98
|
-
expect(nftEnabled(null)).toEqual(false)
|
|
99
|
-
expect(nftEnabled(undefined)).toEqual(false)
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it('should return false when NFT_CURRENCIES env does not include currency', () => {
|
|
103
|
-
process.env.NFT_CURRENCIES = JSON.stringify(['base', 'polygon'])
|
|
104
|
-
expect(nftEnabled('ethereum')).toEqual(false)
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
it('should return true when NFT_CURRENCIES env include currency', () => {
|
|
108
|
-
process.env.NFT_CURRENCIES = JSON.stringify(['base', 'ethereum', 'polygon'])
|
|
109
|
-
expect(nftEnabled('ethereum')).toEqual(true)
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
it.each([
|
|
113
|
-
'',
|
|
114
|
-
'word',
|
|
115
|
-
'a simple sentence',
|
|
116
|
-
'0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3',
|
|
117
|
-
'[]}',
|
|
118
|
-
'{ [] }',
|
|
119
|
-
])('should return false when NFT_CURRENCIES is not a valid JSON (%s)', (value) => {
|
|
120
|
-
process.env.NFT_CURRENCIES = value
|
|
121
|
-
expect(nftEnabled('ethereum')).toEqual(false)
|
|
122
|
-
})
|
|
123
|
-
|
|
124
|
-
it('should return false when NFT_CURRENCIES is not an array', () => {
|
|
125
|
-
// A new config not supported for example (feature flag like)
|
|
126
|
-
process.env.NFT_CURRENCIES = JSON.stringify({
|
|
127
|
-
enabled: true,
|
|
128
|
-
params: { families: ['ethereum'] },
|
|
129
|
-
})
|
|
130
|
-
expect(nftEnabled('ethereum')).toBe(false)
|
|
131
|
-
})
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
describe('nftDisabled', () => {
|
|
135
|
-
beforeEach(() => {
|
|
136
|
-
process.env.NFT_CURRENCIES = JSON.stringify([])
|
|
137
|
-
})
|
|
138
|
-
|
|
139
|
-
it('should return false when currency is null or undefined', () => {
|
|
140
|
-
expect(nftDisabled(null)).toEqual(true)
|
|
141
|
-
expect(nftDisabled(undefined)).toEqual(true)
|
|
142
|
-
})
|
|
143
|
-
|
|
144
|
-
it('should return true when NFT_CURRENCIES env does not include currency', () => {
|
|
145
|
-
process.env.NFT_CURRENCIES = JSON.stringify(['base', 'polygon'])
|
|
146
|
-
expect(nftDisabled('ethereum')).toEqual(true)
|
|
147
|
-
})
|
|
148
|
-
|
|
149
|
-
it('should return false when NFT_CURRENCIES env include currency', () => {
|
|
150
|
-
process.env.NFT_CURRENCIES = JSON.stringify(['base', 'ethereum', 'polygon'])
|
|
151
|
-
expect(nftDisabled('ethereum')).toEqual(false)
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
it.each([
|
|
155
|
-
'',
|
|
156
|
-
'word',
|
|
157
|
-
'a simple sentence',
|
|
158
|
-
'0x66c4371aE8FFeD2ec1c2EBbbcCfb7E494181E1E3',
|
|
159
|
-
'[]}',
|
|
160
|
-
'{ [] }',
|
|
161
|
-
])('should return true when NFT_CURRENCIES is not a valid JSON (%s)', (value) => {
|
|
162
|
-
process.env.NFT_CURRENCIES = value
|
|
163
|
-
expect(nftDisabled('ethereum')).toEqual(true)
|
|
164
|
-
})
|
|
165
|
-
|
|
166
|
-
it('should return true when NFT_CURRENCIES is not an array', () => {
|
|
167
|
-
// A new config not supported for example (feature flag like)
|
|
168
|
-
process.env.NFT_CURRENCIES = JSON.stringify({
|
|
169
|
-
enabled: true,
|
|
170
|
-
params: { families: ['ethereum'] },
|
|
171
|
-
})
|
|
172
|
-
expect(nftDisabled('ethereum')).toBe(true)
|
|
173
|
-
})
|
|
174
|
-
})
|
package/src/utils.ts
CHANGED
|
@@ -371,44 +371,3 @@ export type EvmStakingIntent = StakingTransactionIntent & {
|
|
|
371
371
|
export function isStakingIntent(intent: TransactionIntent): intent is EvmStakingIntent {
|
|
372
372
|
return intent.intentType === 'staking'
|
|
373
373
|
}
|
|
374
|
-
|
|
375
|
-
export function nftEnabled(currencyId: string | undefined | null): boolean {
|
|
376
|
-
let parsedNftCurrencies: unknown = undefined
|
|
377
|
-
if (process.env.NFT_CURRENCIES) {
|
|
378
|
-
try {
|
|
379
|
-
parsedNftCurrencies = JSON.parse(process.env.NFT_CURRENCIES)
|
|
380
|
-
} catch (error) {
|
|
381
|
-
log(
|
|
382
|
-
'EVM Family - utils.ts',
|
|
383
|
-
'Env variable NFT_CURRENCIES is malformed, expecting a string array',
|
|
384
|
-
{
|
|
385
|
-
envName: 'NFT_CURRENCIES',
|
|
386
|
-
envValue: process.env.NFT_CURRENCIES,
|
|
387
|
-
error,
|
|
388
|
-
}
|
|
389
|
-
)
|
|
390
|
-
|
|
391
|
-
return false
|
|
392
|
-
}
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
if (!Array.isArray(parsedNftCurrencies)) {
|
|
396
|
-
log(
|
|
397
|
-
'EVM Family - utils.ts',
|
|
398
|
-
'Env variable NFT_CURRENCIES is malformed, expecting a string array',
|
|
399
|
-
{
|
|
400
|
-
envName: 'NFT_CURRENCIES',
|
|
401
|
-
envValue: process.env.NFT_CURRENCIES,
|
|
402
|
-
}
|
|
403
|
-
)
|
|
404
|
-
|
|
405
|
-
return false
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
return Boolean(currencyId && parsedNftCurrencies.includes(currencyId))
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
// Simple utility function, to ease reading code
|
|
412
|
-
export function nftDisabled(currencyId: string | undefined | null): boolean {
|
|
413
|
-
return !nftEnabled(currencyId)
|
|
414
|
-
}
|