Skip to content

Commit

Permalink
Merge pull request #315 from Psychedelic/fix/xtc-burn-fix
Browse files Browse the repository at this point in the history
Fix/xtc burn fix
  • Loading branch information
tomiir authored Dec 21, 2021
2 parents d49bce1 + 233aae8 commit 094b0a1
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 9 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"emoji-log": "^1.0.2",
"emoji-picker-react": "^3.4.7",
"extensionizer": "^1.0.1",
"from-exponential": "^1.1.1",
"i18next": "^20.2.1",
"moment": "^2.29.1",
"qrcode": "^1.4.4",
Expand Down
9 changes: 8 additions & 1 deletion source/Background/Controller.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import qs from 'query-string';
import extension from 'extensionizer';
import fromExponential from 'from-exponential';
import { BackgroundController } from '@fleekhq/browser-rpc';
import { CONNECTION_STATUS } from '@shared/constants/connectionStatus';
import { areAllElementsIn } from '@shared/utils/array';
Expand Down Expand Up @@ -801,7 +802,13 @@ backgroundController.exposeController(
const xtcAmount = assets?.[DEFAULT_CURRENCY_MAP.XTC]?.amount * CYCLES_PER_TC;

if (xtcAmount - XTC_FEE > transfer.amount) {
const response = await burnXTC(String(transfer));
const stringBurnAmount = fromExponential(transfer.amount / CYCLES_PER_TC);
const burnParams = {
to: transfer.to,
amount: stringBurnAmount,
};

const response = await burnXTC(burnParams);
if (response.error) {
callback(null, false);
callback(ERRORS.SERVER_ERROR(response.error), null, [
Expand Down
13 changes: 5 additions & 8 deletions source/redux/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,11 @@ export const walletSlice = createSlice({
return type.toUpperCase();
};
const getSymbol = () => {
if ('tokenRegistryInfo' in trx.details)
return trx.details['tokenRegistryInfo'].symbol;
if ('nftRegistryInfo' in trx.details)
return 'NFT'
return trx?.details?.currency?.symbol ?? ''
}
if('utozz-siaaa-aaaam-qaaxq-cai' === trx?.details?.canisterId)
console.log('TRX', trx)
if ('tokenRegistryInfo' in trx.details) return trx.details.tokenRegistryInfo.symbol;
if ('nftRegistryInfo' in trx.details) return 'NFT';
return trx?.details?.currency?.symbol ?? '';
};
if (trx?.details?.canisterId === 'utozz-siaaa-aaaam-qaaxq-cai') console.log('TRX', trx);
const transaction = {
...asset,
type: getType(),
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6064,6 +6064,11 @@ fragment-cache@^0.2.1:
dependencies:
map-cache "^0.2.2"

from-exponential@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/from-exponential/-/from-exponential-1.1.1.tgz#41caff748d22e9c195713802cdac31acbe4b1b83"
integrity sha512-VBE7f5OVnYwdgB3LHa+Qo29h8qVpxhVO9Trlc+AWm+/XNAgks1tAwMFHb33mjeiof77GglsJzeYF7OqXrROP/A==

from2@^2.1.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/from2/-/from2-2.3.0.tgz#8bfb5502bde4a4d36cfdeea007fcca21d7e382af"
Expand Down

0 comments on commit 094b0a1

Please sign in to comment.