forked from Deen-Bridge/dnb-backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassets.js
More file actions
85 lines (77 loc) · 2.17 KB
/
Copy pathassets.js
File metadata and controls
85 lines (77 loc) · 2.17 KB
1
2
3
4
5
6
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// config/assets.js
//
// Network-aware asset registry. USDC stays the default so existing
// USDC-only flows (and existing Transaction rows with no currency set)
// keep working unchanged. Issuer addresses below are Circle's official
// EURC issuers (verified against developers.circle.com); XLM is native
// and has no issuer.
const REGISTRY = {
testnet: {
USDC: {
code: "USDC",
issuer: "GBBD47IF6LWK7P7MDEVSCWR7DPUWV3NY3DTQEVFL4NAT4AQH3ZLLFLA5",
decimals: 7,
displayName: "USD Coin",
isDefault: true,
},
EURC: {
code: "EURC",
issuer: "GB3Q6QDZYTHWT7E5PVS3W7FUT5GVAFC5KSZFFLPU25GO7VTC3NM2ZTVO",
decimals: 7,
displayName: "Euro Coin",
isDefault: false,
},
XLM: {
code: "XLM",
issuer: null,
decimals: 7,
displayName: "Stellar Lumens",
isDefault: false,
},
},
mainnet: {
USDC: {
code: "USDC",
issuer: "GA5ZSEJYB37JRC5AVCIA5MOP4RHTM335X2KGX3IHOJAPP5RE34K4KZVN",
decimals: 7,
displayName: "USD Coin",
isDefault: true,
},
EURC: {
code: "EURC",
issuer: "GDHU6WRG4IEQXM5NZ4BMPKOXHW76MZM4Y2IEMFDVXBSDP6SJY4ITNPP2",
decimals: 7,
displayName: "Euro Coin",
isDefault: false,
},
XLM: {
code: "XLM",
issuer: null,
decimals: 7,
displayName: "Stellar Lumens",
isDefault: false,
},
},
};
const NETWORK = process.env.STELLAR_NETWORK || "testnet";
export const getRegistry = (network = NETWORK) => {
const registry = REGISTRY[network];
if (!registry) {
throw new Error(`Unknown Stellar network: ${network}`);
}
return registry;
};
export const getAssetConfig = (code, network = NETWORK) => {
const registry = getRegistry(network);
return registry[code] || null;
};
export const getSupportedCodes = (network = NETWORK) =>
Object.keys(getRegistry(network));
export const getDefaultAssetCode = (network = NETWORK) => {
const registry = getRegistry(network);
const entry = Object.values(registry).find((a) => a.isDefault);
return entry ? entry.code : "USDC";
};
export const isAssetSupported = (code, network = NETWORK) =>
!!getAssetConfig(code, network);
export { REGISTRY };