btc-wallet 0.5.75-beta → 0.5.77-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/core/setupModal.d.ts +7 -0
- package/dist/index.js +37 -11
- package/dist/index.js.map +2 -2
- package/esm/index.js +37 -11
- package/esm/index.js.map +2 -2
- package/package.json +1 -1
@@ -1,6 +1,12 @@
|
|
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;
|
@@ -14,6 +20,7 @@ export interface WalletSelectorModalOptions extends _ModalOptions {
|
|
14
20
|
};
|
15
21
|
buttonSize?: string;
|
16
22
|
mobileButtonSize?: string;
|
23
|
+
customGroups?: CustomGroup[];
|
17
24
|
}
|
18
25
|
export type WalletSelectorModal = _WalletSelectorModal;
|
19
26
|
declare global {
|
package/dist/index.js
CHANGED
@@ -4313,7 +4313,26 @@ function calculateWithdraw(_0) {
|
|
4313
4313
|
satoshis = new import_big2.default(amount).minus(gasLimit).toNumber();
|
4314
4314
|
}
|
4315
4315
|
const brgConfig = yield getBridgeConfig({ env });
|
4316
|
-
const
|
4316
|
+
const { current_utxos_num } = yield nearCallFunction(
|
4317
|
+
config.bridgeContractId,
|
4318
|
+
"get_metadata",
|
4319
|
+
{},
|
4320
|
+
{ network: config.network }
|
4321
|
+
);
|
4322
|
+
const pageSize = 300;
|
4323
|
+
const totalPages = Math.ceil(current_utxos_num / pageSize);
|
4324
|
+
const utxoRequests = Array.from({ length: totalPages }, (_, index) => {
|
4325
|
+
const fromIndex = index * pageSize;
|
4326
|
+
const limit = Math.min(pageSize, current_utxos_num - fromIndex);
|
4327
|
+
return nearCallFunction(
|
4328
|
+
config.bridgeContractId,
|
4329
|
+
"get_utxos_paged",
|
4330
|
+
{ from_index: fromIndex, limit },
|
4331
|
+
{ network: config.network }
|
4332
|
+
);
|
4333
|
+
});
|
4334
|
+
const utxoResults = yield Promise.all(utxoRequests);
|
4335
|
+
const allUTXO = utxoResults.reduce((acc, result) => __spreadValues(__spreadValues({}, acc), result), {});
|
4317
4336
|
if (brgConfig.min_withdraw_amount) {
|
4318
4337
|
if (Number(satoshis) < Number(brgConfig.min_withdraw_amount)) {
|
4319
4338
|
return {
|
@@ -5199,7 +5218,8 @@ function setupWalletSelectorModal(selector, options) {
|
|
5199
5218
|
draggable = true,
|
5200
5219
|
initialPosition = { right: "20px", bottom: "20px" },
|
5201
5220
|
buttonSize = "60px",
|
5202
|
-
mobileButtonSize = "40px"
|
5221
|
+
mobileButtonSize = "40px",
|
5222
|
+
customGroups = []
|
5203
5223
|
} = options;
|
5204
5224
|
subscription == null ? void 0 : subscription.unsubscribe();
|
5205
5225
|
const state = selector.store.getState();
|
@@ -5242,7 +5262,7 @@ function setupWalletSelectorModal(selector, options) {
|
|
5242
5262
|
const modal = (0, import_ref_modal_ui.setupModal)(selector, options);
|
5243
5263
|
const originalShow = modal.show.bind(modal);
|
5244
5264
|
modal.show = () => __async(this, null, function* () {
|
5245
|
-
const chain = group.length > 1 && showChainGroups ? yield openChainModal(group) : group[0];
|
5265
|
+
const chain = group.length > 1 && showChainGroups ? yield openChainModal(group, customGroups) : group[0];
|
5246
5266
|
if (["btc", "eth"].includes(chain)) {
|
5247
5267
|
const moduleId = chain === "btc" ? "btc-wallet" : "ethereum-wallets";
|
5248
5268
|
const module2 = state.modules.find((module3) => module3.id === moduleId);
|
@@ -5252,6 +5272,11 @@ function setupWalletSelectorModal(selector, options) {
|
|
5252
5272
|
}
|
5253
5273
|
} else if (chain === "near") {
|
5254
5274
|
originalShow();
|
5275
|
+
} else {
|
5276
|
+
const customGroup = customGroups.find((g) => g.id === chain);
|
5277
|
+
if (customGroup == null ? void 0 : customGroup.onClick) {
|
5278
|
+
yield customGroup.onClick(customGroup);
|
5279
|
+
}
|
5255
5280
|
}
|
5256
5281
|
});
|
5257
5282
|
return modal;
|
@@ -5261,17 +5286,18 @@ var CHAINS = [
|
|
5261
5286
|
{ id: "eth", name: "Ethereum", description: "EVM address as Near Account" },
|
5262
5287
|
{ id: "btc", name: "Bitcoin", description: "MPC Mapping" }
|
5263
5288
|
];
|
5264
|
-
function openChainModal(
|
5265
|
-
return __async(this,
|
5289
|
+
function openChainModal(_0) {
|
5290
|
+
return __async(this, arguments, function* (group, customGroups = []) {
|
5266
5291
|
const chains5 = CHAINS.filter((chain) => group.includes(chain.id));
|
5292
|
+
const allGroups = [...chains5, ...customGroups];
|
5267
5293
|
const content = (resolve, close) => {
|
5268
5294
|
const buttons = `
|
5269
|
-
<div class="option-list">${
|
5270
|
-
(
|
5271
|
-
<img src="https://assets.deltatrade.ai/assets/chain/${
|
5295
|
+
<div class="option-list">${allGroups.map(
|
5296
|
+
(item) => `<button class="chain-button option-item" data-chain="${item.id}">
|
5297
|
+
<img src="https://assets.deltatrade.ai/assets/chain/${item.id}.svg" alt="${item.id}" style="width:32px; height: 32px;" />
|
5272
5298
|
<div style="display: flex; flex-direction: column; text-align: left;">
|
5273
|
-
<div style="font-size: 16px; font-weight: bold;">${
|
5274
|
-
<div style="font-size: 12px; opacity:0.5;">${
|
5299
|
+
<div style="font-size: 16px; font-weight: bold;">${item.name}</div>
|
5300
|
+
<div style="font-size: 12px; opacity:0.5;">${item.description}</div>
|
5275
5301
|
</div>
|
5276
5302
|
</button>`
|
5277
5303
|
).join("")}
|
@@ -5313,7 +5339,7 @@ function getGroup(state) {
|
|
5313
5339
|
|
5314
5340
|
// src/index.ts
|
5315
5341
|
var getVersion = () => {
|
5316
|
-
return "0.5.
|
5342
|
+
return "0.5.77-beta";
|
5317
5343
|
};
|
5318
5344
|
if (typeof window !== "undefined") {
|
5319
5345
|
window.__BTC_WALLET_VERSION = getVersion();
|