graz 0.0.7 → 0.0.8
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/{vendor.d.ts → cosmjs.d.ts} +0 -1
- package/dist/{vendor.js → cosmjs.js} +1 -1
- package/dist/{vendor.mjs → cosmjs.mjs} +1 -1
- package/dist/index.d.ts +73 -43
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/keplr.d.ts +2 -0
- package/dist/keplr.js +1 -0
- package/dist/keplr.mjs +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,e,p,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of c(e))!d.call(f,m)&&m!==p&&a(f,m,{get:()=>e[m],enumerable:!(x=b(e,m))||x.enumerable});return f},r=(f,e,p)=>(t(f,e,"default"),p&&t(p,e,"default"));var g=f=>t(a({},"__esModule",{value:!0}),f);var o={};module.exports=g(o);r(o,require("@cosmjs/cosmwasm-stargate"),module.exports);r(o,require("@cosmjs/proto-signing"),module.exports);r(o,require("@cosmjs/stargate"),module.exports);
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,e,p,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of c(e))!d.call(f,m)&&m!==p&&a(f,m,{get:()=>e[m],enumerable:!(x=b(e,m))||x.enumerable});return f},r=(f,e,p)=>(t(f,e,"default"),p&&t(p,e,"default"));var g=f=>t(a({},"__esModule",{value:!0}),f);var o={};module.exports=g(o);r(o,require("@cosmjs/cosmwasm-stargate"),module.exports);r(o,require("@cosmjs/proto-signing"),module.exports);r(o,require("@cosmjs/stargate"),module.exports);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk-L7O257ZE.mjs";export*from"@cosmjs/cosmwasm-stargate";export*from"@cosmjs/proto-signing";export*from"@cosmjs/stargate";
|
|
1
|
+
import"./chunk-L7O257ZE.mjs";export*from"@cosmjs/cosmwasm-stargate";export*from"@cosmjs/proto-signing";export*from"@cosmjs/stargate";
|
package/dist/index.d.ts
CHANGED
|
@@ -9,6 +9,7 @@ import * as _cosmjs_amino from '@cosmjs/amino';
|
|
|
9
9
|
import { ReactNode } from 'react';
|
|
10
10
|
|
|
11
11
|
declare type Dictionary<T = string> = Record<string, T>;
|
|
12
|
+
declare type Maybe<T> = T | undefined;
|
|
12
13
|
|
|
13
14
|
interface GrazChain {
|
|
14
15
|
chainId: string;
|
|
@@ -90,11 +91,17 @@ declare const testnetChains: {
|
|
|
90
91
|
*/
|
|
91
92
|
declare const testnetChainsArray: _keplr_wallet_types.ChainInfo[];
|
|
92
93
|
|
|
93
|
-
declare
|
|
94
|
-
|
|
94
|
+
declare type ConnectArgs = Maybe<GrazChain & {
|
|
95
|
+
signerOpts?: SigningCosmWasmClientOptions;
|
|
96
|
+
}>;
|
|
97
|
+
declare function connect(args?: ConnectArgs): Promise<Key>;
|
|
98
|
+
declare function disconnect(clearRecentChain?: boolean): Promise<void>;
|
|
95
99
|
declare function getBalances(bech32Address: string): Promise<Coin[]>;
|
|
96
100
|
declare function reconnect(): void;
|
|
97
101
|
|
|
102
|
+
declare function configureDefaultChain(chain: GrazChain): GrazChain;
|
|
103
|
+
declare function getRecentChain(): GrazChain | null;
|
|
104
|
+
declare function clearRecentChain(): void;
|
|
98
105
|
declare function suggestChain(chainInfo: ChainInfo): Promise<ChainInfo>;
|
|
99
106
|
declare function suggestChainAndConnect(chainInfo: ChainInfo): Promise<{
|
|
100
107
|
account: Key;
|
|
@@ -109,6 +116,41 @@ declare type CreateSigningClientArgs = CreateClientArgs & {
|
|
|
109
116
|
};
|
|
110
117
|
declare function createSigningClient(args: CreateSigningClientArgs): Promise<SigningCosmWasmClient>;
|
|
111
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Function to return {@link Keplr} object and throws and error if it does not exist on `window`.
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* try {
|
|
125
|
+
* const keplr = getKeplr();
|
|
126
|
+
* } catch (error: Error) {
|
|
127
|
+
* console.error(error.message);
|
|
128
|
+
* }
|
|
129
|
+
* ```
|
|
130
|
+
*
|
|
131
|
+
* @see https://docs.keplr.app
|
|
132
|
+
*/
|
|
133
|
+
declare function getKeplr(): Keplr;
|
|
134
|
+
/**
|
|
135
|
+
* Register a callback to run when invoking {@link getKeplr} throws an error.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* registerKeplrNotFound(() => {
|
|
140
|
+
* console.error("keplr not found");
|
|
141
|
+
* });
|
|
142
|
+
* ```
|
|
143
|
+
*
|
|
144
|
+
* @see {@link unregisterKeplrNotFound}
|
|
145
|
+
*/
|
|
146
|
+
declare function registerKeplrNotFound(fn: () => void): void;
|
|
147
|
+
/**
|
|
148
|
+
* Clear registered callback when using {@link registerKeplrNotFound}.
|
|
149
|
+
*
|
|
150
|
+
* @see {@link registerKeplrNotFound}
|
|
151
|
+
*/
|
|
152
|
+
declare function unregisterKeplrNotFound(): void;
|
|
153
|
+
|
|
112
154
|
interface MutationEventArgs<TInitial = unknown, TSuccess = TInitial> {
|
|
113
155
|
onError?: (error: unknown, data: TInitial) => unknown;
|
|
114
156
|
onLoading?: (data: TInitial) => unknown;
|
|
@@ -175,7 +217,7 @@ declare function useBalances(bech32Address?: string): {
|
|
|
175
217
|
refetch: <TPageData>(options?: (react_query.RefetchOptions & react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<react_query.QueryObserverResult<_cosmjs_amino.Coin[], unknown>>;
|
|
176
218
|
status: "idle" | "error" | "loading" | "success";
|
|
177
219
|
};
|
|
178
|
-
declare type UseConnectChainArgs = MutationEventArgs<
|
|
220
|
+
declare type UseConnectChainArgs = MutationEventArgs<ConnectArgs, Key>;
|
|
179
221
|
/**
|
|
180
222
|
* graz mutation hook to execute wallet connection with optional arguments to
|
|
181
223
|
* invoke given functions on error, loading, or success event.
|
|
@@ -209,8 +251,8 @@ declare type UseConnectChainArgs = MutationEventArgs<GrazChain, Key>;
|
|
|
209
251
|
* @see {@link connect}
|
|
210
252
|
*/
|
|
211
253
|
declare function useConnect({ onError, onLoading, onSuccess }?: UseConnectChainArgs): {
|
|
212
|
-
connect:
|
|
213
|
-
connectAsync:
|
|
254
|
+
connect: (args?: ConnectArgs) => void;
|
|
255
|
+
connectAsync: (args?: ConnectArgs) => Promise<Key>;
|
|
214
256
|
error: unknown;
|
|
215
257
|
isLoading: boolean;
|
|
216
258
|
isSuccess: boolean;
|
|
@@ -234,13 +276,16 @@ declare function useConnect({ onError, onLoading, onSuccess }?: UseConnectChainA
|
|
|
234
276
|
* onLoading: () => { ... },
|
|
235
277
|
* onSuccess: () => { ... },
|
|
236
278
|
* });
|
|
279
|
+
*
|
|
280
|
+
* // pass `true` on disconnect to clear recent connected chain
|
|
281
|
+
* disconnect(true);
|
|
237
282
|
* ```
|
|
238
283
|
*
|
|
239
284
|
* @see {@link disconnect}
|
|
240
285
|
*/
|
|
241
286
|
declare function useDisconnect({ onError, onLoading, onSuccess }?: MutationEventArgs): {
|
|
242
|
-
disconnect: () => void;
|
|
243
|
-
disconnectAsync: () => Promise<void>;
|
|
287
|
+
disconnect: (forget?: boolean) => void;
|
|
288
|
+
disconnectAsync: (forget?: boolean) => Promise<void>;
|
|
244
289
|
error: unknown;
|
|
245
290
|
isLoading: boolean;
|
|
246
291
|
isSuccess: boolean;
|
|
@@ -273,6 +318,26 @@ declare function useSigners(): {
|
|
|
273
318
|
* ```
|
|
274
319
|
*/
|
|
275
320
|
declare function useActiveChain(): GrazChain | null;
|
|
321
|
+
/**
|
|
322
|
+
* graz hook to retrieve last connected chain info
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```ts
|
|
326
|
+
* import { useRecentChain, connect, mainnetChains } from "graz";
|
|
327
|
+
* const recentChain = useRecentChain();
|
|
328
|
+
* try {
|
|
329
|
+
* connect();
|
|
330
|
+
* } catch {
|
|
331
|
+
* connect(mainnetChains.cosmos);
|
|
332
|
+
* }
|
|
333
|
+
* ```
|
|
334
|
+
*
|
|
335
|
+
* @see {@link useActiveChain}
|
|
336
|
+
*/
|
|
337
|
+
declare function useRecentChain(): {
|
|
338
|
+
data: GrazChain | null;
|
|
339
|
+
clear: typeof clearRecentChain;
|
|
340
|
+
};
|
|
276
341
|
declare type UseSuggestChainArgs = MutationEventArgs<ChainInfo>;
|
|
277
342
|
/**
|
|
278
343
|
* graz mutation hook to suggest chain to Keplr Wallet
|
|
@@ -419,41 +484,6 @@ declare function useSigningClient(args?: WithRefetchOpts<CreateSigningClientArgs
|
|
|
419
484
|
*/
|
|
420
485
|
declare function useCheckKeplr(): boolean;
|
|
421
486
|
|
|
422
|
-
/**
|
|
423
|
-
* Function to return {@link Keplr} object and throws and error if it does not exist on `window`.
|
|
424
|
-
*
|
|
425
|
-
* @example
|
|
426
|
-
* ```ts
|
|
427
|
-
* try {
|
|
428
|
-
* const keplr = getKeplr();
|
|
429
|
-
* } catch (error: Error) {
|
|
430
|
-
* console.error(error.message);
|
|
431
|
-
* }
|
|
432
|
-
* ```
|
|
433
|
-
*
|
|
434
|
-
* @see https://docs.keplr.app
|
|
435
|
-
*/
|
|
436
|
-
declare function getKeplr(): Keplr;
|
|
437
|
-
/**
|
|
438
|
-
* Register a callback to run when invoking {@link getKeplr} throws an error.
|
|
439
|
-
*
|
|
440
|
-
* @example
|
|
441
|
-
* ```ts
|
|
442
|
-
* registerKeplrNotFound(() => {
|
|
443
|
-
* console.error("keplr not found");
|
|
444
|
-
* });
|
|
445
|
-
* ```
|
|
446
|
-
*
|
|
447
|
-
* @see {@link unregisterKeplrNotFound}
|
|
448
|
-
*/
|
|
449
|
-
declare function registerKeplrNotFound(fn: () => void): void;
|
|
450
|
-
/**
|
|
451
|
-
* Clear registered callback when using {@link registerKeplrNotFound}.
|
|
452
|
-
*
|
|
453
|
-
* @see {@link registerKeplrNotFound}
|
|
454
|
-
*/
|
|
455
|
-
declare function unregisterKeplrNotFound(): void;
|
|
456
|
-
|
|
457
487
|
interface GrazProviderProps {
|
|
458
488
|
children: ReactNode;
|
|
459
489
|
}
|
|
@@ -476,4 +506,4 @@ interface GrazProviderProps {
|
|
|
476
506
|
*/
|
|
477
507
|
declare function GrazProvider({ children }: GrazProviderProps): JSX.Element;
|
|
478
508
|
|
|
479
|
-
export { CreateClientArgs, CreateSigningClientArgs, GrazChain, GrazProvider, GrazProviderProps, UseAccountArgs, UseConnectChainArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, connect, createClient, createSigningClient, defineChains, disconnect, getBalances, getKeplr, mainnetChains, mainnetChainsArray, reconnect, registerKeplrNotFound, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, unregisterKeplrNotFound, useAccount, useActiveChain, useBalances, useCheckKeplr, useClient, useConnect, useDisconnect, useSigners, useSigningClient, useSuggestChain, useSuggestChainAndConnect };
|
|
509
|
+
export { ConnectArgs, CreateClientArgs, CreateSigningClientArgs, GrazChain, GrazProvider, GrazProviderProps, UseAccountArgs, UseConnectChainArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, clearRecentChain, configureDefaultChain, connect, createClient, createSigningClient, defineChains, disconnect, getBalances, getKeplr, getRecentChain, mainnetChains, mainnetChainsArray, reconnect, registerKeplrNotFound, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, unregisterKeplrNotFound, useAccount, useActiveChain, useBalances, useCheckKeplr, useClient, useConnect, useDisconnect, useRecentChain, useSigners, useSigningClient, useSuggestChain, useSuggestChainAndConnect };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var he=Object.create;var y=Object.defineProperty;var fe=Object.getOwnPropertyDescriptor;var ye=Object.getOwnPropertyNames;var Ce=Object.getPrototypeOf,de=Object.prototype.hasOwnProperty;var we=(e,o)=>{for(var t in o)y(e,t,{get:o[t],enumerable:!0})},T=(e,o,t,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let n of ye(o))!de.call(e,n)&&n!==t&&y(e,n,{get:()=>o[n],enumerable:!(i=fe(o,n))||i.enumerable});return e};var S=(e,o,t)=>(t=e!=null?he(Ce(e)):{},T(o||!e||!e.__esModule?y(t,"default",{value:e,enumerable:!0}):t,e)),Ae=e=>T(y({},"__esModule",{value:!0}),e);var tn={};we(tn,{GrazProvider:()=>nn,connect:()=>p,createClient:()=>l,createSigningClient:()=>g,defineChains:()=>Re,disconnect:()=>I,getBalances:()=>D,getKeplr:()=>u,mainnetChains:()=>Ee,mainnetChainsArray:()=>We,reconnect:()=>m,registerKeplrNotFound:()=>Se,suggestChain:()=>d,suggestChainAndConnect:()=>v,testnetChains:()=>_e,testnetChainsArray:()=>Fe,unregisterKeplrNotFound:()=>xe,useAccount:()=>ce,useActiveChain:()=>Ve,useBalances:()=>Le,useCheckKeplr:()=>h,useClient:()=>Ye,useConnect:()=>He,useDisconnect:()=>Qe,useSigners:()=>Je,useSigningClient:()=>Ze,useSuggestChain:()=>Xe,useSuggestChainAndConnect:()=>$e});module.exports=Ae(tn);var c=S(require("react"));var P=require("@cosmjs/stargate");var N=S(require("zustand")),C=require("zustand/middleware"),x={account:null,activeChain:null,balances:null,client:null,offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,signingClient:null,status:"disconnected",_notFoundFn:()=>null,_reconnect:!1,_supported:!1},r=(0,N.default)((0,C.subscribeWithSelector)((0,C.persist)(()=>({...x}),{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 Se(e){r.setState({_notFoundFn:e})}function xe(){r.setState({_notFoundFn:()=>null})}var k=require("@cosmjs/cosmwasm-stargate");async function l({rpc:e,rpcHeaders:o}){let t={url:e,headers:{...o||{}}};return await k.SigningCosmWasmClient.connect(t)}async function g(e){let{rpc:o,rpcHeaders:t,offlineSigner:i,signerOptions:n={}}=e,s={url:o,headers:{...t||{}}};return await k.SigningCosmWasmClient.connectWithSigner(s,i,n)}async function p(e,o={}){try{let t=u();r.setState(A=>{let ge=A._reconnect;return A.activeChain&&A.activeChain.chainId!==e.chainId?{status:"connecting"}:ge?{status:"reconnecting"}:{status:"connecting"}}),await t.enable(e.chainId);let i=t.getOfflineSigner(e.chainId),n=t.getOfflineSignerOnlyAmino(e.chainId),s=e.gas?P.GasPrice.fromString(`${e.gas.price}${e.gas.denom}`):void 0,[a,pe,ue,le]=await Promise.all([t.getKey(e.chainId),l(e),t.getOfflineSignerAuto(e.chainId),g({...e,offlineSigner:i,signerOptions:{gasPrice:s,...o}})]);return r.setState({account:a,activeChain:e,client:pe,offlineSigner:i,offlineSignerAmino:n,offlineSignerAuto:ue,signingClient:le,status:"connected",_reconnect:!0}),a}catch(t){throw r.getState().account===null&&r.setState({status:"disconnected"}),t}}async function I(){return r.setState(e=>({...x,_supported:e._supported})),Promise.resolve()}async function D(e){let{activeChain:o,signingClient:t}=r.getState();if(!o||!t)throw new Error("No connected account detected");return await Promise.all(o.currencies.map(async n=>t.getBalance(e,n.coinMinimalDenom)))}function m(){let{activeChain:e}=r.getState();e&&p(e)}async function d(e){return await u().experimentalSuggestChain(e),e}async function v(e){let o=await d(e);return{account:await p(e),chain:o}}var E=require("@keplr-wallet/cosmos"),W={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},ke={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},Ie={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},De={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},ve={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"},R=[W,ke,Ie,De,ve,be],b={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:W,bip44:{coinType:118},bech32Config:E.Bech32Address.defaultBech32Config("axelar"),currencies:R,feeCurrencies:R};var F=require("@keplr-wallet/cosmos"),L={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},_=[L],j={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:L,bip44:{coinType:118},bech32Config:F.Bech32Address.defaultBech32Config("cosmos"),currencies:_,feeCurrencies:_};var Q=require("@keplr-wallet/cosmos"),J={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},H=[J],z={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:Q.Bech32Address.defaultBech32Config("CRE"),currencies:H,feeCurrencies:H,stakeCurrency:J,coinType:118};var X=require("@keplr-wallet/cosmos"),$={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},je={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},ze={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},Ge={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},Oe={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Me={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},qe={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Ue={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},Ke={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Be={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Te={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},V=[$,je,ze,Ge,Oe,Me,qe,Ue,Ke,Be,Te],G={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:$,bip44:{coinType:118},bech32Config:X.Bech32Address.defaultBech32Config("juno"),currencies:V,feeCurrencies:V};var Z=require("@keplr-wallet/cosmos"),ee={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Ne={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},Y=[ee,Ne],O={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:ee,bip44:{coinType:118},bech32Config:Z.Bech32Address.defaultBech32Config("osmo"),currencies:Y,feeCurrencies:Y};var ne=require("@keplr-wallet/cosmos"),M={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Pe=[M],q={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:M,bip44:{coinType:118},bech32Config:ne.Bech32Address.defaultBech32Config("osmo"),currencies:Pe,feeCurrencies:[M],coinType:118};var oe=require("@keplr-wallet/cosmos"),ie={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},te=[ie],U={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:ie,bip44:{coinType:118},bech32Config:oe.Bech32Address.defaultBech32Config("somm"),currencies:te,feeCurrencies:te};function Re(e){return e}var Ee={axelar:b,cosmos:j,juno:G,osmosis:O,sommelier:U},We=[b,j,G,O,U],_e={crescent:z,osmosis:q},Fe=[z,q];var re=require("react"),f=require("react-query"),se=S(require("zustand/shallow"));function h(){return r(e=>e._supported)}function ce({onConnect:e,onDisconnect:o}={}){let t=r(n=>n.account),i=r(n=>n.status);return(0,re.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"&&(o==null||o())}),[e,o]),{data:t,isConnected:Boolean(t),isConnecting:i==="connecting",isDisconnected:i==="disconnected",isReconnecting:i==="reconnecting",reconnect:m,status:i}}function Le(e){let{data:o}=ce(),t=e||(o==null?void 0:o.bech32Address),n=(0,f.useQuery)(["USE_BALANCES",t],({queryKey:[,s]})=>D(s),{enabled:Boolean(t)});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 He({onError:e,onLoading:o,onSuccess:t}={}){let n=(0,f.useMutation)(["USE_CONNECT",e,o,t],p,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:o,onSuccess:s=>Promise.resolve(t==null?void 0:t(s))});return{connect:n.mutate,connectAsync:n.mutateAsync,error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:h(),status:n.status}}function Qe({onError:e,onLoading:o,onSuccess:t}={}){let n=(0,f.useMutation)(["USE_DISCONNECT",e,o,t],I,{onError:s=>Promise.resolve(e==null?void 0:e(s,void 0)),onMutate:o,onSuccess:()=>Promise.resolve(t==null?void 0:t(void 0))});return{disconnect:()=>n.mutate(void 0),disconnectAsync:()=>n.mutateAsync(void 0),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}}function Je(){return r(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),se.default)}var K=require("react-query");function Ve(){return r(e=>e.activeChain)}function Xe({onError:e,onLoading:o,onSuccess:t}={}){let n=(0,K.useMutation)(["USE_SUGGEST_CHAIN",e,o,t],d,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:o,onSuccess:s=>Promise.resolve(t==null?void 0:t(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}}function $e({onError:e,onLoading:o,onSuccess:t}={}){let n=(0,K.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,o,t],v,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:o,onSuccess:s=>Promise.resolve(t==null?void 0:t(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:h(),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}}var B=require("react-query");function Ye(e){let o=r(n=>n.client),i=(0,B.useQuery)(["USE_CLIENT",e,o],({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}}function Ze(e){let o=r(n=>n.signingClient),i=(0,B.useQuery)(["USE_SIGNING_CLIENT",e,o],({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: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("react-query");var ae=require("react");function me(){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}var en=new w.QueryClient({defaultOptions:{queries:{notifyOnChangeProps:"tracked"}}});function nn({children:e}){return c.createElement(w.QueryClientProvider,{key:"graz-query-client",client:en},c.createElement(me,null),e)}0&&(module.exports={GrazProvider,connect,createClient,createSigningClient,defineChains,disconnect,getBalances,getKeplr,mainnetChains,mainnetChainsArray,reconnect,registerKeplrNotFound,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,unregisterKeplrNotFound,useAccount,useActiveChain,useBalances,useCheckKeplr,useClient,useConnect,useDisconnect,useSigners,useSigningClient,useSuggestChain,useSuggestChainAndConnect});
|
|
1
|
+
"use strict";var ye=Object.create;var C=Object.defineProperty;var de=Object.getOwnPropertyDescriptor;var we=Object.getOwnPropertyNames;var Ae=Object.getPrototypeOf,Se=Object.prototype.hasOwnProperty;var xe=(e,t)=>{for(var o in t)C(e,o,{get:t[o],enumerable:!0})},R=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of we(t))!Se.call(e,n)&&n!==o&&C(e,n,{get:()=>t[n],enumerable:!(i=de(t,n))||i.enumerable});return e};var S=(e,t,o)=>(o=e!=null?ye(Ae(e)):{},R(t||!e||!e.__esModule?C(o,"default",{value:e,enumerable:!0}):o,e)),ke=e=>R(C({},"__esModule",{value:!0}),e);var mn={};xe(mn,{GrazProvider:()=>an,clearRecentChain:()=>v,configureDefaultChain:()=>ve,connect:()=>p,createClient:()=>u,createSigningClient:()=>l,defineChains:()=>Le,disconnect:()=>I,getBalances:()=>D,getKeplr:()=>g,getRecentChain:()=>be,mainnetChains:()=>He,mainnetChainsArray:()=>Qe,reconnect:()=>m,registerKeplrNotFound:()=>Ie,suggestChain:()=>d,suggestChainAndConnect:()=>b,testnetChains:()=>Je,testnetChainsArray:()=>Ve,unregisterKeplrNotFound:()=>De,useAccount:()=>me,useActiveChain:()=>en,useBalances:()=>Xe,useCheckKeplr:()=>h,useClient:()=>rn,useConnect:()=>$e,useDisconnect:()=>Ye,useRecentChain:()=>nn,useSigners:()=>Ze,useSigningClient:()=>sn,useSuggestChain:()=>tn,useSuggestChainAndConnect:()=>on});module.exports=ke(mn);var c=S(require("react"));var E=require("@cosmjs/stargate");var P=S(require("zustand")),y=require("zustand/middleware"),x={account:null,activeChain:null,balances:null,client:null,defaultChain:null,offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClient:null,status:"disconnected",_notFoundFn:()=>null,_reconnect:!1,_supported:!1},s=(0,P.default)((0,y.subscribeWithSelector)((0,y.persist)(()=>({...x}),{name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1})));var k=require("@cosmjs/cosmwasm-stargate");async function u({rpc:e,rpcHeaders:t}){let o={url:e,headers:{...t||{}}};return await k.SigningCosmWasmClient.connect(o)}async function l(e){let{rpc:t,rpcHeaders:o,offlineSigner:i,signerOptions:n={}}=e,r={url:t,headers:{...o||{}}};return await k.SigningCosmWasmClient.connectWithSigner(r,i,n)}function g(){if(typeof window.keplr<"u")return window.keplr;throw s.getState()._notFoundFn(),new Error("Keplr is not defined")}function Ie(e){s.setState({_notFoundFn:e})}function De(){s.setState({_notFoundFn:()=>null})}async function p(e){try{let t=g(),{defaultChain:o,recentChain:i}=s.getState(),n=e||i||o;if(!n)throw new Error("No last known connected chain, connect action requires chain info");s.setState(A=>{let Ce=A._reconnect;return A.activeChain&&A.activeChain.chainId!==n.chainId?{status:"connecting"}:Ce?{status:"reconnecting"}:{status:"connecting"}}),await t.enable(n.chainId);let r=t.getOfflineSigner(n.chainId),a=t.getOfflineSignerOnlyAmino(n.chainId),le=n.gas?E.GasPrice.fromString(`${n.gas.price}${n.gas.denom}`):void 0,[N,ge,he,fe]=await Promise.all([t.getKey(n.chainId),u(n),t.getOfflineSignerAuto(n.chainId),l({...n,offlineSigner:r,signerOptions:{gasPrice:le,...(e==null?void 0:e.signerOpts)||{}}})]);return s.setState({account:N,activeChain:n,client:ge,offlineSigner:r,offlineSignerAmino:a,offlineSignerAuto:he,recentChain:n,signingClient:fe,status:"connected",_reconnect:!0}),N}catch(t){throw s.getState().account===null&&s.setState({status:"disconnected"}),t}}async function I(e=!1){return s.setState(t=>({...x,recentChain:e?null:t.recentChain,_supported:t._supported})),Promise.resolve()}async function D(e){let{activeChain:t,signingClient:o}=s.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 m(){let{activeChain:e}=s.getState();e&&p(e)}function ve(e){return s.setState({defaultChain:e}),e}function be(){return s.getState().recentChain}function v(){s.setState({recentChain:null})}async function d(e){return await g().experimentalSuggestChain(e),e}async function b(e){let t=await d(e);return{account:await p(e),chain:t}}var _=require("@keplr-wallet/cosmos"),F={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},je={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},ze={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},Ge={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},Oe={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},Me={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},W=[F,je,ze,Ge,Oe,Me],j={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:F,bip44:{coinType:118},bech32Config:_.Bech32Address.defaultBech32Config("axelar"),currencies:W,feeCurrencies:W};var H=require("@keplr-wallet/cosmos"),Q={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},L=[Q],z={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:Q,bip44:{coinType:118},bech32Config:H.Bech32Address.defaultBech32Config("cosmos"),currencies:L,feeCurrencies:L};var V=require("@keplr-wallet/cosmos"),X={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},J=[X],G={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:V.Bech32Address.defaultBech32Config("CRE"),currencies:J,feeCurrencies:J,stakeCurrency:X,coinType:118};var Y=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"},qe={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},Ue={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},Ke={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},Be={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"},Ne={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"},Pe={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Ee={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},We={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},$=[Z,qe,Ue,Ke,Be,Te,Ne,Re,Pe,Ee,We],O={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:Z,bip44:{coinType:118},bech32Config:Y.Bech32Address.defaultBech32Config("juno"),currencies:$,feeCurrencies:$};var ne=require("@keplr-wallet/cosmos"),te={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"},ee=[te,_e],M={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:te,bip44:{coinType:118},bech32Config:ne.Bech32Address.defaultBech32Config("osmo"),currencies:ee,feeCurrencies:ee};var oe=require("@keplr-wallet/cosmos"),q={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Fe=[q],U={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:q,bip44:{coinType:118},bech32Config:oe.Bech32Address.defaultBech32Config("osmo"),currencies:Fe,feeCurrencies:[q],coinType:118};var re=require("@keplr-wallet/cosmos"),se={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},ie=[se],K={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:se,bip44:{coinType:118},bech32Config:re.Bech32Address.defaultBech32Config("somm"),currencies:ie,feeCurrencies:ie};function Le(e){return e}var He={axelar:j,cosmos:z,juno:O,osmosis:M,sommelier:K},Qe=[j,z,O,M,K],Je={crescent:G,osmosis:U},Ve=[G,U];var ce=require("react"),f=require("react-query"),ae=S(require("zustand/shallow"));function h(){return s(e=>e._supported)}function me({onConnect:e,onDisconnect:t}={}){let o=s(n=>n.account),i=s(n=>n.status);return(0,ce.useEffect)(()=>s.subscribe(n=>n.status,(n,r)=>{if(n==="connected"){let a=s.getState();e==null||e({account:a.account,isReconnect:r==="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 Xe(e){let{data:t}=me(),o=e||(t==null?void 0:t.bech32Address),n=(0,f.useQuery)(["USE_BALANCES",o],({queryKey:[,r]})=>D(r),{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 $e({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,f.useMutation)(["USE_CONNECT",e,t,o],p,{onError:(r,a)=>Promise.resolve(e==null?void 0:e(r,a)),onMutate:t,onSuccess:r=>Promise.resolve(o==null?void 0:o(r))});return{connect:r=>n.mutate(r),connectAsync:r=>n.mutateAsync(r),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:h(),status:n.status}}function Ye({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,f.useMutation)(["USE_DISCONNECT",e,t,o],I,{onError:r=>Promise.resolve(e==null?void 0:e(r,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return{disconnect:r=>n.mutate(r),disconnectAsync:r=>n.mutateAsync(r),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}}function Ze(){return s(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),ae.default)}var B=require("react-query");function en(){return s(e=>e.activeChain)}function nn(){return{data:s(t=>t.recentChain),clear:v}}function tn({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,B.useMutation)(["USE_SUGGEST_CHAIN",e,t,o],d,{onError:(r,a)=>Promise.resolve(e==null?void 0:e(r,a)),onMutate:t,onSuccess:r=>Promise.resolve(o==null?void 0:o(r))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}}function on({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,B.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],b,{onError:(r,a)=>Promise.resolve(e==null?void 0:e(r,a)),onMutate:t,onSuccess:r=>Promise.resolve(o==null?void 0:o(r))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:h(),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}}var T=require("react-query");function rn(e){let t=s(n=>n.client),i=(0,T.useQuery)(["USE_CLIENT",e,t],({queryKey:[,n,r]})=>n!=null&&n.rpc?u(n):r,{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 sn(e){let t=s(n=>n.signingClient),i=(0,T.useQuery)(["USE_SIGNING_CLIENT",e,t],({queryKey:[,n,r]})=>n!=null&&n.rpc?l(n):r,{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("react-query");var pe=require("react");function ue(){return(0,pe.useEffect)(()=>{s.setState({_supported:typeof window.keplr<"u"});let{_reconnect:e}=s.getState();return e&&m(),window.addEventListener("keplr_keystorechange",m),()=>{window.removeEventListener("keplr_keystorechange",m)}},[]),null}var cn=new w.QueryClient({defaultOptions:{queries:{notifyOnChangeProps:"tracked"}}});function an({children:e}){return c.createElement(w.QueryClientProvider,{key:"graz-query-client",client:cn},c.createElement(ue,null),e)}0&&(module.exports={GrazProvider,clearRecentChain,configureDefaultChain,connect,createClient,createSigningClient,defineChains,disconnect,getBalances,getKeplr,getRecentChain,mainnetChains,mainnetChainsArray,reconnect,registerKeplrNotFound,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,unregisterKeplrNotFound,useAccount,useActiveChain,useBalances,useCheckKeplr,useClient,useConnect,useDisconnect,useRecentChain,useSigners,useSigningClient,useSuggestChain,useSuggestChainAndConnect});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as c}from"./chunk-L7O257ZE.mjs";import{GasPrice as Z}from"@cosmjs/stargate";import X from"zustand";import{persist as $,subscribeWithSelector as Y}from"zustand/middleware";var y={account:null,activeChain:null,balances:null,client:null,offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,signingClient:null,status:"disconnected",_notFoundFn:()=>null,_reconnect:!1,_supported:!1},r=X(Y($(()=>({...y}),{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 Te(e){r.setState({_notFoundFn:e})}function Ne(){r.setState({_notFoundFn:()=>null})}import{SigningCosmWasmClient as v}from"@cosmjs/cosmwasm-stargate";async function l({rpc:e,rpcHeaders:o}){let t={url:e,headers:{...o||{}}};return await v.connect(t)}async function g(e){let{rpc:o,rpcHeaders:t,offlineSigner:i,signerOptions:n={}}=e,s={url:o,headers:{...t||{}}};return await v.connectWithSigner(s,i,n)}async function p(e,o={}){try{let t=u();r.setState(f=>{let V=f._reconnect;return f.activeChain&&f.activeChain.chainId!==e.chainId?{status:"connecting"}:V?{status:"reconnecting"}:{status:"connecting"}}),await t.enable(e.chainId);let i=t.getOfflineSigner(e.chainId),n=t.getOfflineSignerOnlyAmino(e.chainId),s=e.gas?Z.fromString(`${e.gas.price}${e.gas.denom}`):void 0,[a,H,Q,J]=await Promise.all([t.getKey(e.chainId),l(e),t.getOfflineSignerAuto(e.chainId),g({...e,offlineSigner:i,signerOptions:{gasPrice:s,...o}})]);return r.setState({account:a,activeChain:e,client:H,offlineSigner:i,offlineSignerAmino:n,offlineSignerAuto:Q,signingClient:J,status:"connected",_reconnect:!0}),a}catch(t){throw r.getState().account===null&&r.setState({status:"disconnected"}),t}}async function b(){return r.setState(e=>({...y,_supported:e._supported})),Promise.resolve()}async function j(e){let{activeChain:o,signingClient:t}=r.getState();if(!o||!t)throw new Error("No connected account detected");return await Promise.all(o.currencies.map(async n=>t.getBalance(e,n.coinMinimalDenom)))}function m(){let{activeChain:e}=r.getState();e&&p(e)}async function C(e){return await u().experimentalSuggestChain(e),e}async function z(e){let o=await C(e);return{account:await p(e),chain:o}}import{Bech32Address as ee}from"@keplr-wallet/cosmos";var O={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},ne={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},te={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},oe={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},ie={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},re={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},G=[O,ne,te,oe,ie,re],d={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:O,bip44:{coinType:118},bech32Config:ee.defaultBech32Config("axelar"),currencies:G,feeCurrencies:G};import{Bech32Address as se}from"@keplr-wallet/cosmos";var q={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},M=[q],w={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:q,bip44:{coinType:118},bech32Config:se.defaultBech32Config("cosmos"),currencies:M,feeCurrencies:M};import{Bech32Address as ce}from"@keplr-wallet/cosmos";var K={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},U=[K],A={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:ce.defaultBech32Config("CRE"),currencies:U,feeCurrencies:U,stakeCurrency:K,coinType:118};import{Bech32Address as ae}from"@keplr-wallet/cosmos";var T={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},me={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},pe={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},ue={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},le={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},ge={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},he={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},fe={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},ye={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Ce={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},de={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},B=[T,me,pe,ue,le,ge,he,fe,ye,Ce,de],S={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:T,bip44:{coinType:118},bech32Config:ae.defaultBech32Config("juno"),currencies:B,feeCurrencies:B};import{Bech32Address as we}from"@keplr-wallet/cosmos";var P={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"},N=[P,Ae],x={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:P,bip44:{coinType:118},bech32Config:we.defaultBech32Config("osmo"),currencies:N,feeCurrencies:N};import{Bech32Address as Se}from"@keplr-wallet/cosmos";var k={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},xe=[k],I={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:k,bip44:{coinType:118},bech32Config:Se.defaultBech32Config("osmo"),currencies:xe,feeCurrencies:[k],coinType:118};import{Bech32Address as ke}from"@keplr-wallet/cosmos";var E={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},R=[E],D={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:E,bip44:{coinType:118},bech32Config:ke.defaultBech32Config("somm"),currencies:R,feeCurrencies:R};function dn(e){return e}var wn={axelar:d,cosmos:w,juno:S,osmosis:x,sommelier:D},An=[d,w,S,x,D],Sn={crescent:A,osmosis:I},xn=[A,I];import{useEffect as Ie}from"react";import{useMutation as W,useQuery as De}from"react-query";import ve from"zustand/shallow";function h(){return r(e=>e._supported)}function be({onConnect:e,onDisconnect:o}={}){let t=r(n=>n.account),i=r(n=>n.status);return Ie(()=>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"&&(o==null||o())}),[e,o]),{data:t,isConnected:Boolean(t),isConnecting:i==="connecting",isDisconnected:i==="disconnected",isReconnecting:i==="reconnecting",reconnect:m,status:i}}function Mn(e){let{data:o}=be(),t=e||(o==null?void 0:o.bech32Address),n=De(["USE_BALANCES",t],({queryKey:[,s]})=>j(s),{enabled:Boolean(t)});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 qn({onError:e,onLoading:o,onSuccess:t}={}){let n=W(["USE_CONNECT",e,o,t],p,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:o,onSuccess:s=>Promise.resolve(t==null?void 0:t(s))});return{connect:n.mutate,connectAsync:n.mutateAsync,error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:h(),status:n.status}}function Un({onError:e,onLoading:o,onSuccess:t}={}){let n=W(["USE_DISCONNECT",e,o,t],b,{onError:s=>Promise.resolve(e==null?void 0:e(s,void 0)),onMutate:o,onSuccess:()=>Promise.resolve(t==null?void 0:t(void 0))});return{disconnect:()=>n.mutate(void 0),disconnectAsync:()=>n.mutateAsync(void 0),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}}function Kn(){return r(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),ve)}import{useMutation as _}from"react-query";function En(){return r(e=>e.activeChain)}function Wn({onError:e,onLoading:o,onSuccess:t}={}){let n=_(["USE_SUGGEST_CHAIN",e,o,t],C,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:o,onSuccess:s=>Promise.resolve(t==null?void 0:t(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}}function _n({onError:e,onLoading:o,onSuccess:t}={}){let n=_(["USE_SUGGEST_CHAIN_AND_CONNECT",e,o,t],z,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:o,onSuccess:s=>Promise.resolve(t==null?void 0:t(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:h(),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}}import{useQuery as F}from"react-query";function Jn(e){let o=r(n=>n.client),i=F(["USE_CLIENT",e,o],({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}}function Vn(e){let o=r(n=>n.signingClient),i=F(["USE_SIGNING_CLIENT",e,o],({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:i.data,error:i.error,isFetching:i.isFetching,isLoading:i.isLoading,isRefetching:i.isRefetching,isSuccess:i.isSuccess,refetch:i.refetch,status:i.status}}import{QueryClient as ze,QueryClientProvider as Ge}from"react-query";import{useEffect as je}from"react";function L(){return je(()=>{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 Oe=new ze({defaultOptions:{queries:{notifyOnChangeProps:"tracked"}}});function ot({children:e}){return c.createElement(Ge,{key:"graz-query-client",client:Oe},c.createElement(L,null),e)}export{ot as GrazProvider,p as connect,l as createClient,g as createSigningClient,dn as defineChains,b as disconnect,j as getBalances,u as getKeplr,wn as mainnetChains,An as mainnetChainsArray,m as reconnect,Te as registerKeplrNotFound,C as suggestChain,z as suggestChainAndConnect,Sn as testnetChains,xn as testnetChainsArray,Ne as unregisterKeplrNotFound,be as useAccount,En as useActiveChain,Mn as useBalances,h as useCheckKeplr,Jn as useClient,qn as useConnect,Un as useDisconnect,Kn as useSigners,Vn as useSigningClient,Wn as useSuggestChain,_n as useSuggestChainAndConnect};
|
|
1
|
+
import{a as c}from"./chunk-L7O257ZE.mjs";import{GasPrice as te}from"@cosmjs/stargate";import Z from"zustand";import{persist as ee,subscribeWithSelector as ne}from"zustand/middleware";var C={account:null,activeChain:null,balances:null,client:null,defaultChain:null,offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClient:null,status:"disconnected",_notFoundFn:()=>null,_reconnect:!1,_supported:!1},r=Z(ne(ee(()=>({...C}),{name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1})));import{SigningCosmWasmClient as b}from"@cosmjs/cosmwasm-stargate";async function u({rpc:e,rpcHeaders:t}){let o={url:e,headers:{...t||{}}};return await b.connect(o)}async function l(e){let{rpc:t,rpcHeaders:o,offlineSigner:s,signerOptions:n={}}=e,i={url:t,headers:{...o||{}}};return await b.connectWithSigner(i,s,n)}function g(){if(typeof window.keplr<"u")return window.keplr;throw r.getState()._notFoundFn(),new Error("Keplr is not defined")}function We(e){r.setState({_notFoundFn:e})}function _e(){r.setState({_notFoundFn:()=>null})}async function p(e){try{let t=g(),{defaultChain:o,recentChain:s}=r.getState(),n=e||s||o;if(!n)throw new Error("No last known connected chain, connect action requires chain info");r.setState(f=>{let Y=f._reconnect;return f.activeChain&&f.activeChain.chainId!==n.chainId?{status:"connecting"}:Y?{status:"reconnecting"}:{status:"connecting"}}),await t.enable(n.chainId);let i=t.getOfflineSigner(n.chainId),a=t.getOfflineSignerOnlyAmino(n.chainId),J=n.gas?te.fromString(`${n.gas.price}${n.gas.denom}`):void 0,[v,V,X,$]=await Promise.all([t.getKey(n.chainId),u(n),t.getOfflineSignerAuto(n.chainId),l({...n,offlineSigner:i,signerOptions:{gasPrice:J,...(e==null?void 0:e.signerOpts)||{}}})]);return r.setState({account:v,activeChain:n,client:V,offlineSigner:i,offlineSignerAmino:a,offlineSignerAuto:X,recentChain:n,signingClient:$,status:"connected",_reconnect:!0}),v}catch(t){throw r.getState().account===null&&r.setState({status:"disconnected"}),t}}async function j(e=!1){return r.setState(t=>({...C,recentChain:e?null:t.recentChain,_supported:t._supported})),Promise.resolve()}async function z(e){let{activeChain:t,signingClient: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 m(){let{activeChain:e}=r.getState();e&&p(e)}function Ze(e){return r.setState({defaultChain:e}),e}function en(){return r.getState().recentChain}function G(){r.setState({recentChain:null})}async function y(e){return await g().experimentalSuggestChain(e),e}async function O(e){let t=await y(e);return{account:await p(e),chain:t}}import{Bech32Address as oe}from"@keplr-wallet/cosmos";var q={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},ie={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},re={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},se={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},ce={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},ae={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},M=[q,ie,re,se,ce,ae],d={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:q,bip44:{coinType:118},bech32Config:oe.defaultBech32Config("axelar"),currencies:M,feeCurrencies:M};import{Bech32Address as me}from"@keplr-wallet/cosmos";var K={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},U=[K],w={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:K,bip44:{coinType:118},bech32Config:me.defaultBech32Config("cosmos"),currencies:U,feeCurrencies:U};import{Bech32Address as pe}from"@keplr-wallet/cosmos";var T={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},B=[T],A={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:pe.defaultBech32Config("CRE"),currencies:B,feeCurrencies:B,stakeCurrency:T,coinType:118};import{Bech32Address as ue}from"@keplr-wallet/cosmos";var P={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},le={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},ge={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},he={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"},Ce={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},ye={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},de={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},we={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Ae={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Se={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},N=[P,le,ge,he,fe,Ce,ye,de,we,Ae,Se],S={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:P,bip44:{coinType:118},bech32Config:ue.defaultBech32Config("juno"),currencies:N,feeCurrencies:N};import{Bech32Address as xe}from"@keplr-wallet/cosmos";var E={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},ke={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},R=[E,ke],x={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:E,bip44:{coinType:118},bech32Config:xe.defaultBech32Config("osmo"),currencies:R,feeCurrencies:R};import{Bech32Address as Ie}from"@keplr-wallet/cosmos";var k={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},De=[k],I={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:k,bip44:{coinType:118},bech32Config:Ie.defaultBech32Config("osmo"),currencies:De,feeCurrencies:[k],coinType:118};import{Bech32Address as ve}from"@keplr-wallet/cosmos";var _={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},W=[_],D={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:_,bip44:{coinType:118},bech32Config:ve.defaultBech32Config("somm"),currencies:W,feeCurrencies:W};function In(e){return e}var Dn={axelar:d,cosmos:w,juno:S,osmosis:x,sommelier:D},vn=[d,w,S,x,D],bn={crescent:A,osmosis:I},jn=[A,I];import{useEffect as be}from"react";import{useMutation as F,useQuery as je}from"react-query";import ze from"zustand/shallow";function h(){return r(e=>e._supported)}function Ge({onConnect:e,onDisconnect:t}={}){let o=r(n=>n.account),s=r(n=>n.status);return be(()=>r.subscribe(n=>n.status,(n,i)=>{if(n==="connected"){let a=r.getState();e==null||e({account:a.account,isReconnect:i==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:Boolean(o),isConnecting:s==="connecting",isDisconnected:s==="disconnected",isReconnecting:s==="reconnecting",reconnect:m,status:s}}function Nn(e){let{data:t}=Ge(),o=e||(t==null?void 0:t.bech32Address),n=je(["USE_BALANCES",o],({queryKey:[,i]})=>z(i),{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 Pn({onError:e,onLoading:t,onSuccess:o}={}){let n=F(["USE_CONNECT",e,t,o],p,{onError:(i,a)=>Promise.resolve(e==null?void 0:e(i,a)),onMutate:t,onSuccess:i=>Promise.resolve(o==null?void 0:o(i))});return{connect:i=>n.mutate(i),connectAsync:i=>n.mutateAsync(i),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:h(),status:n.status}}function Rn({onError:e,onLoading:t,onSuccess:o}={}){let n=F(["USE_DISCONNECT",e,t,o],j,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return{disconnect:i=>n.mutate(i),disconnectAsync:i=>n.mutateAsync(i),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}}function En(){return r(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),ze)}import{useMutation as L}from"react-query";function Qn(){return r(e=>e.activeChain)}function Jn(){return{data:r(t=>t.recentChain),clear:G}}function Vn({onError:e,onLoading:t,onSuccess:o}={}){let n=L(["USE_SUGGEST_CHAIN",e,t,o],y,{onError:(i,a)=>Promise.resolve(e==null?void 0:e(i,a)),onMutate:t,onSuccess:i=>Promise.resolve(o==null?void 0:o(i))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}}function Xn({onError:e,onLoading:t,onSuccess:o}={}){let n=L(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],O,{onError:(i,a)=>Promise.resolve(e==null?void 0:e(i,a)),onMutate:t,onSuccess:i=>Promise.resolve(o==null?void 0:o(i))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:h(),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}}import{useQuery as H}from"react-query";function nt(e){let t=r(n=>n.client),s=H(["USE_CLIENT",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?u(n):i,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:s.data,error:s.error,isFetching:s.isFetching,isLoading:s.isLoading,isRefetching:s.isRefetching,isSuccess:s.isSuccess,refetch:s.refetch,status:s.status}}function tt(e){let t=r(n=>n.signingClient),s=H(["USE_SIGNING_CLIENT",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?l(n):i,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:s.data,error:s.error,isFetching:s.isFetching,isLoading:s.isLoading,isRefetching:s.isRefetching,isSuccess:s.isSuccess,refetch:s.refetch,status:s.status}}import{QueryClient as Me,QueryClientProvider as qe}from"react-query";import{useEffect as Oe}from"react";function Q(){return Oe(()=>{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 Ue=new Me({defaultOptions:{queries:{notifyOnChangeProps:"tracked"}}});function pt({children:e}){return c.createElement(qe,{key:"graz-query-client",client:Ue},c.createElement(Q,null),e)}export{pt as GrazProvider,G as clearRecentChain,Ze as configureDefaultChain,p as connect,u as createClient,l as createSigningClient,In as defineChains,j as disconnect,z as getBalances,g as getKeplr,en as getRecentChain,Dn as mainnetChains,vn as mainnetChainsArray,m as reconnect,We as registerKeplrNotFound,y as suggestChain,O as suggestChainAndConnect,bn as testnetChains,jn as testnetChainsArray,_e as unregisterKeplrNotFound,Ge as useAccount,Qn as useActiveChain,Nn as useBalances,h as useCheckKeplr,nt as useClient,Pn as useConnect,Rn as useDisconnect,Jn as useRecentChain,En as useSigners,tt as useSigningClient,Vn as useSuggestChain,Xn as useSuggestChainAndConnect};
|
package/dist/keplr.d.ts
ADDED
package/dist/keplr.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,e,p,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of c(e))!d.call(f,m)&&m!==p&&a(f,m,{get:()=>e[m],enumerable:!(x=b(e,m))||x.enumerable});return f},r=(f,e,p)=>(t(f,e,"default"),p&&t(p,e,"default"));var g=f=>t(a({},"__esModule",{value:!0}),f);var o={};module.exports=g(o);r(o,require("@keplr-wallet/cosmos"),module.exports);r(o,require("@keplr-wallet/types"),module.exports);
|
package/dist/keplr.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk-L7O257ZE.mjs";export*from"@keplr-wallet/cosmos";export*from"@keplr-wallet/types";
|
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.8",
|
|
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",
|