Skip to content

Commit

Permalink
Merge branch 'develop' into 7526
Browse files Browse the repository at this point in the history
  • Loading branch information
NeOMakinG authored Aug 15, 2024
2 parents 600a4f2 + 98d1cb5 commit 689960b
Show file tree
Hide file tree
Showing 55 changed files with 3,626 additions and 3,097 deletions.
10 changes: 5 additions & 5 deletions .env.app
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,20 @@ REACT_APP_UNCHAINED_BITCOINCASH_HTTP_URL=https://api.bitcoincash.shapeshift.com
REACT_APP_UNCHAINED_BITCOINCASH_WS_URL=wss://api.bitcoincash.shapeshift.com
REACT_APP_UNCHAINED_COSMOS_HTTP_URL=https://api.cosmos.shapeshift.com
REACT_APP_UNCHAINED_COSMOS_WS_URL=wss://api.cosmos.shapeshift.com
REACT_APP_UNCHAINED_THORCHAIN_HTTP_URL=https://api.thorchain.shapeshift.com
REACT_APP_UNCHAINED_THORCHAIN_WS_URL=wss://api.thorchain.shapeshift.com
REACT_APP_UNCHAINED_THORCHAIN_HTTP_URL=https://dev-api.thorchain.shapeshift.com
REACT_APP_UNCHAINED_THORCHAIN_WS_URL=wss://dev-api.thorchain.shapeshift.com

# nodes
REACT_APP_ETHEREUM_NODE_URL=https://api.ethereum.shapeshift.com/api/v1/jsonrpc
REACT_APP_AVALANCHE_NODE_URL=https://api.avalanche.shapeshift.com/api/v1/jsonrpc
REACT_APP_OPTIMISM_NODE_URL=https://daemon.optimism.shapeshift.com
REACT_APP_OPTIMISM_NODE_URL=https://api.optimism.shapeshift.com/api/v1/jsonrpc
REACT_APP_BNBSMARTCHAIN_NODE_URL=https://api.bnbsmartchain.shapeshift.com/api/v1/jsonrpc
REACT_APP_POLYGON_NODE_URL=https://api.polygon.shapeshift.com/api/v1/jsonrpc
REACT_APP_GNOSIS_NODE_URL=https://daemon.gnosis.shapeshift.com
REACT_APP_ARBITRUM_NODE_URL=https://api.arbitrum.shapeshift.com/api/v1/jsonrpc
REACT_APP_ARBITRUM_NOVA_NODE_URL=https://api.arbitrum-nova.shapeshift.com/api/v1/jsonrpc
REACT_APP_BASE_NODE_URL=https://api.base.shapeshift.com/api/v1/jsonrpc
REACT_APP_THORCHAIN_NODE_URL=https://daemon.thorchain.shapeshift.com
REACT_APP_THORCHAIN_NODE_URL=https://dev-daemon.thorchain.shapeshift.com

# thorchain
REACT_APP_MIDGARD_URL=https://indexer.thorchain.shapeshift.com/v2
REACT_APP_MIDGARD_URL=https://dev-indexer.thorchain.shapeshift.com/v2
10 changes: 5 additions & 5 deletions .env.private
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ REACT_APP_UNCHAINED_BITCOINCASH_HTTP_URL=https://api.bitcoincash.shapeshift.com
REACT_APP_UNCHAINED_BITCOINCASH_WS_URL=wss://api.bitcoincash.shapeshift.com
REACT_APP_UNCHAINED_COSMOS_HTTP_URL=https://api.cosmos.shapeshift.com
REACT_APP_UNCHAINED_COSMOS_WS_URL=wss://api.cosmos.shapeshift.com
REACT_APP_UNCHAINED_THORCHAIN_HTTP_URL=https://api.thorchain.shapeshift.com
REACT_APP_UNCHAINED_THORCHAIN_WS_URL=wss://api.thorchain.shapeshift.com
REACT_APP_UNCHAINED_THORCHAIN_HTTP_URL=https://dev-api.thorchain.shapeshift.com
REACT_APP_UNCHAINED_THORCHAIN_WS_URL=wss://dev-api.thorchain.shapeshift.com

