@d13co/use-wallet 4.5.5 → 4.5.7
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 +52 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +52 -43
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -550,11 +550,8 @@ declare abstract class LiquidEvmBaseWallet extends BaseWallet {
|
|
|
550
550
|
/**
|
|
551
551
|
* Process transaction group to extract transactions that need signing
|
|
552
552
|
*/
|
|
553
|
-
protected processTxns(txnGroup: algosdk.Transaction[], indexesToSign?: number[]):
|
|
554
|
-
|
|
555
|
-
* Process encoded transaction group to extract transactions that need signing
|
|
556
|
-
*/
|
|
557
|
-
protected processEncodedTxns(txnGroup: Uint8Array[], indexesToSign?: number[]): algosdk.Transaction[];
|
|
553
|
+
protected processTxns(txnGroup: algosdk.Transaction[], indexesToSign?: number[]): SignerTransaction[];
|
|
554
|
+
private processEncodedTxns;
|
|
558
555
|
/**
|
|
559
556
|
* Sign Algorand transactions using EVM wallet signatures
|
|
560
557
|
*/
|
|
@@ -582,6 +579,9 @@ interface RainbowKitWalletOptions extends LiquidEvmOptions {
|
|
|
582
579
|
declare class RainbowKitWallet extends LiquidEvmBaseWallet {
|
|
583
580
|
protected options: RainbowKitWalletOptions;
|
|
584
581
|
private _connecting;
|
|
582
|
+
private _disconnecting;
|
|
583
|
+
/** True while disconnect() is running. Used by the bridge to prevent re-entrancy. */
|
|
584
|
+
get isDisconnecting(): boolean;
|
|
585
585
|
constructor(params: WalletConstructor<WalletId.RAINBOWKIT>);
|
|
586
586
|
static defaultMetadata: {
|
|
587
587
|
name: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -550,11 +550,8 @@ declare abstract class LiquidEvmBaseWallet extends BaseWallet {
|
|
|
550
550
|
/**
|
|
551
551
|
* Process transaction group to extract transactions that need signing
|
|
552
552
|
*/
|
|
553
|
-
protected processTxns(txnGroup: algosdk.Transaction[], indexesToSign?: number[]):
|
|
554
|
-
|
|
555
|
-
* Process encoded transaction group to extract transactions that need signing
|
|
556
|
-
*/
|
|
557
|
-
protected processEncodedTxns(txnGroup: Uint8Array[], indexesToSign?: number[]): algosdk.Transaction[];
|
|
553
|
+
protected processTxns(txnGroup: algosdk.Transaction[], indexesToSign?: number[]): SignerTransaction[];
|
|
554
|
+
private processEncodedTxns;
|
|
558
555
|
/**
|
|
559
556
|
* Sign Algorand transactions using EVM wallet signatures
|
|
560
557
|
*/
|
|
@@ -582,6 +579,9 @@ interface RainbowKitWalletOptions extends LiquidEvmOptions {
|
|
|
582
579
|
declare class RainbowKitWallet extends LiquidEvmBaseWallet {
|
|
583
580
|
protected options: RainbowKitWalletOptions;
|
|
584
581
|
private _connecting;
|
|
582
|
+
private _disconnecting;
|
|
583
|
+
/** True while disconnect() is running. Used by the bridge to prevent re-entrancy. */
|
|
584
|
+
get isDisconnecting(): boolean;
|
|
585
585
|
constructor(params: WalletConstructor<WalletId.RAINBOWKIT>);
|
|
586
586
|
static defaultMetadata: {
|
|
587
587
|
name: string;
|
package/dist/index.js
CHANGED
|
@@ -8623,7 +8623,9 @@ var LiquidEvmBaseWallet = class extends BaseWallet {
|
|
|
8623
8623
|
if (currentChainId.toLowerCase() === ALGORAND_CHAIN_ID_HEX.toLowerCase()) {
|
|
8624
8624
|
return;
|
|
8625
8625
|
}
|
|
8626
|
-
this.logger.info(
|
|
8626
|
+
this.logger.info(
|
|
8627
|
+
`Wrong chain (${currentChainId}), switching to Algorand (${ALGORAND_CHAIN_ID_HEX})...`
|
|
8628
|
+
);
|
|
8627
8629
|
try {
|
|
8628
8630
|
await provider.request({
|
|
8629
8631
|
method: "wallet_switchEthereumChain",
|
|
@@ -8694,14 +8696,13 @@ var LiquidEvmBaseWallet = class extends BaseWallet {
|
|
|
8694
8696
|
const signer = txn.sender.toString();
|
|
8695
8697
|
const canSignTxn = this.addresses.includes(signer);
|
|
8696
8698
|
if (isIndexMatch && canSignTxn) {
|
|
8697
|
-
txnsToSign.push(txn);
|
|
8699
|
+
txnsToSign.push({ txn });
|
|
8700
|
+
} else {
|
|
8701
|
+
txnsToSign.push({ txn, signers: [] });
|
|
8698
8702
|
}
|
|
8699
8703
|
});
|
|
8700
8704
|
return txnsToSign;
|
|
8701
8705
|
}
|
|
8702
|
-
/**
|
|
8703
|
-
* Process encoded transaction group to extract transactions that need signing
|
|
8704
|
-
*/
|
|
8705
8706
|
processEncodedTxns(txnGroup, indexesToSign) {
|
|
8706
8707
|
const txnsToSign = [];
|
|
8707
8708
|
txnGroup.forEach((txnBuffer, index) => {
|
|
@@ -8712,7 +8713,9 @@ var LiquidEvmBaseWallet = class extends BaseWallet {
|
|
|
8712
8713
|
const signer = txn.sender.toString();
|
|
8713
8714
|
const canSignTxn = !isSigned && this.addresses.includes(signer);
|
|
8714
8715
|
if (isIndexMatch && canSignTxn) {
|
|
8715
|
-
txnsToSign.push(txn);
|
|
8716
|
+
txnsToSign.push({ txn });
|
|
8717
|
+
} else {
|
|
8718
|
+
txnsToSign.push({ txn, signers: [] });
|
|
8716
8719
|
}
|
|
8717
8720
|
});
|
|
8718
8721
|
return txnsToSign;
|
|
@@ -8723,25 +8726,17 @@ var LiquidEvmBaseWallet = class extends BaseWallet {
|
|
|
8723
8726
|
signTransactions = async (txnGroup, indexesToSign) => {
|
|
8724
8727
|
try {
|
|
8725
8728
|
this.logger.debug("Signing transactions...", { txnGroup, indexesToSign });
|
|
8726
|
-
const
|
|
8727
|
-
let
|
|
8729
|
+
const liquidEvmSdk = await this.initializeEvmSdk();
|
|
8730
|
+
let txnsToSign = [];
|
|
8728
8731
|
if (isTransactionArray(txnGroup)) {
|
|
8729
|
-
flatTxns = flattenTxnGroup(txnGroup);
|
|
8732
|
+
const flatTxns = flattenTxnGroup(txnGroup);
|
|
8733
|
+
txnsToSign = this.processTxns(flatTxns, indexesToSign);
|
|
8730
8734
|
} else {
|
|
8731
|
-
const
|
|
8732
|
-
|
|
8733
|
-
const decodedObj = algosdk11.msgpackRawDecode(txnBuffer);
|
|
8734
|
-
const isSigned = isSignedTxn(decodedObj);
|
|
8735
|
-
return isSigned ? algosdk11.decodeSignedTransaction(txnBuffer).txn : algosdk11.decodeUnsignedTransaction(txnBuffer);
|
|
8736
|
-
});
|
|
8737
|
-
}
|
|
8738
|
-
const txnsToSign = isTransactionArray(txnGroup) ? this.processTxns(flatTxns, indexesToSign) : this.processEncodedTxns(flattenTxnGroup(txnGroup), indexesToSign);
|
|
8739
|
-
if (txnsToSign.length === 0) {
|
|
8740
|
-
this.logger.debug("No transactions to sign");
|
|
8741
|
-
return flatTxns.map(() => null);
|
|
8735
|
+
const flatTxns = flattenTxnGroup(txnGroup);
|
|
8736
|
+
txnsToSign = this.processEncodedTxns(flatTxns, indexesToSign);
|
|
8742
8737
|
}
|
|
8743
8738
|
const firstTxn = txnsToSign[0];
|
|
8744
|
-
const algorandAddress = firstTxn.sender.toString();
|
|
8739
|
+
const algorandAddress = firstTxn.txn.sender.toString();
|
|
8745
8740
|
let evmAddress = this.evmAddressMap.get(algorandAddress);
|
|
8746
8741
|
if (!evmAddress) {
|
|
8747
8742
|
const walletState = this.store.state.wallets[this.id];
|
|
@@ -8761,14 +8756,20 @@ var LiquidEvmBaseWallet = class extends BaseWallet {
|
|
|
8761
8756
|
const onBeforeSign = this.options.uiHooks?.onBeforeSign ?? this.managerUIHooks?.onBeforeSign;
|
|
8762
8757
|
if (onBeforeSign) {
|
|
8763
8758
|
this.logger.debug("Running onBeforeSign hook", { txnGroup, indexesToSign });
|
|
8764
|
-
|
|
8759
|
+
const txnsAsUint8 = txnsToSign.map(({ txn }) => algosdk11.encodeUnsignedTransaction(txn));
|
|
8760
|
+
await onBeforeSign(txnsAsUint8, indexesToSign);
|
|
8765
8761
|
}
|
|
8766
8762
|
await this.ensureAlgorandChain();
|
|
8767
|
-
const
|
|
8763
|
+
const { signer: evmSigner } = await liquidEvmSdk.getSigner({
|
|
8768
8764
|
evmAddress,
|
|
8769
|
-
txns: flatTxns,
|
|
8770
8765
|
signMessage: (typedData) => this.signWithProvider(typedData, evmAddress)
|
|
8771
8766
|
});
|
|
8767
|
+
const allTxns = txnsToSign.map((t) => t.txn);
|
|
8768
|
+
const signIndexes = txnsToSign.reduce((acc, t, i) => {
|
|
8769
|
+
if (!("signers" in t)) acc.push(i);
|
|
8770
|
+
return acc;
|
|
8771
|
+
}, []);
|
|
8772
|
+
const signedBlobs = await evmSigner(allTxns, signIndexes);
|
|
8772
8773
|
const onAfterSign = this.options.uiHooks?.onAfterSign ?? this.managerUIHooks?.onAfterSign;
|
|
8773
8774
|
if (onAfterSign) {
|
|
8774
8775
|
this.logger.debug("Running onAfterSign hook");
|
|
@@ -8777,12 +8778,10 @@ var LiquidEvmBaseWallet = class extends BaseWallet {
|
|
|
8777
8778
|
} catch (e) {
|
|
8778
8779
|
}
|
|
8779
8780
|
}
|
|
8780
|
-
|
|
8781
|
-
|
|
8782
|
-
|
|
8783
|
-
|
|
8784
|
-
if (isIndexMatch && canSignTxn) {
|
|
8785
|
-
return signedBlobs[index];
|
|
8781
|
+
let signedIdx = 0;
|
|
8782
|
+
const result = txnsToSign.map((_2, index) => {
|
|
8783
|
+
if (signIndexes.includes(index)) {
|
|
8784
|
+
return signedBlobs[signedIdx++];
|
|
8786
8785
|
}
|
|
8787
8786
|
return null;
|
|
8788
8787
|
});
|
|
@@ -8840,22 +8839,25 @@ import {
|
|
|
8840
8839
|
} from "liquid-accounts-evm";
|
|
8841
8840
|
var ICON13 = `data:image/svg+xml;base64,${btoa(`
|
|
8842
8841
|
<svg width="120" height="120" viewBox="0 0 120 120" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
8843
|
-
<rect width="120" height="120" rx="24" fill="
|
|
8844
|
-
<
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
|
|
8849
|
-
<
|
|
8850
|
-
|
|
8851
|
-
|
|
8852
|
-
</linearGradient>
|
|
8853
|
-
</defs>
|
|
8842
|
+
<rect width="120" height="120" rx="24" fill="#627EEA"/>
|
|
8843
|
+
<svg x="30" y="11" width="60" height="98" viewBox="420.1 80.7 1079.8 1758.6">
|
|
8844
|
+
<path d="m959.8 80.7-539.7 895.6 539.7-245.3z" fill="white"/>
|
|
8845
|
+
<path d="m959.8 731-539.7 245.3 539.7 319.1z" fill="white" fill-opacity=".602"/>
|
|
8846
|
+
<path d="m1499.6 976.3-539.8-895.6v650.3z" fill="white" fill-opacity=".602"/>
|
|
8847
|
+
<path d="m959.8 1295.4 539.8-319.1-539.8-245.3z" fill="white" fill-opacity=".2"/>
|
|
8848
|
+
<path d="m420.1 1078.7 539.7 760.6v-441.7z" fill="white"/>
|
|
8849
|
+
<path d="m959.8 1397.6v441.7l540.1-760.6z" fill="white" fill-opacity=".602"/>
|
|
8850
|
+
</svg>
|
|
8854
8851
|
</svg>
|
|
8855
8852
|
`)}`;
|
|
8856
8853
|
var RainbowKitWallet = class _RainbowKitWallet extends LiquidEvmBaseWallet {
|
|
8857
8854
|
options;
|
|
8858
8855
|
_connecting = false;
|
|
8856
|
+
_disconnecting = false;
|
|
8857
|
+
/** True while disconnect() is running. Used by the bridge to prevent re-entrancy. */
|
|
8858
|
+
get isDisconnecting() {
|
|
8859
|
+
return this._disconnecting;
|
|
8860
|
+
}
|
|
8859
8861
|
constructor(params) {
|
|
8860
8862
|
super(params);
|
|
8861
8863
|
this.options = params.options || {};
|
|
@@ -9042,12 +9044,15 @@ var RainbowKitWallet = class _RainbowKitWallet extends LiquidEvmBaseWallet {
|
|
|
9042
9044
|
}
|
|
9043
9045
|
};
|
|
9044
9046
|
disconnect = async () => {
|
|
9047
|
+
this._disconnecting = true;
|
|
9045
9048
|
this.logger.info("Disconnecting...");
|
|
9046
9049
|
try {
|
|
9047
9050
|
const { disconnect: wagmiDisconnect } = await import("@wagmi/core");
|
|
9048
9051
|
await wagmiDisconnect(this.wagmiConfig);
|
|
9049
9052
|
} catch (error) {
|
|
9050
9053
|
this.logger.warn("wagmi disconnect error:", error.message);
|
|
9054
|
+
} finally {
|
|
9055
|
+
this._disconnecting = false;
|
|
9051
9056
|
}
|
|
9052
9057
|
this.evmAddressMap.clear();
|
|
9053
9058
|
this.updateMetadata(_RainbowKitWallet.defaultMetadata);
|
|
@@ -9074,8 +9079,8 @@ var RainbowKitWallet = class _RainbowKitWallet extends LiquidEvmBaseWallet {
|
|
|
9074
9079
|
if (account.isConnected && account.address) {
|
|
9075
9080
|
evmAddresses = account.addresses ? [...account.addresses] : [account.address];
|
|
9076
9081
|
connectorInfo = _RainbowKitWallet.extractConnectorInfo(account);
|
|
9077
|
-
} else {
|
|
9078
|
-
this.logger.warn("EVM wallet
|
|
9082
|
+
} else if (account.status === "reconnecting") {
|
|
9083
|
+
this.logger.warn("EVM wallet reconnecting, resuming from persisted state");
|
|
9079
9084
|
evmAddresses = walletState.accounts.map((a) => a.metadata?.evmAddress).filter(Boolean);
|
|
9080
9085
|
if (evmAddresses.length === 0) {
|
|
9081
9086
|
this.logger.warn("No persisted EVM addresses, cannot resume");
|
|
@@ -9083,6 +9088,10 @@ var RainbowKitWallet = class _RainbowKitWallet extends LiquidEvmBaseWallet {
|
|
|
9083
9088
|
return;
|
|
9084
9089
|
}
|
|
9085
9090
|
connectorInfo = {};
|
|
9091
|
+
} else {
|
|
9092
|
+
this.logger.warn("EVM wallet reconnect failed (status: disconnected), disconnecting");
|
|
9093
|
+
this.onDisconnect();
|
|
9094
|
+
return;
|
|
9086
9095
|
}
|
|
9087
9096
|
if (!connectorInfo.name && walletState.accounts.length > 0) {
|
|
9088
9097
|
const first = walletState.accounts[0];
|