Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const addAsset = async (asset: Asset, options: { limit?: string } = {}) => {
try {
const operations = [Operation.changeTrust({ asset, limit: options.limit })]
const transaction = await createTransaction(operations, {
accountData,
horizon: props.horizon,
walletAccount: props.account
})
props.sendTransaction(transaction)
} catch (error) {
trackError(error)
}
}
export const changeTrust = ({ asset, limit }, authData) => {
try {
const trustLimit = (isNumber(limit) || isString(limit)) ? AmountInstance(limit) : undefined;
const operation = Operation.changeTrust({
asset: AssetInstance(asset),
limit: trustLimit,
});
return sendTransaction(authData, { operation });
} catch (e) {
return Promise.reject(e);
}
};
const createAddAssetTransaction = async (options: { limit?: string } = {}) => {
const operations = [Operation.changeTrust({ asset, limit: options.limit })]
return createTransaction(operations, {
accountData,
horizon: props.horizon,
walletAccount: props.account
})
}
const removeAsset = async () => {
try {
const operations = [Operation.changeTrust({ asset: props.asset, limit: "0" })]
const transaction = await createTransaction(operations, {
accountData: props.accountData,
horizon: props.horizon,
walletAccount: props.account
})
props.sendTransaction(transaction)
} catch (error) {
trackError(error)
}
}
const createAddAssetTransaction = async (asset: Asset, options: { limit?: string } = {}) => {
const operations = [Operation.changeTrust({ asset, limit: options.limit })]
return createTransaction(operations, {
accountData: props.accountData,
horizon: props.horizon,
walletAccount: props.account
})
}
const promise = (async () => {
const account = await testnetHorizon.loadAccount("GBPBFWVBADSESGADWEGC7SGTHE3535FWK4BS6UW3WMHX26PHGIH5NF4W")
return buildTransaction(account, [
Operation.changeTrust({
asset: eurt
})
])
})()