@shapeshiftoss/caip 1.12.1 → 2.0.1

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.
@@ -23,13 +23,16 @@ const parseEthData = (data) => {
23
23
  const ethCoins = data.filter(({ id, explorer }) => (explorer && explorer.startsWith('https://etherscan.io/token/0x')) || id === 'ethereum');
24
24
  const chain = types_1.ChainTypes.Ethereum;
25
25
  const network = types_1.NetworkTypes.MAINNET;
26
- const contractType = types_1.ContractTypes.ERC20;
27
26
  return ethCoins.reduce((acc, { id, explorer }) => {
28
- let tokenId;
27
+ let assetReference = caip19_1.AssetReference.Ethereum;
28
+ const assetNamespace = id === 'ethereum' ? caip19_1.AssetNamespace.Slip44 : caip19_1.AssetNamespace.ERC20;
29
29
  if (id !== 'ethereum' && explorer) {
30
- tokenId = explorer.replace('https://etherscan.io/token/', '').split('#')[0].split('?')[0];
30
+ assetReference = explorer
31
+ .replace('https://etherscan.io/token/', '')
32
+ .split('#')[0]
33
+ .split('?')[0];
31
34
  }
32
- const caip19 = (0, caip19_1.toCAIP19)({ chain, network, ...(tokenId ? { contractType, tokenId } : {}) });
35
+ const caip19 = (0, caip19_1.toCAIP19)({ chain, network, assetNamespace, assetReference });
33
36
  acc[caip19] = id;
34
37
  return acc;
35
38
  }, {});
@@ -38,21 +41,36 @@ exports.parseEthData = parseEthData;
38
41
  const makeBtcData = () => {
39
42
  const chain = types_1.ChainTypes.Bitcoin;
40
43
  const network = types_1.NetworkTypes.MAINNET;
41
- const caip19 = (0, caip19_1.toCAIP19)({ chain, network });
44
+ const caip19 = (0, caip19_1.toCAIP19)({
45
+ chain,
46
+ network,
47
+ assetNamespace: caip19_1.AssetNamespace.Slip44,
48
+ assetReference: caip19_1.AssetReference.Bitcoin
49
+ });
42
50
  return { [caip19]: 'bitcoin' };
43
51
  };
44
52
  exports.makeBtcData = makeBtcData;
45
53
  const makeCosmosHubData = () => {
46
54
  const chain = types_1.ChainTypes.Cosmos;
47
55
  const network = types_1.NetworkTypes.COSMOSHUB_MAINNET;
48
- const caip19 = (0, caip19_1.toCAIP19)({ chain, network });
56
+ const caip19 = (0, caip19_1.toCAIP19)({
57
+ chain,
58
+ network,
59
+ assetNamespace: caip19_1.AssetNamespace.Slip44,
60
+ assetReference: caip19_1.AssetReference.Cosmos
61
+ });
49
62
  return { [caip19]: 'cosmos' };
50
63
  };
51
64
  exports.makeCosmosHubData = makeCosmosHubData;
52
65
  const makeOsmosisData = () => {
53
66
  const chain = types_1.ChainTypes.Osmosis;
54
67
  const network = types_1.NetworkTypes.OSMOSIS_MAINNET;
55
- const caip19 = (0, caip19_1.toCAIP19)({ chain, network });
68
+ const caip19 = (0, caip19_1.toCAIP19)({
69
+ chain,
70
+ network,
71
+ assetNamespace: caip19_1.AssetNamespace.Slip44,
72
+ assetReference: caip19_1.AssetReference.Osmosis
73
+ });
56
74
  return { [caip19]: 'osmosis' };
57
75
  };
58
76
  exports.makeOsmosisData = makeOsmosisData;