fix transfer amount decimal point
This commit is contained in:
parent
11aa0b8dc8
commit
fec5831ef8
5 changed files with 15 additions and 10 deletions
|
|
@ -36,7 +36,7 @@ const WalletSend = () => {
|
|||
const isSenderInfo = useCheckbox(false);
|
||||
const isReceiverInfo = useCheckbox(false);
|
||||
|
||||
const sendTransfer = (destination, amount, comment, assetId) => {
|
||||
const sendTransfer = (destination, amount, comment, assetId, decimalPoint) => {
|
||||
return new Promise(async (resolve, reject) => {
|
||||
// eslint-disable-next-line no-undef
|
||||
if (chrome.runtime.sendMessage) {
|
||||
|
|
@ -47,6 +47,7 @@ const WalletSend = () => {
|
|||
destination,
|
||||
amount,
|
||||
comment,
|
||||
decimalPoint,
|
||||
});
|
||||
|
||||
if (response.data) {
|
||||
|
|
@ -189,7 +190,8 @@ const WalletSend = () => {
|
|||
submitAddress,
|
||||
amount.value,
|
||||
comment.value,
|
||||
asset.assetId
|
||||
asset.assetId,
|
||||
asset.decimalPoint
|
||||
);
|
||||
console.log("transfer status", transferStatus);
|
||||
if (transferStatus.result) {
|
||||
|
|
|
|||
|
|
@ -52,13 +52,15 @@
|
|||
z-index: 20;
|
||||
width: 100%;
|
||||
left: 0;
|
||||
overflow: hidden;
|
||||
overflow: auto;
|
||||
border-radius: 0 0 8px 8px;
|
||||
border: 2px solid rgba(255, 255, 255, 0.5);
|
||||
border-top: none;
|
||||
background-color: #11316B;
|
||||
visibility: hidden;
|
||||
opacity: 0;
|
||||
max-height: 300px;
|
||||
|
||||
&.active{
|
||||
opacity: 1;
|
||||
visibility: visible;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ export async function fetchBackground(data) {
|
|||
});
|
||||
}
|
||||
|
||||
const multiplier = new Big((1e12).toString());
|
||||
|
||||
export const removeZeros = (amount, decimal_point = 12) => {
|
||||
const multiplier = new Big(10).pow(decimal_point);
|
||||
|
|
@ -25,7 +24,8 @@ export const removeZeros = (amount, decimal_point = 12) => {
|
|||
return fixedAmount;
|
||||
};
|
||||
|
||||
export const addZeros = (amount) => {
|
||||
export const addZeros = (amount, decimal_point = 12) => {
|
||||
const multiplier = new Big(10).pow(decimal_point);
|
||||
const bigAmount = new Big(amount);
|
||||
const fixedAmount = bigAmount.times(multiplier);
|
||||
return fixedAmount;
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ async function processRequest(request, sender, sendResponse) {
|
|||
break;
|
||||
|
||||
case "SEND_TRANSFER":
|
||||
transfer(request.assetId, request.destination, request.amount)
|
||||
transfer(request.assetId, request.destination, request.amount, request.decimalPoint)
|
||||
.then((data) => {
|
||||
sendResponse({ data });
|
||||
})
|
||||
|
|
|
|||
|
|
@ -259,13 +259,13 @@ export const ionicSwap = async (swapParams) => {
|
|||
to_initiator: [
|
||||
{
|
||||
asset_id: swapParams.destinationAssetID,
|
||||
amount: swapParams.destinationAssetAmount * 1e12,
|
||||
amount: addZeros(swapParams.destinationAssetAmount, 12),
|
||||
},
|
||||
],
|
||||
to_finalizer: [
|
||||
{
|
||||
asset_id: swapParams.currentAssetID,
|
||||
amount: swapParams.currentAssetAmount * 1e12,
|
||||
amount: addZeros(swapParams.currentAssetAmount * 1e12),
|
||||
},
|
||||
],
|
||||
mixins: 10,
|
||||
|
|
@ -302,12 +302,13 @@ export const ionicSwapAccept = async (swapParams) => {
|
|||
export const transfer = async (
|
||||
assetId = "d6329b5b1f7c0805b5c345f4957554002a2f557845f64d7645dae0e051a6498a",
|
||||
destination,
|
||||
amount
|
||||
amount,
|
||||
decimalPoint
|
||||
) => {
|
||||
const destinations = [
|
||||
{
|
||||
address: destination,
|
||||
amount: addZeros(amount),
|
||||
amount: addZeros(amount, typeof decimalPoint === "number" ? decimalPoint : 12),
|
||||
asset_id: assetId,
|
||||
},
|
||||
];
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue