How to use the stellar-sdk.Asset.fromOperation 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 astroband / astrograph / src / storage / builders / operations / change_trust_op.ts View on Github external
public build(): NQuads {
    super.build();

    this.pushValue("limit", this.xdr.limit().toString());

    const asset = Asset.fromOperation(this.xdr.line());
    this.pushBuilder(new AssetBuilder(asset), "change_trust_op.asset");

    return this.nquads;
  }
github astroband / astrograph / src / model / offer_subscription_payload.ts View on Github external
constructor(mutationType: MutationType, change: IChange) {
    const xdr = change.data.offer();

    this.mutationType = mutationType;
    this.offerId = xdr.offerId().toString();
    this.accountID = publicKeyFromBuffer(xdr.sellerId().value());

    if (mutationType !== MutationType.Remove) {
      this.selling = Asset.fromOperation(xdr.selling());
      this.buying = Asset.fromOperation(xdr.buying());
      this.values = OfferValuesFactory.fromXDR(xdr);
    } else {
      this.selling = change.prevState.selling;
      this.buying = change.prevState.buying;
    }
  }
}
github astroband / astrograph / src / storage / builders / operations / manage_offer_op.ts View on Github external
result.offersClaimed().forEach((atom: any) => {
      const sellerId = publicKeyFromBuffer(atom.sellerId().value());
      const offerId = atom.offerId().toInt();

      const tradeBuilder1 = new TradeBuilder({
        sellerId,
        buyerId: this.source,
        asset: Asset.fromOperation(atom.assetSold()),
        amount: atom.amountSold().toInt(),
        offerId
      });

      const tradeBuilder2 = new TradeBuilder({
        sellerId: this.source,
        buyerId: sellerId,
        asset: Asset.fromOperation(atom.assetBought()),
        amount: atom.amountBought().toInt(),
        offerId
      });

      this.nquads.push(...tradeBuilder1.build());
      this.nquads.push(...tradeBuilder2.build());
      this.nquads.push(new NQuad(tradeBuilder1.current, "trade.counterpart", tradeBuilder2.current));
      this.nquads.push(new NQuad(tradeBuilder2.current, "trade.counterpart", tradeBuilder1.current));
github astroband / astrograph / src / model / offer_subscription_payload.ts View on Github external
constructor(mutationType: MutationType, change: IChange) {
    const xdr = change.data.offer();

    this.mutationType = mutationType;
    this.offerId = xdr.offerId().toString();
    this.accountID = publicKeyFromBuffer(xdr.sellerId().value());

    if (mutationType !== MutationType.Remove) {
      this.selling = Asset.fromOperation(xdr.selling());
      this.buying = Asset.fromOperation(xdr.buying());
      this.values = OfferValuesFactory.fromXDR(xdr);
    } else {
      this.selling = change.prevState.selling;
      this.buying = change.prevState.buying;
    }
  }
}
github astroband / astrograph / src / storage / builders / asset.ts View on Github external
public static fromXDR(xdr: any) {
    return new AssetBuilder(Asset.fromOperation(xdr));
  }
github astroband / astrograph / src / storage / builders / operations / manage_offer_op.ts View on Github external
result.offersClaimed().forEach((atom: any) => {
      const sellerId = publicKeyFromBuffer(atom.sellerId().value());
      const offerId = atom.offerId().toInt();

      const tradeBuilder1 = new TradeBuilder({
        sellerId,
        buyerId: this.source,
        asset: Asset.fromOperation(atom.assetSold()),
        amount: atom.amountSold().toInt(),
        offerId
      });

      const tradeBuilder2 = new TradeBuilder({
        sellerId: this.source,
        buyerId: sellerId,
        asset: Asset.fromOperation(atom.assetBought()),
        amount: atom.amountBought().toInt(),
        offerId
      });

      this.nquads.push(...tradeBuilder1.build());
      this.nquads.push(...tradeBuilder2.build());
      this.nquads.push(new NQuad(tradeBuilder1.current, "trade.counterpart", tradeBuilder2.current));
      this.nquads.push(new NQuad(tradeBuilder2.current, "trade.counterpart", tradeBuilder1.current));
    });
github astroband / astrograph / src / storage / builders / asset.ts View on Github external
public static fromXDR(xdr: any) {
    return new AssetBuilder(Asset.fromOperation(xdr));
  }
github astroband / astrograph / src / storage / builders / operations / payment_op.ts View on Github external
public build(): NQuads {
    super.build();
    const asset = Asset.fromOperation(this.body.asset());
    const amount = this.body.amount().toString();
    const destination = publicKeyFromBuffer(this.body.destination().value());

    this.pushValue("amount", amount);
    this.pushBuilder(new AccountBuilder(destination), "op.destination");
    this.pushBuilder(new AssetBuilder(asset), `payment_op.asset`, "operations");

    return this.nquads;
  }