-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathconfig.js
48 lines (39 loc) · 1.2 KB
/
config.js
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
const StellarSdk = require('stellar-sdk');
StellarSdk.Network.useTestNetwork();
const assetCode = 'CNDY';
let issuerCredentials = null;
let distributorCredentials = null;
let asset = null;
try {
issuerCredentials = require('./.credentials_issuer');
} catch (e) {
console.warn('No issuer credentials found.');
}
try {
distributorCredentials = require('./.credentials_distributor');
} catch (e) {
console.warn('No distributor credentials found.');
}
let issuer = null;
let distributor = null;
if (issuerCredentials && issuerCredentials.secret) {
issuer = StellarSdk.Keypair.fromSecret(issuerCredentials.secret);
} else if (issuerCredentials) {
issuer = StellarSdk.Keypair.fromPublicKey(issuerCredentials.public);
}
if (issuer) {
asset = new StellarSdk.Asset(assetCode, issuer.publicKey());
}
if (distributorCredentials && distributorCredentials.secret) {
distributor = StellarSdk.Keypair.fromSecret(distributorCredentials.secret);
} else if (distributorCredentials) {
distributor = StellarSdk.Keypair.fromPublicKey(distributorCredentials.public);
}
const server = new StellarSdk.Server('https://horizon-testnet.stellar.org');
module.exports = {
server,
asset,
issuer,
distributor,
StellarSdk
};