Compare commits
1 Commits
fix/59-tra
...
5cac49e430
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5cac49e430 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -25,4 +25,3 @@ dist/
|
|||||||
|
|
||||||
# Yarn
|
# Yarn
|
||||||
.yarn-integrity
|
.yarn-integrity
|
||||||
package-lock.json
|
|
||||||
|
|||||||
6175
package-lock.json
generated
Normal file
6175
package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -78,12 +78,10 @@ function decodeCalldata(data, toAddress) {
|
|||||||
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
||||||
);
|
);
|
||||||
const isUnlimited = rawAmount === maxUint;
|
const isUnlimited = rawAmount === maxUint;
|
||||||
const amountRaw = isUnlimited
|
|
||||||
? "Unlimited"
|
|
||||||
: formatTxValue(formatUnits(rawAmount, tokenDecimals));
|
|
||||||
const amountStr = isUnlimited
|
const amountStr = isUnlimited
|
||||||
? "Unlimited"
|
? "Unlimited"
|
||||||
: amountRaw + (tokenSymbol ? " " + tokenSymbol : "");
|
: formatTxValue(formatUnits(rawAmount, tokenDecimals)) +
|
||||||
|
(tokenSymbol ? " " + tokenSymbol : "");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: "Token Approval",
|
name: "Token Approval",
|
||||||
@@ -102,11 +100,7 @@ function decodeCalldata(data, toAddress) {
|
|||||||
value: spender,
|
value: spender,
|
||||||
address: spender,
|
address: spender,
|
||||||
},
|
},
|
||||||
{
|
{ label: "Amount", value: amountStr },
|
||||||
label: "Amount",
|
|
||||||
value: amountStr,
|
|
||||||
rawValue: amountRaw,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -114,11 +108,9 @@ function decodeCalldata(data, toAddress) {
|
|||||||
if (parsed.name === "transfer") {
|
if (parsed.name === "transfer") {
|
||||||
const to = parsed.args[0];
|
const to = parsed.args[0];
|
||||||
const rawAmount = parsed.args[1];
|
const rawAmount = parsed.args[1];
|
||||||
const amountRaw = formatTxValue(
|
|
||||||
formatUnits(rawAmount, tokenDecimals),
|
|
||||||
);
|
|
||||||
const amountStr =
|
const amountStr =
|
||||||
amountRaw + (tokenSymbol ? " " + tokenSymbol : "");
|
formatTxValue(formatUnits(rawAmount, tokenDecimals)) +
|
||||||
|
(tokenSymbol ? " " + tokenSymbol : "");
|
||||||
|
|
||||||
return {
|
return {
|
||||||
name: "Token Transfer",
|
name: "Token Transfer",
|
||||||
@@ -133,11 +125,7 @@ function decodeCalldata(data, toAddress) {
|
|||||||
isToken: true,
|
isToken: true,
|
||||||
},
|
},
|
||||||
{ label: "Recipient", value: to, address: to },
|
{ label: "Recipient", value: to, address: to },
|
||||||
{
|
{ label: "Amount", value: amountStr },
|
||||||
label: "Amount",
|
|
||||||
value: amountStr,
|
|
||||||
rawValue: amountRaw,
|
|
||||||
},
|
|
||||||
],
|
],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -167,31 +155,20 @@ function showTxApproval(details) {
|
|||||||
tokenSymbol: token ? token.symbol : null,
|
tokenSymbol: token ? token.symbol : null,
|
||||||
};
|
};
|
||||||
|
|
||||||
// If this is an ERC-20 call or a swap, extract the real recipient, amount, and token info
|
// If this is an ERC-20 call, try to extract the real recipient and amount
|
||||||
const decoded = decodeCalldata(details.txParams.data, toAddr || "");
|
const decoded = decodeCalldata(details.txParams.data, toAddr || "");
|
||||||
if (decoded && decoded.details) {
|
if (decoded && decoded.details) {
|
||||||
let decodedTokenSymbol = null;
|
|
||||||
let decodedTokenAddress = null;
|
|
||||||
for (const d of decoded.details) {
|
for (const d of decoded.details) {
|
||||||
if (d.label === "Recipient" && d.address) {
|
if (d.label === "Recipient" && d.address) {
|
||||||
pendingTxDetails.to = d.address;
|
pendingTxDetails.to = d.address;
|
||||||
}
|
}
|
||||||
if (d.label === "Amount") {
|
if (d.label === "Amount") {
|
||||||
pendingTxDetails.amount = d.rawValue || d.value;
|
pendingTxDetails.amount = d.value;
|
||||||
}
|
|
||||||
if (d.label === "Token In" && !decodedTokenSymbol) {
|
|
||||||
// Extract token symbol and address from decoded details
|
|
||||||
decodedTokenSymbol = d.value;
|
|
||||||
if (d.address) decodedTokenAddress = d.address;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (token) {
|
if (token) {
|
||||||
pendingTxDetails.token = toAddr;
|
pendingTxDetails.token = toAddr;
|
||||||
pendingTxDetails.tokenSymbol = token.symbol;
|
pendingTxDetails.tokenSymbol = token.symbol;
|
||||||
} else if (decodedTokenAddress) {
|
|
||||||
// For swaps through routers: use the input token info
|
|
||||||
pendingTxDetails.token = decodedTokenAddress;
|
|
||||||
pendingTxDetails.tokenSymbol = decodedTokenSymbol;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -445,19 +445,12 @@ function decode(data, toAddress) {
|
|||||||
const maxUint160 = BigInt(
|
const maxUint160 = BigInt(
|
||||||
"0xffffffffffffffffffffffffffffffffffffffff",
|
"0xffffffffffffffffffffffffffffffffffffffff",
|
||||||
);
|
);
|
||||||
const rawAmount =
|
|
||||||
inputAmount >= maxUint160
|
|
||||||
? "Unlimited"
|
|
||||||
: formatAmount(inputAmount, inInfo.decimals);
|
|
||||||
const amountStr =
|
const amountStr =
|
||||||
inputAmount >= maxUint160
|
inputAmount >= maxUint160
|
||||||
? "Unlimited"
|
? "Unlimited"
|
||||||
: rawAmount + (inSymbol ? " " + inSymbol : "");
|
: formatAmount(inputAmount, inInfo.decimals) +
|
||||||
details.push({
|
(inSymbol ? " " + inSymbol : "");
|
||||||
label: "Amount",
|
details.push({ label: "Amount", value: amountStr });
|
||||||
value: amountStr,
|
|
||||||
rawValue: rawAmount,
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (outSymbol) {
|
if (outSymbol) {
|
||||||
|
|||||||
Reference in New Issue
Block a user