btc-wallet 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.js +23 -10
- package/dist/index.js.map +2 -2
- package/dist/utils/setupBTCWallet.d.ts +1 -1
- package/esm/index.js +23 -10
- package/esm/index.js.map +2 -2
- package/package.json +1 -1
@@ -11,7 +11,7 @@ interface BTCWalletParams {
|
|
11
11
|
autoConnect?: boolean;
|
12
12
|
isDev?: boolean;
|
13
13
|
}
|
14
|
-
export declare function setupBTCWallet({ iconUrl, deprecated, autoConnect, }?: BTCWalletParams | undefined): WalletModuleFactory<InjectedWallet>;
|
14
|
+
export declare function setupBTCWallet({ iconUrl, deprecated, autoConnect, isDev, }?: BTCWalletParams | undefined): WalletModuleFactory<InjectedWallet>;
|
15
15
|
declare const _default: {
|
16
16
|
setupBTCWallet: typeof setupBTCWallet;
|
17
17
|
};
|
package/esm/index.js
CHANGED
@@ -2317,12 +2317,17 @@ import bs58 from "bs58";
|
|
2317
2317
|
import { sha256 } from "js-sha256";
|
2318
2318
|
|
2319
2319
|
// src/utils/initWalletButton.ts
|
2320
|
+
var walletUrlConfig = {
|
2321
|
+
dev: "https://wallet-dev.satoshibridge.top",
|
2322
|
+
testnet: "https://wallet-test.satoshibridge.top",
|
2323
|
+
mainnet: "https://wallet.satoshibridge.top"
|
2324
|
+
};
|
2320
2325
|
function setupWalletButton(network, wallet, originalWallet) {
|
2321
2326
|
if (document.getElementById("satoshi-wallet-button")) {
|
2322
2327
|
return;
|
2323
2328
|
}
|
2324
2329
|
const iframe = createIframe({
|
2325
|
-
iframeUrl: network
|
2330
|
+
iframeUrl: walletUrlConfig[network],
|
2326
2331
|
iframeStyle: { width: "400px", height: "650px" }
|
2327
2332
|
});
|
2328
2333
|
iframe.addEventListener("mouseenter", () => {
|
@@ -2453,8 +2458,8 @@ var { transfer, functionCall } = actionCreators;
|
|
2453
2458
|
var config = {
|
2454
2459
|
dev: {
|
2455
2460
|
base_url: "https://api.dev.satoshibridge.top/v1",
|
2456
|
-
token: "nbtc1-nsp.
|
2457
|
-
contractId: "dev1-nsp.
|
2461
|
+
token: "nbtc1-nsp.testnet",
|
2462
|
+
contractId: "dev1-nsp.testnet"
|
2458
2463
|
},
|
2459
2464
|
testnet: {
|
2460
2465
|
base_url: "https://api.testnet.satoshibridge.top/v1",
|
@@ -2525,7 +2530,8 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
2525
2530
|
signAndSendTransactions
|
2526
2531
|
};
|
2527
2532
|
const currentConfig = "isDev" in metadata && metadata.isDev ? config.dev : config[options.network.networkId];
|
2528
|
-
|
2533
|
+
const walletNetwork = "isDev" in metadata && metadata.isDev ? "dev" : options.network.networkId;
|
2534
|
+
initWalletButton(walletNetwork, wallet);
|
2529
2535
|
if (!inter) {
|
2530
2536
|
inter = setInterval(() => __async(void 0, null, function* () {
|
2531
2537
|
const btcContext = window.btcContext;
|
@@ -2535,7 +2541,7 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
2535
2541
|
context.on("updatePublicKey", (btcPublicKey) => __async(void 0, null, function* () {
|
2536
2542
|
const { nearTempAddress } = yield getNearAccountByBtcPublicKey(btcPublicKey);
|
2537
2543
|
removeWalletButton();
|
2538
|
-
initWalletButton(
|
2544
|
+
initWalletButton(walletNetwork, wallet);
|
2539
2545
|
emitter.emit("accountsChanged", {
|
2540
2546
|
accounts: [
|
2541
2547
|
{
|
@@ -2592,7 +2598,7 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
2592
2598
|
const accountId = state.getAccount();
|
2593
2599
|
const publicKey = state.getPublicKey();
|
2594
2600
|
const btcContext = window.btcContext;
|
2595
|
-
initWalletButton(
|
2601
|
+
initWalletButton(walletNetwork, wallet);
|
2596
2602
|
if (accountId && publicKey) {
|
2597
2603
|
return [
|
2598
2604
|
{
|
@@ -2713,7 +2719,12 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
2713
2719
|
gas_limit: "3000",
|
2714
2720
|
use_near_pay_gas: false
|
2715
2721
|
};
|
2716
|
-
const
|
2722
|
+
const nearAccount = yield provider.query({
|
2723
|
+
request_type: "view_account",
|
2724
|
+
account_id: accountId,
|
2725
|
+
finality: "final"
|
2726
|
+
});
|
2727
|
+
const availableBalance = parseFloat(nearAccount.amount) / __pow(10, 24);
|
2717
2728
|
if (availableBalance > 0.2) {
|
2718
2729
|
intention.use_near_pay_gas = true;
|
2719
2730
|
}
|
@@ -2781,7 +2792,8 @@ function uploadBTCTx(url, data) {
|
|
2781
2792
|
function setupBTCWallet({
|
2782
2793
|
iconUrl = "https://assets.deltatrade.ai/assets/chain/btc.svg",
|
2783
2794
|
deprecated = false,
|
2784
|
-
autoConnect = true
|
2795
|
+
autoConnect = true,
|
2796
|
+
isDev = false
|
2785
2797
|
} = {}) {
|
2786
2798
|
const btcWallet = () => __async(this, null, function* () {
|
2787
2799
|
return {
|
@@ -2794,7 +2806,8 @@ function setupBTCWallet({
|
|
2794
2806
|
downloadUrl: iconUrl,
|
2795
2807
|
deprecated,
|
2796
2808
|
available: true,
|
2797
|
-
autoConnect
|
2809
|
+
autoConnect,
|
2810
|
+
isDev
|
2798
2811
|
},
|
2799
2812
|
init: BTCWallet
|
2800
2813
|
};
|
@@ -2854,7 +2867,7 @@ function pollTransactionStatuses(network, hashes) {
|
|
2854
2867
|
|
2855
2868
|
// src/index.ts
|
2856
2869
|
var getVersion = () => {
|
2857
|
-
return "0.2.
|
2870
|
+
return "0.2.3";
|
2858
2871
|
};
|
2859
2872
|
if (typeof window !== "undefined") {
|
2860
2873
|
window.__PARTICLE_BTC_CONNECT_VERSION = getVersion();
|