Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
constructor(bitgo: BitGo, tokenConfig: StellarTokenConfig) {
super(bitgo);
this.tokenConfig = tokenConfig;
const network = this.tokenConfig.network === 'Testnet' ? stellar.Networks.TESTNET : stellar.Networks.PUBLIC;
stellar.Network.use(new stellar.Network(network));
const [tokenCoin, token] = _.split(this.tokenConfig.type, Xlm.coinTokenPatternSeparator);
if (tokenCoin !== tokenConfig.coin) {
throw new BitGoJsError(`invalid coin found in token: ${this.tokenConfig.type}`);
}
if (!token || !token.match(StellarToken.tokenPattern)) {
throw new BitGoJsError(`invalid token: ${this.tokenConfig.type}`);
}
[this._code, this._issuer] = _.split(token, '-');
}
function getHash(passphrase) {
return new StellarSdk.Network(passphrase)
.networkId()
.toString('hex')
.slice(0, 8);
}
export async function R3Stellar(network, serverURI) {
const passPhrase = Stellar.Networks[process.env.STELLAR_NETWORK];
Stellar.Network.use(new Stellar.Network(passPhrase));
const stellar = new Stellar.Server(serverURI);
const assetContracts = AssetContracts(stellar, Stellar);
const hashedTimeLockContracts = HashedTimelockContracts(stellar, Stellar);
return {
stellar,
Stellar,
assetContracts,
hashedTimeLockContracts,
};
}