graz 0.0.19 → 0.0.20
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 +28 -15
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +8 -8
package/dist/index.d.ts
CHANGED
|
@@ -6,8 +6,8 @@ import { ChainInfo, AppCurrency, Key, Keplr } from '@keplr-wallet/types';
|
|
|
6
6
|
import * as _cosmjs_stargate from '@cosmjs/stargate';
|
|
7
7
|
import { StargateClient, SigningStargateClient, SigningStargateClientOptions } from '@cosmjs/stargate';
|
|
8
8
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
9
|
+
import { QueryClientProviderProps } from '@tanstack/react-query';
|
|
9
10
|
import * as _cosmjs_amino from '@cosmjs/amino';
|
|
10
|
-
import { ReactNode } from 'react';
|
|
11
11
|
|
|
12
12
|
declare type Dictionary<T = string> = Record<string, T>;
|
|
13
13
|
declare type Maybe<T> = T | undefined;
|
|
@@ -297,7 +297,7 @@ declare function useBalances(bech32Address?: string): {
|
|
|
297
297
|
isRefetching: boolean;
|
|
298
298
|
isSuccess: boolean;
|
|
299
299
|
refetch: <TPageData>(options?: (_tanstack_react_query.RefetchOptions & _tanstack_react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<_tanstack_react_query.QueryObserverResult<_cosmjs_amino.Coin[], unknown>>;
|
|
300
|
-
status: "error" | "
|
|
300
|
+
status: "error" | "success" | "loading";
|
|
301
301
|
};
|
|
302
302
|
declare type UseConnectChainArgs = MutationEventArgs<ConnectArgs, Key>;
|
|
303
303
|
/**
|
|
@@ -339,7 +339,7 @@ declare function useConnect({ onError, onLoading, onSuccess }?: UseConnectChainA
|
|
|
339
339
|
isLoading: boolean;
|
|
340
340
|
isSuccess: boolean;
|
|
341
341
|
isSupported: boolean;
|
|
342
|
-
status: "error" | "
|
|
342
|
+
status: "error" | "success" | "loading" | "idle";
|
|
343
343
|
};
|
|
344
344
|
/**
|
|
345
345
|
* graz mutation hook to execute wallet disconnection with optional arguments to
|
|
@@ -371,7 +371,7 @@ declare function useDisconnect({ onError, onLoading, onSuccess }?: MutationEvent
|
|
|
371
371
|
error: unknown;
|
|
372
372
|
isLoading: boolean;
|
|
373
373
|
isSuccess: boolean;
|
|
374
|
-
status: "error" | "
|
|
374
|
+
status: "error" | "success" | "loading" | "idle";
|
|
375
375
|
};
|
|
376
376
|
/**
|
|
377
377
|
* graz hook to retrieve offline signer objects (default, amino enabled, and auto).
|
|
@@ -443,7 +443,7 @@ declare function useSuggestChain({ onError, onLoading, onSuccess }?: UseSuggestC
|
|
|
443
443
|
isSuccess: boolean;
|
|
444
444
|
suggest: _tanstack_react_query.UseMutateFunction<ChainInfo, unknown, ChainInfo, unknown>;
|
|
445
445
|
suggestAsync: _tanstack_react_query.UseMutateAsyncFunction<ChainInfo, unknown, ChainInfo, unknown>;
|
|
446
|
-
status: "error" | "
|
|
446
|
+
status: "error" | "success" | "loading" | "idle";
|
|
447
447
|
};
|
|
448
448
|
declare type UseSuggestChainAndConnectArgs = MutationEventArgs<ChainInfo, {
|
|
449
449
|
chain: ChainInfo;
|
|
@@ -481,7 +481,7 @@ declare function useSuggestChainAndConnect({ onError, onLoading, onSuccess }?: U
|
|
|
481
481
|
isLoading: boolean;
|
|
482
482
|
isSuccess: boolean;
|
|
483
483
|
isSupported: boolean;
|
|
484
|
-
status: "error" | "
|
|
484
|
+
status: "error" | "success" | "loading" | "idle";
|
|
485
485
|
suggestAndConnect: _tanstack_react_query.UseMutateFunction<{
|
|
486
486
|
account: Key;
|
|
487
487
|
chain: ChainInfo;
|
|
@@ -523,7 +523,7 @@ declare function useClients(args?: WithRefetchOpts<CreateClientArgs>): {
|
|
|
523
523
|
cosmWasm: _cosmjs_cosmwasm_stargate.CosmWasmClient;
|
|
524
524
|
stargate: _cosmjs_stargate.StargateClient;
|
|
525
525
|
} | null, unknown>>;
|
|
526
|
-
status: "error" | "
|
|
526
|
+
status: "error" | "success" | "loading";
|
|
527
527
|
};
|
|
528
528
|
/**
|
|
529
529
|
* graz query hook to retrieve a SigningCosmWasmClient. If there's no given args it will be using the current connected signer
|
|
@@ -557,7 +557,7 @@ declare function useSigningClients(args?: WithRefetchOpts<CreateSigningClientArg
|
|
|
557
557
|
cosmWasm: _cosmjs_cosmwasm_stargate.SigningCosmWasmClient;
|
|
558
558
|
stargate: _cosmjs_stargate.SigningStargateClient;
|
|
559
559
|
} | null, unknown>>;
|
|
560
|
-
status: "error" | "
|
|
560
|
+
status: "error" | "success" | "loading";
|
|
561
561
|
};
|
|
562
562
|
|
|
563
563
|
/**
|
|
@@ -578,11 +578,12 @@ declare function useSigningClients(args?: WithRefetchOpts<CreateSigningClientArg
|
|
|
578
578
|
*/
|
|
579
579
|
declare function useCheckKeplr(): boolean;
|
|
580
580
|
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
}
|
|
581
|
+
declare type GrazProviderProps = Partial<QueryClientProviderProps> & {
|
|
582
|
+
grazOptions?: ConfigureGrazArgs;
|
|
583
|
+
};
|
|
584
584
|
/**
|
|
585
|
-
* Provider component which
|
|
585
|
+
* Provider component which extends `@tanstack/react-query`'s {@link QueryClientProvider} with built-in query client
|
|
586
|
+
* and various `graz` side effects
|
|
586
587
|
*
|
|
587
588
|
* @example
|
|
588
589
|
* ```tsx
|
|
@@ -598,7 +599,19 @@ interface GrazProviderProps {
|
|
|
598
599
|
*
|
|
599
600
|
* @see https://tanstack.com/query
|
|
600
601
|
*/
|
|
601
|
-
declare function GrazProvider({ children }: GrazProviderProps): JSX.Element;
|
|
602
|
-
|
|
602
|
+
declare function GrazProvider({ children, grazOptions, ...props }: GrazProviderProps): JSX.Element;
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* Graz custom hook to track `keplr_keystorechange` event and reconnect state
|
|
606
|
+
*
|
|
607
|
+
* **Note: only use this hook if not using graz's provider component.**
|
|
608
|
+
*/
|
|
609
|
+
declare function useGrazEvents(): null;
|
|
610
|
+
/**
|
|
611
|
+
* Null component to run {@link useGrazEvents} without affecting component tree.
|
|
612
|
+
*
|
|
613
|
+
* **Note: only use this component if not using graz's provider component.**
|
|
614
|
+
*/
|
|
615
|
+
declare function GrazEvents(): null;
|
|
603
616
|
|
|
604
|
-
export { ChainInfoWithPath, ConfigureGrazArgs, ConnectArgs, CreateClientArgs, CreateSigningClientArgs, Dictionary,
|
|
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, registerKeplrNotFound, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, unregisterKeplrNotFound, useAccount, useActiveChain, useBalances, useCheckKeplr, useClients, useConnect, useDisconnect, useGrazEvents, useRecentChain, useSigners, useSigningClients, useSuggestChain, useSuggestChainAndConnect };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Ie=Object.create;var d=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var be=Object.getPrototypeOf,Ge=Object.prototype.hasOwnProperty;var je=(e,t)=>{for(var o in t)d(e,o,{get:t[o],enumerable:!0})},L=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ve(t))!Ge.call(e,n)&&n!==o&&d(e,n,{get:()=>t[n],enumerable:!(i=De(t,n))||i.enumerable});return e};var H=(e,t,o)=>(o=e!=null?Ie(be(e)):{},L(t||!e||!e.__esModule?d(o,"default",{value:e,enumerable:!0}):o,e)),ze=e=>L(d({},"__esModule",{value:!0}),e);var Sn={};je(Sn,{GRAZ_PROVIDER_COMPONENT_KEY:()=>we,GrazProvider:()=>yn,clearRecentChain:()=>z,configureGraz:()=>Te,connect:()=>p,createClients:()=>u,createSigningClients:()=>l,defineChain:()=>en,defineChainInfo:()=>nn,defineChains:()=>Ze,disconnect:()=>G,getBalances:()=>j,getKeplr:()=>g,getRecentChain:()=>Ke,mainnetChains:()=>tn,mainnetChainsArray:()=>on,reconnect:()=>m,registerKeplrNotFound:()=>b,suggestChain:()=>S,suggestChainAndConnect:()=>O,testnetChains:()=>rn,testnetChainsArray:()=>sn,unregisterKeplrNotFound:()=>Me,useAccount:()=>de,useActiveChain:()=>un,useBalances:()=>cn,useCheckKeplr:()=>h,useClients:()=>fn,useConnect:()=>an,useDisconnect:()=>mn,useRecentChain:()=>ln,useSigners:()=>pn,useSigningClients:()=>Cn,useSuggestChain:()=>gn,useSuggestChainAndConnect:()=>hn});module.exports=ze(Sn);var Q=require("@cosmjs/stargate");var J=H(require("zustand")),y=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},Oe={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},r=(0,J.default)((0,y.subscribeWithSelector)((0,y.persist)(()=>I,Oe)));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 Me(){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 ke=k._reconnect;return k.activeChain&&k.activeChain.chainId!==n.chainId?{status:"connecting"}:ke?{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?Q.GasPrice.fromString(`${n.gas.price}${n.gas.denom}`):void 0,[F,Ae,xe]=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:F,activeChain:n,clients:Ae,offlineSigner:s,offlineSignerAmino:a,offlineSignerAuto:C,recentChain:n,signingClients:xe,status:"connected",_reconnect:!0}),F}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 j(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 Ke(){return r.getState().recentChain}function z(){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 Te(e={}){return e.defaultChain&&r.setState({defaultChain:e.defaultChain}),e.defaultSigningClient&&r.setState({defaultSigningClient:e.defaultSigningClient}),e.onKeplrNotFound&&b(e.onKeplrNotFound),e}var X=require("@keplr-wallet/cosmos"),$={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},Ue={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"},Ne={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},Be={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},V=[$,Ue,qe,Pe,Ne,Be],M={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:$,bip44:{coinType:118},bech32Config:X.Bech32Address.defaultBech32Config("axelar"),currencies:V,feeCurrencies:V};var Z=require("@keplr-wallet/cosmos"),ee={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Y=[ee],w={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:ee,bip44:{coinType:118},bech32Config:Z.Bech32Address.defaultBech32Config("cosmos"),currencies:Y,feeCurrencies:Y};var te=require("@keplr-wallet/cosmos"),oe={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},ne=[oe],K={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:te.Bech32Address.defaultBech32Config("CRE"),currencies:ne,feeCurrencies:ne,stakeCurrency:oe,coinType:118};var re=require("@keplr-wallet/cosmos"),se={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"},_e={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Fe={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"},Je={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Qe={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"},ie=[se,Re,We,Ee,_e,Fe,Le,He,Je,Qe,Ve],T={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:se,bip44:{coinType:118},bech32Config:re.Bech32Address.defaultBech32Config("juno"),currencies:ie,feeCurrencies:ie};var ce=require("@keplr-wallet/cosmos"),U={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Xe=[U],q={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-3",chainName:"Juno Testnet",stakeCurrency:U,bip44:{coinType:118},bech32Config:ce.Bech32Address.defaultBech32Config("juno"),currencies:Xe,feeCurrencies:[U],coinType:118};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"},$e={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ae=[pe,$e],P={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 ue=require("@keplr-wallet/cosmos"),N={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Ye=[N],B={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:N,bip44:{coinType:118},bech32Config:ue.Bech32Address.defaultBech32Config("osmo"),currencies:Ye,feeCurrencies:[N],coinType:118};var ge=require("@keplr-wallet/cosmos"),he={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},le=[he],R={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:he,bip44:{coinType:118},bech32Config:ge.Bech32Address.defaultBech32Config("somm"),currencies:le,feeCurrencies:le};function Ze(e){return e}function en(e){return e}function nn(e){return e}var tn={axelar:M,cosmos:w,cosmoshub:w,juno:T,osmosis:P,sommelier:R},on=[M,w,T,P,R],rn={crescent:K,juno:q,osmosis:B},sn=[K,q,B];var f=require("@tanstack/react-query"),fe=require("react"),Ce=H(require("zustand/shallow"));function h(){return r(e=>e._supported)}function de({onConnect:e,onDisconnect:t}={}){let o=r(n=>n.account),i=r(n=>n.status);return(0,fe.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}=de(),o=e||(t==null?void 0:t.bech32Address),n=(0,f.useQuery)(["USE_BALANCES",o],({queryKey:[,s]})=>j(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,f.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:h(),status:n.status}}function mn({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,f.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}),Ce.default)}var W=require("@tanstack/react-query");function un(){return r(e=>e.activeChain)}function ln(){return{data:r(t=>t.recentChain),clear:z}}function gn({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,W.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 hn({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,W.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:h(),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}}var E=require("@tanstack/react-query");function fn(e){let t=r(n=>n.clients),i=(0,E.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,E.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 A=require("@tanstack/react-query");var ye=require("react");function Se(){return(0,ye.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}var _=require("react/jsx-runtime"),dn=new A.QueryClient({});function yn({children:e}){return(0,_.jsxs)(A.QueryClientProvider,{client:dn,children:[(0,_.jsx)(Se,{}),e]},we)}var we="graz-query-client";0&&(module.exports={GRAZ_PROVIDER_COMPONENT_KEY,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,useRecentChain,useSigners,useSigningClients,useSuggestChain,useSuggestChainAndConnect});
|
|
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});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{GasPrice as ce}from"@cosmjs/stargate";import oe from"zustand";import{persist as ie,subscribeWithSelector as re}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},se={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},i=oe(re(ie(()=>S,se)));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,d]=await Promise.all([O.connectWithSigner(a,r,n),M.connectWithSigner(a,r,s)]);return{cosmWasm:u,stargate:d}}function h(){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 Ze(){i.setState({_notFoundFn:()=>null})}async function p(e){try{let t=h(),{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(y=>{let te=y._reconnect;return y.activeChain&&y.activeChain.chainId!==n.chainId?{status:"connecting"}:te?{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),d=n.gas?ce.fromString(`${n.gas.price}${n.gas.denom}`):void 0,[z,ee,ne]=await Promise.all([t.getKey(n.chainId),l(n),g({...n,offlineSignerAuto:u,cosmWasmSignerOptions:{gasPrice:d,...(e==null?void 0:e.signerOpts)||{}}})]);return i.setState({account:z,activeChain:n,clients:ee,offlineSigner:s,offlineSignerAmino:a,offlineSignerAuto:u,recentChain:n,signingClients:ne,status:"connected",_reconnect:!0}),z}catch(t){throw i.getState().account===null&&i.setState({status:"disconnected"}),t}}async function T(e=!1){return i.setState(t=>({...S,recentChain:e?null:t.recentChain,_supported:t._supported})),Promise.resolve()}async function U(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 pn(){return i.getState().recentChain}function q(){i.setState({recentChain:null})}async function w(e){return await h().experimentalSuggestChain(e),e}async function P(e){let t=await w(e);return{account:await p(e),chain:t}}function hn(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 ae}from"@keplr-wallet/cosmos";var B={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},me={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},pe={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},ue={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},le={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},ge={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},N=[B,me,pe,ue,le,ge],A={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:B,bip44:{coinType:118},bech32Config:ae.defaultBech32Config("axelar"),currencies:N,feeCurrencies:N};import{Bech32Address as he}from"@keplr-wallet/cosmos";var W={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},R=[W],f={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:W,bip44:{coinType:118},bech32Config:he.defaultBech32Config("cosmos"),currencies:R,feeCurrencies:R};import{Bech32Address as fe}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"},E=[_],x={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.defaultBech32Config("CRE"),currencies:E,feeCurrencies:E,stakeCurrency:_,coinType:118};import{Bech32Address as Ce}from"@keplr-wallet/cosmos";var L={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},de={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},ye={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"},we={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Ae={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=[L,de,ye,Se,we,Ae,xe,ke,Ie,De,ve],k={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:L,bip44:{coinType:118},bech32Config:Ce.defaultBech32Config("juno"),currencies:F,feeCurrencies:F};import{Bech32Address as be}from"@keplr-wallet/cosmos";var I={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Ge=[I],D={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-3",chainName:"Juno Testnet",stakeCurrency:I,bip44:{coinType:118},bech32Config:be.defaultBech32Config("juno"),currencies:Ge,feeCurrencies:[I],coinType:118};import{Bech32Address as je}from"@keplr-wallet/cosmos";var J={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"},H=[J,ze],v={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:J,bip44:{coinType:118},bech32Config:je.defaultBech32Config("osmo"),currencies:H,feeCurrencies:H};import{Bech32Address as Oe}from"@keplr-wallet/cosmos";var b={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Me=[b],G={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:Oe.defaultBech32Config("osmo"),currencies:Me,feeCurrencies:[b],coinType:118};import{Bech32Address as Ke}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"},Q=[V],j={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:V,bip44:{coinType:118},bech32Config:Ke.defaultBech32Config("somm"),currencies:Q,feeCurrencies:Q};function Rn(e){return e}function Wn(e){return e}function En(e){return e}var _n={axelar:A,cosmos:f,cosmoshub:f,juno:k,osmosis:v,sommelier:j},Fn=[A,f,k,v,j],Ln={crescent:x,juno:D,osmosis:G},Hn=[x,D,G];import{useMutation as X,useQuery as Te}from"@tanstack/react-query";import{useEffect as Ue}from"react";import qe from"zustand/shallow";function C(){return i(e=>e._supported)}function Pe({onConnect:e,onDisconnect:t}={}){let o=i(n=>n.account),r=i(n=>n.status);return Ue(()=>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}=Pe(),o=e||(t==null?void 0:t.bech32Address),n=Te(["USE_BALANCES",o],({queryKey:[,s]})=>U(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=X(["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=X(["USE_DISCONNECT",e,t,o],T,{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}),qe)}import{useMutation as $}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=$(["USE_SUGGEST_CHAIN",e,t,o],w,{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 ht({onError:e,onLoading:t,onSuccess:o}={}){let n=$(["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 Y}from"@tanstack/react-query";function St(e){let t=i(n=>n.clients),r=Y(["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 wt(e){let t=i(n=>n.signingClients),r=Y(["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 Be,QueryClientProvider as Re}from"@tanstack/react-query";import{useEffect as Ne}from"react";function Z(){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}import{jsx as _e,jsxs as Fe}from"react/jsx-runtime";var We=new Be({});function Gt({children:e}){return Fe(Re,{client:We,children:[_e(Z,{}),e]},Ee)}var Ee="graz-query-client";export{Ee as GRAZ_PROVIDER_COMPONENT_KEY,Gt as GrazProvider,q as clearRecentChain,hn as configureGraz,p as connect,l as createClients,g as createSigningClients,Wn as defineChain,En as defineChainInfo,Rn as defineChains,T as disconnect,U as getBalances,h as getKeplr,pn as getRecentChain,_n as mainnetChains,Fn as mainnetChainsArray,m as reconnect,K as registerKeplrNotFound,w as suggestChain,P as suggestChainAndConnect,Ln as testnetChains,Hn as testnetChainsArray,Ze as unregisterKeplrNotFound,Pe as useAccount,ut as useActiveChain,tt as useBalances,C as useCheckKeplr,St as useClients,ot as useConnect,it as useDisconnect,lt as useRecentChain,rt as useSigners,wt as useSigningClients,gt as useSuggestChain,ht as useSuggestChainAndConnect};
|
|
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};
|
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.20",
|
|
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",
|
|
@@ -35,15 +35,15 @@
|
|
|
35
35
|
],
|
|
36
36
|
"sideEffects": false,
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@cosmjs/cosmwasm-stargate": "^0
|
|
39
|
-
"@cosmjs/proto-signing": "^0
|
|
40
|
-
"@cosmjs/stargate": "^0
|
|
41
|
-
"@keplr-wallet/cosmos": "^0
|
|
42
|
-
"@keplr-wallet/types": "^0
|
|
43
|
-
"@tanstack/react-query": "^4
|
|
38
|
+
"@cosmjs/cosmwasm-stargate": "^0",
|
|
39
|
+
"@cosmjs/proto-signing": "^0",
|
|
40
|
+
"@cosmjs/stargate": "^0",
|
|
41
|
+
"@keplr-wallet/cosmos": "^0",
|
|
42
|
+
"@keplr-wallet/types": "^0",
|
|
43
|
+
"@tanstack/react-query": "^4",
|
|
44
44
|
"arg": "^5",
|
|
45
45
|
"cosmos-directory-client": "0.0.6",
|
|
46
|
-
"zustand": "^4
|
|
46
|
+
"zustand": "^4"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
49
|
"@types/node": "^16",
|