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) {
super(bitgo);
this.homeDomain = 'bitgo.com'; // used for reverse federation lookup
stellar.Network.use(new stellar.Network(stellar.Networks.PUBLIC));
}
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, '-');
}
constructor(bitgo: BitGo) {
super(bitgo);
stellar.Network.use(new stellar.Network(stellar.Networks.TESTNET));
}
type: KeyType.plaintextKey,
network: this.state.isTestnet
? StellarSdk.Networks.TESTNET
: StellarSdk.Networks.PUBLIC,
};
localStorage.setItem("key", key.privateKey);
} catch (e) {
this.setState({ error: "That wasn't a valid secret key." });
return;
}
try {
this.state.keyManager.setDefaultNetworkPassphrase(
this.state.isTestnet
? StellarSdk.Networks.TESTNET
: StellarSdk.Networks.PUBLIC,
);
const keyMetadata = await this.state.keyManager.storeKey({
key,
password,
encrypterName: KeyManagerPlugins.ScryptEncrypter.name,
});
this.setState({ keyMetadata: keyMetadata });
this.props.onSetKey(key.publicKey, this.state.isTestnet);
} catch (e) {
this.setState({ error: e.toString() });
}
};
constructor(params: KeyManagerParams) {
this.encrypterMap = {};
this.keyHandlerMap = {
[KeyType.ledger]: ledgerHandler,
[KeyType.plaintextKey]: plaintextKeyHandler,
};
this.keyCache = {};
this.keyStore = params.keyStore;
this.shouldCache = params.shouldCache || false;
this.defaultNetworkPassphrase =
params.defaultNetworkPassphrase || StellarSdk.Networks.PUBLIC;
}
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,
};
}
_setKey = async (privateKey, password) => {
let key;
try {
const account = StellarSdk.Keypair.fromSecret(privateKey);
key = {
publicKey: account.publicKey(),
privateKey: account.secret(),
type: KeyType.plaintextKey,
network: this.state.isTestnet
? StellarSdk.Networks.TESTNET
: StellarSdk.Networks.PUBLIC,
};
localStorage.setItem("key", key.privateKey);
} catch (e) {
this.setState({ error: "That wasn't a valid secret key." });
return;
}
try {
this.state.keyManager.setDefaultNetworkPassphrase(
this.state.isTestnet
? StellarSdk.Networks.TESTNET
: StellarSdk.Networks.PUBLIC,
);
const keyMetadata = await this.state.keyManager.storeKey({
key,
password,