@d13co/use-wallet 4.5.5 → 4.5.6
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 +29 -30
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -5
- package/dist/index.d.ts +2 -5
- package/dist/index.js +29 -30
- 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
|
*/
|
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
|
*/
|
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
|
});
|