btc-wallet 0.3.24 → 0.3.27

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,8 +1,9 @@
1
1
  import type { Wallet } from '@near-wallet-selector/core';
2
+ import { type ENV } from '../config';
2
3
  interface OriginalWallet {
3
4
  account: string | null;
4
5
  getPublicKey: () => Promise<string>;
5
6
  }
6
- export declare function setupWalletButton(network: string, wallet: Wallet, originalWallet: OriginalWallet): void;
7
+ export declare function setupWalletButton(env: ENV, wallet: Wallet, originalWallet: OriginalWallet): void;
7
8
  export declare function removeWalletButton(): void;
8
9
  export {};
package/esm/index.js CHANGED
@@ -2570,19 +2570,63 @@ import { baseDecode } from "@near-js/utils";
2570
2570
  import bs58 from "bs58";
2571
2571
  import { sha256 } from "js-sha256";
2572
2572
 
2573
- // src/utils/initWalletButton.ts
2574
- var walletUrlConfig = {
2575
- dev: "https://wallet-dev.satoshibridge.top",
2576
- testnet: "https://wallet-test.satoshibridge.top",
2577
- mainnet: "https://wallet.satoshibridge.top"
2573
+ // src/config.ts
2574
+ var walletConfig = {
2575
+ dev: {
2576
+ base_url: "https://api.dev.satoshibridge.top",
2577
+ token: "nbtc-dev.testnet",
2578
+ accountContractId: "acc-dev.testnet",
2579
+ bridgeContractId: "brg-dev.testnet",
2580
+ walletUrl: "https://wallet-dev.satoshibridge.top",
2581
+ bridgeUrl: "https://dev.satoshibridge.top/"
2582
+ },
2583
+ testnet: {
2584
+ base_url: "https://api.testnet.satoshibridge.top",
2585
+ token: "nbtc2-nsp.testnet",
2586
+ accountContractId: "acc2-nsp.testnet",
2587
+ bridgeContractId: "brg2-nsp.testnet",
2588
+ walletUrl: "https://wallet-test.satoshibridge.top",
2589
+ bridgeUrl: "https://testnet.satoshibridge.top/"
2590
+ },
2591
+ private_mainnet: {
2592
+ base_url: "https://api.stg.satoshibridge.top",
2593
+ token: "nbtc.toalice.near",
2594
+ accountContractId: "acc.toalice.near",
2595
+ bridgeContractId: "brg.toalice.near",
2596
+ walletUrl: "https://wallet-stg.satoshibridge.top",
2597
+ bridgeUrl: "https://stg.satoshibridge.top/"
2598
+ },
2599
+ mainnet: {
2600
+ base_url: "https://api.mainnet.satoshibridge.top",
2601
+ token: "nbtc.toalice.near",
2602
+ accountContractId: "acc.toalice.near",
2603
+ bridgeContractId: "brg.toalice.near",
2604
+ walletUrl: "https://wallet.satoshibridge.top",
2605
+ bridgeUrl: "https://www.satoshibridge.top/"
2606
+ }
2578
2607
  };
2579
- function setupWalletButton(network, wallet, originalWallet) {
2608
+ var nearRpcUrls = {
2609
+ mainnet: [
2610
+ "https://near.lava.build",
2611
+ "https://rpc.mainnet.near.org",
2612
+ "https://free.rpc.fastnear.com",
2613
+ "https://near.drpc.org"
2614
+ ],
2615
+ testnet: ["https://rpc.testnet.near.org"]
2616
+ };
2617
+ var btcRpcUrls = {
2618
+ mainnet: "https://mempool.space/api",
2619
+ testnet: "https://mempool.space/testnet/api"
2620
+ };
2621
+
2622
+ // src/utils/initWalletButton.ts
2623
+ function setupWalletButton(env, wallet, originalWallet) {
2580
2624
  console.log("setupWalletButton");
2581
2625
  if (document.getElementById("satoshi-wallet-button")) {
2582
2626
  return;
2583
2627
  }
2584
2628
  const iframe = createIframe({
2585
- iframeUrl: walletUrlConfig[network],
2629
+ iframeUrl: walletConfig[env].walletUrl,
2586
2630
  iframeStyle: { width: "400px", height: "650px" }
2587
2631
  });
2588
2632
  iframe.addEventListener("mouseenter", () => {
@@ -2713,55 +2757,6 @@ function removeWalletButton() {
2713
2757
  iframe == null ? void 0 : iframe.remove();
2714
2758
  }
2715
2759
 
2716
- // src/config.ts
2717
- var walletConfig = {
2718
- dev: {
2719
- base_url: "https://api.dev.satoshibridge.top",
2720
- token: "nbtc-dev.testnet",
2721
- accountContractId: "acc-dev.testnet",
2722
- bridgeContractId: "brg-dev.testnet",
2723
- walletUrl: "https://wallet-dev.satoshibridge.top",
2724
- bridgeUrl: "https://dev.satoshibridge.top/"
2725
- },
2726
- testnet: {
2727
- base_url: "https://api.testnet.satoshibridge.top",
2728
- token: "nbtc2-nsp.testnet",
2729
- accountContractId: "acc2-nsp.testnet",
2730
- bridgeContractId: "brg2-nsp.testnet",
2731
- walletUrl: "https://wallet-test.satoshibridge.top",
2732
- bridgeUrl: "https://testnet.satoshibridge.top/"
2733
- },
2734
- private_mainnet: {
2735
- base_url: "https://api.stg.satoshibridge.top",
2736
- token: "nbtc.toalice.near",
2737
- accountContractId: "acc.toalice.near",
2738
- bridgeContractId: "brg.toalice.near",
2739
- walletUrl: "https://wallet-stg.satoshibridge.top",
2740
- bridgeUrl: "https://stg.satoshibridge.top/"
2741
- },
2742
- mainnet: {
2743
- base_url: "https://api.mainnet.satoshibridge.top",
2744
- token: "nbtc.toalice.near",
2745
- accountContractId: "acc.toalice.near",
2746
- bridgeContractId: "brg.toalice.near",
2747
- walletUrl: "https://wallet.satoshibridge.top",
2748
- bridgeUrl: "https://www.satoshibridge.top/"
2749
- }
2750
- };
2751
- var nearRpcUrls = {
2752
- mainnet: [
2753
- "https://near.lava.build",
2754
- "https://rpc.mainnet.near.org",
2755
- "https://free.rpc.fastnear.com",
2756
- "https://near.drpc.org"
2757
- ],
2758
- testnet: ["https://rpc.testnet.near.org"]
2759
- };
2760
- var btcRpcUrls = {
2761
- mainnet: "https://mempool.space/api",
2762
- testnet: "https://mempool.space/testnet/api"
2763
- };
2764
-
2765
2760
  // src/utils/nearUtils.ts
2766
2761
  import { providers } from "near-api-js";
2767
2762
  function nearCallFunction(contractId, methodName, args, options) {
@@ -3432,7 +3427,7 @@ function executeBTCDepositAndAction(_0) {
3432
3427
  if (!(registerRes == null ? void 0 : registerRes.available)) {
3433
3428
  storageDepositMsg.storage_deposit_msg = {
3434
3429
  contract_id: (action == null ? void 0 : action.receiver_id) || config.token,
3435
- deposit: new Big(0.25).mul(__pow(10, 24)).toFixed(0),
3430
+ deposit: new Big(125e-5).mul(__pow(10, 24)).toFixed(0),
3436
3431
  registration_only: true
3437
3432
  };
3438
3433
  }
@@ -3533,7 +3528,7 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
3533
3528
  signAndSendTransaction,
3534
3529
  signAndSendTransactions
3535
3530
  };
3536
- const env = options.network.networkId || metadata.env || "mainnet";
3531
+ const env = metadata.env || options.network.networkId || "mainnet";
3537
3532
  const currentConfig = walletConfig[env];
3538
3533
  const walletNetwork = ["mainnet", "private_mainnet"].includes(env) ? "mainnet" : "testnet";
3539
3534
  yield initBtcContext();
@@ -3544,7 +3539,7 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
3544
3539
  const accountId = state.getAccount();
3545
3540
  const btcContext = window.btcContext;
3546
3541
  if (accountId && btcContext.account) {
3547
- setupWalletButton(walletNetwork, wallet, btcContext);
3542
+ setupWalletButton(env, wallet, btcContext);
3548
3543
  } else {
3549
3544
  removeWalletButton();
3550
3545
  setTimeout(() => {
@@ -3903,7 +3898,6 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
3903
3898
  if (!btcContext.account)
3904
3899
  return;
3905
3900
  const btcNetwork = yield btcContext.getNetwork();
3906
- console.log("btcNetwork:", btcNetwork, network);
3907
3901
  const networkMap = {
3908
3902
  livenet: ["mainnet", "private_mainnet"],
3909
3903
  testnet: ["testnet", "dev"]
@@ -3930,7 +3924,7 @@ function setupBTCWallet({
3930
3924
  syncLogOut = true,
3931
3925
  env = "mainnet"
3932
3926
  } = {}) {
3933
- console.log("\u26A1\uFE0F BTC Wallet Version:", getVersion());
3927
+ console.log("\u26A1\uFE0F BTC Wallet Version:", getVersion(), "env:", env);
3934
3928
  const btcWallet = () => __async(this, null, function* () {
3935
3929
  return {
3936
3930
  id: "btc-wallet",
@@ -3954,7 +3948,7 @@ function setupBTCWallet({
3954
3948
 
3955
3949
  // src/index.ts
3956
3950
  var getVersion = () => {
3957
- return "0.3.24";
3951
+ return "0.3.27";
3958
3952
  };
3959
3953
  if (typeof window !== "undefined") {
3960
3954
  window.__BTC_WALLET_VERSION = getVersion();