graz 0.0.8 → 0.0.11
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/chunk-L7O257ZE.mjs +0 -0
- package/dist/cosmjs.d.ts +0 -0
- package/dist/cosmjs.js +0 -0
- package/dist/cosmjs.mjs +0 -0
- package/dist/index.d.ts +26 -18
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/keplr.d.ts +0 -0
- package/dist/keplr.js +0 -0
- package/dist/keplr.mjs +0 -0
- package/package.json +9 -9
package/dist/chunk-L7O257ZE.mjs
CHANGED
|
File without changes
|
package/dist/cosmjs.d.ts
CHANGED
|
File without changes
|
package/dist/cosmjs.js
CHANGED
|
File without changes
|
package/dist/cosmjs.mjs
CHANGED
|
File without changes
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import * as _cosmjs_proto_signing from '@cosmjs/proto-signing';
|
|
|
4
4
|
import { Coin, OfflineSigner } from '@cosmjs/proto-signing';
|
|
5
5
|
import * as _keplr_wallet_types from '@keplr-wallet/types';
|
|
6
6
|
import { AppCurrency, Key, ChainInfo, Keplr } from '@keplr-wallet/types';
|
|
7
|
-
import * as
|
|
7
|
+
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
8
8
|
import * as _cosmjs_amino from '@cosmjs/amino';
|
|
9
9
|
import { ReactNode } from 'react';
|
|
10
10
|
|
|
@@ -82,6 +82,7 @@ declare const mainnetChainsArray: _keplr_wallet_types.ChainInfo[];
|
|
|
82
82
|
*/
|
|
83
83
|
declare const testnetChains: {
|
|
84
84
|
crescent: _keplr_wallet_types.ChainInfo;
|
|
85
|
+
juno: _keplr_wallet_types.ChainInfo;
|
|
85
86
|
osmosis: _keplr_wallet_types.ChainInfo;
|
|
86
87
|
};
|
|
87
88
|
/**
|
|
@@ -116,6 +117,12 @@ declare type CreateSigningClientArgs = CreateClientArgs & {
|
|
|
116
117
|
};
|
|
117
118
|
declare function createSigningClient(args: CreateSigningClientArgs): Promise<SigningCosmWasmClient>;
|
|
118
119
|
|
|
120
|
+
interface ConfigureGrazArgs {
|
|
121
|
+
defaultChain?: GrazChain;
|
|
122
|
+
onKeplrNotFound?: () => void;
|
|
123
|
+
}
|
|
124
|
+
declare function configureGraz(args?: ConfigureGrazArgs): ConfigureGrazArgs;
|
|
125
|
+
|
|
119
126
|
/**
|
|
120
127
|
* Function to return {@link Keplr} object and throws and error if it does not exist on `window`.
|
|
121
128
|
*
|
|
@@ -214,8 +221,8 @@ declare function useBalances(bech32Address?: string): {
|
|
|
214
221
|
isLoading: boolean;
|
|
215
222
|
isRefetching: boolean;
|
|
216
223
|
isSuccess: boolean;
|
|
217
|
-
refetch: <TPageData>(options?: (
|
|
218
|
-
status: "
|
|
224
|
+
refetch: <TPageData>(options?: (_tanstack_react_query.RefetchOptions & _tanstack_react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<_tanstack_react_query.QueryObserverResult<_cosmjs_amino.Coin[], unknown>>;
|
|
225
|
+
status: "error" | "loading" | "success";
|
|
219
226
|
};
|
|
220
227
|
declare type UseConnectChainArgs = MutationEventArgs<ConnectArgs, Key>;
|
|
221
228
|
/**
|
|
@@ -257,7 +264,7 @@ declare function useConnect({ onError, onLoading, onSuccess }?: UseConnectChainA
|
|
|
257
264
|
isLoading: boolean;
|
|
258
265
|
isSuccess: boolean;
|
|
259
266
|
isSupported: boolean;
|
|
260
|
-
status: "
|
|
267
|
+
status: "error" | "loading" | "success" | "idle";
|
|
261
268
|
};
|
|
262
269
|
/**
|
|
263
270
|
* graz mutation hook to execute wallet disconnection with optional arguments to
|
|
@@ -289,7 +296,7 @@ declare function useDisconnect({ onError, onLoading, onSuccess }?: MutationEvent
|
|
|
289
296
|
error: unknown;
|
|
290
297
|
isLoading: boolean;
|
|
291
298
|
isSuccess: boolean;
|
|
292
|
-
status: "
|
|
299
|
+
status: "error" | "loading" | "success" | "idle";
|
|
293
300
|
};
|
|
294
301
|
/**
|
|
295
302
|
* graz hook to retrieve offline signer objects (default, amino enabled, and auto).
|
|
@@ -359,9 +366,9 @@ declare function useSuggestChain({ onError, onLoading, onSuccess }?: UseSuggestC
|
|
|
359
366
|
error: unknown;
|
|
360
367
|
isLoading: boolean;
|
|
361
368
|
isSuccess: boolean;
|
|
362
|
-
suggest:
|
|
363
|
-
suggestAsync:
|
|
364
|
-
status: "
|
|
369
|
+
suggest: _tanstack_react_query.UseMutateFunction<ChainInfo, unknown, ChainInfo, unknown>;
|
|
370
|
+
suggestAsync: _tanstack_react_query.UseMutateAsyncFunction<ChainInfo, unknown, ChainInfo, unknown>;
|
|
371
|
+
status: "error" | "loading" | "success" | "idle";
|
|
365
372
|
};
|
|
366
373
|
declare type UseSuggestChainAndConnectArgs = MutationEventArgs<ChainInfo, {
|
|
367
374
|
chain: ChainInfo;
|
|
@@ -399,12 +406,12 @@ declare function useSuggestChainAndConnect({ onError, onLoading, onSuccess }?: U
|
|
|
399
406
|
isLoading: boolean;
|
|
400
407
|
isSuccess: boolean;
|
|
401
408
|
isSupported: boolean;
|
|
402
|
-
status: "
|
|
403
|
-
suggestAndConnect:
|
|
409
|
+
status: "error" | "loading" | "success" | "idle";
|
|
410
|
+
suggestAndConnect: _tanstack_react_query.UseMutateFunction<{
|
|
404
411
|
account: Key;
|
|
405
412
|
chain: ChainInfo;
|
|
406
413
|
}, unknown, ChainInfo, unknown>;
|
|
407
|
-
suggestAndConnectAsync:
|
|
414
|
+
suggestAndConnectAsync: _tanstack_react_query.UseMutateAsyncFunction<{
|
|
408
415
|
account: Key;
|
|
409
416
|
chain: ChainInfo;
|
|
410
417
|
}, unknown, ChainInfo, unknown>;
|
|
@@ -434,8 +441,8 @@ declare function useClient(args?: WithRefetchOpts<CreateClientArgs>): {
|
|
|
434
441
|
isLoading: boolean;
|
|
435
442
|
isRefetching: boolean;
|
|
436
443
|
isSuccess: boolean;
|
|
437
|
-
refetch: <TPageData>(options?: (
|
|
438
|
-
status: "
|
|
444
|
+
refetch: <TPageData>(options?: (_tanstack_react_query.RefetchOptions & _tanstack_react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<_tanstack_react_query.QueryObserverResult<_cosmjs_cosmwasm_stargate.CosmWasmClient | null, unknown>>;
|
|
445
|
+
status: "error" | "loading" | "success";
|
|
439
446
|
};
|
|
440
447
|
/**
|
|
441
448
|
* graz query hook to retrieve a SigningCosmWasmClient. If there's no given args it will be using the current connected signer
|
|
@@ -462,8 +469,8 @@ declare function useSigningClient(args?: WithRefetchOpts<CreateSigningClientArgs
|
|
|
462
469
|
isLoading: boolean;
|
|
463
470
|
isRefetching: boolean;
|
|
464
471
|
isSuccess: boolean;
|
|
465
|
-
refetch: <TPageData>(options?: (
|
|
466
|
-
status: "
|
|
472
|
+
refetch: <TPageData>(options?: (_tanstack_react_query.RefetchOptions & _tanstack_react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<_tanstack_react_query.QueryObserverResult<_cosmjs_cosmwasm_stargate.SigningCosmWasmClient | null, unknown>>;
|
|
473
|
+
status: "error" | "loading" | "success";
|
|
467
474
|
};
|
|
468
475
|
|
|
469
476
|
/**
|
|
@@ -488,7 +495,7 @@ interface GrazProviderProps {
|
|
|
488
495
|
children: ReactNode;
|
|
489
496
|
}
|
|
490
497
|
/**
|
|
491
|
-
* Provider component which wraps
|
|
498
|
+
* Provider component which wraps `@tanstack/react-query`'s {@link QueryClientProvider} and various `graz` side effects
|
|
492
499
|
*
|
|
493
500
|
* @example
|
|
494
501
|
* ```tsx
|
|
@@ -502,8 +509,9 @@ interface GrazProviderProps {
|
|
|
502
509
|
* }
|
|
503
510
|
* ```
|
|
504
511
|
*
|
|
505
|
-
* @see https://
|
|
512
|
+
* @see https://tanstack.com/query
|
|
506
513
|
*/
|
|
507
514
|
declare function GrazProvider({ children }: GrazProviderProps): JSX.Element;
|
|
515
|
+
declare const GRAZ_PROVIDER_COMPONENT_KEY = "graz-query-client";
|
|
508
516
|
|
|
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 };
|
|
517
|
+
export { ConfigureGrazArgs, ConnectArgs, CreateClientArgs, CreateSigningClientArgs, GRAZ_PROVIDER_COMPONENT_KEY, GrazChain, GrazProvider, GrazProviderProps, UseAccountArgs, UseConnectChainArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, clearRecentChain, configureDefaultChain, configureGraz, 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 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});
|
|
1
|
+
"use strict";var ke=Object.create;var C=Object.defineProperty;var Ie=Object.getOwnPropertyDescriptor;var De=Object.getOwnPropertyNames;var ve=Object.getPrototypeOf,be=Object.prototype.hasOwnProperty;var je=(e,t)=>{for(var o in t)C(e,o,{get:t[o],enumerable:!0})},F=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of De(t))!be.call(e,n)&&n!==o&&C(e,n,{get:()=>t[n],enumerable:!(i=Ie(t,n))||i.enumerable});return e};var S=(e,t,o)=>(o=e!=null?ke(ve(e)):{},F(t||!e||!e.__esModule?C(o,"default",{value:e,enumerable:!0}):o,e)),Ge=e=>F(C({},"__esModule",{value:!0}),e);var Cn={};je(Cn,{GRAZ_PROVIDER_COMPONENT_KEY:()=>ye,GrazProvider:()=>fn,clearRecentChain:()=>j,configureDefaultChain:()=>b,configureGraz:()=>Ke,connect:()=>p,createClient:()=>u,createSigningClient:()=>l,defineChains:()=>Ye,disconnect:()=>D,getBalances:()=>v,getKeplr:()=>g,getRecentChain:()=>Me,mainnetChains:()=>Ze,mainnetChainsArray:()=>en,reconnect:()=>m,registerKeplrNotFound:()=>I,suggestChain:()=>d,suggestChainAndConnect:()=>G,testnetChains:()=>nn,testnetChainsArray:()=>tn,unregisterKeplrNotFound:()=>Oe,useAccount:()=>he,useActiveChain:()=>an,useBalances:()=>on,useCheckKeplr:()=>h,useClient:()=>ln,useConnect:()=>rn,useDisconnect:()=>sn,useRecentChain:()=>mn,useSigners:()=>cn,useSigningClient:()=>gn,useSuggestChain:()=>pn,useSuggestChainAndConnect:()=>un});module.exports=Ge(Cn);var c=S(require("react"));var L=require("@cosmjs/stargate");var W=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},ze={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},s=(0,W.default)((0,y.subscribeWithSelector)((0,y.persist)(()=>x,ze)));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 I(e){s.setState({_notFoundFn:e})}function Oe(){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 xe=A._reconnect;return A.activeChain&&A.activeChain.chainId!==n.chainId?{status:"connecting"}:xe?{status:"reconnecting"}:{status:"connecting"}}),await t.enable(n.chainId);let r=t.getOfflineSigner(n.chainId),a=t.getOfflineSignerOnlyAmino(n.chainId),de=n.gas?L.GasPrice.fromString(`${n.gas.price}${n.gas.denom}`):void 0,[_,we,Ae,Se]=await Promise.all([t.getKey(n.chainId),u(n),t.getOfflineSignerAuto(n.chainId),l({...n,offlineSigner:r,signerOptions:{gasPrice:de,...(e==null?void 0:e.signerOpts)||{}}})]);return s.setState({account:_,activeChain:n,client:we,offlineSigner:r,offlineSignerAmino:a,offlineSignerAuto:Ae,recentChain:n,signingClient:Se,status:"connected",_reconnect:!0}),_}catch(t){throw s.getState().account===null&&s.setState({status:"disconnected"}),t}}async function D(e=!1){return s.setState(t=>({...x,recentChain:e?null:t.recentChain,_supported:t._supported})),Promise.resolve()}async function v(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 b(e){return s.setState({defaultChain:e}),e}function Me(){return s.getState().recentChain}function j(){s.setState({recentChain:null})}async function d(e){return await g().experimentalSuggestChain(e),e}async function G(e){let t=await d(e);return{account:await p(e),chain:t}}function Ke(e={}){let{defaultChain:t,onKeplrNotFound:o}=e;return t&&b(t),o&&I(o),e}var J=require("@keplr-wallet/cosmos"),Q={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},Ue={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},qe={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},Te={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},Ne={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},Pe={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},H=[Q,Ue,qe,Te,Ne,Pe],z={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:Q,bip44:{coinType:118},bech32Config:J.Bech32Address.defaultBech32Config("axelar"),currencies:H,feeCurrencies:H};var X=require("@keplr-wallet/cosmos"),$={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},V=[$],O={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:$,bip44:{coinType:118},bech32Config:X.Bech32Address.defaultBech32Config("cosmos"),currencies:V,feeCurrencies:V};var Z=require("@keplr-wallet/cosmos"),ee={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},Y=[ee],M={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:Z.Bech32Address.defaultBech32Config("CRE"),currencies:Y,feeCurrencies:Y,stakeCurrency:ee,coinType:118};var te=require("@keplr-wallet/cosmos"),oe={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Be={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},Re={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},Ee={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},_e={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Fe={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},We={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Le={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},He={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Je={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Qe={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},ne=[oe,Be,Re,Ee,_e,Fe,We,Le,He,Je,Qe],K={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:oe,bip44:{coinType:118},bech32Config:te.Bech32Address.defaultBech32Config("juno"),currencies:ne,feeCurrencies:ne};var ie=require("@keplr-wallet/cosmos"),U={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Ve=[U],q={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-3",chainName:"Juno Testnet",stakeCurrency:U,bip44:{coinType:118},bech32Config:ie.Bech32Address.defaultBech32Config("juno"),currencies:Ve,feeCurrencies:[U],coinType:118};var se=require("@keplr-wallet/cosmos"),ce={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Xe={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},re=[ce,Xe],T={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:ce,bip44:{coinType:118},bech32Config:se.Bech32Address.defaultBech32Config("osmo"),currencies:re,feeCurrencies:re};var ae=require("@keplr-wallet/cosmos"),N={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},$e=[N],P={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:N,bip44:{coinType:118},bech32Config:ae.Bech32Address.defaultBech32Config("osmo"),currencies:$e,feeCurrencies:[N],coinType:118};var pe=require("@keplr-wallet/cosmos"),ue={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},me=[ue],B={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:ue,bip44:{coinType:118},bech32Config:pe.Bech32Address.defaultBech32Config("somm"),currencies:me,feeCurrencies:me};function Ye(e){return e}var Ze={axelar:z,cosmos:O,juno:K,osmosis:T,sommelier:B},en=[z,O,K,T,B],nn={crescent:M,juno:q,osmosis:P},tn=[M,q,P];var f=require("@tanstack/react-query"),le=require("react"),ge=S(require("zustand/shallow"));function h(){return s(e=>e._supported)}function he({onConnect:e,onDisconnect:t}={}){let o=s(n=>n.account),i=s(n=>n.status);return(0,le.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 on(e){let{data:t}=he(),o=e||(t==null?void 0:t.bech32Address),n=(0,f.useQuery)(["USE_BALANCES",o],({queryKey:[,r]})=>v(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 rn({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 sn({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,f.useMutation)(["USE_DISCONNECT",e,t,o],D,{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 cn(){return s(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),ge.default)}var R=require("@tanstack/react-query");function an(){return s(e=>e.activeChain)}function mn(){return{data:s(t=>t.recentChain),clear:j}}function pn({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,R.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 un({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,R.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],G,{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 E=require("@tanstack/react-query");function ln(e){let t=s(n=>n.client),i=(0,E.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 gn(e){let t=s(n=>n.signingClient),i=(0,E.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("@tanstack/react-query");var fe=require("react");function Ce(){return(0,fe.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 hn=new w.QueryClient({});function fn({children:e}){return c.createElement(w.QueryClientProvider,{key:ye,client:hn},c.createElement(Ce,null),e)}var ye="graz-query-client";0&&(module.exports={GRAZ_PROVIDER_COMPONENT_KEY,GrazProvider,clearRecentChain,configureDefaultChain,configureGraz,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 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};
|
|
1
|
+
import{a as c}from"./chunk-L7O257ZE.mjs";import{GasPrice as ce}from"@cosmjs/stargate";import oe from"zustand";import{persist as ie,subscribeWithSelector as re}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},se={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},r=oe(re(ie(()=>C,se)));import{SigningCosmWasmClient as G}from"@cosmjs/cosmwasm-stargate";async function u({rpc:e,rpcHeaders:t}){let o={url:e,headers:{...t||{}}};return await G.connect(o)}async function l(e){let{rpc:t,rpcHeaders:o,offlineSigner:s,signerOptions:n={}}=e,i={url:t,headers:{...o||{}}};return await G.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 z(e){r.setState({_notFoundFn:e})}function Xe(){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 te=f._reconnect;return f.activeChain&&f.activeChain.chainId!==n.chainId?{status:"connecting"}:te?{status:"reconnecting"}:{status:"connecting"}}),await t.enable(n.chainId);let i=t.getOfflineSigner(n.chainId),a=t.getOfflineSignerOnlyAmino(n.chainId),Y=n.gas?ce.fromString(`${n.gas.price}${n.gas.denom}`):void 0,[j,Z,ee,ne]=await Promise.all([t.getKey(n.chainId),u(n),t.getOfflineSignerAuto(n.chainId),l({...n,offlineSigner:i,signerOptions:{gasPrice:Y,...(e==null?void 0:e.signerOpts)||{}}})]);return r.setState({account:j,activeChain:n,client:Z,offlineSigner:i,offlineSignerAmino:a,offlineSignerAuto:ee,recentChain:n,signingClient:ne,status:"connected",_reconnect:!0}),j}catch(t){throw r.getState().account===null&&r.setState({status:"disconnected"}),t}}async function O(e=!1){return r.setState(t=>({...C,recentChain:e?null:t.recentChain,_supported:t._supported})),Promise.resolve()}async function M(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 K(e){return r.setState({defaultChain:e}),e}function cn(){return r.getState().recentChain}function U(){r.setState({recentChain:null})}async function y(e){return await g().experimentalSuggestChain(e),e}async function q(e){let t=await y(e);return{account:await p(e),chain:t}}function un(e={}){let{defaultChain:t,onKeplrNotFound:o}=e;return t&&K(t),o&&z(o),e}import{Bech32Address as ae}from"@keplr-wallet/cosmos";var N={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},me={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},pe={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},ue={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},le={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},ge={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},T=[N,me,pe,ue,le,ge],d={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:N,bip44:{coinType:118},bech32Config:ae.defaultBech32Config("axelar"),currencies:T,feeCurrencies:T};import{Bech32Address as he}from"@keplr-wallet/cosmos";var B={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},P=[B],w={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:B,bip44:{coinType:118},bech32Config:he.defaultBech32Config("cosmos"),currencies:P,feeCurrencies:P};import{Bech32Address as fe}from"@keplr-wallet/cosmos";var E={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},R=[E],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:fe.defaultBech32Config("CRE"),currencies:R,feeCurrencies:R,stakeCurrency:E,coinType:118};import{Bech32Address as Ce}from"@keplr-wallet/cosmos";var F={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},ye={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},de={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},we={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},Ae={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Se={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},xe={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},ke={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},Ie={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},De={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},ve={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},_=[F,ye,de,we,Ae,Se,xe,ke,Ie,De,ve],S={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:F,bip44:{coinType:118},bech32Config:Ce.defaultBech32Config("juno"),currencies:_,feeCurrencies:_};import{Bech32Address as be}from"@keplr-wallet/cosmos";var x={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},je=[x],k={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-3",chainName:"Juno Testnet",stakeCurrency:x,bip44:{coinType:118},bech32Config:be.defaultBech32Config("juno"),currencies:je,feeCurrencies:[x],coinType:118};import{Bech32Address as Ge}from"@keplr-wallet/cosmos";var L={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},ze={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},W=[L,ze],I={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:L,bip44:{coinType:118},bech32Config:Ge.defaultBech32Config("osmo"),currencies:W,feeCurrencies:W};import{Bech32Address as Oe}from"@keplr-wallet/cosmos";var D={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Me=[D],v={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:D,bip44:{coinType:118},bech32Config:Oe.defaultBech32Config("osmo"),currencies:Me,feeCurrencies:[D],coinType:118};import{Bech32Address as Ke}from"@keplr-wallet/cosmos";var J={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},H=[J],b={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:J,bip44:{coinType:118},bech32Config:Ke.defaultBech32Config("somm"),currencies:H,feeCurrencies:H};function Nn(e){return e}var Pn={axelar:d,cosmos:w,juno:S,osmosis:I,sommelier:b},Bn=[d,w,S,I,b],Rn={crescent:A,juno:k,osmosis:v},En=[A,k,v];import{useMutation as Q,useQuery as Ue}from"@tanstack/react-query";import{useEffect as qe}from"react";import Te from"zustand/shallow";function h(){return r(e=>e._supported)}function Ne({onConnect:e,onDisconnect:t}={}){let o=r(n=>n.account),s=r(n=>n.status);return qe(()=>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 $n(e){let{data:t}=Ne(),o=e||(t==null?void 0:t.bech32Address),n=Ue(["USE_BALANCES",o],({queryKey:[,i]})=>M(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 Yn({onError:e,onLoading:t,onSuccess:o}={}){let n=Q(["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 Zn({onError:e,onLoading:t,onSuccess:o}={}){let n=Q(["USE_DISCONNECT",e,t,o],O,{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 et(){return r(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Te)}import{useMutation as V}from"@tanstack/react-query";function st(){return r(e=>e.activeChain)}function ct(){return{data:r(t=>t.recentChain),clear:U}}function at({onError:e,onLoading:t,onSuccess:o}={}){let n=V(["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 mt({onError:e,onLoading:t,onSuccess:o}={}){let n=V(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],q,{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 X}from"@tanstack/react-query";function ht(e){let t=r(n=>n.client),s=X(["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 ft(e){let t=r(n=>n.signingClient),s=X(["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 Be,QueryClientProvider as Re}from"@tanstack/react-query";import{useEffect as Pe}from"react";function $(){return Pe(()=>{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 Ee=new Be({});function kt({children:e}){return c.createElement(Re,{key:_e,client:Ee},c.createElement($,null),e)}var _e="graz-query-client";export{_e as GRAZ_PROVIDER_COMPONENT_KEY,kt as GrazProvider,U as clearRecentChain,K as configureDefaultChain,un as configureGraz,p as connect,u as createClient,l as createSigningClient,Nn as defineChains,O as disconnect,M as getBalances,g as getKeplr,cn as getRecentChain,Pn as mainnetChains,Bn as mainnetChainsArray,m as reconnect,z as registerKeplrNotFound,y as suggestChain,q as suggestChainAndConnect,Rn as testnetChains,En as testnetChainsArray,Xe as unregisterKeplrNotFound,Ne as useAccount,st as useActiveChain,$n as useBalances,h as useCheckKeplr,ht as useClient,Yn as useConnect,Zn as useDisconnect,ct as useRecentChain,et as useSigners,ft as useSigningClient,at as useSuggestChain,mt as useSuggestChainAndConnect};
|
package/dist/keplr.d.ts
CHANGED
|
File without changes
|
package/dist/keplr.js
CHANGED
|
File without changes
|
package/dist/keplr.mjs
CHANGED
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graz",
|
|
3
3
|
"description": "React hooks for Cosmos",
|
|
4
|
-
"version": "0.0.
|
|
5
|
-
"author": "Griko Nibras <griko@
|
|
4
|
+
"version": "0.0.11",
|
|
5
|
+
"author": "Griko Nibras <griko@strangelove.ventures>",
|
|
6
6
|
"repository": "https://github.com/strangelove-ventures/graz.git",
|
|
7
7
|
"homepage": "https://github.com/strangelove-ventures/graz",
|
|
8
8
|
"bugs": "https://github.com/strangelove-ventures/graz/issues",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"dev": "tsup --watch"
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
|
-
"@cosmjs/cosmwasm-stargate": "^0.28.
|
|
25
|
-
"@cosmjs/proto-signing": "^0.28.
|
|
26
|
-
"@cosmjs/stargate": "^0.28.
|
|
27
|
-
"@keplr-wallet/cosmos": "^0.10.
|
|
28
|
-
"@keplr-wallet/types": "^0.10.
|
|
29
|
-
"react-query": "^
|
|
30
|
-
"zustand": "4.0.0-rc.
|
|
24
|
+
"@cosmjs/cosmwasm-stargate": "^0.28.11",
|
|
25
|
+
"@cosmjs/proto-signing": "^0.28.11",
|
|
26
|
+
"@cosmjs/stargate": "^0.28.11",
|
|
27
|
+
"@keplr-wallet/cosmos": "^0.10.13",
|
|
28
|
+
"@keplr-wallet/types": "^0.10.13",
|
|
29
|
+
"@tanstack/react-query": "^4.0.10",
|
|
30
|
+
"zustand": "^4.0.0-rc.4"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^16",
|