@exodus/ethereum-api 8.22.0 → 8.22.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 CHANGED
@@ -3,6 +3,24 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [8.22.2](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.22.1...@exodus/ethereum-api@8.22.2) (2024-12-04)
7
+
8
+ **Note:** Version bump only for package @exodus/ethereum-api
9
+
10
+
11
+
12
+
13
+
14
+ ## [8.22.1](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.22.0...@exodus/ethereum-api@8.22.1) (2024-12-03)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+
20
+ * fix: increase gasLimit estimation when from or to address are unknown (#4594)
21
+
22
+
23
+
6
24
  ## [8.22.0](https://github.com/ExodusMovement/assets/compare/@exodus/ethereum-api@8.21.3...@exodus/ethereum-api@8.22.0) (2024-12-02)
7
25
 
8
26
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@exodus/ethereum-api",
3
- "version": "8.22.0",
3
+ "version": "8.22.2",
4
4
  "description": "Transaction monitors, fee monitors, RPC with the blockchain node, and other networking code for Ethereum and EVM-based blockchains",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -64,5 +64,5 @@
64
64
  "type": "git",
65
65
  "url": "git+https://github.com/ExodusMovement/assets.git"
66
66
  },
67
- "gitHead": "9888fd7b7356fd52f0bf92e505071565c8fa19ce"
67
+ "gitHead": "94b6b798534f6b0587f6940248ab612513bfc34f"
68
68
  }
