@chainrails/common 0.2.4 → 0.2.6
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/chainrails-common.es.js +1061 -430
- package/dist/chainrails-common.es.mjs +1061 -430
- package/dist/chainrails-common.umd.js +2 -2
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/src/amountSymbols/constant.d.ts +15 -0
- package/dist/src/amountSymbols/constant.d.ts.map +1 -0
- package/dist/src/amountSymbols/index.d.ts +2 -0
- package/dist/src/amountSymbols/index.d.ts.map +1 -0
- package/dist/src/chains/all.d.ts +2 -4
- package/dist/src/chains/all.d.ts.map +1 -1
- package/dist/src/chains/constants.d.ts +67 -24
- package/dist/src/chains/constants.d.ts.map +1 -1
- package/dist/src/chains/index.d.ts +4 -13
- package/dist/src/chains/index.d.ts.map +1 -1
- package/dist/src/chains/types.d.ts +10 -6
- package/dist/src/chains/types.d.ts.map +1 -1
- package/dist/src/chains/utils.d.ts +58 -0
- package/dist/src/chains/utils.d.ts.map +1 -0
- package/dist/src/tokens/index.d.ts +4 -14
- package/dist/src/tokens/index.d.ts.map +1 -1
- package/dist/src/tokens/registry.d.ts +41 -0
- package/dist/src/tokens/registry.d.ts.map +1 -0
- package/dist/src/tokens/types.d.ts +22 -0
- package/dist/src/tokens/types.d.ts.map +1 -0
- package/dist/src/tokens/utils.d.ts +41 -0
- package/dist/src/tokens/utils.d.ts.map +1 -0
- package/dist/src/tokens/validation.d.ts +56 -0
- package/dist/src/tokens/validation.d.ts.map +1 -0
- package/package.json +1 -1
- package/dist/src/tokenAddresses/index.d.ts +0 -8
- package/dist/src/tokenAddresses/index.d.ts.map +0 -1
- package/dist/src/tokens/all.d.ts +0 -35
- package/dist/src/tokens/all.d.ts.map +0 -1
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { AmountSymbol } from "../amountSymbols";
|
|
2
|
+
import { Token } from "./types";
|
|
3
|
+
import { InternalChain } from "../chains/types";
|
|
4
|
+
export declare function assertTokenMatchesAmountSymbol(token: Token, tokenSymbol: AmountSymbol): asserts token is Token;
|
|
5
|
+
/**
|
|
6
|
+
* Asserts that a token address exists on the specified chain.
|
|
7
|
+
*
|
|
8
|
+
* @param chainKey - The internal chain value (e.g., "ETHEREUM_MAINNET")
|
|
9
|
+
* @param tokenAddress - The token address to validate
|
|
10
|
+
* @returns The token object if found
|
|
11
|
+
* @throws Error if the address does not exist on the specified chain
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const token = assertTokenAddressMatchesChain("ETHEREUM_MAINNET", "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48");
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function assertTokenAddressMatchesChain(chainKey: InternalChain, tokenAddress: string): Token;
|
|
19
|
+
/**
|
|
20
|
+
* Asserts that a token's symbol matches the expected token symbol.
|
|
21
|
+
*
|
|
22
|
+
* @param token - The token object to validate
|
|
23
|
+
* @param tokenSymbol - The expected token symbol
|
|
24
|
+
* @throws Error if the token symbol does not match
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```typescript
|
|
28
|
+
* const token = getToken(chains.ETHEREUM, "USDC");
|
|
29
|
+
* assertTokenSymbolMatches(token, "USDC");
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
export declare function assertTokenSymbolMatches(token: Token, tokenSymbol: AmountSymbol): asserts token is Token;
|
|
33
|
+
/**
|
|
34
|
+
* Asserts that a token address exists on the specified chain AND matches the expected token symbol.
|
|
35
|
+
* This is a combined validation that checks both conditions and provides clear error messages.
|
|
36
|
+
*
|
|
37
|
+
* @param chainKey - The internal chain value (e.g., "ETHEREUM_MAINNET")
|
|
38
|
+
* @param tokenAddress - The token address to validate
|
|
39
|
+
* @param tokenSymbol - The expected token symbol
|
|
40
|
+
* @returns The token object if both validations pass
|
|
41
|
+
* @throws Error with specific message if:
|
|
42
|
+
* - Chain is not found
|
|
43
|
+
* - Address does not exist on the chain
|
|
44
|
+
* - Address exists but token symbol doesn't match
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* const token = assertTokenAddressMatchesChainAndSymbol(
|
|
49
|
+
* "ETHEREUM_MAINNET",
|
|
50
|
+
* "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
51
|
+
* "USDC"
|
|
52
|
+
* );
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare function assertTokenAddressMatchesChainAndSymbol(chainKey: InternalChain, tokenAddress: string, tokenSymbol: AmountSymbol): Token;
|
|
56
|
+
//# sourceMappingURL=validation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/tokens/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,wBAAgB,8BAA8B,CAC5C,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,YAAY,GACxB,OAAO,CAAC,KAAK,IAAI,KAAK,CAOxB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,8BAA8B,CAC5C,QAAQ,EAAE,aAAa,EACvB,YAAY,EAAE,MAAM,GACnB,KAAK,CAkCP;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,KAAK,EACZ,WAAW,EAAE,YAAY,GACxB,OAAO,CAAC,KAAK,IAAI,KAAK,CAOxB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,uCAAuC,CACrD,QAAQ,EAAE,aAAa,EACvB,YAAY,EAAE,MAAM,EACpB,WAAW,EAAE,YAAY,GACxB,KAAK,CAcP"}
|
package/package.json
CHANGED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { chains } from "../chains";
|
|
2
|
-
import { allChains } from "../chains/all";
|
|
3
|
-
import { chainData } from "../chains/types";
|
|
4
|
-
import { tokens } from "../tokens";
|
|
5
|
-
/** @description Get a chain by chain enum */
|
|
6
|
-
export declare const getChainByChainEnum: (chainEnum: keyof typeof allChains) => chainData | undefined;
|
|
7
|
-
export declare function getTokenAddress(destinationChain: keyof typeof chains, destinationToken: keyof typeof tokens): string | undefined;
|
|
8
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tokenAddresses/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACnC,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAS,MAAM,EAAE,MAAM,WAAW,CAAC;AAE1C,6CAA6C;AAC7C,eAAO,MAAM,mBAAmB,cAAe,MAAM,OAAO,SAAS,KAAG,SAAS,GAAG,SAMnF,CAAC;AAEF,wBAAgB,eAAe,CAAC,gBAAgB,EAAE,MAAM,OAAO,MAAM,EAAE,gBAAgB,EAAE,MAAM,OAAO,MAAM,sBAI3G"}
|
package/dist/src/tokens/all.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { Token } from ".";
|
|
2
|
-
export declare enum TokenLogo {
|
|
3
|
-
ETH = "https://pay.daimo.com/chain-logos/ethereum.png",
|
|
4
|
-
WETH = "https://pay.daimo.com/coin-logos/weth.png",
|
|
5
|
-
USDC = "https://pay.daimo.com/coin-logos/usdc.png",
|
|
6
|
-
EURC = "https://pay.daimo.com/coin-logos/eurc.png",
|
|
7
|
-
USDT = "https://pay.daimo.com/coin-logos/usdt.png",
|
|
8
|
-
DAI = "https://pay.daimo.com/coin-logos/dai.png",
|
|
9
|
-
POL = "https://pay.daimo.com/coin-logos/pol.png",
|
|
10
|
-
AVAX = "https://pay.daimo.com/coin-logos/avax.png",
|
|
11
|
-
BNB = "https://pay.daimo.com/coin-logos/bnb.png",
|
|
12
|
-
SOL = "https://pay.daimo.com/coin-logos/sol.png",
|
|
13
|
-
WLD = "https://pay.daimo.com/coin-logos/wld.jpeg",
|
|
14
|
-
USDB = "https://pay.daimo.com/coin-logos/usdb.png",
|
|
15
|
-
BLAST = "https://pay.daimo.com/coin-logos/blast.jpg",
|
|
16
|
-
WBTC = "https://pay.daimo.com/coin-logos/wbtc.png",
|
|
17
|
-
MNT = "https://pay.daimo.com/coin-logos/mnt.png",
|
|
18
|
-
CELO = "https://pay.daimo.com/coin-logos/celo.png",
|
|
19
|
-
cUSD = "https://pay.daimo.com/coin-logos/cusd.png"
|
|
20
|
-
}
|
|
21
|
-
export declare const arbitrumTestnetUSDC: Token;
|
|
22
|
-
export declare const arbitrumUSDC: Token;
|
|
23
|
-
export declare const avalancheTestnetUSDC: Token;
|
|
24
|
-
export declare const avalancheUSDC: Token;
|
|
25
|
-
export declare const baseTestnetUSDC: Token;
|
|
26
|
-
export declare const baseUSDC: Token;
|
|
27
|
-
export declare const bscUSDC: Token;
|
|
28
|
-
export declare const ethereumTestnetUSDC: Token;
|
|
29
|
-
export declare const ethereumUSDC: Token;
|
|
30
|
-
export declare const starknetUSDC: Token;
|
|
31
|
-
export declare const supportedTokens: Token[];
|
|
32
|
-
export declare const EVM_USDC_TOKENS: {
|
|
33
|
-
[x: string]: Token;
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=all.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"all.d.ts","sourceRoot":"","sources":["../../../src/tokens/all.ts"],"names":[],"mappings":"AAaA,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,CAAC;AAE1B,oBAAY,SAAS;IACnB,GAAG,mDAAmD;IACtD,IAAI,8CAA8C;IAClD,IAAI,8CAA8C;IAClD,IAAI,8CAA8C;IAClD,IAAI,8CAA8C;IAClD,GAAG,6CAA6C;IAChD,GAAG,6CAA6C;IAChD,IAAI,8CAA8C;IAClD,GAAG,6CAA6C;IAChD,GAAG,6CAA6C;IAChD,GAAG,8CAA8C;IACjD,IAAI,8CAA8C;IAClD,KAAK,+CAA+C;IACpD,IAAI,8CAA8C;IAClD,GAAG,6CAA6C;IAChD,IAAI,8CAA8C;IAClD,IAAI,8CAA8C;CACnD;AAED,eAAO,MAAM,mBAAmB,EAAE,KAQjC,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAO1B,CAAC;AAEF,eAAO,MAAM,oBAAoB,EAAE,KAQlC,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,KAQ3B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAQ7B,CAAC;AAEF,eAAO,MAAM,QAAQ,EAAE,KAQtB,CAAC;AAEF,eAAO,MAAM,OAAO,EAAE,KAOrB,CAAC;AAEF,eAAO,MAAM,mBAAmB,EAAE,KAOjC,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAO1B,CAAC;AAEF,eAAO,MAAM,YAAY,EAAE,KAO1B,CAAC;AAEF,eAAO,MAAM,eAAe,EAAE,KAAK,EAWlC,CAAC;AAEF,eAAO,MAAM,eAAe;;CAU3B,CAAC"}
|