btc-wallet 0.5.74-beta → 0.5.76-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.
@@ -1,9 +1,16 @@
1
1
  import { type WalletSelectorModal as _WalletSelectorModal, type ModalOptions as _ModalOptions } from 'ref-modal-ui';
2
2
  import type { WalletSelector } from '@near-wallet-selector/core';
3
3
  import { ENV } from '../config';
4
+ export interface CustomGroup {
5
+ id: string;
6
+ name: string;
7
+ description: string;
8
+ onClick?: (group: CustomGroup) => void | Promise<void>;
9
+ }
4
10
  export interface WalletSelectorModalOptions extends _ModalOptions {
5
11
  showChainGroups?: boolean;
6
12
  showWalletUIForNearAccount?: boolean;
13
+ hideWalletUIForNearWallets?: string[];
7
14
  walletUrl?: string;
8
15
  env?: ENV;
9
16
  draggable?: boolean;
@@ -13,6 +20,7 @@ export interface WalletSelectorModalOptions extends _ModalOptions {
13
20
  };
14
21
  buttonSize?: string;
15
22
  mobileButtonSize?: string;
23
+ customGroups?: CustomGroup[];
16
24
  }
17
25
  export type WalletSelectorModal = _WalletSelectorModal;
18
26
  declare global {
package/dist/index.js CHANGED
@@ -5193,12 +5193,14 @@ function setupWalletSelectorModal(selector, options) {
5193
5193
  const {
5194
5194
  showChainGroups = true,
5195
5195
  showWalletUIForNearAccount = true,
5196
+ hideWalletUIForNearWallets = ["meteor-wallet-app"],
5196
5197
  env = "mainnet",
5197
5198
  walletUrl,
5198
5199
  draggable = true,
5199
5200
  initialPosition = { right: "20px", bottom: "20px" },
5200
5201
  buttonSize = "60px",
5201
- mobileButtonSize = "40px"
5202
+ mobileButtonSize = "40px",
5203
+ customGroups = []
5202
5204
  } = options;
5203
5205
  subscription == null ? void 0 : subscription.unsubscribe();
5204
5206
  const state = selector.store.getState();
@@ -5207,8 +5209,9 @@ function setupWalletSelectorModal(selector, options) {
5207
5209
  const walletId = state2.selectedWalletId;
5208
5210
  window.enableCustomWalletSelectorModal = true;
5209
5211
  console.log("setupWalletSelectorModal walletId", walletId);
5212
+ const showWalletUI = walletId && (walletId === "btc-wallet" || showWalletUIForNearAccount && !hideWalletUIForNearWallets.includes(walletId));
5210
5213
  removeWalletButton();
5211
- if (walletId === "btc-wallet" || showWalletUIForNearAccount) {
5214
+ if (showWalletUI) {
5212
5215
  selector.wallet().then((wallet) => {
5213
5216
  setupWalletButton({
5214
5217
  env,
@@ -5240,7 +5243,7 @@ function setupWalletSelectorModal(selector, options) {
5240
5243
  const modal = (0, import_ref_modal_ui.setupModal)(selector, options);
5241
5244
  const originalShow = modal.show.bind(modal);
5242
5245
  modal.show = () => __async(this, null, function* () {
5243
- const chain = group.length > 1 && showChainGroups ? yield openChainModal(group) : group[0];
5246
+ const chain = group.length > 1 && showChainGroups ? yield openChainModal(group, customGroups) : group[0];
5244
5247
  if (["btc", "eth"].includes(chain)) {
5245
5248
  const moduleId = chain === "btc" ? "btc-wallet" : "ethereum-wallets";
5246
5249
  const module2 = state.modules.find((module3) => module3.id === moduleId);
@@ -5250,6 +5253,11 @@ function setupWalletSelectorModal(selector, options) {
5250
5253
  }
5251
5254
  } else if (chain === "near") {
5252
5255
  originalShow();
5256
+ } else {
5257
+ const customGroup = customGroups.find((g) => g.id === chain);
5258
+ if (customGroup == null ? void 0 : customGroup.onClick) {
5259
+ yield customGroup.onClick(customGroup);
5260
+ }
5253
5261
  }
5254
5262
  });
5255
5263
  return modal;
@@ -5259,17 +5267,18 @@ var CHAINS = [
5259
5267
  { id: "eth", name: "Ethereum", description: "EVM address as Near Account" },
5260
5268
  { id: "btc", name: "Bitcoin", description: "MPC Mapping" }
5261
5269
  ];
5262
- function openChainModal(group) {
5263
- return __async(this, null, function* () {
5270
+ function openChainModal(_0) {
5271
+ return __async(this, arguments, function* (group, customGroups = []) {
5264
5272
  const chains5 = CHAINS.filter((chain) => group.includes(chain.id));
5273
+ const allGroups = [...chains5, ...customGroups];
5265
5274
  const content = (resolve, close) => {
5266
5275
  const buttons = `
5267
- <div class="option-list">${chains5.map(
5268
- (chain) => `<button class="chain-button option-item" data-chain="${chain.id}">
5269
- <img src="https://assets.deltatrade.ai/assets/chain/${chain.id}.svg" alt="${chain.id}" style="width:32px; height: 32px;" />
5276
+ <div class="option-list">${allGroups.map(
5277
+ (item) => `<button class="chain-button option-item" data-chain="${item.id}">
5278
+ <img src="https://assets.deltatrade.ai/assets/chain/${item.id}.svg" alt="${item.id}" style="width:32px; height: 32px;" />
5270
5279
  <div style="display: flex; flex-direction: column; text-align: left;">
5271
- <div style="font-size: 16px; font-weight: bold;">${chain.name}</div>
5272
- <div style="font-size: 12px; opacity:0.5;">${chain.description}</div>
5280
+ <div style="font-size: 16px; font-weight: bold;">${item.name}</div>
5281
+ <div style="font-size: 12px; opacity:0.5;">${item.description}</div>
5273
5282
  </div>
5274
5283
  </button>`
5275
5284
  ).join("")}
@@ -5311,7 +5320,7 @@ function getGroup(state) {
5311
5320
 
5312
5321
  // src/index.ts
5313
5322
  var getVersion = () => {
5314
- return "0.5.74-beta";
5323
+ return "0.5.76-beta";
5315
5324
  };
5316
5325
  if (typeof window !== "undefined") {
5317
5326
  window.__BTC_WALLET_VERSION = getVersion();