@cranberry-money/shared-constants 8.15.403 → 8.15.405
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.
|
@@ -7,7 +7,7 @@ export declare const WALLET_VERIFICATION_STATUS: {
|
|
|
7
7
|
};
|
|
8
8
|
export type WalletVerificationStatus = (typeof WALLET_VERIFICATION_STATUS)[keyof typeof WALLET_VERIFICATION_STATUS];
|
|
9
9
|
export declare const WALLET_VERIFICATION_STATUS_LABELS: Record<WalletVerificationStatus, string>;
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const BLOCKCHAIN: {
|
|
11
11
|
readonly ETHEREUM: "ethereum";
|
|
12
12
|
readonly BITCOIN: "bitcoin";
|
|
13
13
|
readonly POLYGON: "polygon";
|
|
@@ -17,16 +17,33 @@ export declare const BLOCKCHAIN_NETWORK: {
|
|
|
17
17
|
readonly OPTIMISM: "optimism";
|
|
18
18
|
readonly BASE: "base";
|
|
19
19
|
};
|
|
20
|
-
export type
|
|
21
|
-
export declare const
|
|
20
|
+
export type BlockchainType = (typeof BLOCKCHAIN)[keyof typeof BLOCKCHAIN];
|
|
21
|
+
export declare const BLOCKCHAIN_LABELS: Record<string, string>;
|
|
22
22
|
/**
|
|
23
|
-
* Maps blockchain
|
|
23
|
+
* Maps blockchain chain codes (as stored in database) to their native asset symbols
|
|
24
24
|
* Used for transaction labeling and blockchain operations
|
|
25
25
|
*
|
|
26
26
|
* IMPORTANT: These are NATIVE tokens, not chain identifiers
|
|
27
27
|
* Example: Arbitrum's native token is ETH (not ARB)
|
|
28
28
|
*/
|
|
29
|
-
export declare const
|
|
29
|
+
export declare const CHAIN_TO_NATIVE_ASSET: Record<string, string>;
|
|
30
|
+
/**
|
|
31
|
+
* Maps native asset short codes (ETH, BTC) to full blockchain names
|
|
32
|
+
* Used when APIs expect full chain names but input is short code
|
|
33
|
+
*/
|
|
34
|
+
export declare const NATIVE_ASSET_TO_CHAIN: Record<string, BlockchainType>;
|
|
35
|
+
/**
|
|
36
|
+
* Get full blockchain name from any chain identifier (short code or full name)
|
|
37
|
+
* @param chain - Chain identifier (e.g., 'ETH', 'ethereum', 'BTC', 'bitcoin')
|
|
38
|
+
* @returns Full blockchain name (e.g., 'ethereum', 'bitcoin') or original if not found
|
|
39
|
+
*/
|
|
40
|
+
export declare function getChainName(chain: string): string;
|
|
41
|
+
/**
|
|
42
|
+
* Get native asset short code from any chain identifier
|
|
43
|
+
* @param chain - Chain identifier (e.g., 'ETH', 'ethereum', 'BTC', 'bitcoin')
|
|
44
|
+
* @returns Native asset symbol (e.g., 'ETH', 'BTC') or uppercase input if not found
|
|
45
|
+
*/
|
|
46
|
+
export declare function getChainShortCode(chain: string): string;
|
|
30
47
|
export declare const WALLET_ADDRESS_PATTERNS: {
|
|
31
48
|
readonly ETHEREUM: RegExp;
|
|
32
49
|
readonly BITCOIN: RegExp;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../src/business/wallets.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,eAAO,MAAM,0BAA0B;;;CAG7B,CAAC;AAEX,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,OAAO,0BAA0B,CAAC,CAAC;AAEpH,eAAO,MAAM,iCAAiC,EAAE,MAAM,CAAC,wBAAwB,EAAE,MAAM,CAGtF,CAAC;AAMF,eAAO,MAAM,
|
|
1
|
+
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../src/business/wallets.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH,eAAO,MAAM,0BAA0B;;;CAG7B,CAAC;AAEX,MAAM,MAAM,wBAAwB,GAAG,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,OAAO,0BAA0B,CAAC,CAAC;AAEpH,eAAO,MAAM,iCAAiC,EAAE,MAAM,CAAC,wBAAwB,EAAE,MAAM,CAGtF,CAAC;AAMF,eAAO,MA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,CAAC,aAAa,EAAE,MAAM,CAK/D,CAAC"}
|
package/dist/business/wallets.js
CHANGED
|
@@ -13,9 +13,9 @@ export const WALLET_VERIFICATION_STATUS_LABELS = {
|
|
|
13
13
|
[WALLET_VERIFICATION_STATUS.VERIFIED]: 'Verified',
|
|
14
14
|
};
|
|
15
15
|
// ============================================
|
|
16
|
-
// Blockchain
|
|
16
|
+
// Blockchain Chains
|
|
17
17
|
// ============================================
|
|
18
|
-
export const
|
|
18
|
+
export const BLOCKCHAIN = {
|
|
19
19
|
ETHEREUM: 'ethereum',
|
|
20
20
|
BITCOIN: 'bitcoin',
|
|
21
21
|
POLYGON: 'polygon',
|
|
@@ -25,7 +25,7 @@ export const BLOCKCHAIN_NETWORK = {
|
|
|
25
25
|
OPTIMISM: 'optimism',
|
|
26
26
|
BASE: 'base',
|
|
27
27
|
};
|
|
28
|
-
export const
|
|
28
|
+
export const BLOCKCHAIN_LABELS = {
|
|
29
29
|
ethereum: 'Ethereum',
|
|
30
30
|
bitcoin: 'Bitcoin',
|
|
31
31
|
polygon: 'Polygon',
|
|
@@ -36,13 +36,13 @@ export const BLOCKCHAIN_NETWORK_LABELS = {
|
|
|
36
36
|
base: 'Base',
|
|
37
37
|
};
|
|
38
38
|
/**
|
|
39
|
-
* Maps blockchain
|
|
39
|
+
* Maps blockchain chain codes (as stored in database) to their native asset symbols
|
|
40
40
|
* Used for transaction labeling and blockchain operations
|
|
41
41
|
*
|
|
42
42
|
* IMPORTANT: These are NATIVE tokens, not chain identifiers
|
|
43
43
|
* Example: Arbitrum's native token is ETH (not ARB)
|
|
44
44
|
*/
|
|
45
|
-
export const
|
|
45
|
+
export const CHAIN_TO_NATIVE_ASSET = {
|
|
46
46
|
ethereum: 'ETH',
|
|
47
47
|
bitcoin: 'BTC',
|
|
48
48
|
btc: 'BTC',
|
|
@@ -55,6 +55,51 @@ export const NETWORK_TO_NATIVE_ASSET = {
|
|
|
55
55
|
optimism: 'ETH', // Optimism's native token is ETH
|
|
56
56
|
base: 'ETH', // Base's native token is ETH
|
|
57
57
|
};
|
|
58
|
+
/**
|
|
59
|
+
* Maps native asset short codes (ETH, BTC) to full blockchain names
|
|
60
|
+
* Used when APIs expect full chain names but input is short code
|
|
61
|
+
*/
|
|
62
|
+
export const NATIVE_ASSET_TO_CHAIN = {
|
|
63
|
+
ETH: BLOCKCHAIN.ETHEREUM,
|
|
64
|
+
BTC: BLOCKCHAIN.BITCOIN,
|
|
65
|
+
MATIC: BLOCKCHAIN.POLYGON,
|
|
66
|
+
SOL: BLOCKCHAIN.SOLANA,
|
|
67
|
+
AVAX: BLOCKCHAIN.AVALANCHE,
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* Get full blockchain name from any chain identifier (short code or full name)
|
|
71
|
+
* @param chain - Chain identifier (e.g., 'ETH', 'ethereum', 'BTC', 'bitcoin')
|
|
72
|
+
* @returns Full blockchain name (e.g., 'ethereum', 'bitcoin') or original if not found
|
|
73
|
+
*/
|
|
74
|
+
export function getChainName(chain) {
|
|
75
|
+
const normalized = chain?.toLowerCase() || '';
|
|
76
|
+
if (Object.values(BLOCKCHAIN).includes(normalized)) {
|
|
77
|
+
return normalized;
|
|
78
|
+
}
|
|
79
|
+
const upper = chain?.toUpperCase() || '';
|
|
80
|
+
const mapped = NATIVE_ASSET_TO_CHAIN[upper];
|
|
81
|
+
if (mapped) {
|
|
82
|
+
return mapped;
|
|
83
|
+
}
|
|
84
|
+
return normalized;
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Get native asset short code from any chain identifier
|
|
88
|
+
* @param chain - Chain identifier (e.g., 'ETH', 'ethereum', 'BTC', 'bitcoin')
|
|
89
|
+
* @returns Native asset symbol (e.g., 'ETH', 'BTC') or uppercase input if not found
|
|
90
|
+
*/
|
|
91
|
+
export function getChainShortCode(chain) {
|
|
92
|
+
const normalized = chain?.toLowerCase() || '';
|
|
93
|
+
const mapped = CHAIN_TO_NATIVE_ASSET[normalized];
|
|
94
|
+
if (mapped) {
|
|
95
|
+
return mapped;
|
|
96
|
+
}
|
|
97
|
+
const upper = chain?.toUpperCase() || '';
|
|
98
|
+
if (upper in NATIVE_ASSET_TO_CHAIN) {
|
|
99
|
+
return upper;
|
|
100
|
+
}
|
|
101
|
+
return upper;
|
|
102
|
+
}
|
|
58
103
|
// ============================================
|
|
59
104
|
// Wallet Address Validation Patterns
|
|
60
105
|
// ============================================
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallets.js","sourceRoot":"","sources":["../../src/business/wallets.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,+CAA+C;AAC/C,+BAA+B;AAC/B,+CAA+C;AAE/C,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;CACZ,CAAC;AAIX,MAAM,CAAC,MAAM,iCAAiC,GAA6C;IACzF,CAAC,0BAA0B,CAAC,OAAO,CAAC,EAAE,sBAAsB;IAC5D,CAAC,0BAA0B,CAAC,QAAQ,CAAC,EAAE,UAAU;CAClD,CAAC;AAEF,+CAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"wallets.js","sourceRoot":"","sources":["../../src/business/wallets.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,+CAA+C;AAC/C,+BAA+B;AAC/B,+CAA+C;AAE/C,MAAM,CAAC,MAAM,0BAA0B,GAAG;IACxC,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,UAAU;CACZ,CAAC;AAIX,MAAM,CAAC,MAAM,iCAAiC,GAA6C;IACzF,CAAC,0BAA0B,CAAC,OAAO,CAAC,EAAE,sBAAsB;IAC5D,CAAC,0BAA0B,CAAC,QAAQ,CAAC,EAAE,UAAU;CAClD,CAAC;AAEF,+CAA+C;AAC/C,oBAAoB;AACpB,+CAA+C;AAE/C,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,QAAQ,EAAE,UAAU;IACpB,OAAO,EAAE,SAAS;IAClB,OAAO,E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