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.
- package/README.md +1 -0
- package/dist/core/btcWalletSelectorContext.d.ts +0 -1
- package/dist/index.js +10 -83
- package/dist/index.js.map +3 -3
- package/dist/utils/ethereumUtils.d.ts +0 -1
- package/esm/index.js +12 -99
- package/esm/index.js.map +3 -3
- package/package.json +1 -2
package/README.md
CHANGED
package/dist/index.js
CHANGED
@@ -24,18 +24,6 @@ var __spreadValues = (a, b) => {
|
|
24
24
|
return a;
|
25
25
|
};
|
26
26
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
27
|
-
var __objRest = (source, exclude) => {
|
28
|
-
var target = {};
|
29
|
-
for (var prop in source)
|
30
|
-
if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
|
31
|
-
target[prop] = source[prop];
|
32
|
-
if (source != null && __getOwnPropSymbols)
|
33
|
-
for (var prop of __getOwnPropSymbols(source)) {
|
34
|
-
if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
|
35
|
-
target[prop] = source[prop];
|
36
|
-
}
|
37
|
-
return target;
|
38
|
-
};
|
39
27
|
var __export = (target, all) => {
|
40
28
|
for (var name in all)
|
41
29
|
__defProp(target, name, { get: all[name], enumerable: true });
|
@@ -1742,17 +1730,6 @@ var copy_default = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My
|
|
1742
1730
|
|
1743
1731
|
// src/utils/ethereumUtils.ts
|
1744
1732
|
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
1733
|
function caculateNativeFee(userOp) {
|
1757
1734
|
return (BigInt(userOp.callGasLimit) + BigInt(userOp.verificationGasLimit) + BigInt(userOp.preVerificationGas)) * BigInt(userOp.maxFeePerGas);
|
1758
1735
|
}
|
@@ -2288,7 +2265,6 @@ var SignModal = ({
|
|
2288
2265
|
var signModal_default = SignModal;
|
2289
2266
|
|
2290
2267
|
// src/evmSigner/index.ts
|
2291
|
-
var import_util3 = require("@ethereumjs/util");
|
2292
2268
|
var import_chains3 = require("@particle-network/chains");
|
2293
2269
|
var import_events4 = require("events");
|
2294
2270
|
var import_viem4 = require("viem");
|
@@ -2331,61 +2307,13 @@ var AASignerProvider = class {
|
|
2331
2307
|
}
|
2332
2308
|
request(arg) {
|
2333
2309
|
return __async(this, null, function* () {
|
2334
|
-
var _a, _b;
|
2335
2310
|
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;
|
2311
|
+
throw new import_viem4.UnsupportedProviderMethodError(
|
2312
|
+
new Error("The Provider does not support the requested method.")
|
2313
|
+
);
|
2388
2314
|
}
|
2315
|
+
const result = yield this.publicClient.request(arg);
|
2316
|
+
return result;
|
2389
2317
|
});
|
2390
2318
|
}
|
2391
2319
|
removeListener(event, listener) {
|
@@ -2760,7 +2688,6 @@ function ComfirmBox({ onClose, status = 1, fromChain = {
|
|
2760
2688
|
}
|
2761
2689
|
|
2762
2690
|
// src/core/btcWalletSelectorContext.tsx
|
2763
|
-
var import_styles = require("ref-modal-ui/styles.css");
|
2764
2691
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
2765
2692
|
var WalletSelectorContext = import_react11.default.createContext(null);
|
2766
2693
|
function BtcWalletSelectorContextProvider({
|
@@ -4257,13 +4184,13 @@ function getWithdrawTransaction(_0) {
|
|
4257
4184
|
const config = getWalletConfig(env);
|
4258
4185
|
const _btcAddress = btcAddress || getBtcProvider().account;
|
4259
4186
|
const _csna = csna || (yield getCsnaAccountId(env));
|
4260
|
-
const
|
4187
|
+
const { inputs, outputs, isError, errorMsg, fromAmount, gasFee } = yield calculateWithdraw({
|
4261
4188
|
amount,
|
4262
4189
|
feeRate,
|
4263
4190
|
csna: _csna,
|
4264
4191
|
btcAddress: _btcAddress,
|
4265
4192
|
env
|
4266
|
-
})
|
4193
|
+
});
|
4267
4194
|
if (isError || !inputs || !outputs) {
|
4268
4195
|
throw new Error(errorMsg);
|
4269
4196
|
}
|
@@ -4271,7 +4198,7 @@ function getWithdrawTransaction(_0) {
|
|
4271
4198
|
console.log("outputs:", JSON.stringify(outputs));
|
4272
4199
|
console.log("inputs - outputs = gas");
|
4273
4200
|
console.log(
|
4274
|
-
`(${inputs.map((item) => item.value).join(" + ")}) - (${outputs.map((item) => item.value).join(" + ")}) = ${
|
4201
|
+
`(${inputs.map((item) => item.value).join(" + ")}) - (${outputs.map((item) => item.value).join(" + ")}) = ${gasFee}`
|
4275
4202
|
);
|
4276
4203
|
const network = yield getNetwork();
|
4277
4204
|
const btcNetwork = network === "mainnet" ? import_bitcoinjs_lib.default.networks.bitcoin : import_bitcoinjs_lib.default.networks.testnet;
|
@@ -4324,7 +4251,7 @@ function getWithdrawTransaction(_0) {
|
|
4324
4251
|
methodName: "ft_transfer_call",
|
4325
4252
|
args: {
|
4326
4253
|
receiver_id: config.bridgeContractId,
|
4327
|
-
amount:
|
4254
|
+
amount: fromAmount,
|
4328
4255
|
msg: JSON.stringify(msg)
|
4329
4256
|
},
|
4330
4257
|
gas: "300000000000000",
|
@@ -4970,7 +4897,7 @@ function getGroup(state) {
|
|
4970
4897
|
|
4971
4898
|
// src/index.ts
|
4972
4899
|
var getVersion = () => {
|
4973
|
-
return "0.5.
|
4900
|
+
return "0.5.28-beta";
|
4974
4901
|
};
|
4975
4902
|
if (typeof window !== "undefined") {
|
4976
4903
|
window.__BTC_WALLET_VERSION = getVersion();
|