@@ -263,6 +263,7 @@ export const createAssetFactory = ({
263
263
  getSupportedPurposes: () => [44],
264
264
  getTokens,
265
265
  hasFeature: (feature) => !!features[feature], // @deprecated use api.features instead
266
+ privateKeyEncodingDefinition: { encoding: 'hex', prefix: '0x' },
266
267
  sendTx,
267
268
  signTx: ({ unsignedTx, privateKey, signer }) =>
268
269
  signer
@@ -7,6 +7,9 @@ import * as ErrorWrapper from './error-wrapper.js'
7
7
  import { getServer, getServerByName } from './exodus-eth-server/index.js'
8
8
  import { fromHexToString } from './number-utils.js'
9
9
 
10
+ export const FORWARDER_CONTRACT_CODE =
11
+ '0x5836818037808036817364b29dc43e817817cf77468c8dda63d98ce08fb25af43d91908282803e602b57fd5bf3'
12
+
10
13
  export async function isContract(baseAssetName, address) {
11
14
  return getServerByName(baseAssetName).isContract(address)
12
15
  }
@@ -22,11 +25,9 @@ export const isContractAddressCached = memoizeLruCache(
22
25
  )
23
26
 
24
27
  export async function isForwarderContract({ asset, address }) {
25
- const contractCode = await getServer(asset).getCode(address)
26
- return (
27
- contractCode ===
28
- '0x5836818037808036817364b29dc43e817817cf77468c8dda63d98ce08fb25af43d91908282803e602b57fd5bf3'
29
- )
28
+ const server = getServer(asset)
29
+ const contractCode = await server.getCode(address)
30
+ return contractCode === FORWARDER_CONTRACT_CODE
30
31
  }
31
32
 
32
33
  export const isForwarderContractCached = memoizeLruCache(
@@ -4,7 +4,7 @@ import BN from 'bn.js'
4
4
 
5
5
  import { estimateGas, isContractAddressCached } from './eth-like-util.js'
6
6
 
7
- const EXTRA_PERCENTAGE = 20
7
+ export const EXTRA_PERCENTAGE = 20
8
8
 
9
9
  // 16 gas per non-zero byte (4 gas per zero byte) of "transaction input data"
10
10
  const GAS_PER_NON_ZERO_BYTE = 16
@@ -1,7 +1,7 @@
1
1
  import assert from 'minimalistic-assert'
2
2
 
3
3
  import { isForwarderContractCached } from './eth-like-util.js'
4
- import { fetchGasLimit, resolveDefaultTxInput } from './gas-estimation.js'
4
+ import { EXTRA_PERCENTAGE, fetchGasLimit, resolveDefaultTxInput } from './gas-estimation.js'
5
5
  import { getFeeFactory } from './get-fee.js'
6
6
  import { getNftArguments } from './nft-utils.js'
7
7
 
@@ -13,19 +13,40 @@ const FIXED_TRANSFER_GAS_LIMIT_ASSETS = new Set([
13
13
  'geminidollar',
14
14
  ])
15
15
 
16
- async function resolveExtraPercentage({ asset, toAddress }) {
16
+ const UNKNOWN_ADDRESS_EXTRA_PERCENTAGE = {
17
+ usdt_bsc_ddedf0f8: 80,
18
+ }
19
+
20
+ export async function resolveExtraPercentage({ asset, fromAddress, toAddress }) {
21
+ if (asset.baseAsset.estimateL1DataFee) {
22
+ return 100
23
+ }
24
+
17
25
  const isToken = asset.name !== asset.baseAsset.name
26
+
27
+ const isFixedGasLimitToken = isToken && FIXED_TRANSFER_GAS_LIMIT_ASSETS.has(asset.name)
28
+
29
+ if (isFixedGasLimitToken) {
30
+ return 0
31
+ }
32
+
18
33
  // calling forwarder contracts with a bumped gas limit causes 'Out Of Gas' error on chain
19
34
  const hasForwarderContract =
20
35
  !isToken && toAddress ? await isForwarderContractCached({ asset, address: toAddress }) : false
21
36
 
22
- return asset.baseAsset.estimateL1DataFee
23
- ? 100
24
- : (isToken && FIXED_TRANSFER_GAS_LIMIT_ASSETS.has(asset.name)) || hasForwarderContract
25
- ? 0
26
- : undefined
37
+ if (hasForwarderContract) {
38
+ return 0
39
+ }
40
+
41
+ if (!fromAddress || !toAddress) {
42
+ return UNKNOWN_ADDRESS_EXTRA_PERCENTAGE[asset.name] ?? EXTRA_PERCENTAGE
43
+ }
44
+
45
+ return EXTRA_PERCENTAGE
27
46
  }
28
47
 
48
+ const ARBITRARY_ADDRESS = '0xffffffffffffffffffffffffffffffffffffffff'
49
+
29
50
  const getFeeAsyncFactory = ({
30
51
  assetClientInterface,
31
52
  gasLimit: defaultGasLimit,
@@ -37,8 +58,8 @@ const getFeeAsyncFactory = ({
37
58
  return async ({
38
59
  nft,
39
60
  asset,
40
- fromAddress = '0xffffffffffffffffffffffffffffffffffffffff', // sending from a random address
41
- toAddress = '0xffffffffffffffffffffffffffffffffffffffff', // sending to a random address,
61
+ fromAddress: providedFromAddress,
62
+ toAddress: providedToAddress,
42
63
  amount,
43
64
  bip70,
44
65
  txInput: txInputPram,
@@ -49,16 +70,24 @@ const getFeeAsyncFactory = ({
49
70
  gasLimit: providedGasLimit,
50
71
  isRbfAllowed = true, // Destkop, isRbfAllowed=true when advanced panel is on
51
72
  }) => {
73
+ const fromAddress = providedFromAddress || ARBITRARY_ADDRESS // sending from a random address
74
+ const toAddress = providedToAddress || ARBITRARY_ADDRESS // sending to a random address,
75
+
52
76
  const resolveGasLimit = async () => {
53
77
  if (nft) {
54
78
  return getNftArguments({ asset, nft, fromAddress, toAddress })
55
79
  }
56
80
 
57
81
  if (!amount) amount = asset.currency.ZERO
58
- const extraPercentage = await resolveExtraPercentage({ asset, toAddress })
59
82
  const txInput = txInputPram || resolveDefaultTxInput({ asset, toAddress, amount })
60
83
  if (providedGasLimit) return { gasLimit: providedGasLimit, txInput }
61
84
 
85
+ const extraPercentage = await resolveExtraPercentage({
86
+ asset,
87
+ fromAddress: providedFromAddress,
88
+ toAddress: providedToAddress,
89
+ })
90
+
62
91
  const gasLimit = await fetchGasLimit({
63
92
  asset,
64
93
  fromAddress,