@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.
Files changed (97) hide show
  1. package/CHANGELOG.md +30 -0
  2. package/lib/adapters/etherscan.d.ts.map +1 -1
  3. package/lib/adapters/etherscan.js +2 -1
  4. package/lib/adapters/etherscan.js.map +1 -1
  5. package/lib/config.d.ts +4 -0
  6. package/lib/config.d.ts.map +1 -1
  7. package/lib/config.js.map +1 -1
  8. package/lib/errors.d.ts +6 -0
  9. package/lib/errors.d.ts.map +1 -1
  10. package/lib/errors.js +12 -1
  11. package/lib/errors.js.map +1 -1
  12. package/lib/logic/getBlock.js +2 -2
  13. package/lib/logic/getBlock.js.map +1 -1
  14. package/lib/network/explorer/etherscan.d.ts.map +1 -1
  15. package/lib/network/explorer/etherscan.js +38 -24
  16. package/lib/network/explorer/etherscan.js.map +1 -1
  17. package/lib/network/explorer/ledger.d.ts.map +1 -1
  18. package/lib/network/explorer/ledger.js +6 -4
  19. package/lib/network/explorer/ledger.js.map +1 -1
  20. package/lib/network/node/rpc.common.d.ts.map +1 -1
  21. package/lib/network/node/rpc.common.js +30 -6
  22. package/lib/network/node/rpc.common.js.map +1 -1
  23. package/lib/network/node/types.d.ts +3 -1
  24. package/lib/network/node/types.d.ts.map +1 -1
  25. package/lib/network/node/types.js.map +1 -1
  26. package/lib/network/withRetries.d.ts.map +1 -1
  27. package/lib/network/withRetries.js +13 -0
  28. package/lib/network/withRetries.js.map +1 -1
  29. package/lib/types/etherscan.d.ts +2 -0
  30. package/lib/types/etherscan.d.ts.map +1 -1
  31. package/lib/utils.d.ts +0 -2
  32. package/lib/utils.d.ts.map +1 -1
  33. package/lib/utils.js +0 -30
  34. package/lib/utils.js.map +1 -1
  35. package/lib-es/adapters/etherscan.d.ts.map +1 -1
  36. package/lib-es/adapters/etherscan.js +2 -1
  37. package/lib-es/adapters/etherscan.js.map +1 -1
  38. package/lib-es/config.d.ts +4 -0
  39. package/lib-es/config.d.ts.map +1 -1
  40. package/lib-es/config.js.map +1 -1
  41. package/lib-es/errors.d.ts +6 -0
  42. package/lib-es/errors.d.ts.map +1 -1
  43. package/lib-es/errors.js +10 -0
  44. package/lib-es/errors.js.map +1 -1
  45. package/lib-es/logic/getBlock.js +2 -2
  46. package/lib-es/logic/getBlock.js.map +1 -1
  47. package/lib-es/network/explorer/etherscan.d.ts.map +1 -1
  48. package/lib-es/network/explorer/etherscan.js +39 -25
  49. package/lib-es/network/explorer/etherscan.js.map +1 -1
  50. package/lib-es/network/explorer/ledger.d.ts.map +1 -1
  51. package/lib-es/network/explorer/ledger.js +7 -5
  52. package/lib-es/network/explorer/ledger.js.map +1 -1
  53. package/lib-es/network/node/rpc.common.d.ts.map +1 -1
  54. package/lib-es/network/node/rpc.common.js +30 -6
  55. package/lib-es/network/node/rpc.common.js.map +1 -1
  56. package/lib-es/network/node/types.d.ts +3 -1
  57. package/lib-es/network/node/types.d.ts.map +1 -1
  58. package/lib-es/network/node/types.js.map +1 -1
  59. package/lib-es/network/withRetries.d.ts.map +1 -1
  60. package/lib-es/network/withRetries.js +10 -0
  61. package/lib-es/network/withRetries.js.map +1 -1
  62. package/lib-es/types/etherscan.d.ts +2 -0
  63. package/lib-es/types/etherscan.d.ts.map +1 -1
  64. package/lib-es/utils.d.ts +0 -2
  65. package/lib-es/utils.d.ts.map +1 -1
  66. package/lib-es/utils.js +0 -28
  67. package/lib-es/utils.js.map +1 -1
  68. package/package.json +1 -1
  69. package/src/adapters/etherscan.test.ts +67 -0
  70. package/src/adapters/etherscan.ts +3 -1
  71. package/src/api/getBlock.integ.test.ts +1 -1
  72. package/src/api/index.avalanche_c_chain_fuji.integ.test.ts +1 -1
  73. package/src/api/index.integ.test.ts +7 -12
  74. package/src/api/index.linea.integ.test.ts +1 -1
  75. package/src/api/index.monad_testnet.integ.test.ts +1 -1
  76. package/src/api/index.optimism.integ.test.ts +30 -1
  77. package/src/api/index.rsk.integ.test.ts +1 -1
  78. package/src/api/index.shape.integ.test.ts +1 -1
  79. package/src/api/index.somnia.integ.test.ts +40 -0
  80. package/src/api/index.zksync.integ.test.ts +42 -0
  81. package/src/config.ts +4 -0
  82. package/src/errors.ts +10 -0
  83. package/src/logic/getBlock.test.ts +49 -0
  84. package/src/logic/getBlock.ts +3 -2
  85. package/src/network/explorer/etherscan.test.ts +407 -91
  86. package/src/network/explorer/etherscan.ts +69 -33
  87. package/src/network/explorer/ledger.test.ts +24 -13
  88. package/src/network/explorer/ledger.ts +27 -22
  89. package/src/network/node/rpc.common.ts +35 -6
  90. package/src/network/node/rpc.test.ts +73 -0
  91. package/src/network/node/types.ts +10 -1
  92. package/src/network/withRetries.test.ts +63 -0
  93. package/src/network/withRetries.ts +12 -0
  94. package/src/staking/validators.integ.test.ts +1 -1
  95. package/src/types/etherscan.ts +2 -0
  96. package/src/utils.test.ts +0 -86
  97. 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
- }