@weblock-wallet/sdk 0.1.57 → 0.1.59
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.cjs +32 -31
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +32 -31
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -104664,25 +104664,40 @@ var WalletService = class {
|
|
|
104664
104664
|
if (!from) {
|
|
104665
104665
|
throw new SDKError("Wallet not found", "WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */);
|
|
104666
104666
|
}
|
|
104667
|
-
const
|
|
104668
|
-
|
|
104669
|
-
|
|
104670
|
-
|
|
104671
|
-
|
|
104672
|
-
|
|
104673
|
-
|
|
104674
|
-
|
|
104675
|
-
|
|
104676
|
-
|
|
104667
|
+
const walletInfo = await this.walletClient.getWallet();
|
|
104668
|
+
const share1 = walletInfo?.share1;
|
|
104669
|
+
let share2 = await LocalForage.get(
|
|
104670
|
+
STORAGE_KEYS.share2(this.orgHost)
|
|
104671
|
+
);
|
|
104672
|
+
if (!share2) {
|
|
104673
|
+
const [firebaseId, deviceSecret, encryptedShare2Device] = await Promise.all([
|
|
104674
|
+
LocalForage.get(STORAGE_KEYS.firebaseId(this.orgHost)),
|
|
104675
|
+
LocalForage.get(STORAGE_KEYS.deviceSecret(this.orgHost)),
|
|
104676
|
+
LocalForage.get(
|
|
104677
|
+
STORAGE_KEYS.encryptedShare2Device(this.orgHost)
|
|
104678
|
+
)
|
|
104679
|
+
]);
|
|
104680
|
+
if (firebaseId && deviceSecret && encryptedShare2Device) {
|
|
104681
|
+
try {
|
|
104682
|
+
console.debug(
|
|
104683
|
+
"[WalletService] recovering share2 from encryptedShare2_device"
|
|
104684
|
+
);
|
|
104685
|
+
share2 = Crypto.decryptShare(
|
|
104686
|
+
encryptedShare2Device,
|
|
104687
|
+
deviceSecret,
|
|
104688
|
+
firebaseId
|
|
104689
|
+
);
|
|
104690
|
+
} catch (e7) {
|
|
104691
|
+
console.warn(
|
|
104692
|
+
"[WalletService] failed to decrypt encryptedShare2_device",
|
|
104693
|
+
e7
|
|
104694
|
+
);
|
|
104695
|
+
}
|
|
104677
104696
|
}
|
|
104678
|
-
}
|
|
104679
|
-
const [share1, share2] = await Promise.all([
|
|
104680
|
-
this.walletClient.getWallet().then((wallet2) => wallet2.share1),
|
|
104681
|
-
LocalForage.get(STORAGE_KEYS.share2(this.orgHost))
|
|
104682
|
-
]);
|
|
104697
|
+
}
|
|
104683
104698
|
if (!share1 || !share2) {
|
|
104684
104699
|
throw new SDKError(
|
|
104685
|
-
"Wallet shares not found",
|
|
104700
|
+
"Wallet shares not found. Please unlock the wallet by calling retrieveWallet(PIN) once on this device.",
|
|
104686
104701
|
"WALLET_NOT_FOUND" /* WALLET_NOT_FOUND */
|
|
104687
104702
|
);
|
|
104688
104703
|
}
|
|
@@ -104690,20 +104705,6 @@ var WalletService = class {
|
|
|
104690
104705
|
const wallet = new import_ethers2.Wallet(privateKey);
|
|
104691
104706
|
const nonce = params.nonce ?? await this.getTransactionCount(from, params.chainId);
|
|
104692
104707
|
const gasPrice = params.gasPrice ?? await this.getGasPrice(params.chainId);
|
|
104693
|
-
let gasLimit = params.gasLimit;
|
|
104694
|
-
if (!gasLimit) {
|
|
104695
|
-
const est = await this.estimateGas(
|
|
104696
|
-
{
|
|
104697
|
-
from,
|
|
104698
|
-
to: params.to,
|
|
104699
|
-
value: toHexQuantity(params.value),
|
|
104700
|
-
data: params.data || "0x"
|
|
104701
|
-
},
|
|
104702
|
-
params.chainId
|
|
104703
|
-
);
|
|
104704
|
-
const buffered = Math.max(21e3, Math.ceil(est * 1.2));
|
|
104705
|
-
gasLimit = "0x" + buffered.toString(16);
|
|
104706
|
-
}
|
|
104707
104708
|
const signedTx = await wallet.signTransaction({
|
|
104708
104709
|
to: params.to,
|
|
104709
104710
|
value: params.value,
|
|
@@ -104711,7 +104712,7 @@ var WalletService = class {
|
|
|
104711
104712
|
chainId: params.chainId,
|
|
104712
104713
|
nonce,
|
|
104713
104714
|
gasPrice,
|
|
104714
|
-
gasLimit
|
|
104715
|
+
gasLimit: params.gasLimit
|
|
104715
104716
|
});
|
|
104716
104717
|
return this.sendRawTransaction(signedTx, params.chainId);
|
|
104717
104718
|
} catch (error) {
|