@shapeshiftoss/caip 7.0.0 → 8.0.0

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/README.md CHANGED
@@ -12,7 +12,7 @@ Usage
12
12
  ### `toChainId` | `toCAIP2`
13
13
 
14
14
  ```ts
15
- const chainNamespace = CHAIN_NAMESPACE.Ethereum
15
+ const chainNamespace = CHAIN_NAMESPACE.Evm
16
16
  const chainReference = CHAIN_REFERENCE.EthereumMainnet
17
17
  const result = toChainId({ chainNamespace, chainReference })
18
18
  expect(result).toEqual('eip155:1')
@@ -23,7 +23,7 @@ expect(result).toEqual('eip155:1')
23
23
  ```ts
24
24
  const ethereumChainId = 'eip155:1'
25
25
  const { chainNamespace, chainReference } = fromChainId(ethereumChainId)
26
- expect(chainNamespace).toEqual(CHAIN_NAMESPACE.Ethereum)
26
+ expect(chainNamespace).toEqual(CHAIN_NAMESPACE.Evm)
27
27
  expect(chainReference).toEqual(CHAIN_REFERENCE.EthereumMainnet)
28
28
  ```
29
29
 
@@ -36,7 +36,7 @@ Usage
36
36
  ### `toAccountId` | `toCAIP10`
37
37
 
38
38
  ```ts
39
- const chainNamespace = CHAIN_NAMESPACE.Ethereum
39
+ const chainNamespace = CHAIN_NAMESPACE.Evm
40
40
  const chainReference = CHAIN_REFERENCE.EthereumMainnet
41
41
  const chainId = toChainId({ chainNamespace, chainReference })
42
42
  const account = '0xa44c286ba83bb771cd0107b2c1df678435bd1535'
@@ -67,7 +67,7 @@ Usage
67
67
  Ether
68
68
 
69
69
  ```ts
70
- const chainNamespace = CHAIN_NAMESPACE.Ethereum
70
+ const chainNamespace = CHAIN_NAMESPACE.Evm
71
71
  const chainReference = CHAIN_REFERENCE.EthereumMainnet
72
72
  const chainId = toChainId({ chainNamespace, chainReference })
73
73
  const assetNamespace = 'slip44'
@@ -79,7 +79,7 @@ expect(toAssetId({ chainId, assetNamespace, assetReference })).toEqual('eip155:1
79
79
  ERC20 token
80
80
 
81
81
  ```ts
82
- const chainNamespace = CHAIN_NAMESPACE.Ethereum
82
+ const chainNamespace = CHAIN_NAMESPACE.Evm
83
83
  const chainReference = CHAIN_REFERENCE.EthereumMainnet
84
84
  const chainId = toChainId({ chainNamespace, chainReference })
85
85
  const assetNamespace = 'erc20'
