Skip to content

Commit

Permalink
chore(get-router-state): add human readable chain id
Browse files Browse the repository at this point in the history
  • Loading branch information
gitmp01 committed Apr 3, 2024
1 parent 69402c8 commit c8a565c
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions lib/get-router-state.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const {
flatten,
toPairs,
fromPairs,
mergeAll,
} = require('ramda')
/* eslint-disable-next-line no-shadow */
const ethers = require('ethers')
Expand Down Expand Up @@ -34,6 +35,7 @@ const VAULT_DICTIONARY = 'vaultDictionary'
const TOKEN_INFOS_STATE_KEY = 'tokenInfos'
const FEE_CONTRACT_STATE_KEY = 'feeContract'
const ORIGIN_CHAIN_ID_FXN = 'ORIGIN_CHAIN_ID'
const ORIGIN_CHAIN_STATE_KEY = 'originChain'
const CHAIN_ID_NAMES = keys(metadataChainIds)
const GLOBAL_MIN_FEE_STATE_KEY = 'globalMinFee'
const SAFE_VAULT_ADDRESS_STATE_KEY = 'safeVault'
Expand Down Expand Up @@ -193,9 +195,9 @@ const getTokenDetailsFromContract = (_tokenContract, _maybeAddress = null) =>
name: normalizeName(_name),
address: _tokenContract.address,
symbol: normalizeSymbol(_symbol),
originChainId: _originChainIdHex,
[ORIGIN_CHAIN_ID_STATE_KEY]: _originChainIdHex,
totalSupply: _totalSupply.toString(),
originChain: getHumanReadableOriginChainIdFromHex(_originChainIdHex)
[ORIGIN_CHAIN_STATE_KEY]: getHumanReadableOriginChainIdFromHex(_originChainIdHex)
}

if (_maybeBalance === false)
Expand Down Expand Up @@ -342,7 +344,10 @@ const getSafeVaultTokenBalancesAndAddToState = _state =>
const attachOriginChainId = curry((_signer, _keyValuePair) =>
Promise.resolve(getErc777Contract(_signer, _keyValuePair[1].address))
.then(_contract => _contract.ORIGIN_CHAIN_ID())
.then(_originChainId => assoc(ORIGIN_CHAIN_ID_STATE_KEY, _originChainId, _keyValuePair[1]))
.then(_originChainId => mergeAll([_keyValuePair[1], {
[ORIGIN_CHAIN_ID_STATE_KEY]: _originChainId,
[ORIGIN_CHAIN_STATE_KEY]: getHumanReadableOriginChainIdFromHex(_originChainId),
}]))
.then(_newObj => [_keyValuePair[0], _newObj])
)

Expand Down

0 comments on commit c8a565c

Please sign in to comment.