btc-wallet 0.1.3 → 0.1.5
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 +10 -41
- package/dist/index.js.map +2 -2
- package/esm/index.js +10 -41
- package/esm/index.js.map +2 -2
- package/package.json +1 -1
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
|
}
|
@@ -2389,6 +2365,15 @@ function setupWalletButton(network, wallet, originalWallet) {
|
|
2389
2365
|
iframeUrl: network === "testnet" ? "https://wallet-dev.satoshibridge.top" : "https://wallet.satoshibridge.top",
|
2390
2366
|
iframeStyle: { width: "400px", height: "650px" }
|
2391
2367
|
});
|
2368
|
+
iframe.addEventListener("mouseenter", () => {
|
2369
|
+
var _a;
|
2370
|
+
if (document.activeElement !== iframe) {
|
2371
|
+
(_a = document.activeElement) == null ? void 0 : _a.setAttribute("tabindex", "null");
|
2372
|
+
setTimeout(() => {
|
2373
|
+
iframe.focus();
|
2374
|
+
}, 0);
|
2375
|
+
}
|
2376
|
+
});
|
2392
2377
|
const button = createFloatingButtonWithIframe({
|
2393
2378
|
openImageUrl: "https://assets.deltatrade.ai/wallet-assets/wallet-btn.png",
|
2394
2379
|
closeImageUrl: "https://assets.deltatrade.ai/wallet-assets/wallet-btn-active.png",
|
@@ -2460,24 +2445,20 @@ function setupButtonClickHandler(button, iframe, wallet, originalWallet) {
|
|
2460
2445
|
const accountId = (_a = yield wallet == null ? void 0 : wallet.getAccounts()) == null ? void 0 : _a[0].accountId;
|
2461
2446
|
const originalAccountId = originalWallet.account;
|
2462
2447
|
const originalPublicKey = yield originalWallet.getPublicKey();
|
2463
|
-
console.log({ accountId, originalAccountId, originalPublicKey });
|
2464
2448
|
const iframeSrc = new URL(iframe.src);
|
2465
2449
|
iframeSrc.searchParams.set("origin", window.location.origin);
|
2466
2450
|
accountId && iframeSrc.searchParams.set("accountId", accountId);
|
2467
2451
|
originalAccountId && iframeSrc.searchParams.set("originalAccountId", originalAccountId);
|
2468
2452
|
originalPublicKey && iframeSrc.searchParams.set("originalPublicKey", originalPublicKey);
|
2469
2453
|
iframe.src = iframeSrc.toString();
|
2470
|
-
console.log("iframe src", iframe.src);
|
2471
2454
|
window.addEventListener("message", (event) => __async(this, null, function* () {
|
2472
2455
|
var _a2, _b;
|
2473
2456
|
if (event.origin !== iframeSrc.origin)
|
2474
2457
|
return;
|
2475
2458
|
const { action, requestId, data } = event.data;
|
2476
2459
|
if (action === "signAndSendTransaction") {
|
2477
|
-
console.log("signAndSendTransaction message", event.data);
|
2478
2460
|
try {
|
2479
2461
|
const result = yield wallet.signAndSendTransaction(data);
|
2480
|
-
console.log("signAndSendTransaction result", result);
|
2481
2462
|
(_a2 = event.source) == null ? void 0 : _a2.postMessage(
|
2482
2463
|
{
|
2483
2464
|
requestId,
|
@@ -2487,7 +2468,6 @@ function setupButtonClickHandler(button, iframe, wallet, originalWallet) {
|
|
2487
2468
|
{ targetOrigin: event.origin }
|
2488
2469
|
);
|
2489
2470
|
} catch (error) {
|
2490
|
-
console.error("signAndSendTransaction error", error);
|
2491
2471
|
(_b = event.source) == null ? void 0 : _b.postMessage(
|
2492
2472
|
{
|
2493
2473
|
requestId,
|
@@ -2588,7 +2568,6 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
2588
2568
|
const context = btcContext.getContext();
|
2589
2569
|
context.on("updatePublicKey", (btcPublicKey) => __async(void 0, null, function* () {
|
2590
2570
|
const { nearTempAddress } = yield getNearAccountByBtcPublicKey(btcPublicKey);
|
2591
|
-
console.info("accountsChanged:", nearTempAddress, btcContext.account);
|
2592
2571
|
emitter.emit("accountsChanged", {
|
2593
2572
|
accounts: [
|
2594
2573
|
{
|
@@ -2602,7 +2581,6 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
2602
2581
|
accounts: []
|
2603
2582
|
});
|
2604
2583
|
}));
|
2605
|
-
console.log("metadata.autoConnect:", metadata);
|
2606
2584
|
if ("autoConnect" in metadata && metadata.autoConnect && localStorage.getItem("near-wallet-selector:selectedWalletId") === '"btc-wallet"') {
|
2607
2585
|
yield btcContext.autoConnect();
|
2608
2586
|
}
|
@@ -2643,7 +2621,6 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
2643
2621
|
}
|
2644
2622
|
function signIn(_02) {
|
2645
2623
|
return __async(this, arguments, function* ({ contractId, methodNames }) {
|
2646
|
-
console.log(provider);
|
2647
2624
|
const accountId = state.getAccount();
|
2648
2625
|
const publicKey = state.getPublicKey();
|
2649
2626
|
const btcContext = window.btcContext;
|
@@ -2749,7 +2726,6 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
2749
2726
|
txBytes,
|
2750
2727
|
(byte) => ("0" + (byte & 255).toString(16)).slice(-2)
|
2751
2728
|
).join("");
|
2752
|
-
console.log("txHex:", txHex);
|
2753
2729
|
const hash = import_bs58.default.encode(new Uint8Array(import_js_sha256.sha256.array(txBytes)));
|
2754
2730
|
return { txBytes, txHex, hash };
|
2755
2731
|
});
|
@@ -2774,10 +2750,8 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
2774
2750
|
btcPubKey: state.getBtcPublicKey(),
|
2775
2751
|
data: toHex(strIntention)
|
2776
2752
|
});
|
2777
|
-
console.log("result:", result);
|
2778
2753
|
if (result.result_code === 0) {
|
2779
2754
|
const hash = newTransactions.map((t) => t.hash);
|
2780
|
-
console.log("txHash:", hash);
|
2781
2755
|
const result2 = yield pollTransactionStatuses(options.network.networkId, hash);
|
2782
2756
|
return result2;
|
2783
2757
|
} else {
|
@@ -2787,11 +2761,9 @@ var BTCWallet = (_0) => __async(void 0, [_0], function* ({
|
|
2787
2761
|
}
|
2788
2762
|
function initWalletButton(network, wallet2) {
|
2789
2763
|
return __async(this, null, function* () {
|
2790
|
-
console.log("initWalletButton:", network, wallet2);
|
2791
2764
|
const checkAndSetupWalletButton = () => {
|
2792
2765
|
const accountId = state.getAccount();
|
2793
2766
|
const btcContext = window.btcContext;
|
2794
|
-
console.log("checkAndSetupWalletButton:", accountId, btcContext.account);
|
2795
2767
|
if (accountId && btcContext.account) {
|
2796
2768
|
setupWalletButton(network, wallet2, btcContext);
|
2797
2769
|
} else {
|
@@ -2891,17 +2863,14 @@ function pollTransactionStatuses(network, hashes) {
|
|
2891
2863
|
try {
|
2892
2864
|
const result = yield provider.txStatus(hash, "unused", "FINAL");
|
2893
2865
|
if (result && result.status) {
|
2894
|
-
console.log(`Transaction ${hash} result:`, result);
|
2895
2866
|
return result;
|
2896
2867
|
}
|
2897
2868
|
} catch (error) {
|
2898
|
-
console.error(`Failed to fetch transaction status for ${hash}: ${error.message}`);
|
2899
2869
|
}
|
2900
2870
|
if (attempt === maxAttempts) {
|
2901
2871
|
throw new Error(`Transaction not found after max attempts: ${hash}`);
|
2902
2872
|
}
|
2903
2873
|
yield delay(1e4);
|
2904
|
-
console.log(`RPC request failed for ${hash}, retrying ${maxAttempts - attempt} more times`);
|
2905
2874
|
}
|
2906
2875
|
});
|
2907
2876
|
const results = yield Promise.all(hashes.map((hash) => pollStatus(hash)));
|
@@ -2911,7 +2880,7 @@ function pollTransactionStatuses(network, hashes) {
|
|
2911
2880
|
|
2912
2881
|
// src/index.ts
|
2913
2882
|
var getVersion = () => {
|
2914
|
-
return "0.1.
|
2883
|
+
return "0.1.5";
|
2915
2884
|
};
|
2916
2885
|
if (typeof window !== "undefined") {
|
2917
2886
|
window.__PARTICLE_BTC_CONNECT_VERSION = getVersion();
|