graz 0.0.11 → 0.0.14
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/cosmjs.mjs +1 -1
- package/dist/index.d.ts +52 -13
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/keplr.mjs +1 -1
- package/package.json +3 -3
- package/dist/chunk-L7O257ZE.mjs +0 -1
package/dist/cosmjs.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export*from"@cosmjs/cosmwasm-stargate";export*from"@cosmjs/proto-signing";export*from"@cosmjs/stargate";
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import * as _cosmjs_cosmwasm_stargate from '@cosmjs/cosmwasm-stargate';
|
|
2
2
|
import { SigningCosmWasmClientOptions, CosmWasmClient, SigningCosmWasmClient } from '@cosmjs/cosmwasm-stargate';
|
|
3
3
|
import * as _cosmjs_proto_signing from '@cosmjs/proto-signing';
|
|
4
|
-
import { Coin, OfflineSigner } from '@cosmjs/proto-signing';
|
|
4
|
+
import { Coin, OfflineSigner, OfflineDirectSigner } 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 _cosmjs_stargate from '@cosmjs/stargate';
|
|
8
|
+
import { StargateClient, SigningStargateClient, SigningStargateClientOptions } from '@cosmjs/stargate';
|
|
7
9
|
import * as _tanstack_react_query from '@tanstack/react-query';
|
|
8
10
|
import * as _cosmjs_amino from '@cosmjs/amino';
|
|
9
11
|
import { ReactNode } from 'react';
|
|
@@ -100,7 +102,6 @@ declare function disconnect(clearRecentChain?: boolean): Promise<void>;
|
|
|
100
102
|
declare function getBalances(bech32Address: string): Promise<Coin[]>;
|
|
101
103
|
declare function reconnect(): void;
|
|
102
104
|
|
|
103
|
-
declare function configureDefaultChain(chain: GrazChain): GrazChain;
|
|
104
105
|
declare function getRecentChain(): GrazChain | null;
|
|
105
106
|
declare function clearRecentChain(): void;
|
|
106
107
|
declare function suggestChain(chainInfo: ChainInfo): Promise<ChainInfo>;
|
|
@@ -109,16 +110,42 @@ declare function suggestChainAndConnect(chainInfo: ChainInfo): Promise<{
|
|
|
109
110
|
chain: ChainInfo;
|
|
110
111
|
}>;
|
|
111
112
|
|
|
113
|
+
interface GrazStore {
|
|
114
|
+
account: Key | null;
|
|
115
|
+
activeChain: GrazChain | null;
|
|
116
|
+
balances: Coin[] | null;
|
|
117
|
+
clients: {
|
|
118
|
+
cosmWasm: CosmWasmClient;
|
|
119
|
+
stargate: StargateClient;
|
|
120
|
+
} | null;
|
|
121
|
+
defaultChain: GrazChain | null;
|
|
122
|
+
defaultSigningClient: "cosmWasm" | "stargate";
|
|
123
|
+
offlineSigner: (OfflineSigner & OfflineDirectSigner) | null;
|
|
124
|
+
offlineSignerAmino: OfflineSigner | null;
|
|
125
|
+
offlineSignerAuto: (OfflineSigner | OfflineDirectSigner) | null;
|
|
126
|
+
recentChain: GrazChain | null;
|
|
127
|
+
signingClients: {
|
|
128
|
+
cosmWasm: SigningCosmWasmClient;
|
|
129
|
+
stargate: SigningStargateClient;
|
|
130
|
+
} | null;
|
|
131
|
+
status: "connected" | "connecting" | "reconnecting" | "disconnected";
|
|
132
|
+
_notFoundFn: () => void;
|
|
133
|
+
_reconnect: boolean;
|
|
134
|
+
_supported: boolean;
|
|
135
|
+
}
|
|
136
|
+
|
|
112
137
|
declare type CreateClientArgs = Pick<GrazChain, "rpc" | "rpcHeaders">;
|
|
113
|
-
declare function
|
|
138
|
+
declare function createClients({ rpc, rpcHeaders }: CreateClientArgs): Promise<GrazStore["clients"]>;
|
|
114
139
|
declare type CreateSigningClientArgs = CreateClientArgs & {
|
|
115
|
-
|
|
116
|
-
|
|
140
|
+
offlineSignerAuto: OfflineSigner | OfflineDirectSigner;
|
|
141
|
+
cosmWasmSignerOptions?: SigningCosmWasmClientOptions;
|
|
142
|
+
stargateSignerOptions?: SigningStargateClientOptions;
|
|
117
143
|
};
|
|
118
|
-
declare function
|
|
144
|
+
declare function createSigningClients(args: CreateSigningClientArgs): Promise<GrazStore["signingClients"]>;
|
|
119
145
|
|
|
120
146
|
interface ConfigureGrazArgs {
|
|
121
147
|
defaultChain?: GrazChain;
|
|
148
|
+
defaultSigningClient?: GrazStore["defaultSigningClient"];
|
|
122
149
|
onKeplrNotFound?: () => void;
|
|
123
150
|
}
|
|
124
151
|
declare function configureGraz(args?: ConfigureGrazArgs): ConfigureGrazArgs;
|
|
@@ -434,14 +461,20 @@ declare type WithRefetchOpts<T> = T & {
|
|
|
434
461
|
* useClient({ rpc: "https://rpc.cosmoshub.strange.love", });
|
|
435
462
|
* ```
|
|
436
463
|
*/
|
|
437
|
-
declare function
|
|
438
|
-
data:
|
|
464
|
+
declare function useClients(args?: WithRefetchOpts<CreateClientArgs>): {
|
|
465
|
+
data: {
|
|
466
|
+
cosmWasm: _cosmjs_cosmwasm_stargate.CosmWasmClient;
|
|
467
|
+
stargate: _cosmjs_stargate.StargateClient;
|
|
468
|
+
} | null | undefined;
|
|
439
469
|
error: unknown;
|
|
440
470
|
isFetching: boolean;
|
|
441
471
|
isLoading: boolean;
|
|
442
472
|
isRefetching: boolean;
|
|
443
473
|
isSuccess: boolean;
|
|
444
|
-
refetch: <TPageData>(options?: (_tanstack_react_query.RefetchOptions & _tanstack_react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<_tanstack_react_query.QueryObserverResult<
|
|
474
|
+
refetch: <TPageData>(options?: (_tanstack_react_query.RefetchOptions & _tanstack_react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<_tanstack_react_query.QueryObserverResult<{
|
|
475
|
+
cosmWasm: _cosmjs_cosmwasm_stargate.CosmWasmClient;
|
|
476
|
+
stargate: _cosmjs_stargate.StargateClient;
|
|
477
|
+
} | null, unknown>>;
|
|
445
478
|
status: "error" | "loading" | "success";
|
|
446
479
|
};
|
|
447
480
|
/**
|
|
@@ -462,14 +495,20 @@ declare function useClient(args?: WithRefetchOpts<CreateClientArgs>): {
|
|
|
462
495
|
* });
|
|
463
496
|
* ```
|
|
464
497
|
*/
|
|
465
|
-
declare function
|
|
466
|
-
data:
|
|
498
|
+
declare function useSigningClients(args?: WithRefetchOpts<CreateSigningClientArgs>): {
|
|
499
|
+
data: {
|
|
500
|
+
cosmWasm: _cosmjs_cosmwasm_stargate.SigningCosmWasmClient;
|
|
501
|
+
stargate: _cosmjs_stargate.SigningStargateClient;
|
|
502
|
+
} | null | undefined;
|
|
467
503
|
error: unknown;
|
|
468
504
|
isFetching: boolean;
|
|
469
505
|
isLoading: boolean;
|
|
470
506
|
isRefetching: boolean;
|
|
471
507
|
isSuccess: boolean;
|
|
472
|
-
refetch: <TPageData>(options?: (_tanstack_react_query.RefetchOptions & _tanstack_react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<_tanstack_react_query.QueryObserverResult<
|
|
508
|
+
refetch: <TPageData>(options?: (_tanstack_react_query.RefetchOptions & _tanstack_react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<_tanstack_react_query.QueryObserverResult<{
|
|
509
|
+
cosmWasm: _cosmjs_cosmwasm_stargate.SigningCosmWasmClient;
|
|
510
|
+
stargate: _cosmjs_stargate.SigningStargateClient;
|
|
511
|
+
} | null, unknown>>;
|
|
473
512
|
status: "error" | "loading" | "success";
|
|
474
513
|
};
|
|
475
514
|
|
|
@@ -514,4 +553,4 @@ interface GrazProviderProps {
|
|
|
514
553
|
declare function GrazProvider({ children }: GrazProviderProps): JSX.Element;
|
|
515
554
|
declare const GRAZ_PROVIDER_COMPONENT_KEY = "graz-query-client";
|
|
516
555
|
|
|
517
|
-
export { ConfigureGrazArgs, ConnectArgs, CreateClientArgs, CreateSigningClientArgs, GRAZ_PROVIDER_COMPONENT_KEY, GrazChain, GrazProvider, GrazProviderProps, UseAccountArgs, UseConnectChainArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, clearRecentChain,
|
|
556
|
+
export { ConfigureGrazArgs, ConnectArgs, CreateClientArgs, CreateSigningClientArgs, GRAZ_PROVIDER_COMPONENT_KEY, GrazChain, GrazProvider, GrazProviderProps, UseAccountArgs, UseConnectChainArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, clearRecentChain, configureGraz, connect, createClients, createSigningClients, defineChains, disconnect, getBalances, getKeplr, getRecentChain, mainnetChains, mainnetChainsArray, reconnect, registerKeplrNotFound, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, unregisterKeplrNotFound, useAccount, useActiveChain, useBalances, useCheckKeplr, useClients, useConnect, useDisconnect, useRecentChain, useSigners, useSigningClients, useSuggestChain, useSuggestChainAndConnect };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
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});
|
|
1
|
+
"use strict";var Ie=Object.create;var y=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var be=Object.getPrototypeOf,je=Object.prototype.hasOwnProperty;var Ge=(e,t)=>{for(var o in t)y(e,o,{get:t[o],enumerable:!0})},L=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ve(t))!je.call(e,n)&&n!==o&&y(e,n,{get:()=>t[n],enumerable:!(i=De(t,n))||i.enumerable});return e};var H=(e,t,o)=>(o=e!=null?Ie(be(e)):{},L(t||!e||!e.__esModule?y(o,"default",{value:e,enumerable:!0}):o,e)),ze=e=>L(y({},"__esModule",{value:!0}),e);var yn={};Ge(yn,{GRAZ_PROVIDER_COMPONENT_KEY:()=>we,GrazProvider:()=>Cn,clearRecentChain:()=>G,configureGraz:()=>Ue,connect:()=>p,createClients:()=>u,createSigningClients:()=>l,defineChains:()=>Ze,disconnect:()=>b,getBalances:()=>j,getKeplr:()=>g,getRecentChain:()=>Ke,mainnetChains:()=>en,mainnetChainsArray:()=>nn,reconnect:()=>m,registerKeplrNotFound:()=>v,suggestChain:()=>S,suggestChainAndConnect:()=>z,testnetChains:()=>tn,testnetChainsArray:()=>on,unregisterKeplrNotFound:()=>Me,useAccount:()=>ye,useActiveChain:()=>mn,useBalances:()=>rn,useCheckKeplr:()=>h,useClients:()=>gn,useConnect:()=>sn,useDisconnect:()=>cn,useRecentChain:()=>pn,useSigners:()=>an,useSigningClients:()=>hn,useSuggestChain:()=>un,useSuggestChainAndConnect:()=>ln});module.exports=ze(yn);var Q=require("@cosmjs/stargate");var J=H(require("zustand")),d=require("zustand/middleware"),k={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",_notFoundFn:()=>null,_reconnect:!1,_supported:!1},Oe={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},r=(0,J.default)((0,d.subscribeWithSelector)((0,d.persist)(()=>k,Oe)));var I=require("@cosmjs/cosmwasm-stargate"),D=require("@cosmjs/stargate");async function u({rpc:e,rpcHeaders:t}){let o={url:e,headers:{...t||{}}},[i,n]=await Promise.all([I.SigningCosmWasmClient.connect(o),D.SigningStargateClient.connect(o)]);return{cosmWasm:i,stargate:n}}async function l(e){let{rpc:t,rpcHeaders:o,offlineSignerAuto:i,cosmWasmSignerOptions:n={},stargateSignerOptions:s={}}=e,a={url:t,headers:{...o||{}}},[C,A]=await Promise.all([I.SigningCosmWasmClient.connectWithSigner(a,i,n),D.SigningStargateClient.connectWithSigner(a,i,s)]);return{cosmWasm:C,stargate:A}}function g(){if(typeof window.keplr<"u")return window.keplr;throw r.getState()._notFoundFn(),new Error("Keplr is not defined")}function v(e){r.setState({_notFoundFn:e})}function Me(){r.setState({_notFoundFn:()=>null})}async function p(e){try{let t=g(),{defaultChain:o,recentChain:i}=r.getState(),n=e||i||o;if(!n)throw new Error("No last known connected chain, connect action requires chain info");r.setState(x=>{let ke=x._reconnect;return x.activeChain&&x.activeChain.chainId!==n.chainId?{status:"connecting"}:ke?{status:"reconnecting"}:{status:"connecting"}}),await t.enable(n.chainId);let s=t.getOfflineSigner(n.chainId),a=t.getOfflineSignerOnlyAmino(n.chainId),C=await t.getOfflineSignerAuto(n.chainId),A=n.gas?Q.GasPrice.fromString(`${n.gas.price}${n.gas.denom}`):void 0,[F,Ae,xe]=await Promise.all([t.getKey(n.chainId),u(n),l({...n,offlineSignerAuto:C,cosmWasmSignerOptions:{gasPrice:A,...(e==null?void 0:e.signerOpts)||{}}})]);return r.setState({account:F,activeChain:n,clients:Ae,offlineSigner:s,offlineSignerAmino:a,offlineSignerAuto:C,recentChain:n,signingClients:xe,status:"connected",_reconnect:!0}),F}catch(t){throw r.getState().account===null&&r.setState({status:"disconnected"}),t}}async function b(e=!1){return r.setState(t=>({...k,recentChain:e?null:t.recentChain,_supported:t._supported})),Promise.resolve()}async function j(e){let{activeChain:t,signingClients:o}=r.getState();if(!t||!o)throw new Error("No connected account detected");let{defaultSigningClient:i}=r.getState();return await Promise.all(t.currencies.map(async s=>o[i].getBalance(e,s.coinMinimalDenom)))}function m(){let{activeChain:e}=r.getState();e&&p(e)}function Ke(){return r.getState().recentChain}function G(){r.setState({recentChain:null})}async function S(e){return await g().experimentalSuggestChain(e),e}async function z(e){let t=await S(e);return{account:await p(e),chain:t}}function Ue(e={}){return e.defaultChain&&r.setState({defaultChain:e.defaultChain}),e.defaultSigningClient&&r.setState({defaultSigningClient:e.defaultSigningClient}),e.onKeplrNotFound&&v(e.onKeplrNotFound),e}var X=require("@keplr-wallet/cosmos"),$={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},qe={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},Ne={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"},Pe={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},Be={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},V=[$,qe,Ne,Te,Pe,Be],O={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:$,bip44:{coinType:118},bech32Config:X.Bech32Address.defaultBech32Config("axelar"),currencies:V,feeCurrencies:V};var Z=require("@keplr-wallet/cosmos"),ee={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Y=[ee],M={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:ee,bip44:{coinType:118},bech32Config:Z.Bech32Address.defaultBech32Config("cosmos"),currencies:Y,feeCurrencies:Y};var te=require("@keplr-wallet/cosmos"),oe={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},ne=[oe],K={rpc:"https://testnet-endpoint.crescent.network/rpc/crescent",rest:"https://testnet-endpoint.crescent.network/api/crescent",chainId:"mooncat-1-1",chainName:"Crescent Testnet",bip44:{coinType:118},bech32Config:te.Bech32Address.defaultBech32Config("CRE"),currencies:ne,feeCurrencies:ne,stakeCurrency:oe,coinType:118};var re=require("@keplr-wallet/cosmos"),se={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Re={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},Ee={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"},_e={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Fe={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Le={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},He={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},Je={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Qe={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Ve={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},ie=[se,Re,Ee,We,_e,Fe,Le,He,Je,Qe,Ve],U={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:se,bip44:{coinType:118},bech32Config:re.Bech32Address.defaultBech32Config("juno"),currencies:ie,feeCurrencies:ie};var ce=require("@keplr-wallet/cosmos"),q={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Xe=[q],N={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-3",chainName:"Juno Testnet",stakeCurrency:q,bip44:{coinType:118},bech32Config:ce.Bech32Address.defaultBech32Config("juno"),currencies:Xe,feeCurrencies:[q],coinType:118};var me=require("@keplr-wallet/cosmos"),pe={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},$e={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ae=[pe,$e],T={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:pe,bip44:{coinType:118},bech32Config:me.Bech32Address.defaultBech32Config("osmo"),currencies:ae,feeCurrencies:ae};var ue=require("@keplr-wallet/cosmos"),P={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Ye=[P],B={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:P,bip44:{coinType:118},bech32Config:ue.Bech32Address.defaultBech32Config("osmo"),currencies:Ye,feeCurrencies:[P],coinType:118};var ge=require("@keplr-wallet/cosmos"),he={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},le=[he],R={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:he,bip44:{coinType:118},bech32Config:ge.Bech32Address.defaultBech32Config("somm"),currencies:le,feeCurrencies:le};function Ze(e){return e}var en={axelar:O,cosmos:M,juno:U,osmosis:T,sommelier:R},nn=[O,M,U,T,R],tn={crescent:K,juno:N,osmosis:B},on=[K,N,B];var f=require("@tanstack/react-query"),fe=require("react"),Ce=H(require("zustand/shallow"));function h(){return r(e=>e._supported)}function ye({onConnect:e,onDisconnect:t}={}){let o=r(n=>n.account),i=r(n=>n.status);return(0,fe.useEffect)(()=>r.subscribe(n=>n.status,(n,s)=>{if(n==="connected"){let a=r.getState();e==null||e({account:a.account,isReconnect:s==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:Boolean(o),isConnecting:i==="connecting",isDisconnected:i==="disconnected",isReconnecting:i==="reconnecting",reconnect:m,status:i}}function rn(e){let{data:t}=ye(),o=e||(t==null?void 0:t.bech32Address),n=(0,f.useQuery)(["USE_BALANCES",o],({queryKey:[,s]})=>j(s),{enabled:Boolean(o)});return{data:n.data,error:n.error,isFetching:n.isFetching,isLoading:n.isLoading,isRefetching:n.isRefetching,isSuccess:n.isSuccess,refetch:n.refetch,status:n.status}}function sn({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,f.useMutation)(["USE_CONNECT",e,t,o],p,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return{connect:s=>n.mutate(s),connectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:h(),status:n.status}}function cn({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,f.useMutation)(["USE_DISCONNECT",e,t,o],b,{onError:s=>Promise.resolve(e==null?void 0:e(s,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return{disconnect:s=>n.mutate(s),disconnectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}}function an(){return r(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Ce.default)}var E=require("@tanstack/react-query");function mn(){return r(e=>e.activeChain)}function pn(){return{data:r(t=>t.recentChain),clear:G}}function un({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,E.useMutation)(["USE_SUGGEST_CHAIN",e,t,o],S,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}}function ln({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,E.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],z,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:h(),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}}var W=require("@tanstack/react-query");function gn(e){let t=r(n=>n.clients),i=(0,W.useQuery)(["USE_CLIENTS",e,t],({queryKey:[,n,s]})=>n!=null&&n.rpc?u(n):s,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:i.data,error:i.error,isFetching:i.isFetching,isLoading:i.isLoading,isRefetching:i.isRefetching,isSuccess:i.isSuccess,refetch:i.refetch,status:i.status}}function hn(e){let t=r(n=>n.signingClients),i=(0,W.useQuery)(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,s]})=>n!=null&&n.rpc?l(n):s,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:i.data,error:i.error,isFetching:i.isFetching,isLoading:i.isLoading,isRefetching:i.isRefetching,isSuccess:i.isSuccess,refetch:i.refetch,status:i.status}}var w=require("@tanstack/react-query");var de=require("react");function Se(){return(0,de.useEffect)(()=>{r.setState({_supported:typeof window.keplr<"u"});let{_reconnect:e}=r.getState();return e&&m(),window.addEventListener("keplr_keystorechange",m),()=>{window.removeEventListener("keplr_keystorechange",m)}},[]),null}var _=require("react/jsx-runtime"),fn=new w.QueryClient({});function Cn({children:e}){return(0,_.jsxs)(w.QueryClientProvider,{client:fn,children:[(0,_.jsx)(Se,{}),e]},we)}var we="graz-query-client";0&&(module.exports={GRAZ_PROVIDER_COMPONENT_KEY,GrazProvider,clearRecentChain,configureGraz,connect,createClients,createSigningClients,defineChains,disconnect,getBalances,getKeplr,getRecentChain,mainnetChains,mainnetChainsArray,reconnect,registerKeplrNotFound,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,unregisterKeplrNotFound,useAccount,useActiveChain,useBalances,useCheckKeplr,useClients,useConnect,useDisconnect,useRecentChain,useSigners,useSigningClients,useSuggestChain,useSuggestChainAndConnect});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
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};
|
|
1
|
+
import{GasPrice as ce}from"@cosmjs/stargate";import oe from"zustand";import{persist as ie,subscribeWithSelector as re}from"zustand/middleware";var d={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",_notFoundFn:()=>null,_reconnect:!1,_supported:!1},se={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},i=oe(re(ie(()=>d,se)));import{SigningCosmWasmClient as O}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as M}from"@cosmjs/stargate";async function l({rpc:e,rpcHeaders:t}){let o={url:e,headers:{...t||{}}},[r,n]=await Promise.all([O.connect(o),M.connect(o)]);return{cosmWasm:r,stargate:n}}async function g(e){let{rpc:t,rpcHeaders:o,offlineSignerAuto:r,cosmWasmSignerOptions:n={},stargateSignerOptions:s={}}=e,a={url:t,headers:{...o||{}}},[u,C]=await Promise.all([O.connectWithSigner(a,r,n),M.connectWithSigner(a,r,s)]);return{cosmWasm:u,stargate:C}}function h(){if(typeof window.keplr<"u")return window.keplr;throw i.getState()._notFoundFn(),new Error("Keplr is not defined")}function K(e){i.setState({_notFoundFn:e})}function Ze(){i.setState({_notFoundFn:()=>null})}async function p(e){try{let t=h(),{defaultChain:o,recentChain:r}=i.getState(),n=e||r||o;if(!n)throw new Error("No last known connected chain, connect action requires chain info");i.setState(y=>{let te=y._reconnect;return y.activeChain&&y.activeChain.chainId!==n.chainId?{status:"connecting"}:te?{status:"reconnecting"}:{status:"connecting"}}),await t.enable(n.chainId);let s=t.getOfflineSigner(n.chainId),a=t.getOfflineSignerOnlyAmino(n.chainId),u=await t.getOfflineSignerAuto(n.chainId),C=n.gas?ce.fromString(`${n.gas.price}${n.gas.denom}`):void 0,[z,ee,ne]=await Promise.all([t.getKey(n.chainId),l(n),g({...n,offlineSignerAuto:u,cosmWasmSignerOptions:{gasPrice:C,...(e==null?void 0:e.signerOpts)||{}}})]);return i.setState({account:z,activeChain:n,clients:ee,offlineSigner:s,offlineSignerAmino:a,offlineSignerAuto:u,recentChain:n,signingClients:ne,status:"connected",_reconnect:!0}),z}catch(t){throw i.getState().account===null&&i.setState({status:"disconnected"}),t}}async function U(e=!1){return i.setState(t=>({...d,recentChain:e?null:t.recentChain,_supported:t._supported})),Promise.resolve()}async function q(e){let{activeChain:t,signingClients:o}=i.getState();if(!t||!o)throw new Error("No connected account detected");let{defaultSigningClient:r}=i.getState();return await Promise.all(t.currencies.map(async s=>o[r].getBalance(e,s.coinMinimalDenom)))}function m(){let{activeChain:e}=i.getState();e&&p(e)}function pn(){return i.getState().recentChain}function N(){i.setState({recentChain:null})}async function S(e){return await h().experimentalSuggestChain(e),e}async function T(e){let t=await S(e);return{account:await p(e),chain:t}}function hn(e={}){return e.defaultChain&&i.setState({defaultChain:e.defaultChain}),e.defaultSigningClient&&i.setState({defaultSigningClient:e.defaultSigningClient}),e.onKeplrNotFound&&K(e.onKeplrNotFound),e}import{Bech32Address as ae}from"@keplr-wallet/cosmos";var B={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},me={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},pe={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},ue={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},le={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},ge={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},P=[B,me,pe,ue,le,ge],w={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:B,bip44:{coinType:118},bech32Config:ae.defaultBech32Config("axelar"),currencies:P,feeCurrencies:P};import{Bech32Address as he}from"@keplr-wallet/cosmos";var E={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},R=[E],A={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:E,bip44:{coinType:118},bech32Config:he.defaultBech32Config("cosmos"),currencies:R,feeCurrencies:R};import{Bech32Address as fe}from"@keplr-wallet/cosmos";var _={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},W=[_],x={rpc:"https://testnet-endpoint.crescent.network/rpc/crescent",rest:"https://testnet-endpoint.crescent.network/api/crescent",chainId:"mooncat-1-1",chainName:"Crescent Testnet",bip44:{coinType:118},bech32Config:fe.defaultBech32Config("CRE"),currencies:W,feeCurrencies:W,stakeCurrency:_,coinType:118};import{Bech32Address as Ce}from"@keplr-wallet/cosmos";var L={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},ye={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},de={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},Se={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},we={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Ae={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},xe={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},ke={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},Ie={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},De={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},ve={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},F=[L,ye,de,Se,we,Ae,xe,ke,Ie,De,ve],k={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:L,bip44:{coinType:118},bech32Config:Ce.defaultBech32Config("juno"),currencies:F,feeCurrencies:F};import{Bech32Address as be}from"@keplr-wallet/cosmos";var I={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},je=[I],D={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-3",chainName:"Juno Testnet",stakeCurrency:I,bip44:{coinType:118},bech32Config:be.defaultBech32Config("juno"),currencies:je,feeCurrencies:[I],coinType:118};import{Bech32Address as Ge}from"@keplr-wallet/cosmos";var J={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},ze={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},H=[J,ze],v={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:J,bip44:{coinType:118},bech32Config:Ge.defaultBech32Config("osmo"),currencies:H,feeCurrencies:H};import{Bech32Address as Oe}from"@keplr-wallet/cosmos";var b={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Me=[b],j={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:b,bip44:{coinType:118},bech32Config:Oe.defaultBech32Config("osmo"),currencies:Me,feeCurrencies:[b],coinType:118};import{Bech32Address as Ke}from"@keplr-wallet/cosmos";var V={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},Q=[V],G={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:V,bip44:{coinType:118},bech32Config:Ke.defaultBech32Config("somm"),currencies:Q,feeCurrencies:Q};function Rn(e){return e}var En={axelar:w,cosmos:A,juno:k,osmosis:v,sommelier:G},Wn=[w,A,k,v,G],_n={crescent:x,juno:D,osmosis:j},Fn=[x,D,j];import{useMutation as X,useQuery as Ue}from"@tanstack/react-query";import{useEffect as qe}from"react";import Ne from"zustand/shallow";function f(){return i(e=>e._supported)}function Te({onConnect:e,onDisconnect:t}={}){let o=i(n=>n.account),r=i(n=>n.status);return qe(()=>i.subscribe(n=>n.status,(n,s)=>{if(n==="connected"){let a=i.getState();e==null||e({account:a.account,isReconnect:s==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:Boolean(o),isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",reconnect:m,status:r}}function et(e){let{data:t}=Te(),o=e||(t==null?void 0:t.bech32Address),n=Ue(["USE_BALANCES",o],({queryKey:[,s]})=>q(s),{enabled:Boolean(o)});return{data:n.data,error:n.error,isFetching:n.isFetching,isLoading:n.isLoading,isRefetching:n.isRefetching,isSuccess:n.isSuccess,refetch:n.refetch,status:n.status}}function nt({onError:e,onLoading:t,onSuccess:o}={}){let n=X(["USE_CONNECT",e,t,o],p,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return{connect:s=>n.mutate(s),connectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:f(),status:n.status}}function tt({onError:e,onLoading:t,onSuccess:o}={}){let n=X(["USE_DISCONNECT",e,t,o],U,{onError:s=>Promise.resolve(e==null?void 0:e(s,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return{disconnect:s=>n.mutate(s),disconnectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}}function ot(){return i(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Ne)}import{useMutation as $}from"@tanstack/react-query";function mt(){return i(e=>e.activeChain)}function pt(){return{data:i(t=>t.recentChain),clear:N}}function ut({onError:e,onLoading:t,onSuccess:o}={}){let n=$(["USE_SUGGEST_CHAIN",e,t,o],S,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}}function lt({onError:e,onLoading:t,onSuccess:o}={}){let n=$(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],T,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:f(),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}}import{useQuery as Y}from"@tanstack/react-query";function yt(e){let t=i(n=>n.clients),r=Y(["USE_CLIENTS",e,t],({queryKey:[,n,s]})=>n!=null&&n.rpc?l(n):s,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:r.data,error:r.error,isFetching:r.isFetching,isLoading:r.isLoading,isRefetching:r.isRefetching,isSuccess:r.isSuccess,refetch:r.refetch,status:r.status}}function dt(e){let t=i(n=>n.signingClients),r=Y(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,s]})=>n!=null&&n.rpc?g(n):s,{refetchOnMount:Boolean(e==null?void 0:e.keepRefetchBehavior),refetchOnWindowFocus:Boolean(e==null?void 0:e.keepRefetchBehavior)});return{data:r.data,error:r.error,isFetching:r.isFetching,isLoading:r.isLoading,isRefetching:r.isRefetching,isSuccess:r.isSuccess,refetch:r.refetch,status:r.status}}import{QueryClient as Be,QueryClientProvider as Re}from"@tanstack/react-query";import{useEffect as Pe}from"react";function Z(){return Pe(()=>{i.setState({_supported:typeof window.keplr<"u"});let{_reconnect:e}=i.getState();return e&&m(),window.addEventListener("keplr_keystorechange",m),()=>{window.removeEventListener("keplr_keystorechange",m)}},[]),null}import{jsx as _e,jsxs as Fe}from"react/jsx-runtime";var Ee=new Be({});function vt({children:e}){return Fe(Re,{client:Ee,children:[_e(Z,{}),e]},We)}var We="graz-query-client";export{We as GRAZ_PROVIDER_COMPONENT_KEY,vt as GrazProvider,N as clearRecentChain,hn as configureGraz,p as connect,l as createClients,g as createSigningClients,Rn as defineChains,U as disconnect,q as getBalances,h as getKeplr,pn as getRecentChain,En as mainnetChains,Wn as mainnetChainsArray,m as reconnect,K as registerKeplrNotFound,S as suggestChain,T as suggestChainAndConnect,_n as testnetChains,Fn as testnetChainsArray,Ze as unregisterKeplrNotFound,Te as useAccount,mt as useActiveChain,et as useBalances,f as useCheckKeplr,yt as useClients,nt as useConnect,tt as useDisconnect,pt as useRecentChain,ot as useSigners,dt as useSigningClients,ut as useSuggestChain,lt as useSuggestChainAndConnect};
|
package/dist/keplr.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
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.14",
|
|
5
5
|
"author": "Griko Nibras <griko@strangelove.ventures>",
|
|
6
6
|
"repository": "https://github.com/strangelove-ventures/graz.git",
|
|
7
7
|
"homepage": "https://github.com/strangelove-ventures/graz",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"@keplr-wallet/cosmos": "^0.10.13",
|
|
28
28
|
"@keplr-wallet/types": "^0.10.13",
|
|
29
29
|
"@tanstack/react-query": "^4.0.10",
|
|
30
|
-
"zustand": "^4.0.0
|
|
30
|
+
"zustand": "^4.0.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@types/node": "^16",
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"typescript": "^4"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
|
39
|
-
"react": ">=
|
|
39
|
+
"react": ">=17"
|
|
40
40
|
},
|
|
41
41
|
"eslintConfig": {
|
|
42
42
|
"extends": [
|
package/dist/chunk-L7O257ZE.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import*as e from"react";export{e as a};
|