diff --git a/packages/snap/snap.manifest.json b/packages/snap/snap.manifest.json index 850bd6d..5823801 100644 --- a/packages/snap/snap.manifest.json +++ b/packages/snap/snap.manifest.json @@ -7,7 +7,7 @@ "url": "https://github.com/MetaMask/template-snap-monorepo.git" }, "source": { - "shasum": "qHDT1vTWgUFNwrbA+eJsPwPUHDbwkrQXM94Eao40W8M=", + "shasum": "KXUWUpOnKM55BwS0UbSTDZfeL2XpDMOOidcAPNAmKVE=", "location": { "npm": { "filePath": "dist/bundle.js", diff --git a/packages/snap/src/index.ts b/packages/snap/src/index.ts index 0cf0a0f..281846b 100644 --- a/packages/snap/src/index.ts +++ b/packages/snap/src/index.ts @@ -1,5 +1,5 @@ import type { OnRpcRequestHandler } from '@metamask/snaps-types'; -import { heading, panel, text } from '@metamask/snaps-ui'; +import { copyable, heading, panel, text } from '@metamask/snaps-ui'; import createAccount from './utils/aptos/CreateAccount'; import transferCoin from './utils/aptos/TransferCoin'; @@ -60,6 +60,9 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ content: panel([ heading('Account Details'), text(`Address: **${accountDetails.accountAddress}**`), + text( + 'If you have created your account in devnet/testnet, we have already funded some Aptos to your account.', + ), ]), }, }), @@ -98,8 +101,15 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ type: 'confirmation', content: panel([ heading('Transfer Coin'), - text(`To: **${to}**`), + text(`To:`), + copyable(`${to}`), text(`Amount: **${amount}**`), + panel([ + heading('Gas fee insights'), + text('Average price per gas unit: **0.000001 APT**'), + text('Max price per gas unit: **0.0000015 APT**'), + text('Max gas limit: **200**(upto **0.0003 APT**)'), + ]), text('Are you sure you want to transfer?'), ]), }, @@ -117,9 +127,11 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ type: 'alert', content: panel([ heading('Amount transferred successfully.'), - text(`To: **${to}**`), + text(`To:`), + copyable(`${to}`), text(`Amount: **${amount}**`), - text(`Transaction Hash: **${txHash.hash}**`), + text(`Transaction Hash:`), + copyable(`${txHash.hash}`), ]), }, }); @@ -135,7 +147,8 @@ export const onRpcRequest: OnRpcRequestHandler = async ({ type: 'alert', content: panel([ heading('Funded 1 APT successfully.'), - text(`Transaction Hash: **${txHash}**`), + text(`Transaction Hash:`), + copyable(`${txHash}`), ]), }, }); diff --git a/server/src/privateKeyTxn.ts b/server/src/privateKeyTxn.ts index cb09c5f..b5e7a03 100644 --- a/server/src/privateKeyTxn.ts +++ b/server/src/privateKeyTxn.ts @@ -13,6 +13,15 @@ function decryptPhrase(encryptedPhrase: string, key: string): string { return originalText; } +function padHexString(input: string): string { + let hexString = input.startsWith('0x') ? input.slice(2) : input; + const length = 64; + while (hexString.length < length) { + hexString = '0' + hexString; + } + return '0x' + hexString; +} + export async function privateKeyTxn(request: Request) { const aptos = new Aptos(); @@ -28,7 +37,7 @@ export async function privateKeyTxn(request: Request) { const txn = await aptos.transferCoinTransaction({ sender: account, - recipient, + recipient: padHexString(recipient), amount, }); const txn1 = await aptos.signAndSubmitTransaction({