How to use the stellar-sdk.Networks function in stellar-sdk

To help you get started, we’ve selected a few stellar-sdk examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github BitGo / BitGoJS / modules / core / src / v2 / coins / xlm.ts View on Github external
constructor(bitgo: BitGo) {
    super(bitgo);
    this.homeDomain = 'bitgo.com'; // used for reverse federation lookup
    stellar.Network.use(new stellar.Network(stellar.Networks.PUBLIC));
  }
github BitGo / BitGoJS / modules / core / src / v2 / coins / stellarToken.ts View on Github external
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, '-');
  }
github BitGo / BitGoJS / modules / core / src / v2 / coins / txlm.ts View on Github external
constructor(bitgo: BitGo) {
    super(bitgo);
    stellar.Network.use(new stellar.Network(stellar.Networks.TESTNET));
  }
github stellar / js-stellar-wallets / playground / src / components / KeyEntry.js View on Github external
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() });
    }
  };
github stellar / js-stellar-wallets / src / KeyManager.ts View on Github external
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;
  }
github rate-engineering / rate3-monorepo / packages / stellar-contracts / r3-stellar-js / r3-stellar.js View on Github external
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,
    };
}
github stellar / js-stellar-wallets / playground / src / components / KeyEntry.js View on Github external
_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,