btc-wallet 0.1.7 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -133,7 +133,6 @@ var InjectedConnector = class extends BaseConnector {
133
133
  requestAccounts() {
134
134
  return __async(this, null, function* () {
135
135
  const accounts = yield this.getProviderOrThrow().requestAccounts();
136
- console.log("\u{1F680} ~ InjectedConnector ~ requestAccounts ~ accounts:", accounts);
137
136
  return accounts;
138
137
  });
139
138
  }
@@ -699,7 +698,6 @@ var WalletClientProvider = class {
699
698
  }
700
699
  }
701
700
  if (method === "personal_sign" /* personalSign */) {
702
- console.log("personal_sign ---- ", arg);
703
701
  return new Promise((resolve, reject) => {
704
702
  eventUtils_default.emit("personalSign" /* personalSign */, arg);
705
703
  eventUtils_default.once("personalSignResult" /* personalSignResult */, ({ result, error }) => {
@@ -1005,7 +1003,6 @@ var ConnectModal = ({ open, onClose }) => {
1005
1003
  yield connect(connector.metadata.id);
1006
1004
  closeConnectModal();
1007
1005
  } catch (error) {
1008
- console.error("onConnect error", error);
1009
1006
  if (error.code === 4001) {
1010
1007
  setRetryVisible(true);
1011
1008
  }
@@ -1548,13 +1545,10 @@ var SignModal = ({ open, onClose, onOpen }) => {
1548
1545
  }), [userOpBundle, smartAccount, accountContract]);
1549
1546
  (0, import_react8.useEffect)(() => {
1550
1547
  if (userOpBundle && open) {
1551
- console.log("deserializeUserOp start");
1552
1548
  setDeserializeLoading(true);
1553
1549
  deserializeUserOp().then((result) => {
1554
- console.log("\u{1F680} ~ deserializeUserOp ~ result:", result);
1555
1550
  setDeserializeResult(result);
1556
1551
  }).catch((error) => {
1557
- console.log("\u{1F680} ~ deserializeUserOp ~ error:", error);
1558
1552
  eventUtils_default.emit("sendUserOpResult" /* sendUserOpResult */, {
1559
1553
  error
1560
1554
  });
@@ -1565,7 +1559,6 @@ var SignModal = ({ open, onClose, onOpen }) => {
1565
1559
  (0, import_react8.useEffect)(() => {
1566
1560
  if (open && publicClient && evmAccount && userOpBundle) {
1567
1561
  publicClient.getBalance({ address: evmAccount }).then((result) => setNativeBalance(result)).catch((error) => {
1568
- console.log("\u{1F680} ~ getBalance ~ error:", error);
1569
1562
  eventUtils_default.emit("sendUserOpResult" /* sendUserOpResult */, {
1570
1563
  error
1571
1564
  });
@@ -1730,7 +1723,6 @@ var AASignerProvider = class {
1730
1723
  this.getPublicClient = () => {
1731
1724
  var _a, _b;
1732
1725
  const rpcUrl = ((_a = this == null ? void 0 : this.rpcUrls) == null ? void 0 : _a[this.chainId]) || ((_b = import_chains3.chains.getEVMChainInfoById(this.chainId || 1)) == null ? void 0 : _b.rpcUrl);
1733
- console.log("rpcUrl", rpcUrl);
1734
1726
  return (0, import_viem4.createPublicClient)({
1735
1727
  transport: (0, import_viem4.http)(rpcUrl)
1736
1728
  });
@@ -1765,10 +1757,8 @@ var AASignerProvider = class {
1765
1757
  return `0x${this.chainId.toString(16)}`;
1766
1758
  } else if (arg.method === "personal_sign" /* personalSign */) {
1767
1759
  let message = (_a = arg.params) == null ? void 0 : _a[0];
1768
- console.log("personal_sign message:", message);
1769
1760
  if (message.length !== 66) {
1770
1761
  const hash = (0, import_viem4.hashMessage)({ raw: message });
1771
- console.log("personal_sign hash:", hash);
1772
1762
  message = hash;
1773
1763
  }
1774
1764
  const result = yield this.personalSign(message || "");
@@ -1776,19 +1766,15 @@ var AASignerProvider = class {
1776
1766
  if (!convertResult) {
1777
1767
  throw new Error("sign error");
1778
1768
  }
1779
- console.log(`personal_sign result(${convertResult.length}): `, convertResult);
1780
1769
  return convertResult;
1781
1770
  } else if (arg.method === "eth_signTypedData" || arg.method === "eth_signTypedData_v4") {
1782
1771
  const typedData = (_b = arg.params) == null ? void 0 : _b[1];
1783
- console.log("signTypedData typedData", typedData);
1784
1772
  const hash = (0, import_viem4.hashTypedData)(typeof typedData === "string" ? JSON.parse(typedData) : typedData);
1785
- console.log("signTypedData hash", hash);
1786
1773
  const result = yield this.personalSign(hash || "");
1787
1774
  const convertResult = convertSignature(result);
1788
1775
  if (!convertResult) {
1789
1776
  throw new Error("sign error");
1790
1777
  }
1791
- console.log(`eth_signTypedData result(${convertResult.length}): `, convertResult);
1792
1778
  return convertResult;
1793
1779
  } else if (arg.method === "wallet_switchEthereumChain") {
1794
1780
  if (arg.params && arg.params instanceof Array && arg.params[0] && arg.params[0].chainId) {
@@ -1960,7 +1946,6 @@ var ConnectProvider = ({
1960
1946
  setEVMAccount(res);
1961
1947
  }).catch((e) => {
1962
1948
  setEVMAccount(void 0);
1963
- console.error("smartAccount getAddress error", e);
1964
1949
  });
1965
1950
  } else {
1966
1951
  setEVMAccount(void 0);
@@ -1982,7 +1967,6 @@ var ConnectProvider = ({
1982
1967
  const requestAccount = (0, import_react10.useCallback)(
1983
1968
  (connector2) => __async(void 0, null, function* () {
1984
1969
  let accounts2 = yield connector2.getAccounts();
1985
- console.log("requestAccount start, autoConnect", accounts2, autoConnect);
1986
1970
  if (accounts2.length === 0 && autoConnect) {
1987
1971
  accounts2 = yield connector2.requestAccounts();
1988
1972
  }
@@ -1992,9 +1976,7 @@ var ConnectProvider = ({
1992
1976
  );
1993
1977
  const requestDirectAccount = (0, import_react10.useCallback)(
1994
1978
  (connector2) => __async(void 0, null, function* () {
1995
- console.log(111);
1996
1979
  let accounts2 = yield connector2.getAccounts();
1997
- console.log("requestAccount start, autoConnect", accounts2, autoConnect);
1998
1980
  if (accounts2.length === 0) {
1999
1981
  accounts2 = yield connector2.requestAccounts();
2000
1982
  }
@@ -2006,7 +1988,6 @@ var ConnectProvider = ({
2006
1988
  (0, import_react10.useEffect)(() => {
2007
1989
  if (connector) {
2008
1990
  requestAccount(connector).catch((e) => {
2009
- console.log("get account error", e);
2010
1991
  setAccounts([]);
2011
1992
  });
2012
1993
  } else {
@@ -2062,7 +2043,6 @@ var ConnectProvider = ({
2062
2043
  })
2063
2044
  })
2064
2045
  );
2065
- console.log("walletEntryPlugin init");
2066
2046
  }
2067
2047
  }, [options, evmSupportChainIds, accountContract]);
2068
2048
  (0, import_react10.useEffect)(() => {
@@ -2071,7 +2051,6 @@ var ConnectProvider = ({
2071
2051
  import_wallet.walletEntryPlugin.setWalletCore({
2072
2052
  ethereum: smartAccount.provider
2073
2053
  });
2074
- console.log("walletEntryPlugin setWalletCore");
2075
2054
  }
2076
2055
  }, [smartAccount, options]);
2077
2056
  (0, import_react10.useEffect)(() => {
@@ -2079,10 +2058,8 @@ var ConnectProvider = ({
2079
2058
  if (((_a2 = options.walletOptions) == null ? void 0 : _a2.visible) !== false) {
2080
2059
  if (evmAccount) {
2081
2060
  import_wallet.walletEntryPlugin.walletEntryCreate();
2082
- console.log("walletEntryPlugin walletEntryCreate");
2083
2061
  } else {
2084
2062
  import_wallet.walletEntryPlugin.walletEntryDestroy();
2085
- console.log("walletEntryPlugin walletEntryDestroy");
2086
2063
  }
2087
2064
  }
2088
2065
  }, [evmAccount, smartAccount, options]);
@@ -2381,7 +2358,6 @@ var import_js_sha256 = require("js-sha256");
2381
2358
 
2382
2359
  // src/utils/initWalletButton.ts
2383
2360
  function setupWalletButton(network, wallet, originalWallet) {
2384
- console.log("setupWalletButton");
2385
2361
  if (document.getElementById("satoshi-wallet-button")) {
2386
2362
  return;
2387
2363
  }
@@ -2469,24 +2445,20 @@ function setupButtonClickHandler(button, iframe, wallet, originalWallet) {
2469
2445
  const accountId = (_a = yield wallet == null ? void 0 : wallet.getAccounts()) == null ? void 0 : _a[0].accountId;
2470
2446
  const originalAccountId = originalWallet.account;
2471
2447
  const originalPublicKey = yield originalWallet.getPublicKey();
2472
- console.log({ accountId, originalAccountId, originalPublicKey });
2473
2448
  const iframeSrc = new URL(iframe.src);
2474
2449
  iframeSrc.searchParams.set("origin", window.location.origin);
2475
2450
  accountId && iframeSrc.searchParams.set("accountId", accountId);
2476
2451
  originalAccountId && iframeSrc.searchParams.set("originalAccountId", originalAccountId);
2477
2452
  originalPublicKey && iframeSrc.searchParams.set("originalPublicKey", originalPublicKey);
2478
2453
  iframe.src = iframeSrc.toString();
2479
- console.log("iframe src", iframe.src);
2480
2454
  window.addEventListener("message", (event) => __async(this, null, function* () {
2481
2455
  var _a2, _b;
2482
2456
  if (event.origin !== iframeSrc.origin)
2483
2457
  return;
2484
2458
  const { action, requestId, data } = event.data;
2485
2459
  if (action === "signAndSendTransaction") {
2486
- console.log("signAndSendTransaction message", event.data);
2487
2460
  try {
2488
2461
  const result = yield wallet.signAndSendTransaction(data);
2489
- console.log("signAndSendTransaction result", result);
2490
2462
  (_a2 = event.source) == null ? void 0 : _a2.postMessage(
2491
2463
  {
2492
2464
  requestId,
@@ -2496,7 +2468,6 @@ function setupButtonClickHandler(button, iframe, wallet, originalWallet) {
2496
2468
  { targetOrigin: event.origin }
2497
2469
  );
2498
2470
  } catch (error) {
2499
- console.error("signAndSendTransaction error", error);
2500
2471
  (_b = event.source) == null ? void 0 : _b.postMessage(
2501
2472
  {
2502
2473
  requestId,
@@ -2592,13 +2563,12 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
2592
2563
  if (!inter) {
2593
2564
  inter = setInterval(() => __async(void 0, null, function* () {
2594
2565
  const btcContext = window.btcContext;
2595
- console.log("inter btcContext:", btcContext);
2596
2566
  if (btcContext) {
2597
2567
  clearInterval(inter);
2598
2568
  const context = btcContext.getContext();
2599
2569
  context.on("updatePublicKey", (btcPublicKey) => __async(void 0, null, function* () {
2600
2570
  const { nearTempAddress } = yield getNearAccountByBtcPublicKey(btcPublicKey);
2601
- console.info("accountsChanged:", nearTempAddress, btcContext.account);
2571
+ initWalletButton(options.network.networkId, wallet);
2602
2572
  emitter.emit("accountsChanged", {
2603
2573
  accounts: [
2604
2574
  {
@@ -2612,7 +2582,6 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
2612
2582
  accounts: []
2613
2583
  });
2614
2584
  }));
2615
- console.log("metadata.autoConnect:", metadata);
2616
2585
  if ("autoConnect" in metadata && metadata.autoConnect && localStorage.getItem("near-wallet-selector:selectedWalletId") === '"btc-wallet"') {
2617
2586
  yield btcContext.autoConnect();
2618
2587
  }
@@ -2653,10 +2622,10 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
2653
2622
  }
2654
2623
  function signIn(_02) {
2655
2624
  return __async(this, arguments, function* ({ contractId, methodNames }) {
2656
- console.log(provider);
2657
2625
  const accountId = state.getAccount();
2658
2626
  const publicKey = state.getPublicKey();
2659
2627
  const btcContext = window.btcContext;
2628
+ initWalletButton(options.network.networkId, wallet);
2660
2629
  if (accountId && publicKey) {
2661
2630
  return [
2662
2631
  {
@@ -2759,7 +2728,6 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
2759
2728
  txBytes,
2760
2729
  (byte) => ("0" + (byte & 255).toString(16)).slice(-2)
2761
2730
  ).join("");
2762
- console.log("txHex:", txHex);
2763
2731
  const hash = import_bs58.default.encode(new Uint8Array(import_js_sha256.sha256.array(txBytes)));
2764
2732
  return { txBytes, txHex, hash };
2765
2733
  });
@@ -2784,10 +2752,8 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
2784
2752
  btcPubKey: state.getBtcPublicKey(),
2785
2753
  data: toHex(strIntention)
2786
2754
  });
2787
- console.log("result:", result);
2788
2755
  if (result.result_code === 0) {
2789
2756
  const hash = newTransactions.map((t) => t.hash);
2790
- console.log("txHash:", hash);
2791
2757
  const result2 = yield pollTransactionStatuses(options.network.networkId, hash);
2792
2758
  return result2;
2793
2759
  } else {
@@ -2797,16 +2763,14 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
2797
2763
  }
2798
2764
  function initWalletButton(network, wallet2) {
2799
2765
  return __async(this, null, function* () {
2800
- console.log("initWalletButton:", network, wallet2);
2801
2766
  const checkAndSetupWalletButton = () => {
2802
2767
  const accountId = state.getAccount();
2803
2768
  const btcContext = window.btcContext;
2804
- console.log("checkAndSetupWalletButton:", accountId, btcContext.account);
2805
2769
  if (accountId && btcContext.account) {
2806
2770
  setupWalletButton(network, wallet2, btcContext);
2807
2771
  } else {
2808
2772
  removeWalletButton();
2809
- !btcContext.account && setTimeout(() => {
2773
+ setTimeout(() => {
2810
2774
  checkAndSetupWalletButton();
2811
2775
  }, 5e3);
2812
2776
  }
@@ -2901,17 +2865,14 @@ function pollTransactionStatuses(network, hashes) {
2901
2865
  try {
2902
2866
  const result = yield provider.txStatus(hash, "unused", "FINAL");
2903
2867
  if (result && result.status) {
2904
- console.log(`Transaction ${hash} result:`, result);
2905
2868
  return result;
2906
2869
  }
2907
2870
  } catch (error) {
2908
- console.error(`Failed to fetch transaction status for ${hash}: ${error.message}`);
2909
2871
  }
2910
2872
  if (attempt === maxAttempts) {
2911
2873
  throw new Error(`Transaction not found after max attempts: ${hash}`);
2912
2874
  }
2913
2875
  yield delay(1e4);
2914
- console.log(`RPC request failed for ${hash}, retrying ${maxAttempts - attempt} more times`);
2915
2876
  }
2916
2877
  });
2917
2878
  const results = yield Promise.all(hashes.map((hash) => pollStatus(hash)));
@@ -2921,7 +2882,7 @@ function pollTransactionStatuses(network, hashes) {
2921
2882
 
2922
2883
  // src/index.ts
2923
2884
  var getVersion = () => {
2924
- return "0.1.7";
2885
+ return "0.1.9";
2925
2886
  };
2926
2887
  if (typeof window !== "undefined") {
2927
2888
  window.__PARTICLE_BTC_CONNECT_VERSION = getVersion();