@d13co/use-wallet 4.5.8 → 4.5.10
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 +15 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -18
- package/dist/index.d.ts +5 -18
- package/dist/index.js +15 -64
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -8657,39 +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 rawChainId = await provider.request({ method: "eth_chainId" });
|
|
8668
|
-
const currentChainId = typeof rawChainId === "number" ? "0x" + rawChainId.toString(16) : String(rawChainId);
|
|
8669
|
-
if (currentChainId.toLowerCase() === ALGORAND_CHAIN_ID_HEX.toLowerCase()) {
|
|
8670
|
-
return;
|
|
8671
|
-
}
|
|
8672
|
-
this.logger.info(
|
|
8673
|
-
`Wrong chain (${currentChainId}), switching to Algorand (${ALGORAND_CHAIN_ID_HEX})...`
|
|
8674
|
-
);
|
|
8675
|
-
try {
|
|
8676
|
-
await provider.request({
|
|
8677
|
-
method: "wallet_switchEthereumChain",
|
|
8678
|
-
params: [{ chainId: ALGORAND_CHAIN_ID_HEX }]
|
|
8679
|
-
});
|
|
8680
|
-
} catch (switchError) {
|
|
8681
|
-
const chainUnknown = [4902, -32600, -32603].includes(switchError.code);
|
|
8682
|
-
if (chainUnknown) {
|
|
8683
|
-
this.logger.info("Algorand chain not found, adding it...");
|
|
8684
|
-
await provider.request({
|
|
8685
|
-
method: "wallet_addEthereumChain",
|
|
8686
|
-
params: [ALGORAND_EVM_CHAIN_CONFIG]
|
|
8687
|
-
});
|
|
8688
|
-
} else {
|
|
8689
|
-
throw switchError;
|
|
8690
|
-
}
|
|
8691
|
-
}
|
|
8692
|
-
}
|
|
8693
8660
|
/**
|
|
8694
8661
|
* Initialize the Liquid EVM SDK for deriving Algorand addresses
|
|
8695
8662
|
*/
|
|
@@ -8805,7 +8772,6 @@ var LiquidEvmBaseWallet = class extends BaseWallet {
|
|
|
8805
8772
|
const txnsAsUint8 = txnsToSign.map(({ txn }) => import_algosdk11.default.encodeUnsignedTransaction(txn));
|
|
8806
8773
|
await onBeforeSign(txnsAsUint8, indexesToSign);
|
|
8807
8774
|
}
|
|
8808
|
-
await this.ensureAlgorandChain();
|
|
8809
8775
|
const { signer: evmSigner } = await liquidEvmSdk.getSigner({
|
|
8810
8776
|
evmAddress,
|
|
8811
8777
|
signMessage: (typedData) => this.signWithProvider(typedData, evmAddress)
|
|
@@ -8879,7 +8845,6 @@ var LiquidEvmBaseWallet = class extends BaseWallet {
|
|
|
8879
8845
|
};
|
|
8880
8846
|
|
|
8881
8847
|
// src/wallets/rainbowkit.ts
|
|
8882
|
-
var import_liquid_accounts_evm = require("liquid-accounts-evm");
|
|
8883
8848
|
var ICON13 = `data:image/svg+xml;base64,${btoa(`
|
|
8884
8849
|
<svg width="120" height="120" viewBox="0 0 120 120" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
8885
8850
|
<rect width="120" height="120" rx="24" fill="#627EEA"/>
|
|
@@ -8907,7 +8872,6 @@ var RainbowKitWallet = class _RainbowKitWallet extends LiquidEvmBaseWallet {
|
|
|
8907
8872
|
if (!this.options.wagmiConfig) {
|
|
8908
8873
|
throw new Error("RainbowKitWallet requires wagmiConfig in options");
|
|
8909
8874
|
}
|
|
8910
|
-
this.ensureChainRegistered();
|
|
8911
8875
|
}
|
|
8912
8876
|
static defaultMetadata = {
|
|
8913
8877
|
name: "EVM Wallet",
|
|
@@ -8933,25 +8897,11 @@ var RainbowKitWallet = class _RainbowKitWallet extends LiquidEvmBaseWallet {
|
|
|
8933
8897
|
get wagmiConfig() {
|
|
8934
8898
|
return this.options.wagmiConfig;
|
|
8935
8899
|
}
|
|
8936
|
-
/**
|
|
8937
|
-
* If the Algorand chain (4160) isn't already in the wagmi config, add it.
|
|
8938
|
-
* This is needed so wagmi's switchChain and signTypedData work without
|
|
8939
|
-
* falling back to raw provider calls.
|
|
8940
|
-
*/
|
|
8941
|
-
ensureChainRegistered() {
|
|
8942
|
-
const chains = this.wagmiConfig.chains;
|
|
8943
|
-
if (chains.some((c) => c.id === import_liquid_accounts_evm.ALGORAND_CHAIN_ID)) {
|
|
8944
|
-
return;
|
|
8945
|
-
}
|
|
8946
|
-
this.logger.info(`Registering Algorand chain (${import_liquid_accounts_evm.ALGORAND_CHAIN_ID}) in wagmi config`);
|
|
8947
|
-
chains.push(import_liquid_accounts_evm.algorandChain);
|
|
8948
|
-
}
|
|
8949
8900
|
async initializeProvider() {
|
|
8950
8901
|
this.logger.info("Using wagmi for EVM provider management");
|
|
8951
8902
|
}
|
|
8952
8903
|
/**
|
|
8953
8904
|
* Get the raw EIP-1193 provider from the active wagmi connector.
|
|
8954
|
-
* Used by the base class's getEvmProvider and ensureAlgorandChain.
|
|
8955
8905
|
*/
|
|
8956
8906
|
async getRawProvider() {
|
|
8957
8907
|
const { getAccount } = await import("@wagmi/core");
|
|
@@ -8963,24 +8913,28 @@ var RainbowKitWallet = class _RainbowKitWallet extends LiquidEvmBaseWallet {
|
|
|
8963
8913
|
return this.getRawProvider();
|
|
8964
8914
|
}
|
|
8965
8915
|
/**
|
|
8966
|
-
* Sign EIP-712 typed data
|
|
8916
|
+
* Sign EIP-712 typed data via the raw EIP-1193 provider.
|
|
8967
8917
|
*
|
|
8968
|
-
* wagmi's signTypedData
|
|
8969
|
-
*
|
|
8970
|
-
* EIP-712
|
|
8971
|
-
*
|
|
8972
|
-
* reports being on.
|
|
8918
|
+
* Bypasses wagmi's signTypedData (which requires the wallet's current chain
|
|
8919
|
+
* to be in the wagmi config) and calls eth_signTypedData_v4 directly.
|
|
8920
|
+
* Since the EIP-712 domain has no chainId, signing is truly chain-agnostic
|
|
8921
|
+
* and works regardless of which chain the wallet is on.
|
|
8973
8922
|
*/
|
|
8974
8923
|
async signWithProvider(typedData, evmAddress) {
|
|
8975
|
-
const
|
|
8976
|
-
const
|
|
8977
|
-
|
|
8978
|
-
account: evmAddress,
|
|
8924
|
+
const provider = await this.getRawProvider();
|
|
8925
|
+
const data = JSON.stringify({
|
|
8926
|
+
types: typedData.types,
|
|
8979
8927
|
domain: typedData.domain,
|
|
8980
|
-
types,
|
|
8981
8928
|
primaryType: typedData.primaryType,
|
|
8982
8929
|
message: typedData.message
|
|
8983
8930
|
});
|
|
8931
|
+
this.logger.info("Requesting eth_signTypedData_v4", { evmAddress, domain: typedData.domain, primaryType: typedData.primaryType });
|
|
8932
|
+
const signature = await provider.request({
|
|
8933
|
+
method: "eth_signTypedData_v4",
|
|
8934
|
+
params: [evmAddress, data]
|
|
8935
|
+
});
|
|
8936
|
+
this.logger.info("Received signature", { signature: signature?.slice(0, 20) + "..." });
|
|
8937
|
+
return signature;
|
|
8984
8938
|
}
|
|
8985
8939
|
/**
|
|
8986
8940
|
* Build a connectorInfo object from a wagmi account, omitting undefined fields.
|