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/README.md
CHANGED
package/dist/index.js
CHANGED
@@ -1742,17 +1742,6 @@ var copy_default = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My
|
|
1742
1742
|
|
1743
1743
|
// src/utils/ethereumUtils.ts
|
1744
1744
|
var import_util2 = require("@ethereumjs/util");
|
1745
|
-
var import_bitcore_lib = __toESM(require("bitcore-lib"), 1);
|
1746
|
-
var pubKeyToEVMAddress = (pubKey) => {
|
1747
|
-
const address = (0, import_util2.toChecksumAddress)((0, import_util2.bytesToHex)((0, import_util2.publicToAddress)((0, import_util2.toBytes)(`0x${pubKey}`), true)));
|
1748
|
-
return address;
|
1749
|
-
};
|
1750
|
-
var convertSignature = (signature) => {
|
1751
|
-
const sig = import_bitcore_lib.default.crypto.Signature.fromCompact(Buffer.from(signature, "base64"));
|
1752
|
-
const v = BigInt(sig.i + 27);
|
1753
|
-
const evmSig = (0, import_util2.toRpcSig)(v, sig.r.toBuffer(), sig.s.toBuffer());
|
1754
|
-
return evmSig;
|
1755
|
-
};
|
1756
1745
|
function caculateNativeFee(userOp) {
|
1757
1746
|
return (BigInt(userOp.callGasLimit) + BigInt(userOp.verificationGasLimit) + BigInt(userOp.preVerificationGas)) * BigInt(userOp.maxFeePerGas);
|
1758
1747
|
}
|
@@ -2288,7 +2277,6 @@ var SignModal = ({
|
|
2288
2277
|
var signModal_default = SignModal;
|
2289
2278
|
|
2290
2279
|
// src/evmSigner/index.ts
|
2291
|
-
var import_util3 = require("@ethereumjs/util");
|
2292
2280
|
var import_chains3 = require("@particle-network/chains");
|
2293
2281
|
var import_events4 = require("events");
|
2294
2282
|
var import_viem4 = require("viem");
|
@@ -2331,61 +2319,13 @@ var AASignerProvider = class {
|
|
2331
2319
|
}
|
2332
2320
|
request(arg) {
|
2333
2321
|
return __async(this, null, function* () {
|
2334
|
-
var _a, _b;
|
2335
2322
|
if (arg.method === "eth_sendTransaction" || arg.method === "wallet_addEthereumChain" || arg.method === "wallet_watchAsset" || arg.method === "eth_sign") {
|
2336
|
-
throw new import_viem4.UnsupportedProviderMethodError(
|
2337
|
-
|
2338
|
-
|
2339
|
-
const pubKey = yield this.getPublicKey();
|
2340
|
-
const address = pubKeyToEVMAddress(pubKey);
|
2341
|
-
return [address];
|
2342
|
-
} else if (arg.method === "eth_chainId") {
|
2343
|
-
return `0x${this.chainId.toString(16)}`;
|
2344
|
-
} else if (arg.method === "personal_sign" /* personalSign */) {
|
2345
|
-
let message = (_a = arg.params) == null ? void 0 : _a[0];
|
2346
|
-
console.log("personal_sign message:", message);
|
2347
|
-
if (message.length !== 66) {
|
2348
|
-
const hash = (0, import_viem4.hashMessage)({ raw: message });
|
2349
|
-
console.log("personal_sign hash:", hash);
|
2350
|
-
message = hash;
|
2351
|
-
}
|
2352
|
-
const result = yield this.personalSign(message || "");
|
2353
|
-
const convertResult = convertSignature(result);
|
2354
|
-
if (!convertResult) {
|
2355
|
-
throw new Error("sign error");
|
2356
|
-
}
|
2357
|
-
console.log(`personal_sign result(${convertResult.length}): `, convertResult);
|
2358
|
-
return convertResult;
|
2359
|
-
} else if (arg.method === "eth_signTypedData" || arg.method === "eth_signTypedData_v4") {
|
2360
|
-
const typedData = (_b = arg.params) == null ? void 0 : _b[1];
|
2361
|
-
console.log("signTypedData typedData", typedData);
|
2362
|
-
const hash = (0, import_viem4.hashTypedData)(typeof typedData === "string" ? JSON.parse(typedData) : typedData);
|
2363
|
-
console.log("signTypedData hash", hash);
|
2364
|
-
const result = yield this.personalSign(hash || "");
|
2365
|
-
const convertResult = convertSignature(result);
|
2366
|
-
if (!convertResult) {
|
2367
|
-
throw new Error("sign error");
|
2368
|
-
}
|
2369
|
-
console.log(`eth_signTypedData result(${convertResult.length}): `, convertResult);
|
2370
|
-
return convertResult;
|
2371
|
-
} else if (arg.method === "wallet_switchEthereumChain") {
|
2372
|
-
if (arg.params && arg.params instanceof Array && arg.params[0] && arg.params[0].chainId) {
|
2373
|
-
const chainId = Number(arg.params[0].chainId);
|
2374
|
-
if (this.supportChainIds.includes(this.chainId)) {
|
2375
|
-
this.chainId = chainId;
|
2376
|
-
localStorage.setItem("connect-evm-chain-id", this.chainId.toString());
|
2377
|
-
this.publicClient = this.getPublicClient();
|
2378
|
-
setTimeout(() => this.events.emit("chainChanged", (0, import_util3.intToHex)(this.chainId)), 0);
|
2379
|
-
return Promise.resolve(null);
|
2380
|
-
}
|
2381
|
-
throw new import_viem4.SwitchChainError(new Error(`The chain: ${chainId} is not supported`));
|
2382
|
-
} else {
|
2383
|
-
throw new import_viem4.InvalidParamsRpcError(new Error("Invalid Params"));
|
2384
|
-
}
|
2385
|
-
} else {
|
2386
|
-
const result = yield this.publicClient.request(arg);
|
2387
|
-
return result;
|
2323
|
+
throw new import_viem4.UnsupportedProviderMethodError(
|
2324
|
+
new Error("The Provider does not support the requested method.")
|
2325
|
+
);
|
2388
2326
|
}
|
2327
|
+
const result = yield this.publicClient.request(arg);
|
2328
|
+
return result;
|
2389
2329
|
});
|
2390
2330
|
}
|
2391
2331
|
removeListener(event, listener) {
|
@@ -2760,7 +2700,6 @@ function ComfirmBox({ onClose, status = 1, fromChain = {
|
|
2760
2700
|
}
|
2761
2701
|
|
2762
2702
|
// src/core/btcWalletSelectorContext.tsx
|
2763
|
-
var import_styles = require("ref-modal-ui/styles.css");
|
2764
2703
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
2765
2704
|
var WalletSelectorContext = import_react11.default.createContext(null);
|
2766
2705
|
function BtcWalletSelectorContextProvider({
|
@@ -4903,6 +4842,13 @@ function setupWalletSelectorModal(selector, options) {
|
|
4903
4842
|
throw new Error("selector is required");
|
4904
4843
|
const state = selector.store.getState();
|
4905
4844
|
const group = getGroup(state);
|
4845
|
+
if (group.includes("btc")) {
|
4846
|
+
document.head.appendChild(document.createElement("style")).textContent = `
|
4847
|
+
#near-wallet-selector-modal .options-list .btc-wallet {
|
4848
|
+
display: none;
|
4849
|
+
}
|
4850
|
+
`;
|
4851
|
+
}
|
4906
4852
|
const modal = (0, import_ref_modal_ui.setupModal)(selector, options);
|
4907
4853
|
const originalShow = modal.show.bind(modal);
|
4908
4854
|
modal.show = () => __async(this, null, function* () {
|
@@ -4963,7 +4909,7 @@ function getGroup(state) {
|
|
4963
4909
|
|
4964
4910
|
// src/index.ts
|
4965
4911
|
var getVersion = () => {
|
4966
|
-
return "0.5.
|
4912
|
+
return "0.5.27-beta";
|
4967
4913
|
};
|
4968
4914
|
if (typeof window !== "undefined") {
|
4969
4915
|
window.__BTC_WALLET_VERSION = getVersion();
|