diff --git a/packages/snap/snap.manifest.json b/packages/snap/snap.manifest.json
index 02a1bea..cbadce8 100644
--- a/packages/snap/snap.manifest.json
+++ b/packages/snap/snap.manifest.json
@@ -7,7 +7,7 @@
"url": "https://github.com/polkagate/polkamask.git"
},
"source": {
- "shasum": "pfHNpIzWs5bNt6+gN5oqFwg5LqnEljSox9GX8/kM7h4=",
+ "shasum": "zKNwgefHGQqz8h/tnMRKYyRUwxyvGf12iZVSA28zAYw=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
diff --git a/packages/snap/src/rpc/showConfirmTx.ts b/packages/snap/src/rpc/showConfirmTx.ts
index 3c54a3d..b08b81c 100644
--- a/packages/snap/src/rpc/showConfirmTx.ts
+++ b/packages/snap/src/rpc/showConfirmTx.ts
@@ -1,85 +1,30 @@
/* eslint-disable no-case-declarations */
/* eslint-disable jsdoc/require-jsdoc */
-import {
- copyable,
- divider,
- heading,
- image,
- panel,
- text,
-} from '@metamask/snaps-sdk';
+import { divider, heading, image, panel, text } from '@metamask/snaps-sdk';
import { ApiPromise } from '@polkadot/api';
-import { Compact, u128 } from '@polkadot/types';
import { SignerPayloadJSON } from '@polkadot/types/types';
-import { BN, bnToBn } from '@polkadot/util';
+import { bnToBn } from '@polkadot/util';
import { Balance } from '@polkadot/types/interfaces';
import getLogo from '../util/getLogo';
import getChainName from '../util/getChainName';
+import { formatCamelCase } from '../util/formatCamelCase';
+import { getIdentity } from '../util/getIdentity';
+import { txContent } from './txContent';
import { Decoded, getDecoded } from '.';
-const FLOATING_POINT_DIGIT = 4;
const EMPTY_LOGO = ``;
-export function fixFloatingPoint(
- _number: number | string,
- decimalDigit = FLOATING_POINT_DIGIT,
- commify?: boolean,
-): string {
- // make number positive if it is negative
- const sNumber =
- Number(_number) < 0 ? String(-Number(_number)) : String(_number);
-
- const dotIndex = sNumber.indexOf('.');
-
- if (dotIndex < 0) {
- return sNumber;
- }
-
- let integerDigits = sNumber.slice(0, dotIndex);
-
- integerDigits = commify
- ? Number(integerDigits).toLocaleString()
- : integerDigits;
- const fractionalDigits = sNumber.slice(dotIndex, dotIndex + decimalDigit + 1);
-
- return integerDigits + fractionalDigits;
-}
-
-function formatCamelCase(input?: string) {
- return input
- ?.replace(/([a-z])([A-Z])/g, '$1 $2') // Add space between camelCase
- ?.replace(/\b(\w)/, (char) => char.toUpperCase()); // Capitalize the first letter
-}
-
-export function amountToHuman(
- _amount: string | number | BN | bigint | Compact | undefined,
- _decimals: number | undefined,
- decimalDigits?: number,
- commify?: boolean,
-): string {
- if (!_amount || !_decimals) {
- return '';
- }
-
- // eslint-disable-next-line no-param-reassign
- _amount = String(_amount).replace(/,/g, '');
-
- const x = 10 ** _decimals;
-
- return fixFloatingPoint(Number(_amount) / x, decimalDigits, commify);
-}
-
const transactionContent = (
api: ApiPromise,
origin: string,
payload: SignerPayloadJSON,
partialFee: Balance,
decoded: Decoded,
+ maybeReceiverIdentity: string,
) => {
const headingText = `Transaction Approval Request from ${origin}`;
- const decodedArgs = decoded?.args;
const { args, callIndex } = api.createType('Call', payload.method);
const { method, section } = api.registry.findMetaCall(callIndex);
@@ -90,155 +35,38 @@ const transactionContent = (
let chainLogoSvg = EMPTY_LOGO;
const dataURI = getLogo(payload.genesisHash);
const maybeSvgString = atob(
- dataURI.replace(/data:image\/svg\+xml;base64,/, ''),
+ dataURI.replace(/data:image\/svg\+xml;base64,/u, ''),
);
const indexOfFirstSvgTag = maybeSvgString.indexOf('