Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
onClick={() => props.onRemoveTrustline(new Asset(balance.asset_code, balance.asset_issuer))}
style={{ color: "black" }}
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()
export function balancelineToAsset(balanceline: Horizon.BalanceLine): Asset {
return balanceline.asset_type === "native"
? Asset.native()
: new Asset(balanceline.asset_code, balanceline.asset_issuer)
}
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;
}
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);
};
const createTransaction = () =>
props.createAddAssetTransaction(new Asset(code, issuerPublicKey), { limit: limit || undefined })
const addCustomAsset = () => props.sendTransaction(createTransaction)
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
}
};
}
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
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) {