@d13co/use-wallet 4.5.13 → 4.5.14
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 +54 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -6
- package/dist/index.d.ts +4 -6
- package/dist/index.js +54 -50
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -619,12 +619,10 @@ declare class RainbowKitWallet extends AlgoXEvmBaseWallet {
|
|
|
619
619
|
private static extractConnectorInfo;
|
|
620
620
|
/**
|
|
621
621
|
* Read connected EVM accounts from wagmi state.
|
|
622
|
-
* If
|
|
623
|
-
*
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
* selection UI). The callback is responsible for any disconnect/reconnect
|
|
627
|
-
* needed to present a fresh selection.
|
|
622
|
+
* If already connected (e.g. auto-reconnect on page refresh), uses the
|
|
623
|
+
* existing connection directly. Otherwise tries the getEvmAccounts
|
|
624
|
+
* callback (wallet picker UI), then falls back to connecting with the
|
|
625
|
+
* first available connector.
|
|
628
626
|
*/
|
|
629
627
|
private getConnectedEvmAddresses;
|
|
630
628
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -619,12 +619,10 @@ declare class RainbowKitWallet extends AlgoXEvmBaseWallet {
|
|
|
619
619
|
private static extractConnectorInfo;
|
|
620
620
|
/**
|
|
621
621
|
* Read connected EVM accounts from wagmi state.
|
|
622
|
-
* If
|
|
623
|
-
*
|
|
624
|
-
*
|
|
625
|
-
*
|
|
626
|
-
* selection UI). The callback is responsible for any disconnect/reconnect
|
|
627
|
-
* needed to present a fresh selection.
|
|
622
|
+
* If already connected (e.g. auto-reconnect on page refresh), uses the
|
|
623
|
+
* existing connection directly. Otherwise tries the getEvmAccounts
|
|
624
|
+
* callback (wallet picker UI), then falls back to connecting with the
|
|
625
|
+
* first available connector.
|
|
628
626
|
*/
|
|
629
627
|
private getConnectedEvmAddresses;
|
|
630
628
|
/**
|
package/dist/index.js
CHANGED
|
@@ -8703,23 +8703,33 @@ var AlgoXEvmBaseWallet = class extends BaseWallet {
|
|
|
8703
8703
|
const flatTxns = flattenTxnGroup(txnGroup);
|
|
8704
8704
|
txnsToSign = this.processEncodedTxns(flatTxns, indexesToSign);
|
|
8705
8705
|
}
|
|
8706
|
-
const
|
|
8707
|
-
|
|
8708
|
-
|
|
8709
|
-
|
|
8710
|
-
|
|
8711
|
-
|
|
8712
|
-
for (const account of walletState.accounts) {
|
|
8713
|
-
const addr = account.metadata?.evmAddress;
|
|
8714
|
-
if (addr) {
|
|
8715
|
-
this.evmAddressMap.set(account.address, addr);
|
|
8716
|
-
}
|
|
8706
|
+
const walletState = this.store.state.wallets[this.id];
|
|
8707
|
+
if (walletState) {
|
|
8708
|
+
for (const account of walletState.accounts) {
|
|
8709
|
+
const addr = account.metadata?.evmAddress;
|
|
8710
|
+
if (addr && !this.evmAddressMap.has(account.address)) {
|
|
8711
|
+
this.evmAddressMap.set(account.address, addr);
|
|
8717
8712
|
}
|
|
8718
|
-
evmAddress = this.evmAddressMap.get(algorandAddress);
|
|
8719
8713
|
}
|
|
8720
8714
|
}
|
|
8721
|
-
|
|
8722
|
-
|
|
8715
|
+
const allTxns = txnsToSign.map((t) => t.txn);
|
|
8716
|
+
const signIndexes = txnsToSign.reduce((acc, t, i) => {
|
|
8717
|
+
if (!("signers" in t)) acc.push(i);
|
|
8718
|
+
return acc;
|
|
8719
|
+
}, []);
|
|
8720
|
+
const evmGroups = /* @__PURE__ */ new Map();
|
|
8721
|
+
for (const idx of signIndexes) {
|
|
8722
|
+
const algorandAddress = allTxns[idx].sender.toString();
|
|
8723
|
+
const evmAddress = this.evmAddressMap.get(algorandAddress);
|
|
8724
|
+
if (!evmAddress) {
|
|
8725
|
+
throw new Error(`No EVM address found for Algorand address: ${algorandAddress}`);
|
|
8726
|
+
}
|
|
8727
|
+
const group = evmGroups.get(evmAddress);
|
|
8728
|
+
if (group) {
|
|
8729
|
+
group.push(idx);
|
|
8730
|
+
} else {
|
|
8731
|
+
evmGroups.set(evmAddress, [idx]);
|
|
8732
|
+
}
|
|
8723
8733
|
}
|
|
8724
8734
|
const onBeforeSign = this.options.uiHooks?.onBeforeSign ?? this.managerUIHooks?.onBeforeSign;
|
|
8725
8735
|
if (onBeforeSign) {
|
|
@@ -8727,16 +8737,18 @@ var AlgoXEvmBaseWallet = class extends BaseWallet {
|
|
|
8727
8737
|
const txnsAsUint8 = txnsToSign.map(({ txn }) => algosdk11.encodeUnsignedTransaction(txn));
|
|
8728
8738
|
await onBeforeSign(txnsAsUint8, indexesToSign);
|
|
8729
8739
|
}
|
|
8730
|
-
const
|
|
8731
|
-
|
|
8732
|
-
|
|
8733
|
-
|
|
8734
|
-
|
|
8735
|
-
|
|
8736
|
-
|
|
8737
|
-
|
|
8738
|
-
|
|
8739
|
-
|
|
8740
|
+
const signedResult = new Array(txnsToSign.length).fill(null);
|
|
8741
|
+
console.log("EVM Groups for signing:", evmGroups);
|
|
8742
|
+
for (const [evmAddress, indexes] of evmGroups) {
|
|
8743
|
+
const { signer: evmSigner } = await algoXEvmSdk.getSigner({
|
|
8744
|
+
evmAddress,
|
|
8745
|
+
signMessage: (typedData) => this.signWithProvider(typedData, evmAddress)
|
|
8746
|
+
});
|
|
8747
|
+
const signedBlobs = await evmSigner(allTxns, indexes);
|
|
8748
|
+
for (let i = 0; i < indexes.length; i++) {
|
|
8749
|
+
signedResult[indexes[i]] = signedBlobs[i];
|
|
8750
|
+
}
|
|
8751
|
+
}
|
|
8740
8752
|
const onAfterSign = this.options.uiHooks?.onAfterSign ?? this.managerUIHooks?.onAfterSign;
|
|
8741
8753
|
if (onAfterSign) {
|
|
8742
8754
|
this.logger.debug("Running onAfterSign hook");
|
|
@@ -8745,15 +8757,8 @@ var AlgoXEvmBaseWallet = class extends BaseWallet {
|
|
|
8745
8757
|
} catch (e) {
|
|
8746
8758
|
}
|
|
8747
8759
|
}
|
|
8748
|
-
|
|
8749
|
-
|
|
8750
|
-
if (signIndexes.includes(index)) {
|
|
8751
|
-
return signedBlobs[signedIdx++];
|
|
8752
|
-
}
|
|
8753
|
-
return null;
|
|
8754
|
-
});
|
|
8755
|
-
this.logger.debug("Transactions signed successfully", result);
|
|
8756
|
-
return result;
|
|
8760
|
+
this.logger.debug("Transactions signed successfully", signedResult);
|
|
8761
|
+
return signedResult;
|
|
8757
8762
|
} catch (error) {
|
|
8758
8763
|
try {
|
|
8759
8764
|
const onAfterSignCleanup = this.options.uiHooks?.onAfterSign ?? this.managerUIHooks?.onAfterSign;
|
|
@@ -8906,36 +8911,35 @@ var RainbowKitWallet = class _RainbowKitWallet extends AlgoXEvmBaseWallet {
|
|
|
8906
8911
|
}
|
|
8907
8912
|
/**
|
|
8908
8913
|
* Read connected EVM accounts from wagmi state.
|
|
8909
|
-
* If
|
|
8910
|
-
*
|
|
8911
|
-
*
|
|
8912
|
-
*
|
|
8913
|
-
* selection UI). The callback is responsible for any disconnect/reconnect
|
|
8914
|
-
* needed to present a fresh selection.
|
|
8914
|
+
* If already connected (e.g. auto-reconnect on page refresh), uses the
|
|
8915
|
+
* existing connection directly. Otherwise tries the getEvmAccounts
|
|
8916
|
+
* callback (wallet picker UI), then falls back to connecting with the
|
|
8917
|
+
* first available connector.
|
|
8915
8918
|
*/
|
|
8916
8919
|
async getConnectedEvmAddresses() {
|
|
8917
8920
|
const { getAccount, connect: wagmiConnect } = await import("@wagmi/core");
|
|
8921
|
+
const existing = getAccount(this.wagmiConfig);
|
|
8922
|
+
if (existing.isConnected && existing.address) {
|
|
8923
|
+
this.logger.info("Using existing wagmi connection");
|
|
8924
|
+
return {
|
|
8925
|
+
addresses: existing.addresses ? [...existing.addresses] : [existing.address],
|
|
8926
|
+
connectorInfo: _RainbowKitWallet.extractConnectorInfo(existing)
|
|
8927
|
+
};
|
|
8928
|
+
}
|
|
8918
8929
|
if (this.options.getEvmAccounts) {
|
|
8919
8930
|
const addresses = await this.options.getEvmAccounts();
|
|
8920
8931
|
if (addresses.length > 0) {
|
|
8921
|
-
const
|
|
8922
|
-
const connectorInfo = _RainbowKitWallet.extractConnectorInfo(
|
|
8923
|
-
if (
|
|
8932
|
+
const account = getAccount(this.wagmiConfig);
|
|
8933
|
+
const connectorInfo = _RainbowKitWallet.extractConnectorInfo(account);
|
|
8934
|
+
if (account.isConnected && account.address) {
|
|
8924
8935
|
return {
|
|
8925
|
-
addresses:
|
|
8936
|
+
addresses: account.addresses ? [...account.addresses] : [account.address],
|
|
8926
8937
|
connectorInfo
|
|
8927
8938
|
};
|
|
8928
8939
|
}
|
|
8929
8940
|
return { addresses, connectorInfo };
|
|
8930
8941
|
}
|
|
8931
8942
|
}
|
|
8932
|
-
const account = getAccount(this.wagmiConfig);
|
|
8933
|
-
if (account.isConnected && account.address) {
|
|
8934
|
-
return {
|
|
8935
|
-
addresses: account.addresses ? [...account.addresses] : [account.address],
|
|
8936
|
-
connectorInfo: _RainbowKitWallet.extractConnectorInfo(account)
|
|
8937
|
-
};
|
|
8938
|
-
}
|
|
8939
8943
|
const connectors = this.wagmiConfig.connectors;
|
|
8940
8944
|
if (connectors.length > 0) {
|
|
8941
8945
|
this.logger.info("Attempting connection with first available connector...");
|