Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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;
}
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;
}
}
}
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));
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;
}
}
}
public static fromXDR(xdr: any) {
return new AssetBuilder(Asset.fromOperation(xdr));
}
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));
});
public static fromXDR(xdr: any) {
return new AssetBuilder(Asset.fromOperation(xdr));
}
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;
}