btc-wallet 0.5.26-beta → 0.5.28-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,4 +1,3 @@
1
1
  import type { UserOp } from '@particle-network/aa';
2
2
  export declare const pubKeyToEVMAddress: (pubKey: string) => `0x${string}`;
3
- export declare const convertSignature: (signature: string) => string;
4
3
  export declare function caculateNativeFee(userOp: UserOp): bigint;
package/esm/index.js CHANGED
@@ -19,18 +19,6 @@ var __spreadValues = (a, b) => {
19
19
  return a;
20
20
  };
21
21
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
- var __objRest = (source, exclude) => {
23
- var target = {};
24
- for (var prop in source)
25
- if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
26
- target[prop] = source[prop];
27
- if (source != null && __getOwnPropSymbols)
28
- for (var prop of __getOwnPropSymbols(source)) {
29
- if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
30
- target[prop] = source[prop];
31
- }
32
- return target;
33
- };
34
22
  var __accessCheck = (obj, member, msg) => {
35
23
  if (!member.has(obj))
36
24
  throw TypeError("Cannot " + msg);
@@ -1672,24 +1660,7 @@ var check_box_blank_default = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDo
1672
1660
  var copy_default = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIGhlaWdodD0iMjQiIHZpZXdCb3g9IjAgLTk2MCA5NjAgOTYwIiB3aWR0aD0iMjQiIGZpbGw9IiNmZmYiPgogICAgPHBhdGgKICAgICAgICBkPSJNMzYwLTI0MHEtMzMgMC01Ni41LTIzLjVUMjgwLTMyMHYtNDgwcTAtMzMgMjMuNS01Ni41VDM2MC04ODBoMzYwcTMzIDAgNTYuNSAyMy41VDgwMC04MDB2NDgwcTAgMzMtMjMuNSA1Ni41VDcyMC0yNDBIMzYwWm0wLTgwaDM2MHYtNDgwSDM2MHY0ODBaTTIwMC04MHEtMzMgMC01Ni41LTIzLjVUMTIwLTE2MHYtNTYwaDgwdjU2MGg0NDB2ODBIMjAwWm0xNjAtMjQwdi00ODAgNDgwWiIgLz4KPC9zdmc+";
1673
1661
 
1674
1662
  // 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
- };
1663
+ import { bytesToHex, publicToAddress, toBytes, toChecksumAddress } from "@ethereumjs/util";
1693
1664
  function caculateNativeFee(userOp) {
1694
1665
  return (BigInt(userOp.callGasLimit) + BigInt(userOp.verificationGasLimit) + BigInt(userOp.preVerificationGas)) * BigInt(userOp.maxFeePerGas);
1695
1666
  }
@@ -2225,18 +2196,9 @@ var SignModal = ({
2225
2196
  var signModal_default = SignModal;
2226
2197
 
2227
2198
  // src/evmSigner/index.ts
2228
- import { intToHex as intToHex2 } from "@ethereumjs/util";
2229
2199
  import { chains as chains3 } from "@particle-network/chains";
2230
2200
  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";
2201
+ import { UnsupportedProviderMethodError, createPublicClient, http } from "viem";
2240
2202
  var AASignerProvider = class {
2241
2203
  constructor(supportChainIds, projectId, clientKey, rpcUrls) {
2242
2204
  this.supportChainIds = supportChainIds;
@@ -2276,61 +2238,13 @@ var AASignerProvider = class {
2276
2238
  }
2277
2239
  request(arg) {
2278
2240
  return __async(this, null, function* () {
2279
- var _a, _b;
2280
2241
  if (arg.method === "eth_sendTransaction" || arg.method === "wallet_addEthereumChain" || arg.method === "wallet_watchAsset" || arg.method === "eth_sign") {
2281
- throw new UnsupportedProviderMethodError(new Error("The Provider does not support the requested method."));
2282
- }
2283
- if (arg.method === "eth_accounts" || arg.method === "eth_requestAccounts") {
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;
2242
+ throw new UnsupportedProviderMethodError(
2243
+ new Error("The Provider does not support the requested method.")
2244
+ );
2333
2245
  }
2246
+ const result = yield this.publicClient.request(arg);
2247
+ return result;
2334
2248
  });
2335
2249
  }
2336
2250
  removeListener(event, listener) {
@@ -2705,7 +2619,6 @@ function ComfirmBox({ onClose, status = 1, fromChain = {
2705
2619
  }
2706
2620
 
2707
2621
  // src/core/btcWalletSelectorContext.tsx
2708
- import "ref-modal-ui/styles.css";
2709
2622
  import { jsx as jsx12, jsxs as jsxs9 } from "react/jsx-runtime";
2710
2623
  var WalletSelectorContext = React.createContext(null);
2711
2624
  function BtcWalletSelectorContextProvider({
@@ -4202,13 +4115,13 @@ function getWithdrawTransaction(_0) {
4202
4115
  const config = getWalletConfig(env);
4203
4116
  const _btcAddress = btcAddress || getBtcProvider().account;
4204
4117
  const _csna = csna || (yield getCsnaAccountId(env));
4205
- const _a = yield calculateWithdraw({
4118
+ const { inputs, outputs, isError, errorMsg, fromAmount, gasFee } = yield calculateWithdraw({
4206
4119
  amount,
4207
4120
  feeRate,
4208
4121
  csna: _csna,
4209
4122
  btcAddress: _btcAddress,
4210
4123
  env
4211
- }), { inputs, outputs, isError, errorMsg } = _a, rest = __objRest(_a, ["inputs", "outputs", "isError", "errorMsg"]);
4124
+ });
4212
4125
  if (isError || !inputs || !outputs) {
4213
4126
  throw new Error(errorMsg);
4214
4127
  }
@@ -4216,7 +4129,7 @@ function getWithdrawTransaction(_0) {
4216
4129
  console.log("outputs:", JSON.stringify(outputs));
4217
4130
  console.log("inputs - outputs = gas");
4218
4131
  console.log(
4219
- `(${inputs.map((item) => item.value).join(" + ")}) - (${outputs.map((item) => item.value).join(" + ")}) = ${rest.gasFee}`
4132
+ `(${inputs.map((item) => item.value).join(" + ")}) - (${outputs.map((item) => item.value).join(" + ")}) = ${gasFee}`
4220
4133
  );
4221
4134
  const network = yield getNetwork();
4222
4135
  const btcNetwork = network === "mainnet" ? bitcoin.networks.bitcoin : bitcoin.networks.testnet;
@@ -4269,7 +4182,7 @@ function getWithdrawTransaction(_0) {
4269
4182
  methodName: "ft_transfer_call",
4270
4183
  args: {
4271
4184
  receiver_id: config.bridgeContractId,
4272
- amount: amount.toString(),
4185
+ amount: fromAmount,
4273
4186
  msg: JSON.stringify(msg)
4274
4187
  },
4275
4188
  gas: "300000000000000",
@@ -4917,7 +4830,7 @@ function getGroup(state) {
4917
4830
 
4918
4831
  // src/index.ts
4919
4832
  var getVersion = () => {
4920
- return "0.5.26-beta";
4833
+ return "0.5.28-beta";
4921
4834
  };
4922
4835
  if (typeof window !== "undefined") {
4923
4836
  window.__BTC_WALLET_VERSION = getVersion();