# nodes
REACT_APP_ETHEREUM_NODE_URL=https://api.ethereum.shapeshift.com/api/v1/jsonrpc
REACT_APP_AVALANCHE_NODE_URL=https://api.avalanche.shapeshift.com/api/v1/jsonrpc
REACT_APP_OPTIMISM_NODE_URL=https://daemon.optimism.shapeshift.com
REACT_APP_OPTIMISM_NODE_URL=https://api.optimism.shapeshift.com/api/v1/jsonrpc
REACT_APP_BNBSMARTCHAIN_NODE_URL=https://api.bnbsmartchain.shapeshift.com/api/v1/jsonrpc
REACT_APP_POLYGON_NODE_URL=https://api.polygon.shapeshift.com/api/v1/jsonrpc
REACT_APP_GNOSIS_NODE_URL=https://daemon.gnosis.shapeshift.com
REACT_APP_ARBITRUM_NODE_URL=https://api.arbitrum.shapeshift.com/api/v1/jsonrpc
REACT_APP_ARBITRUM_NOVA_NODE_URL=https://api.arbitrum-nova.shapeshift.com/api/v1/jsonrpc
REACT_APP_BASE_NODE_URL=https://api.base.shapeshift.com/api/v1/jsonrpc
REACT_APP_THORCHAIN_NODE_URL=https://daemon.thorchain.shapeshift.com
REACT_APP_THORCHAIN_NODE_URL=https://dev-daemon.thorchain.shapeshift.com

# thorchain
REACT_APP_MIDGARD_URL=https://indexer.thorchain.shapeshift.com/v2
REACT_APP_MIDGARD_URL=https://dev-indexer.thorchain.shapeshift.com/v2

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

