btc-wallet 0.5.58-beta → 0.5.60-beta

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
@@ -1171,7 +1171,7 @@ var MagicEdenConnector = class extends BaseConnector {
1171
1171
  };
1172
1172
  sendBtcTransaction(sendBtcOptions).catch((e) => reject(e));
1173
1173
  });
1174
- return result;
1174
+ return (result == null ? void 0 : result.txid) || result;
1175
1175
  });
1176
1176
  }
1177
1177
  disconnect() {
@@ -4461,7 +4461,7 @@ function setupWalletButton({
4461
4461
  }
4462
4462
  const iframe = createIframe({
4463
4463
  iframeUrl: walletUrl || walletConfig[env].walletUrl,
4464
- iframeStyle: { width: "400px", height: "650px" }
4464
+ iframeStyle: isMobile() ? { width: "calc(100% - 40px)", height: "80%" } : { width: "400px", height: "650px" }
4465
4465
  });
4466
4466
  iframe.addEventListener("mouseenter", () => {
4467
4467
  var _a;
@@ -4472,9 +4472,12 @@ function setupWalletButton({
4472
4472
  }, 0);
4473
4473
  }
4474
4474
  });
4475
+ const isNearWallet = !btcWallet;
4476
+ const openImageUrl = `https://assets.deltatrade.ai/wallet-assets/wallet${isNearWallet ? "-near" : ""}-btn.png`;
4477
+ const closeImageUrl = `https://assets.deltatrade.ai/wallet-assets/wallet${isNearWallet ? "-near" : ""}-btn-active.png`;
4475
4478
  const button = createFloatingButtonWithIframe({
4476
- openImageUrl: "https://assets.deltatrade.ai/wallet-assets/wallet-btn.png",
4477
- closeImageUrl: "https://assets.deltatrade.ai/wallet-assets/wallet-btn-active.png",
4479
+ openImageUrl,
4480
+ closeImageUrl,
4478
4481
  iframe
4479
4482
  });
4480
4483
  setupButtonClickHandler(button, iframe, nearWallet, btcWallet);
@@ -4502,15 +4505,20 @@ function createFloatingButtonWithIframe({
4502
4505
  position: "fixed",
4503
4506
  bottom: `${bottom}px`,
4504
4507
  right: `${right}px`,
4505
- zIndex: "2147483647",
4508
+ zIndex: "100000",
4506
4509
  width: "60px",
4507
4510
  height: "60px",
4508
4511
  cursor: "grab",
4509
4512
  transition: "transform 0.15s ease",
4510
4513
  userSelect: "none",
4511
- touchAction: "none",
4512
- pointerEvents: "auto"
4514
+ touchAction: "none"
4513
4515
  });
4516
+ if (isMobile()) {
4517
+ Object.assign(button.style, {
4518
+ width: "40px",
4519
+ height: "40px"
4520
+ });
4521
+ }
4514
4522
  document.body.appendChild(button);
4515
4523
  updateIframePosition(iframe, right, bottom, windowWidth, windowHeight);
4516
4524
  let isDragging = false;
@@ -4518,71 +4526,86 @@ function createFloatingButtonWithIframe({
4518
4526
  let startY = 0;
4519
4527
  let initialRight = 0;
4520
4528
  let initialBottom = 0;
4521
- let isLongPress = false;
4529
+ let dragStartTime = 0;
4530
+ function startDrag(clientX, clientY) {
4531
+ isDragging = true;
4532
+ startX = clientX;
4533
+ startY = clientY;
4534
+ initialRight = parseInt(button.style.right);
4535
+ initialBottom = parseInt(button.style.bottom);
4536
+ dragStartTime = Date.now();
4537
+ button.style.cursor = "grabbing";
4538
+ button.style.transition = "none";
4539
+ }
4540
+ function toggleWallet() {
4541
+ const isCurrentlyVisible = iframe.style.display === "block";
4542
+ button.style.transform = "scale(0.8)";
4543
+ setTimeout(() => {
4544
+ button.style.transform = "scale(1)";
4545
+ }, 150);
4546
+ const newVisibleState = !isCurrentlyVisible;
4547
+ iframe.style.display = newVisibleState ? "block" : "none";
4548
+ button.src = newVisibleState ? closeImageUrl : openImageUrl;
4549
+ storage4 == null ? void 0 : storage4.set("visible", newVisibleState);
4550
+ setTimeout(() => {
4551
+ if (newVisibleState) {
4552
+ iframe.focus();
4553
+ }
4554
+ }, 0);
4555
+ }
4522
4556
  button.addEventListener(
4523
4557
  "click",
4524
4558
  (e) => {
4525
- if (isLongPress) {
4526
- isLongPress = false;
4527
- return;
4559
+ if (!isDragging) {
4560
+ toggleWallet();
4528
4561
  }
4529
- handleButtonClick();
4530
4562
  e.preventDefault();
4531
4563
  e.stopPropagation();
4532
4564
  },
4533
4565
  { capture: true }
4534
4566
  );
4535
- const handleMouseDown = (e) => {
4536
- startDrag(e.clientX, e.clientY);
4537
- e.preventDefault();
4538
- e.stopPropagation();
4539
- };
4540
- const handleTouchStart = (e) => {
4541
- if (e.touches.length === 1) {
4542
- const touch = e.touches[0];
4543
- startDrag(touch.clientX, touch.clientY);
4567
+ button.addEventListener(
4568
+ "mousedown",
4569
+ (e) => {
4570
+ startDrag(e.clientX, e.clientY);
4544
4571
  e.preventDefault();
4545
4572
  e.stopPropagation();
4546
- }
4547
- };
4548
- button.addEventListener("mousedown", handleMouseDown, { capture: true });
4549
- button.addEventListener("touchstart", handleTouchStart, { capture: true });
4550
- function startDrag(clientX, clientY) {
4551
- isDragging = true;
4552
- startX = clientX;
4553
- startY = clientY;
4554
- initialRight = parseInt(button.style.right);
4555
- initialBottom = parseInt(button.style.bottom);
4556
- button.style.cursor = "grabbing";
4557
- button.style.transition = "none";
4558
- }
4559
- const handleMouseMove = (e) => {
4560
- if (!isDragging)
4561
- return;
4562
- const deltaX = Math.abs(startX - e.clientX);
4563
- const deltaY = Math.abs(startY - e.clientY);
4564
- if (deltaX > 5 || deltaY > 5) {
4565
- isLongPress = true;
4566
- }
4567
- moveButton(e.clientX, e.clientY);
4568
- e.preventDefault();
4569
- e.stopPropagation();
4570
- };
4571
- const handleTouchMove = (e) => {
4572
- if (!isDragging || e.touches.length !== 1)
4573
- return;
4574
- const touch = e.touches[0];
4575
- const deltaX = Math.abs(startX - touch.clientX);
4576
- const deltaY = Math.abs(startY - touch.clientY);
4577
- if (deltaX > 5 || deltaY > 5) {
4578
- isLongPress = true;
4579
- }
4580
- moveButton(touch.clientX, touch.clientY);
4581
- e.preventDefault();
4582
- e.stopPropagation();
4583
- };
4584
- document.addEventListener("mousemove", handleMouseMove, { capture: true });
4585
- document.addEventListener("touchmove", handleTouchMove, { capture: true });
4573
+ },
4574
+ { capture: true }
4575
+ );
4576
+ button.addEventListener(
4577
+ "touchstart",
4578
+ (e) => {
4579
+ if (e.touches.length === 1) {
4580
+ const touch = e.touches[0];
4581
+ startDrag(touch.clientX, touch.clientY);
4582
+ e.preventDefault();
4583
+ e.stopPropagation();
4584
+ }
4585
+ },
4586
+ { capture: true }
4587
+ );
4588
+ document.addEventListener(
4589
+ "mousemove",
4590
+ (e) => {
4591
+ if (!isDragging)
4592
+ return;
4593
+ moveButton(e.clientX, e.clientY);
4594
+ e.preventDefault();
4595
+ },
4596
+ { capture: true }
4597
+ );
4598
+ document.addEventListener(
4599
+ "touchmove",
4600
+ (e) => {
4601
+ if (!isDragging || e.touches.length !== 1)
4602
+ return;
4603
+ const touch = e.touches[0];
4604
+ moveButton(touch.clientX, touch.clientY);
4605
+ e.preventDefault();
4606
+ },
4607
+ { capture: true }
4608
+ );
4586
4609
  function moveButton(clientX, clientY) {
4587
4610
  const deltaX = startX - clientX;
4588
4611
  const deltaY = startY - clientY;
@@ -4606,23 +4629,40 @@ function createFloatingButtonWithIframe({
4606
4629
  button.style.bottom = `${newBottom}px`;
4607
4630
  updateIframePosition(iframe, newRight, newBottom, windowWidth, windowHeight);
4608
4631
  }
4609
- const handleMouseUp = (e) => {
4610
- if (isDragging) {
4611
- e.preventDefault();
4612
- e.stopPropagation();
4613
- }
4614
- endDrag();
4615
- };
4616
- const handleTouchEnd = (e) => {
4617
- if (isDragging) {
4618
- e.preventDefault();
4619
- e.stopPropagation();
4620
- }
4621
- endDrag();
4622
- };
4623
- document.addEventListener("mouseup", handleMouseUp, { capture: true });
4624
- document.addEventListener("touchend", handleTouchEnd, { capture: true });
4625
- document.addEventListener("touchcancel", handleTouchEnd, { capture: true });
4632
+ document.addEventListener(
4633
+ "mouseup",
4634
+ (e) => {
4635
+ if (isDragging) {
4636
+ e.preventDefault();
4637
+ e.stopPropagation();
4638
+ }
4639
+ endDrag();
4640
+ },
4641
+ { capture: true }
4642
+ );
4643
+ document.addEventListener(
4644
+ "touchend",
4645
+ (e) => {
4646
+ if (isDragging) {
4647
+ e.preventDefault();
4648
+ e.stopPropagation();
4649
+ }
4650
+ endDrag();
4651
+ const dragEndTime = Date.now();
4652
+ const dragDuration = dragEndTime - dragStartTime;
4653
+ if (dragDuration < 200 && Math.abs(parseInt(button.style.right) - initialRight) < 5 && Math.abs(parseInt(button.style.bottom) - initialBottom) < 5) {
4654
+ toggleWallet();
4655
+ }
4656
+ },
4657
+ { capture: true }
4658
+ );
4659
+ document.addEventListener(
4660
+ "touchcancel",
4661
+ () => {
4662
+ endDrag();
4663
+ },
4664
+ { capture: true }
4665
+ );
4626
4666
  function endDrag() {
4627
4667
  if (!isDragging)
4628
4668
  return;
@@ -4635,20 +4675,6 @@ function createFloatingButtonWithIframe({
4635
4675
  });
4636
4676
  }
4637
4677
  const handleButtonClick = () => {
4638
- const isCurrentlyVisible = iframe.style.display === "block";
4639
- button.style.transform = "scale(0.8)";
4640
- setTimeout(() => {
4641
- button.style.transform = "scale(1)";
4642
- }, 150);
4643
- const newVisibleState = !isCurrentlyVisible;
4644
- iframe.style.display = newVisibleState ? "block" : "none";
4645
- button.src = newVisibleState ? closeImageUrl : openImageUrl;
4646
- storage4 == null ? void 0 : storage4.set("visible", newVisibleState);
4647
- setTimeout(() => {
4648
- if (newVisibleState) {
4649
- iframe.focus();
4650
- }
4651
- }, 0);
4652
4678
  };
4653
4679
  button.onclick = null;
4654
4680
  return button;
@@ -4667,12 +4693,11 @@ function createIframe({
4667
4693
  position: "fixed",
4668
4694
  bottom: "90px",
4669
4695
  right: "20px",
4670
- zIndex: "2147483646",
4696
+ zIndex: "100000",
4671
4697
  boxShadow: "0 0 10px rgba(0, 0, 0, 0.1)",
4672
4698
  borderRadius: "10px",
4673
4699
  display: isVisible ? "block" : "none",
4674
- border: "none",
4675
- pointerEvents: "auto"
4700
+ border: "none"
4676
4701
  }, iframeStyle));
4677
4702
  document.body.appendChild(iframe);
4678
4703
  return iframe;
@@ -5124,12 +5149,20 @@ function setupWalletSelectorModal(selector, options) {
5124
5149
  }
5125
5150
  `;
5126
5151
  }
5152
+ if (group.includes("eth")) {
5153
+ document.head.appendChild(document.createElement("style")).textContent = `
5154
+ #near-wallet-selector-modal .options-list .ethereum-wallets {
5155
+ display: none;
5156
+ }
5157
+ `;
5158
+ }
5127
5159
  const modal = (0, import_ref_modal_ui.setupModal)(selector, options);
5128
5160
  const originalShow = modal.show.bind(modal);
5129
5161
  modal.show = () => __async(this, null, function* () {
5130
- const chain = group.length > 1 && showChainGroups ? yield openChainModal() : group[0];
5131
- if (chain === "btc") {
5132
- const module2 = state.modules.find((module3) => module3.id === "btc-wallet");
5162
+ const chain = group.length > 1 && showChainGroups ? yield openChainModal(group) : group[0];
5163
+ if (["btc", "eth"].includes(chain)) {
5164
+ const moduleId = chain === "btc" ? "btc-wallet" : "ethereum-wallets";
5165
+ const module2 = state.modules.find((module3) => module3.id === moduleId);
5133
5166
  if (module2) {
5134
5167
  const wallet = yield module2.wallet();
5135
5168
  yield wallet.signIn(options);
@@ -5140,15 +5173,20 @@ function setupWalletSelectorModal(selector, options) {
5140
5173
  });
5141
5174
  return modal;
5142
5175
  }
5143
- function openChainModal() {
5176
+ var CHAINS = [
5177
+ { id: "btc", name: "Bitcoin" },
5178
+ { id: "eth", name: "Ethereum" },
5179
+ { id: "near", name: "Near" }
5180
+ ];
5181
+ function openChainModal(group) {
5144
5182
  return __async(this, null, function* () {
5145
- const chains5 = ["btc", "near"];
5183
+ const chains5 = CHAINS.filter((chain) => group.includes(chain.id));
5146
5184
  const content = (resolve, close) => {
5147
5185
  const buttons = `
5148
5186
  <div class="option-list">${chains5.map(
5149
- (chain) => `<button class="chain-button option-item" data-chain="${chain}">
5150
- <img src="https://assets.deltatrade.ai/assets/chain/${chain}.svg" alt="${chain}" style="width:32px; height: 32px;" />
5151
- ${chain.toUpperCase()}
5187
+ (chain) => `<button class="chain-button option-item" data-chain="${chain.id}">
5188
+ <img src="https://assets.deltatrade.ai/assets/chain/${chain.id}.svg" alt="${chain.id}" style="width:32px; height: 32px;" />
5189
+ ${chain.name}
5152
5190
  </button>`
5153
5191
  ).join("")}
5154
5192
  </div>
@@ -5173,10 +5211,15 @@ function openChainModal() {
5173
5211
  }
5174
5212
  function getGroup(state) {
5175
5213
  const hasBtcWallet = state.modules.some((module2) => module2.id === "btc-wallet");
5176
- const hasNearWallet = state.modules.some((module2) => module2.id !== "btc-wallet");
5214
+ const hasEvmWallet = state.modules.some((module2) => module2.id === "ethereum-wallets");
5215
+ const hasNearWallet = state.modules.some(
5216
+ (module2) => module2.id !== "btc-wallet" && module2.id !== "ethereum-wallets"
5217
+ );
5177
5218
  const group = [];
5178
5219
  if (hasBtcWallet)
5179
5220
  group.push("btc");
5221
+ if (hasEvmWallet)
5222
+ group.push("eth");
5180
5223
  if (hasNearWallet)
5181
5224
  group.push("near");
5182
5225
  return group;
@@ -5184,7 +5227,7 @@ function getGroup(state) {
5184
5227
 
5185
5228
  // src/index.ts
5186
5229
  var getVersion = () => {
5187
- return "0.5.58-beta";
5230
+ return "0.5.60-beta";
5188
5231
  };
5189
5232
  if (typeof window !== "undefined") {
5190
5233
  window.__BTC_WALLET_VERSION = getVersion();