@shapeshiftoss/caip 5.2.1 → 5.3.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/dist/accountId/accountId.d.ts +2 -1
- package/dist/adapters/coincap/utils.d.ts +1 -8
- package/dist/adapters/coingecko/utils.d.ts +1 -8
- package/dist/adapters/thortrading/index.d.ts +1 -2
- package/dist/adapters/thortrading/index.js +31 -74
- package/dist/assetId/assetId.d.ts +2 -1
- package/dist/chainId/chainId.d.ts +2 -1
- package/dist/constants.d.ts +10 -10
- package/dist/typeGuards.d.ts +1 -1
- package/dist/utils.d.ts +5 -0
- package/package.json +3 -3
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ChainId, ChainNamespace, ChainReference } from '../chainId/chainId';
|
|
2
|
-
|
|
2
|
+
import { Nominal } from '../utils';
|
|
3
|
+
export declare type AccountId = Nominal<string, 'AccountId'>;
|
|
3
4
|
declare type ToAccountIdWithChainId = {
|
|
4
5
|
chainId: ChainId;
|
|
5
6
|
account: string;
|
|
@@ -16,14 +16,7 @@ export declare const writeFiles: (data: Record<string, Record<string, string>>)
|
|
|
16
16
|
export declare const fetchData: (URL: string) => Promise<CoinCapCoin[]>;
|
|
17
17
|
export declare const parseEthData: (data: CoinCapCoin[]) => Record<string, string>;
|
|
18
18
|
export declare const parseData: (d: CoinCapCoin[]) => {
|
|
19
|
-
|
|
20
|
-
"bip122:000000000019d6689c085ae165831e93": {
|
|
21
|
-
[x: string]: string;
|
|
22
|
-
};
|
|
23
|
-
"cosmos:cosmoshub-4": {
|
|
24
|
-
[x: string]: string;
|
|
25
|
-
};
|
|
26
|
-
"cosmos:osmosis-1": {
|
|
19
|
+
[x: string]: {
|
|
27
20
|
[x: string]: string;
|
|
28
21
|
};
|
|
29
22
|
};
|
|
@@ -10,14 +10,7 @@ export declare const writeFiles: (data: Record<string, Record<string, string>>)
|
|
|
10
10
|
export declare const fetchData: (URL: string) => Promise<CoingeckoCoin[]>;
|
|
11
11
|
export declare const parseEthData: (data: CoingeckoCoin[]) => Record<string, string>;
|
|
12
12
|
export declare const parseData: (d: CoingeckoCoin[]) => {
|
|
13
|
-
|
|
14
|
-
"bip122:000000000019d6689c085ae165831e93": {
|
|
15
|
-
[x: string]: string;
|
|
16
|
-
};
|
|
17
|
-
"cosmos:cosmoshub-4": {
|
|
18
|
-
[x: string]: string;
|
|
19
|
-
};
|
|
20
|
-
"cosmos:osmosis-1": {
|
|
13
|
+
[x: string]: {
|
|
21
14
|
[x: string]: string;
|
|
22
15
|
};
|
|
23
16
|
};
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { AssetId } from './../../assetId/assetId';
|
|
2
2
|
export declare const poolAssetIdToAssetId: (id: string) => AssetId | undefined;
|
|
3
|
-
export declare const assetIdToPoolAssetId: ({ assetId
|
|
3
|
+
export declare const assetIdToPoolAssetId: ({ assetId }: {
|
|
4
4
|
assetId: AssetId;
|
|
5
|
-
symbol?: string | undefined;
|
|
6
5
|
}) => string | undefined;
|
|
@@ -1,80 +1,37 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.assetIdToPoolAssetId = exports.poolAssetIdToAssetId = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
if (!assetReference)
|
|
32
|
-
return undefined;
|
|
33
|
-
const chainId = constants_1.ethChainId;
|
|
34
|
-
const assetNamespace = 'erc20';
|
|
35
|
-
try {
|
|
36
|
-
return (0, assetId_1.toAssetId)({ chainId, assetNamespace, assetReference });
|
|
37
|
-
}
|
|
38
|
-
catch (e) {
|
|
39
|
-
console.error(e);
|
|
40
|
-
return undefined;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
case 'BTC': {
|
|
44
|
-
return constants_1.btcAssetId;
|
|
45
|
-
}
|
|
46
|
-
default: {
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
4
|
+
// derived from https://midgard.thorchain.info/v2/pools
|
|
5
|
+
// Rarely changes. Will need to be updated as we add additional assets to thor swapper
|
|
6
|
+
const thorPoolIdAssetIdSymbolMap = {
|
|
7
|
+
'ETH.YFI-0X0BC529C00C6401AEF6D220BE8C6EA1667F6AD93E': 'eip155:1/erc20:0x0bc529c00c6401aef6d220be8c6ea1667f6ad93e',
|
|
8
|
+
'ETH.XRUNE-0X69FA0FEE221AD11012BAB0FDB45D444D3D2CE71C': 'eip155:1/erc20:0x69fa0fee221ad11012bab0fdb45d444d3d2ce71c',
|
|
9
|
+
'ETH.XDEFI-0X72B886D09C117654AB7DA13A14D603001DE0B777': 'eip155:1/erc20:0x72b886d09c117654ab7da13a14d603001de0b777',
|
|
10
|
+
'ETH.WBTC-0X2260FAC5E5542A773AA44FBCFEDF7C193BC2C599': 'eip155:1/erc20:0x2260fac5e5542a773aa44fbcfedf7c193bc2c599',
|
|
11
|
+
'ETH.USDT-0XDAC17F958D2EE523A2206206994597C13D831EC7': 'eip155:1/erc20:0xdac17f958d2ee523a2206206994597c13d831ec7',
|
|
12
|
+
'ETH.USDC-0XA0B86991C6218B36C1D19D4A2E9EB0CE3606EB48': 'eip155:1/erc20:0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',
|
|
13
|
+
'ETH.UOS-0XD13C7342E1EF687C5AD21B27C2B65D772CAB5C8C': 'eip155:1/erc20:0xd13c7342e1ef687c5ad21b27c2b65d772cab5c8c',
|
|
14
|
+
'ETH.THOR-0XA5F2211B9B8170F694421F2046281775E8468044': 'eip155:1/erc20:0xa5f2211b9b8170f694421f2046281775e8468044',
|
|
15
|
+
'ETH.TGT-0X108A850856DB3F85D0269A2693D896B394C80325': 'eip155:1/erc20:0x108a850856db3f85d0269a2693d896b394c80325',
|
|
16
|
+
'ETH.SUSHI-0X6B3595068778DD592E39A122F4F5A5CF09C90FE2': 'eip155:1/erc20:0x6b3595068778dd592e39a122f4f5a5cf09c90fe2',
|
|
17
|
+
'ETH.SNX-0XC011A73EE8576FB46F5E1C5751CA3B9FE0AF2A6F': 'eip155:1/erc20:0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f',
|
|
18
|
+
'ETH.RAZE-0X5EAA69B29F99C84FE5DE8200340B4E9B4AB38EAC"': 'eip155:1/erc20:0x5eaa69b29f99c84fe5de8200340b4e9b4ab38eac',
|
|
19
|
+
'ETH.PERP-0XBC396689893D065F41BC2C6ECBEE5E0085233447': 'eip155:1/erc20:0xbc396689893d065f41bc2c6ecbee5e0085233447',
|
|
20
|
+
'ETH.KYL-0X67B6D479C7BB412C54E03DCA8E1BC6740CE6B99C': 'eip155:1/erc20:0x67b6d479c7bb412c54e03dca8e1bc6740ce6b99c',
|
|
21
|
+
'ETH.HOT-0X6C6EE5E31D828DE241282B9606C8E98EA48526E2': 'eip155:1/erc20:0x6c6ee5e31d828de241282b9606c8e98ea48526e2',
|
|
22
|
+
'ETH.HEGIC-0X584BC13C7D411C00C01A62E8019472DE68768430': 'eip155:1/erc20:0x584bc13c7d411c00c01a62e8019472de68768430',
|
|
23
|
+
'ETH.FOX-0XC770EEFAD204B5180DF6A14EE197D99D808EE52D': 'eip155:1/erc20:0xc770eefad204b5180df6a14ee197d99d808ee52d',
|
|
24
|
+
'ETH.DAI-0X6B175474E89094C44DA98B954EEDEAC495271D0F': 'eip155:1/erc20:0x6b175474e89094c44da98b954eedeac495271d0f',
|
|
25
|
+
'ETH.CREAM-0X2BA592F78DB6436527729929AAF6C908497CB200': 'eip155:1/erc20:0x2ba592f78db6436527729929aaf6c908497cb200',
|
|
26
|
+
'ETH.ALPHA-0XA1FAA113CBE53436DF28FF0AEE54275C13B40975': 'eip155:1/erc20:0xa1faa113cbe53436df28ff0aee54275c13b40975',
|
|
27
|
+
'ETH.ALCX-0XDBDB4D16EDA451D0503B854CF79D55697F90C8DF': 'eip155:1/erc20:0xdbdb4d16eda451d0503b854cf79d55697f90c8df',
|
|
28
|
+
'ETH.AAVE-0X7FC66500C84A76AD7E9C93437BFC5AC33E2DDAE9': 'eip155:1/erc20:0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9',
|
|
29
|
+
'BTC.BTC': 'bip122:000000000019d6689c085ae165831e93/slip44:0',
|
|
30
|
+
'ETH.ETH': 'eip155:1/slip44:60'
|
|
50
31
|
};
|
|
32
|
+
const invert = (data) => Object.entries(data).reduce((acc, [k, v]) => ((acc[v] = k), acc), {});
|
|
33
|
+
const assetIdToPoolAssetIdMap = invert(thorPoolIdAssetIdSymbolMap);
|
|
34
|
+
const poolAssetIdToAssetId = (id) => thorPoolIdAssetIdSymbolMap[id.toUpperCase()];
|
|
51
35
|
exports.poolAssetIdToAssetId = poolAssetIdToAssetId;
|
|
52
|
-
const assetIdToPoolAssetId = ({ assetId
|
|
53
|
-
try {
|
|
54
|
-
const { chainId, assetReference } = (0, assetId_1.fromAssetId)(assetId);
|
|
55
|
-
// https://dev.thorchain.org/thorchain-dev/memos#asset-notation
|
|
56
|
-
switch (chainId) {
|
|
57
|
-
case constants_1.ethChainId: {
|
|
58
|
-
if (assetId === constants_1.ethAssetId)
|
|
59
|
-
return 'ETH.ETH';
|
|
60
|
-
if (!symbol)
|
|
61
|
-
return undefined;
|
|
62
|
-
// this is predicated on the assumption that the symbol from the asset service
|
|
63
|
-
// and the contract address are static, correct, and won't ever change. Midgard
|
|
64
|
-
// also returns the asset notation with the assetReference in uppercase format,
|
|
65
|
-
// so we will keep that consistent here and uppercase it.
|
|
66
|
-
return `ETH.${symbol}-${assetReference.toUpperCase()}`;
|
|
67
|
-
}
|
|
68
|
-
case constants_2.btcChainId: {
|
|
69
|
-
return 'BTC.BTC';
|
|
70
|
-
}
|
|
71
|
-
default: {
|
|
72
|
-
return undefined;
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
catch (e) {
|
|
77
|
-
return undefined;
|
|
78
|
-
}
|
|
79
|
-
};
|
|
36
|
+
const assetIdToPoolAssetId = ({ assetId }) => assetIdToPoolAssetIdMap[assetId.toLowerCase()];
|
|
80
37
|
exports.assetIdToPoolAssetId = assetIdToPoolAssetId;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ChainId, ChainNamespace, ChainReference } from '../chainId/chainId';
|
|
2
2
|
import { ASSET_NAMESPACE_STRINGS, ASSET_REFERENCE } from '../constants';
|
|
3
|
-
|
|
3
|
+
import { Nominal } from '../utils';
|
|
4
|
+
export declare type AssetId = Nominal<string, 'AssetId'>;
|
|
4
5
|
export declare type AssetNamespace = typeof ASSET_NAMESPACE_STRINGS[number];
|
|
5
6
|
export declare type AssetReference = typeof ASSET_REFERENCE[keyof typeof ASSET_REFERENCE];
|
|
6
7
|
declare type ToAssetIdWithChainId = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CHAIN_NAMESPACE, CHAIN_REFERENCE } from '../constants';
|
|
2
|
-
|
|
2
|
+
import { Nominal } from '../utils';
|
|
3
|
+
export declare type ChainId = Nominal<string, 'ChainId'>;
|
|
3
4
|
export declare type ChainNamespace = typeof CHAIN_NAMESPACE[keyof typeof CHAIN_NAMESPACE];
|
|
4
5
|
export declare type ChainReference = typeof CHAIN_REFERENCE[keyof typeof CHAIN_REFERENCE];
|
|
5
6
|
declare type ToChainIdArgs = {
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { AssetNamespace } from './assetId/assetId';
|
|
2
|
-
import { ChainNamespace, ChainReference } from './chainId/chainId';
|
|
3
|
-
export declare const btcAssetId
|
|
4
|
-
export declare const ethAssetId
|
|
5
|
-
export declare const cosmosAssetId
|
|
6
|
-
export declare const osmosisAssetId
|
|
7
|
-
export declare const ethChainId
|
|
8
|
-
export declare const btcChainId
|
|
9
|
-
export declare const cosmosChainId
|
|
10
|
-
export declare const osmosisChainId
|
|
1
|
+
import { AssetId, AssetNamespace } from './assetId/assetId';
|
|
2
|
+
import { ChainId, ChainNamespace, ChainReference } from './chainId/chainId';
|
|
3
|
+
export declare const btcAssetId: AssetId;
|
|
4
|
+
export declare const ethAssetId: AssetId;
|
|
5
|
+
export declare const cosmosAssetId: AssetId;
|
|
6
|
+
export declare const osmosisAssetId: AssetId;
|
|
7
|
+
export declare const ethChainId: ChainId;
|
|
8
|
+
export declare const btcChainId: ChainId;
|
|
9
|
+
export declare const cosmosChainId: ChainId;
|
|
10
|
+
export declare const osmosisChainId: ChainId;
|
|
11
11
|
export declare const CHAIN_NAMESPACE: {
|
|
12
12
|
readonly Ethereum: "eip155";
|
|
13
13
|
readonly Bitcoin: "bip122";
|
package/dist/typeGuards.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ export declare const isChainReference: (maybeChainReference: ChainReference | st
|
|
|
5
5
|
export declare const isAssetNamespace: (maybeAssetNamespace: AssetNamespace | string) => maybeAssetNamespace is "cw20" | "cw721" | "erc20" | "erc721" | "slip44" | "native" | "ibc";
|
|
6
6
|
export declare const isAssetReference: (maybeAssetReference: AssetReference | string) => maybeAssetReference is AssetReference;
|
|
7
7
|
export declare const isAssetId: (maybeAssetId: AssetId | string) => maybeAssetId is AssetReference;
|
|
8
|
-
export declare const isChainId: (maybeChainId: ChainId | string) => maybeChainId is
|
|
8
|
+
export declare const isChainId: (maybeChainId: ChainId | string) => maybeChainId is ChainId;
|
|
9
9
|
export declare const assertIsChainId: (value: ChainId | string | undefined) => asserts value is ChainId;
|
|
10
10
|
export declare const assertIsChainNamespace: (value: ChainNamespace | string | undefined) => asserts value is ChainNamespace;
|
|
11
11
|
export declare const assertIsChainReference: (value: ChainReference | string | undefined) => asserts value is ChainReference;
|
package/dist/utils.d.ts
CHANGED
|
@@ -17,3 +17,8 @@ export declare const makeCosmosHubData: () => {
|
|
|
17
17
|
export declare const makeOsmosisData: () => {
|
|
18
18
|
[x: string]: string;
|
|
19
19
|
};
|
|
20
|
+
interface Flavoring<FlavorT> {
|
|
21
|
+
_type?: FlavorT;
|
|
22
|
+
}
|
|
23
|
+
export declare type Nominal<T, FlavorT> = T & Flavoring<FlavorT>;
|
|
24
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shapeshiftoss/caip",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"description": "CAIP Implementation",
|
|
5
5
|
"homepage": "",
|
|
6
6
|
"license": "MIT",
|
|
@@ -31,10 +31,10 @@
|
|
|
31
31
|
"type-check": "tsc --project ./tsconfig.build.json --noEmit"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@shapeshiftoss/types": "^4.
|
|
34
|
+
"@shapeshiftoss/types": "^4.4.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@shapeshiftoss/types": "^4.
|
|
37
|
+
"@shapeshiftoss/types": "^4.4.0",
|
|
38
38
|
"@yfi/sdk": "^1.0.30",
|
|
39
39
|
"axios": "^0.26.1",
|
|
40
40
|
"ts-node": "^10.7.0"
|