116 changes: 10 additions & 106 deletions packages/caip/src/assetId/assetId.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@ describe('assetId', () => {
describe('toAssetId(fromAssetId())', () => {
it.each([
['eip155:1/slip44:60'],
['eip155:3/slip44:60'],
['eip155:1/erc20:0xc770eefad204b5180df6a14ee197d99d808ee52d'],
['bip122:000000000019d6689c085ae165831e93/slip44:0'],
['bip122:000000000933ea01ad0ee984209779ba/slip44:0'],
['cosmos:cosmoshub-4/slip44:118'],
['cosmos:vega-testnet/slip44:118'],
])('returns an AssetId from the result of fromAssetId for %s', assetId => {
const result = fromAssetId(assetId)
expect(toAssetId(omit(result, 'chainId'))).toBe(assetId)
Expand All @@ -46,26 +43,9 @@ describe('assetId', () => {
)
})

it('can make eth AssetId on ropsten', () => {
const chainNamespace = CHAIN_NAMESPACE.Evm
const chainReference = CHAIN_REFERENCE.EthereumRopsten
const assetIdArgSuperset = {
chainNamespace,
chainReference,
assetNamespace: 'slip44' as AssetNamespace,
assetReference: ASSET_REFERENCE.Ethereum,
chainId: toChainId({ chainNamespace, chainReference }),
}
const expected = 'eip155:3/slip44:60'
expect(toAssetId(omit(assetIdArgSuperset, 'chainId'))).toEqual(expected)
expect(toAssetId(omit(assetIdArgSuperset, ['chainNamespace', 'chainReference']))).toEqual(
expected,
)
})

it('throws with invalid eth network', () => {
const chainNamespace = CHAIN_NAMESPACE.Evm
const chainReference = CHAIN_REFERENCE.CosmosHubVega
const chainReference = CHAIN_REFERENCE.CosmosHubMainnet
const assetIdArgSuperset = {
chainNamespace,
chainReference,
Expand All @@ -85,7 +65,7 @@ describe('assetId', () => {
const assetIdArgSuperset = {
chainNamespace,
chainReference,
assetNamespace: 'cw721' as AssetNamespace,
assetNamespace: 'bad' as AssetNamespace,
assetReference: ASSET_REFERENCE.Ethereum,
chainId: `${chainNamespace}:${chainReference}`,
}
Expand All @@ -112,23 +92,6 @@ describe('assetId', () => {
)
})

it('can make Cosmos AssetId on CosmosHub vega', () => {
const chainNamespace = CHAIN_NAMESPACE.CosmosSdk
const chainReference = CHAIN_REFERENCE.CosmosHubVega
const assetIdArgSuperset = {
chainNamespace,
chainReference,
assetNamespace: 'slip44' as AssetNamespace,
assetReference: ASSET_REFERENCE.Cosmos,
chainId: toChainId({ chainNamespace, chainReference }),
}
const expected = 'cosmos:vega-testnet/slip44:118'
expect(toAssetId(omit(assetIdArgSuperset, 'chainId'))).toEqual(expected)
expect(toAssetId(omit(assetIdArgSuperset, ['chainNamespace', 'chainReference']))).toEqual(
expected,
)
})

it('can make an IBC AssetId on CosmosHub', () => {
const chainNamespace = CHAIN_NAMESPACE.CosmosSdk
const chainReference = CHAIN_REFERENCE.CosmosHubMainnet
Expand All @@ -149,7 +112,7 @@ describe('assetId', () => {

it('throws with invalid Cosmos network', () => {
const chainNamespace = CHAIN_NAMESPACE.CosmosSdk
const chainReference = CHAIN_REFERENCE.BitcoinTestnet
const chainReference = CHAIN_REFERENCE.BitcoinMainnet
const assetIdArgSuperset = {
chainNamespace,
chainReference,
Expand Down Expand Up @@ -181,7 +144,7 @@ describe('assetId', () => {

it('throws with invalid btc network', () => {
const chainNamespace = CHAIN_NAMESPACE.Utxo
const chainReference = CHAIN_REFERENCE.EthereumRopsten
const chainReference = CHAIN_REFERENCE.EthereumMainnet
const assetIdArgSuperset = {
chainNamespace,
chainReference,
Expand Down Expand Up @@ -246,23 +209,6 @@ describe('assetId', () => {
)
})

it('can make FOX AssetId on ropsten', () => {
const chainNamespace = CHAIN_NAMESPACE.Evm
const chainReference = CHAIN_REFERENCE.EthereumRopsten
const assetIdArgSuperset = {
chainNamespace,
chainReference,
assetNamespace: 'erc20' as AssetNamespace,
assetReference: '0xc770eefad204b5180df6a14ee197d99d808ee52d',
chainId: `${chainNamespace}:${chainReference}`,
}
const expected = 'eip155:3/erc20:0xc770eefad204b5180df6a14ee197d99d808ee52d'
expect(toAssetId(omit(assetIdArgSuperset, 'chainId'))).toEqual(expected)
expect(toAssetId(omit(assetIdArgSuperset, ['chainNamespace', 'chainReference']))).toEqual(
expected,
)
})

it('throws with invalid assetReference length', () => {
const chainNamespace = CHAIN_NAMESPACE.Evm
const chainReference = CHAIN_REFERENCE.EthereumMainnet
Expand Down Expand Up @@ -343,23 +289,6 @@ describe('assetId', () => {
expected,
)
})

it('can make bitcoin AssetId on testnet', () => {
const chainNamespace = CHAIN_NAMESPACE.Utxo
const chainReference = CHAIN_REFERENCE.BitcoinTestnet
const assetIdArgSuperset = {
chainNamespace,
chainReference,
assetNamespace: 'slip44' as AssetNamespace,
assetReference: ASSET_REFERENCE.Bitcoin,
chainId: `${chainNamespace}:${chainReference}`,
}
const expected = 'bip122:000000000933ea01ad0ee984209779ba/slip44:0'
expect(toAssetId(omit(assetIdArgSuperset, 'chainId'))).toEqual(expected)
expect(toAssetId(omit(assetIdArgSuperset, ['chainNamespace', 'chainReference']))).toEqual(
expected,
)
})
})

describe('fromAssetId', () => {
Expand All @@ -368,9 +297,7 @@ describe('assetId', () => {
const erc20: AssetNamespace = 'erc20'
it.each([
[CHAIN_NAMESPACE.Utxo, CHAIN_REFERENCE.BitcoinMainnet, slip44, ASSET_REFERENCE.Bitcoin],
[CHAIN_NAMESPACE.Utxo, CHAIN_REFERENCE.BitcoinTestnet, slip44, ASSET_REFERENCE.Bitcoin],
[CHAIN_NAMESPACE.Evm, CHAIN_REFERENCE.EthereumMainnet, slip44, ASSET_REFERENCE.Ethereum],
[CHAIN_NAMESPACE.Evm, CHAIN_REFERENCE.EthereumRopsten, slip44, ASSET_REFERENCE.Ethereum],
[
CHAIN_NAMESPACE.Evm,
CHAIN_REFERENCE.EthereumMainnet,
Expand All @@ -383,7 +310,6 @@ describe('assetId', () => {
slip44,
ASSET_REFERENCE.Cosmos,
],
[CHAIN_NAMESPACE.CosmosSdk, CHAIN_REFERENCE.CosmosHubVega, slip44, ASSET_REFERENCE.Cosmos],
])(
'returns a AssetId from the result of fromAssetId for %s',
(
Expand Down Expand Up @@ -418,17 +344,6 @@ describe('assetId', () => {
expect(assetReference).toEqual(ASSET_REFERENCE.Ethereum)
})

it('can return chain, network from eth AssetId on ropsten', () => {
const AssetId = 'eip155:3/slip44:60'
const { chainId, chainReference, chainNamespace, assetNamespace, assetReference } =
fromAssetId(AssetId)
expect(chainNamespace).toEqual(CHAIN_NAMESPACE.Evm)
expect(chainReference).toEqual(CHAIN_REFERENCE.EthereumRopsten)
expect(chainId).toEqual(toChainId({ chainNamespace, chainReference }))
expect(assetNamespace).toEqual('slip44')
expect(assetReference).toEqual(ASSET_REFERENCE.Ethereum)
})

it('can return chain, network from bitcoin AssetId on mainnet', () => {
const AssetId = 'bip122:000000000019d6689c085ae165831e93/slip44:0'
const { chainId, chainReference, chainNamespace, assetNamespace, assetReference } =
Expand All @@ -440,17 +355,6 @@ describe('assetId', () => {
expect(assetReference).toEqual(ASSET_REFERENCE.Bitcoin)
})

it('can return chain, network from bitcoin AssetId on testnet', () => {
const AssetId = 'bip122:000000000933ea01ad0ee984209779ba/slip44:0'
const { chainId, chainReference, chainNamespace, assetNamespace, assetReference } =
fromAssetId(AssetId)
expect(chainNamespace).toEqual(CHAIN_NAMESPACE.Utxo)
expect(chainReference).toEqual(CHAIN_REFERENCE.BitcoinTestnet)
expect(chainId).toEqual(toChainId({ chainNamespace, chainReference }))
expect(assetNamespace).toEqual('slip44')
expect(assetReference).toEqual(ASSET_REFERENCE.Bitcoin)
})

it('can return chainId, chainReference, chainNamespace, assetNamespace, assetReference from FOX AssetId on mainnet', () => {
const AssetId = 'eip155:1/erc20:0xc770eefad204b5180df6a14ee197d99d808ee52d'
const { chainId, chainReference, chainNamespace, assetNamespace, assetReference } =
Expand All @@ -463,22 +367,22 @@ describe('assetId', () => {
})

it('should lower case assetReference for assetNamespace ERC20', () => {
const AssetId = 'eip155:3/erc20:0xc770EEfAd204B5180dF6a14Ee197D99d808ee52d'
const AssetId = 'eip155:1/erc20:0xc770EEfAd204B5180dF6a14Ee197D99d808ee52d'
const { chainId, chainReference, chainNamespace, assetNamespace, assetReference } =
fromAssetId(AssetId)
expect(chainNamespace).toEqual(CHAIN_NAMESPACE.Evm)
expect(chainReference).toEqual(CHAIN_REFERENCE.EthereumRopsten)
expect(chainReference).toEqual(CHAIN_REFERENCE.EthereumMainnet)
expect(chainId).toEqual(toChainId({ chainNamespace, chainReference }))
expect(assetNamespace).toEqual('erc20')
expect(assetReference).toEqual('0xc770eefad204b5180df6a14ee197d99d808ee52d')
})

it('should lower case assetReference for assetNamespace ERC721', () => {
const AssetId = 'eip155:3/erc721:0xc770EEfAd204B5180dF6a14Ee197D99d808ee52d/12345'
const AssetId = 'eip155:1/erc721:0xc770EEfAd204B5180dF6a14Ee197D99d808ee52d/12345'
const { chainId, chainReference, chainNamespace, assetNamespace, assetReference } =
fromAssetId(AssetId)
expect(chainNamespace).toEqual(CHAIN_NAMESPACE.Evm)
expect(chainReference).toEqual(CHAIN_REFERENCE.EthereumRopsten)
expect(chainReference).toEqual(CHAIN_REFERENCE.EthereumMainnet)
expect(chainId).toEqual(toChainId({ chainNamespace, chainReference }))
expect(assetNamespace).toEqual('erc721')
const [address, id] = assetReference.split('/')
Expand All @@ -487,11 +391,11 @@ describe('assetId', () => {
})

it('can return chainId, chainReference, chainNamespace, assetNamespace, assetReference from FOX AssetId on ropsten', () => {
const AssetId = 'eip155:3/erc20:0xc770eefad204b5180df6a14ee197d99d808ee52d'
const AssetId = 'eip155:1/erc20:0xc770eefad204b5180df6a14ee197d99d808ee52d'
const { chainId, chainReference, chainNamespace, assetNamespace, assetReference } =
fromAssetId(AssetId)
expect(chainNamespace).toEqual(CHAIN_NAMESPACE.Evm)
expect(chainReference).toEqual(CHAIN_REFERENCE.EthereumRopsten)
expect(chainReference).toEqual(CHAIN_REFERENCE.EthereumMainnet)
expect(chainId).toEqual(toChainId({ chainNamespace, chainReference }))
expect(assetNamespace).toEqual('erc20')
expect(assetReference).toEqual('0xc770eefad204b5180df6a14ee197d99d808ee52d')
Expand Down
Loading

0 comments on commit 689960b

Please sign in to comment.