@d13co/use-wallet 4.5.7 → 4.5.9
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 +2 -54
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -17
- package/dist/index.d.ts +2 -17
- package/dist/index.js +2 -57
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8657,38 +8657,6 @@ var LiquidEvmBaseWallet = class extends BaseWallet {
|
|
|
8657
8657
|
* Subclasses MUST override this with their own metadata including isLiquid: "EVM"
|
|
8658
8658
|
*/
|
|
8659
8659
|
static defaultMetadata;
|
|
8660
|
-
/**
|
|
8661
|
-
* Ensure the wallet is on the Algorand chain (4160).
|
|
8662
|
-
* Queries the current chain first, and only switches/adds if needed.
|
|
8663
|
-
*/
|
|
8664
|
-
async ensureAlgorandChain() {
|
|
8665
|
-
const provider = await this.getEvmProvider();
|
|
8666
|
-
const { ALGORAND_CHAIN_ID_HEX, ALGORAND_EVM_CHAIN_CONFIG } = await import("liquid-accounts-evm");
|
|
8667
|
-
const currentChainId = await provider.request({ method: "eth_chainId" });
|
|
8668
|
-
if (currentChainId.toLowerCase() === ALGORAND_CHAIN_ID_HEX.toLowerCase()) {
|
|
8669
|
-
return;
|
|
8670
|
-
}
|
|
8671
|
-
this.logger.info(
|
|
8672
|
-
`Wrong chain (${currentChainId}), switching to Algorand (${ALGORAND_CHAIN_ID_HEX})...`
|
|
8673
|
-
);
|
|
8674
|
-
try {
|
|
8675
|
-
await provider.request({
|
|
8676
|
-
method: "wallet_switchEthereumChain",
|
|
8677
|
-
params: [{ chainId: ALGORAND_CHAIN_ID_HEX }]
|
|
8678
|
-
});
|
|
8679
|
-
} catch (switchError) {
|
|
8680
|
-
const chainUnknown = [4902, -32600, -32603].includes(switchError.code);
|
|
8681
|
-
if (chainUnknown) {
|
|
8682
|
-
this.logger.info("Algorand chain not found, adding it...");
|
|
8683
|
-
await provider.request({
|
|
8684
|
-
method: "wallet_addEthereumChain",
|
|
8685
|
-
params: [ALGORAND_EVM_CHAIN_CONFIG]
|
|
8686
|
-
});
|
|
8687
|
-
} else {
|
|
8688
|
-
throw switchError;
|
|
8689
|
-
}
|
|
8690
|
-
}
|
|
8691
|
-
}
|
|
8692
8660
|
/**
|
|
8693
8661
|
* Initialize the Liquid EVM SDK for deriving Algorand addresses
|
|
8694
8662
|
*/
|
|
@@ -8804,7 +8772,6 @@ var LiquidEvmBaseWallet = class extends BaseWallet {
|
|
|
8804
8772
|
const txnsAsUint8 = txnsToSign.map(({ txn }) => import_algosdk11.default.encodeUnsignedTransaction(txn));
|
|
8805
8773
|
await onBeforeSign(txnsAsUint8, indexesToSign);
|
|
8806
8774
|
}
|
|
8807
|
-
await this.ensureAlgorandChain();
|
|
8808
8775
|
const { signer: evmSigner } = await liquidEvmSdk.getSigner({
|
|
8809
8776
|
evmAddress,
|
|
8810
8777
|
signMessage: (typedData) => this.signWithProvider(typedData, evmAddress)
|
|
@@ -8878,7 +8845,6 @@ var LiquidEvmBaseWallet = class extends BaseWallet {
|
|
|
8878
8845
|
};
|
|
8879
8846
|
|
|
8880
8847
|
// src/wallets/rainbowkit.ts
|
|
8881
|
-
var import_liquid_accounts_evm = require("liquid-accounts-evm");
|
|
8882
8848
|
var ICON13 = `data:image/svg+xml;base64,${btoa(`
|
|
8883
8849
|
<svg width="120" height="120" viewBox="0 0 120 120" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
8884
8850
|
<rect width="120" height="120" rx="24" fill="#627EEA"/>
|
|
@@ -8906,7 +8872,6 @@ var RainbowKitWallet = class _RainbowKitWallet extends LiquidEvmBaseWallet {
|
|
|
8906
8872
|
if (!this.options.wagmiConfig) {
|
|
8907
8873
|
throw new Error("RainbowKitWallet requires wagmiConfig in options");
|
|
8908
8874
|
}
|
|
8909
|
-
this.ensureChainRegistered();
|
|
8910
8875
|
}
|
|
8911
8876
|
static defaultMetadata = {
|
|
8912
8877
|
name: "EVM Wallet",
|
|
@@ -8932,25 +8897,11 @@ var RainbowKitWallet = class _RainbowKitWallet extends LiquidEvmBaseWallet {
|
|
|
8932
8897
|
get wagmiConfig() {
|
|
8933
8898
|
return this.options.wagmiConfig;
|
|
8934
8899
|
}
|
|
8935
|
-
/**
|
|
8936
|
-
* If the Algorand chain (4160) isn't already in the wagmi config, add it.
|
|
8937
|
-
* This is needed so wagmi's switchChain and signTypedData work without
|
|
8938
|
-
* falling back to raw provider calls.
|
|
8939
|
-
*/
|
|
8940
|
-
ensureChainRegistered() {
|
|
8941
|
-
const chains = this.wagmiConfig.chains;
|
|
8942
|
-
if (chains.some((c) => c.id === import_liquid_accounts_evm.ALGORAND_CHAIN_ID)) {
|
|
8943
|
-
return;
|
|
8944
|
-
}
|
|
8945
|
-
this.logger.info(`Registering Algorand chain (${import_liquid_accounts_evm.ALGORAND_CHAIN_ID}) in wagmi config`);
|
|
8946
|
-
chains.push(import_liquid_accounts_evm.algorandChain);
|
|
8947
|
-
}
|
|
8948
8900
|
async initializeProvider() {
|
|
8949
8901
|
this.logger.info("Using wagmi for EVM provider management");
|
|
8950
8902
|
}
|
|
8951
8903
|
/**
|
|
8952
8904
|
* Get the raw EIP-1193 provider from the active wagmi connector.
|
|
8953
|
-
* Used by the base class's getEvmProvider and ensureAlgorandChain.
|
|
8954
8905
|
*/
|
|
8955
8906
|
async getRawProvider() {
|
|
8956
8907
|
const { getAccount } = await import("@wagmi/core");
|
|
@@ -8964,11 +8915,8 @@ var RainbowKitWallet = class _RainbowKitWallet extends LiquidEvmBaseWallet {
|
|
|
8964
8915
|
/**
|
|
8965
8916
|
* Sign EIP-712 typed data using wagmi's signTypedData.
|
|
8966
8917
|
*
|
|
8967
|
-
*
|
|
8968
|
-
*
|
|
8969
|
-
* EIP-712 signing is chain-agnostic (the chain ID is in the typed data domain,
|
|
8970
|
-
* not in the RPC method), so this works regardless of which chain the wallet
|
|
8971
|
-
* reports being on.
|
|
8918
|
+
* The EIP-712 domain uses only (name, version) with no chainId, so signing
|
|
8919
|
+
* works regardless of which chain the wallet reports being on.
|
|
8972
8920
|
*/
|
|
8973
8921
|
async signWithProvider(typedData, evmAddress) {
|
|
8974
8922
|
const { signTypedData } = await import("@wagmi/core");
|