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/esm/index.js CHANGED
@@ -1101,7 +1101,7 @@ var MagicEdenConnector = class extends BaseConnector {
1101
1101
  };
1102
1102
  sendBtcTransaction(sendBtcOptions).catch((e) => reject(e));
1103
1103
  });
1104
- return result;
1104
+ return (result == null ? void 0 : result.txid) || result;
1105
1105
  });
1106
1106
  }
1107
1107
  disconnect() {
@@ -4391,7 +4391,7 @@ function setupWalletButton({
4391
4391
  }
4392
4392
  const iframe = createIframe({
4393
4393
  iframeUrl: walletUrl || walletConfig[env].walletUrl,
4394
- iframeStyle: { width: "400px", height: "650px" }
4394
+ iframeStyle: isMobile() ? { width: "calc(100% - 40px)", height: "80%" } : { width: "400px", height: "650px" }
4395
4395
  });
4396
4396
  iframe.addEventListener("mouseenter", () => {
4397
4397
  var _a;
@@ -4402,9 +4402,12 @@ function setupWalletButton({
4402
4402
  }, 0);
4403
4403
  }
4404
4404
  });
4405
+ const isNearWallet = !btcWallet;
4406
+ const openImageUrl = `https://assets.deltatrade.ai/wallet-assets/wallet${isNearWallet ? "-near" : ""}-btn.png`;
4407
+ const closeImageUrl = `https://assets.deltatrade.ai/wallet-assets/wallet${isNearWallet ? "-near" : ""}-btn-active.png`;
4405
4408
  const button = createFloatingButtonWithIframe({
4406
- openImageUrl: "https://assets.deltatrade.ai/wallet-assets/wallet-btn.png",
4407
- closeImageUrl: "https://assets.deltatrade.ai/wallet-assets/wallet-btn-active.png",
4409
+ openImageUrl,
4410
+ closeImageUrl,
4408
4411
  iframe
4409
4412
  });
4410
4413
  setupButtonClickHandler(button, iframe, nearWallet, btcWallet);
@@ -4432,15 +4435,20 @@ function createFloatingButtonWithIframe({
4432
4435
  position: "fixed",
4433
4436
  bottom: `${bottom}px`,
4434
4437
  right: `${right}px`,
4435
- zIndex: "2147483647",
4438
+ zIndex: "100000",
4436
4439
  width: "60px",
4437
4440
  height: "60px",
4438
4441
  cursor: "grab",
4439
4442
  transition: "transform 0.15s ease",
4440
4443
  userSelect: "none",
4441
- touchAction: "none",
4442
- pointerEvents: "auto"
4444
+ touchAction: "none"
4443
4445
  });
4446
+ if (isMobile()) {
4447
+ Object.assign(button.style, {
4448
+ width: "40px",
4449
+ height: "40px"
4450
+ });
4451
+ }
4444
4452
  document.body.appendChild(button);
4445
4453
  updateIframePosition(iframe, right, bottom, windowWidth, windowHeight);
4446
4454
  let isDragging = false;
@@ -4448,71 +4456,86 @@ function createFloatingButtonWithIframe({
4448
4456
  let startY = 0;
4449
4457
  let initialRight = 0;
4450
4458
  let initialBottom = 0;
4451
- let isLongPress = false;
4459
+ let dragStartTime = 0;
4460
+ function startDrag(clientX, clientY) {
4461
+ isDragging = true;
4462
+ startX = clientX;
4463
+ startY = clientY;
4464
+ initialRight = parseInt(button.style.right);
4465
+ initialBottom = parseInt(button.style.bottom);
4466
+ dragStartTime = Date.now();
4467
+ button.style.cursor = "grabbing";
4468
+ button.style.transition = "none";
4469
+ }
4470
+ function toggleWallet() {
4471
+ const isCurrentlyVisible = iframe.style.display === "block";
4472
+ button.style.transform = "scale(0.8)";
4473
+ setTimeout(() => {
4474
+ button.style.transform = "scale(1)";
4475
+ }, 150);
4476
+ const newVisibleState = !isCurrentlyVisible;
4477
+ iframe.style.display = newVisibleState ? "block" : "none";
4478
+ button.src = newVisibleState ? closeImageUrl : openImageUrl;
4479
+ storage4 == null ? void 0 : storage4.set("visible", newVisibleState);
4480
+ setTimeout(() => {
4481
+ if (newVisibleState) {
4482
+ iframe.focus();
4483
+ }
4484
+ }, 0);
4485
+ }
4452
4486
  button.addEventListener(
4453
4487
  "click",
4454
4488
  (e) => {
4455
- if (isLongPress) {
4456
- isLongPress = false;
4457
- return;
4489
+ if (!isDragging) {
4490
+ toggleWallet();
4458
4491
  }
4459
- handleButtonClick();
4460
4492
  e.preventDefault();
4461
4493
  e.stopPropagation();
4462
4494
  },
4463
4495
  { capture: true }
4464
4496
  );
4465
- const handleMouseDown = (e) => {
4466
- startDrag(e.clientX, e.clientY);
4467
- e.preventDefault();
4468
- e.stopPropagation();
4469
- };
4470
- const handleTouchStart = (e) => {
4471
- if (e.touches.length === 1) {
4472
- const touch = e.touches[0];
4473
- startDrag(touch.clientX, touch.clientY);
4497
+ button.addEventListener(
4498
+ "mousedown",
4499
+ (e) => {
4500
+ startDrag(e.clientX, e.clientY);
4474
4501
  e.preventDefault();
4475
4502
  e.stopPropagation();
4476
- }
4477
- };
4478
- button.addEventListener("mousedown", handleMouseDown, { capture: true });
4479
- button.addEventListener("touchstart", handleTouchStart, { capture: true });
4480
- function startDrag(clientX, clientY) {
4481
- isDragging = true;
4482
- startX = clientX;
4483
- startY = clientY;
4484
- initialRight = parseInt(button.style.right);
4485
- initialBottom = parseInt(button.style.bottom);
4486
- button.style.cursor = "grabbing";
4487
- button.style.transition = "none";
4488
- }
4489
- const handleMouseMove = (e) => {
4490
- if (!isDragging)
4491
- return;
4492
- const deltaX = Math.abs(startX - e.clientX);
4493
- const deltaY = Math.abs(startY - e.clientY);
4494
- if (deltaX > 5 || deltaY > 5) {
4495
- isLongPress = true;
4496
- }
4497
- moveButton(e.clientX, e.clientY);
4498
- e.preventDefault();
4499
- e.stopPropagation();
4500
- };
4501
- const handleTouchMove = (e) => {
4502
- if (!isDragging || e.touches.length !== 1)
4503
- return;
4504
- const touch = e.touches[0];
4505
- const deltaX = Math.abs(startX - touch.clientX);
4506
- const deltaY = Math.abs(startY - touch.clientY);
4507
- if (deltaX > 5 || deltaY > 5) {
4508
- isLongPress = true;
4509
- }
4510
- moveButton(touch.clientX, touch.clientY);
4511
- e.preventDefault();
4512
- e.stopPropagation();
4513
- };
4514
- document.addEventListener("mousemove", handleMouseMove, { capture: true });
4515
- document.addEventListener("touchmove", handleTouchMove, { capture: true });
4503
+ },
4504
+ { capture: true }
4505
+ );
4506
+ button.addEventListener(
4507
+ "touchstart",
4508
+ (e) => {
4509
+ if (e.touches.length === 1) {
4510
+ const touch = e.touches[0];
4511
+ startDrag(touch.clientX, touch.clientY);
4512
+ e.preventDefault();
4513
+ e.stopPropagation();
4514
+ }
4515
+ },
4516
+ { capture: true }
4517
+ );
4518
+ document.addEventListener(
4519
+ "mousemove",
4520
+ (e) => {
4521
+ if (!isDragging)
4522
+ return;
4523
+ moveButton(e.clientX, e.clientY);
4524
+ e.preventDefault();
4525
+ },
4526
+ { capture: true }
4527
+ );
4528
+ document.addEventListener(
4529
+ "touchmove",
4530
+ (e) => {
4531
+ if (!isDragging || e.touches.length !== 1)
4532
+ return;
4533
+ const touch = e.touches[0];
4534
+ moveButton(touch.clientX, touch.clientY);
4535
+ e.preventDefault();
4536
+ },
4537
+ { capture: true }
4538
+ );
4516
4539
  function moveButton(clientX, clientY) {
4517
4540
  const deltaX = startX - clientX;
4518
4541
  const deltaY = startY - clientY;
@@ -4536,23 +4559,40 @@ function createFloatingButtonWithIframe({
4536
4559
  button.style.bottom = `${newBottom}px`;
4537
4560
  updateIframePosition(iframe, newRight, newBottom, windowWidth, windowHeight);
4538
4561
  }
4539
- const handleMouseUp = (e) => {
4540
- if (isDragging) {
4541
- e.preventDefault();
4542
- e.stopPropagation();
4543
- }
4544
- endDrag();
4545
- };
4546
- const handleTouchEnd = (e) => {
4547
- if (isDragging) {
4548
- e.preventDefault();
4549
- e.stopPropagation();
4550
- }
4551
- endDrag();
4552
- };
4553
- document.addEventListener("mouseup", handleMouseUp, { capture: true });
4554
- document.addEventListener("touchend", handleTouchEnd, { capture: true });
4555
- document.addEventListener("touchcancel", handleTouchEnd, { capture: true });
4562
+ document.addEventListener(
4563
+ "mouseup",
4564
+ (e) => {
4565
+ if (isDragging) {
4566
+ e.preventDefault();
4567
+ e.stopPropagation();
4568
+ }
4569
+ endDrag();
4570
+ },
4571
+ { capture: true }
4572
+ );
4573
+ document.addEventListener(
4574
+ "touchend",
4575
+ (e) => {
4576
+ if (isDragging) {
4577
+ e.preventDefault();
4578
+ e.stopPropagation();
4579
+ }
4580
+ endDrag();
4581
+ const dragEndTime = Date.now();
4582
+ const dragDuration = dragEndTime - dragStartTime;
4583
+ if (dragDuration < 200 && Math.abs(parseInt(button.style.right) - initialRight) < 5 && Math.abs(parseInt(button.style.bottom) - initialBottom) < 5) {
4584
+ toggleWallet();
4585
+ }
4586
+ },
4587
+ { capture: true }
4588
+ );
4589
+ document.addEventListener(
4590
+ "touchcancel",
4591
+ () => {
4592
+ endDrag();
4593
+ },
4594
+ { capture: true }
4595
+ );
4556
4596
  function endDrag() {
4557
4597
  if (!isDragging)
4558
4598
  return;
@@ -4565,20 +4605,6 @@ function createFloatingButtonWithIframe({
4565
4605
  });
4566
4606
  }
4567
4607
  const handleButtonClick = () => {
4568
- const isCurrentlyVisible = iframe.style.display === "block";
4569
- button.style.transform = "scale(0.8)";
4570
- setTimeout(() => {
4571
- button.style.transform = "scale(1)";
4572
- }, 150);
4573
- const newVisibleState = !isCurrentlyVisible;
4574
- iframe.style.display = newVisibleState ? "block" : "none";
4575
- button.src = newVisibleState ? closeImageUrl : openImageUrl;
4576
- storage4 == null ? void 0 : storage4.set("visible", newVisibleState);
4577
- setTimeout(() => {
4578
- if (newVisibleState) {
4579
- iframe.focus();
4580
- }
4581
- }, 0);
4582
4608
  };
4583
4609
  button.onclick = null;
4584
4610
  return button;
@@ -4597,12 +4623,11 @@ function createIframe({
4597
4623
  position: "fixed",
4598
4624
  bottom: "90px",
4599
4625
  right: "20px",
4600
- zIndex: "2147483646",
4626
+ zIndex: "100000",
4601
4627
  boxShadow: "0 0 10px rgba(0, 0, 0, 0.1)",
4602
4628
  borderRadius: "10px",
4603
4629
  display: isVisible ? "block" : "none",
4604
- border: "none",
4605
- pointerEvents: "auto"
4630
+ border: "none"
4606
4631
  }, iframeStyle));
4607
4632
  document.body.appendChild(iframe);
4608
4633
  return iframe;
@@ -5056,12 +5081,20 @@ function setupWalletSelectorModal(selector, options) {
5056
5081
  }
5057
5082
  `;
5058
5083
  }
5084
+ if (group.includes("eth")) {
5085
+ document.head.appendChild(document.createElement("style")).textContent = `
5086
+ #near-wallet-selector-modal .options-list .ethereum-wallets {
5087
+ display: none;
5088
+ }
5089
+ `;
5090
+ }
5059
5091
  const modal = _setupModal(selector, options);
5060
5092
  const originalShow = modal.show.bind(modal);
5061
5093
  modal.show = () => __async(this, null, function* () {
5062
- const chain = group.length > 1 && showChainGroups ? yield openChainModal() : group[0];
5063
- if (chain === "btc") {
5064
- const module = state.modules.find((module2) => module2.id === "btc-wallet");
5094
+ const chain = group.length > 1 && showChainGroups ? yield openChainModal(group) : group[0];
5095
+ if (["btc", "eth"].includes(chain)) {
5096
+ const moduleId = chain === "btc" ? "btc-wallet" : "ethereum-wallets";
5097
+ const module = state.modules.find((module2) => module2.id === moduleId);
5065
5098
  if (module) {
5066
5099
  const wallet = yield module.wallet();
5067
5100
  yield wallet.signIn(options);
@@ -5072,15 +5105,20 @@ function setupWalletSelectorModal(selector, options) {
5072
5105
  });
5073
5106
  return modal;
5074
5107
  }
5075
- function openChainModal() {
5108
+ var CHAINS = [
5109
+ { id: "btc", name: "Bitcoin" },
5110
+ { id: "eth", name: "Ethereum" },
5111
+ { id: "near", name: "Near" }
5112
+ ];
5113
+ function openChainModal(group) {
5076
5114
  return __async(this, null, function* () {
5077
- const chains5 = ["btc", "near"];
5115
+ const chains5 = CHAINS.filter((chain) => group.includes(chain.id));
5078
5116
  const content = (resolve, close) => {
5079
5117
  const buttons = `
5080
5118
  <div class="option-list">${chains5.map(
5081
- (chain) => `<button class="chain-button option-item" data-chain="${chain}">
5082
- <img src="https://assets.deltatrade.ai/assets/chain/${chain}.svg" alt="${chain}" style="width:32px; height: 32px;" />
5083
- ${chain.toUpperCase()}
5119
+ (chain) => `<button class="chain-button option-item" data-chain="${chain.id}">
5120
+ <img src="https://assets.deltatrade.ai/assets/chain/${chain.id}.svg" alt="${chain.id}" style="width:32px; height: 32px;" />
5121
+ ${chain.name}
5084
5122
  </button>`
5085
5123
  ).join("")}
5086
5124
  </div>
@@ -5105,10 +5143,15 @@ function openChainModal() {
5105
5143
  }
5106
5144
  function getGroup(state) {
5107
5145
  const hasBtcWallet = state.modules.some((module) => module.id === "btc-wallet");
5108
- const hasNearWallet = state.modules.some((module) => module.id !== "btc-wallet");
5146
+ const hasEvmWallet = state.modules.some((module) => module.id === "ethereum-wallets");
5147
+ const hasNearWallet = state.modules.some(
5148
+ (module) => module.id !== "btc-wallet" && module.id !== "ethereum-wallets"
5149
+ );
5109
5150
  const group = [];
5110
5151
  if (hasBtcWallet)
5111
5152
  group.push("btc");
5153
+ if (hasEvmWallet)
5154
+ group.push("eth");
5112
5155
  if (hasNearWallet)
5113
5156
  group.push("near");
5114
5157
  return group;
@@ -5116,7 +5159,7 @@ function getGroup(state) {
5116
5159
 
5117
5160
  // src/index.ts
5118
5161
  var getVersion = () => {
5119
- return "0.5.58-beta";
5162
+ return "0.5.60-beta";
5120
5163
  };
5121
5164
  if (typeof window !== "undefined") {
5122
5165
  window.__BTC_WALLET_VERSION = getVersion();