Skip to content

Commit

Permalink
fix: minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
narekpetrosyan committed Dec 23, 2024
1 parent c536c16 commit f9d1993
Show file tree
Hide file tree
Showing 11 changed files with 3,717 additions and 3,248 deletions.
21 changes: 18 additions & 3 deletions packages/extension/src/libs/spark-handler/callRPC.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import axios from "axios";

const rpcURL = "https://firo-rpc.publicnode.com/";
const DEFAULT_TIMEOUT = 30000;

const RPC_URLS = {
mainnet: "https://firo-rpc.publicnode.com/",
};

const axiosInstance = axios.create({
timeout: DEFAULT_TIMEOUT,
headers: {
"Content-Type": "application/json",
}
});

export async function callRPC<T = any>(
method: string,
params?: object
): Promise<T> {
try {
const response = await axios.post(
rpcURL,
const response = await axiosInstance.post(
RPC_URLS['mainnet'],
{
jsonrpc: "1.0",
id: "js-client",
Expand All @@ -21,6 +32,10 @@ export async function callRPC<T = any>(
},
}
);

if (!response.data || response.data.result === undefined) {
throw new Error('Invalid RPC response structure');
}
return response.data.result;
} catch (error) {
console.error("RPC Error:", error);
Expand Down
6 changes: 3 additions & 3 deletions packages/extension/src/providers/bitcoin/libs/api-firo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class API implements ProviderAPIInterface {
return getBitcoinAddress(pubkey, this.networkInfo);
}

// eslint-disable-next-line @typescript-eslint/no-empty-function
async init(): Promise<void> {}

async getRawTransaction(hash: string): Promise<string | null> {
Expand Down Expand Up @@ -133,7 +133,7 @@ class API implements ProviderAPIInterface {
ret.sort((a, b) => {
return a.value - b.value;
});
return [ret.at(-1)!]; // TODO: check or filter same values
return ret;
}

async getUTXOs(pubkey: string): Promise<HaskoinUnspentType[]> {
Expand All @@ -145,7 +145,7 @@ class API implements ProviderAPIInterface {
return filterOutOrdinals(
address,
this.networkInfo.name,
await this.FiroToHaskoinUTXOs(utxos, address)
[(await this.FiroToHaskoinUTXOs(utxos, address)).at(-1)!]
).then((futxos) => {
futxos.sort((a, b) => {
return a.value - b.value;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NetworkNames } from "@enkryptcom/types";
import icon from './icons/firo.svg';
import {
BitcoinNetwork,
BitcoinNetworkOptions,
Expand All @@ -18,7 +19,7 @@ const firoOptions: BitcoinNetworkOptions = {
isTestNetwork: true,
currencyName: "tFIRO",
currencyNameLong: "tFiro",
icon: require("./icons/firo.svg"),
icon,
decimals: 8,
node: "https://testexplorer.firo.org",
coingeckoID: "zcoin",
Expand Down
3 changes: 2 additions & 1 deletion packages/extension/src/providers/bitcoin/networks/firo.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { NetworkNames } from "@enkryptcom/types";
import icon from './icons/firo.svg';
import {
BitcoinNetwork,
BitcoinNetworkOptions,
Expand All @@ -18,7 +19,7 @@ const firoOptions: BitcoinNetworkOptions = {
isTestNetwork: false,
currencyName: "FIRO",
currencyNameLong: "Firo",
icon: require("./icons/firo.svg"),
icon,
decimals: 8,
node: "https://explorer.firo.org",
coingeckoID: "zcoin",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,23 @@
</template>

<script setup lang="ts">
import { computed } from "@vue/reactivity";
import { PropType, ref } from "vue";
import { PropType, ref, computed } from "vue";
import { isAddress, isSparkAddress } from "@/providers/bitcoin/libs/utils";
import { BitcoinNetwork } from "@/providers/bitcoin/types/bitcoin-network";
const isFocus = ref<boolean>(false);
const addressInput = ref<HTMLInputElement>();
const pasteFromClipboard = () => {
addressInput.value?.focus();
document.execCommand("paste");
const pasteFromClipboard = async () => {
try {
const text = await navigator.clipboard.readText();
if (addressInput.value) {
addressInput.value?.focus()
emit("update:inputAddress", text);
}
} catch (err) {
console.error("Failed to read clipboard:", err);
}
};
defineExpose({ addressInput, pasteFromClipboard });
Expand Down Expand Up @@ -83,7 +89,7 @@ const changeFocus = (val: FocusEvent) => {
</script>

<style lang="less">
@import "~@action/styles/theme.less";
@import "@action/styles/theme.less";
.send-address-input {
height: 64px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ const inputAmount = (inputAmount: string) => {
}
const inputAmountBn = new BigNumber(inputAmount);
isMaxSelected.value = false;
amount.value = inputAmountBn.lt(0) ? "0" : inputAmount;
amount.value = inputAmountBn.lt(0) ? "0" : inputAmountBn.toString();
};
const sendAction = async () => {
Expand Down Expand Up @@ -266,8 +266,8 @@ const close = () => {
</script>

<style lang="less" scoped>
@import "~@action/styles/theme.less";
@import "~@action/styles/custom-scroll.less";
@import "@action/styles/theme.less";
@import "@action/styles/custom-scroll.less";
.form__container {
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,8 @@ const sendAction = async () => {
</script>

<style lang="less" scoped>
@import "~@action/styles/theme.less";
@import "~@action/styles/custom-scroll.less";
@import "@action/styles/theme.less";
@import "@action/styles/custom-scroll.less";
.form__container {
display: flex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
</template>

<script setup lang="ts">
import { onBeforeMount, ref, ComponentPublicInstance, defineEmits } from "vue";
import { onBeforeMount, ref, ComponentPublicInstance } from "vue";
import { useRoute, useRouter } from "vue-router";
import CloseIcon from "@action/icons/common/close-icon.vue";
import BaseButton from "@action/components/base-button/index.vue";
Expand Down Expand Up @@ -215,8 +215,8 @@ const isHasScroll = () => {
</script>

<style lang="less" scoped>
@import "~@action/styles/theme.less";
@import "~@action/styles/custom-scroll.less";
@import "@action/styles/theme.less";
@import "@action/styles/custom-scroll.less";
.container {
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,8 @@ const isHasScroll = () => {
</script>

<style lang="less" scoped>
@import "~@action/styles/theme.less";
@import "~@action/styles/custom-scroll.less";
@import "@action/styles/theme.less";
@import "@action/styles/custom-scroll.less";
.container {
width: 100%;
Expand Down
2 changes: 1 addition & 1 deletion packages/hw-wallets/src/ledger/bitcoin/configs.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NetworkNames } from "@enkryptcom/types";
import { bip44Paths } from "@src/configs";
import { bip44Paths } from "../../configs";

const supportedPaths = {
[NetworkNames.Bitcoin]: [bip44Paths.bitcoinSegwitLedger],
Expand Down
Loading

0 comments on commit f9d1993

Please sign in to comment.