graz 0.0.1 → 0.0.4
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 +16 -3
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +5 -6
package/dist/index.d.ts
CHANGED
|
@@ -18,6 +18,7 @@ declare const defaultChains: {
|
|
|
18
18
|
juno: _keplr_wallet_types.ChainInfo;
|
|
19
19
|
osmosis: _keplr_wallet_types.ChainInfo;
|
|
20
20
|
};
|
|
21
|
+
declare const defaultChainsArray: _keplr_wallet_types.ChainInfo[];
|
|
21
22
|
|
|
22
23
|
declare function reconnect(): void;
|
|
23
24
|
|
|
@@ -27,7 +28,14 @@ interface MutationEventArgs<TInitial = unknown, TSuccess = TInitial> {
|
|
|
27
28
|
onSuccess?: (data: TSuccess) => unknown;
|
|
28
29
|
}
|
|
29
30
|
|
|
30
|
-
|
|
31
|
+
interface UseAccountArgs {
|
|
32
|
+
onConnect?: (args: {
|
|
33
|
+
account: Key;
|
|
34
|
+
isReconnect: boolean;
|
|
35
|
+
}) => void;
|
|
36
|
+
onDisconnect?: () => void;
|
|
37
|
+
}
|
|
38
|
+
declare function useAccount({ onConnect, onDisconnect }?: UseAccountArgs): {
|
|
31
39
|
data: Key | null;
|
|
32
40
|
isConnected: boolean;
|
|
33
41
|
isConnecting: boolean;
|
|
@@ -39,8 +47,8 @@ declare function useAccount(): {
|
|
|
39
47
|
declare function useBalances(bech32Address?: string): {
|
|
40
48
|
data: _cosmjs_amino.Coin[] | undefined;
|
|
41
49
|
error: unknown;
|
|
42
|
-
isLoading: boolean;
|
|
43
50
|
isFetching: boolean;
|
|
51
|
+
isLoading: boolean;
|
|
44
52
|
isRefetching: boolean;
|
|
45
53
|
isSuccess: boolean;
|
|
46
54
|
refetch: <TPageData>(options?: (react_query.RefetchOptions & react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<react_query.QueryObserverResult<_cosmjs_amino.Coin[], unknown>>;
|
|
@@ -52,6 +60,7 @@ declare function useConnect({ onError, onLoading, onSuccess }?: UseConnectChainA
|
|
|
52
60
|
error: unknown;
|
|
53
61
|
isLoading: boolean;
|
|
54
62
|
isSuccess: boolean;
|
|
63
|
+
isSupported: boolean;
|
|
55
64
|
connect: react_query.UseMutateFunction<Key, unknown, GrazChain, unknown>;
|
|
56
65
|
connectAsync: react_query.UseMutateAsyncFunction<Key, unknown, GrazChain, unknown>;
|
|
57
66
|
status: "idle" | "error" | "loading" | "success";
|
|
@@ -81,10 +90,14 @@ declare function useSuggestChain({ onError, onLoading, onSuccess }?: UseSuggestC
|
|
|
81
90
|
status: "idle" | "error" | "loading" | "success";
|
|
82
91
|
};
|
|
83
92
|
|
|
93
|
+
declare function useCheckKeplr(): boolean;
|
|
94
|
+
|
|
84
95
|
declare function getKeplr(): _keplr_wallet_types.Keplr;
|
|
96
|
+
declare function registerKeplrNotFound(fn: () => void): void;
|
|
97
|
+
declare function unregisterKeplrNotFound(): void;
|
|
85
98
|
|
|
86
99
|
declare function GrazProvider({ children }: {
|
|
87
100
|
children: ReactNode;
|
|
88
101
|
}): JSX.Element;
|
|
89
102
|
|
|
90
|
-
export { GrazChain, GrazProvider, UseConnectChainArgs, UseSuggestChainArgs, defaultChains, defineChains, getKeplr, useAccount, useActiveChain, useBalances, useConnect, useCosmWasmClient, useDisconnect, useSigners, useSuggestChain };
|
|
103
|
+
export { GrazChain, GrazProvider, UseAccountArgs, UseConnectChainArgs, UseSuggestChainArgs, defaultChains, defaultChainsArray, defineChains, getKeplr, registerKeplrNotFound, unregisterKeplrNotFound, useAccount, useActiveChain, useBalances, useCheckKeplr, useConnect, useCosmWasmClient, useDisconnect, useSigners, useSuggestChain };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var R=Object.create;var l=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var
|
|
1
|
+
"use strict";var R=Object.create;var l=Object.defineProperty;var H=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var J=Object.getPrototypeOf,V=Object.prototype.hasOwnProperty;var X=(e,t)=>{for(var o in t)l(e,o,{get:t[o],enumerable:!0})},k=(e,t,o,c)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Q(t))!V.call(e,n)&&n!==o&&l(e,n,{get:()=>t[n],enumerable:!(c=H(t,n))||c.enumerable});return e};var d=(e,t,o)=>(o=e!=null?R(J(e)):{},k(t||!e||!e.__esModule?l(o,"default",{value:e,enumerable:!0}):o,e)),Y=e=>k(l({},"__esModule",{value:!0}),e);var ke={};X(ke,{GrazProvider:()=>ve,defaultChains:()=>ue,defaultChainsArray:()=>pe,defineChains:()=>me,getKeplr:()=>u,registerKeplrNotFound:()=>le,unregisterKeplrNotFound:()=>ge,useAccount:()=>B,useActiveChain:()=>we,useBalances:()=>he,useCheckKeplr:()=>v,useConnect:()=>de,useCosmWasmClient:()=>fe,useDisconnect:()=>ye,useSigners:()=>Ce,useSuggestChain:()=>Ae});module.exports=Y(ke);var i=d(require("react"));var j=require("@keplr-wallet/cosmos"),b={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},x=[b],y={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:b,bip44:{coinType:118},bech32Config:j.Bech32Address.defaultBech32Config("cosmos"),currencies:x,feeCurrencies:x};var I=require("@keplr-wallet/cosmos"),z={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Z={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},$={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"},ne={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},te={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},oe={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},re={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"},se={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},ce={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},D=[z,Z,$,ee,ne,te,oe,re,ie,se,ce],C={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:z,bip44:{coinType:118},bech32Config:I.Bech32Address.defaultBech32Config("juno"),currencies:D,feeCurrencies:D};var q=require("@keplr-wallet/cosmos"),_={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},ae={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},G=[_,ae],w={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:_,bip44:{coinType:118},bech32Config:q.Bech32Address.defaultBech32Config("osmo"),currencies:G,feeCurrencies:G};function me(e){return e}var ue={cosmos:y,juno:C,osmosis:w},pe=[y,C,w];var N=require("react"),p=require("react-query"),E=d(require("zustand/shallow"));var U=require("@cosmjs/cosmwasm-stargate");var M=d(require("zustand")),g=require("zustand/middleware"),A={account:null,activeChain:null,balances:null,client:null,signer:null,signerAmino:null,signerAuto:null,status:"disconnected",_notFoundFn:()=>null,_reconnect:!1,_supported:!1},r=(0,M.default)((0,g.subscribeWithSelector)((0,g.persist)(()=>({...A}),{name:"graz",partialize:e=>({activeChain:e.activeChain,_reconnect:e._reconnect}),version:1})));function u(){if(typeof window.keplr<"u")return window.keplr;throw r.getState()._notFoundFn(),new Error("Keplr is not defined")}function le(e){r.setState({_notFoundFn:e})}function ge(){r.setState({_notFoundFn:()=>null})}async function S(e){try{let t=u();r.setState(f=>{let W=f._reconnect;return f.activeChain&&f.activeChain.chainId!==e.chainId?{status:"connecting"}:W?{status:"reconnecting"}:{status:"connecting"}}),await t.enable(e.chainId);let o=t.getOfflineSigner(e.chainId),c=t.getOfflineSignerOnlyAmino(e.chainId),[n,s,m]=await Promise.all([await t.getKey(e.chainId),await t.getOfflineSignerAuto(e.chainId),await U.SigningCosmWasmClient.connectWithSigner(e.rpc,o)]);return r.setState({account:n,activeChain:e,client:m,signer:o,signerAuto:s,signerAmino:c,status:"connected",_reconnect:!0}),n}catch(t){throw r.getState().account===null&&r.setState({status:"disconnected"}),t}}async function K(){return r.setState(e=>({...A,_supported:e._supported})),Promise.resolve()}async function O(e){let{activeChain:t,client:o}=r.getState();if(!t||!o)throw new Error("No connected account detected");return await Promise.all(t.currencies.map(async n=>o.getBalance(e,n.coinMinimalDenom)))}function a(){let{activeChain:e}=r.getState();e&&S(e)}function v(){return r(e=>e._supported)}function B({onConnect:e,onDisconnect:t}={}){let o=r(n=>n.account),c=r(n=>n.status);return(0,N.useEffect)(()=>r.subscribe(n=>n.status,(n,s)=>{if(n==="connected"){let m=r.getState();e==null||e({account:m.account,isReconnect:s==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:Boolean(o),isConnecting:c==="connecting",isDisconnected:c==="disconnected",isReconnecting:c==="reconnecting",reconnect:a,status:c}}function he(e){let{data:t}=B(),o=e||(t==null?void 0:t.bech32Address),n=(0,p.useQuery)(["WADESTA_USE_BALANCES",o],({queryKey:[,s]})=>O(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 fe(){return r(e=>e.client)}function de({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,p.useMutation)(["WADESTA_USE_CONNECT",e,t,o],S,{onError:(s,m)=>Promise.resolve(e==null?void 0:e(s,m)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:v(),connect:n.mutate,connectAsync:n.mutateAsync,status:n.status}}function ye({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,p.useMutation)(["WADESTA_USE_DISCONNECT",e,t,o],K,{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{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,disconnect:n.mutate,disconnectAsync:n.mutateAsync,status:n.status}}function Ce(){return r(e=>({signer:e.signer,signerAmino:e.signerAmino,signerAuto:e.signerAuto}),E.default)}var F=require("react-query");async function T(e){return await u().experimentalSuggestChain(e),e}function we(){return r(e=>e.activeChain)}function Ae({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,F.useMutation)(["WADESTA_USE_SUGGEST_CHAIN",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))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}}var h=require("react-query");var P=require("react");function L(){return(0,P.useEffect)(()=>{r.setState({_supported:typeof window.keplr<"u"});let{_reconnect:e}=r.getState();return e&&a(),window.addEventListener("focus",a),window.addEventListener("keplr_keystorechange",a),()=>{window.removeEventListener("focus",a),window.removeEventListener("keplr_keystorechange",a)}},[]),null}var Se=new h.QueryClient({defaultOptions:{queries:{notifyOnChangeProps:"tracked"}}});function ve({children:e}){return i.createElement(h.QueryClientProvider,{key:"graz-query-client",client:Se},i.createElement(L,null),e)}0&&(module.exports={GrazProvider,defaultChains,defaultChainsArray,defineChains,getKeplr,registerKeplrNotFound,unregisterKeplrNotFound,useAccount,useActiveChain,useBalances,useCheckKeplr,useConnect,useCosmWasmClient,useDisconnect,useSigners,useSuggestChain});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import*as i from"react";import{Bech32Address as
|
|
1
|
+
import*as i from"react";import{Bech32Address as G}from"@keplr-wallet/cosmos";var C={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},y=[C],l={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:C,bip44:{coinType:118},bech32Config:G.defaultBech32Config("cosmos"),currencies:y,feeCurrencies:y};import{Bech32Address as q}from"@keplr-wallet/cosmos";var A={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},_={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},M={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},U={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},K={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},O={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},N={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},E={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},B={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},T={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},F={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},w=[A,_,M,U,K,O,N,E,B,T,F],g={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:A,bip44:{coinType:118},bech32Config:q.defaultBech32Config("juno"),currencies:w,feeCurrencies:w};import{Bech32Address as P}from"@keplr-wallet/cosmos";var v={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},L={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},S=[v,L],h={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:v,bip44:{coinType:118},bech32Config:P.defaultBech32Config("osmo"),currencies:S,feeCurrencies:S};function he(e){return e}var fe={cosmos:l,juno:g,osmosis:h},de=[l,g,h];import{useEffect as J}from"react";import{useMutation as b,useQuery as V}from"react-query";import X from"zustand/shallow";import{SigningCosmWasmClient as Q}from"@cosmjs/cosmwasm-stargate";import W from"zustand";import{persist as R,subscribeWithSelector as H}from"zustand/middleware";var f={account:null,activeChain:null,balances:null,client:null,signer:null,signerAmino:null,signerAuto:null,status:"disconnected",_notFoundFn:()=>null,_reconnect:!1,_supported:!1},r=W(H(R(()=>({...f}),{name:"graz",partialize:e=>({activeChain:e.activeChain,_reconnect:e._reconnect}),version:1})));function u(){if(typeof window.keplr<"u")return window.keplr;throw r.getState()._notFoundFn(),new Error("Keplr is not defined")}function ve(e){r.setState({_notFoundFn:e})}function ke(){r.setState({_notFoundFn:()=>null})}async function d(e){try{let t=u();r.setState(p=>{let z=p._reconnect;return p.activeChain&&p.activeChain.chainId!==e.chainId?{status:"connecting"}:z?{status:"reconnecting"}:{status:"connecting"}}),await t.enable(e.chainId);let o=t.getOfflineSigner(e.chainId),c=t.getOfflineSignerOnlyAmino(e.chainId),[n,s,m]=await Promise.all([await t.getKey(e.chainId),await t.getOfflineSignerAuto(e.chainId),await Q.connectWithSigner(e.rpc,o)]);return r.setState({account:n,activeChain:e,client:m,signer:o,signerAuto:s,signerAmino:c,status:"connected",_reconnect:!0}),n}catch(t){throw r.getState().account===null&&r.setState({status:"disconnected"}),t}}async function k(){return r.setState(e=>({...f,_supported:e._supported})),Promise.resolve()}async function x(e){let{activeChain:t,client:o}=r.getState();if(!t||!o)throw new Error("No connected account detected");return await Promise.all(t.currencies.map(async n=>o.getBalance(e,n.coinMinimalDenom)))}function a(){let{activeChain:e}=r.getState();e&&d(e)}function j(){return r(e=>e._supported)}function Y({onConnect:e,onDisconnect:t}={}){let o=r(n=>n.account),c=r(n=>n.status);return J(()=>r.subscribe(n=>n.status,(n,s)=>{if(n==="connected"){let m=r.getState();e==null||e({account:m.account,isReconnect:s==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:Boolean(o),isConnecting:c==="connecting",isDisconnected:c==="disconnected",isReconnecting:c==="reconnecting",reconnect:a,status:c}}function Ne(e){let{data:t}=Y(),o=e||(t==null?void 0:t.bech32Address),n=V(["WADESTA_USE_BALANCES",o],({queryKey:[,s]})=>x(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 Ee(){return r(e=>e.client)}function Be({onError:e,onLoading:t,onSuccess:o}={}){let n=b(["WADESTA_USE_CONNECT",e,t,o],d,{onError:(s,m)=>Promise.resolve(e==null?void 0:e(s,m)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:j(),connect:n.mutate,connectAsync:n.mutateAsync,status:n.status}}function Te({onError:e,onLoading:t,onSuccess:o}={}){let n=b(["WADESTA_USE_DISCONNECT",e,t,o],k,{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{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,disconnect:n.mutate,disconnectAsync:n.mutateAsync,status:n.status}}function Fe(){return r(e=>({signer:e.signer,signerAmino:e.signerAmino,signerAuto:e.signerAuto}),X)}import{useMutation as Z}from"react-query";async function D(e){return await u().experimentalSuggestChain(e),e}function Je(){return r(e=>e.activeChain)}function Ve({onError:e,onLoading:t,onSuccess:o}={}){let n=Z(["WADESTA_USE_SUGGEST_CHAIN",e,t,o],D,{onError:(s,m)=>Promise.resolve(e==null?void 0:e(s,m)),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}}import{QueryClient as ee,QueryClientProvider as ne}from"react-query";import{useEffect as $}from"react";function I(){return $(()=>{r.setState({_supported:typeof window.keplr<"u"});let{_reconnect:e}=r.getState();return e&&a(),window.addEventListener("focus",a),window.addEventListener("keplr_keystorechange",a),()=>{window.removeEventListener("focus",a),window.removeEventListener("keplr_keystorechange",a)}},[]),null}var te=new ee({defaultOptions:{queries:{notifyOnChangeProps:"tracked"}}});function on({children:e}){return i.createElement(ne,{key:"graz-query-client",client:te},i.createElement(I,null),e)}export{on as GrazProvider,fe as defaultChains,de as defaultChainsArray,he as defineChains,u as getKeplr,ve as registerKeplrNotFound,ke as unregisterKeplrNotFound,Y as useAccount,Je as useActiveChain,Ne as useBalances,j as useCheckKeplr,Be as useConnect,Ee as useCosmWasmClient,Te as useDisconnect,Fe as useSigners,Ve as useSuggestChain};
|
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.4",
|
|
5
5
|
"author": "Griko Nibras <griko@stranvgelove.ventures>",
|
|
6
6
|
"repository": "https://github.com/strangelove-ventures/graz.git",
|
|
7
7
|
"homepage": "https://github.com/strangelove-ventures/graz",
|
|
@@ -21,11 +21,10 @@
|
|
|
21
21
|
"dev": "tsup --watch"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@cosmjs/cosmwasm-stargate": "0.28.10",
|
|
25
|
-
"@cosmjs/proto-signing": "0.28.10",
|
|
26
|
-
"@keplr-wallet/
|
|
27
|
-
"@keplr-wallet/
|
|
28
|
-
"@keplr-wallet/types": "0.10.9",
|
|
24
|
+
"@cosmjs/cosmwasm-stargate": "^0.28.10",
|
|
25
|
+
"@cosmjs/proto-signing": "^0.28.10",
|
|
26
|
+
"@keplr-wallet/cosmos": "^0.10.10",
|
|
27
|
+
"@keplr-wallet/types": "^0.10.10",
|
|
29
28
|
"react-query": "^3",
|
|
30
29
|
"zustand": "4.0.0-rc.1"
|
|
31
30
|
},
|