graz 0.1.5 → 0.1.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.d.mts +31 -24
- package/dist/index.d.ts +31 -24
- package/dist/index.js +72 -70
- package/dist/index.mjs +3 -3
- package/package.json +6 -4
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/// <reference types="../types/global" />
|
|
2
2
|
import { OfflineDirectSigner, Coin } from '@cosmjs/proto-signing';
|
|
3
|
-
import { Keplr, Key, ChainInfo, OfflineAminoSigner, AppCurrency } from '@keplr-wallet/types';
|
|
3
|
+
import { Keplr, KeplrIntereactionOptions, Key, ChainInfo, OfflineAminoSigner, AppCurrency } from '@keplr-wallet/types';
|
|
4
4
|
import { SignClientTypes } from '@walletconnect/types';
|
|
5
5
|
import { Web3ModalConfig } from '@web3modal/standalone';
|
|
6
6
|
import * as _cosmjs_cosmwasm_stargate from '@cosmjs/cosmwasm-stargate';
|
|
7
7
|
import { SigningCosmWasmClient, InstantiateOptions, CosmWasmClient, InstantiateResult, ExecuteResult, SigningCosmWasmClientOptions } from '@cosmjs/cosmwasm-stargate';
|
|
8
8
|
import { SigningStargateClient, StdFee, DeliverTxResponse, QueryClient, StakingExtension, StargateClient, SigningStargateClientOptions } from '@cosmjs/stargate';
|
|
9
9
|
import { Height } from 'cosmjs-types/ibc/core/client/v1/client';
|
|
10
|
-
import { OfflineSigner } from '@cosmjs/launchpad';
|
|
11
10
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
12
11
|
import { UseQueryResult, QueryClientProviderProps } from '@tanstack/react-query';
|
|
12
|
+
import * as _leapwallet_cosmos_social_login_capsule_provider from '@leapwallet/cosmos-social-login-capsule-provider';
|
|
13
13
|
import { BondStatusString } from '@cosmjs/stargate/build/modules/staking/queries';
|
|
14
14
|
import { QueryValidatorsResponse } from 'cosmjs-types/cosmos/staking/v1beta1/query';
|
|
15
15
|
import { Tendermint34Client, Tendermint37Client } from '@cosmjs/tendermint-rpc';
|
|
@@ -29,7 +29,8 @@ declare enum WalletType {
|
|
|
29
29
|
WC_COSMOSTATION_MOBILE = "wc_cosmostation_mobile",
|
|
30
30
|
METAMASK_SNAP_LEAP = "metamask_snap_leap",
|
|
31
31
|
STATION = "station",
|
|
32
|
-
XDEFI = "xdefi"
|
|
32
|
+
XDEFI = "xdefi",
|
|
33
|
+
CAPSULE = "capsule"
|
|
33
34
|
}
|
|
34
35
|
declare const WALLET_TYPES: WalletType[];
|
|
35
36
|
type Wallet = Pick<Keplr, "enable" | "getKey" | "getOfflineSigner" | "getOfflineSignerAuto" | "getOfflineSignerOnlyAmino" | "experimentalSuggestChain" | "signDirect" | "signAmino"> & {
|
|
@@ -37,6 +38,8 @@ type Wallet = Pick<Keplr, "enable" | "getKey" | "getOfflineSigner" | "getOffline
|
|
|
37
38
|
subscription?: (reconnect: () => void) => () => void;
|
|
38
39
|
init?: () => Promise<unknown>;
|
|
39
40
|
disable?: (chainIds?: string | undefined) => Promise<void>;
|
|
41
|
+
setDefaultOptions?: (options: KeplrIntereactionOptions) => void;
|
|
42
|
+
onAfterLoginSuccessful?: () => Promise<void>;
|
|
40
43
|
};
|
|
41
44
|
type SignDirectParams = Parameters<Wallet["signDirect"]>;
|
|
42
45
|
type SignAminoParams = Parameters<Wallet["signAmino"]>;
|
|
@@ -108,8 +111,18 @@ interface WalletConnectStore {
|
|
|
108
111
|
options: SignClientTypes.Options | null;
|
|
109
112
|
web3Modal?: Pick<Web3ModalConfig, "themeVariables" | "themeMode" | "privacyPolicyUrl" | "termsOfServiceUrl"> | null;
|
|
110
113
|
}
|
|
114
|
+
interface CapsuleConfig {
|
|
115
|
+
apiKey?: string;
|
|
116
|
+
env?: "DEV" | "SANDBOX" | "BETA" | "PROD";
|
|
117
|
+
}
|
|
118
|
+
interface CapsuleState {
|
|
119
|
+
showModal: boolean;
|
|
120
|
+
chainId?: string[];
|
|
121
|
+
}
|
|
111
122
|
interface GrazInternalStore {
|
|
112
123
|
recentChainIds: string[] | null;
|
|
124
|
+
capsuleConfig: CapsuleConfig | null;
|
|
125
|
+
capsuleState: CapsuleState | null;
|
|
113
126
|
chains: ChainInfo[] | null;
|
|
114
127
|
chainsConfig: Record<string, ChainConfig> | null;
|
|
115
128
|
/**
|
|
@@ -119,6 +132,7 @@ interface GrazInternalStore {
|
|
|
119
132
|
multiChainFetchConcurrency: number;
|
|
120
133
|
walletType: WalletType;
|
|
121
134
|
walletConnect: WalletConnectStore | null;
|
|
135
|
+
walletDefaultOptions: Keplr["defaultOptions"] | null;
|
|
122
136
|
_notFoundFn: () => void;
|
|
123
137
|
_reconnect: boolean;
|
|
124
138
|
_reconnectConnector: WalletType | null;
|
|
@@ -129,9 +143,11 @@ interface ConfigureGrazArgs {
|
|
|
129
143
|
defaultWallet?: WalletType;
|
|
130
144
|
chains: ChainInfo[];
|
|
131
145
|
chainsConfig?: Record<string, ChainConfig>;
|
|
146
|
+
capsuleConfig?: CapsuleConfig;
|
|
132
147
|
onNotFound?: () => void;
|
|
133
148
|
onReconnectFailed?: () => void;
|
|
134
149
|
walletConnect?: GrazInternalStore["walletConnect"];
|
|
150
|
+
walletDefaultOptions?: GrazInternalStore["walletDefaultOptions"];
|
|
135
151
|
/**
|
|
136
152
|
* default to true
|
|
137
153
|
*/
|
|
@@ -222,6 +238,7 @@ declare const clearSession: () => void;
|
|
|
222
238
|
*/
|
|
223
239
|
declare const getWallet: (type?: WalletType) => Wallet;
|
|
224
240
|
declare const getAvailableWallets: () => Record<WalletType, boolean>;
|
|
241
|
+
declare const isCapsule: (type: WalletType) => boolean;
|
|
225
242
|
declare const isWalletConnect: (type: WalletType) => boolean;
|
|
226
243
|
|
|
227
244
|
/**
|
|
@@ -324,25 +341,6 @@ declare const getWCKeplr: () => Wallet;
|
|
|
324
341
|
|
|
325
342
|
declare const getWCLeap: () => Wallet;
|
|
326
343
|
|
|
327
|
-
interface AccountData {
|
|
328
|
-
address: Uint8Array;
|
|
329
|
-
bech32Address: string;
|
|
330
|
-
pubKey: Uint8Array;
|
|
331
|
-
algo: string;
|
|
332
|
-
}
|
|
333
|
-
interface Connector {
|
|
334
|
-
checkConnector: () => boolean;
|
|
335
|
-
getAccount: (chainId: string, prefix?: string) => Promise<AccountData>;
|
|
336
|
-
getOfflineSigner: (chainId: string) => OfflineSigner & OfflineDirectSigner;
|
|
337
|
-
getOfflineSignerOnlyAmino: (chainId: string) => OfflineSigner;
|
|
338
|
-
getOfflineSignerAuto: (chainId: string) => Promise<OfflineSigner | OfflineDirectSigner>;
|
|
339
|
-
}
|
|
340
|
-
interface GrazAdapter extends Connector {
|
|
341
|
-
name: string;
|
|
342
|
-
id: string;
|
|
343
|
-
keystoreEvent: string;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
344
|
/**
|
|
347
345
|
* Helper function to define chain information records (key values).
|
|
348
346
|
*
|
|
@@ -477,7 +475,7 @@ declare const useBalances: <TMulti extends MultiChainHookArgs>(args?: ({
|
|
|
477
475
|
* ```
|
|
478
476
|
*/
|
|
479
477
|
declare const useBalance: <TMulti extends MultiChainHookArgs>(args: {
|
|
480
|
-
denom
|
|
478
|
+
denom?: string;
|
|
481
479
|
bech32Address?: string;
|
|
482
480
|
} & {
|
|
483
481
|
chainId: ChainId$1;
|
|
@@ -605,6 +603,14 @@ declare const useBalanceStaked: <TMulti extends MultiChainHookArgs>(args?: ({
|
|
|
605
603
|
bech32Address?: string | undefined;
|
|
606
604
|
} & TMulti) | undefined) => UseMultiChainQueryResult<TMulti, Coin>;
|
|
607
605
|
|
|
606
|
+
declare const useCapsule: () => {
|
|
607
|
+
setModalState: (state: boolean) => void;
|
|
608
|
+
modalState: boolean;
|
|
609
|
+
client: _leapwallet_cosmos_social_login_capsule_provider.CapsuleProvider | null;
|
|
610
|
+
onAfterLoginSuccessful: (() => Promise<void>) | undefined;
|
|
611
|
+
onLoginFailure: () => void;
|
|
612
|
+
};
|
|
613
|
+
|
|
608
614
|
/**
|
|
609
615
|
* graz hook to retrieve connected account's active chainIds
|
|
610
616
|
*
|
|
@@ -1050,6 +1056,7 @@ declare const useActiveWalletType: () => {
|
|
|
1050
1056
|
isWalletConnect: boolean;
|
|
1051
1057
|
isMetamaskSnapLeap: boolean;
|
|
1052
1058
|
isStation: boolean;
|
|
1059
|
+
isCapsule: boolean;
|
|
1053
1060
|
};
|
|
1054
1061
|
/**
|
|
1055
1062
|
* graz query hook to check whether given {@link WalletType} or default configured wallet is supported
|
|
@@ -1100,4 +1107,4 @@ declare const useGrazEvents: () => null;
|
|
|
1100
1107
|
*/
|
|
1101
1108
|
declare const GrazEvents: FC;
|
|
1102
1109
|
|
|
1103
|
-
export {
|
|
1110
|
+
export { ConfigureGrazArgs, ConnectArgs, ConnectResult, Dictionary, ExecuteContractArgs, ExecuteContractMutationArgs, GrazEvents, GrazProvider, GrazProviderProps, InstantiateContractArgs, InstantiateContractMutationArgs, Maybe, OfflineSigners, ReconnectArgs, SendIbcTokensArgs, SendTokensArgs, SignAminoParams, SignDirectParams, SuggestChainAndConnectArgs, SuggestChainArgs, UseAccountArgs, UseAccountResult, UseConnectChainArgs, UseExecuteContractArgs, UseInstantiateContractArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WALLET_TYPES, Wallet, WalletType, checkWallet, clearRecentChain, clearSession, configureGraz, connect, defineChainInfo, defineChains, disconnect, executeContract, getAvailableWallets, getChainInfo, getChainInfos, getCosmostation, getKeplr, getLeap, getMetamaskSnapLeap, getOfflineSigners, getQueryRaw, getQuerySmart, getRecentChainIds, getRecentChains, getVectis, getWCCosmostation, getWCKeplr, getWCLeap, getWallet, getWalletConnect, instantiateContract, isCapsule, isWalletConnect, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, useAccount, useActiveChainCurrency, useActiveChainIds, useActiveChains, useActiveWalletType, useBalance, useBalanceStaked, useBalances, useCapsule, useChainInfo, useChainInfos, useCheckWallet, useConnect, useCosmWasmClient, useCosmWasmSigningClient, useCosmWasmTmSigningClient, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryClientValidators, useQueryRaw, useQuerySmart, useRecentChainIds, useRecentChains, useSendIbcTokens, useSendTokens, useStargateClient, useStargateSigningClient, useStargateTmSigningClient, useSuggestChain, useSuggestChainAndConnect, useTendermintClient };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
/// <reference types="../types/global" />
|
|
2
2
|
import { OfflineDirectSigner, Coin } from '@cosmjs/proto-signing';
|
|
3
|
-
import { Keplr, Key, ChainInfo, OfflineAminoSigner, AppCurrency } from '@keplr-wallet/types';
|
|
3
|
+
import { Keplr, KeplrIntereactionOptions, Key, ChainInfo, OfflineAminoSigner, AppCurrency } from '@keplr-wallet/types';
|
|
4
4
|
import { SignClientTypes } from '@walletconnect/types';
|
|
5
5
|
import { Web3ModalConfig } from '@web3modal/standalone';
|
|
6
6
|
import * as _cosmjs_cosmwasm_stargate from '@cosmjs/cosmwasm-stargate';
|
|
7
7
|
import { SigningCosmWasmClient, InstantiateOptions, CosmWasmClient, InstantiateResult, ExecuteResult, SigningCosmWasmClientOptions } from '@cosmjs/cosmwasm-stargate';
|
|
8
8
|
import { SigningStargateClient, StdFee, DeliverTxResponse, QueryClient, StakingExtension, StargateClient, SigningStargateClientOptions } from '@cosmjs/stargate';
|
|
9
9
|
import { Height } from 'cosmjs-types/ibc/core/client/v1/client';
|
|
10
|
-
import { OfflineSigner } from '@cosmjs/launchpad';
|
|
11
10
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
12
11
|
import { UseQueryResult, QueryClientProviderProps } from '@tanstack/react-query';
|
|
12
|
+
import * as _leapwallet_cosmos_social_login_capsule_provider from '@leapwallet/cosmos-social-login-capsule-provider';
|
|
13
13
|
import { BondStatusString } from '@cosmjs/stargate/build/modules/staking/queries';
|
|
14
14
|
import { QueryValidatorsResponse } from 'cosmjs-types/cosmos/staking/v1beta1/query';
|
|
15
15
|
import { Tendermint34Client, Tendermint37Client } from '@cosmjs/tendermint-rpc';
|
|
@@ -29,7 +29,8 @@ declare enum WalletType {
|
|
|
29
29
|
WC_COSMOSTATION_MOBILE = "wc_cosmostation_mobile",
|
|
30
30
|
METAMASK_SNAP_LEAP = "metamask_snap_leap",
|
|
31
31
|
STATION = "station",
|
|
32
|
-
XDEFI = "xdefi"
|
|
32
|
+
XDEFI = "xdefi",
|
|
33
|
+
CAPSULE = "capsule"
|
|
33
34
|
}
|
|
34
35
|
declare const WALLET_TYPES: WalletType[];
|
|
35
36
|
type Wallet = Pick<Keplr, "enable" | "getKey" | "getOfflineSigner" | "getOfflineSignerAuto" | "getOfflineSignerOnlyAmino" | "experimentalSuggestChain" | "signDirect" | "signAmino"> & {
|
|
@@ -37,6 +38,8 @@ type Wallet = Pick<Keplr, "enable" | "getKey" | "getOfflineSigner" | "getOffline
|
|
|
37
38
|
subscription?: (reconnect: () => void) => () => void;
|
|
38
39
|
init?: () => Promise<unknown>;
|
|
39
40
|
disable?: (chainIds?: string | undefined) => Promise<void>;
|
|
41
|
+
setDefaultOptions?: (options: KeplrIntereactionOptions) => void;
|
|
42
|
+
onAfterLoginSuccessful?: () => Promise<void>;
|
|
40
43
|
};
|
|
41
44
|
type SignDirectParams = Parameters<Wallet["signDirect"]>;
|
|
42
45
|
type SignAminoParams = Parameters<Wallet["signAmino"]>;
|
|
@@ -108,8 +111,18 @@ interface WalletConnectStore {
|
|
|
108
111
|
options: SignClientTypes.Options | null;
|
|
109
112
|
web3Modal?: Pick<Web3ModalConfig, "themeVariables" | "themeMode" | "privacyPolicyUrl" | "termsOfServiceUrl"> | null;
|
|
110
113
|
}
|
|
114
|
+
interface CapsuleConfig {
|
|
115
|
+
apiKey?: string;
|
|
116
|
+
env?: "DEV" | "SANDBOX" | "BETA" | "PROD";
|
|
117
|
+
}
|
|
118
|
+
interface CapsuleState {
|
|
119
|
+
showModal: boolean;
|
|
120
|
+
chainId?: string[];
|
|
121
|
+
}
|
|
111
122
|
interface GrazInternalStore {
|
|
112
123
|
recentChainIds: string[] | null;
|
|
124
|
+
capsuleConfig: CapsuleConfig | null;
|
|
125
|
+
capsuleState: CapsuleState | null;
|
|
113
126
|
chains: ChainInfo[] | null;
|
|
114
127
|
chainsConfig: Record<string, ChainConfig> | null;
|
|
115
128
|
/**
|
|
@@ -119,6 +132,7 @@ interface GrazInternalStore {
|
|
|
119
132
|
multiChainFetchConcurrency: number;
|
|
120
133
|
walletType: WalletType;
|
|
121
134
|
walletConnect: WalletConnectStore | null;
|
|
135
|
+
walletDefaultOptions: Keplr["defaultOptions"] | null;
|
|
122
136
|
_notFoundFn: () => void;
|
|
123
137
|
_reconnect: boolean;
|
|
124
138
|
_reconnectConnector: WalletType | null;
|
|
@@ -129,9 +143,11 @@ interface ConfigureGrazArgs {
|
|
|
129
143
|
defaultWallet?: WalletType;
|
|
130
144
|
chains: ChainInfo[];
|
|
131
145
|
chainsConfig?: Record<string, ChainConfig>;
|
|
146
|
+
capsuleConfig?: CapsuleConfig;
|
|
132
147
|
onNotFound?: () => void;
|
|
133
148
|
onReconnectFailed?: () => void;
|
|
134
149
|
walletConnect?: GrazInternalStore["walletConnect"];
|
|
150
|
+
walletDefaultOptions?: GrazInternalStore["walletDefaultOptions"];
|
|
135
151
|
/**
|
|
136
152
|
* default to true
|
|
137
153
|
*/
|
|
@@ -222,6 +238,7 @@ declare const clearSession: () => void;
|
|
|
222
238
|
*/
|
|
223
239
|
declare const getWallet: (type?: WalletType) => Wallet;
|
|
224
240
|
declare const getAvailableWallets: () => Record<WalletType, boolean>;
|
|
241
|
+
declare const isCapsule: (type: WalletType) => boolean;
|
|
225
242
|
declare const isWalletConnect: (type: WalletType) => boolean;
|
|
226
243
|
|
|
227
244
|
/**
|
|
@@ -324,25 +341,6 @@ declare const getWCKeplr: () => Wallet;
|
|
|
324
341
|
|
|
325
342
|
declare const getWCLeap: () => Wallet;
|
|
326
343
|
|
|
327
|
-
interface AccountData {
|
|
328
|
-
address: Uint8Array;
|
|
329
|
-
bech32Address: string;
|
|
330
|
-
pubKey: Uint8Array;
|
|
331
|
-
algo: string;
|
|
332
|
-
}
|
|
333
|
-
interface Connector {
|
|
334
|
-
checkConnector: () => boolean;
|
|
335
|
-
getAccount: (chainId: string, prefix?: string) => Promise<AccountData>;
|
|
336
|
-
getOfflineSigner: (chainId: string) => OfflineSigner & OfflineDirectSigner;
|
|
337
|
-
getOfflineSignerOnlyAmino: (chainId: string) => OfflineSigner;
|
|
338
|
-
getOfflineSignerAuto: (chainId: string) => Promise<OfflineSigner | OfflineDirectSigner>;
|
|
339
|
-
}
|
|
340
|
-
interface GrazAdapter extends Connector {
|
|
341
|
-
name: string;
|
|
342
|
-
id: string;
|
|
343
|
-
keystoreEvent: string;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
344
|
/**
|
|
347
345
|
* Helper function to define chain information records (key values).
|
|
348
346
|
*
|
|
@@ -477,7 +475,7 @@ declare const useBalances: <TMulti extends MultiChainHookArgs>(args?: ({
|
|
|
477
475
|
* ```
|
|
478
476
|
*/
|
|
479
477
|
declare const useBalance: <TMulti extends MultiChainHookArgs>(args: {
|
|
480
|
-
denom
|
|
478
|
+
denom?: string;
|
|
481
479
|
bech32Address?: string;
|
|
482
480
|
} & {
|
|
483
481
|
chainId: ChainId$1;
|
|
@@ -605,6 +603,14 @@ declare const useBalanceStaked: <TMulti extends MultiChainHookArgs>(args?: ({
|
|
|
605
603
|
bech32Address?: string | undefined;
|
|
606
604
|
} & TMulti) | undefined) => UseMultiChainQueryResult<TMulti, Coin>;
|
|
607
605
|
|
|
606
|
+
declare const useCapsule: () => {
|
|
607
|
+
setModalState: (state: boolean) => void;
|
|
608
|
+
modalState: boolean;
|
|
609
|
+
client: _leapwallet_cosmos_social_login_capsule_provider.CapsuleProvider | null;
|
|
610
|
+
onAfterLoginSuccessful: (() => Promise<void>) | undefined;
|
|
611
|
+
onLoginFailure: () => void;
|
|
612
|
+
};
|
|
613
|
+
|
|
608
614
|
/**
|
|
609
615
|
* graz hook to retrieve connected account's active chainIds
|
|
610
616
|
*
|
|
@@ -1050,6 +1056,7 @@ declare const useActiveWalletType: () => {
|
|
|
1050
1056
|
isWalletConnect: boolean;
|
|
1051
1057
|
isMetamaskSnapLeap: boolean;
|
|
1052
1058
|
isStation: boolean;
|
|
1059
|
+
isCapsule: boolean;
|
|
1053
1060
|
};
|
|
1054
1061
|
/**
|
|
1055
1062
|
* graz query hook to check whether given {@link WalletType} or default configured wallet is supported
|
|
@@ -1100,4 +1107,4 @@ declare const useGrazEvents: () => null;
|
|
|
1100
1107
|
*/
|
|
1101
1108
|
declare const GrazEvents: FC;
|
|
1102
1109
|
|
|
1103
|
-
export {
|
|
1110
|
+
export { ConfigureGrazArgs, ConnectArgs, ConnectResult, Dictionary, ExecuteContractArgs, ExecuteContractMutationArgs, GrazEvents, GrazProvider, GrazProviderProps, InstantiateContractArgs, InstantiateContractMutationArgs, Maybe, OfflineSigners, ReconnectArgs, SendIbcTokensArgs, SendTokensArgs, SignAminoParams, SignDirectParams, SuggestChainAndConnectArgs, SuggestChainArgs, UseAccountArgs, UseAccountResult, UseConnectChainArgs, UseExecuteContractArgs, UseInstantiateContractArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WALLET_TYPES, Wallet, WalletType, checkWallet, clearRecentChain, clearSession, configureGraz, connect, defineChainInfo, defineChains, disconnect, executeContract, getAvailableWallets, getChainInfo, getChainInfos, getCosmostation, getKeplr, getLeap, getMetamaskSnapLeap, getOfflineSigners, getQueryRaw, getQuerySmart, getRecentChainIds, getRecentChains, getVectis, getWCCosmostation, getWCKeplr, getWCLeap, getWallet, getWalletConnect, instantiateContract, isCapsule, isWalletConnect, reconnect, sendIbcTokens, sendTokens, suggestChain, suggestChainAndConnect, useAccount, useActiveChainCurrency, useActiveChainIds, useActiveChains, useActiveWalletType, useBalance, useBalanceStaked, useBalances, useCapsule, useChainInfo, useChainInfos, useCheckWallet, useConnect, useCosmWasmClient, useCosmWasmSigningClient, useCosmWasmTmSigningClient, useDisconnect, useExecuteContract, useGrazEvents, useInstantiateContract, useOfflineSigners, useQueryClientValidators, useQueryRaw, useQuerySmart, useRecentChainIds, useRecentChains, useSendIbcTokens, useSendTokens, useStargateClient, useStargateSigningClient, useStargateTmSigningClient, useSuggestChain, useSuggestChainAndConnect, useTendermintClient };
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
var encoding = require('@cosmjs/encoding');
|
|
4
4
|
var zustand = require('zustand');
|
|
5
5
|
var middleware = require('zustand/middleware');
|
|
6
|
-
var
|
|
6
|
+
var Ft = require('long');
|
|
7
7
|
var signClient = require('@walletconnect/sign-client');
|
|
8
8
|
var utils = require('@walletconnect/utils');
|
|
9
9
|
var reactQuery = require('@tanstack/react-query');
|
|
@@ -16,78 +16,80 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
16
16
|
|
|
17
17
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
18
18
|
|
|
19
|
-
var
|
|
19
|
+
var Ft__default = /*#__PURE__*/_interopDefault(Ft);
|
|
20
20
|
|
|
21
|
-
var Wt=Object.defineProperty,vt=Object.defineProperties;var kt=Object.getOwnPropertyDescriptors;var re=Object.getOwnPropertySymbols;var Le=Object.prototype.hasOwnProperty,Ke=Object.prototype.propertyIsEnumerable;var De=(e,t,n)=>t in e?Wt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,T=(e,t)=>{for(var n in t||(t={}))Le.call(t,n)&&De(e,n,t[n]);if(re)for(var n of re(t))Ke.call(t,n)&&De(e,n,t[n]);return e},N=(e,t)=>vt(e,kt(t));var Ue=(e,t)=>{var n={};for(var i in e)Le.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&re)for(var i of re(e))t.indexOf(i)<0&&Ke.call(e,i)&&(n[i]=e[i]);return n};var l=(e,t,n)=>new Promise((i,r)=>{var o=c=>{try{a(n.next(c));}catch(d){r(d);}},s=c=>{try{a(n.throw(c));}catch(d){r(d);}},a=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,s);a((n=n.apply(e,t)).next());});var J="graz-reconnect-session";var qe=(f=>(f.KEPLR="keplr",f.LEAP="leap",f.VECTIS="vectis",f.COSMOSTATION="cosmostation",f.WALLETCONNECT="walletconnect",f.WC_KEPLR_MOBILE="wc_keplr_mobile",f.WC_LEAP_MOBILE="wc_leap_mobile",f.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",f.METAMASK_SNAP_LEAP="metamask_snap_leap",f.STATION="station",f.XDEFI="xdefi",f))(qe||{}),Ge=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","metamask_snap_leap","station","xdefi"];var Pt={recentChainIds:null,chains:null,chainsConfig:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,web3Modal:null},_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},Z={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map},Nt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:middleware.createJSONStorage(()=>sessionStorage)},_t={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector}),version:2},C=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>Z,Nt))),u=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>Pt,_t)));var se=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:r=>{var s;let o=()=>{F(),r();};return (s=window.cosmostation)==null||s.cosmos.on("accountChanged",o),()=>{var a;(a=window.cosmostation)==null||a.cosmos.off("accountChanged",o);}}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var ae=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:i=>{let r=()=>{F(),i();};return window.addEventListener("keplr_keystorechange",r),()=>{window.removeEventListener("keplr_keystorechange",r);}}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var ce=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:i=>{let r=()=>{F(),i();};return window.addEventListener("leap_keystorechange",r),()=>{window.removeEventListener("leap_keystorechange",r);}}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var je=e=>{let t=window.ethereum;if(t&&e){let n=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),i=h=>l(void 0,null,function*(){try{let w=yield n();return Object.values(w).find(x=>x.id===e.id&&(!h||x.version===h))}catch(w){return}}),r=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),o=()=>l(void 0,null,function*(){var _;let h=yield t.request({method:"web3_clientVersion"});if(!h.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let x=(_=h.split("MetaMask/v")[1])==null?void 0:_.split(".")[0];if(!(Number(x)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield i())||(yield r()),!0}),s=h=>l(void 0,null,function*(){(yield i())||(yield r());}),a=(h,w,x)=>l(void 0,null,function*(){let P=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:h,signerAddress:w,signDoc:x}}}}),D=x.accountNumber,_=new Bt__default.default(D.low,D.high,D.unsigned);return {signature:P.signature,signed:N(T({},P.signed),{accountNumber:`${_.toString()}`,authInfoBytes:new Uint8Array(Object.values(P.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(P.signed.bodyBytes))})}}),c=(h,w,x)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:h,signerAddress:w,signDoc:x}}}})}),d=h=>l(void 0,null,function*(){let w=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:h}}}});if(!w)throw new Error("No response from Metamask");return w.pubKey=Uint8Array.from(Object.values(w.pubkey)),delete w.pubkey,T({},w)}),g=h=>l(void 0,null,function*(){let w=yield d(h);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),f=(...h)=>l(void 0,null,function*(){let[w,x,P,D]=h;return yield c(w,x,P)}),A=(...h)=>l(void 0,null,function*(){let[w,x,P]=h;return yield a(w,x,P)}),S=h=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(h)]}),signDirect:(w,x)=>A(h,w,x)}),b=h=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(h)]}),signAmino:(w,x)=>f(h,w,x)});return {enable:s,experimentalSuggestChain:(...h)=>l(void 0,null,function*(){yield o(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:h[0]}}}});}),getKey:d,getOfflineSigner:h=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(h)]}),signDirect:(w,x)=>A(h,w,x),signAmino:(w,x)=>f(h,w,x)}),getOfflineSignerAuto:h=>l(void 0,null,function*(){return (yield d(h)).isNanoLedger?b(h):S(h)}),getOfflineSignerOnlyAmino:b,init:o,signAmino:f,signDirect:A}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var $e=()=>je({id:"npm:@leapwallet/metamask-cosmos-snap"});var le=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:o=>{let s=()=>{F(),o();};return window.addEventListener("station_wallet_change",s),()=>{window.removeEventListener("station_wallet_change",s);}},getKey:o=>l(void 0,null,function*(){let s=yield e.getKey(o);return T({isKeystone:!1},s)}),getOfflineSigner:o=>{try{let s=e.getOfflineSignerOnlyAmino(o);return Object.assign(s,{signDirect:(d,g)=>{throw new Error("signDirect not supported by Station")}})}catch(s){throw console.error(s),s}},experimentalSuggestChain:o=>l(void 0,null,function*(){try{let s=Object.assign(o,{chainSymbolImageUrl:o.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:o.stakeCurrency.coinDecimals,coinDenom:o.stakeCurrency.coinDenom,coinImageUrl:o.stakeCurrency.coinImageUrl||"",coinMinimalDenom:o.stakeCurrency.coinMinimalDenom},currencies:o.currencies.map(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:o.feeCurrencies.map(a=>{var c,d,g;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((c=a.gasPriceStep)==null?void 0:c.average)||0,high:((d=a.gasPriceStep)==null?void 0:d.high)||0,low:((g=a.gasPriceStep)==null?void 0:g.low)||0}}})});yield e.experimentalSuggestChain(s);}catch(s){throw console.error(s),s}}),enable:o=>e.enable(o),disable:o=>e.disable(o),getOfflineSignerAuto:o=>e.getOfflineSignerAuto(o),getOfflineSignerOnlyAmino:o=>e.getOfflineSignerOnlyAmino(o),signDirect:()=>e.signDirect(),signAmino:(o,s,a,c)=>e.signAmino(o,s,a)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var ue=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:a=>e.enable(a),getOfflineSigner:a=>e.getOfflineSigner(a),getOfflineSignerAuto:a=>e.getOfflineSignerAuto(a),getKey:a=>l(void 0,null,function*(){let c=yield e.getKey(a);return {address:encoding.fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}}),subscription:a=>{let c=()=>{F(),a();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...a)=>e.getOfflineSignerAmino(...a),experimentalSuggestChain:(...a)=>l(void 0,null,function*(){let[c]=a,d=N(T({},c),{rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr});return e.suggestChains([d])}),signDirect:(...a)=>l(void 0,null,function*(){var g;let{1:c,2:d}=a;return e.signDirect(c,{bodyBytes:d.bodyBytes||Uint8Array.from([]),authInfoBytes:d.authInfoBytes||Uint8Array.from([]),accountNumber:Bt__default.default.fromString(((g=d.accountNumber)==null?void 0:g.toString())||"",!1),chainId:d.chainId||""})}),signAmino:(...a)=>l(void 0,null,function*(){let{1:c,2:d}=a;return e.signAmino(c,d)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var Q=()=>typeof window!="undefined"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,He=()=>Q()&&navigator.userAgent.toLowerCase().includes("android"),Ve=()=>Q()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Ie=(e,t,n=new Error("Promise timed out"))=>{let i=new Promise((r,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,i])};var j=e=>{var _,te,Re;if(!((Re=(te=(_=u.getState().walletConnect)==null?void 0:_.options)==null?void 0:te.projectId)!=null&&Re.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",i=m=>{if(!e)return;let{appUrl:p,formatNativeUrl:y}=e;if(Q()){if(He())if(!m)window.open(p.mobile.android,"_self","noreferrer noopener");else {let E=y(p.mobile.android,m,"android");window.open(E,"_self","noreferrer noopener");}if(Ve())if(!m)window.open(p.mobile.ios,"_self","noreferrer noopener");else {let E=y(p.mobile.ios,m,"ios");window.open(E,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:m}=C.getState();if(!m.get(t))throw new Error("walletConnect.signClient is not defined");m.delete(t),C.setState({wcSignClients:m}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},o=m=>l(void 0,null,function*(){let{wcSignClients:p}=C.getState(),y=p.get(t);if(!y)throw new Error("walletConnect.signClient is not defined");if(!m)throw new Error("No wallet connect session");yield y.disconnect({topic:m,reason:utils.getSdkError("USER_DISCONNECTED")}),yield c(y);}),s=m=>{try{let{wcSignClients:p}=C.getState(),y=p.get(t);if(!y)throw new Error("walletConnect.signClient is not defined");let E=y.session.getAll().at(-1);if(!E)return;if(!(E.expiry*1e3>Date.now()+1e3))throw o(E.topic),new Error("invalid session");try{let M=y.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:m.map(U=>`cosmos:${U}`),events:["chainChanged","accountsChanged"]}}});if(!M.length)throw new Error("no session");return M.at(-1)}catch(M){if(!M.message.toLowerCase().includes("no matching key"))throw M}return E}catch(p){if(!p.message.toLowerCase().includes("no matching key"))throw p}},a=m=>{try{return s(m)}catch(p){return}},c=m=>l(void 0,null,function*(){try{let p=m.core.pairing.pairings.getAll({active:!1});if(!p.length)return;yield Promise.all(p.map(y=>l(void 0,null,function*(){yield m.core.pairing.pairings.delete(y.topic,{code:7001,message:"clear pairing"});})));}catch(p){if(!p.message.toLowerCase().includes("no matching key"))throw p}}),d=()=>l(void 0,null,function*(){let{walletConnect:m}=u.getState();if(!(m!=null&&m.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:p}=C.getState(),y=p.get(t);if(y)return y;let E=yield signClient.SignClient.init(m.options);return p.set(t,E),C.setState({wcSignClients:p}),E}),g=m=>{let{wcSignClients:p}=C.getState(),y=p.get(t);if(!y)return ()=>{};let E=v=>{let M=C.getState().accounts;if(v.params.event.name==="accountsChanged"&&M&&!Object.values(M).map(U=>U.bech32Address).includes(v.params.event.data[0])){let U=v.params.chainId.split(":")[1];U&&f([U]);}else m();};return y.events.on("session_delete",r),y.events.on("session_expire",r),y.events.on("session_event",E),()=>{y.events.off("session_delete",r),y.events.off("session_expire",r),y.events.off("session_event",E);}},f=m=>l(void 0,null,function*(){var ne;let p=typeof m=="string"?[m]:m,{wcSignClients:y}=C.getState(),E=y.get(t);if(!E)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:v,chains:M}=u.getState();if(!((ne=v==null?void 0:v.options)!=null&&ne.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:U}=yield import('@web3modal/standalone'),$=new U(T({projectId:v.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},v.web3Modal)),V=a(p);if(!V){let{uri:L,approval:Y}=yield Ie(E.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:p.map(G=>`cosmos:${G}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!L)throw new Error("No wallet connect uri");e?i(L):yield $.openModal({uri:L});let oe=G=>l(void 0,null,function*(){return G.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((we,X)=>{Y().then(Pe=>{let Ne=Pe.sessionProperties;if(!Ne)return X(new Error("No session properties"));let Ae=JSON.parse(String(Ne.keys));if(Ae.length===0)return X(new Error("No accounts"));let _e=Ae[0];if(!_e)return X(new Error("No accounts"));let Be={};return p.forEach(ie=>{Be[ie]=N(T({},_e),{bech32Address:encoding.toBech32(M.find(Mt=>Mt.chainId===ie).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(Ae[0].bech32Address).data)});}),C.setState(ie=>({accounts:T(T({},ie.accounts||{}),Be)})),we(Pe)}).catch(X),G.addEventListener("abort",()=>{X(new Error("User closed wallet connect"));},{once:!0});})});try{let G=new AbortController,we=G.signal;$.subscribeModal(X=>{X.open||G.abort();}),yield oe(we);}catch(G){if($.closeModal(),!G.message.toLowerCase().includes("no matching key"))return Promise.reject(G)}return e||$.closeModal(),Promise.resolve()}try{yield Ie((()=>l(void 0,null,function*(){let L=yield S(p[0]),Y={};p.forEach(oe=>{Y[oe]=N(T({},L),{bech32Address:encoding.toBech32(M.find(G=>G.chainId===oe).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(L.bech32Address).data)});}),C.setState({accounts:Y});}))(),15e3,new Error("Connection timeout"));}catch(L){if(o(V.topic),!L.message.toLowerCase().includes("no matching key"))throw L}}),A=m=>l(void 0,null,function*(){var M;let{wcSignClients:p}=C.getState(),y=p.get(t);if(!y)throw new Error("walletConnect.signClient is not defined");let E=(M=s([m]))==null?void 0:M.topic;if(!E)throw new Error("No wallet connect session");let v=yield y.request({topic:E,chainId:`cosmos:${m}`,request:{method:"cosmos_getAccounts",params:{}}});if(!v[0])throw new Error("No wallet connect account");return {address:v[0].address,algo:v[0].algo,pubkey:new Uint8Array(Buffer.from(v[0].pubkey,n))}}),S=m=>l(void 0,null,function*(){let p=s([m]);if(!(p!=null&&p.topic))throw new Error("No wallet connect session");let y=p.sessionProperties&&JSON.parse(String(p.sessionProperties.keys))[0];if(!y)throw new Error("No wallet connect key");return y}),b=(...m)=>l(void 0,null,function*(){var L,Y;let[p,y,E]=m,{accounts:v,wcSignClients:M}=C.getState(),U=M.get(t);if(!U)throw new Error("walletConnect.signClient is not defined");if(!v)throw new Error("account is not defined");let $=(L=s([p]))==null?void 0:L.topic;if(!$)throw new Error("No wallet connect session");if(!E.bodyBytes)throw new Error("No bodyBytes");if(!E.authInfoBytes)throw new Error("No authInfoBytes");let V={topic:$,chainId:`cosmos:${p}`,request:{method:"cosmos_signDirect",params:{signerAddress:y,signDoc:N(T({},E),{bodyBytes:Buffer.from(E.bodyBytes).toString(n),authInfoBytes:Buffer.from(E.authInfoBytes).toString(n),accountNumber:(Y=E.accountNumber)==null?void 0:Y.toString()})}}};return i(),yield U.request(V)}),I=(...m)=>l(void 0,null,function*(){let[p,y,E]=m,{signature:v,signed:M}=yield b(p,y,E);return {signed:{chainId:M.chainId,accountNumber:Bt__default.default.fromString(M.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(M.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(M.bodyBytes,n))},signature:v}}),W=(...m)=>l(void 0,null,function*(){var L;let[p,y,E,v]=m,{wcSignClients:M}=C.getState(),U=M.get(t),{accounts:$}=C.getState();if(!U)throw new Error("walletConnect.signClient is not defined");if(!$)throw new Error("account is not defined");let V=(L=s([p]))==null?void 0:L.topic;if(!V)throw new Error("No wallet connect session");return i(),yield U.request({topic:V,chainId:`cosmos:${p}`,request:{method:"cosmos_signDirect",params:{signerAddress:y,signDoc:E}}})}),R=(...m)=>l(void 0,null,function*(){let[p,y,E,v]=m;return yield W(p,y,E)}),h=m=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(m)]}),signDirect:(p,y)=>I(m,p,y)}),w=m=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(m)]}),signAmino:(p,y)=>R(m,p,y)});return {enable:f,disable:m=>l(void 0,null,function*(){var E;let{wcSignClients:p}=C.getState(),y=p.get(t);if(m===void 0){let v=y==null?void 0:y.session.getAll();v!==void 0&&(yield Promise.all(v.map(M=>o(M.topic))));}else typeof m=="string"?yield o((E=s([m]))==null?void 0:E.topic):yield Promise.all(m.map(v=>{var M;return o((M=s([v]))==null?void 0:M.topic)}));(y==null?void 0:y.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...m)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:S,getOfflineSigner:m=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(m)]}),signDirect:(p,y)=>I(m,p,y),signAmino:(p,y)=>R(m,p,y)}),getOfflineSignerAuto:m=>l(void 0,null,function*(){return (yield S(m)).isNanoLedger?w(m):h(m)}),getOfflineSignerOnlyAmino:w,signAmino:R,signDirect:I,subscription:g,init:d}};var Je=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(r,o,s)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${o}`};return j(e)};var Ze=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(r,o,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${c}`;case"android":return `${a}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${a}://wc?uri=${c}`}}};return j(e)};var et=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(r,o,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${c}`;case"android":return `${a}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${a}://wc?uri=${c}`}}};return j(e)};var de=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let o=()=>{F(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var B=(e=u.getState().walletType)=>{try{return k(e),!0}catch(t){return !1}},F=()=>{window.sessionStorage.removeItem(J),C.setState(Z);},k=(e=u.getState().walletType)=>{switch(e){case"keplr":return ae();case"leap":return ce();case"cosmostation":return se();case"vectis":return ue();case"walletconnect":return j();case"wc_keplr_mobile":return Ze();case"wc_leap_mobile":return et();case"wc_cosmostation_mobile":return Je();case"metamask_snap_leap":return $e();case"station":return le();case"xdefi":return de();default:throw new Error("Unknown wallet type")}},Qo=()=>Object.fromEntries(Ge.map(e=>[e,B(e)])),tt=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var ee=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:i,walletType:r}=u.getState(),o=(e==null?void 0:e.walletType)||r;if(!B(o))throw new Error(`${o} is not available`);let a=k(o),c=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!c)throw new Error("No last known connected chain, connect action requires chain ids");let d=i==null?void 0:i.map(S=>S.chainId);c.forEach(S=>{if(!(d!=null&&d.includes(S)))throw new Error(`Chain ${S} is not provided in GrazProvider`)}),C.setState(S=>{let b=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return S.activeChainIds&&c.filter(W=>{var R;return !((R=S.activeChainIds)!=null&&R.includes(W))}).length>0?{status:"connecting"}:b?{status:"reconnecting"}:{status:"connecting"}});let{accounts:g}=C.getState();if(yield (t=a.init)==null?void 0:t.call(a),yield a.enable(c),!tt(o)){let S=yield a.getKey(c[0]),b={};c.forEach(I=>{b[I]=N(T({},S),{bech32Address:encoding.toBech32(i.find(W=>W.chainId===I).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(S.bech32Address).data)});}),C.setState(I=>({accounts:T(T({},I.accounts||{}),b)}));}u.setState(S=>({recentChainIds:[...S.recentChainIds||[],...c].filter((b,I,W)=>W.indexOf(b)===I)})),C.setState(S=>({activeChainIds:[...S.activeChainIds||[],...c].filter((b,I,W)=>W.indexOf(b)===I)})),u.setState({walletType:o,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:o}),C.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(J,"Active");let f=c.map(S=>i.find(b=>b.chainId===S));return {accounts:C.getState().accounts,walletType:o,chains:f}}catch(n){throw console.error("connect ",n),C.getState().accounts===null&&C.setState({status:"disconnected"}),C.getState().accounts&&C.getState().activeChainIds&&C.setState({status:"connected"}),n}}),Ee=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(J);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=C.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(C.setState(Z),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(C.setState(r=>{var o;return {activeChainIds:(o=r.activeChainIds)==null?void 0:o.filter(s=>!t.includes(s)),accounts:n}}),u.setState(r=>{var o;return {recentChainIds:(o=r.recentChainIds)==null?void 0:o.filter(s=>!t.includes(s))}}));}else C.setState(Z),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},z=e=>l(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:i}=u.getState();try{let o=B(n||void 0);if(t&&o&&n)return yield ee({chainId:t,walletType:n,autoReconnect:i})}catch(o){(r=e==null?void 0:e.onError)==null||r.call(e,o),Ee();}}),nt=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!B(n))throw new Error(`${n} is not available`);let r=k(n),o=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),a=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:s,offlineSignerAuto:a}});var Te=()=>{u.setState({recentChainIds:null});},ii=()=>u.getState().recentChainIds,ri=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(i=>t.find(r=>r.chainId===i)))!=null?n:null},si=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},ai=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},be=n=>l(void 0,[n],function*({chainInfo:e,walletType:t}){return yield k(t).experimentalSuggestChain(e),e}),ot=e=>l(void 0,null,function*(){var i;let t=u.getState().walletType;return yield be({chainInfo:e.chainInfo,walletType:(i=e.walletType)!=null?i:t}),yield ee({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var it=e=>(u.setState(t=>({walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var rt=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:i,fee:r,memo:o}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,i,r,o)}),st=g=>l(void 0,[g],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:i,sourcePort:r,sourceChannel:o,timeoutHeight:s,timeoutTimestamp:a,fee:c,memo:d}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,i,r,o,s,a,c,d)}),at=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,options:r,label:o,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,o,i,r)}),ct=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,contractAddress:r,funds:o,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,i,s,o)}),lt=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),ut=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let i=new TextEncoder().encode(t);return n.queryContractRaw(e,i)};var Ci=e=>e,hi=e=>e;var me=e=>e?Object.keys(e).length===0:!0;var Oe=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},dt=e=>globalThis.DOMException===void 0?new Oe(e):new DOMException(e),mt=e=>{let t=e.reason===void 0?dt("This operation was aborted."):e.reason;return t instanceof Error?t:dt(t)};function xe(o,s){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:i=!0,signal:r}={}){return new Promise((a,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let d=[],g=[],f=new Map,A=!1,S=!1,b=!1,I=0,W=0,R=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),h=x=>{A=!0,S=!0,c(x);};r&&(r.aborted&&h(mt(r)),r.addEventListener("abort",()=>{h(mt(r));}));let w=()=>l(this,null,function*(){if(S)return;let x=yield R.next(),P=W;if(W++,x.done){if(b=!0,I===0&&!S){if(!i&&g.length>0){h(new AggregateError(g));return}if(S=!0,f.size===0){a(d);return}let D=[];for(let[_,te]of d.entries())f.get(_)!==pt&&D.push(te);a(D);}return}I++,l(this,null,function*(){try{let D=yield x.value;if(S)return;let _=yield t(D,P);_===pt&&f.set(P,_),d[P]=_,I--,yield w();}catch(D){if(i)h(D);else {g.push(D),I--;try{yield w();}catch(_){h(_);}}}});});l(this,null,function*(){for(let x=0;x<n;x++){try{yield w();}catch(P){h(P);break}if(b||A)break}});})})}var pt=Symbol("skip");var K=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let i=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!i):return i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean);case(!t&&!!i):return [i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean)[0]];case(!!t&&!i):return n;default:return [n[0]]}},q=(e,t,n)=>l(void 0,null,function*(){let i=u.getState().multiChainFetchConcurrency;if(e){let o=yield xe(t,n,{concurrency:i});return Object.fromEntries(o.map((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),ft=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((o,s)=>[t[s].chainId,o]))}return n(t[0])};var ve=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),i,s=>l(void 0,null,function*(){var g;let a=(g=u.getState().chainsConfig)==null?void 0:g[s.chainId],c={url:s.rpc,headers:T({},(a==null?void 0:a.rpcHeaders)||{})};return yield stargate.StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},ke=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),i,s=>l(void 0,null,function*(){var g;let a=(g=u.getState().chainsConfig)==null?void 0:g[s.chainId],c={url:s.rpc,headers:T({},(a==null?void 0:a.rpcHeaders)||{})};return yield cosmwasmStargate.CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},pe=({type:e,chainId:t,multiChain:n,enabled:i})=>{let r=K({chainId:t,multiChain:n}),o=react.useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return reactQuery.useQuery({queryKey:o,queryFn:c=>l(void 0,[c],function*({queryKey:[,s,a]}){if(a.length<1)throw new Error("No chains found");return yield q(!!n,a,g=>l(void 0,null,function*(){var I;let f=(I=u.getState().chainsConfig)==null?void 0:I[g.chainId],A={url:g.rpc,headers:T({},(f==null?void 0:f.rpcHeaders)||{})};return yield (s==="tm37"?tendermintRpc.Tendermint37Client:tendermintRpc.Tendermint34Client).connect(A)}))}),enabled:!!r&&r.length>0&&(i!==void 0?!!i:!0),refetchOnWindowFocus:!1})};var Qi=()=>u(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station"}),shallow.shallow),fe=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return reactQuery.useQuery(n,({queryKey:[,r]})=>B(r))};var H=e=>{let t=u(a=>a.walletType),n=C(a=>a.activeChainIds),i=K({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=C(a=>a.accounts),o=C(a=>a.status);return react.useEffect(()=>C.subscribe(a=>a.status,(a,c)=>{var d,g,f;if(a==="connected"){let{accounts:A,activeChainIds:S}=C.getState(),{chains:b}=u.getState(),{walletType:I}=u.getState();if(!A||!S||!b)return (d=e==null?void 0:e.onDisconnect)==null?void 0:d.call(e);(g=e==null?void 0:e.onConnect)==null||g.call(e,{accounts:A,chains:S.map(W=>b.find(R=>R.chainId===W)),walletType:I,isReconnect:c==="reconnecting"});}a==="disconnected"&&((f=e==null?void 0:e.onDisconnect)==null||f.call(e));}),[e]),{data:react.useMemo(()=>r?ft(!!(e!=null&&e.multiChain),i,a=>r[a.chainId]):void 0,[r,i,e==null?void 0:e.multiChain]),isConnected:o==="connected",isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",isLoading:o==="connecting"||o==="reconnecting",walletType:o==="connected"?t:void 0,reconnect:z,status:o}},Xt=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=H(),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=ve({chainId:t.map(s=>s.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!i}),o=react.useMemo(()=>["USE_ALL_BALANCES",r,t,i,e==null?void 0:e.chainId],[i,e==null?void 0:e.chainId,t,r]);return reactQuery.useQuery(o,d=>l(void 0,[d],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield q(!!(e!=null&&e.multiChain),a,f=>l(void 0,null,function*(){let A=s==null?void 0:s[f.chainId];if(!A)throw new Error(`Client is not ready ${f.chainId}`);return yield A.getAllBalances(encoding.toBech32(f.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),{enabled:!!i&&!!t&&t.length>0&&!me(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},ir=e=>{let t=K({chainId:e.chainId}),{data:n}=H({chainId:e.chainId}),i=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:o}=Xt({chainId:t.map(c=>c.chainId),bech32Address:i,enabled:!!i&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,i,e.chainId],a=reactQuery.useQuery(s,({queryKey:[,c,d]})=>d==null?void 0:d.find(g=>g.denom===c),{enabled:!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return N(T({},a),{refetch:c=>l(void 0,null,function*(){return yield o(),a.refetch(c)})})},rr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_CONNECT",e,t,n],ee,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=fe();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status}},sr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_DISCONNECT",e,t,n],Ee,{onError:o=>Promise.resolve(e==null?void 0:e(o,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:o=>r.mutate(o),disconnectAsync:o=>r.mutateAsync(o),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},ar=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),i=react.useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return reactQuery.useQuery({queryKey:i,queryFn:s=>l(void 0,[s],function*({queryKey:[,r,o]}){if(r.length<1)throw new Error("No chain found");if(!B(o))throw new Error(`${o} is not available`);return yield q(!!(e!=null&&e.multiChain),r,d=>l(void 0,null,function*(){return yield nt({chainId:d.chainId,walletType:o})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},cr=e=>{let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=H(),{data:i}=ve({chainId:t.map(s=>s.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),o=react.useMemo(()=>["USE_BALANCE_STAKED",i,t,r],[t,r,i]);return reactQuery.useQuery(o,d=>l(void 0,[d],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield q(!!(e!=null&&e.multiChain),a,f=>l(void 0,null,function*(){var S;if(!s)throw new Error("Client is not ready");return yield (S=s[f.chainId])==null?void 0:S.getBalanceStaked(encoding.toBech32(f.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!i,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var yr=()=>C(e=>e.activeChainIds),Jt=()=>{var e;return (e=C(t=>t.activeChainIds))==null?void 0:e.map(t=>{var i;let n=(i=u.getState().chains)==null?void 0:i.find(r=>r.chainId===t);if(n)return n}).filter(Boolean)},Cr=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},hr=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Sr=({denom:e})=>{let t=Jt();return reactQuery.useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var o;return (o=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===r)))==null?void 0:o.currencies.find(s=>s)})},wr=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return reactQuery.useQuery(n,a=>l(void 0,[a],function*({queryKey:[,o,s]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(s)}),{enabled:typeof e.queryClient!="undefined"})},Ar=()=>({data:u(t=>t.recentChainIds),clear:Te}),Ir=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let i=(r=u.getState().chains)==null?void 0:r.find(o=>o.chainId===n);if(i)return i}).filter(Boolean),clear:Te}},Er=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN",e,t,n],be,{onError:(o,s)=>Promise.resolve(e==null?void 0:e(o,s.chainInfo)),onMutate:o=>t==null?void 0:t(o.chainInfo),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},Tr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],ot,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=fe();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var Rr=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=H(),r=i==null?void 0:i.bech32Address,o=reactQuery.useMutation(["USE_SEND_TOKENS",e,t,n,r],s=>rt(T({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},Pr=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=H(),r=i==null?void 0:i.bech32Address,o=reactQuery.useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],s=>st(T({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Nr=({codeId:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=H(),o=r==null?void 0:r.bech32Address,a=reactQuery.useMutation(["USE_INSTANTIATE_CONTRACT",t,n,i,e,o],c=>{var g;if(!o)throw new Error("senderAddress is undefined");let d=N(T({},c),{fee:(g=c.fee)!=null?g:"auto",senderAddress:o,codeId:e});return at(d)},{onError:(c,d)=>Promise.resolve(t==null?void 0:t(c,d)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},_r=({contractAddress:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=H(),o=r==null?void 0:r.bech32Address,a=reactQuery.useMutation(["USE_EXECUTE_CONTRACT",t,n,i,e,o],c=>{var g,f,A;if(!o)throw new Error("senderAddress is undefined");let d=N(T({},c),{fee:(g=c.fee)!=null?g:"auto",senderAddress:o,contractAddress:e,memo:(f=c.memo)!=null?f:"",funds:(A=c.funds)!=null?A:[]});return ct(d)},{onError:(c,d)=>Promise.resolve(t==null?void 0:t(c,d)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},Br=e=>{let{data:t}=ke();return reactQuery.useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return lt(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Dr=e=>{let{data:t}=ke(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return reactQuery.useQuery(n,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return ut(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function Yr(e){let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=C(o=>o.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),o,d=>l(this,null,function*(){var I,W;if(!(i!=null&&i.includes(d.chainId)))return;if(!B(s))throw new Error(`${s} is not available`);let f=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return k(s).getOfflineSigner(d.chainId);case"offlineSignerAuto":return k(s).getOfflineSignerAuto(d.chainId);case"offlineSignerOnlyAmino":return k(s).getOfflineSignerOnlyAmino(d.chainId);default:return k(s).getOfflineSignerAuto(d.chainId)}}))(),A=(I=u.getState().chainsConfig)==null?void 0:I[d.chainId],S={url:d.rpc,headers:T({},(A==null?void 0:A.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(S,f,e!=null&&e.multiChain?(W=e.opts)==null?void 0:W[d.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Xr(e){let t=K({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=C(o=>o.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),o,d=>l(this,null,function*(){var W,R;if(!(i!=null&&i.includes(d.chainId)))return;if(!B(s))throw new Error(`${s} is not available`);let f=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return k(s).getOfflineSigner(d.chainId);case"offlineSignerAuto":return k(s).getOfflineSignerAuto(d.chainId);case"offlineSignerOnlyAmino":return k(s).getOfflineSignerOnlyAmino(d.chainId);default:return k(s).getOfflineSignerAuto(d.chainId)}}))(),A=(W=u.getState().chainsConfig)==null?void 0:W[d.chainId],S={url:d.rpc,headers:T({},(A==null?void 0:A.rpcHeaders)||{})},b=A!=null&&A.gas?stargate.GasPrice.fromString(`${A.gas.price}${A.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(S,f,T({gasPrice:b},e!=null&&e.multiChain?(R=e.opts)==null?void 0:R[d.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Jr(e){let t=K({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),i=C(s=>s.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=pe({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:c=>l(this,[c],function*({queryKey:[,s,a]}){if(s.length<1)throw new Error("No chains found");return yield q(!!e.multiChain,s,g=>l(this,null,function*(){var I;if(!(i!=null&&i.includes(g.chainId)))return;if(!B(a))throw new Error(`${a} is not available`);if(!o)throw new Error("No tendermint client found");let A=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return k(a).getOfflineSigner(g.chainId);case"offlineSignerAuto":return k(a).getOfflineSignerAuto(g.chainId);case"offlineSignerOnlyAmino":return k(a).getOfflineSignerOnlyAmino(g.chainId);default:return k(a).getOfflineSignerAuto(g.chainId)}}))(),S=e.multiChain?o[g.chainId]:o;return yield stargate.SigningStargateClient.createWithSigner(S,A,e.multiChain?(I=e.opts)==null?void 0:I[g.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!o&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Zr(e){let t=K({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),i=C(a=>a.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=pe({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:s}=pe({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:d=>l(this,[d],function*({queryKey:[,a,c]}){if(a.length<1)throw new Error("No chains found");return yield q(!!e.multiChain,a,f=>l(this,null,function*(){var h,w;if(!(i!=null&&i.includes(f.chainId)))return;if(!B(c))throw new Error(`${c} is not available`);let S=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return k(c).getOfflineSigner(f.chainId);case"offlineSignerAuto":return k(c).getOfflineSignerAuto(f.chainId);case"offlineSignerOnlyAmino":return k(c).getOfflineSignerOnlyAmino(f.chainId);default:return k(c).getOfflineSignerAuto(f.chainId)}}))(),b=(h=u.getState().chainsConfig)==null?void 0:h[f.chainId],I=b!=null&&b.gas?stargate.GasPrice.fromString(`${b.gas.price}${b.gas.denom}`):void 0,W=e.multiChain?s==null?void 0:s[f.chainId]:o;if(!W)throw new Error("No tendermint client found");return yield cosmwasmStargate.SigningCosmWasmClient.createWithSigner(W,S,T({gasPrice:I},e.multiChain?(w=e.opts)==null?void 0:w[f.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!o||!me(s))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Tt=({children:e})=>{let[t,n]=react.useState(!1);return react.useEffect(()=>{n(!0);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};var on=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(J)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:i}=u(),{activeChainIds:r,wcSignClients:o}=C(),s=B(i||void 0);return react.useEffect(()=>{if(i){if(!s)return;e&&r?z({onError:n}):!e&&t&&z({onError:n});}},[s]),react.useEffect(()=>{var a,c,d,g,f,A,S,b,I,W,R,h,w,x;if(i){if(!s)return;i==="cosmostation"&&((c=(a=se()).subscription)==null||c.call(a,()=>{z({onError:n});})),i==="keplr"&&((g=(d=ae()).subscription)==null||g.call(d,()=>{z({onError:n});})),i==="leap"&&((A=(f=ce()).subscription)==null||A.call(f,()=>{z({onError:n});})),i==="vectis"&&((b=(S=ue()).subscription)==null||b.call(S,()=>{z({onError:n});})),i==="walletconnect"&&o.has("walletconnect")&&((W=(I=j()).subscription)==null||W.call(I,()=>{z({onError:n});})),i==="station"&&((h=(R=le()).subscription)==null||h.call(R,()=>{z({onError:n});})),i==="xdefi"&&((x=(w=de()).subscription)==null||x.call(w,()=>{z({onError:n});}));}},[i,o,s]),null},Ot=()=>(on(),null);var an=new reactQuery.QueryClient({}),bs=i=>{var r=i,{children:e,grazOptions:t}=r,n=Ue(r,["children","grazOptions"]);return it(t),jsxRuntime.jsx(reactQuery.QueryClientProvider,N(T({client:an},n),{children:jsxRuntime.jsxs(Tt,{children:[e,jsxRuntime.jsx(Ot,{})]})}),"graz-provider")};
|
|
21
|
+
var Nt=Object.defineProperty,Bt=Object.defineProperties;var Kt=Object.getOwnPropertyDescriptors;var se=Object.getOwnPropertySymbols;var Ge=Object.prototype.hasOwnProperty,Fe=Object.prototype.propertyIsEnumerable;var qe=(e,t,n)=>t in e?Nt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,O=(e,t)=>{for(var n in t||(t={}))Ge.call(t,n)&&qe(e,n,t[n]);if(se)for(var n of se(t))Fe.call(t,n)&&qe(e,n,t[n]);return e},N=(e,t)=>Bt(e,Kt(t));var ze=(e,t)=>{var n={};for(var i in e)Ge.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&se)for(var i of se(e))t.indexOf(i)<0&&Fe.call(e,i)&&(n[i]=e[i]);return n};var l=(e,t,n)=>new Promise((i,r)=>{var o=c=>{try{a(n.next(c));}catch(m){r(m);}},s=c=>{try{a(n.throw(c));}catch(m){r(m);}},a=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,s);a((n=n.apply(e,t)).next());});var H="graz-reconnect-session";var Qe=(h=>(h.KEPLR="keplr",h.LEAP="leap",h.VECTIS="vectis",h.COSMOSTATION="cosmostation",h.WALLETCONNECT="walletconnect",h.WC_KEPLR_MOBILE="wc_keplr_mobile",h.WC_LEAP_MOBILE="wc_leap_mobile",h.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",h.METAMASK_SNAP_LEAP="metamask_snap_leap",h.STATION="station",h.XDEFI="xdefi",h.CAPSULE="capsule",h))(Qe||{}),je=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","metamask_snap_leap","station","xdefi","capsule"];var Lt={recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,web3Modal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},Z={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},Ut={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:middleware.createJSONStorage(()=>sessionStorage)},qt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},p=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>Z,Ut))),u=zustand.create(middleware.subscribeWithSelector(middleware.persist(()=>Lt,qt)));var ae=()=>{var E,h;if(!((E=u.getState().capsuleConfig)!=null&&E.apiKey)||!((h=u.getState().capsuleConfig)!=null&&h.env))throw new Error("Capsule configuration is not set");let e=()=>l(void 0,null,function*(){var C,T;let d=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,g=new d({apiKey:(C=u.getState().capsuleConfig)==null?void 0:C.apiKey,env:(T=u.getState().capsuleConfig)==null?void 0:T.env});return p.setState({capsuleClient:g}),g});return {init:e,enable:d=>l(void 0,null,function*(){let g=typeof d=="string"?[d]:d,C=p.getState().capsuleClient;C||(C=yield e()),u.setState({capsuleState:{showModal:!0,chainId:g}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var f;let d=p.getState().capsuleClient,{chains:g}=u.getState();if(!d)throw new Error("Capsule client is not initialized");if(!g)throw new Error("Chains are not set");yield d.enable();let C=(f=u.getState().capsuleState)==null?void 0:f.chainId;if(!C)throw new Error("Chain ids are not set");let T=yield d.getAccount(C[0]),x={};C.forEach(w=>{x[w]={address:encoding.fromBech32(T.address).data,bech32Address:encoding.toBech32(g.find(b=>b.chainId===w).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(T.address).data),algo:T.algo,name:T.username||"",pubKey:T.pubkey,isKeystone:!1,isNanoLedger:!1};}),p.setState(w=>({accounts:O(O({},w.accounts||{}),x)})),u.setState(w=>({recentChainIds:[...w.recentChainIds||[],...C].filter((b,P,D)=>D.indexOf(b)===P)})),p.setState(w=>({activeChainIds:[...w.activeChainIds||[],...C].filter((b,P,D)=>D.indexOf(b)===P)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),p.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active"),u.setState({capsuleState:null});}),getKey:d=>l(void 0,null,function*(){let g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");let C=yield g.getAccount(d);return {address:encoding.fromBech32(C.address).data,bech32Address:C.address,algo:C.algo,name:C.username||"",pubKey:C.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:d=>l(void 0,null,function*(){let g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerDirect(d)}),getOfflineSignerDirect:d=>{let g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerDirect(d)},signDirect:(...d)=>l(void 0,null,function*(){let[g,C,T]=d,x=p.getState().capsuleClient;if(!x)throw new Error("Capsule client is not initialized");return x.signDirect(g,C,{bodyBytes:T.bodyBytes,authInfoBytes:T.authInfoBytes,chainId:T.chainId,accountNumber:T.accountNumber})}),signAmino:(...d)=>l(void 0,null,function*(){let[g,C,T,x]=d,f=p.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.signAmino(g,C,T,x)}),experimentalSuggestChain:(...d)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),setDefaultOptions:()=>{console.log("setDefaultOptions not supported by capsule");},getOfflineSigner:d=>{let g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSigner(d)},getOfflineSignerAmino:d=>{let g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerAmino(d)}}};var ce=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:o=>{var a;let s=()=>{F(),o();};return (a=window.cosmostation)==null||a.cosmos.on("accountChanged",s),()=>{var c;(c=window.cosmostation)==null||c.cosmos.off("accountChanged",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var le=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let o=()=>{F(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var ue=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:r=>{let o=()=>{F(),r();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var de={},Ye=e=>{let t=window.ethereum;if(t&&e){let n=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),i=f=>l(void 0,null,function*(){try{let w=yield n();return Object.values(w).find(b=>b.id===e.id&&(!f||b.version===f))}catch(w){return}}),r=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),o=()=>l(void 0,null,function*(){var B;let f=yield t.request({method:"web3_clientVersion"});if(!f.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let b=(B=f.split("MetaMask/v")[1])==null?void 0:B.split(".")[0];if(!(Number(b)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield i())||(yield r()),!0}),s=f=>l(void 0,null,function*(){(yield i())||(yield r());}),a=(f,w,b)=>l(void 0,null,function*(){let P=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:f,signerAddress:w,signDoc:b}}}}),D=b.accountNumber,B=new Ft__default.default(D.low,D.high,D.unsigned);return {signature:P.signature,signed:N(O({},P.signed),{accountNumber:`${B.toString()}`,authInfoBytes:new Uint8Array(Object.values(P.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(P.signed.bodyBytes))})}}),c=(f,w,b)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:f,signerAddress:w,signDoc:b}}}})}),m=f=>l(void 0,null,function*(){if(typeof de[f]!="undefined")return de[f];let w=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:f}}}});if(!w)throw new Error("No response from Metamask");return w.pubKey=Uint8Array.from(Object.values(w.pubkey)),delete w.pubkey,de[f]=w,de[f]}),A=f=>l(void 0,null,function*(){let w=yield m(f);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),E=(...f)=>l(void 0,null,function*(){let[w,b,P,D]=f;return yield c(w,b,P)}),h=(...f)=>l(void 0,null,function*(){let[w,b,P]=f;return yield a(w,b,P)}),d=f=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(f)]}),signDirect:(w,b)=>h(f,w,b)}),g=f=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(f)]}),signAmino:(w,b)=>E(f,w,b)});return {enable:s,experimentalSuggestChain:(...f)=>l(void 0,null,function*(){yield o(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:f[0]}}}});}),getKey:m,getOfflineSigner:f=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(f)]}),signDirect:(w,b)=>h(f,w,b),signAmino:(w,b)=>E(f,w,b)}),getOfflineSignerAuto:f=>l(void 0,null,function*(){return (yield m(f)).isNanoLedger?g(f):d(f)}),getOfflineSignerOnlyAmino:g,init:o,signAmino:E,signDirect:h}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var Xe=()=>Ye({id:"npm:@leapwallet/metamask-cosmos-snap"});var pe=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:o=>{let s=()=>{F(),o();};return window.addEventListener("station_wallet_change",s),()=>{window.removeEventListener("station_wallet_change",s);}},getKey:o=>l(void 0,null,function*(){let s=yield e.getKey(o);return O({isKeystone:!1},s)}),getOfflineSigner:o=>{try{let s=e.getOfflineSignerOnlyAmino(o);return Object.assign(s,{signDirect:(m,A)=>{throw new Error("signDirect not supported by Station")}})}catch(s){throw console.error(s),s}},experimentalSuggestChain:o=>l(void 0,null,function*(){try{let s=Object.assign(o,{chainSymbolImageUrl:o.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:o.stakeCurrency.coinDecimals,coinDenom:o.stakeCurrency.coinDenom,coinImageUrl:o.stakeCurrency.coinImageUrl||"",coinMinimalDenom:o.stakeCurrency.coinMinimalDenom},currencies:o.currencies.map(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:o.feeCurrencies.map(a=>{var c,m,A;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((c=a.gasPriceStep)==null?void 0:c.average)||0,high:((m=a.gasPriceStep)==null?void 0:m.high)||0,low:((A=a.gasPriceStep)==null?void 0:A.low)||0}}})});yield e.experimentalSuggestChain(s);}catch(s){throw console.error(s),s}}),enable:o=>e.enable(o),disable:o=>e.disable(o),getOfflineSignerAuto:o=>e.getOfflineSignerAuto(o),getOfflineSignerOnlyAmino:o=>e.getOfflineSignerOnlyAmino(o),signDirect:()=>e.signDirect(),signAmino:(o,s,a,c)=>e.signAmino(o,s,a),setDefaultOptions:()=>{console.log("setDefaultOptions not supported by WalletConnect");}}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var me=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:a=>e.enable(a),getOfflineSigner:a=>e.getOfflineSigner(a),getOfflineSignerAuto:a=>e.getOfflineSignerAuto(a),getKey:a=>l(void 0,null,function*(){let c=yield e.getKey(a);return {address:encoding.fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}}),subscription:a=>{let c=()=>{F(),a();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...a)=>e.getOfflineSignerAmino(...a),experimentalSuggestChain:(...a)=>l(void 0,null,function*(){let[c]=a,m=N(O({},c),{rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr});return e.suggestChains([m])}),signDirect:(...a)=>l(void 0,null,function*(){var A;let{1:c,2:m}=a;return e.signDirect(c,{bodyBytes:m.bodyBytes||Uint8Array.from([]),authInfoBytes:m.authInfoBytes||Uint8Array.from([]),accountNumber:Ft__default.default.fromString(((A=m.accountNumber)==null?void 0:A.toString())||"",!1),chainId:m.chainId||""})}),signAmino:(...a)=>l(void 0,null,function*(){let{1:c,2:m}=a;return e.signAmino(c,m)}),setDefaultOptions:()=>{console.log("setDefaultOptions not supported by Vectis");}}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var Q=()=>typeof window!="undefined"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,Je=()=>Q()&&navigator.userAgent.toLowerCase().includes("android"),Ze=()=>Q()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Oe=(e,t,n=new Error("Promise timed out"))=>{let i=new Promise((r,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,i])};var j=e=>{var B,ne,Be;if(!((Be=(ne=(B=u.getState().walletConnect)==null?void 0:B.options)==null?void 0:ne.projectId)!=null&&Be.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",i=y=>{if(!e)return;let{appUrl:S,formatNativeUrl:I}=e;if(Q()){if(Je())if(!y)window.open(S.mobile.android,"_self","noreferrer noopener");else {let v=I(S.mobile.android,y,"android");window.open(v,"_self","noreferrer noopener");}if(Ze())if(!y)window.open(S.mobile.ios,"_self","noreferrer noopener");else {let v=I(S.mobile.ios,y,"ios");window.open(v,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:y}=p.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),p.setState({wcSignClients:y}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},o=y=>l(void 0,null,function*(){let{wcSignClients:S}=p.getState(),I=S.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");if(!y)throw new Error("No wallet connect session");yield I.disconnect({topic:y,reason:utils.getSdkError("USER_DISCONNECTED")}),yield c(I);}),s=y=>{try{let{wcSignClients:S}=p.getState(),I=S.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let v=I.session.getAll().at(-1);if(!v)return;if(!(v.expiry*1e3>Date.now()+1e3))throw o(v.topic),new Error("invalid session");try{let W=I.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:y.map(U=>`cosmos:${U}`),events:["chainChanged","accountsChanged"]}}});if(!W.length)throw new Error("no session");return W.at(-1)}catch(W){if(!W.message.toLowerCase().includes("no matching key"))throw W}return v}catch(S){if(!S.message.toLowerCase().includes("no matching key"))throw S}},a=y=>{try{return s(y)}catch(S){return}},c=y=>l(void 0,null,function*(){try{let S=y.core.pairing.pairings.getAll({active:!1});if(!S.length)return;yield Promise.all(S.map(I=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(I.topic,{code:7001,message:"clear pairing"});})));}catch(S){if(!S.message.toLowerCase().includes("no matching key"))throw S}}),m=()=>l(void 0,null,function*(){let{walletConnect:y}=u.getState();if(!(y!=null&&y.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:S}=p.getState(),I=S.get(t);if(I)return I;let v=yield signClient.SignClient.init(y.options);return S.set(t,v),p.setState({wcSignClients:S}),v}),A=y=>{let{wcSignClients:S}=p.getState(),I=S.get(t);if(!I)return ()=>{};let v=k=>{let W=p.getState().accounts;if(k.params.event.name==="accountsChanged"&&W&&!Object.values(W).map(U=>U.bech32Address).includes(k.params.event.data[0])){let U=k.params.chainId.split(":")[1];U&&E([U]);}else y();};return I.events.on("session_delete",r),I.events.on("session_expire",r),I.events.on("session_event",v),()=>{I.events.off("session_delete",r),I.events.off("session_expire",r),I.events.off("session_event",v);}},E=y=>l(void 0,null,function*(){var oe;let S=typeof y=="string"?[y]:y,{wcSignClients:I}=p.getState(),v=I.get(t);if(!v)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:k,chains:W}=u.getState();if(!((oe=k==null?void 0:k.options)!=null&&oe.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:U}=yield import('@web3modal/standalone'),$=new U(O({projectId:k.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},k.web3Modal)),Y=a(S);if(!Y){let{uri:_,approval:X}=yield Oe(v.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:S.map(G=>`cosmos:${G}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!_)throw new Error("No wallet connect uri");e?i(_):yield $.openModal({uri:_});let ie=G=>l(void 0,null,function*(){return G.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Ee,J)=>{X().then(Ke=>{let _e=Ke.sessionProperties;if(!_e)return J(new Error("No session properties"));let Te=JSON.parse(String(_e.keys));if(Te.length===0)return J(new Error("No accounts"));let Le=Te[0];if(!Le)return J(new Error("No accounts"));let Ue={};return S.forEach(re=>{Ue[re]=N(O({},Le),{bech32Address:encoding.toBech32(W.find(Dt=>Dt.chainId===re).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(Te[0].bech32Address).data)});}),p.setState(re=>({accounts:O(O({},re.accounts||{}),Ue)})),Ee(Ke)}).catch(J),G.addEventListener("abort",()=>{J(new Error("User closed wallet connect"));},{once:!0});})});try{let G=new AbortController,Ee=G.signal;$.subscribeModal(J=>{J.open||G.abort();}),yield ie(Ee);}catch(G){if($.closeModal(),!G.message.toLowerCase().includes("no matching key"))return Promise.reject(G)}return e||$.closeModal(),Promise.resolve()}try{yield Oe((()=>l(void 0,null,function*(){let _=yield d(S[0]),X={};S.forEach(ie=>{X[ie]=N(O({},_),{bech32Address:encoding.toBech32(W.find(G=>G.chainId===ie).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(_.bech32Address).data)});}),p.setState({accounts:X});}))(),15e3,new Error("Connection timeout"));}catch(_){if(o(Y.topic),!_.message.toLowerCase().includes("no matching key"))throw _}}),h=y=>l(void 0,null,function*(){var W;let{wcSignClients:S}=p.getState(),I=S.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let v=(W=s([y]))==null?void 0:W.topic;if(!v)throw new Error("No wallet connect session");let k=yield I.request({topic:v,chainId:`cosmos:${y}`,request:{method:"cosmos_getAccounts",params:{}}});if(!k[0])throw new Error("No wallet connect account");return {address:k[0].address,algo:k[0].algo,pubkey:new Uint8Array(Buffer.from(k[0].pubkey,n))}}),d=y=>l(void 0,null,function*(){let S=s([y]);if(!(S!=null&&S.topic))throw new Error("No wallet connect session");let I=S.sessionProperties&&JSON.parse(String(S.sessionProperties.keys))[0];if(!I)throw new Error("No wallet connect key");return I}),g=(...y)=>l(void 0,null,function*(){var _,X;let[S,I,v]=y,{accounts:k,wcSignClients:W}=p.getState(),U=W.get(t);if(!U)throw new Error("walletConnect.signClient is not defined");if(!k)throw new Error("account is not defined");let $=(_=s([S]))==null?void 0:_.topic;if(!$)throw new Error("No wallet connect session");if(!v.bodyBytes)throw new Error("No bodyBytes");if(!v.authInfoBytes)throw new Error("No authInfoBytes");let Y={topic:$,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:N(O({},v),{bodyBytes:Buffer.from(v.bodyBytes).toString(n),authInfoBytes:Buffer.from(v.authInfoBytes).toString(n),accountNumber:(X=v.accountNumber)==null?void 0:X.toString()})}}};return i(),yield U.request(Y)}),C=(...y)=>l(void 0,null,function*(){let[S,I,v]=y,{signature:k,signed:W}=yield g(S,I,v);return {signed:{chainId:W.chainId,accountNumber:Ft__default.default.fromString(W.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(W.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(W.bodyBytes,n))},signature:k}}),T=(...y)=>l(void 0,null,function*(){var _;let[S,I,v,k]=y,{wcSignClients:W}=p.getState(),U=W.get(t),{accounts:$}=p.getState();if(!U)throw new Error("walletConnect.signClient is not defined");if(!$)throw new Error("account is not defined");let Y=(_=s([S]))==null?void 0:_.topic;if(!Y)throw new Error("No wallet connect session");return i(),yield U.request({topic:Y,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:v}}})}),x=(...y)=>l(void 0,null,function*(){let[S,I,v,k]=y;return yield T(S,I,v)}),f=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield h(y)]}),signDirect:(S,I)=>C(y,S,I)}),w=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield h(y)]}),signAmino:(S,I)=>x(y,S,I)});return {enable:E,disable:y=>l(void 0,null,function*(){var v;let{wcSignClients:S}=p.getState(),I=S.get(t);if(y===void 0){let k=I==null?void 0:I.session.getAll();k!==void 0&&(yield Promise.all(k.map(W=>o(W.topic))));}else typeof y=="string"?yield o((v=s([y]))==null?void 0:v.topic):yield Promise.all(y.map(k=>{var W;return o((W=s([k]))==null?void 0:W.topic)}));(I==null?void 0:I.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...y)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:d,getOfflineSigner:y=>({getAccounts:()=>l(void 0,null,function*(){return [yield h(y)]}),signDirect:(S,I)=>C(y,S,I),signAmino:(S,I)=>x(y,S,I)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield d(y)).isNanoLedger?w(y):f(y)}),getOfflineSignerOnlyAmino:w,signAmino:x,signDirect:C,subscription:A,init:m,setDefaultOptions:()=>{console.log("setDefaultOptions not supported by WalletConnect");}}};var nt=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(r,o,s)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${o}`};return j(e)};var ot=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(r,o,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${c}`;case"android":return `${a}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${a}://wc?uri=${c}`}}};return j(e)};var it=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!Q())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(r,o,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${c}`;case"android":return `${a}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${a}://wc?uri=${c}`}}};return j(e)};var fe=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let o=()=>{F(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:()=>{console.log("setDefaultOptions not supported by Vectis");}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var K=(e=u.getState().walletType)=>{try{return R(e),!0}catch(t){return !1}},F=()=>{window.sessionStorage.removeItem(H),p.setState(Z);},R=(e=u.getState().walletType)=>{var i;let t=(()=>{switch(e){case"keplr":return le();case"leap":return ue();case"cosmostation":return ce();case"vectis":return me();case"walletconnect":return j();case"wc_keplr_mobile":return ot();case"wc_leap_mobile":return it();case"wc_cosmostation_mobile":return nt();case"metamask_snap_leap":return Xe();case"station":return pe();case"xdefi":return fe();case"capsule":return ae();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((i=t.setDefaultOptions)==null||i.call(t,n)),t},oi=()=>Object.fromEntries(je.map(e=>[e,K(e)])),xe=e=>e==="capsule",rt=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var ee=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:i,walletType:r}=u.getState(),o=(e==null?void 0:e.walletType)||r;if(!K(o))throw new Error(`${o} is not available`);let a=R(o),c=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!c)throw new Error("No last known connected chain, connect action requires chain ids");let m=i==null?void 0:i.map(d=>d.chainId);c.forEach(d=>{if(!(m!=null&&m.includes(d)))throw new Error(`Chain ${d} is not provided in GrazProvider`)}),p.setState(d=>{let g=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return d.activeChainIds&&c.filter(T=>{var x;return !((x=d.activeChainIds)!=null&&x.includes(T))}).length>0?{status:"connecting"}:g?{status:"reconnecting"}:{status:"connecting"}});let{accounts:A}=p.getState();if(yield (t=a.init)==null?void 0:t.call(a),xe(o)&&p.getState().capsuleClient&&Object.values(p.getState().accounts||[]).length>0){let d=c.map(x=>i.find(f=>f.chainId===x)),g=p.getState().accounts;p.setState({status:"connecting"});let C=yield a.getKey(c[0]),T={};return c.forEach(x=>{T[x]=N(O({},C),{bech32Address:encoding.toBech32(i.find(f=>f.chainId===x).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(C.bech32Address).data)});}),p.setState(x=>({accounts:O(O({},x.accounts||{}),T)})),u.setState(x=>({recentChainIds:[...x.recentChainIds||[],...c].filter((f,w,b)=>b.indexOf(f)===w)})),p.setState(x=>({activeChainIds:[...x.activeChainIds||[],...c].filter((f,w,b)=>b.indexOf(f)===w)})),p.setState({status:"connected"}),{accounts:g,walletType:o,chains:d}}if(yield a.enable(c),xe(o)){let d=c.map(C=>i.find(T=>T.chainId===C)),g=p.getState().accounts;return p.setState({status:"connecting"}),{accounts:g,walletType:o,chains:d}}if(!rt(o)){let d=yield a.getKey(c[0]),g={};c.forEach(C=>{g[C]=N(O({},d),{bech32Address:encoding.toBech32(i.find(T=>T.chainId===C).bech32Config.bech32PrefixAccAddr,encoding.fromBech32(d.bech32Address).data)});}),p.setState(C=>({accounts:O(O({},C.accounts||{}),g)}));}u.setState(d=>({recentChainIds:[...d.recentChainIds||[],...c].filter((g,C,T)=>T.indexOf(g)===C)})),p.setState(d=>({activeChainIds:[...d.activeChainIds||[],...c].filter((g,C,T)=>T.indexOf(g)===C)})),u.setState({walletType:o,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:o}),p.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(H,"Active");let E=c.map(d=>i.find(g=>g.chainId===d));return {accounts:p.getState().accounts,walletType:o,chains:E}}catch(n){throw console.error("connect ",n),p.getState().accounts===null&&p.setState({status:"disconnected"}),p.getState().accounts&&p.getState().activeChainIds&&p.setState({status:"connected"}),n}}),te=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(H);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=p.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(p.setState(Z),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(p.setState(r=>{var o;return {activeChainIds:(o=r.activeChainIds)==null?void 0:o.filter(s=>!t.includes(s)),accounts:n}}),u.setState(r=>{var o;return {recentChainIds:(o=r.recentChainIds)==null?void 0:o.filter(s=>!t.includes(s))}}));}else p.setState(Z),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},z=e=>l(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:i}=u.getState();try{let o=K(n||void 0);if(t&&o&&n)return yield ee({chainId:t,walletType:n,autoReconnect:i})}catch(o){(r=e==null?void 0:e.onError)==null||r.call(e,o),te();}}),ct=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!K(n))throw new Error(`${n} is not available`);let r=R(n),o=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),a=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:s,offlineSignerAuto:a}});var Me=()=>{u.setState({recentChainIds:null});},Ci=()=>u.getState().recentChainIds,yi=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(i=>t.find(r=>r.chainId===i)))!=null?n:null},Si=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},hi=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},ve=n=>l(void 0,[n],function*({chainInfo:e,walletType:t}){let i=R(t);return t==="capsule"?yield ee({chainId:e.chainId,walletType:t}):yield i.experimentalSuggestChain(e),e}),lt=e=>l(void 0,null,function*(){var i;let t=u.getState().walletType;return yield ve({chainInfo:e.chainInfo,walletType:(i=e.walletType)!=null?i:t}),yield ee({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var ut=e=>(u.setState(t=>({walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,capsuleConfig:e.capsuleConfig||t.capsuleConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var dt=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:i,fee:r,memo:o}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,i,r,o)}),pt=A=>l(void 0,[A],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:i,sourcePort:r,sourceChannel:o,timeoutHeight:s,timeoutTimestamp:a,fee:c,memo:m}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,i,r,o,s,a,c,m)}),mt=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,options:r,label:o,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,o,i,r)}),ft=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,contractAddress:r,funds:o,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,i,s,o)}),gt=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),Ct=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let i=new TextEncoder().encode(t);return n.queryContractRaw(e,i)};var vi=e=>e,Wi=e=>e;var ge=e=>e?Object.keys(e).length===0:!0;var We=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},yt=e=>globalThis.DOMException===void 0?new We(e):new DOMException(e),St=e=>{let t=e.reason===void 0?yt("This operation was aborted."):e.reason;return t instanceof Error?t:yt(t)};function ke(o,s){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:i=!0,signal:r}={}){return new Promise((a,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let m=[],A=[],E=new Map,h=!1,d=!1,g=!1,C=0,T=0,x=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),f=b=>{h=!0,d=!0,c(b);};r&&(r.aborted&&f(St(r)),r.addEventListener("abort",()=>{f(St(r));}));let w=()=>l(this,null,function*(){if(d)return;let b=yield x.next(),P=T;if(T++,b.done){if(g=!0,C===0&&!d){if(!i&&A.length>0){f(new AggregateError(A));return}if(d=!0,E.size===0){a(m);return}let D=[];for(let[B,ne]of m.entries())E.get(B)!==ht&&D.push(ne);a(D);}return}C++,l(this,null,function*(){try{let D=yield b.value;if(d)return;let B=yield t(D,P);B===ht&&E.set(P,B),m[P]=B,C--,yield w();}catch(D){if(i)f(D);else {A.push(D),C--;try{yield w();}catch(B){f(B);}}}});});l(this,null,function*(){for(let b=0;b<n;b++){try{yield w();}catch(P){f(P);break}if(g||h)break}});})})}var ht=Symbol("skip");var L=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let i=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!i):return i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean);case(!t&&!!i):return [i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean)[0]];case(!!t&&!i):return n;default:return [n[0]]}},q=(e,t,n)=>l(void 0,null,function*(){let i=u.getState().multiChainFetchConcurrency;if(e){let o=yield ke(t,n,{concurrency:i});return Object.fromEntries(o.map((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),wt=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((o,s)=>[t[s].chainId,o]))}return n(t[0])};var De=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),i,s=>l(void 0,null,function*(){var A;let a=(A=u.getState().chainsConfig)==null?void 0:A[s.chainId],c={url:s.rpc,headers:O({},(a==null?void 0:a.rpcHeaders)||{})};return yield stargate.StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ne=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=react.useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return reactQuery.useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),i,s=>l(void 0,null,function*(){var A;let a=(A=u.getState().chainsConfig)==null?void 0:A[s.chainId],c={url:s.rpc,headers:O({},(a==null?void 0:a.rpcHeaders)||{})};return yield cosmwasmStargate.CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Ce=({type:e,chainId:t,multiChain:n,enabled:i})=>{let r=L({chainId:t,multiChain:n}),o=react.useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return reactQuery.useQuery({queryKey:o,queryFn:c=>l(void 0,[c],function*({queryKey:[,s,a]}){if(a.length<1)throw new Error("No chains found");return yield q(!!n,a,A=>l(void 0,null,function*(){var C;let E=(C=u.getState().chainsConfig)==null?void 0:C[A.chainId],h={url:A.rpc,headers:O({},(E==null?void 0:E.rpcHeaders)||{})};return yield (s==="tm37"?tendermintRpc.Tendermint37Client:tendermintRpc.Tendermint34Client).connect(h)}))}),enabled:!!r&&r.length>0&&(i!==void 0?!!i:!0),refetchOnWindowFocus:!1})};var or=()=>u(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCapsule:e.walletType==="capsule"}),shallow.shallow),ye=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return reactQuery.useQuery(n,({queryKey:[,r]})=>K(r))};var V=e=>{let t=u(a=>a.walletType),n=p(a=>a.activeChainIds),i=L({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=p(a=>a.accounts),o=p(a=>a.status);return react.useEffect(()=>p.subscribe(a=>a.status,(a,c)=>{var m,A,E;if(a==="connected"){let{accounts:h,activeChainIds:d}=p.getState(),{chains:g}=u.getState(),{walletType:C}=u.getState();if(!h||!d||!g)return (m=e==null?void 0:e.onDisconnect)==null?void 0:m.call(e);(A=e==null?void 0:e.onConnect)==null||A.call(e,{accounts:h,chains:d.map(T=>g.find(x=>x.chainId===T)),walletType:C,isReconnect:c==="reconnecting"});}a==="disconnected"&&((E=e==null?void 0:e.onDisconnect)==null||E.call(e));}),[e]),{data:react.useMemo(()=>r?wt(!!(e!=null&&e.multiChain),i,a=>r[a.chainId]):void 0,[r,i,e==null?void 0:e.multiChain]),isConnected:o==="connected",isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",isLoading:o==="connecting"||o==="reconnecting",walletType:o==="connected"?t:void 0,reconnect:z,status:o}},nn=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=V(),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=De({chainId:t.map(s=>s.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!i}),o=react.useMemo(()=>["USE_ALL_BALANCES",r,t,i,e==null?void 0:e.chainId],[i,e==null?void 0:e.chainId,t,r]);return reactQuery.useQuery(o,m=>l(void 0,[m],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield q(!!(e!=null&&e.multiChain),a,E=>l(void 0,null,function*(){let h=s==null?void 0:s[E.chainId];if(!h)throw new Error(`Client is not ready ${E.chainId}`);return yield h.getAllBalances(encoding.toBech32(E.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),{enabled:!!i&&!!t&&t.length>0&&!ge(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},Cr=e=>{let t=L({chainId:e.chainId}),{data:n}=V({chainId:e.chainId}),i=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:o}=nn({chainId:t.map(c=>c.chainId),bech32Address:i,enabled:!!i&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,i,e.chainId],a=reactQuery.useQuery(s,({queryKey:[,c,m]})=>m==null?void 0:m.find(A=>A.denom===c),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return N(O({},a),{refetch:c=>l(void 0,null,function*(){return yield o(),a.refetch(c)})})},yr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_CONNECT",e,t,n],ee,{onError:(s,a)=>e==null?void 0:e(s,a),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=ye();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status}},Sr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_DISCONNECT",e,t,n],te,{onError:o=>Promise.resolve(e==null?void 0:e(o,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:o=>r.mutate(o),disconnectAsync:o=>r.mutateAsync(o),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},hr=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),i=react.useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return reactQuery.useQuery({queryKey:i,queryFn:s=>l(void 0,[s],function*({queryKey:[,r,o]}){if(r.length<1)throw new Error("No chain found");if(!K(o))throw new Error(`${o} is not available`);return yield q(!!(e!=null&&e.multiChain),r,m=>l(void 0,null,function*(){return yield ct({chainId:m.chainId,walletType:o})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},wr=e=>{let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=V(),{data:i}=De({chainId:t.map(s=>s.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),o=react.useMemo(()=>["USE_BALANCE_STAKED",i,t,r],[t,r,i]);return reactQuery.useQuery(o,m=>l(void 0,[m],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield q(!!(e!=null&&e.multiChain),a,E=>l(void 0,null,function*(){var d;if(!s)throw new Error("Client is not ready");return yield (d=s[E.chainId])==null?void 0:d.getBalanceStaked(encoding.toBech32(E.bech32Config.bech32PrefixAccAddr,encoding.fromBech32(c).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!i,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var xr=()=>{let e=u(i=>i.capsuleState),t=p(i=>i.capsuleClient),n=ae();return {setModalState:i=>{u.setState(r=>{var o;return {capsuleState:{showModal:i,chainId:(o=r.capsuleState)==null?void 0:o.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:n.onAfterLoginSuccessful,onLoginFailure:()=>{te();}}};var Dr=()=>p(e=>e.activeChainIds),on=()=>{var e;return (e=p(t=>t.activeChainIds))==null?void 0:e.map(t=>{var i;let n=(i=u.getState().chains)==null?void 0:i.find(r=>r.chainId===t);if(n)return n}).filter(Boolean)},Nr=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Br=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Kr=({denom:e})=>{let t=on();return reactQuery.useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var o;return (o=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===r)))==null?void 0:o.currencies.find(s=>s)})},_r=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return reactQuery.useQuery(n,a=>l(void 0,[a],function*({queryKey:[,o,s]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(s)}),{enabled:typeof e.queryClient!="undefined"})},Lr=()=>({data:u(t=>t.recentChainIds),clear:Me}),Ur=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let i=(r=u.getState().chains)==null?void 0:r.find(o=>o.chainId===n);if(i)return i}).filter(Boolean),clear:Me}},qr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN",e,t,n],ve,{onError:(o,s)=>Promise.resolve(e==null?void 0:e(o,s.chainInfo)),onMutate:o=>t==null?void 0:t(o.chainInfo),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},Gr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=reactQuery.useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],lt,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=ye();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var Yr=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=V(),r=i==null?void 0:i.bech32Address,o=reactQuery.useMutation(["USE_SEND_TOKENS",e,t,n,r],s=>dt(O({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},Xr=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=V(),r=i==null?void 0:i.bech32Address,o=reactQuery.useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],s=>pt(O({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Jr=({codeId:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=V(),o=r==null?void 0:r.bech32Address,a=reactQuery.useMutation(["USE_INSTANTIATE_CONTRACT",t,n,i,e,o],c=>{var A;if(!o)throw new Error("senderAddress is undefined");let m=N(O({},c),{fee:(A=c.fee)!=null?A:"auto",senderAddress:o,codeId:e});return mt(m)},{onError:(c,m)=>Promise.resolve(t==null?void 0:t(c,m)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},Zr=({contractAddress:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=V(),o=r==null?void 0:r.bech32Address,a=reactQuery.useMutation(["USE_EXECUTE_CONTRACT",t,n,i,e,o],c=>{var A,E,h;if(!o)throw new Error("senderAddress is undefined");let m=N(O({},c),{fee:(A=c.fee)!=null?A:"auto",senderAddress:o,contractAddress:e,memo:(E=c.memo)!=null?E:"",funds:(h=c.funds)!=null?h:[]});return ft(m)},{onError:(c,m)=>Promise.resolve(t==null?void 0:t(c,m)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},es=e=>{let{data:t}=Ne();return reactQuery.useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return gt(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},ts=e=>{let{data:t}=Ne(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return reactQuery.useQuery(n,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return Ct(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function fs(e){let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=p(o=>o.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),o,m=>l(this,null,function*(){var C,T;if(!(i!=null&&i.includes(m.chainId)))return;if(!K(s))throw new Error(`${s} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(m.chainId);default:return R(s).getOfflineSignerAuto(m.chainId)}}))(),h=(C=u.getState().chainsConfig)==null?void 0:C[m.chainId],d={url:m.rpc,headers:O({},(h==null?void 0:h.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield stargate.SigningStargateClient.connectWithSigner(d,E,e!=null&&e.multiChain?(T=e.opts)==null?void 0:T[m.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function gs(e){let t=L({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=p(o=>o.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return reactQuery.useQuery({queryKey:r,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield q(!!(e!=null&&e.multiChain),o,m=>l(this,null,function*(){var T,x;if(!(i!=null&&i.includes(m.chainId)))return;if(!K(s))throw new Error(`${s} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(m.chainId);default:return R(s).getOfflineSignerAuto(m.chainId)}}))(),h=(T=u.getState().chainsConfig)==null?void 0:T[m.chainId],d={url:m.rpc,headers:O({},(h==null?void 0:h.rpcHeaders)||{})},g=h!=null&&h.gas?stargate.GasPrice.fromString(`${h.gas.price}${h.gas.denom}`):void 0;return yield cosmwasmStargate.SigningCosmWasmClient.connectWithSigner(d,E,O({gasPrice:g},e!=null&&e.multiChain?(x=e.opts)==null?void 0:x[m.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Cs(e){let t=L({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),i=p(s=>s.activeChainIds),r=react.useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=Ce({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:c=>l(this,[c],function*({queryKey:[,s,a]}){if(s.length<1)throw new Error("No chains found");return yield q(!!e.multiChain,s,A=>l(this,null,function*(){var C;if(!(i!=null&&i.includes(A.chainId)))return;if(!K(a))throw new Error(`${a} is not available`);if(!o)throw new Error("No tendermint client found");let h=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(a).getOfflineSigner(A.chainId);case"offlineSignerAuto":return R(a).getOfflineSignerAuto(A.chainId);case"offlineSignerOnlyAmino":return R(a).getOfflineSignerOnlyAmino(A.chainId);default:return R(a).getOfflineSignerAuto(A.chainId)}}))(),d=e.multiChain?o[A.chainId]:o;return yield stargate.SigningStargateClient.createWithSigner(d,h,e.multiChain?(C=e.opts)==null?void 0:C[A.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!o&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ys(e){let t=L({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),i=p(a=>a.activeChainIds),r=react.useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=Ce({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:s}=Ce({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return reactQuery.useQuery({queryKey:r,queryFn:m=>l(this,[m],function*({queryKey:[,a,c]}){if(a.length<1)throw new Error("No chains found");return yield q(!!e.multiChain,a,E=>l(this,null,function*(){var f,w;if(!(i!=null&&i.includes(E.chainId)))return;if(!K(c))throw new Error(`${c} is not available`);let d=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(c).getOfflineSigner(E.chainId);case"offlineSignerAuto":return R(c).getOfflineSignerAuto(E.chainId);case"offlineSignerOnlyAmino":return R(c).getOfflineSignerOnlyAmino(E.chainId);default:return R(c).getOfflineSignerAuto(E.chainId)}}))(),g=(f=u.getState().chainsConfig)==null?void 0:f[E.chainId],C=g!=null&&g.gas?stargate.GasPrice.fromString(`${g.gas.price}${g.gas.denom}`):void 0,T=e.multiChain?s==null?void 0:s[E.chainId]:o;if(!T)throw new Error("No tendermint client found");return yield cosmwasmStargate.SigningCosmWasmClient.createWithSigner(T,d,O({gasPrice:C},e.multiChain?(w=e.opts)==null?void 0:w[E.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!o||!ge(s))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var Wt=({children:e})=>{let[t,n]=react.useState(!1);return react.useEffect(()=>{n(!0);},[]),jsxRuntime.jsx(jsxRuntime.Fragment,{children:t?e:null})};var ln=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(H)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:i}=u(),{activeChainIds:r,wcSignClients:o}=p(),s=K(i||void 0);return react.useEffect(()=>{if(i){if(!s)return;e&&r?z({onError:n}):!e&&t&&z({onError:n});}},[s]),react.useEffect(()=>{var a,c,m,A,E,h,d,g,C,T,x,f,w,b;if(i){if(!s)return;i==="cosmostation"&&((c=(a=ce()).subscription)==null||c.call(a,()=>{z({onError:n});})),i==="keplr"&&((A=(m=le()).subscription)==null||A.call(m,()=>{z({onError:n});})),i==="leap"&&((h=(E=ue()).subscription)==null||h.call(E,()=>{z({onError:n});})),i==="vectis"&&((g=(d=me()).subscription)==null||g.call(d,()=>{z({onError:n});})),i==="walletconnect"&&o.has("walletconnect")&&((T=(C=j()).subscription)==null||T.call(C,()=>{z({onError:n});})),i==="station"&&((f=(x=pe()).subscription)==null||f.call(x,()=>{z({onError:n});})),i==="xdefi"&&((b=(w=fe()).subscription)==null||b.call(w,()=>{z({onError:n});}));}},[i,o,s]),null},Rt=()=>(ln(),null);var pn=new reactQuery.QueryClient({}),Fs=i=>{var r=i,{children:e,grazOptions:t}=r,n=ze(r,["children","grazOptions"]);return ut(t),jsxRuntime.jsx(reactQuery.QueryClientProvider,N(O({client:pn},n),{children:jsxRuntime.jsxs(Wt,{children:[e,jsxRuntime.jsx(Rt,{})]})}),"graz-provider")};
|
|
22
22
|
|
|
23
|
-
exports.GrazEvents =
|
|
24
|
-
exports.GrazProvider =
|
|
25
|
-
exports.WALLET_TYPES =
|
|
26
|
-
exports.WalletType =
|
|
27
|
-
exports.checkWallet =
|
|
28
|
-
exports.clearRecentChain =
|
|
23
|
+
exports.GrazEvents = Rt;
|
|
24
|
+
exports.GrazProvider = Fs;
|
|
25
|
+
exports.WALLET_TYPES = je;
|
|
26
|
+
exports.WalletType = Qe;
|
|
27
|
+
exports.checkWallet = K;
|
|
28
|
+
exports.clearRecentChain = Me;
|
|
29
29
|
exports.clearSession = F;
|
|
30
|
-
exports.configureGraz =
|
|
30
|
+
exports.configureGraz = ut;
|
|
31
31
|
exports.connect = ee;
|
|
32
|
-
exports.defineChainInfo =
|
|
33
|
-
exports.defineChains =
|
|
34
|
-
exports.disconnect =
|
|
35
|
-
exports.executeContract =
|
|
36
|
-
exports.getAvailableWallets =
|
|
37
|
-
exports.getChainInfo =
|
|
38
|
-
exports.getChainInfos =
|
|
39
|
-
exports.getCosmostation =
|
|
40
|
-
exports.getKeplr =
|
|
41
|
-
exports.getLeap =
|
|
42
|
-
exports.getMetamaskSnapLeap =
|
|
43
|
-
exports.getOfflineSigners =
|
|
44
|
-
exports.getQueryRaw =
|
|
45
|
-
exports.getQuerySmart =
|
|
46
|
-
exports.getRecentChainIds =
|
|
47
|
-
exports.getRecentChains =
|
|
48
|
-
exports.getVectis =
|
|
49
|
-
exports.getWCCosmostation =
|
|
50
|
-
exports.getWCKeplr =
|
|
51
|
-
exports.getWCLeap =
|
|
52
|
-
exports.getWallet =
|
|
32
|
+
exports.defineChainInfo = Wi;
|
|
33
|
+
exports.defineChains = vi;
|
|
34
|
+
exports.disconnect = te;
|
|
35
|
+
exports.executeContract = ft;
|
|
36
|
+
exports.getAvailableWallets = oi;
|
|
37
|
+
exports.getChainInfo = Si;
|
|
38
|
+
exports.getChainInfos = hi;
|
|
39
|
+
exports.getCosmostation = ce;
|
|
40
|
+
exports.getKeplr = le;
|
|
41
|
+
exports.getLeap = ue;
|
|
42
|
+
exports.getMetamaskSnapLeap = Xe;
|
|
43
|
+
exports.getOfflineSigners = ct;
|
|
44
|
+
exports.getQueryRaw = Ct;
|
|
45
|
+
exports.getQuerySmart = gt;
|
|
46
|
+
exports.getRecentChainIds = Ci;
|
|
47
|
+
exports.getRecentChains = yi;
|
|
48
|
+
exports.getVectis = me;
|
|
49
|
+
exports.getWCCosmostation = nt;
|
|
50
|
+
exports.getWCKeplr = ot;
|
|
51
|
+
exports.getWCLeap = it;
|
|
52
|
+
exports.getWallet = R;
|
|
53
53
|
exports.getWalletConnect = j;
|
|
54
|
-
exports.instantiateContract =
|
|
55
|
-
exports.
|
|
54
|
+
exports.instantiateContract = mt;
|
|
55
|
+
exports.isCapsule = xe;
|
|
56
|
+
exports.isWalletConnect = rt;
|
|
56
57
|
exports.reconnect = z;
|
|
57
|
-
exports.sendIbcTokens =
|
|
58
|
-
exports.sendTokens =
|
|
59
|
-
exports.suggestChain =
|
|
60
|
-
exports.suggestChainAndConnect =
|
|
61
|
-
exports.useAccount =
|
|
62
|
-
exports.useActiveChainCurrency =
|
|
63
|
-
exports.useActiveChainIds =
|
|
64
|
-
exports.useActiveChains =
|
|
65
|
-
exports.useActiveWalletType =
|
|
66
|
-
exports.useBalance =
|
|
67
|
-
exports.useBalanceStaked =
|
|
68
|
-
exports.useBalances =
|
|
69
|
-
exports.
|
|
70
|
-
exports.
|
|
71
|
-
exports.
|
|
72
|
-
exports.
|
|
73
|
-
exports.
|
|
74
|
-
exports.
|
|
75
|
-
exports.
|
|
76
|
-
exports.
|
|
77
|
-
exports.
|
|
78
|
-
exports.
|
|
79
|
-
exports.
|
|
80
|
-
exports.
|
|
81
|
-
exports.
|
|
82
|
-
exports.
|
|
83
|
-
exports.
|
|
84
|
-
exports.
|
|
85
|
-
exports.
|
|
86
|
-
exports.
|
|
87
|
-
exports.
|
|
88
|
-
exports.
|
|
89
|
-
exports.
|
|
90
|
-
exports.
|
|
91
|
-
exports.
|
|
92
|
-
exports.
|
|
93
|
-
exports.
|
|
58
|
+
exports.sendIbcTokens = pt;
|
|
59
|
+
exports.sendTokens = dt;
|
|
60
|
+
exports.suggestChain = ve;
|
|
61
|
+
exports.suggestChainAndConnect = lt;
|
|
62
|
+
exports.useAccount = V;
|
|
63
|
+
exports.useActiveChainCurrency = Kr;
|
|
64
|
+
exports.useActiveChainIds = Dr;
|
|
65
|
+
exports.useActiveChains = on;
|
|
66
|
+
exports.useActiveWalletType = or;
|
|
67
|
+
exports.useBalance = Cr;
|
|
68
|
+
exports.useBalanceStaked = wr;
|
|
69
|
+
exports.useBalances = nn;
|
|
70
|
+
exports.useCapsule = xr;
|
|
71
|
+
exports.useChainInfo = Nr;
|
|
72
|
+
exports.useChainInfos = Br;
|
|
73
|
+
exports.useCheckWallet = ye;
|
|
74
|
+
exports.useConnect = yr;
|
|
75
|
+
exports.useCosmWasmClient = Ne;
|
|
76
|
+
exports.useCosmWasmSigningClient = gs;
|
|
77
|
+
exports.useCosmWasmTmSigningClient = ys;
|
|
78
|
+
exports.useDisconnect = Sr;
|
|
79
|
+
exports.useExecuteContract = Zr;
|
|
80
|
+
exports.useGrazEvents = ln;
|
|
81
|
+
exports.useInstantiateContract = Jr;
|
|
82
|
+
exports.useOfflineSigners = hr;
|
|
83
|
+
exports.useQueryClientValidators = _r;
|
|
84
|
+
exports.useQueryRaw = ts;
|
|
85
|
+
exports.useQuerySmart = es;
|
|
86
|
+
exports.useRecentChainIds = Lr;
|
|
87
|
+
exports.useRecentChains = Ur;
|
|
88
|
+
exports.useSendIbcTokens = Xr;
|
|
89
|
+
exports.useSendTokens = Yr;
|
|
90
|
+
exports.useStargateClient = De;
|
|
91
|
+
exports.useStargateSigningClient = fs;
|
|
92
|
+
exports.useStargateTmSigningClient = Cs;
|
|
93
|
+
exports.useSuggestChain = qr;
|
|
94
|
+
exports.useSuggestChainAndConnect = Gr;
|
|
95
|
+
exports.useTendermintClient = Ce;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { fromBech32, toBech32 } from '@cosmjs/encoding';
|
|
2
2
|
import { create } from 'zustand';
|
|
3
3
|
import { createJSONStorage, subscribeWithSelector, persist } from 'zustand/middleware';
|
|
4
|
-
import
|
|
4
|
+
import zt from 'long';
|
|
5
5
|
import { SignClient } from '@walletconnect/sign-client';
|
|
6
6
|
import { getSdkError } from '@walletconnect/utils';
|
|
7
7
|
import { QueryClient, useQuery, useMutation, QueryClientProvider } from '@tanstack/react-query';
|
|
@@ -12,6 +12,6 @@ import { Tendermint37Client, Tendermint34Client } from '@cosmjs/tendermint-rpc';
|
|
|
12
12
|
import { shallow } from 'zustand/shallow';
|
|
13
13
|
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
14
14
|
|
|
15
|
-
var vt=Object.defineProperty,kt=Object.defineProperties;var Rt=Object.getOwnPropertyDescriptors;var se=Object.getOwnPropertySymbols;var Ke=Object.prototype.hasOwnProperty,Ue=Object.prototype.propertyIsEnumerable;var Le=(e,t,n)=>t in e?vt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,T=(e,t)=>{for(var n in t||(t={}))Ke.call(t,n)&&Le(e,n,t[n]);if(se)for(var n of se(t))Ue.call(t,n)&&Le(e,n,t[n]);return e},_=(e,t)=>kt(e,Rt(t));var qe=(e,t)=>{var n={};for(var i in e)Ke.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&se)for(var i of se(e))t.indexOf(i)<0&&Ue.call(e,i)&&(n[i]=e[i]);return n};var l=(e,t,n)=>new Promise((i,r)=>{var o=c=>{try{a(n.next(c));}catch(d){r(d);}},s=c=>{try{a(n.throw(c));}catch(d){r(d);}},a=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,s);a((n=n.apply(e,t)).next());});var Z="graz-reconnect-session";var Ge=(f=>(f.KEPLR="keplr",f.LEAP="leap",f.VECTIS="vectis",f.COSMOSTATION="cosmostation",f.WALLETCONNECT="walletconnect",f.WC_KEPLR_MOBILE="wc_keplr_mobile",f.WC_LEAP_MOBILE="wc_leap_mobile",f.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",f.METAMASK_SNAP_LEAP="metamask_snap_leap",f.STATION="station",f.XDEFI="xdefi",f))(Ge||{}),Fe=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","metamask_snap_leap","station","xdefi"];var Nt={recentChainIds:null,chains:null,chainsConfig:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,web3Modal:null},_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ee={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map},_t={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:createJSONStorage(()=>sessionStorage)},Bt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector}),version:2},C=create(subscribeWithSelector(persist(()=>ee,_t))),u=create(subscribeWithSelector(persist(()=>Nt,Bt)));var ae=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:r=>{var s;let o=()=>{z(),r();};return (s=window.cosmostation)==null||s.cosmos.on("accountChanged",o),()=>{var a;(a=window.cosmostation)==null||a.cosmos.off("accountChanged",o);}}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var ce=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:i=>{let r=()=>{z(),i();};return window.addEventListener("keplr_keystorechange",r),()=>{window.removeEventListener("keplr_keystorechange",r);}}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var le=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:i=>{let r=()=>{z(),i();};return window.addEventListener("leap_keystorechange",r),()=>{window.removeEventListener("leap_keystorechange",r);}}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var $e=e=>{let t=window.ethereum;if(t&&e){let n=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),i=h=>l(void 0,null,function*(){try{let w=yield n();return Object.values(w).find(M=>M.id===e.id&&(!h||M.version===h))}catch(w){return}}),r=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),o=()=>l(void 0,null,function*(){var B;let h=yield t.request({method:"web3_clientVersion"});if(!h.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let M=(B=h.split("MetaMask/v")[1])==null?void 0:B.split(".")[0];if(!(Number(M)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield i())||(yield r()),!0}),s=h=>l(void 0,null,function*(){(yield i())||(yield r());}),a=(h,w,M)=>l(void 0,null,function*(){let N=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:h,signerAddress:w,signDoc:M}}}}),L=M.accountNumber,B=new Dt(L.low,L.high,L.unsigned);return {signature:N.signature,signed:_(T({},N.signed),{accountNumber:`${B.toString()}`,authInfoBytes:new Uint8Array(Object.values(N.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(N.signed.bodyBytes))})}}),c=(h,w,M)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:h,signerAddress:w,signDoc:M}}}})}),d=h=>l(void 0,null,function*(){let w=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:h}}}});if(!w)throw new Error("No response from Metamask");return w.pubKey=Uint8Array.from(Object.values(w.pubkey)),delete w.pubkey,T({},w)}),g=h=>l(void 0,null,function*(){let w=yield d(h);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),f=(...h)=>l(void 0,null,function*(){let[w,M,N,L]=h;return yield c(w,M,N)}),A=(...h)=>l(void 0,null,function*(){let[w,M,N]=h;return yield a(w,M,N)}),S=h=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(h)]}),signDirect:(w,M)=>A(h,w,M)}),b=h=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(h)]}),signAmino:(w,M)=>f(h,w,M)});return {enable:s,experimentalSuggestChain:(...h)=>l(void 0,null,function*(){yield o(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:h[0]}}}});}),getKey:d,getOfflineSigner:h=>({getAccounts:()=>l(void 0,null,function*(){return [yield g(h)]}),signDirect:(w,M)=>A(h,w,M),signAmino:(w,M)=>f(h,w,M)}),getOfflineSignerAuto:h=>l(void 0,null,function*(){return (yield d(h)).isNanoLedger?b(h):S(h)}),getOfflineSignerOnlyAmino:b,init:o,signAmino:f,signDirect:A}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var He=()=>$e({id:"npm:@leapwallet/metamask-cosmos-snap"});var ue=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:o=>{let s=()=>{z(),o();};return window.addEventListener("station_wallet_change",s),()=>{window.removeEventListener("station_wallet_change",s);}},getKey:o=>l(void 0,null,function*(){let s=yield e.getKey(o);return T({isKeystone:!1},s)}),getOfflineSigner:o=>{try{let s=e.getOfflineSignerOnlyAmino(o);return Object.assign(s,{signDirect:(d,g)=>{throw new Error("signDirect not supported by Station")}})}catch(s){throw console.error(s),s}},experimentalSuggestChain:o=>l(void 0,null,function*(){try{let s=Object.assign(o,{chainSymbolImageUrl:o.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:o.stakeCurrency.coinDecimals,coinDenom:o.stakeCurrency.coinDenom,coinImageUrl:o.stakeCurrency.coinImageUrl||"",coinMinimalDenom:o.stakeCurrency.coinMinimalDenom},currencies:o.currencies.map(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:o.feeCurrencies.map(a=>{var c,d,g;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((c=a.gasPriceStep)==null?void 0:c.average)||0,high:((d=a.gasPriceStep)==null?void 0:d.high)||0,low:((g=a.gasPriceStep)==null?void 0:g.low)||0}}})});yield e.experimentalSuggestChain(s);}catch(s){throw console.error(s),s}}),enable:o=>e.enable(o),disable:o=>e.disable(o),getOfflineSignerAuto:o=>e.getOfflineSignerAuto(o),getOfflineSignerOnlyAmino:o=>e.getOfflineSignerOnlyAmino(o),signDirect:()=>e.signDirect(),signAmino:(o,s,a,c)=>e.signAmino(o,s,a)}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var de=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:a=>e.enable(a),getOfflineSigner:a=>e.getOfflineSigner(a),getOfflineSignerAuto:a=>e.getOfflineSignerAuto(a),getKey:a=>l(void 0,null,function*(){let c=yield e.getKey(a);return {address:fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}}),subscription:a=>{let c=()=>{z(),a();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...a)=>e.getOfflineSignerAmino(...a),experimentalSuggestChain:(...a)=>l(void 0,null,function*(){let[c]=a,d=_(T({},c),{rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr});return e.suggestChains([d])}),signDirect:(...a)=>l(void 0,null,function*(){var g;let{1:c,2:d}=a;return e.signDirect(c,{bodyBytes:d.bodyBytes||Uint8Array.from([]),authInfoBytes:d.authInfoBytes||Uint8Array.from([]),accountNumber:Dt.fromString(((g=d.accountNumber)==null?void 0:g.toString())||"",!1),chainId:d.chainId||""})}),signAmino:(...a)=>l(void 0,null,function*(){let{1:c,2:d}=a;return e.signAmino(c,d)})}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var j=()=>typeof window!="undefined"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,Ve=()=>j()&&navigator.userAgent.toLowerCase().includes("android"),Ye=()=>j()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var Ee=(e,t,n=new Error("Promise timed out"))=>{let i=new Promise((r,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,i])};var $=e=>{var B,ne,Pe;if(!((Pe=(ne=(B=u.getState().walletConnect)==null?void 0:B.options)==null?void 0:ne.projectId)!=null&&Pe.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",i=m=>{if(!e)return;let{appUrl:p,formatNativeUrl:y}=e;if(j()){if(Ve())if(!m)window.open(p.mobile.android,"_self","noreferrer noopener");else {let E=y(p.mobile.android,m,"android");window.open(E,"_self","noreferrer noopener");}if(Ye())if(!m)window.open(p.mobile.ios,"_self","noreferrer noopener");else {let E=y(p.mobile.ios,m,"ios");window.open(E,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:m}=C.getState();if(!m.get(t))throw new Error("walletConnect.signClient is not defined");m.delete(t),C.setState({wcSignClients:m}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},o=m=>l(void 0,null,function*(){let{wcSignClients:p}=C.getState(),y=p.get(t);if(!y)throw new Error("walletConnect.signClient is not defined");if(!m)throw new Error("No wallet connect session");yield y.disconnect({topic:m,reason:getSdkError("USER_DISCONNECTED")}),yield c(y);}),s=m=>{try{let{wcSignClients:p}=C.getState(),y=p.get(t);if(!y)throw new Error("walletConnect.signClient is not defined");let E=y.session.getAll().at(-1);if(!E)return;if(!(E.expiry*1e3>Date.now()+1e3))throw o(E.topic),new Error("invalid session");try{let W=y.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:m.map(q=>`cosmos:${q}`),events:["chainChanged","accountsChanged"]}}});if(!W.length)throw new Error("no session");return W.at(-1)}catch(W){if(!W.message.toLowerCase().includes("no matching key"))throw W}return E}catch(p){if(!p.message.toLowerCase().includes("no matching key"))throw p}},a=m=>{try{return s(m)}catch(p){return}},c=m=>l(void 0,null,function*(){try{let p=m.core.pairing.pairings.getAll({active:!1});if(!p.length)return;yield Promise.all(p.map(y=>l(void 0,null,function*(){yield m.core.pairing.pairings.delete(y.topic,{code:7001,message:"clear pairing"});})));}catch(p){if(!p.message.toLowerCase().includes("no matching key"))throw p}}),d=()=>l(void 0,null,function*(){let{walletConnect:m}=u.getState();if(!(m!=null&&m.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:p}=C.getState(),y=p.get(t);if(y)return y;let E=yield SignClient.init(m.options);return p.set(t,E),C.setState({wcSignClients:p}),E}),g=m=>{let{wcSignClients:p}=C.getState(),y=p.get(t);if(!y)return ()=>{};let E=k=>{let W=C.getState().accounts;if(k.params.event.name==="accountsChanged"&&W&&!Object.values(W).map(q=>q.bech32Address).includes(k.params.event.data[0])){let q=k.params.chainId.split(":")[1];q&&f([q]);}else m();};return y.events.on("session_delete",r),y.events.on("session_expire",r),y.events.on("session_event",E),()=>{y.events.off("session_delete",r),y.events.off("session_expire",r),y.events.off("session_event",E);}},f=m=>l(void 0,null,function*(){var oe;let p=typeof m=="string"?[m]:m,{wcSignClients:y}=C.getState(),E=y.get(t);if(!E)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:k,chains:W}=u.getState();if(!((oe=k==null?void 0:k.options)!=null&&oe.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:q}=yield import('@web3modal/standalone'),H=new q(T({projectId:k.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},k.web3Modal)),Y=a(p);if(!Y){let{uri:K,approval:X}=yield Ee(E.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:p.map(F=>`cosmos:${F}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!K)throw new Error("No wallet connect uri");e?i(K):yield H.openModal({uri:K});let ie=F=>l(void 0,null,function*(){return F.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Ae,J)=>{X().then(Ne=>{let _e=Ne.sessionProperties;if(!_e)return J(new Error("No session properties"));let Ie=JSON.parse(String(_e.keys));if(Ie.length===0)return J(new Error("No accounts"));let Be=Ie[0];if(!Be)return J(new Error("No accounts"));let De={};return p.forEach(re=>{De[re]=_(T({},Be),{bech32Address:toBech32(W.find(Wt=>Wt.chainId===re).bech32Config.bech32PrefixAccAddr,fromBech32(Ie[0].bech32Address).data)});}),C.setState(re=>({accounts:T(T({},re.accounts||{}),De)})),Ae(Ne)}).catch(J),F.addEventListener("abort",()=>{J(new Error("User closed wallet connect"));},{once:!0});})});try{let F=new AbortController,Ae=F.signal;H.subscribeModal(J=>{J.open||F.abort();}),yield ie(Ae);}catch(F){if(H.closeModal(),!F.message.toLowerCase().includes("no matching key"))return Promise.reject(F)}return e||H.closeModal(),Promise.resolve()}try{yield Ee((()=>l(void 0,null,function*(){let K=yield S(p[0]),X={};p.forEach(ie=>{X[ie]=_(T({},K),{bech32Address:toBech32(W.find(F=>F.chainId===ie).bech32Config.bech32PrefixAccAddr,fromBech32(K.bech32Address).data)});}),C.setState({accounts:X});}))(),15e3,new Error("Connection timeout"));}catch(K){if(o(Y.topic),!K.message.toLowerCase().includes("no matching key"))throw K}}),A=m=>l(void 0,null,function*(){var W;let{wcSignClients:p}=C.getState(),y=p.get(t);if(!y)throw new Error("walletConnect.signClient is not defined");let E=(W=s([m]))==null?void 0:W.topic;if(!E)throw new Error("No wallet connect session");let k=yield y.request({topic:E,chainId:`cosmos:${m}`,request:{method:"cosmos_getAccounts",params:{}}});if(!k[0])throw new Error("No wallet connect account");return {address:k[0].address,algo:k[0].algo,pubkey:new Uint8Array(Buffer.from(k[0].pubkey,n))}}),S=m=>l(void 0,null,function*(){let p=s([m]);if(!(p!=null&&p.topic))throw new Error("No wallet connect session");let y=p.sessionProperties&&JSON.parse(String(p.sessionProperties.keys))[0];if(!y)throw new Error("No wallet connect key");return y}),b=(...m)=>l(void 0,null,function*(){var K,X;let[p,y,E]=m,{accounts:k,wcSignClients:W}=C.getState(),q=W.get(t);if(!q)throw new Error("walletConnect.signClient is not defined");if(!k)throw new Error("account is not defined");let H=(K=s([p]))==null?void 0:K.topic;if(!H)throw new Error("No wallet connect session");if(!E.bodyBytes)throw new Error("No bodyBytes");if(!E.authInfoBytes)throw new Error("No authInfoBytes");let Y={topic:H,chainId:`cosmos:${p}`,request:{method:"cosmos_signDirect",params:{signerAddress:y,signDoc:_(T({},E),{bodyBytes:Buffer.from(E.bodyBytes).toString(n),authInfoBytes:Buffer.from(E.authInfoBytes).toString(n),accountNumber:(X=E.accountNumber)==null?void 0:X.toString()})}}};return i(),yield q.request(Y)}),I=(...m)=>l(void 0,null,function*(){let[p,y,E]=m,{signature:k,signed:W}=yield b(p,y,E);return {signed:{chainId:W.chainId,accountNumber:Dt.fromString(W.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(W.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(W.bodyBytes,n))},signature:k}}),v=(...m)=>l(void 0,null,function*(){var K;let[p,y,E,k]=m,{wcSignClients:W}=C.getState(),q=W.get(t),{accounts:H}=C.getState();if(!q)throw new Error("walletConnect.signClient is not defined");if(!H)throw new Error("account is not defined");let Y=(K=s([p]))==null?void 0:K.topic;if(!Y)throw new Error("No wallet connect session");return i(),yield q.request({topic:Y,chainId:`cosmos:${p}`,request:{method:"cosmos_signDirect",params:{signerAddress:y,signDoc:E}}})}),P=(...m)=>l(void 0,null,function*(){let[p,y,E,k]=m;return yield v(p,y,E)}),h=m=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(m)]}),signDirect:(p,y)=>I(m,p,y)}),w=m=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(m)]}),signAmino:(p,y)=>P(m,p,y)});return {enable:f,disable:m=>l(void 0,null,function*(){var E;let{wcSignClients:p}=C.getState(),y=p.get(t);if(m===void 0){let k=y==null?void 0:y.session.getAll();k!==void 0&&(yield Promise.all(k.map(W=>o(W.topic))));}else typeof m=="string"?yield o((E=s([m]))==null?void 0:E.topic):yield Promise.all(m.map(k=>{var W;return o((W=s([k]))==null?void 0:W.topic)}));(y==null?void 0:y.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...m)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:S,getOfflineSigner:m=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(m)]}),signDirect:(p,y)=>I(m,p,y),signAmino:(p,y)=>P(m,p,y)}),getOfflineSignerAuto:m=>l(void 0,null,function*(){return (yield S(m)).isNanoLedger?w(m):h(m)}),getOfflineSignerOnlyAmino:w,signAmino:P,signDirect:I,subscription:g,init:d}};var Ze=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!j())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(r,o,s)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${o}`};return $(e)};var et=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!j())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(r,o,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${c}`;case"android":return `${a}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${a}://wc?uri=${c}`}}};return $(e)};var tt=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!j())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(r,o,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${c}`;case"android":return `${a}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${a}://wc?uri=${c}`}}};return $(e)};var me=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let o=()=>{z(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var D=(e=u.getState().walletType)=>{try{return R(e),!0}catch(t){return !1}},z=()=>{window.sessionStorage.removeItem(Z),C.setState(ee);},R=(e=u.getState().walletType)=>{switch(e){case"keplr":return ce();case"leap":return le();case"cosmostation":return ae();case"vectis":return de();case"walletconnect":return $();case"wc_keplr_mobile":return et();case"wc_leap_mobile":return tt();case"wc_cosmostation_mobile":return Ze();case"metamask_snap_leap":return He();case"station":return ue();case"xdefi":return me();default:throw new Error("Unknown wallet type")}},jo=()=>Object.fromEntries(Fe.map(e=>[e,D(e)])),nt=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var te=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:i,walletType:r}=u.getState(),o=(e==null?void 0:e.walletType)||r;if(!D(o))throw new Error(`${o} is not available`);let a=R(o),c=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!c)throw new Error("No last known connected chain, connect action requires chain ids");let d=i==null?void 0:i.map(S=>S.chainId);c.forEach(S=>{if(!(d!=null&&d.includes(S)))throw new Error(`Chain ${S} is not provided in GrazProvider`)}),C.setState(S=>{let b=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return S.activeChainIds&&c.filter(v=>{var P;return !((P=S.activeChainIds)!=null&&P.includes(v))}).length>0?{status:"connecting"}:b?{status:"reconnecting"}:{status:"connecting"}});let{accounts:g}=C.getState();if(yield (t=a.init)==null?void 0:t.call(a),yield a.enable(c),!nt(o)){let S=yield a.getKey(c[0]),b={};c.forEach(I=>{b[I]=_(T({},S),{bech32Address:toBech32(i.find(v=>v.chainId===I).bech32Config.bech32PrefixAccAddr,fromBech32(S.bech32Address).data)});}),C.setState(I=>({accounts:T(T({},I.accounts||{}),b)}));}u.setState(S=>({recentChainIds:[...S.recentChainIds||[],...c].filter((b,I,v)=>v.indexOf(b)===I)})),C.setState(S=>({activeChainIds:[...S.activeChainIds||[],...c].filter((b,I,v)=>v.indexOf(b)===I)})),u.setState({walletType:o,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:o}),C.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(Z,"Active");let f=c.map(S=>i.find(b=>b.chainId===S));return {accounts:C.getState().accounts,walletType:o,chains:f}}catch(n){throw console.error("connect ",n),C.getState().accounts===null&&C.setState({status:"disconnected"}),C.getState().accounts&&C.getState().activeChainIds&&C.setState({status:"connected"}),n}}),Te=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(Z);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=C.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(C.setState(ee),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(C.setState(r=>{var o;return {activeChainIds:(o=r.activeChainIds)==null?void 0:o.filter(s=>!t.includes(s)),accounts:n}}),u.setState(r=>{var o;return {recentChainIds:(o=r.recentChainIds)==null?void 0:o.filter(s=>!t.includes(s))}}));}else C.setState(ee),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},Q=e=>l(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:i}=u.getState();try{let o=D(n||void 0);if(t&&o&&n)return yield te({chainId:t,walletType:n,autoReconnect:i})}catch(o){(r=e==null?void 0:e.onError)==null||r.call(e,o),Te();}}),ot=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!D(n))throw new Error(`${n} is not available`);let r=R(n),o=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),a=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:s,offlineSignerAuto:a}});var be=()=>{u.setState({recentChainIds:null});},ri=()=>u.getState().recentChainIds,si=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(i=>t.find(r=>r.chainId===i)))!=null?n:null},ai=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},ci=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},Oe=n=>l(void 0,[n],function*({chainInfo:e,walletType:t}){return yield R(t).experimentalSuggestChain(e),e}),it=e=>l(void 0,null,function*(){var i;let t=u.getState().walletType;return yield Oe({chainInfo:e.chainInfo,walletType:(i=e.walletType)!=null?i:t}),yield te({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var rt=e=>(u.setState(t=>({walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var st=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:i,fee:r,memo:o}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,i,r,o)}),at=g=>l(void 0,[g],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:i,sourcePort:r,sourceChannel:o,timeoutHeight:s,timeoutTimestamp:a,fee:c,memo:d}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,i,r,o,s,a,c,d)}),ct=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,options:r,label:o,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,o,i,r)}),lt=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,contractAddress:r,funds:o,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,i,s,o)}),ut=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),dt=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let i=new TextEncoder().encode(t);return n.queryContractRaw(e,i)};var hi=e=>e,Si=e=>e;var pe=e=>e?Object.keys(e).length===0:!0;var xe=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},mt=e=>globalThis.DOMException===void 0?new xe(e):new DOMException(e),pt=e=>{let t=e.reason===void 0?mt("This operation was aborted."):e.reason;return t instanceof Error?t:mt(t)};function Me(o,s){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:i=!0,signal:r}={}){return new Promise((a,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let d=[],g=[],f=new Map,A=!1,S=!1,b=!1,I=0,v=0,P=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),h=M=>{A=!0,S=!0,c(M);};r&&(r.aborted&&h(pt(r)),r.addEventListener("abort",()=>{h(pt(r));}));let w=()=>l(this,null,function*(){if(S)return;let M=yield P.next(),N=v;if(v++,M.done){if(b=!0,I===0&&!S){if(!i&&g.length>0){h(new AggregateError(g));return}if(S=!0,f.size===0){a(d);return}let L=[];for(let[B,ne]of d.entries())f.get(B)!==ft&&L.push(ne);a(L);}return}I++,l(this,null,function*(){try{let L=yield M.value;if(S)return;let B=yield t(L,N);B===ft&&f.set(N,B),d[N]=B,I--,yield w();}catch(L){if(i)h(L);else {g.push(L),I--;try{yield w();}catch(B){h(B);}}}});});l(this,null,function*(){for(let M=0;M<n;M++){try{yield w();}catch(N){h(N);break}if(b||A)break}});})})}var ft=Symbol("skip");var U=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let i=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!i):return i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean);case(!t&&!!i):return [i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean)[0]];case(!!t&&!i):return n;default:return [n[0]]}},G=(e,t,n)=>l(void 0,null,function*(){let i=u.getState().multiChainFetchConcurrency;if(e){let o=yield Me(t,n,{concurrency:i});return Object.fromEntries(o.map((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),gt=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((o,s)=>[t[s].chainId,o]))}return n(t[0])};var ke=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,s=>l(void 0,null,function*(){var g;let a=(g=u.getState().chainsConfig)==null?void 0:g[s.chainId],c={url:s.rpc,headers:T({},(a==null?void 0:a.rpcHeaders)||{})};return yield StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Re=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,s=>l(void 0,null,function*(){var g;let a=(g=u.getState().chainsConfig)==null?void 0:g[s.chainId],c={url:s.rpc,headers:T({},(a==null?void 0:a.rpcHeaders)||{})};return yield CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},fe=({type:e,chainId:t,multiChain:n,enabled:i})=>{let r=U({chainId:t,multiChain:n}),o=useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return useQuery({queryKey:o,queryFn:c=>l(void 0,[c],function*({queryKey:[,s,a]}){if(a.length<1)throw new Error("No chains found");return yield G(!!n,a,g=>l(void 0,null,function*(){var I;let f=(I=u.getState().chainsConfig)==null?void 0:I[g.chainId],A={url:g.rpc,headers:T({},(f==null?void 0:f.rpcHeaders)||{})};return yield (s==="tm37"?Tendermint37Client:Tendermint34Client).connect(A)}))}),enabled:!!r&&r.length>0&&(i!==void 0?!!i:!0),refetchOnWindowFocus:!1})};var ji=()=>u(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station"}),shallow),ge=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return useQuery(n,({queryKey:[,r]})=>D(r))};var V=e=>{let t=u(a=>a.walletType),n=C(a=>a.activeChainIds),i=U({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=C(a=>a.accounts),o=C(a=>a.status);return useEffect(()=>C.subscribe(a=>a.status,(a,c)=>{var d,g,f;if(a==="connected"){let{accounts:A,activeChainIds:S}=C.getState(),{chains:b}=u.getState(),{walletType:I}=u.getState();if(!A||!S||!b)return (d=e==null?void 0:e.onDisconnect)==null?void 0:d.call(e);(g=e==null?void 0:e.onConnect)==null||g.call(e,{accounts:A,chains:S.map(v=>b.find(P=>P.chainId===v)),walletType:I,isReconnect:c==="reconnecting"});}a==="disconnected"&&((f=e==null?void 0:e.onDisconnect)==null||f.call(e));}),[e]),{data:useMemo(()=>r?gt(!!(e!=null&&e.multiChain),i,a=>r[a.chainId]):void 0,[r,i,e==null?void 0:e.multiChain]),isConnected:o==="connected",isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",isLoading:o==="connecting"||o==="reconnecting",walletType:o==="connected"?t:void 0,reconnect:Q,status:o}},Jt=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=V(),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=ke({chainId:t.map(s=>s.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!i}),o=useMemo(()=>["USE_ALL_BALANCES",r,t,i,e==null?void 0:e.chainId],[i,e==null?void 0:e.chainId,t,r]);return useQuery(o,d=>l(void 0,[d],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),a,f=>l(void 0,null,function*(){let A=s==null?void 0:s[f.chainId];if(!A)throw new Error(`Client is not ready ${f.chainId}`);return yield A.getAllBalances(toBech32(f.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),{enabled:!!i&&!!t&&t.length>0&&!pe(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},rr=e=>{let t=U({chainId:e.chainId}),{data:n}=V({chainId:e.chainId}),i=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:o}=Jt({chainId:t.map(c=>c.chainId),bech32Address:i,enabled:!!i&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,i,e.chainId],a=useQuery(s,({queryKey:[,c,d]})=>d==null?void 0:d.find(g=>g.denom===c),{enabled:!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return _(T({},a),{refetch:c=>l(void 0,null,function*(){return yield o(),a.refetch(c)})})},sr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_CONNECT",e,t,n],te,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=ge();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status}},ar=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_DISCONNECT",e,t,n],Te,{onError:o=>Promise.resolve(e==null?void 0:e(o,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:o=>r.mutate(o),disconnectAsync:o=>r.mutateAsync(o),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},cr=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),i=useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return useQuery({queryKey:i,queryFn:s=>l(void 0,[s],function*({queryKey:[,r,o]}){if(r.length<1)throw new Error("No chain found");if(!D(o))throw new Error(`${o} is not available`);return yield G(!!(e!=null&&e.multiChain),r,d=>l(void 0,null,function*(){return yield ot({chainId:d.chainId,walletType:o})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},lr=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=V(),{data:i}=ke({chainId:t.map(s=>s.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),o=useMemo(()=>["USE_BALANCE_STAKED",i,t,r],[t,r,i]);return useQuery(o,d=>l(void 0,[d],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),a,f=>l(void 0,null,function*(){var S;if(!s)throw new Error("Client is not ready");return yield (S=s[f.chainId])==null?void 0:S.getBalanceStaked(toBech32(f.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!i,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var Cr=()=>C(e=>e.activeChainIds),Zt=()=>{var e;return (e=C(t=>t.activeChainIds))==null?void 0:e.map(t=>{var i;let n=(i=u.getState().chains)==null?void 0:i.find(r=>r.chainId===t);if(n)return n}).filter(Boolean)},hr=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Sr=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},wr=({denom:e})=>{let t=Zt();return useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var o;return (o=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===r)))==null?void 0:o.currencies.find(s=>s)})},Ar=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery(n,a=>l(void 0,[a],function*({queryKey:[,o,s]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(s)}),{enabled:typeof e.queryClient!="undefined"})},Ir=()=>({data:u(t=>t.recentChainIds),clear:be}),Er=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let i=(r=u.getState().chains)==null?void 0:r.find(o=>o.chainId===n);if(i)return i}).filter(Boolean),clear:be}},Tr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN",e,t,n],Oe,{onError:(o,s)=>Promise.resolve(e==null?void 0:e(o,s.chainInfo)),onMutate:o=>t==null?void 0:t(o.chainInfo),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},br=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],it,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=ge();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var Pr=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=V(),r=i==null?void 0:i.bech32Address,o=useMutation(["USE_SEND_TOKENS",e,t,n,r],s=>st(T({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},Nr=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=V(),r=i==null?void 0:i.bech32Address,o=useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],s=>at(T({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},_r=({codeId:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=V(),o=r==null?void 0:r.bech32Address,a=useMutation(["USE_INSTANTIATE_CONTRACT",t,n,i,e,o],c=>{var g;if(!o)throw new Error("senderAddress is undefined");let d=_(T({},c),{fee:(g=c.fee)!=null?g:"auto",senderAddress:o,codeId:e});return ct(d)},{onError:(c,d)=>Promise.resolve(t==null?void 0:t(c,d)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},Br=({contractAddress:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=V(),o=r==null?void 0:r.bech32Address,a=useMutation(["USE_EXECUTE_CONTRACT",t,n,i,e,o],c=>{var g,f,A;if(!o)throw new Error("senderAddress is undefined");let d=_(T({},c),{fee:(g=c.fee)!=null?g:"auto",senderAddress:o,contractAddress:e,memo:(f=c.memo)!=null?f:"",funds:(A=c.funds)!=null?A:[]});return lt(d)},{onError:(c,d)=>Promise.resolve(t==null?void 0:t(c,d)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},Dr=e=>{let{data:t}=Re();return useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return ut(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},Lr=e=>{let{data:t}=Re(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery(n,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return dt(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function Xr(e){let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=C(o=>o.activeChainIds),r=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return useQuery({queryKey:r,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,d=>l(this,null,function*(){var I,v;if(!(i!=null&&i.includes(d.chainId)))return;if(!D(s))throw new Error(`${s} is not available`);let f=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(d.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(d.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(d.chainId);default:return R(s).getOfflineSignerAuto(d.chainId)}}))(),A=(I=u.getState().chainsConfig)==null?void 0:I[d.chainId],S={url:d.rpc,headers:T({},(A==null?void 0:A.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield SigningStargateClient.connectWithSigner(S,f,e!=null&&e.multiChain?(v=e.opts)==null?void 0:v[d.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Jr(e){let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=C(o=>o.activeChainIds),r=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return useQuery({queryKey:r,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,d=>l(this,null,function*(){var v,P;if(!(i!=null&&i.includes(d.chainId)))return;if(!D(s))throw new Error(`${s} is not available`);let f=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return R(s).getOfflineSigner(d.chainId);case"offlineSignerAuto":return R(s).getOfflineSignerAuto(d.chainId);case"offlineSignerOnlyAmino":return R(s).getOfflineSignerOnlyAmino(d.chainId);default:return R(s).getOfflineSignerAuto(d.chainId)}}))(),A=(v=u.getState().chainsConfig)==null?void 0:v[d.chainId],S={url:d.rpc,headers:T({},(A==null?void 0:A.rpcHeaders)||{})},b=A!=null&&A.gas?GasPrice.fromString(`${A.gas.price}${A.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(S,f,T({gasPrice:b},e!=null&&e.multiChain?(P=e.opts)==null?void 0:P[d.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Zr(e){let t=U({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),i=C(s=>s.activeChainIds),r=useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=fe({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return useQuery({queryKey:r,queryFn:c=>l(this,[c],function*({queryKey:[,s,a]}){if(s.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,s,g=>l(this,null,function*(){var I;if(!(i!=null&&i.includes(g.chainId)))return;if(!D(a))throw new Error(`${a} is not available`);if(!o)throw new Error("No tendermint client found");let A=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(a).getOfflineSigner(g.chainId);case"offlineSignerAuto":return R(a).getOfflineSignerAuto(g.chainId);case"offlineSignerOnlyAmino":return R(a).getOfflineSignerOnlyAmino(g.chainId);default:return R(a).getOfflineSignerAuto(g.chainId)}}))(),S=e.multiChain?o[g.chainId]:o;return yield SigningStargateClient.createWithSigner(S,A,e.multiChain?(I=e.opts)==null?void 0:I[g.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!o&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function es(e){let t=U({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),i=C(a=>a.activeChainIds),r=useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=fe({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:s}=fe({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return useQuery({queryKey:r,queryFn:d=>l(this,[d],function*({queryKey:[,a,c]}){if(a.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,a,f=>l(this,null,function*(){var h,w;if(!(i!=null&&i.includes(f.chainId)))return;if(!D(c))throw new Error(`${c} is not available`);let S=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return R(c).getOfflineSigner(f.chainId);case"offlineSignerAuto":return R(c).getOfflineSignerAuto(f.chainId);case"offlineSignerOnlyAmino":return R(c).getOfflineSignerOnlyAmino(f.chainId);default:return R(c).getOfflineSignerAuto(f.chainId)}}))(),b=(h=u.getState().chainsConfig)==null?void 0:h[f.chainId],I=b!=null&&b.gas?GasPrice.fromString(`${b.gas.price}${b.gas.denom}`):void 0,v=e.multiChain?s==null?void 0:s[f.chainId]:o;if(!v)throw new Error("No tendermint client found");return yield SigningCosmWasmClient.createWithSigner(v,S,T({gasPrice:I},e.multiChain?(w=e.opts)==null?void 0:w[f.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!o||!pe(s))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var bt=({children:e})=>{let[t,n]=useState(!1);return useEffect(()=>{n(!0);},[]),jsx(Fragment,{children:t?e:null})};var rn=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(Z)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:i}=u(),{activeChainIds:r,wcSignClients:o}=C(),s=D(i||void 0);return useEffect(()=>{if(i){if(!s)return;e&&r?Q({onError:n}):!e&&t&&Q({onError:n});}},[s]),useEffect(()=>{var a,c,d,g,f,A,S,b,I,v,P,h,w,M;if(i){if(!s)return;i==="cosmostation"&&((c=(a=ae()).subscription)==null||c.call(a,()=>{Q({onError:n});})),i==="keplr"&&((g=(d=ce()).subscription)==null||g.call(d,()=>{Q({onError:n});})),i==="leap"&&((A=(f=le()).subscription)==null||A.call(f,()=>{Q({onError:n});})),i==="vectis"&&((b=(S=de()).subscription)==null||b.call(S,()=>{Q({onError:n});})),i==="walletconnect"&&o.has("walletconnect")&&((v=(I=$()).subscription)==null||v.call(I,()=>{Q({onError:n});})),i==="station"&&((h=(P=ue()).subscription)==null||h.call(P,()=>{Q({onError:n});})),i==="xdefi"&&((M=(w=me()).subscription)==null||M.call(w,()=>{Q({onError:n});}));}},[i,o,s]),null},xt=()=>(rn(),null);var cn=new QueryClient({}),Os=i=>{var r=i,{children:e,grazOptions:t}=r,n=qe(r,["children","grazOptions"]);return rt(t),jsx(QueryClientProvider,_(T({client:cn},n),{children:jsxs(bt,{children:[e,jsx(xt,{})]})}),"graz-provider")};
|
|
15
|
+
var Bt=Object.defineProperty,Kt=Object.defineProperties;var _t=Object.getOwnPropertyDescriptors;var ae=Object.getOwnPropertySymbols;var Fe=Object.prototype.hasOwnProperty,ze=Object.prototype.propertyIsEnumerable;var Ge=(e,t,n)=>t in e?Bt(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,O=(e,t)=>{for(var n in t||(t={}))Fe.call(t,n)&&Ge(e,n,t[n]);if(ae)for(var n of ae(t))ze.call(t,n)&&Ge(e,n,t[n]);return e},B=(e,t)=>Kt(e,_t(t));var Qe=(e,t)=>{var n={};for(var i in e)Fe.call(e,i)&&t.indexOf(i)<0&&(n[i]=e[i]);if(e!=null&&ae)for(var i of ae(e))t.indexOf(i)<0&&ze.call(e,i)&&(n[i]=e[i]);return n};var l=(e,t,n)=>new Promise((i,r)=>{var o=c=>{try{a(n.next(c));}catch(m){r(m);}},s=c=>{try{a(n.throw(c));}catch(m){r(m);}},a=c=>c.done?i(c.value):Promise.resolve(c.value).then(o,s);a((n=n.apply(e,t)).next());});var V="graz-reconnect-session";var je=(h=>(h.KEPLR="keplr",h.LEAP="leap",h.VECTIS="vectis",h.COSMOSTATION="cosmostation",h.WALLETCONNECT="walletconnect",h.WC_KEPLR_MOBILE="wc_keplr_mobile",h.WC_LEAP_MOBILE="wc_leap_mobile",h.WC_COSMOSTATION_MOBILE="wc_cosmostation_mobile",h.METAMASK_SNAP_LEAP="metamask_snap_leap",h.STATION="station",h.XDEFI="xdefi",h.CAPSULE="capsule",h))(je||{}),$e=["keplr","leap","vectis","cosmostation","walletconnect","wc_keplr_mobile","wc_leap_mobile","wc_cosmostation_mobile","metamask_snap_leap","station","xdefi","capsule"];var Ut={recentChainIds:null,chains:null,chainsConfig:null,capsuleConfig:null,capsuleState:null,multiChainFetchConcurrency:3,walletType:"keplr",walletConnect:{options:null,web3Modal:null},walletDefaultOptions:null,_notFoundFn:()=>null,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ee={accounts:null,activeChainIds:null,status:"disconnected",wcSignClients:new Map,capsuleClient:null},qt={name:"graz-session",version:2,partialize:e=>({accounts:e.accounts,activeChainIds:e.activeChainIds}),storage:createJSONStorage(()=>sessionStorage)},Gt={name:"graz-internal",partialize:e=>({recentChainIds:e.recentChainIds,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector,walletType:e.walletType}),version:2},p=create(subscribeWithSelector(persist(()=>ee,qt))),u=create(subscribeWithSelector(persist(()=>Ut,Gt)));var ce=()=>{var E,h;if(!((E=u.getState().capsuleConfig)!=null&&E.apiKey)||!((h=u.getState().capsuleConfig)!=null&&h.env))throw new Error("Capsule configuration is not set");let e=()=>l(void 0,null,function*(){var C,T;let d=(yield import('@leapwallet/cosmos-social-login-capsule-provider')).CapsuleProvider,g=new d({apiKey:(C=u.getState().capsuleConfig)==null?void 0:C.apiKey,env:(T=u.getState().capsuleConfig)==null?void 0:T.env});return p.setState({capsuleClient:g}),g});return {init:e,enable:d=>l(void 0,null,function*(){let g=typeof d=="string"?[d]:d,C=p.getState().capsuleClient;C||(C=yield e()),u.setState({capsuleState:{showModal:!0,chainId:g}});}),onAfterLoginSuccessful:()=>l(void 0,null,function*(){var f;let d=p.getState().capsuleClient,{chains:g}=u.getState();if(!d)throw new Error("Capsule client is not initialized");if(!g)throw new Error("Chains are not set");yield d.enable();let C=(f=u.getState().capsuleState)==null?void 0:f.chainId;if(!C)throw new Error("Chain ids are not set");let T=yield d.getAccount(C[0]),x={};C.forEach(w=>{x[w]={address:fromBech32(T.address).data,bech32Address:toBech32(g.find(b=>b.chainId===w).bech32Config.bech32PrefixAccAddr,fromBech32(T.address).data),algo:T.algo,name:T.username||"",pubKey:T.pubkey,isKeystone:!1,isNanoLedger:!1};}),p.setState(w=>({accounts:O(O({},w.accounts||{}),x)})),u.setState(w=>({recentChainIds:[...w.recentChainIds||[],...C].filter((b,D,N)=>N.indexOf(b)===D)})),p.setState(w=>({activeChainIds:[...w.activeChainIds||[],...C].filter((b,D,N)=>N.indexOf(b)===D)})),u.setState({walletType:"capsule",_reconnect:!1,_reconnectConnector:"capsule"}),p.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active"),u.setState({capsuleState:null});}),getKey:d=>l(void 0,null,function*(){let g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");let C=yield g.getAccount(d);return {address:fromBech32(C.address).data,bech32Address:C.address,algo:C.algo,name:C.username||"",pubKey:C.pubkey,isKeystone:!1,isNanoLedger:!1}}),getOfflineSignerAuto:d=>l(void 0,null,function*(){let g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerDirect(d)}),getOfflineSignerDirect:d=>{let g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerDirect(d)},signDirect:(...d)=>l(void 0,null,function*(){let[g,C,T]=d,x=p.getState().capsuleClient;if(!x)throw new Error("Capsule client is not initialized");return x.signDirect(g,C,{bodyBytes:T.bodyBytes,authInfoBytes:T.authInfoBytes,chainId:T.chainId,accountNumber:T.accountNumber})}),signAmino:(...d)=>l(void 0,null,function*(){let[g,C,T,x]=d,f=p.getState().capsuleClient;if(!f)throw new Error("Capsule client is not initialized");return f.signAmino(g,C,T,x)}),experimentalSuggestChain:(...d)=>l(void 0,null,function*(){yield Promise.reject(new Error("Capsule does not support experimentalSuggestChain"));}),setDefaultOptions:()=>{console.log("setDefaultOptions not supported by capsule");},getOfflineSigner:d=>{let g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSigner(d)},getOfflineSignerAmino:d=>{let g=p.getState().capsuleClient;if(!g)throw new Error("Capsule client is not initialized");return g.getOfflineSignerAmino(d)}}};var le=()=>{var e;if(typeof((e=window.cosmostation)==null?void 0:e.providers.keplr)!="undefined"){let t=window.cosmostation.providers.keplr;return Object.assign(t,{subscription:o=>{var a;let s=()=>{z(),o();};return (a=window.cosmostation)==null||a.cosmos.on("accountChanged",s),()=>{var c;(c=window.cosmostation)==null||c.cosmos.off("accountChanged",s);}},setDefaultOptions:o=>{t.defaultOptions=o;}})}throw u.getState()._notFoundFn(),new Error("window.cosmostation.providers.keplr is not defined")};var ue=()=>{if(typeof window.keplr!="undefined"){let e=window.keplr;return Object.assign(e,{subscription:r=>{let o=()=>{z(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.keplr is not defined")};var de=()=>{if(typeof window.leap!="undefined"){let e=window.leap;return Object.assign(e,{subscription:r=>{let o=()=>{z(),r();};return window.addEventListener("leap_keystorechange",o),()=>{window.removeEventListener("leap_keystorechange",o);}},setDefaultOptions:r=>{e.defaultOptions=r;}})}throw u.getState()._notFoundFn(),new Error("window.leap is not defined")};var pe={},Xe=e=>{let t=window.ethereum;if(t&&e){let n=()=>l(void 0,null,function*(){return yield t.request({method:"wallet_getSnaps"})}),i=f=>l(void 0,null,function*(){try{let w=yield n();return Object.values(w).find(b=>b.id===e.id&&(!f||b.version===f))}catch(w){return}}),r=()=>l(void 0,null,function*(){yield t.request({method:"wallet_requestSnaps",params:{[e.id]:e.params||{}}});}),o=()=>l(void 0,null,function*(){var K;let f=yield t.request({method:"web3_clientVersion"});if(!f.includes("MetaMask"))throw new Error("Metamask is not installed");if(typeof window.okxwallet!="undefined"&&window.okxwallet.isOkxWallet)throw new Error("You have OKX Wallet installed. Please disable and reload the page to use Metamask Snap.");let b=(K=f.split("MetaMask/v")[1])==null?void 0:K.split(".")[0];if(!(Number(b)>=11))throw new Error("Metamask Snap is not supported in this version");return (yield i())||(yield r()),!0}),s=f=>l(void 0,null,function*(){(yield i())||(yield r());}),a=(f,w,b)=>l(void 0,null,function*(){let D=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signDirect",params:{chainId:f,signerAddress:w,signDoc:b}}}}),N=b.accountNumber,K=new zt(N.low,N.high,N.unsigned);return {signature:D.signature,signed:B(O({},D.signed),{accountNumber:`${K.toString()}`,authInfoBytes:new Uint8Array(Object.values(D.signed.authInfoBytes)),bodyBytes:new Uint8Array(Object.values(D.signed.bodyBytes))})}}),c=(f,w,b)=>l(void 0,null,function*(){return yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"signAmino",params:{chainId:f,signerAddress:w,signDoc:b}}}})}),m=f=>l(void 0,null,function*(){if(typeof pe[f]!="undefined")return pe[f];let w=yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"getKey",params:{chainId:f}}}});if(!w)throw new Error("No response from Metamask");return w.pubKey=Uint8Array.from(Object.values(w.pubkey)),delete w.pubkey,pe[f]=w,pe[f]}),A=f=>l(void 0,null,function*(){let w=yield m(f);return {address:w.bech32Address,algo:w.algo,pubkey:w.pubKey}}),E=(...f)=>l(void 0,null,function*(){let[w,b,D,N]=f;return yield c(w,b,D)}),h=(...f)=>l(void 0,null,function*(){let[w,b,D]=f;return yield a(w,b,D)}),d=f=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(f)]}),signDirect:(w,b)=>h(f,w,b)}),g=f=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(f)]}),signAmino:(w,b)=>E(f,w,b)});return {enable:s,experimentalSuggestChain:(...f)=>l(void 0,null,function*(){yield o(),yield t.request({method:"wallet_invokeSnap",params:{snapId:e.id,request:{method:"suggestChain",params:{chainInfo:f[0]}}}});}),getKey:m,getOfflineSigner:f=>({getAccounts:()=>l(void 0,null,function*(){return [yield A(f)]}),signDirect:(w,b)=>h(f,w,b),signAmino:(w,b)=>E(f,w,b)}),getOfflineSignerAuto:f=>l(void 0,null,function*(){return (yield m(f)).isNanoLedger?g(f):d(f)}),getOfflineSignerOnlyAmino:g,init:o,signAmino:E,signDirect:h}}throw u.getState()._notFoundFn(),new Error("window.ethereum is not defined")};var Je=()=>Xe({id:"npm:@leapwallet/metamask-cosmos-snap"});var me=()=>{if(typeof window.station!="undefined"){let e=window.station.keplr;return {subscription:o=>{let s=()=>{z(),o();};return window.addEventListener("station_wallet_change",s),()=>{window.removeEventListener("station_wallet_change",s);}},getKey:o=>l(void 0,null,function*(){let s=yield e.getKey(o);return O({isKeystone:!1},s)}),getOfflineSigner:o=>{try{let s=e.getOfflineSignerOnlyAmino(o);return Object.assign(s,{signDirect:(m,A)=>{throw new Error("signDirect not supported by Station")}})}catch(s){throw console.error(s),s}},experimentalSuggestChain:o=>l(void 0,null,function*(){try{let s=Object.assign(o,{chainSymbolImageUrl:o.chainSymbolImageUrl||"",stakeCurrency:{coinDecimals:o.stakeCurrency.coinDecimals,coinDenom:o.stakeCurrency.coinDenom,coinImageUrl:o.stakeCurrency.coinImageUrl||"",coinMinimalDenom:o.stakeCurrency.coinMinimalDenom},currencies:o.currencies.map(a=>({coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom})),feeCurrencies:o.feeCurrencies.map(a=>{var c,m,A;return {coinDecimals:a.coinDecimals,coinDenom:a.coinDenom,coinImageUrl:a.coinImageUrl||"",coinMinimalDenom:a.coinMinimalDenom,gasPriceStep:{average:((c=a.gasPriceStep)==null?void 0:c.average)||0,high:((m=a.gasPriceStep)==null?void 0:m.high)||0,low:((A=a.gasPriceStep)==null?void 0:A.low)||0}}})});yield e.experimentalSuggestChain(s);}catch(s){throw console.error(s),s}}),enable:o=>e.enable(o),disable:o=>e.disable(o),getOfflineSignerAuto:o=>e.getOfflineSignerAuto(o),getOfflineSignerOnlyAmino:o=>e.getOfflineSignerOnlyAmino(o),signDirect:()=>e.signDirect(),signAmino:(o,s,a,c)=>e.signAmino(o,s,a),setDefaultOptions:()=>{console.log("setDefaultOptions not supported by WalletConnect");}}}throw u.getState()._notFoundFn(),new Error("window.station is not defined")};var fe=()=>{if(typeof window.vectis!="undefined"){let e=window.vectis.cosmos;return {enable:a=>e.enable(a),getOfflineSigner:a=>e.getOfflineSigner(a),getOfflineSignerAuto:a=>e.getOfflineSignerAuto(a),getKey:a=>l(void 0,null,function*(){let c=yield e.getKey(a);return {address:fromBech32(c.address).data,algo:c.algo,bech32Address:c.address,name:c.name,pubKey:c.pubKey,isKeystone:!1,isNanoLedger:c.isNanoLedger}}),subscription:a=>{let c=()=>{z(),a();};return window.addEventListener("vectis_accountChanged",c),()=>{window.removeEventListener("vectis_accountChanged",c);}},getOfflineSignerOnlyAmino:(...a)=>e.getOfflineSignerAmino(...a),experimentalSuggestChain:(...a)=>l(void 0,null,function*(){let[c]=a,m=B(O({},c),{rpcUrl:c.rpc,restUrl:c.rest,prettyName:c.chainName.replace(" ",""),bech32Prefix:c.bech32Config.bech32PrefixAccAddr});return e.suggestChains([m])}),signDirect:(...a)=>l(void 0,null,function*(){var A;let{1:c,2:m}=a;return e.signDirect(c,{bodyBytes:m.bodyBytes||Uint8Array.from([]),authInfoBytes:m.authInfoBytes||Uint8Array.from([]),accountNumber:zt.fromString(((A=m.accountNumber)==null?void 0:A.toString())||"",!1),chainId:m.chainId||""})}),signAmino:(...a)=>l(void 0,null,function*(){let{1:c,2:m}=a;return e.signAmino(c,m)}),setDefaultOptions:()=>{console.log("setDefaultOptions not supported by Vectis");}}}throw u.getState()._notFoundFn(),new Error("window.vectis is not defined")};var j=()=>typeof window!="undefined"?!!(window.matchMedia("(pointer:coarse)").matches||/Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/u.test(navigator.userAgent)):!1,Ze=()=>j()&&navigator.userAgent.toLowerCase().includes("android"),et=()=>j()&&(navigator.userAgent.toLowerCase().includes("iphone")||navigator.userAgent.toLowerCase().includes("ipad"));var xe=(e,t,n=new Error("Promise timed out"))=>{let i=new Promise((r,o)=>{setTimeout(()=>{o(n);},t);});return Promise.race([e,i])};var $=e=>{var K,oe,Ke;if(!((Ke=(oe=(K=u.getState().walletConnect)==null?void 0:K.options)==null?void 0:oe.projectId)!=null&&Ke.trim()))throw new Error("walletConnect.options.projectId is not defined");let t=(e==null?void 0:e.walletType)||"walletconnect",n=(e==null?void 0:e.encoding)||"base64",i=y=>{if(!e)return;let{appUrl:S,formatNativeUrl:I}=e;if(j()){if(Ze())if(!y)window.open(S.mobile.android,"_self","noreferrer noopener");else {let W=I(S.mobile.android,y,"android");window.open(W,"_self","noreferrer noopener");}if(et())if(!y)window.open(S.mobile.ios,"_self","noreferrer noopener");else {let W=I(S.mobile.ios,y,"ios");window.open(W,"_self","noreferrer noopener");}}},r=()=>{let{wcSignClients:y}=p.getState();if(!y.get(t))throw new Error("walletConnect.signClient is not defined");y.delete(t),p.setState({wcSignClients:y}),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});},o=y=>l(void 0,null,function*(){let{wcSignClients:S}=p.getState(),I=S.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");if(!y)throw new Error("No wallet connect session");yield I.disconnect({topic:y,reason:getSdkError("USER_DISCONNECTED")}),yield c(I);}),s=y=>{try{let{wcSignClients:S}=p.getState(),I=S.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let W=I.session.getAll().at(-1);if(!W)return;if(!(W.expiry*1e3>Date.now()+1e3))throw o(W.topic),new Error("invalid session");try{let k=I.find({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:y.map(q=>`cosmos:${q}`),events:["chainChanged","accountsChanged"]}}});if(!k.length)throw new Error("no session");return k.at(-1)}catch(k){if(!k.message.toLowerCase().includes("no matching key"))throw k}return W}catch(S){if(!S.message.toLowerCase().includes("no matching key"))throw S}},a=y=>{try{return s(y)}catch(S){return}},c=y=>l(void 0,null,function*(){try{let S=y.core.pairing.pairings.getAll({active:!1});if(!S.length)return;yield Promise.all(S.map(I=>l(void 0,null,function*(){yield y.core.pairing.pairings.delete(I.topic,{code:7001,message:"clear pairing"});})));}catch(S){if(!S.message.toLowerCase().includes("no matching key"))throw S}}),m=()=>l(void 0,null,function*(){let{walletConnect:y}=u.getState();if(!(y!=null&&y.options))throw new Error("walletConnect.options is not defined");let{wcSignClients:S}=p.getState(),I=S.get(t);if(I)return I;let W=yield SignClient.init(y.options);return S.set(t,W),p.setState({wcSignClients:S}),W}),A=y=>{let{wcSignClients:S}=p.getState(),I=S.get(t);if(!I)return ()=>{};let W=R=>{let k=p.getState().accounts;if(R.params.event.name==="accountsChanged"&&k&&!Object.values(k).map(q=>q.bech32Address).includes(R.params.event.data[0])){let q=R.params.chainId.split(":")[1];q&&E([q]);}else y();};return I.events.on("session_delete",r),I.events.on("session_expire",r),I.events.on("session_event",W),()=>{I.events.off("session_delete",r),I.events.off("session_expire",r),I.events.off("session_event",W);}},E=y=>l(void 0,null,function*(){var ie;let S=typeof y=="string"?[y]:y,{wcSignClients:I}=p.getState(),W=I.get(t);if(!W)throw new Error("enable walletConnect.signClient is not defined");let{walletConnect:R,chains:k}=u.getState();if(!((ie=R==null?void 0:R.options)!=null&&ie.projectId))throw new Error("walletConnect.options.projectId is not defined");let{Web3Modal:q}=yield import('@web3modal/standalone'),H=new q(O({projectId:R.options.projectId,walletConnectVersion:2,enableExplorer:!1,explorerRecommendedWalletIds:"NONE"},R.web3Modal)),X=a(S);if(!X){let{uri:L,approval:J}=yield xe(W.connect({requiredNamespaces:{cosmos:{methods:["cosmos_getAccounts","cosmos_signAmino","cosmos_signDirect"],chains:S.map(F=>`cosmos:${F}`),events:["chainChanged","accountsChanged"]}}}),15e3,new Error("Connection timeout"));if(!L)throw new Error("No wallet connect uri");e?i(L):yield H.openModal({uri:L});let re=F=>l(void 0,null,function*(){return F.aborted?Promise.reject(new Error("User closed wallet connect")):new Promise((Te,Z)=>{J().then(_e=>{let Le=_e.sessionProperties;if(!Le)return Z(new Error("No session properties"));let be=JSON.parse(String(Le.keys));if(be.length===0)return Z(new Error("No accounts"));let Ue=be[0];if(!Ue)return Z(new Error("No accounts"));let qe={};return S.forEach(se=>{qe[se]=B(O({},Ue),{bech32Address:toBech32(k.find(Nt=>Nt.chainId===se).bech32Config.bech32PrefixAccAddr,fromBech32(be[0].bech32Address).data)});}),p.setState(se=>({accounts:O(O({},se.accounts||{}),qe)})),Te(_e)}).catch(Z),F.addEventListener("abort",()=>{Z(new Error("User closed wallet connect"));},{once:!0});})});try{let F=new AbortController,Te=F.signal;H.subscribeModal(Z=>{Z.open||F.abort();}),yield re(Te);}catch(F){if(H.closeModal(),!F.message.toLowerCase().includes("no matching key"))return Promise.reject(F)}return e||H.closeModal(),Promise.resolve()}try{yield xe((()=>l(void 0,null,function*(){let L=yield d(S[0]),J={};S.forEach(re=>{J[re]=B(O({},L),{bech32Address:toBech32(k.find(F=>F.chainId===re).bech32Config.bech32PrefixAccAddr,fromBech32(L.bech32Address).data)});}),p.setState({accounts:J});}))(),15e3,new Error("Connection timeout"));}catch(L){if(o(X.topic),!L.message.toLowerCase().includes("no matching key"))throw L}}),h=y=>l(void 0,null,function*(){var k;let{wcSignClients:S}=p.getState(),I=S.get(t);if(!I)throw new Error("walletConnect.signClient is not defined");let W=(k=s([y]))==null?void 0:k.topic;if(!W)throw new Error("No wallet connect session");let R=yield I.request({topic:W,chainId:`cosmos:${y}`,request:{method:"cosmos_getAccounts",params:{}}});if(!R[0])throw new Error("No wallet connect account");return {address:R[0].address,algo:R[0].algo,pubkey:new Uint8Array(Buffer.from(R[0].pubkey,n))}}),d=y=>l(void 0,null,function*(){let S=s([y]);if(!(S!=null&&S.topic))throw new Error("No wallet connect session");let I=S.sessionProperties&&JSON.parse(String(S.sessionProperties.keys))[0];if(!I)throw new Error("No wallet connect key");return I}),g=(...y)=>l(void 0,null,function*(){var L,J;let[S,I,W]=y,{accounts:R,wcSignClients:k}=p.getState(),q=k.get(t);if(!q)throw new Error("walletConnect.signClient is not defined");if(!R)throw new Error("account is not defined");let H=(L=s([S]))==null?void 0:L.topic;if(!H)throw new Error("No wallet connect session");if(!W.bodyBytes)throw new Error("No bodyBytes");if(!W.authInfoBytes)throw new Error("No authInfoBytes");let X={topic:H,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:B(O({},W),{bodyBytes:Buffer.from(W.bodyBytes).toString(n),authInfoBytes:Buffer.from(W.authInfoBytes).toString(n),accountNumber:(J=W.accountNumber)==null?void 0:J.toString()})}}};return i(),yield q.request(X)}),C=(...y)=>l(void 0,null,function*(){let[S,I,W]=y,{signature:R,signed:k}=yield g(S,I,W);return {signed:{chainId:k.chainId,accountNumber:zt.fromString(k.accountNumber,!1),authInfoBytes:new Uint8Array(Buffer.from(k.authInfoBytes,n)),bodyBytes:new Uint8Array(Buffer.from(k.bodyBytes,n))},signature:R}}),T=(...y)=>l(void 0,null,function*(){var L;let[S,I,W,R]=y,{wcSignClients:k}=p.getState(),q=k.get(t),{accounts:H}=p.getState();if(!q)throw new Error("walletConnect.signClient is not defined");if(!H)throw new Error("account is not defined");let X=(L=s([S]))==null?void 0:L.topic;if(!X)throw new Error("No wallet connect session");return i(),yield q.request({topic:X,chainId:`cosmos:${S}`,request:{method:"cosmos_signDirect",params:{signerAddress:I,signDoc:W}}})}),x=(...y)=>l(void 0,null,function*(){let[S,I,W,R]=y;return yield T(S,I,W)}),f=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield h(y)]}),signDirect:(S,I)=>C(y,S,I)}),w=y=>({getAccounts:()=>l(void 0,null,function*(){return [yield h(y)]}),signAmino:(S,I)=>x(y,S,I)});return {enable:E,disable:y=>l(void 0,null,function*(){var W;let{wcSignClients:S}=p.getState(),I=S.get(t);if(y===void 0){let R=I==null?void 0:I.session.getAll();R!==void 0&&(yield Promise.all(R.map(k=>o(k.topic))));}else typeof y=="string"?yield o((W=s([y]))==null?void 0:W.topic):yield Promise.all(y.map(R=>{var k;return o((k=s([R]))==null?void 0:k.topic)}));(I==null?void 0:I.session.getAll().length)===0&&r();}),experimentalSuggestChain:(...y)=>l(void 0,null,function*(){yield Promise.reject(new Error("WalletConnect does not support experimentalSuggestChain"));}),getKey:d,getOfflineSigner:y=>({getAccounts:()=>l(void 0,null,function*(){return [yield h(y)]}),signDirect:(S,I)=>C(y,S,I),signAmino:(S,I)=>x(y,S,I)}),getOfflineSignerAuto:y=>l(void 0,null,function*(){return (yield d(y)).isNanoLedger?w(y):f(y)}),getOfflineSignerOnlyAmino:w,signAmino:x,signDirect:C,subscription:A,init:m,setDefaultOptions:()=>{console.log("setDefaultOptions not supported by WalletConnect");}}};var ot=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!j())throw new Error("WalletConnect Cosmostation mobile is only supported in mobile");let e={encoding:"hex",appUrl:{mobile:{ios:"cosmostation://",android:"cosmostation://"}},walletType:"wc_cosmostation_mobile",formatNativeUrl:(r,o,s)=>`${r.replaceAll("/","").replaceAll(":","")}://wc?${o}`};return $(e)};var it=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!j())throw new Error("WalletConnect Keplr mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"keplrwallet://",android:"intent://"}},walletType:"wc_keplr_mobile",formatNativeUrl:(r,o,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${c}`;case"android":return `${a}://wcV2?${c}#Intent;package=com.chainapsis.keplr;scheme=keplrwallet;end;`;default:return `${a}://wc?uri=${c}`}}};return $(e)};var rt=()=>{var t,n,i;if(!((i=(n=(t=u.getState().walletConnect)==null?void 0:t.options)==null?void 0:n.projectId)!=null&&i.trim()))throw new Error("walletConnect.options.projectId is not defined");if(!j())throw new Error("WalletConnect Leap mobile is only supported in mobile");let e={encoding:"base64",appUrl:{mobile:{ios:"leapcosmos://",android:"intent://"}},walletType:"wc_leap_mobile",formatNativeUrl:(r,o,s)=>{let a=r.replaceAll("/","").replaceAll(":",""),c=encodeURIComponent(o);switch(s){case"ios":return `${a}://wcV2?${c}`;case"android":return `${a}://wcV2?${c}#Intent;package=io.leapwallet.cosmos;scheme=leapwallet;end;`;default:return `${a}://wc?uri=${c}`}}};return $(e)};var ge=()=>{var e;if(typeof((e=window.xfi)==null?void 0:e.keplr)!="undefined"){let t=window.xfi.keplr;return Object.assign(t,{subscription:r=>{let o=()=>{z(),r();};return window.addEventListener("keplr_keystorechange",o),()=>{window.removeEventListener("keplr_keystorechange",o);}},setDefaultOptions:()=>{console.log("setDefaultOptions not supported by Vectis");}})}throw u.getState()._notFoundFn(),new Error("window.xfi.keplr is not defined")};var _=(e=u.getState().walletType)=>{try{return P(e),!0}catch(t){return !1}},z=()=>{window.sessionStorage.removeItem(V),p.setState(ee);},P=(e=u.getState().walletType)=>{var i;let t=(()=>{switch(e){case"keplr":return ue();case"leap":return de();case"cosmostation":return le();case"vectis":return fe();case"walletconnect":return $();case"wc_keplr_mobile":return it();case"wc_leap_mobile":return rt();case"wc_cosmostation_mobile":return ot();case"metamask_snap_leap":return Je();case"station":return me();case"xdefi":return ge();case"capsule":return ce();default:throw new Error("Unknown wallet type")}})(),n=u.getState().walletDefaultOptions;return n&&((i=t.setDefaultOptions)==null||i.call(t,n)),t},ii=()=>Object.fromEntries($e.map(e=>[e,_(e)])),Me=e=>e==="capsule",st=e=>e==="walletconnect"||e==="wc_keplr_mobile"||e==="wc_leap_mobile"||e==="wc_cosmostation_mobile";var te=e=>l(void 0,null,function*(){var t;try{let{recentChainIds:n,chains:i,walletType:r}=u.getState(),o=(e==null?void 0:e.walletType)||r;if(!_(o))throw new Error(`${o} is not available`);let a=P(o),c=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:(e==null?void 0:e.chainId)||n;if(!c)throw new Error("No last known connected chain, connect action requires chain ids");let m=i==null?void 0:i.map(d=>d.chainId);c.forEach(d=>{if(!(m!=null&&m.includes(d)))throw new Error(`Chain ${d} is not provided in GrazProvider`)}),p.setState(d=>{let g=u.getState()._reconnect||!!u.getState()._reconnectConnector||!!c;return d.activeChainIds&&c.filter(T=>{var x;return !((x=d.activeChainIds)!=null&&x.includes(T))}).length>0?{status:"connecting"}:g?{status:"reconnecting"}:{status:"connecting"}});let{accounts:A}=p.getState();if(yield (t=a.init)==null?void 0:t.call(a),Me(o)&&p.getState().capsuleClient&&Object.values(p.getState().accounts||[]).length>0){let d=c.map(x=>i.find(f=>f.chainId===x)),g=p.getState().accounts;p.setState({status:"connecting"});let C=yield a.getKey(c[0]),T={};return c.forEach(x=>{T[x]=B(O({},C),{bech32Address:toBech32(i.find(f=>f.chainId===x).bech32Config.bech32PrefixAccAddr,fromBech32(C.bech32Address).data)});}),p.setState(x=>({accounts:O(O({},x.accounts||{}),T)})),u.setState(x=>({recentChainIds:[...x.recentChainIds||[],...c].filter((f,w,b)=>b.indexOf(f)===w)})),p.setState(x=>({activeChainIds:[...x.activeChainIds||[],...c].filter((f,w,b)=>b.indexOf(f)===w)})),p.setState({status:"connected"}),{accounts:g,walletType:o,chains:d}}if(yield a.enable(c),Me(o)){let d=c.map(C=>i.find(T=>T.chainId===C)),g=p.getState().accounts;return p.setState({status:"connecting"}),{accounts:g,walletType:o,chains:d}}if(!st(o)){let d=yield a.getKey(c[0]),g={};c.forEach(C=>{g[C]=B(O({},d),{bech32Address:toBech32(i.find(T=>T.chainId===C).bech32Config.bech32PrefixAccAddr,fromBech32(d.bech32Address).data)});}),p.setState(C=>({accounts:O(O({},C.accounts||{}),g)}));}u.setState(d=>({recentChainIds:[...d.recentChainIds||[],...c].filter((g,C,T)=>T.indexOf(g)===C)})),p.setState(d=>({activeChainIds:[...d.activeChainIds||[],...c].filter((g,C,T)=>T.indexOf(g)===C)})),u.setState({walletType:o,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:o}),p.setState({status:"connected"}),typeof window!="undefined"&&window.sessionStorage.setItem(V,"Active");let E=c.map(d=>i.find(g=>g.chainId===d));return {accounts:p.getState().accounts,walletType:o,chains:E}}catch(n){throw console.error("connect ",n),p.getState().accounts===null&&p.setState({status:"disconnected"}),p.getState().accounts&&p.getState().activeChainIds&&p.setState({status:"connected"}),n}}),ne=e=>{typeof window!="undefined"&&window.sessionStorage.removeItem(V);let t=typeof(e==null?void 0:e.chainId)=="string"?[e.chainId]:e==null?void 0:e.chainId;if(t){let n=p.getState().accounts;t.forEach(r=>{n==null||delete n[r];}),Object.values(n||{}).length===0?(p.setState(ee),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null})):(p.setState(r=>{var o;return {activeChainIds:(o=r.activeChainIds)==null?void 0:o.filter(s=>!t.includes(s)),accounts:n}}),u.setState(r=>{var o;return {recentChainIds:(o=r.recentChainIds)==null?void 0:o.filter(s=>!t.includes(s))}}));}else p.setState(ee),u.setState({_reconnect:!1,_reconnectConnector:null,recentChainIds:null});return Promise.resolve()},Q=e=>l(void 0,null,function*(){var r;let{recentChainIds:t,_reconnectConnector:n,_reconnect:i}=u.getState();try{let o=_(n||void 0);if(t&&o&&n)return yield te({chainId:t,walletType:n,autoReconnect:i})}catch(o){(r=e==null?void 0:e.onError)==null||r.call(e,o),ne();}}),lt=e=>l(void 0,null,function*(){if(!(e!=null&&e.chainId))throw new Error("chainId is required");let{walletType:t}=u.getState(),n=e.walletType||t;if(!_(n))throw new Error(`${n} is not available`);let r=P(n),o=r.getOfflineSigner(e.chainId),s=r.getOfflineSignerOnlyAmino(e.chainId),a=yield r.getOfflineSignerAuto(e.chainId);return {offlineSigner:o,offlineSignerAmino:s,offlineSignerAuto:a}});var ve=()=>{u.setState({recentChainIds:null});},yi=()=>u.getState().recentChainIds,Si=()=>{var n;let{recentChainIds:e,chains:t}=u.getState();return (n=e==null?void 0:e.map(i=>t.find(r=>r.chainId===i)))!=null?n:null},hi=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.find(n=>n.chainId===e)},wi=({chainId:e})=>{var t;return (t=u.getState().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},We=n=>l(void 0,[n],function*({chainInfo:e,walletType:t}){let i=P(t);return t==="capsule"?yield te({chainId:e.chainId,walletType:t}):yield i.experimentalSuggestChain(e),e}),ut=e=>l(void 0,null,function*(){var i;let t=u.getState().walletType;return yield We({chainInfo:e.chainInfo,walletType:(i=e.walletType)!=null?i:t}),yield te({chainId:e.chainInfo.chainId,walletType:e.walletType,autoReconnect:e.autoReconnect})});var dt=e=>(u.setState(t=>({walletConnect:e.walletConnect||t.walletConnect,walletType:e.defaultWallet||t.walletType,capsuleConfig:e.capsuleConfig||t.capsuleConfig,walletDefaultOptions:e.walletDefaultOptions||t.walletDefaultOptions,chains:e.chains,chainsConfig:e.chainsConfig||t.chainsConfig,multiChainFetchConcurrency:e.multiChainFetchConcurrency||t.multiChainFetchConcurrency,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var pt=s=>l(void 0,[s],function*({signingClient:e,senderAddress:t,recipientAddress:n,amount:i,fee:r,memo:o}){if(!e)throw new Error("No connected account detected");if(!t)throw new Error("senderAddress is not defined");return e.sendTokens(t,n,i,r,o)}),mt=A=>l(void 0,[A],function*({signingClient:e,senderAddress:t,recipientAddress:n,transferAmount:i,sourcePort:r,sourceChannel:o,timeoutHeight:s,timeoutTimestamp:a,fee:c,memo:m}){if(!e)throw new Error("Stargate signing client is not ready");if(!t)throw new Error("senderAddress is not defined");return e.sendIbcTokens(t,n,i,r,o,s,a,c,m)}),ft=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,options:r,label:o,codeId:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.instantiate(t,s,n,o,i,r)}),gt=a=>l(void 0,[a],function*({signingClient:e,senderAddress:t,msg:n,fee:i,contractAddress:r,funds:o,memo:s}){if(!e)throw new Error("CosmWasm signing client is not ready");return e.execute(t,r,n,i,s,o)}),Ct=(e,t,n)=>l(void 0,null,function*(){if(!n)throw new Error("CosmWasm client is not ready");return yield n.queryContractSmart(e,t)}),yt=(e,t,n)=>{if(!n)throw new Error("CosmWasm client is not ready");let i=new TextEncoder().encode(t);return n.queryContractRaw(e,i)};var Wi=e=>e,ki=e=>e;var Ce=e=>e?Object.keys(e).length===0:!0;var ke=class extends Error{constructor(t){super(),this.name="AbortError",this.message=t;}},St=e=>globalThis.DOMException===void 0?new ke(e):new DOMException(e),ht=e=>{let t=e.reason===void 0?St("This operation was aborted."):e.reason;return t instanceof Error?t:St(t)};function Re(o,s){return l(this,arguments,function*(e,t,{concurrency:n=Number.POSITIVE_INFINITY,stopOnError:i=!0,signal:r}={}){return new Promise((a,c)=>{if(e[Symbol.iterator]===void 0&&e[Symbol.asyncIterator]===void 0)throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`);if(typeof t!="function")throw new TypeError("Mapper function is required");if(!((Number.isSafeInteger(n)||n===Number.POSITIVE_INFINITY)&&n>=1))throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`);let m=[],A=[],E=new Map,h=!1,d=!1,g=!1,C=0,T=0,x=e[Symbol.iterator]===void 0?e[Symbol.asyncIterator]():e[Symbol.iterator](),f=b=>{h=!0,d=!0,c(b);};r&&(r.aborted&&f(ht(r)),r.addEventListener("abort",()=>{f(ht(r));}));let w=()=>l(this,null,function*(){if(d)return;let b=yield x.next(),D=T;if(T++,b.done){if(g=!0,C===0&&!d){if(!i&&A.length>0){f(new AggregateError(A));return}if(d=!0,E.size===0){a(m);return}let N=[];for(let[K,oe]of m.entries())E.get(K)!==wt&&N.push(oe);a(N);}return}C++,l(this,null,function*(){try{let N=yield b.value;if(d)return;let K=yield t(N,D);K===wt&&E.set(D,K),m[D]=K,C--,yield w();}catch(N){if(i)f(N);else {A.push(N),C--;try{yield w();}catch(K){f(K);}}}});});l(this,null,function*(){for(let b=0;b<n;b++){try{yield w();}catch(D){f(D);break}if(g||h)break}});})})}var wt=Symbol("skip");var U=({chainId:e,multiChain:t})=>{let n=u(r=>r.chains);if(!n)throw new Error("No chains found in GrazProvider");let i=typeof e=="string"?[e]:e;switch(!0){case(!!t&&!!i):return i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean);case(!t&&!!i):return [i.map(r=>n.find(o=>o.chainId===r)).filter(Boolean)[0]];case(!!t&&!i):return n;default:return [n[0]]}},G=(e,t,n)=>l(void 0,null,function*(){let i=u.getState().multiChainFetchConcurrency;if(e){let o=yield Re(t,n,{concurrency:i});return Object.fromEntries(o.map((s,a)=>[t[a].chainId,s]))}return yield n(t[0])}),At=(e,t,n)=>{if(e){let r=t.map(n);return Object.fromEntries(r.map((o,s)=>[t[s].chainId,o]))}return n(t[0])};var Ne=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_STARGATE_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,s=>l(void 0,null,function*(){var A;let a=(A=u.getState().chainsConfig)==null?void 0:A[s.chainId],c={url:s.rpc,headers:O({},(a==null?void 0:a.rpcHeaders)||{})};return yield StargateClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},Be=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=useMemo(()=>["USE_COSMWASM_CLIENT",t],[t]);return useQuery({queryKey:n,queryFn:r=>l(void 0,[r],function*({queryKey:[,i]}){if(i.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),i,s=>l(void 0,null,function*(){var A;let a=(A=u.getState().chainsConfig)==null?void 0:A[s.chainId],c={url:s.rpc,headers:O({},(a==null?void 0:a.rpcHeaders)||{})};return yield CosmWasmClient.connect(c)}))}),enabled:!!t&&t.length>0&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})},ye=({type:e,chainId:t,multiChain:n,enabled:i})=>{let r=U({chainId:t,multiChain:n}),o=useMemo(()=>["USE_TENDERMINT_CLIENT",e,r],[e,r]);return useQuery({queryKey:o,queryFn:c=>l(void 0,[c],function*({queryKey:[,s,a]}){if(a.length<1)throw new Error("No chains found");return yield G(!!n,a,A=>l(void 0,null,function*(){var C;let E=(C=u.getState().chainsConfig)==null?void 0:C[A.chainId],h={url:A.rpc,headers:O({},(E==null?void 0:E.rpcHeaders)||{})};return yield (s==="tm37"?Tendermint37Client:Tendermint34Client).connect(h)}))}),enabled:!!r&&r.length>0&&(i!==void 0?!!i:!0),refetchOnWindowFocus:!1})};var ir=()=>u(e=>({walletType:e.walletType,isCosmostation:e.walletType==="cosmostation",isCosmostationMobile:e.walletType==="wc_cosmostation_mobile",isKeplr:e.walletType==="keplr",isKeplrMobile:e.walletType==="wc_keplr_mobile",isLeap:e.walletType==="leap",isLeapMobile:e.walletType==="wc_leap_mobile",isVectis:e.walletType==="vectis",isWalletConnect:e.walletType==="walletconnect",isMetamaskSnapLeap:e.walletType==="metamask_snap_leap",isStation:e.walletType==="station",isCapsule:e.walletType==="capsule"}),shallow),Se=e=>{let n=["USE_CHECK_WALLET",u(r=>e||r.walletType)];return useQuery(n,({queryKey:[,r]})=>_(r))};var Y=e=>{let t=u(a=>a.walletType),n=p(a=>a.activeChainIds),i=U({chainId:e!=null&&e.chainId?e.chainId:n||void 0,multiChain:e==null?void 0:e.multiChain}),r=p(a=>a.accounts),o=p(a=>a.status);return useEffect(()=>p.subscribe(a=>a.status,(a,c)=>{var m,A,E;if(a==="connected"){let{accounts:h,activeChainIds:d}=p.getState(),{chains:g}=u.getState(),{walletType:C}=u.getState();if(!h||!d||!g)return (m=e==null?void 0:e.onDisconnect)==null?void 0:m.call(e);(A=e==null?void 0:e.onConnect)==null||A.call(e,{accounts:h,chains:d.map(T=>g.find(x=>x.chainId===T)),walletType:C,isReconnect:c==="reconnecting"});}a==="disconnected"&&((E=e==null?void 0:e.onDisconnect)==null||E.call(e));}),[e]),{data:useMemo(()=>r?At(!!(e!=null&&e.multiChain),i,a=>r[a.chainId]):void 0,[r,i,e==null?void 0:e.multiChain]),isConnected:o==="connected",isConnecting:o==="connecting",isDisconnected:o==="disconnected",isReconnecting:o==="reconnecting",isLoading:o==="connecting"||o==="reconnecting",walletType:o==="connected"?t:void 0,reconnect:Q,status:o}},on=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),i=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),{data:r}=Ne({chainId:t.map(s=>s.chainId),multiChain:!0,enabled:((e==null?void 0:e.enabled)===void 0?!0:e.enabled)&&!!i}),o=useMemo(()=>["USE_ALL_BALANCES",r,t,i,e==null?void 0:e.chainId],[i,e==null?void 0:e.chainId,t,r]);return useQuery(o,m=>l(void 0,[m],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),a,E=>l(void 0,null,function*(){let h=s==null?void 0:s[E.chainId];if(!h)throw new Error(`Client is not ready ${E.chainId}`);return yield h.getAllBalances(toBech32(E.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),{enabled:!!i&&!!t&&t.length>0&&!Ce(r)&&((e==null?void 0:e.enabled)===void 0?!0:e.enabled),refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})},yr=e=>{let t=U({chainId:e.chainId}),{data:n}=Y({chainId:e.chainId}),i=e.bech32Address||(n==null?void 0:n.bech32Address),{data:r,refetch:o}=on({chainId:t.map(c=>c.chainId),bech32Address:i,enabled:!!i&&(e.enabled===void 0?!0:e.enabled)}),s=["USE_BALANCE",e.denom,r,t,i,e.chainId],a=useQuery(s,({queryKey:[,c,m]})=>m==null?void 0:m.find(A=>A.denom===c),{enabled:!!e.denom&&!!r&&!!(r!=null&&r.length)&&(e.enabled===void 0?!0:e.enabled)});return B(O({},a),{refetch:c=>l(void 0,null,function*(){return yield o(),a.refetch(c)})})},Sr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_CONNECT",e,t,n],te,{onError:(s,a)=>e==null?void 0:e(s,a),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=Se();return {connect:s=>r.mutate(s),connectAsync:s=>r.mutateAsync(s),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status}},hr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_DISCONNECT",e,t,n],ne,{onError:o=>Promise.resolve(e==null?void 0:e(o,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return {disconnect:o=>r.mutate(o),disconnectAsync:o=>r.mutateAsync(o),error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,status:r.status}},wr=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(r=>r.walletType),i=useMemo(()=>["USE_OFFLINE_SIGNERS",t,n],[t,n]);return useQuery({queryKey:i,queryFn:s=>l(void 0,[s],function*({queryKey:[,r,o]}){if(r.length<1)throw new Error("No chain found");if(!_(o))throw new Error(`${o} is not available`);return yield G(!!(e!=null&&e.multiChain),r,m=>l(void 0,null,function*(){return yield lt({chainId:m.chainId,walletType:o})}))}),enabled:!!t&&t.length>0&&!!n,refetchOnWindowFocus:!1})},Ar=e=>{let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),{data:n}=Y(),{data:i}=Ne({chainId:t.map(s=>s.chainId),multiChain:!0}),r=(e==null?void 0:e.bech32Address)||(n==null?void 0:n.bech32Address),o=useMemo(()=>["USE_BALANCE_STAKED",i,t,r],[t,r,i]);return useQuery(o,m=>l(void 0,[m],function*({queryKey:[,s,a,c]}){if(!c)throw new Error("address is not defined");return yield G(!!(e!=null&&e.multiChain),a,E=>l(void 0,null,function*(){var d;if(!s)throw new Error("Client is not ready");return yield (d=s[E.chainId])==null?void 0:d.getBalanceStaked(toBech32(E.bech32Config.bech32PrefixAccAddr,fromBech32(c).data))}))}),{enabled:!!r&&!!t&&t.length>0&&!!i,refetchOnMount:!1,refetchOnReconnect:!0,refetchOnWindowFocus:!1})};var Mr=()=>{let e=u(i=>i.capsuleState),t=p(i=>i.capsuleClient),n=ce();return {setModalState:i=>{u.setState(r=>{var o;return {capsuleState:{showModal:i,chainId:(o=r.capsuleState)==null?void 0:o.chainId}}});},modalState:!!(e!=null&&e.showModal),client:t,onAfterLoginSuccessful:n.onAfterLoginSuccessful,onLoginFailure:()=>{ne();}}};var Nr=()=>p(e=>e.activeChainIds),rn=()=>{var e;return (e=p(t=>t.activeChainIds))==null?void 0:e.map(t=>{var i;let n=(i=u.getState().chains)==null?void 0:i.find(r=>r.chainId===t);if(n)return n}).filter(Boolean)},Br=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.find(n=>n.chainId===e)},Kr=({chainId:e})=>{var t;return (t=u().chains)==null?void 0:t.filter(n=>e==null?void 0:e.includes(n.chainId))},_r=({denom:e})=>{let t=rn();return useQuery(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>{var o;return (o=t==null?void 0:t.find(s=>s.currencies.find(a=>a.coinMinimalDenom===r)))==null?void 0:o.currencies.find(s=>s)})},Lr=e=>{var r;let t=(r=e.status)!=null?r:"BOND_STATUS_BONDED",n=["USE_ACTIVE_CHAIN_VALIDATORS",e.queryClient,t];return useQuery(n,a=>l(void 0,[a],function*({queryKey:[,o,s]}){if(!o)throw new Error("Query client is not defined");return yield o.staking.validators(s)}),{enabled:typeof e.queryClient!="undefined"})},Ur=()=>({data:u(t=>t.recentChainIds),clear:ve}),qr=()=>{var t;return {data:(t=u(n=>n.recentChainIds))==null?void 0:t.map(n=>{var r;let i=(r=u.getState().chains)==null?void 0:r.find(o=>o.chainId===n);if(i)return i}).filter(Boolean),clear:ve}},Gr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN",e,t,n],We,{onError:(o,s)=>Promise.resolve(e==null?void 0:e(o,s.chainInfo)),onMutate:o=>t==null?void 0:t(o.chainInfo),onSuccess:o=>Promise.resolve(n==null?void 0:n(o))});return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,suggest:r.mutate,suggestAsync:r.mutateAsync,status:r.status}},Fr=({onError:e,onLoading:t,onSuccess:n}={})=>{let r=useMutation(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],ut,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:o}=Se();return {error:r.error,isLoading:r.isLoading,isSuccess:r.isSuccess,isSupported:!!o,status:r.status,suggestAndConnect:r.mutate,suggestAndConnectAsync:r.mutateAsync}};var Xr=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=Y(),r=i==null?void 0:i.bech32Address,o=useMutation(["USE_SEND_TOKENS",e,t,n,r],s=>pt(O({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendTokens:o.mutate,sendTokensAsync:o.mutateAsync,status:o.status}},Jr=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:i}=Y(),r=i==null?void 0:i.bech32Address,o=useMutation(["USE_SEND_IBC_TOKENS",e,t,n,r],s=>mt(O({senderAddress:r},s)),{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))});return {error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,sendIbcTokens:o.mutate,sendIbcTokensAsync:o.mutateAsync,status:o.status}},Zr=({codeId:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=Y(),o=r==null?void 0:r.bech32Address,a=useMutation(["USE_INSTANTIATE_CONTRACT",t,n,i,e,o],c=>{var A;if(!o)throw new Error("senderAddress is undefined");let m=B(O({},c),{fee:(A=c.fee)!=null?A:"auto",senderAddress:o,codeId:e});return ft(m)},{onError:(c,m)=>Promise.resolve(t==null?void 0:t(c,m)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,instantiateContract:a.mutate,instantiateContractAsync:a.mutateAsync,status:a.status}},es=({contractAddress:e,onError:t,onLoading:n,onSuccess:i})=>{let{data:r}=Y(),o=r==null?void 0:r.bech32Address,a=useMutation(["USE_EXECUTE_CONTRACT",t,n,i,e,o],c=>{var A,E,h;if(!o)throw new Error("senderAddress is undefined");let m=B(O({},c),{fee:(A=c.fee)!=null?A:"auto",senderAddress:o,contractAddress:e,memo:(E=c.memo)!=null?E:"",funds:(h=c.funds)!=null?h:[]});return gt(m)},{onError:(c,m)=>Promise.resolve(t==null?void 0:t(c,m)),onMutate:n,onSuccess:c=>Promise.resolve(i==null?void 0:i(c))});return {error:a.error,isLoading:a.isLoading,isSuccess:a.isSuccess,executeContract:a.mutate,executeContractAsync:a.mutateAsync,status:a.status}},ts=e=>{let{data:t}=Be();return useQuery(["USE_QUERY_SMART",e==null?void 0:e.address,e==null?void 0:e.queryMsg,t],({queryKey:[,i]})=>{if(!(e!=null&&e.address)||!e.queryMsg)throw new Error("address or queryMsg undefined");return Ct(e.address,e.queryMsg,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.queryMsg)&&!!t})},ns=e=>{let{data:t}=Be(),n=["USE_QUERY_RAW",e==null?void 0:e.key,e==null?void 0:e.address,t];return useQuery(n,({queryKey:[,r]})=>{if(!(e!=null&&e.address)||!e.key)throw new Error("address or key undefined");return yt(e.address,e.key,t)},{enabled:!!(e!=null&&e.address)&&!!(e!=null&&e.key)&&!!t})};function gs(e){let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=p(o=>o.activeChainIds),r=useMemo(()=>["USE_STARGATE_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return useQuery({queryKey:r,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,m=>l(this,null,function*(){var C,T;if(!(i!=null&&i.includes(m.chainId)))return;if(!_(s))throw new Error(`${s} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return P(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return P(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return P(s).getOfflineSignerOnlyAmino(m.chainId);default:return P(s).getOfflineSignerAuto(m.chainId)}}))(),h=(C=u.getState().chainsConfig)==null?void 0:C[m.chainId],d={url:m.rpc,headers:O({},(h==null?void 0:h.rpcHeaders)||{})};return (e==null?void 0:e.multiChain)===!0&&e.opts,yield SigningStargateClient.connectWithSigner(d,E,e!=null&&e.multiChain?(T=e.opts)==null?void 0:T[m.chainId]:e==null?void 0:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Cs(e){let t=U({chainId:e==null?void 0:e.chainId,multiChain:e==null?void 0:e.multiChain}),n=u(o=>o.walletType),i=p(o=>o.activeChainIds),r=useMemo(()=>["USE_COSMWASM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]);return useQuery({queryKey:r,queryFn:a=>l(this,[a],function*({queryKey:[,o,s]}){if(o.length<1)throw new Error("No chains found");return yield G(!!(e!=null&&e.multiChain),o,m=>l(this,null,function*(){var T,x;if(!(i!=null&&i.includes(m.chainId)))return;if(!_(s))throw new Error(`${s} is not available`);let E=yield (()=>l(this,null,function*(){switch(e==null?void 0:e.offlineSigner){case"offlineSigner":return P(s).getOfflineSigner(m.chainId);case"offlineSignerAuto":return P(s).getOfflineSignerAuto(m.chainId);case"offlineSignerOnlyAmino":return P(s).getOfflineSignerOnlyAmino(m.chainId);default:return P(s).getOfflineSignerAuto(m.chainId)}}))(),h=(T=u.getState().chainsConfig)==null?void 0:T[m.chainId],d={url:m.rpc,headers:O({},(h==null?void 0:h.rpcHeaders)||{})},g=h!=null&&h.gas?GasPrice.fromString(`${h.gas.price}${h.gas.denom}`):void 0;return yield SigningCosmWasmClient.connectWithSigner(d,E,O({gasPrice:g},e!=null&&e.multiChain?(x=e.opts)==null?void 0:x[m.chainId]:(e==null?void 0:e.opts)||{}))}))}),enabled:!!t&&t.length>0&&!!n&&((e==null?void 0:e.enabled)!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function ys(e){let t=U({chainId:e.chainId,multiChain:e.multiChain}),n=u(s=>s.walletType),i=p(s=>s.activeChainIds),r=useMemo(()=>["USE_STARGATE_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=ye({type:e.type,chainId:e.chainId,multiChain:e.multiChain});return useQuery({queryKey:r,queryFn:c=>l(this,[c],function*({queryKey:[,s,a]}){if(s.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,s,A=>l(this,null,function*(){var C;if(!(i!=null&&i.includes(A.chainId)))return;if(!_(a))throw new Error(`${a} is not available`);if(!o)throw new Error("No tendermint client found");let h=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return P(a).getOfflineSigner(A.chainId);case"offlineSignerAuto":return P(a).getOfflineSignerAuto(A.chainId);case"offlineSignerOnlyAmino":return P(a).getOfflineSignerOnlyAmino(A.chainId);default:return P(a).getOfflineSignerAuto(A.chainId)}}))(),d=e.multiChain?o[A.chainId]:o;return yield SigningStargateClient.createWithSigner(d,h,e.multiChain?(C=e.opts)==null?void 0:C[A.chainId]:e.opts)}))}),enabled:!!t&&t.length>0&&!!n&&!!o&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}function Ss(e){let t=U({chainId:e.chainId,multiChain:e.multiChain}),n=u(a=>a.walletType),i=p(a=>a.activeChainIds),r=useMemo(()=>["USE_COSMWASM_TM_SIGNING_CLIENT",t,n,e,i],[i,e,t,n]),{data:o}=ye({type:e.type,chainId:e.chainId,multiChain:!1,enabled:!e.multiChain}),{data:s}=ye({type:e.type,chainId:e.chainId,multiChain:!0,enabled:!!e.multiChain});return useQuery({queryKey:r,queryFn:m=>l(this,[m],function*({queryKey:[,a,c]}){if(a.length<1)throw new Error("No chains found");return yield G(!!e.multiChain,a,E=>l(this,null,function*(){var f,w;if(!(i!=null&&i.includes(E.chainId)))return;if(!_(c))throw new Error(`${c} is not available`);let d=yield (()=>l(this,null,function*(){switch(e.offlineSigner){case"offlineSigner":return P(c).getOfflineSigner(E.chainId);case"offlineSignerAuto":return P(c).getOfflineSignerAuto(E.chainId);case"offlineSignerOnlyAmino":return P(c).getOfflineSignerOnlyAmino(E.chainId);default:return P(c).getOfflineSignerAuto(E.chainId)}}))(),g=(f=u.getState().chainsConfig)==null?void 0:f[E.chainId],C=g!=null&&g.gas?GasPrice.fromString(`${g.gas.price}${g.gas.denom}`):void 0,T=e.multiChain?s==null?void 0:s[E.chainId]:o;if(!T)throw new Error("No tendermint client found");return yield SigningCosmWasmClient.createWithSigner(T,d,O({gasPrice:C},e.multiChain?(w=e.opts)==null?void 0:w[E.chainId]:e.opts||{}))}))}),enabled:!!t&&t.length>0&&!!n&&(!!o||!Ce(s))&&(e.enabled!==void 0?!!e.enabled:!0),refetchOnWindowFocus:!1})}var kt=({children:e})=>{let[t,n]=useState(!1);return useEffect(()=>{n(!0);},[]),jsx(Fragment,{children:t?e:null})};var un=()=>{let e=typeof window!="undefined"&&window.sessionStorage.getItem(V)==="Active",{_reconnect:t,_onReconnectFailed:n,_reconnectConnector:i}=u(),{activeChainIds:r,wcSignClients:o}=p(),s=_(i||void 0);return useEffect(()=>{if(i){if(!s)return;e&&r?Q({onError:n}):!e&&t&&Q({onError:n});}},[s]),useEffect(()=>{var a,c,m,A,E,h,d,g,C,T,x,f,w,b;if(i){if(!s)return;i==="cosmostation"&&((c=(a=le()).subscription)==null||c.call(a,()=>{Q({onError:n});})),i==="keplr"&&((A=(m=ue()).subscription)==null||A.call(m,()=>{Q({onError:n});})),i==="leap"&&((h=(E=de()).subscription)==null||h.call(E,()=>{Q({onError:n});})),i==="vectis"&&((g=(d=fe()).subscription)==null||g.call(d,()=>{Q({onError:n});})),i==="walletconnect"&&o.has("walletconnect")&&((T=(C=$()).subscription)==null||T.call(C,()=>{Q({onError:n});})),i==="station"&&((f=(x=me()).subscription)==null||f.call(x,()=>{Q({onError:n});})),i==="xdefi"&&((b=(w=ge()).subscription)==null||b.call(w,()=>{Q({onError:n});}));}},[i,o,s]),null},Pt=()=>(un(),null);var mn=new QueryClient({}),zs=i=>{var r=i,{children:e,grazOptions:t}=r,n=Qe(r,["children","grazOptions"]);return dt(t),jsx(QueryClientProvider,B(O({client:mn},n),{children:jsxs(kt,{children:[e,jsx(Pt,{})]})}),"graz-provider")};
|
|
16
16
|
|
|
17
|
-
export {
|
|
17
|
+
export { Pt as GrazEvents, zs as GrazProvider, $e as WALLET_TYPES, je as WalletType, _ as checkWallet, ve as clearRecentChain, z as clearSession, dt as configureGraz, te as connect, ki as defineChainInfo, Wi as defineChains, ne as disconnect, gt as executeContract, ii as getAvailableWallets, hi as getChainInfo, wi as getChainInfos, le as getCosmostation, ue as getKeplr, de as getLeap, Je as getMetamaskSnapLeap, lt as getOfflineSigners, yt as getQueryRaw, Ct as getQuerySmart, yi as getRecentChainIds, Si as getRecentChains, fe as getVectis, ot as getWCCosmostation, it as getWCKeplr, rt as getWCLeap, P as getWallet, $ as getWalletConnect, ft as instantiateContract, Me as isCapsule, st as isWalletConnect, Q as reconnect, mt as sendIbcTokens, pt as sendTokens, We as suggestChain, ut as suggestChainAndConnect, Y as useAccount, _r as useActiveChainCurrency, Nr as useActiveChainIds, rn as useActiveChains, ir as useActiveWalletType, yr as useBalance, Ar as useBalanceStaked, on as useBalances, Mr as useCapsule, Br as useChainInfo, Kr as useChainInfos, Se as useCheckWallet, Sr as useConnect, Be as useCosmWasmClient, Cs as useCosmWasmSigningClient, Ss as useCosmWasmTmSigningClient, hr as useDisconnect, es as useExecuteContract, un as useGrazEvents, Zr as useInstantiateContract, wr as useOfflineSigners, Lr as useQueryClientValidators, ns as useQueryRaw, ts as useQuerySmart, Ur as useRecentChainIds, qr as useRecentChains, Jr as useSendIbcTokens, Xr as useSendTokens, Ne as useStargateClient, gs as useStargateSigningClient, ys as useStargateTmSigningClient, Gr as useSuggestChain, Fr as useSuggestChainAndConnect, ye as useTendermintClient };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graz",
|
|
3
3
|
"description": "React hooks for Cosmos",
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.7",
|
|
5
5
|
"author": "Griko Nibras <griko@strange.love>",
|
|
6
6
|
"repository": "https://github.com/graz-sh/graz.git",
|
|
7
7
|
"homepage": "https://github.com/graz-sh/graz",
|
|
@@ -39,7 +39,9 @@
|
|
|
39
39
|
"@cosmjs/proto-signing": "*",
|
|
40
40
|
"@cosmjs/stargate": "*",
|
|
41
41
|
"@cosmjs/tendermint-rpc": "*",
|
|
42
|
-
"
|
|
42
|
+
"@leapwallet/cosmos-social-login-capsule-provider": "^0.0.30",
|
|
43
|
+
"@leapwallet/cosmos-social-login-capsule-provider-ui": "^0.0.47",
|
|
44
|
+
"long": "^4",
|
|
43
45
|
"react": ">=17"
|
|
44
46
|
},
|
|
45
47
|
"peerDependenciesMeta": {
|
|
@@ -53,7 +55,7 @@
|
|
|
53
55
|
"@keplr-wallet/types": "^0.12.23",
|
|
54
56
|
"@metamask/providers": "^12.0.0",
|
|
55
57
|
"@tanstack/react-query": "^4.35.0",
|
|
56
|
-
"@terra-money/station-connector": "^1.0
|
|
58
|
+
"@terra-money/station-connector": "^1.1.0",
|
|
57
59
|
"@vectis/extension-client": "^0.7.2",
|
|
58
60
|
"@walletconnect/sign-client": "^2.10.0",
|
|
59
61
|
"@walletconnect/types": "^2.10.0",
|
|
@@ -62,7 +64,7 @@
|
|
|
62
64
|
"cac": "^6.7.14",
|
|
63
65
|
"cosmos-directory-client": "0.0.6",
|
|
64
66
|
"wadesta": "^0.0.5",
|
|
65
|
-
"zustand": "^4.
|
|
67
|
+
"zustand": "^4.5.2"
|
|
66
68
|
},
|
|
67
69
|
"devDependencies": {
|
|
68
70
|
"@types/node": "^18.17.15",
|