@@ -13,7 +13,7 @@ const toAccountId = ({ chainId: maybeChainId, chainNamespace: maybeChainNamespac
13
13
  // we lowercase eth accounts as per the draft spec
14
14
  // it's not explicit, but cHecKsUM can be recovered from lowercase eth accounts
15
15
  // we don't lowercase bitcoin addresses as they'll fail checksum
16
- const outputAccount = chainNamespace === constants_1.CHAIN_NAMESPACE.Ethereum ? account.toLowerCase() : account;
16
+ const outputAccount = chainNamespace === constants_1.CHAIN_NAMESPACE.Evm ? account.toLowerCase() : account;
17
17
  return `${chainId}:${outputAccount}`;
18
18
  };
19
19
  exports.toAccountId = toAccountId;
@@ -35,7 +35,7 @@ const fromAccountId = (accountId) => {
35
35
  // we lowercase eth accounts as per the draft spec
36
36
  // it's not explicit, but cHecKsUM can be recovered from lowercase eth accounts
37
37
  // we don't lowercase bitcoin addresses as they'll fail checksum
38
- const outputAccount = chainNamespace === constants_1.CHAIN_NAMESPACE.Ethereum ? account.toLowerCase() : account;
38
+ const outputAccount = chainNamespace === constants_1.CHAIN_NAMESPACE.Evm ? account.toLowerCase() : account;
39
39
  return { chainId, account: outputAccount, chainNamespace, chainReference };
40
40
  };
41
41
  exports.fromAccountId = fromAccountId;
@@ -22,7 +22,7 @@ exports.fetchData = fetchData;
22
22
  const parseEthData = (data) => {
23
23
  const ethCoins = data.filter(({ id, explorer }) => (explorer && explorer.startsWith('https://etherscan.io/token/0x')) || id === 'ethereum');
24
24
  return ethCoins.reduce((acc, { id, explorer }) => {
25
- const chainNamespace = constants_1.CHAIN_NAMESPACE.Ethereum;
25
+ const chainNamespace = constants_1.CHAIN_NAMESPACE.Evm;
26
26
  const chainReference = constants_1.CHAIN_REFERENCE.EthereumMainnet;
27
27
  let assetReference = constants_1.ASSET_REFERENCE.Ethereum;
28
28
  const assetNamespace = id === 'ethereum' ? 'slip44' : 'erc20';
@@ -58,7 +58,7 @@ exports.assetIdToCoingecko = assetIdToCoingecko;
58
58
  const chainIdToCoingeckoAssetPlatform = (chainId) => {
59
59
  const { chainNamespace, chainReference } = (0, chainId_1.fromChainId)(chainId);
60
60
  switch (chainNamespace) {
61
- case constants_1.CHAIN_NAMESPACE.Ethereum:
61
+ case constants_1.CHAIN_NAMESPACE.Evm:
62
62
  switch (chainReference) {
63
63
  case constants_1.CHAIN_REFERENCE.EthereumMainnet:
64
64
  return CoingeckoAssetPlatform.Ethereum;
@@ -67,7 +67,7 @@ const chainIdToCoingeckoAssetPlatform = (chainId) => {
67
67
  default:
68
68
  throw new Error(`chainNamespace ${chainNamespace}, chainReference ${chainReference} not supported.`);
69
69
  }
70
- case constants_1.CHAIN_NAMESPACE.Cosmos:
70
+ case constants_1.CHAIN_NAMESPACE.CosmosSdk:
71
71
  switch (chainReference) {
72
72
  case constants_1.CHAIN_REFERENCE.CosmosHubMainnet:
73
73
  return CoingeckoAssetPlatform.Cosmos;
@@ -16,7 +16,7 @@ const parseData = (coins) => {
16
16
  if (Object.keys(platforms).includes('ethereum')) {
17
17
  try {
18
18
  const assetId = (0, assetId_1.toAssetId)({
19
- chainNamespace: constants_1.CHAIN_NAMESPACE.Ethereum,
19
+ chainNamespace: constants_1.CHAIN_NAMESPACE.Evm,
20
20
  chainReference: constants_1.CHAIN_REFERENCE.EthereumMainnet,
21
21
  assetNamespace: 'erc20',
22
22
  assetReference: platforms.ethereum,
@@ -30,7 +30,7 @@ const parseData = (coins) => {
30
30
  if (Object.keys(platforms).includes('avalanche')) {
31
31
  try {
32
32
  const assetId = (0, assetId_1.toAssetId)({
33
- chainNamespace: constants_1.CHAIN_NAMESPACE.Ethereum,
33
+ chainNamespace: constants_1.CHAIN_NAMESPACE.Evm,
34
34
  chainReference: constants_1.CHAIN_REFERENCE.AvalancheCChain,
35
35
  assetNamespace: 'erc20',
36
36
  assetReference: platforms.avalanche,
@@ -34,7 +34,7 @@ const parseOsmosisData = (data) => {
34
34
  assetReference = denom.split('/')[1];
35
35
  assetNamespace = 'ibc';
36
36
  }
37
- const chainNamespace = constants_1.CHAIN_NAMESPACE.Cosmos;
37
+ const chainNamespace = constants_1.CHAIN_NAMESPACE.CosmosSdk;
38
38
  const chainReference = constants_1.CHAIN_REFERENCE.OsmosisMainnet;
39
39
  const assetId = (0, assetId_1.toAssetId)({ chainNamespace, chainReference, assetNamespace, assetReference });
40
40
  acc[assetId] = symbol;
@@ -45,7 +45,7 @@ const parseOsmosisData = (data) => {
45
45
  exports.parseOsmosisData = parseOsmosisData;
46
46
  const parseData = (d) => {
47
47
  const osmosisMainnet = (0, chainId_1.toChainId)({
48
- chainNamespace: constants_1.CHAIN_NAMESPACE.Cosmos,
48
+ chainNamespace: constants_1.CHAIN_NAMESPACE.CosmosSdk,
49
49
  chainReference: constants_1.CHAIN_REFERENCE.OsmosisMainnet,
50
50
  });
51
51
  return {
@@ -36,7 +36,7 @@ const fetchData = async () => {
36
36
  exports.fetchData = fetchData;
37
37
  const parseEthData = (data) => {
38
38
  const assetNamespace = 'erc20';
39
- const chainNamespace = constants_1.CHAIN_NAMESPACE.Ethereum;
39
+ const chainNamespace = constants_1.CHAIN_NAMESPACE.Evm;
40
40
  const chainReference = constants_1.CHAIN_REFERENCE.EthereumMainnet;
41
41
  return data.reduce((acc, datum) => {
42
42
  const { address } = datum;
@@ -55,7 +55,7 @@ const parseEthData = (data) => {
55
55
  exports.parseEthData = parseEthData;
56
56
  const parseData = (d) => {
57
57
  const ethMainnet = (0, chainId_1.toChainId)({
58
- chainNamespace: constants_1.CHAIN_NAMESPACE.Ethereum,
58
+ chainNamespace: constants_1.CHAIN_NAMESPACE.Evm,
59
59
  chainReference: constants_1.CHAIN_REFERENCE.EthereumMainnet,
60
60
  });
61
61
  return { [ethMainnet]: (0, exports.parseEthData)(d) };
@@ -17,9 +17,9 @@ export declare const avalancheChainId: ChainId;
17
17
  export declare const cosmosChainId: ChainId;
18
18
  export declare const osmosisChainId: ChainId;
19
19
  export declare const CHAIN_NAMESPACE: {
20
- readonly Ethereum: "eip155";
20
+ readonly Evm: "eip155";
21
21
  readonly Utxo: "bip122";
22
- readonly Cosmos: "cosmos";
22
+ readonly CosmosSdk: "cosmos";
23
23
  };
24
24
  declare type ValidChainMap = {
25
25
  [k in ChainNamespace]: ChainReference[];
package/dist/constants.js CHANGED
@@ -18,9 +18,9 @@ exports.avalancheChainId = 'eip155:43114';
18
18
  exports.cosmosChainId = 'cosmos:cosmoshub-4';
19
19
  exports.osmosisChainId = 'cosmos:osmosis-1';
20
20
  exports.CHAIN_NAMESPACE = {
21
- Ethereum: 'eip155',
21
+ Evm: 'eip155',
22
22
  Utxo: 'bip122',
23
- Cosmos: 'cosmos',
23
+ CosmosSdk: 'cosmos',
24
24
  };
25
25
  exports.CHAIN_REFERENCE = {
26
26
  EthereumMainnet: '1',
@@ -48,13 +48,13 @@ exports.VALID_CHAIN_IDS = Object.freeze({
48
48
  exports.CHAIN_REFERENCE.DogecoinMainnet,
49
49
  exports.CHAIN_REFERENCE.LitecoinMainnet,
50
50
  ],
51
- [exports.CHAIN_NAMESPACE.Ethereum]: [
51
+ [exports.CHAIN_NAMESPACE.Evm]: [
52
52
  exports.CHAIN_REFERENCE.EthereumMainnet,
53
53
  exports.CHAIN_REFERENCE.EthereumRopsten,
54
54
  exports.CHAIN_REFERENCE.EthereumRinkeby,
55
55
  exports.CHAIN_REFERENCE.AvalancheCChain,
56
56
  ],
57
- [exports.CHAIN_NAMESPACE.Cosmos]: [
57
+ [exports.CHAIN_NAMESPACE.CosmosSdk]: [
58
58
  exports.CHAIN_REFERENCE.CosmosHubMainnet,
59
59
  exports.CHAIN_REFERENCE.CosmosHubVega,
60
60
  exports.CHAIN_REFERENCE.OsmosisMainnet,
@@ -63,8 +63,8 @@ exports.VALID_CHAIN_IDS = Object.freeze({
63
63
  });
64
64
  exports.VALID_ASSET_NAMESPACE = Object.freeze({
65
65
  [exports.CHAIN_NAMESPACE.Utxo]: ['slip44'],
66
- [exports.CHAIN_NAMESPACE.Ethereum]: ['slip44', 'erc20', 'erc721'],
67
- [exports.CHAIN_NAMESPACE.Cosmos]: ['cw20', 'cw721', 'ibc', 'native', 'slip44'],
66
+ [exports.CHAIN_NAMESPACE.Evm]: ['slip44', 'erc20', 'erc721'],
67
+ [exports.CHAIN_NAMESPACE.CosmosSdk]: ['cw20', 'cw721', 'ibc', 'native', 'slip44'],
68
68
  });
69
69
  exports.ASSET_NAMESPACE_STRINGS = [
70
70
  'cw20',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shapeshiftoss/caip",
3
- "version": "7.0.0",
3
+ "version": "8.0.0",
4
4
  "description": "CAIP Implementation",
5
5
  "homepage": "",
6
6
  "license": "MIT",