graz 0.0.20 → 0.0.21
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.ts +38 -23
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import * as _cosmjs_amino from '@cosmjs/amino';
|
|
|
11
11
|
|
|
12
12
|
declare type Dictionary<T = string> = Record<string, T>;
|
|
13
13
|
declare type Maybe<T> = T | undefined;
|
|
14
|
+
declare type WalletType = "keplr";
|
|
14
15
|
|
|
15
16
|
interface ChainInfoWithPath extends ChainInfo {
|
|
16
17
|
path: string;
|
|
@@ -144,14 +145,15 @@ declare const testnetChainsArray: ChainInfo[];
|
|
|
144
145
|
|
|
145
146
|
declare type ConnectArgs = Maybe<GrazChain & {
|
|
146
147
|
signerOpts?: SigningCosmWasmClientOptions;
|
|
148
|
+
walletType?: WalletType;
|
|
147
149
|
}>;
|
|
148
150
|
declare function connect(args?: ConnectArgs): Promise<Key>;
|
|
149
151
|
declare function disconnect(clearRecentChain?: boolean): Promise<void>;
|
|
150
152
|
declare function getBalances(bech32Address: string): Promise<Coin[]>;
|
|
151
153
|
declare function reconnect(): void;
|
|
152
154
|
|
|
153
|
-
declare function getRecentChain(): GrazChain | null;
|
|
154
155
|
declare function clearRecentChain(): void;
|
|
156
|
+
declare function getRecentChain(): GrazChain | null;
|
|
155
157
|
declare function suggestChain(chainInfo: ChainInfo): Promise<ChainInfo>;
|
|
156
158
|
declare function suggestChainAndConnect(chainInfo: ChainInfo): Promise<{
|
|
157
159
|
account: Key;
|
|
@@ -177,9 +179,9 @@ interface GrazStore {
|
|
|
177
179
|
stargate: SigningStargateClient;
|
|
178
180
|
} | null;
|
|
179
181
|
status: "connected" | "connecting" | "reconnecting" | "disconnected";
|
|
182
|
+
walletType: WalletType;
|
|
180
183
|
_notFoundFn: () => void;
|
|
181
184
|
_reconnect: boolean;
|
|
182
|
-
_supported: boolean;
|
|
183
185
|
}
|
|
184
186
|
|
|
185
187
|
declare type CreateClientArgs = Pick<GrazChain, "rpc" | "rpcHeaders">;
|
|
@@ -194,10 +196,21 @@ declare function createSigningClients(args: CreateSigningClientArgs): Promise<Gr
|
|
|
194
196
|
interface ConfigureGrazArgs {
|
|
195
197
|
defaultChain?: GrazChain;
|
|
196
198
|
defaultSigningClient?: GrazStore["defaultSigningClient"];
|
|
197
|
-
|
|
199
|
+
defaultWallet?: WalletType;
|
|
200
|
+
onNotFound?: () => void;
|
|
198
201
|
}
|
|
199
202
|
declare function configureGraz(args?: ConfigureGrazArgs): ConfigureGrazArgs;
|
|
200
203
|
|
|
204
|
+
/**
|
|
205
|
+
* Function to check whether given {@link WalletType} or default configured wallet exists.
|
|
206
|
+
*
|
|
207
|
+
* @example
|
|
208
|
+
* ```ts
|
|
209
|
+
* const isSupported = checkWallet();
|
|
210
|
+
* const isKeplrSupported = checkWallet("keplr");
|
|
211
|
+
* ```
|
|
212
|
+
*/
|
|
213
|
+
declare function checkWallet(type?: WalletType): boolean;
|
|
201
214
|
/**
|
|
202
215
|
* Function to return {@link Keplr} object and throws and error if it does not exist on `window`.
|
|
203
216
|
*
|
|
@@ -214,24 +227,18 @@ declare function configureGraz(args?: ConfigureGrazArgs): ConfigureGrazArgs;
|
|
|
214
227
|
*/
|
|
215
228
|
declare function getKeplr(): Keplr;
|
|
216
229
|
/**
|
|
217
|
-
*
|
|
230
|
+
* Function to return wallet object based on given {@link WalletType} or from store and throws an error if it does not
|
|
231
|
+
* exist on `window` or unknown wallet type.
|
|
218
232
|
*
|
|
219
233
|
* @example
|
|
220
234
|
* ```ts
|
|
221
|
-
*
|
|
222
|
-
*
|
|
223
|
-
* });
|
|
235
|
+
* const wallet = getWallet();
|
|
236
|
+
* const keplr = getWallet("keplr");
|
|
224
237
|
* ```
|
|
225
238
|
*
|
|
226
|
-
* @see {@link
|
|
227
|
-
*/
|
|
228
|
-
declare function registerKeplrNotFound(fn: () => void): void;
|
|
229
|
-
/**
|
|
230
|
-
* Clear registered callback when using {@link registerKeplrNotFound}.
|
|
231
|
-
*
|
|
232
|
-
* @see {@link registerKeplrNotFound}
|
|
239
|
+
* @see {@link getKeplr}
|
|
233
240
|
*/
|
|
234
|
-
declare function
|
|
241
|
+
declare function getWallet(type?: WalletType): Keplr;
|
|
235
242
|
|
|
236
243
|
interface MutationEventArgs<TInitial = unknown, TSuccess = TInitial> {
|
|
237
244
|
onError?: (error: unknown, data: TInitial) => unknown;
|
|
@@ -567,16 +574,24 @@ declare function useSigningClients(args?: WithRefetchOpts<CreateSigningClientArg
|
|
|
567
574
|
* ```ts
|
|
568
575
|
* import { useCheckKeplr } from "graz";
|
|
569
576
|
*
|
|
570
|
-
*
|
|
571
|
-
* const isSupported = useCheckKeplr();
|
|
572
|
-
* if (isSupported) {
|
|
573
|
-
* ...
|
|
574
|
-
* }
|
|
577
|
+
* const { data: isSupported } = useCheckKeplr();
|
|
575
578
|
* ```
|
|
576
579
|
*
|
|
577
|
-
* @
|
|
580
|
+
* @deprecated prefer using {@link useCheckWallet}
|
|
581
|
+
*/
|
|
582
|
+
declare function useCheckKeplr(): _tanstack_react_query.UseQueryResult<boolean, unknown>;
|
|
583
|
+
/**
|
|
584
|
+
* graz query hook to check whether given {@link WalletType} or default configured wallet is supported
|
|
585
|
+
*
|
|
586
|
+
* @example
|
|
587
|
+
* ```ts
|
|
588
|
+
* import { useCheckWallet } from "graz";
|
|
589
|
+
*
|
|
590
|
+
* const { data: isSupported } = useCheckWallet();
|
|
591
|
+
* const { data: isKeplrSupported } = useCheckWallet("keplr");
|
|
592
|
+
* ```
|
|
578
593
|
*/
|
|
579
|
-
declare function
|
|
594
|
+
declare function useCheckWallet(type?: WalletType): _tanstack_react_query.UseQueryResult<boolean, unknown>;
|
|
580
595
|
|
|
581
596
|
declare type GrazProviderProps = Partial<QueryClientProviderProps> & {
|
|
582
597
|
grazOptions?: ConfigureGrazArgs;
|
|
@@ -614,4 +629,4 @@ declare function useGrazEvents(): null;
|
|
|
614
629
|
*/
|
|
615
630
|
declare function GrazEvents(): null;
|
|
616
631
|
|
|
617
|
-
export { ChainInfoWithPath, ConfigureGrazArgs, ConnectArgs, CreateClientArgs, CreateSigningClientArgs, Dictionary, GrazChain, GrazEvents, GrazProvider, GrazProviderProps, Maybe, UseAccountArgs, UseConnectChainArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, clearRecentChain, configureGraz, connect, createClients, createSigningClients, defineChain, defineChainInfo, defineChains, disconnect, getBalances, getKeplr, getRecentChain, mainnetChains, mainnetChainsArray, reconnect,
|
|
632
|
+
export { ChainInfoWithPath, ConfigureGrazArgs, ConnectArgs, CreateClientArgs, CreateSigningClientArgs, Dictionary, GrazChain, GrazEvents, GrazProvider, GrazProviderProps, Maybe, UseAccountArgs, UseConnectChainArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WalletType, checkWallet, clearRecentChain, configureGraz, connect, createClients, createSigningClients, defineChain, defineChainInfo, defineChains, disconnect, getBalances, getKeplr, getRecentChain, getWallet, mainnetChains, mainnetChainsArray, reconnect, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, useAccount, useActiveChain, useBalances, useCheckKeplr, useCheckWallet, useClients, useConnect, useDisconnect, useGrazEvents, useRecentChain, useSigners, useSigningClients, useSuggestChain, useSuggestChainAndConnect };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var De=Object.create;var y=Object.defineProperty;var ve=Object.getOwnPropertyDescriptor;var be=Object.getOwnPropertyNames;var Ge=Object.getPrototypeOf,ze=Object.prototype.hasOwnProperty;var je=(e,t)=>{for(var o in t)y(e,o,{get:t[o],enumerable:!0})},Q=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of be(t))!ze.call(e,n)&&n!==o&&y(e,n,{get:()=>t[n],enumerable:!(i=ve(t,n))||i.enumerable});return e};var J=(e,t,o)=>(o=e!=null?De(Ge(e)):{},Q(t||!e||!e.__esModule?y(o,"default",{value:e,enumerable:!0}):o,e)),Oe=e=>Q(y({},"__esModule",{value:!0}),e);var Sn={};je(Sn,{GrazEvents:()=>_,GrazProvider:()=>dn,clearRecentChain:()=>j,configureGraz:()=>M,connect:()=>p,createClients:()=>u,createSigningClients:()=>l,defineChain:()=>en,defineChainInfo:()=>nn,defineChains:()=>Ze,disconnect:()=>G,getBalances:()=>z,getKeplr:()=>g,getRecentChain:()=>Ue,mainnetChains:()=>tn,mainnetChainsArray:()=>on,reconnect:()=>m,registerKeplrNotFound:()=>b,suggestChain:()=>S,suggestChainAndConnect:()=>O,testnetChains:()=>rn,testnetChainsArray:()=>sn,unregisterKeplrNotFound:()=>Ke,useAccount:()=>Se,useActiveChain:()=>un,useBalances:()=>cn,useCheckKeplr:()=>f,useClients:()=>hn,useConnect:()=>an,useDisconnect:()=>mn,useGrazEvents:()=>we,useRecentChain:()=>ln,useSigners:()=>pn,useSigningClients:()=>Cn,useSuggestChain:()=>gn,useSuggestChainAndConnect:()=>fn});module.exports=Oe(Sn);var X=require("@cosmjs/stargate");var V=J(require("zustand")),d=require("zustand/middleware"),I={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",_notFoundFn:()=>null,_reconnect:!1,_supported:!1},Me={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},r=(0,V.default)((0,d.subscribeWithSelector)((0,d.persist)(()=>I,Me)));var D=require("@cosmjs/cosmwasm-stargate"),v=require("@cosmjs/stargate");async function u({rpc:e,rpcHeaders:t}){let o={url:e,headers:{...t||{}}},[i,n]=await Promise.all([D.SigningCosmWasmClient.connect(o),v.SigningStargateClient.connect(o)]);return{cosmWasm:i,stargate:n}}async function l(e){let{rpc:t,rpcHeaders:o,offlineSignerAuto:i,cosmWasmSignerOptions:n={},stargateSignerOptions:s={}}=e,a={url:t,headers:{...o||{}}},[C,x]=await Promise.all([D.SigningCosmWasmClient.connectWithSigner(a,i,n),v.SigningStargateClient.connectWithSigner(a,i,s)]);return{cosmWasm:C,stargate:x}}function g(){if(typeof window.keplr<"u")return window.keplr;throw r.getState()._notFoundFn(),new Error("Keplr is not defined")}function b(e){r.setState({_notFoundFn:e})}function Ke(){r.setState({_notFoundFn:()=>null})}async function p(e){try{let t=g(),{defaultChain:o,recentChain:i}=r.getState(),n=e||i||o;if(!n)throw new Error("No last known connected chain, connect action requires chain info");r.setState(k=>{let Ie=k._reconnect;return k.activeChain&&k.activeChain.chainId!==n.chainId?{status:"connecting"}:Ie?{status:"reconnecting"}:{status:"connecting"}}),await t.enable(n.chainId);let s=t.getOfflineSigner(n.chainId),a=t.getOfflineSignerOnlyAmino(n.chainId),C=await t.getOfflineSignerAuto(n.chainId),x=n.gas?X.GasPrice.fromString(`${n.gas.price}${n.gas.denom}`):void 0,[H,xe,ke]=await Promise.all([t.getKey(n.chainId),u(n),l({...n,offlineSignerAuto:C,cosmWasmSignerOptions:{gasPrice:x,...(e==null?void 0:e.signerOpts)||{}}})]);return r.setState({account:H,activeChain:n,clients:xe,offlineSigner:s,offlineSignerAmino:a,offlineSignerAuto:C,recentChain:n,signingClients:ke,status:"connected",_reconnect:!0}),H}catch(t){throw r.getState().account===null&&r.setState({status:"disconnected"}),t}}async function G(e=!1){return r.setState(t=>({...I,recentChain:e?null:t.recentChain,_supported:t._supported})),Promise.resolve()}async function z(e){let{activeChain:t,signingClients:o}=r.getState();if(!t||!o)throw new Error("No connected account detected");let{defaultSigningClient:i}=r.getState();return await Promise.all(t.currencies.map(async s=>o[i].getBalance(e,s.coinMinimalDenom)))}function m(){let{activeChain:e}=r.getState();e&&p(e)}function Ue(){return r.getState().recentChain}function j(){r.setState({recentChain:null})}async function S(e){return await g().experimentalSuggestChain(e),e}async function O(e){let t=await S(e);return{account:await p(e),chain:t}}function M(e={}){return e.defaultChain&&r.setState({defaultChain:e.defaultChain}),e.defaultSigningClient&&r.setState({defaultSigningClient:e.defaultSigningClient}),e.onKeplrNotFound&&b(e.onKeplrNotFound),e}var Y=require("@keplr-wallet/cosmos"),Z={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},Te={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},qe={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},Pe={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},Be={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},Ne={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},$=[Z,Te,qe,Pe,Be,Ne],K={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:Z,bip44:{coinType:118},bech32Config:Y.Bech32Address.defaultBech32Config("axelar"),currencies:$,feeCurrencies:$};var ne=require("@keplr-wallet/cosmos"),te={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},ee=[te],A={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:te,bip44:{coinType:118},bech32Config:ne.Bech32Address.defaultBech32Config("cosmos"),currencies:ee,feeCurrencies:ee};var ie=require("@keplr-wallet/cosmos"),re={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Re={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},We={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},Ee={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},Fe={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},_e={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Le={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},He={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},Qe={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Je={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Ve={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},oe=[re,Re,We,Ee,Fe,_e,Le,He,Qe,Je,Ve],U={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:re,bip44:{coinType:118},bech32Config:ie.Bech32Address.defaultBech32Config("juno"),currencies:oe,feeCurrencies:oe};var ce=require("@keplr-wallet/cosmos"),ae={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Xe={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},se=[ae,Xe],T={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:ae,bip44:{coinType:118},bech32Config:ce.Bech32Address.defaultBech32Config("osmo"),currencies:se,feeCurrencies:se};var pe=require("@keplr-wallet/cosmos"),ue={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},me=[ue],q={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:ue,bip44:{coinType:118},bech32Config:pe.Bech32Address.defaultBech32Config("somm"),currencies:me,feeCurrencies:me};var ge=require("@keplr-wallet/cosmos"),fe={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},le=[fe],P={rpc:"https://testnet-endpoint.crescent.network/rpc/crescent",rest:"https://testnet-endpoint.crescent.network/api/crescent",chainId:"mooncat-1-1",chainName:"Crescent Testnet",bip44:{coinType:118},bech32Config:ge.Bech32Address.defaultBech32Config("CRE"),currencies:le,feeCurrencies:le,stakeCurrency:fe,coinType:118};var he=require("@keplr-wallet/cosmos"),B={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},$e=[B],N={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-3",chainName:"Juno Testnet",stakeCurrency:B,bip44:{coinType:118},bech32Config:he.Bech32Address.defaultBech32Config("juno"),currencies:$e,feeCurrencies:[B],coinType:118};var Ce=require("@keplr-wallet/cosmos"),R={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Ye=[R],W={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:R,bip44:{coinType:118},bech32Config:Ce.Bech32Address.defaultBech32Config("osmo"),currencies:Ye,feeCurrencies:[R],coinType:118};function Ze(e){return e}function en(e){return e}function nn(e){return e}var tn={axelar:K,cosmos:A,cosmoshub:A,juno:U,osmosis:T,sommelier:q},on=[K,A,U,T,q],rn={crescent:P,juno:N,osmosis:W},sn=[P,N,W];var h=require("@tanstack/react-query"),ye=require("react"),de=J(require("zustand/shallow"));function f(){return r(e=>e._supported)}function Se({onConnect:e,onDisconnect:t}={}){let o=r(n=>n.account),i=r(n=>n.status);return(0,ye.useEffect)(()=>r.subscribe(n=>n.status,(n,s)=>{if(n==="connected"){let a=r.getState();e==null||e({account:a.account,isReconnect:s==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:Boolean(o),isConnecting:i==="connecting",isDisconnected:i==="disconnected",isReconnecting:i==="reconnecting",reconnect:m,status:i}}function cn(e){let{data:t}=Se(),o=e||(t==null?void 0:t.bech32Address),n=(0,h.useQuery)(["USE_BALANCES",o],({queryKey:[,s]})=>z(s),{enabled:Boolean(o)});return{data:n.data,error:n.error,isFetching:n.isFetching,isLoading:n.isLoading,isRefetching:n.isRefetching,isSuccess:n.isSuccess,refetch:n.refetch,status:n.status}}function an({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,h.useMutation)(["USE_CONNECT",e,t,o],p,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return{connect:s=>n.mutate(s),connectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:f(),status:n.status}}function mn({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,h.useMutation)(["USE_DISCONNECT",e,t,o],G,{onError:s=>Promise.resolve(e==null?void 0:e(s,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return{disconnect:s=>n.mutate(s),disconnectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}}function pn(){return r(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),de.default)}var E=require("@tanstack/react-query");function un(){return r(e=>e.activeChain)}function ln(){return{data:r(t=>t.recentChain),clear:j}}function gn({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,E.useMutation)(["USE_SUGGEST_CHAIN",e,t,o],S,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}}function fn({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,E.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],O,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:f(),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}}var F=require("@tanstack/react-query");function hn(e){let t=r(n=>n.clients),i=(0,F.useQuery)(["USE_CLIENTS",e,t],({queryKey:[,n,s]})=>n!=null&&n.rpc?u(n):s,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:i.data,error:i.error,isFetching:i.isFetching,isLoading:i.isLoading,isRefetching:i.isRefetching,isSuccess:i.isSuccess,refetch:i.refetch,status:i.status}}function Cn(e){let t=r(n=>n.signingClients),i=(0,F.useQuery)(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,s]})=>n!=null&&n.rpc?l(n):s,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:i.data,error:i.error,isFetching:i.isFetching,isLoading:i.isLoading,isRefetching:i.isRefetching,isSuccess:i.isSuccess,refetch:i.refetch,status:i.status}}var w=require("@tanstack/react-query");var Ae=require("react");function we(){return(0,Ae.useEffect)(()=>{r.setState({_supported:typeof window.keplr<"u"});let{_reconnect:e}=r.getState();return e&&m(),window.addEventListener("keplr_keystorechange",m),()=>{window.removeEventListener("keplr_keystorechange",m)}},[]),null}function _(){return we(),null}var L=require("react/jsx-runtime"),yn=new w.QueryClient({});function dn({children:e,grazOptions:t,...o}){return t&&M(t),(0,L.jsxs)(w.QueryClientProvider,{client:yn,...o,children:[(0,L.jsx)(_,{}),e]})}0&&(module.exports={GrazEvents,GrazProvider,clearRecentChain,configureGraz,connect,createClients,createSigningClients,defineChain,defineChainInfo,defineChains,disconnect,getBalances,getKeplr,getRecentChain,mainnetChains,mainnetChainsArray,reconnect,registerKeplrNotFound,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,unregisterKeplrNotFound,useAccount,useActiveChain,useBalances,useCheckKeplr,useClients,useConnect,useDisconnect,useGrazEvents,useRecentChain,useSigners,useSigningClients,useSuggestChain,useSuggestChainAndConnect});
|
|
1
|
+
"use strict";var ze=Object.create;var C=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var Oe=Object.getPrototypeOf,We=Object.prototype.hasOwnProperty;var Me=(e,t)=>{for(var o in t)C(e,o,{get:t[o],enumerable:!0})},J=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Te(t))!We.call(e,n)&&n!==o&&C(e,n,{get:()=>t[n],enumerable:!(r=je(t,n))||r.enumerable});return e};var V=(e,t,o)=>(o=e!=null?ze(Oe(e)):{},J(t||!e||!e.__esModule?C(o,"default",{value:e,enumerable:!0}):o,e)),Ue=e=>J(C({},"__esModule",{value:!0}),e);var kn={};Me(kn,{GrazEvents:()=>L,GrazProvider:()=>xn,checkWallet:()=>G,clearRecentChain:()=>j,configureGraz:()=>O,connect:()=>l,createClients:()=>h,createSigningClients:()=>f,defineChain:()=>on,defineChainInfo:()=>rn,defineChains:()=>tn,disconnect:()=>b,getBalances:()=>z,getKeplr:()=>$,getRecentChain:()=>Pe,getWallet:()=>u,mainnetChains:()=>sn,mainnetChainsArray:()=>cn,reconnect:()=>p,suggestChain:()=>w,suggestChainAndConnect:()=>T,testnetChains:()=>an,testnetChainsArray:()=>mn,useAccount:()=>xe,useActiveChain:()=>fn,useBalances:()=>un,useCheckKeplr:()=>pn,useCheckWallet:()=>g,useClients:()=>wn,useConnect:()=>ln,useDisconnect:()=>gn,useGrazEvents:()=>Ie,useRecentChain:()=>yn,useSigners:()=>hn,useSigningClients:()=>Sn,useSuggestChain:()=>Cn,useSuggestChainAndConnect:()=>dn});module.exports=Ue(kn);var Y=require("@cosmjs/stargate");var X=V(require("zustand")),d=require("zustand/middleware"),I={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",walletType:"keplr",_notFoundFn:()=>null,_reconnect:!1},qe={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},i=(0,X.default)((0,d.subscribeWithSelector)((0,d.persist)(()=>I,qe)));var D=require("@cosmjs/cosmwasm-stargate"),v=require("@cosmjs/stargate");async function h({rpc:e,rpcHeaders:t}){let o={url:e,headers:{...t||{}}},[r,n]=await Promise.all([D.SigningCosmWasmClient.connect(o),v.SigningStargateClient.connect(o)]);return{cosmWasm:r,stargate:n}}async function f(e){let{rpc:t,rpcHeaders:o,offlineSignerAuto:r,cosmWasmSignerOptions:n={},stargateSignerOptions:c={}}=e,s={url:t,headers:{...o||{}}},[m,x]=await Promise.all([D.SigningCosmWasmClient.connectWithSigner(s,r,n),v.SigningStargateClient.connectWithSigner(s,r,c)]);return{cosmWasm:m,stargate:x}}function G(e=i.getState().walletType){try{return u(e),!0}catch(t){return console.error(t),!1}}function $(){if(typeof window.keplr<"u")return window.keplr;throw i.getState()._notFoundFn(),new Error("window.keplr is not defined")}function u(e=i.getState().walletType){switch(e){case"keplr":return $();default:throw new Error("Unknown wallet type")}}async function l(e){try{let{defaultChain:t,recentChain:o,walletType:r}=i.getState(),n=(e==null?void 0:e.walletType)||r,c=u(n),s=e||o||t;if(!s)throw new Error("No last known connected chain, connect action requires chain info");i.setState(k=>{let be=k._reconnect;return k.activeChain&&k.activeChain.chainId!==s.chainId?{status:"connecting"}:be?{status:"reconnecting"}:{status:"connecting"}}),await c.enable(s.chainId);let m=c.getOfflineSigner(s.chainId),x=c.getOfflineSignerOnlyAmino(s.chainId),H=await c.getOfflineSignerAuto(s.chainId),De=s.gas?Y.GasPrice.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[Q,ve,Ge]=await Promise.all([c.getKey(s.chainId),h(s),f({...s,offlineSignerAuto:H,cosmWasmSignerOptions:{gasPrice:De,...(e==null?void 0:e.signerOpts)||{}}})]);return i.setState({account:Q,activeChain:s,clients:ve,offlineSigner:m,offlineSignerAmino:x,offlineSignerAuto:H,recentChain:s,signingClients:Ge,status:"connected",walletType:n,_reconnect:!0}),Q}catch(t){throw i.getState().account===null&&i.setState({status:"disconnected"}),t}}async function b(e=!1){return i.setState(t=>({...I,recentChain:e?null:t.recentChain})),Promise.resolve()}async function z(e){let{activeChain:t,signingClients:o}=i.getState();if(!t||!o)throw new Error("No connected account detected");let{defaultSigningClient:r}=i.getState();return await Promise.all(t.currencies.map(async c=>o[r].getBalance(e,c.coinMinimalDenom)))}function p(){let{activeChain:e}=i.getState();e&&l(e)}function j(){i.setState({recentChain:null})}function Pe(){return i.getState().recentChain}async function w(e){return await u().experimentalSuggestChain(e),e}async function T(e){let t=await w(e);return{account:await l(e),chain:t}}function O(e={}){return i.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||e.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn})),e}var ee=require("@keplr-wallet/cosmos"),ne={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},Ke={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},Be={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},Ee={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},Ne={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},Re={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},Z=[ne,Ke,Be,Ee,Ne,Re],W={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:ne,bip44:{coinType:118},bech32Config:ee.Bech32Address.defaultBech32Config("axelar"),currencies:Z,feeCurrencies:Z};var oe=require("@keplr-wallet/cosmos"),re={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},te=[re],S={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:re,bip44:{coinType:118},bech32Config:oe.Bech32Address.defaultBech32Config("cosmos"),currencies:te,feeCurrencies:te};var se=require("@keplr-wallet/cosmos"),ce={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Fe={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},Le={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},_e={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},He={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Qe={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Je={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Ve={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},Xe={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},$e={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Ye={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},ie=[ce,Fe,Le,_e,He,Qe,Je,Ve,Xe,$e,Ye],M={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:ce,bip44:{coinType:118},bech32Config:se.Bech32Address.defaultBech32Config("juno"),currencies:ie,feeCurrencies:ie};var me=require("@keplr-wallet/cosmos"),pe={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Ze={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ae=[pe,Ze],U={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:pe,bip44:{coinType:118},bech32Config:me.Bech32Address.defaultBech32Config("osmo"),currencies:ae,feeCurrencies:ae};var le=require("@keplr-wallet/cosmos"),ge={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},ue=[ge],q={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:ge,bip44:{coinType:118},bech32Config:le.Bech32Address.defaultBech32Config("somm"),currencies:ue,feeCurrencies:ue};var fe=require("@keplr-wallet/cosmos"),ye={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},he=[ye],P={rpc:"https://testnet-endpoint.crescent.network/rpc/crescent",rest:"https://testnet-endpoint.crescent.network/api/crescent",chainId:"mooncat-1-1",chainName:"Crescent Testnet",bip44:{coinType:118},bech32Config:fe.Bech32Address.defaultBech32Config("CRE"),currencies:he,feeCurrencies:he,stakeCurrency:ye,coinType:118};var Ce=require("@keplr-wallet/cosmos"),K={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},en=[K],B={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-3",chainName:"Juno Testnet",stakeCurrency:K,bip44:{coinType:118},bech32Config:Ce.Bech32Address.defaultBech32Config("juno"),currencies:en,feeCurrencies:[K],coinType:118};var de=require("@keplr-wallet/cosmos"),E={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},nn=[E],N={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:E,bip44:{coinType:118},bech32Config:de.Bech32Address.defaultBech32Config("osmo"),currencies:nn,feeCurrencies:[E],coinType:118};function tn(e){return e}function on(e){return e}function rn(e){return e}var sn={axelar:W,cosmos:S,cosmoshub:S,juno:M,osmosis:U,sommelier:q},cn=[W,S,M,U,q],an={crescent:P,juno:B,osmosis:N},mn=[P,B,N];var y=require("@tanstack/react-query"),Se=require("react"),Ae=V(require("zustand/shallow"));var we=require("@tanstack/react-query");function pn(){return g("keplr")}function g(e){let t=i(r=>e||r.walletType);return(0,we.useQuery)(["USE_CHECK_WALLET",t],({queryKey:[,r]})=>G(r))}function xe({onConnect:e,onDisconnect:t}={}){let o=i(n=>n.account),r=i(n=>n.status);return(0,Se.useEffect)(()=>i.subscribe(n=>n.status,(n,c)=>{if(n==="connected"){let s=i.getState();e==null||e({account:s.account,isReconnect:c==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:Boolean(o),isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",reconnect:p,status:r}}function un(e){let{data:t}=xe(),o=e||(t==null?void 0:t.bech32Address),n=(0,y.useQuery)(["USE_BALANCES",o],({queryKey:[,c]})=>z(c),{enabled:Boolean(o)});return{data:n.data,error:n.error,isFetching:n.isFetching,isLoading:n.isLoading,isRefetching:n.isRefetching,isSuccess:n.isSuccess,refetch:n.refetch,status:n.status}}function ln({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,y.useMutation)(["USE_CONNECT",e,t,o],l,{onError:(s,m)=>Promise.resolve(e==null?void 0:e(s,m)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:c}=g();return{connect:s=>n.mutate(s),connectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(c),status:n.status}}function gn({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,y.useMutation)(["USE_DISCONNECT",e,t,o],b,{onError:c=>Promise.resolve(e==null?void 0:e(c,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return{disconnect:c=>n.mutate(c),disconnectAsync:c=>n.mutateAsync(c),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}}function hn(){return i(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Ae.default)}var R=require("@tanstack/react-query");function fn(){return i(e=>e.activeChain)}function yn(){return{data:i(t=>t.recentChain),clear:j}}function Cn({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,R.useMutation)(["USE_SUGGEST_CHAIN",e,t,o],w,{onError:(c,s)=>Promise.resolve(e==null?void 0:e(c,s)),onMutate:t,onSuccess:c=>Promise.resolve(o==null?void 0:o(c))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}}function dn({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,R.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],T,{onError:(s,m)=>Promise.resolve(e==null?void 0:e(s,m)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:c}=g();return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(c),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}}var F=require("@tanstack/react-query");function wn(e){let t=i(n=>n.clients),r=(0,F.useQuery)(["USE_CLIENTS",e,t],({queryKey:[,n,c]})=>n!=null&&n.rpc?h(n):c,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:r.data,error:r.error,isFetching:r.isFetching,isLoading:r.isLoading,isRefetching:r.isRefetching,isSuccess:r.isSuccess,refetch:r.refetch,status:r.status}}function Sn(e){let t=i(n=>n.signingClients),r=(0,F.useQuery)(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,c]})=>n!=null&&n.rpc?f(n):c,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:r.data,error:r.error,isFetching:r.isFetching,isLoading:r.isLoading,isRefetching:r.isRefetching,isSuccess:r.isSuccess,refetch:r.refetch,status:r.status}}var A=require("@tanstack/react-query");var ke=require("react");function Ie(){return(0,ke.useEffect)(()=>{let{_reconnect:e}=i.getState();return e&&p(),window.addEventListener("keplr_keystorechange",p),()=>{window.removeEventListener("keplr_keystorechange",p)}},[]),null}function L(){return Ie(),null}var _=require("react/jsx-runtime"),An=new A.QueryClient({});function xn({children:e,grazOptions:t,...o}){return t&&O(t),(0,_.jsxs)(A.QueryClientProvider,{client:An,...o,children:[(0,_.jsx)(L,{}),e]})}0&&(module.exports={GrazEvents,GrazProvider,checkWallet,clearRecentChain,configureGraz,connect,createClients,createSigningClients,defineChain,defineChainInfo,defineChains,disconnect,getBalances,getKeplr,getRecentChain,getWallet,mainnetChains,mainnetChainsArray,reconnect,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,useAccount,useActiveChain,useBalances,useCheckKeplr,useCheckWallet,useClients,useConnect,useDisconnect,useGrazEvents,useRecentChain,useSigners,useSigningClients,useSuggestChain,useSuggestChainAndConnect});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{GasPrice as ae}from"@cosmjs/stargate";import ie from"zustand";import{persist as re,subscribeWithSelector as se}from"zustand/middleware";var S={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",_notFoundFn:()=>null,_reconnect:!1,_supported:!1},ce={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},i=ie(se(re(()=>S,ce)));import{SigningCosmWasmClient as O}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as M}from"@cosmjs/stargate";async function l({rpc:e,rpcHeaders:t}){let o={url:e,headers:{...t||{}}},[r,n]=await Promise.all([O.connect(o),M.connect(o)]);return{cosmWasm:r,stargate:n}}async function g(e){let{rpc:t,rpcHeaders:o,offlineSignerAuto:r,cosmWasmSignerOptions:n={},stargateSignerOptions:s={}}=e,a={url:t,headers:{...o||{}}},[u,y]=await Promise.all([O.connectWithSigner(a,r,n),M.connectWithSigner(a,r,s)]);return{cosmWasm:u,stargate:y}}function f(){if(typeof window.keplr<"u")return window.keplr;throw i.getState()._notFoundFn(),new Error("Keplr is not defined")}function K(e){i.setState({_notFoundFn:e})}function en(){i.setState({_notFoundFn:()=>null})}async function p(e){try{let t=f(),{defaultChain:o,recentChain:r}=i.getState(),n=e||r||o;if(!n)throw new Error("No last known connected chain, connect action requires chain info");i.setState(d=>{let oe=d._reconnect;return d.activeChain&&d.activeChain.chainId!==n.chainId?{status:"connecting"}:oe?{status:"reconnecting"}:{status:"connecting"}}),await t.enable(n.chainId);let s=t.getOfflineSigner(n.chainId),a=t.getOfflineSignerOnlyAmino(n.chainId),u=await t.getOfflineSignerAuto(n.chainId),y=n.gas?ae.fromString(`${n.gas.price}${n.gas.denom}`):void 0,[j,ne,te]=await Promise.all([t.getKey(n.chainId),l(n),g({...n,offlineSignerAuto:u,cosmWasmSignerOptions:{gasPrice:y,...(e==null?void 0:e.signerOpts)||{}}})]);return i.setState({account:j,activeChain:n,clients:ne,offlineSigner:s,offlineSignerAmino:a,offlineSignerAuto:u,recentChain:n,signingClients:te,status:"connected",_reconnect:!0}),j}catch(t){throw i.getState().account===null&&i.setState({status:"disconnected"}),t}}async function U(e=!1){return i.setState(t=>({...S,recentChain:e?null:t.recentChain,_supported:t._supported})),Promise.resolve()}async function T(e){let{activeChain:t,signingClients:o}=i.getState();if(!t||!o)throw new Error("No connected account detected");let{defaultSigningClient:r}=i.getState();return await Promise.all(t.currencies.map(async s=>o[r].getBalance(e,s.coinMinimalDenom)))}function m(){let{activeChain:e}=i.getState();e&&p(e)}function un(){return i.getState().recentChain}function q(){i.setState({recentChain:null})}async function A(e){return await f().experimentalSuggestChain(e),e}async function P(e){let t=await A(e);return{account:await p(e),chain:t}}function B(e={}){return e.defaultChain&&i.setState({defaultChain:e.defaultChain}),e.defaultSigningClient&&i.setState({defaultSigningClient:e.defaultSigningClient}),e.onKeplrNotFound&&K(e.onKeplrNotFound),e}import{Bech32Address as me}from"@keplr-wallet/cosmos";var R={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},pe={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},ue={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},le={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},ge={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},fe={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},N=[R,pe,ue,le,ge,fe],w={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:R,bip44:{coinType:118},bech32Config:me.defaultBech32Config("axelar"),currencies:N,feeCurrencies:N};import{Bech32Address as he}from"@keplr-wallet/cosmos";var E={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},W=[E],h={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:E,bip44:{coinType:118},bech32Config:he.defaultBech32Config("cosmos"),currencies:W,feeCurrencies:W};import{Bech32Address as Ce}from"@keplr-wallet/cosmos";var _={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},ye={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},de={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},Se={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},Ae={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},we={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},xe={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},ke={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},Ie={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},De={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},ve={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},F=[_,ye,de,Se,Ae,we,xe,ke,Ie,De,ve],x={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:_,bip44:{coinType:118},bech32Config:Ce.defaultBech32Config("juno"),currencies:F,feeCurrencies:F};import{Bech32Address as be}from"@keplr-wallet/cosmos";var H={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Ge={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},L=[H,Ge],k={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:H,bip44:{coinType:118},bech32Config:be.defaultBech32Config("osmo"),currencies:L,feeCurrencies:L};import{Bech32Address as ze}from"@keplr-wallet/cosmos";var J={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},Q=[J],I={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:J,bip44:{coinType:118},bech32Config:ze.defaultBech32Config("somm"),currencies:Q,feeCurrencies:Q};import{Bech32Address as je}from"@keplr-wallet/cosmos";var X={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},V=[X],D={rpc:"https://testnet-endpoint.crescent.network/rpc/crescent",rest:"https://testnet-endpoint.crescent.network/api/crescent",chainId:"mooncat-1-1",chainName:"Crescent Testnet",bip44:{coinType:118},bech32Config:je.defaultBech32Config("CRE"),currencies:V,feeCurrencies:V,stakeCurrency:X,coinType:118};import{Bech32Address as Oe}from"@keplr-wallet/cosmos";var v={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Me=[v],b={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-3",chainName:"Juno Testnet",stakeCurrency:v,bip44:{coinType:118},bech32Config:Oe.defaultBech32Config("juno"),currencies:Me,feeCurrencies:[v],coinType:118};import{Bech32Address as Ke}from"@keplr-wallet/cosmos";var G={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Ue=[G],z={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:G,bip44:{coinType:118},bech32Config:Ke.defaultBech32Config("osmo"),currencies:Ue,feeCurrencies:[G],coinType:118};function Rn(e){return e}function Wn(e){return e}function En(e){return e}var Fn={axelar:w,cosmos:h,cosmoshub:h,juno:x,osmosis:k,sommelier:I},_n=[w,h,x,k,I],Ln={crescent:D,juno:b,osmosis:z},Hn=[D,b,z];import{useMutation as $,useQuery as Te}from"@tanstack/react-query";import{useEffect as qe}from"react";import Pe from"zustand/shallow";function C(){return i(e=>e._supported)}function Be({onConnect:e,onDisconnect:t}={}){let o=i(n=>n.account),r=i(n=>n.status);return qe(()=>i.subscribe(n=>n.status,(n,s)=>{if(n==="connected"){let a=i.getState();e==null||e({account:a.account,isReconnect:s==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:Boolean(o),isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",reconnect:m,status:r}}function tt(e){let{data:t}=Be(),o=e||(t==null?void 0:t.bech32Address),n=Te(["USE_BALANCES",o],({queryKey:[,s]})=>T(s),{enabled:Boolean(o)});return{data:n.data,error:n.error,isFetching:n.isFetching,isLoading:n.isLoading,isRefetching:n.isRefetching,isSuccess:n.isSuccess,refetch:n.refetch,status:n.status}}function ot({onError:e,onLoading:t,onSuccess:o}={}){let n=$(["USE_CONNECT",e,t,o],p,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return{connect:s=>n.mutate(s),connectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:C(),status:n.status}}function it({onError:e,onLoading:t,onSuccess:o}={}){let n=$(["USE_DISCONNECT",e,t,o],U,{onError:s=>Promise.resolve(e==null?void 0:e(s,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return{disconnect:s=>n.mutate(s),disconnectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}}function rt(){return i(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Pe)}import{useMutation as Y}from"@tanstack/react-query";function ut(){return i(e=>e.activeChain)}function lt(){return{data:i(t=>t.recentChain),clear:q}}function gt({onError:e,onLoading:t,onSuccess:o}={}){let n=Y(["USE_SUGGEST_CHAIN",e,t,o],A,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}}function ft({onError:e,onLoading:t,onSuccess:o}={}){let n=Y(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],P,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:C(),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}}import{useQuery as Z}from"@tanstack/react-query";function St(e){let t=i(n=>n.clients),r=Z(["USE_CLIENTS",e,t],({queryKey:[,n,s]})=>n!=null&&n.rpc?l(n):s,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:r.data,error:r.error,isFetching:r.isFetching,isLoading:r.isLoading,isRefetching:r.isRefetching,isSuccess:r.isSuccess,refetch:r.refetch,status:r.status}}function At(e){let t=i(n=>n.signingClients),r=Z(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,s]})=>n!=null&&n.rpc?g(n):s,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:r.data,error:r.error,isFetching:r.isFetching,isLoading:r.isLoading,isRefetching:r.isRefetching,isSuccess:r.isSuccess,refetch:r.refetch,status:r.status}}import{QueryClient as We,QueryClientProvider as Ee}from"@tanstack/react-query";import{useEffect as Ne}from"react";function Re(){return Ne(()=>{i.setState({_supported:typeof window.keplr<"u"});let{_reconnect:e}=i.getState();return e&&m(),window.addEventListener("keplr_keystorechange",m),()=>{window.removeEventListener("keplr_keystorechange",m)}},[]),null}function ee(){return Re(),null}import{jsx as _e,jsxs as Le}from"react/jsx-runtime";var Fe=new We({});function zt({children:e,grazOptions:t,...o}){return t&&B(t),Le(Ee,{client:Fe,...o,children:[_e(ee,{}),e]})}export{ee as GrazEvents,zt as GrazProvider,q as clearRecentChain,B as configureGraz,p as connect,l as createClients,g as createSigningClients,Wn as defineChain,En as defineChainInfo,Rn as defineChains,U as disconnect,T as getBalances,f as getKeplr,un as getRecentChain,Fn as mainnetChains,_n as mainnetChainsArray,m as reconnect,K as registerKeplrNotFound,A as suggestChain,P as suggestChainAndConnect,Ln as testnetChains,Hn as testnetChainsArray,en as unregisterKeplrNotFound,Be as useAccount,ut as useActiveChain,tt as useBalances,C as useCheckKeplr,St as useClients,ot as useConnect,it as useDisconnect,Re as useGrazEvents,lt as useRecentChain,rt as useSigners,At as useSigningClients,gt as useSuggestChain,ft as useSuggestChainAndConnect};
|
|
1
|
+
import{GasPrice as ue}from"@cosmjs/stargate";import se from"zustand";import{persist as ce,subscribeWithSelector as ae}from"zustand/middleware";var w={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",walletType:"keplr",_notFoundFn:()=>null,_reconnect:!1},me={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},i=se(ae(ce(()=>w,me)));import{SigningCosmWasmClient as O}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as W}from"@cosmjs/stargate";async function h({rpc:e,rpcHeaders:t}){let o={url:e,headers:{...t||{}}},[r,n]=await Promise.all([O.connect(o),W.connect(o)]);return{cosmWasm:r,stargate:n}}async function f(e){let{rpc:t,rpcHeaders:o,offlineSignerAuto:r,cosmWasmSignerOptions:n={},stargateSignerOptions:c={}}=e,s={url:t,headers:{...o||{}}},[m,C]=await Promise.all([O.connectWithSigner(s,r,n),W.connectWithSigner(s,r,c)]);return{cosmWasm:m,stargate:C}}function M(e=i.getState().walletType){try{return u(e),!0}catch(t){return console.error(t),!1}}function pe(){if(typeof window.keplr<"u")return window.keplr;throw i.getState()._notFoundFn(),new Error("window.keplr is not defined")}function u(e=i.getState().walletType){switch(e){case"keplr":return pe();default:throw new Error("Unknown wallet type")}}async function l(e){try{let{defaultChain:t,recentChain:o,walletType:r}=i.getState(),n=(e==null?void 0:e.walletType)||r,c=u(n),s=e||o||t;if(!s)throw new Error("No last known connected chain, connect action requires chain info");i.setState(d=>{let ie=d._reconnect;return d.activeChain&&d.activeChain.chainId!==s.chainId?{status:"connecting"}:ie?{status:"reconnecting"}:{status:"connecting"}}),await c.enable(s.chainId);let m=c.getOfflineSigner(s.chainId),C=c.getOfflineSignerOnlyAmino(s.chainId),j=await c.getOfflineSignerAuto(s.chainId),te=s.gas?ue.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[T,oe,re]=await Promise.all([c.getKey(s.chainId),h(s),f({...s,offlineSignerAuto:j,cosmWasmSignerOptions:{gasPrice:te,...(e==null?void 0:e.signerOpts)||{}}})]);return i.setState({account:T,activeChain:s,clients:oe,offlineSigner:m,offlineSignerAmino:C,offlineSignerAuto:j,recentChain:s,signingClients:re,status:"connected",walletType:n,_reconnect:!0}),T}catch(t){throw i.getState().account===null&&i.setState({status:"disconnected"}),t}}async function U(e=!1){return i.setState(t=>({...w,recentChain:e?null:t.recentChain})),Promise.resolve()}async function q(e){let{activeChain:t,signingClients:o}=i.getState();if(!t||!o)throw new Error("No connected account detected");let{defaultSigningClient:r}=i.getState();return await Promise.all(t.currencies.map(async c=>o[r].getBalance(e,c.coinMinimalDenom)))}function p(){let{activeChain:e}=i.getState();e&&l(e)}function P(){i.setState({recentChain:null})}function hn(){return i.getState().recentChain}async function S(e){return await u().experimentalSuggestChain(e),e}async function K(e){let t=await S(e);return{account:await l(e),chain:t}}function B(e={}){return i.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||e.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn})),e}import{Bech32Address as le}from"@keplr-wallet/cosmos";var N={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},ge={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},he={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},fe={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},ye={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},Ce={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},E=[N,ge,he,fe,ye,Ce],A={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:N,bip44:{coinType:118},bech32Config:le.defaultBech32Config("axelar"),currencies:E,feeCurrencies:E};import{Bech32Address as de}from"@keplr-wallet/cosmos";var F={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},R=[F],y={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:F,bip44:{coinType:118},bech32Config:de.defaultBech32Config("cosmos"),currencies:R,feeCurrencies:R};import{Bech32Address as we}from"@keplr-wallet/cosmos";var _={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Se={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},Ae={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},xe={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},ke={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Ie={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},De={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},ve={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},Ge={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},be={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},ze={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},L=[_,Se,Ae,xe,ke,Ie,De,ve,Ge,be,ze],x={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:_,bip44:{coinType:118},bech32Config:we.defaultBech32Config("juno"),currencies:L,feeCurrencies:L};import{Bech32Address as je}from"@keplr-wallet/cosmos";var Q={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Te={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},H=[Q,Te],k={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Q,bip44:{coinType:118},bech32Config:je.defaultBech32Config("osmo"),currencies:H,feeCurrencies:H};import{Bech32Address as Oe}from"@keplr-wallet/cosmos";var V={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},J=[V],I={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:V,bip44:{coinType:118},bech32Config:Oe.defaultBech32Config("somm"),currencies:J,feeCurrencies:J};import{Bech32Address as We}from"@keplr-wallet/cosmos";var $={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},X=[$],D={rpc:"https://testnet-endpoint.crescent.network/rpc/crescent",rest:"https://testnet-endpoint.crescent.network/api/crescent",chainId:"mooncat-1-1",chainName:"Crescent Testnet",bip44:{coinType:118},bech32Config:We.defaultBech32Config("CRE"),currencies:X,feeCurrencies:X,stakeCurrency:$,coinType:118};import{Bech32Address as Me}from"@keplr-wallet/cosmos";var v={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Ue=[v],G={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-3",chainName:"Juno Testnet",stakeCurrency:v,bip44:{coinType:118},bech32Config:Me.defaultBech32Config("juno"),currencies:Ue,feeCurrencies:[v],coinType:118};import{Bech32Address as qe}from"@keplr-wallet/cosmos";var b={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Pe=[b],z={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:b,bip44:{coinType:118},bech32Config:qe.defaultBech32Config("osmo"),currencies:Pe,feeCurrencies:[b],coinType:118};function Rn(e){return e}function Fn(e){return e}function Ln(e){return e}var _n={axelar:A,cosmos:y,cosmoshub:y,juno:x,osmosis:k,sommelier:I},Hn=[A,y,x,k,I],Qn={crescent:D,juno:G,osmosis:z},Jn=[D,G,z];import{useMutation as Y,useQuery as Be}from"@tanstack/react-query";import{useEffect as Ee}from"react";import Ne from"zustand/shallow";import{useQuery as Ke}from"@tanstack/react-query";function Zn(){return g("keplr")}function g(e){let t=i(r=>e||r.walletType);return Ke(["USE_CHECK_WALLET",t],({queryKey:[,r]})=>M(r))}function Re({onConnect:e,onDisconnect:t}={}){let o=i(n=>n.account),r=i(n=>n.status);return Ee(()=>i.subscribe(n=>n.status,(n,c)=>{if(n==="connected"){let s=i.getState();e==null||e({account:s.account,isReconnect:c==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:Boolean(o),isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",reconnect:p,status:r}}function ct(e){let{data:t}=Re(),o=e||(t==null?void 0:t.bech32Address),n=Be(["USE_BALANCES",o],({queryKey:[,c]})=>q(c),{enabled:Boolean(o)});return{data:n.data,error:n.error,isFetching:n.isFetching,isLoading:n.isLoading,isRefetching:n.isRefetching,isSuccess:n.isSuccess,refetch:n.refetch,status:n.status}}function at({onError:e,onLoading:t,onSuccess:o}={}){let n=Y(["USE_CONNECT",e,t,o],l,{onError:(s,m)=>Promise.resolve(e==null?void 0:e(s,m)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:c}=g();return{connect:s=>n.mutate(s),connectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(c),status:n.status}}function mt({onError:e,onLoading:t,onSuccess:o}={}){let n=Y(["USE_DISCONNECT",e,t,o],U,{onError:c=>Promise.resolve(e==null?void 0:e(c,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return{disconnect:c=>n.mutate(c),disconnectAsync:c=>n.mutateAsync(c),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}}function pt(){return i(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Ne)}import{useMutation as Z}from"@tanstack/react-query";function yt(){return i(e=>e.activeChain)}function Ct(){return{data:i(t=>t.recentChain),clear:P}}function dt({onError:e,onLoading:t,onSuccess:o}={}){let n=Z(["USE_SUGGEST_CHAIN",e,t,o],S,{onError:(c,s)=>Promise.resolve(e==null?void 0:e(c,s)),onMutate:t,onSuccess:c=>Promise.resolve(o==null?void 0:o(c))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}}function wt({onError:e,onLoading:t,onSuccess:o}={}){let n=Z(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],K,{onError:(s,m)=>Promise.resolve(e==null?void 0:e(s,m)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:c}=g();return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(c),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}}import{useQuery as ee}from"@tanstack/react-query";function It(e){let t=i(n=>n.clients),r=ee(["USE_CLIENTS",e,t],({queryKey:[,n,c]})=>n!=null&&n.rpc?h(n):c,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:r.data,error:r.error,isFetching:r.isFetching,isLoading:r.isLoading,isRefetching:r.isRefetching,isSuccess:r.isSuccess,refetch:r.refetch,status:r.status}}function Dt(e){let t=i(n=>n.signingClients),r=ee(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,c]})=>n!=null&&n.rpc?f(n):c,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:r.data,error:r.error,isFetching:r.isFetching,isLoading:r.isLoading,isRefetching:r.isRefetching,isSuccess:r.isSuccess,refetch:r.refetch,status:r.status}}import{QueryClient as _e,QueryClientProvider as He}from"@tanstack/react-query";import{useEffect as Fe}from"react";function Le(){return Fe(()=>{let{_reconnect:e}=i.getState();return e&&p(),window.addEventListener("keplr_keystorechange",p),()=>{window.removeEventListener("keplr_keystorechange",p)}},[]),null}function ne(){return Le(),null}import{jsx as Je,jsxs as Ve}from"react/jsx-runtime";var Qe=new _e({});function Mt({children:e,grazOptions:t,...o}){return t&&B(t),Ve(He,{client:Qe,...o,children:[Je(ne,{}),e]})}export{ne as GrazEvents,Mt as GrazProvider,M as checkWallet,P as clearRecentChain,B as configureGraz,l as connect,h as createClients,f as createSigningClients,Fn as defineChain,Ln as defineChainInfo,Rn as defineChains,U as disconnect,q as getBalances,pe as getKeplr,hn as getRecentChain,u as getWallet,_n as mainnetChains,Hn as mainnetChainsArray,p as reconnect,S as suggestChain,K as suggestChainAndConnect,Qn as testnetChains,Jn as testnetChainsArray,Re as useAccount,yt as useActiveChain,ct as useBalances,Zn as useCheckKeplr,g as useCheckWallet,It as useClients,at as useConnect,mt as useDisconnect,Le as useGrazEvents,Ct as useRecentChain,pt as useSigners,Dt as useSigningClients,dt as useSuggestChain,wt as useSuggestChainAndConnect};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graz",
|
|
3
3
|
"description": "React hooks for Cosmos",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.21",
|
|
5
5
|
"author": "Griko Nibras <griko@strangelove.ventures>",
|
|
6
6
|
"repository": "https://github.com/strangelove-ventures/graz.git",
|
|
7
7
|
"homepage": "https://github.com/strangelove-ventures/graz",
|