diff --git a/packages/extension/src/libs/spark-handler/callRPC.ts b/packages/extension/src/libs/spark-handler/callRPC.ts index 9dce2af48..f369aa27f 100644 --- a/packages/extension/src/libs/spark-handler/callRPC.ts +++ b/packages/extension/src/libs/spark-handler/callRPC.ts @@ -4,7 +4,7 @@ const rpcURL = "https://firo-rpc.publicnode.com/"; export async function callRPC( method: string, - params = [] + params?: object ): Promise { try { const response = await axios.post( @@ -13,7 +13,7 @@ export async function callRPC( jsonrpc: "1.0", id: "js-client", method: method, - params: params, + params: params ?? [], }, { headers: { diff --git a/packages/extension/src/libs/spark-handler/index.ts b/packages/extension/src/libs/spark-handler/index.ts index e2c52a5c1..b6eda8da6 100644 --- a/packages/extension/src/libs/spark-handler/index.ts +++ b/packages/extension/src/libs/spark-handler/index.ts @@ -18,3 +18,11 @@ export async function generateSparkAddress(): Promise { const newSparkAddress = await callRPC("getnewsparkaddress"); return newSparkAddress[0]; } + +export async function sendToSparkAddress(to: string, amount: string) { + return await callRPC("mintspark", [ + { + [to]: { amount: Number(amount) }, + }, + ]); +} diff --git a/packages/extension/src/providers/bitcoin/libs/utils.ts b/packages/extension/src/providers/bitcoin/libs/utils.ts index 6da7331ca..9c5251da1 100644 --- a/packages/extension/src/providers/bitcoin/libs/utils.ts +++ b/packages/extension/src/providers/bitcoin/libs/utils.ts @@ -6,6 +6,14 @@ import BigNumber from 'bignumber.js'; import { BitcoinNetwork } from '../types/bitcoin-network'; import { BTCTxInfo } from '../ui/types'; +export const isSparkAddress = (address = "") => { + if (address.length === 144 && address.startsWith("sm1")) { + // TODO: hack, change in future + return true; + } + return false; +}; + const isAddress = (address: string, network: BitcoinNetworkInfo): boolean => { try { BTCAddress.toOutputScript(address, network); diff --git a/packages/extension/src/providers/bitcoin/ui/send-transaction/tabs/transparent-send-tab.vue b/packages/extension/src/providers/bitcoin/ui/send-transaction/tabs/transparent-send-tab.vue new file mode 100644 index 000000000..41cef2344 --- /dev/null +++ b/packages/extension/src/providers/bitcoin/ui/send-transaction/tabs/transparent-send-tab.vue @@ -0,0 +1,687 @@ + + + + + diff --git a/packages/extension/src/ui/action/App.vue b/packages/extension/src/ui/action/App.vue index 3101b1eb0..7bda88cc6 100644 --- a/packages/extension/src/ui/action/App.vue +++ b/packages/extension/src/ui/action/App.vue @@ -63,6 +63,7 @@ @toggle:deposit="toggleDepositWindow" @action:generate-new-spark="generateNewSparkAddress" @open:buy-action="openBuyPage" + @update:spark-state-changed="getSparkAccountState" /> @@ -293,6 +294,15 @@ const generateNewSparkAddress = async () => { ); } }; +const getSparkAccountState = async (network: BaseNetwork) => { + if ( + network.name === NetworkNames.Firo || + network.name === NetworkNames.FiroTest + ) { + const sparkAccountResponse = await getSparkState(); + accountHeaderData.value.sparkAccount = { ...sparkAccountResponse }; + } +}; const setNetwork = async (network: BaseNetwork) => { trackNetworkSelected(NetworkChangeEvents.NetworkChangePopup, { provider: network.provider, @@ -315,7 +325,10 @@ const setNetwork = async (network: BaseNetwork) => { let sparkAccount: SparkAccount | null = null; - if (network.name === NetworkNames.Firo) { + if ( + network.name === NetworkNames.Firo || + network.name === NetworkNames.FiroTest + ) { const sparkAccountResponse = await getSparkState(); sparkAccount = { ...sparkAccountResponse }; } diff --git a/packages/extension/src/ui/action/router/index.ts b/packages/extension/src/ui/action/router/index.ts index b68e90e00..5c552122a 100644 --- a/packages/extension/src/ui/action/router/index.ts +++ b/packages/extension/src/ui/action/router/index.ts @@ -9,6 +9,7 @@ import Intro from '@action/views/intro/index.vue'; import Swap from '@action/views/swap/index.vue'; import SwapBestOffer from '@action/views/swap/views/swap-best-offer/index.vue'; import VerifyTransaction from '@action/views/verify-transaction/index.vue'; +import VerifySendToSparkTransaction from "@action/views/verify-send-to-spark-transaction/index.vue"; import SendTransaction from '@action/views/send-transaction/index.vue'; const routes = { @@ -68,6 +69,13 @@ const routes = { }, name: 'verify-transaction', }, + verifySendToSpark: { + path: "/verify-send-to-spark-transaction/:id?", + components: { + view: VerifySendToSparkTransaction, + }, + name: "verify-send-to-spark", + }, swap: { path: '/swap/:id?', components: { diff --git a/packages/extension/src/ui/action/views/deposit/index.vue b/packages/extension/src/ui/action/views/deposit/index.vue index c37c8416b..565fb1db8 100644 --- a/packages/extension/src/ui/action/views/deposit/index.vue +++ b/packages/extension/src/ui/action/views/deposit/index.vue @@ -28,7 +28,7 @@ -
+
+
+
+
+ +
+

Verify Transaction

+ + + +
+ +

+ Double check the information and confirm transaction +

+
+ + + + + + {{ errorMsg }} +
+
+ +
+
+ +
+
+ +
+
+
+ + +
+ + + + +