Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
}else {
type = 'retire'
const gas = amount - asset.retire
amount = asset.retire
items.push({
type: 'sent',
amount: normalizeBtmAmountUnit(assetId, gas, this.props.btmAmountUnit),
asset: assetAlias ? assetAlias : <code>{assetId}</code>,
assetId: assetId,
account: account.alias ? account.alias : <code>{accountId}</code>,
accountId: accountId,
})
}
items.push({
type: type,
amount: asset.decimals? converIntToDec(amount, asset.decimals) : normalizeBtmAmountUnit(assetId, amount, this.props.btmAmountUnit),
asset: assetAlias ? assetAlias : <code>{assetId}</code>,
assetId: assetId,
account: account.alias ? account.alias : <code>{accountId}</code>,
accountId: accountId,
})
}
if(account['spend']< account['control'] && account['control'] > 0){
const amount = account['control']- account['spend']
const type = asset.issue >= amount? 'issue': 'received'
items.push({
type: type,
amount: asset.decimals? converIntToDec(amount, asset.decimals) : normalizeBtmAmountUnit(assetId, amount, this.props.btmAmountUnit),
asset: assetAlias ? assetAlias : <code>{assetId}</code>,
assetId: assetId,
account: account.alias ? account.alias : <code>{accountId}</code>,
const normalize = (value, asset) => {
if (asset === btmID || asset === 'BTM'){
return normalizeBTMAmountUnit(btmID, value, btmAmountUnit)
}else if( assetDecimal ){
return converIntToDec(value, assetDecimal)
}else{
return value
}
}
nonAccountTypes.forEach((type) => {
if (asset[type] > 0) {
items.push({
type: INOUT_TYPES[type],
rawAction: type,
amount: asset.decimals? converIntToDec(asset[type], asset.decimals) : normalizeBtmAmountUnit(assetId, asset[type], this.props.btmAmountUnit),
asset: asset.alias ? asset.alias : <code>{assetId}</code>,
assetId: assetId,
})
}
})
const normalizeBtmAmountUnit = (assetID, amount, btmAmountUnit) => {
//normalize BTM Amount
if (assetID === btmID) {
switch (btmAmountUnit){
case 'BTM':
return converIntToDec(amount, 8)
case 'mBTM':
return converIntToDec(amount, 5)
}
}
return amount
}
inouts.forEach(inout => {
const assetId = inout.assetId
let filteredAsset = assets
filteredAsset = filteredAsset.filter(asset => asset.id === assetId)
let alias = assetId
let amount = inout.amount
if(filteredAsset.length === 1){
alias = filteredAsset[0].alias
amount = assetId===btmID?
normalizeGlobalBTMAmount(btmID, amount, this.props.btmAmountUnit):
converIntToDec(amount, filteredAsset[0].definition.decimals)
}
items.push({
type: inout.type,
amount: amount,
assetAlias: alias ,
assetId: assetId,
address: inout.address,
controlProgram: inout.controlProgram
})
})
const normalizeBtmAmountUnit = (assetID, amount, btmAmountUnit) => {
//normalize BTM Amount
if (assetID === btmID) {
switch (btmAmountUnit){
case 'BTM':
return converIntToDec(amount, 8)
case 'mBTM':
return converIntToDec(amount, 5)
}
}
return amount
}
const normalizeBtmAmountUnit = (assetID, amount, btmAmountUnit) => {
//normalize BTM Amount
if (assetID === btmID) {
switch (btmAmountUnit){
case 'BTM':
return converIntToDec(amount, 8)
case 'mBTM':
return converIntToDec(amount, 5)
}
}
return amount
}