btc-wallet 0.5.25-beta → 0.5.27-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/README.md +1 -0
- package/dist/core/btcWalletSelectorContext.d.ts +0 -1
- package/dist/index.js +13 -67
- package/dist/index.js.map +3 -3
- package/dist/utils/ethereumUtils.d.ts +0 -1
- package/esm/index.js +15 -83
- package/esm/index.js.map +3 -3
- package/package.json +1 -2
package/esm/index.js
CHANGED
@@ -1672,24 +1672,7 @@ var check_box_blank_default = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDo
|
|
1672
1672
|
var copy_default = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgLTk2MCA5NjAgOTYwIiB3aWR0aD0iMjQiIGZpbGw9IiNmZmYiPgogICAgPHBhdGgKICAgICAgICBkPSJNMzYwLTI0MHEtMzMgMC01Ni41LTIzLjVUMjgwLTMyMHYtNDgwcTAtMzMgMjMuNS01Ni41VDM2MC04ODBoMzYwcTMzIDAgNTYuNSAyMy41VDgwMC04MDB2NDgwcTAgMzMtMjMuNSA1Ni41VDcyMC0yNDBIMzYwWm0wLTgwaDM2MHYtNDgwSDM2MHY0ODBaTTIwMC04MHEtMzMgMC01Ni41LTIzLjVUMTIwLTE2MHYtNTYwaDgwdjU2MGg0NDB2ODBIMjAwWm0xNjAtMjQwdi00ODAgNDgwWiIgLz4KPC9zdmc+";
|
1673
1673
|
|
1674
1674
|
// src/utils/ethereumUtils.ts
|
1675
|
-
import {
|
1676
|
-
bytesToHex,
|
1677
|
-
publicToAddress,
|
1678
|
-
toBytes,
|
1679
|
-
toChecksumAddress,
|
1680
|
-
toRpcSig
|
1681
|
-
} from "@ethereumjs/util";
|
1682
|
-
import bitcore from "bitcore-lib";
|
1683
|
-
var pubKeyToEVMAddress = (pubKey) => {
|
1684
|
-
const address = toChecksumAddress(bytesToHex(publicToAddress(toBytes(`0x${pubKey}`), true)));
|
1685
|
-
return address;
|
1686
|
-
};
|
1687
|
-
var convertSignature = (signature) => {
|
1688
|
-
const sig = bitcore.crypto.Signature.fromCompact(Buffer.from(signature, "base64"));
|
1689
|
-
const v = BigInt(sig.i + 27);
|
1690
|
-
const evmSig = toRpcSig(v, sig.r.toBuffer(), sig.s.toBuffer());
|
1691
|
-
return evmSig;
|
1692
|
-
};
|
1675
|
+
import { bytesToHex, publicToAddress, toBytes, toChecksumAddress } from "@ethereumjs/util";
|
1693
1676
|
function caculateNativeFee(userOp) {
|
1694
1677
|
return (BigInt(userOp.callGasLimit) + BigInt(userOp.verificationGasLimit) + BigInt(userOp.preVerificationGas)) * BigInt(userOp.maxFeePerGas);
|
1695
1678
|
}
|
@@ -2225,18 +2208,9 @@ var SignModal = ({
|
|
2225
2208
|
var signModal_default = SignModal;
|
2226
2209
|
|
2227
2210
|
// src/evmSigner/index.ts
|
2228
|
-
import { intToHex as intToHex2 } from "@ethereumjs/util";
|
2229
2211
|
import { chains as chains3 } from "@particle-network/chains";
|
2230
2212
|
import { EventEmitter as EventEmitter4 } from "events";
|
2231
|
-
import {
|
2232
|
-
InvalidParamsRpcError,
|
2233
|
-
SwitchChainError,
|
2234
|
-
UnsupportedProviderMethodError,
|
2235
|
-
createPublicClient,
|
2236
|
-
hashMessage,
|
2237
|
-
hashTypedData,
|
2238
|
-
http
|
2239
|
-
} from "viem";
|
2213
|
+
import { UnsupportedProviderMethodError, createPublicClient, http } from "viem";
|
2240
2214
|
var AASignerProvider = class {
|
2241
2215
|
constructor(supportChainIds, projectId, clientKey, rpcUrls) {
|
2242
2216
|
this.supportChainIds = supportChainIds;
|
@@ -2276,61 +2250,13 @@ var AASignerProvider = class {
|
|
2276
2250
|
}
|
2277
2251
|
request(arg) {
|
2278
2252
|
return __async(this, null, function* () {
|
2279
|
-
var _a, _b;
|
2280
2253
|
if (arg.method === "eth_sendTransaction" || arg.method === "wallet_addEthereumChain" || arg.method === "wallet_watchAsset" || arg.method === "eth_sign") {
|
2281
|
-
throw new UnsupportedProviderMethodError(
|
2282
|
-
|
2283
|
-
|
2284
|
-
const pubKey = yield this.getPublicKey();
|
2285
|
-
const address = pubKeyToEVMAddress(pubKey);
|
2286
|
-
return [address];
|
2287
|
-
} else if (arg.method === "eth_chainId") {
|
2288
|
-
return `0x${this.chainId.toString(16)}`;
|
2289
|
-
} else if (arg.method === "personal_sign" /* personalSign */) {
|
2290
|
-
let message = (_a = arg.params) == null ? void 0 : _a[0];
|
2291
|
-
console.log("personal_sign message:", message);
|
2292
|
-
if (message.length !== 66) {
|
2293
|
-
const hash = hashMessage({ raw: message });
|
2294
|
-
console.log("personal_sign hash:", hash);
|
2295
|
-
message = hash;
|
2296
|
-
}
|
2297
|
-
const result = yield this.personalSign(message || "");
|
2298
|
-
const convertResult = convertSignature(result);
|
2299
|
-
if (!convertResult) {
|
2300
|
-
throw new Error("sign error");
|
2301
|
-
}
|
2302
|
-
console.log(`personal_sign result(${convertResult.length}): `, convertResult);
|
2303
|
-
return convertResult;
|
2304
|
-
} else if (arg.method === "eth_signTypedData" || arg.method === "eth_signTypedData_v4") {
|
2305
|
-
const typedData = (_b = arg.params) == null ? void 0 : _b[1];
|
2306
|
-
console.log("signTypedData typedData", typedData);
|
2307
|
-
const hash = hashTypedData(typeof typedData === "string" ? JSON.parse(typedData) : typedData);
|
2308
|
-
console.log("signTypedData hash", hash);
|
2309
|
-
const result = yield this.personalSign(hash || "");
|
2310
|
-
const convertResult = convertSignature(result);
|
2311
|
-
if (!convertResult) {
|
2312
|
-
throw new Error("sign error");
|
2313
|
-
}
|
2314
|
-
console.log(`eth_signTypedData result(${convertResult.length}): `, convertResult);
|
2315
|
-
return convertResult;
|
2316
|
-
} else if (arg.method === "wallet_switchEthereumChain") {
|
2317
|
-
if (arg.params && arg.params instanceof Array && arg.params[0] && arg.params[0].chainId) {
|
2318
|
-
const chainId = Number(arg.params[0].chainId);
|
2319
|
-
if (this.supportChainIds.includes(this.chainId)) {
|
2320
|
-
this.chainId = chainId;
|
2321
|
-
localStorage.setItem("connect-evm-chain-id", this.chainId.toString());
|
2322
|
-
this.publicClient = this.getPublicClient();
|
2323
|
-
setTimeout(() => this.events.emit("chainChanged", intToHex2(this.chainId)), 0);
|
2324
|
-
return Promise.resolve(null);
|
2325
|
-
}
|
2326
|
-
throw new SwitchChainError(new Error(`The chain: ${chainId} is not supported`));
|
2327
|
-
} else {
|
2328
|
-
throw new InvalidParamsRpcError(new Error("Invalid Params"));
|
2329
|
-
}
|
2330
|
-
} else {
|
2331
|
-
const result = yield this.publicClient.request(arg);
|
2332
|
-
return result;
|
2254
|
+
throw new UnsupportedProviderMethodError(
|
2255
|
+
new Error("The Provider does not support the requested method.")
|
2256
|
+
);
|
2333
2257
|
}
|
2258
|
+
const result = yield this.publicClient.request(arg);
|
2259
|
+
return result;
|
2334
2260
|
});
|
2335
2261
|
}
|
2336
2262
|
removeListener(event, listener) {
|
@@ -2705,7 +2631,6 @@ function ComfirmBox({ onClose, status = 1, fromChain = {
|
|
2705
2631
|
}
|
2706
2632
|
|
2707
2633
|
// src/core/btcWalletSelectorContext.tsx
|
2708
|
-
import "ref-modal-ui/styles.css";
|
2709
2634
|
import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
|
2710
2635
|
var WalletSelectorContext = React.createContext(null);
|
2711
2636
|
function BtcWalletSelectorContextProvider({
|
@@ -4850,6 +4775,13 @@ function setupWalletSelectorModal(selector, options) {
|
|
4850
4775
|
throw new Error("selector is required");
|
4851
4776
|
const state = selector.store.getState();
|
4852
4777
|
const group = getGroup(state);
|
4778
|
+
if (group.includes("btc")) {
|
4779
|
+
document.head.appendChild(document.createElement("style")).textContent = `
|
4780
|
+
#near-wallet-selector-modal .options-list .btc-wallet {
|
4781
|
+
display: none;
|
4782
|
+
}
|
4783
|
+
`;
|
4784
|
+
}
|
4853
4785
|
const modal = _setupModal(selector, options);
|
4854
4786
|
const originalShow = modal.show.bind(modal);
|
4855
4787
|
modal.show = () => __async(this, null, function* () {
|
@@ -4910,7 +4842,7 @@ function getGroup(state) {
|
|
4910
4842
|
|
4911
4843
|
// src/index.ts
|
4912
4844
|
var getVersion = () => {
|
4913
|
-
return "0.5.
|
4845
|
+
return "0.5.27-beta";
|
4914
4846
|
};
|
4915
4847
|
if (typeof window !== "undefined") {
|
4916
4848
|
window.__BTC_WALLET_VERSION = getVersion();
|