How to use the stellar-sdk.Asset 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 satoshipay / solar / src / components / Account / TrustlineList.tsx View on Github external
            onClick={() => props.onRemoveTrustline(new Asset(balance.asset_code, balance.asset_issuer))}
            style={{ color: "black" }}
github astroband / astrograph / src / model / factories / operation_data_mapper / dgraph.ts View on Github external
private mapPathPayment(): IDgraphPathPaymentOperation {
    const destinationAssetData = this.data["path_payment_op.asset_destination"];
    const sourceAssetData = this.data["path_payment_op.asset_source"];

    const destinationAsset = destinationAssetData.native
      ? Asset.native()
      : new Asset(destinationAssetData.code, destinationAssetData[assetIssuerPredicate][accountIdPredicate]);
    const sourceAsset = sourceAssetData.native
      ? Asset.native()
      : new Asset(sourceAssetData.code, sourceAssetData[assetIssuerPredicate][accountIdPredicate]);

    return {
      ...this.baseData,
      ...{
        sendMax: this.data.send_max,
        destinationAmount: this.data.amount,
        destinationAccount: this.data[opDestinationPredicate][accountIdPredicate],
        destinationAsset,
        sourceAccount: this.data["op.source"][accountIdPredicate],
        sourceAsset,
        path: this.data["path_payment_op.assets_path"].map((assetData: IAssetData) => {
          return assetData.native
            ? Asset.native()
github satoshipay / solar / src / lib / stellar.ts View on Github external
export function balancelineToAsset(balanceline: Horizon.BalanceLine): Asset {
  return balanceline.asset_type === "native"
    ? Asset.native()
    : new Asset(balanceline.asset_code, balanceline.asset_issuer)
}
github stellarterm / stellarterm / api / functions / ticker.js View on Github external
return Promise.all(_.map(ticker.pairs, (pair, pairSlug) => {
    let baseBuying     = new StellarSdk.Asset(pair.baseBuying.code, pair.baseBuying.issuer);
    let counterSelling = new StellarSdk.Asset(pair.counterSelling.code, pair.counterSelling.issuer);

    let asset;
    if (baseBuying.isNative()) {
      let asset = _.find(ticker.assets, {
        code: pair.counterSelling.code,
        issuer: pair.counterSelling.issuer,
      });
      asset.topTradePairSlug = pairSlug;
    } else if (counterSelling.isNative()) {
      let asset = _.find(ticker.assets, {
        code: pair.baseBuying.code,
        issuer: pair.baseBuying.issuer,
      });
      asset.topTradePairSlug = pairSlug;
    }
github pakokrew / stellar-portal / app / js / helpers / StellarTools.js View on Github external
export const AssetInstance = asset => {
  if(!asset) return null;
  if(asset instanceof Asset) {
    return asset;
  }
  if(asset.asset_type === 'native') {
    return Asset.native();
  }
  return new Asset(asset.asset_code, asset.asset_issuer);
};
github satoshipay / solar / src / components / AccountAssets / CustomTrustline.tsx View on Github external
const createTransaction = () =>
    props.createAddAssetTransaction(new Asset(code, issuerPublicKey), { limit: limit || undefined })
  const addCustomAsset = () => props.sendTransaction(createTransaction)
github astroband / astrograph / src / model / factories / operation_data_mapper / dgraph.ts View on Github external
private mapManageOffer(): IManageOfferOperation {
    const assetBuyingData = this.data["manage_offer_op.asset_buying"];
    const assetSellingData = this.data["manage_offer_op.asset_selling"];

    const assetBuying = assetBuyingData.native
      ? Asset.native()
      : new Asset(assetBuyingData.code, assetBuyingData[assetIssuerPredicate][accountIdPredicate]);
    const assetSelling = assetSellingData.native
      ? Asset.native()
      : new Asset(assetSellingData.code, assetSellingData[assetIssuerPredicate][accountIdPredicate]);

    return {
      ...this.baseData,
      ...{
        offerId: this.data.offer_id,
        amount: this.data.amount,
        price: this.data.price,
        priceComponents: {
          n: this.data.price_n,
          d: this.data.price_d
        },
        assetBuying,
        assetSelling
      }
    };
  }
github astroband / astrograph / src / model / factories / operation_data_mapper / dgraph.ts View on Github external
private mapManageOffer(): IManageOfferOperation {
    const assetBuyingData = this.data["manage_offer_op.asset_buying"];
    const assetSellingData = this.data["manage_offer_op.asset_selling"];

    const assetBuying = assetBuyingData.native
      ? Asset.native()
      : new Asset(assetBuyingData.code, assetBuyingData[assetIssuerPredicate][accountIdPredicate]);
    const assetSelling = assetSellingData.native
      ? Asset.native()
      : new Asset(assetSellingData.code, assetSellingData[assetIssuerPredicate][accountIdPredicate]);

    return {
      ...this.baseData,
      ...{
        offerId: this.data.offer_id,
        amount: this.data.amount,
        price: this.data.price,
        priceComponents: {
          n: this.data.price_n,
          d: this.data.price_d
        },
        assetBuying,
        assetSelling
github ety001 / stellar-bot / src / lib / Api.js View on Github external
getOrderBook: function (server, selling, buying, cb, cbErr) {
    const sellingAsset = selling.asset_code === 'XLM' ?
          new StellarSdk.Asset.native() :
          new StellarSdk.Asset(selling.asset_code, selling.asset_issuer);
    const buyingAsset = buying.asset_code === 'XLM' ?
          new StellarSdk.Asset.native() :
          new StellarSdk.Asset(buying.asset_code, buying.asset_issuer);
    server.orderbook(sellingAsset, buyingAsset)
      .call()
      .then(function(resp) { cb(resp); })
      .catch(function(err) { cbErr(err); });
  },
  addTrustline: function (server, privateKey, code, issuer, cb, cbErr) {