From e3ddb539913f19a2db29f88acd13b1c2cabfbf81 Mon Sep 17 00:00:00 2001 From: AricRedemption Date: Fri, 26 Apr 2024 16:03:18 +0800 Subject: [PATCH] fix: ft token send and inscribe api --- src/background.ts | 6 +- src/components/AssetLogo.vue | 2 +- src/lib/actions/btc/sign-message.ts | 2 - src/lib/crypto.ts | 1 - src/lib/formatters.ts | 4 +- src/lib/utils.ts | 1 + src/pages/wallet/BRC20.vue | 2 +- src/pages/wallet/Send.vue | 1 - src/pages/wallet/SendToken.vue | 226 +++++++++++------- src/pages/wallet/Transfer.vue | 11 +- src/pages/wallet/components/ActivityItem.vue | 37 +-- .../components/TransactionResultModal.vue | 43 ++-- src/router.ts | 2 +- 13 files changed, 183 insertions(+), 155 deletions(-) diff --git a/src/background.ts b/src/background.ts index 7af5f6f3..9f7e1a3d 100644 --- a/src/background.ts +++ b/src/background.ts @@ -4,9 +4,10 @@ import { network } from '@/lib/network' import actions from './data/query-actions' import browser from 'webextension-polyfill' import exActions from './data/extension-actions' -import { getCurrentWalletId, hasWallets } from './lib/wallet' import { getAddress, getCurrentAccountId } from './lib/account' import { NOTIFICATION_HEIGHT, NOTIFICATION_WIDTH } from './data/config' +import { getCurrentWalletId, hasWallets, getCurrentWallet } from './lib/wallet' +import { Chain } from '@metalet/utxo-wallet-service' // const browser = window.browser as typeof chromex browser.runtime.onMessage.addListener(async (msg, sender) => { @@ -80,7 +81,8 @@ browser.runtime.onMessage.addListener(async (msg, sender) => { if (actionName === 'InscribeTransfer') { const rawUrl = 'popup.html#/wallet/inscribe' let popupUrl = browser.runtime.getURL(rawUrl) - const address = await getAddress('btc') + const wallet = await getCurrentWallet(Chain.BTC) + const address = wallet.getAddress() popupUrl += `/${msg.params}/${address}` let top = 0 let left = 0 diff --git a/src/components/AssetLogo.vue b/src/components/AssetLogo.vue index d0e5e4d8..026b9406 100644 --- a/src/components/AssetLogo.vue +++ b/src/components/AssetLogo.vue @@ -12,7 +12,7 @@ const { logo, chain, symbol } = defineProps<{ chain?: Chain symbol: string type: 'network' | 'activity' - flow?: 'Send' | 'Receive' + flow?: 'Send' | 'Receive' | 'Transfer' }>() diff --git a/src/lib/actions/btc/sign-message.ts b/src/lib/actions/btc/sign-message.ts index f87be1b7..3aaca888 100644 --- a/src/lib/actions/btc/sign-message.ts +++ b/src/lib/actions/btc/sign-message.ts @@ -1,7 +1,5 @@ -import { getPrivateKey } from '@/lib/account' import { getCurrentWallet } from '@/lib/wallet' import { Chain } from '@metalet/utxo-wallet-service' -import { Message, PrivateKey } from 'bitcore-lib' export async function process(message: string): Promise { const wallet = await getCurrentWallet(Chain.BTC) diff --git a/src/lib/crypto.ts b/src/lib/crypto.ts index e86d3fd7..8daf7f43 100644 --- a/src/lib/crypto.ts +++ b/src/lib/crypto.ts @@ -345,7 +345,6 @@ export const payTransactions = async ( } const addressObj = new mvc.Address(address, network) - console.log({ addressObj }) // find out the total amount of the transaction (total output minus total input) const totalOutput = tx.outputs.reduce((acc, output) => acc + output.satoshis, 0) const totalInput = tx.inputs.reduce((acc, input) => acc + input.output!.satoshis, 0) diff --git a/src/lib/formatters.ts b/src/lib/formatters.ts index f3d8c9db..86569fad 100644 --- a/src/lib/formatters.ts +++ b/src/lib/formatters.ts @@ -15,8 +15,8 @@ export const prettifyTxId = (txId: string, useDigits = 6) => { return `${txId.slice(0, useDigits)}...${txId.slice(-useDigits)}` } -export const prettifyAddress = (txId: string, useDigits = 6) => { - return `${txId.slice(0, useDigits)}...${txId.slice(-useDigits)}` +export const prettifyAddress = (address: string, useDigits = 6) => { + return `${address.slice(0, useDigits)}...${address.slice(-useDigits)}` } export const prettifyBalance = (balance: number, symbol: string = 'SPACE'): string => { diff --git a/src/lib/utils.ts b/src/lib/utils.ts index b676eadd..fff083f3 100644 --- a/src/lib/utils.ts +++ b/src/lib/utils.ts @@ -26,6 +26,7 @@ export const goToTab = (path: string, created = false) => { router.push(path) } else { window.open(`${window.location.href.split('#')[0]}#${path}`, '_blank') + window.close() } } diff --git a/src/pages/wallet/BRC20.vue b/src/pages/wallet/BRC20.vue index feb536b2..d35a018a 100644 --- a/src/pages/wallet/BRC20.vue +++ b/src/pages/wallet/BRC20.vue @@ -161,7 +161,7 @@ watch(assetUSD, (_assetUSD) => {
- + Mint Mint diff --git a/src/pages/wallet/Send.vue b/src/pages/wallet/Send.vue index 745c02a5..4ba84dfa 100644 --- a/src/pages/wallet/Send.vue +++ b/src/pages/wallet/Send.vue @@ -235,7 +235,6 @@ async function send() {
-
{{ symbol }}
diff --git a/src/pages/wallet/SendToken.vue b/src/pages/wallet/SendToken.vue index 4a93486a..d05bc93e 100644 --- a/src/pages/wallet/SendToken.vue +++ b/src/pages/wallet/SendToken.vue @@ -1,32 +1,44 @@