graz 0.0.16 → 0.0.21

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.
@@ -1,4 +1,4 @@
1
- const { defineChains } = require("../dist");
1
+ const { defineChainInfo, defineChains } = require("../dist");
2
2
 
3
3
  /* REPLACE_MAINNET_DEFS */
4
4
  /* REPLACE_TESTNET_DEFS */
@@ -1,4 +1,4 @@
1
- import { defineChains } from "../dist";
1
+ import { defineChainInfo, defineChains } from "../dist";
2
2
 
3
3
  /* REPLACE_MAINNET_DEFS */
4
4
  /* REPLACE_TESTNET_DEFS */
package/cli.mjs ADDED
@@ -0,0 +1,214 @@
1
+ #!/usr/bin/env node
2
+ // @ts-check
3
+ import { Bech32Address } from "@keplr-wallet/cosmos";
4
+ import arg from "arg";
5
+ import { createClient, createTestnetClient } from "cosmos-directory-client";
6
+ import * as fs from "fs/promises";
7
+ import * as path from "path";
8
+ import { fileURLToPath } from "url";
9
+
10
+ import pmap from "./compiled/p-map/index.mjs";
11
+
12
+ const HELP_MESSAGE = `Usage: graz [options]
13
+
14
+ Options:
15
+
16
+ -g, --generate Generate chain definitions and export to "graz/chains"
17
+ -h, --help Show this help message
18
+
19
+ Generate options:
20
+ -b, --best Set REST and RPC endpoint to best available nodes instead or first listed ones
21
+ -M, --mainnet Generate given mainnet chain paths seperated by commas (e.g. "axelar,cosmoshub,juno")
22
+ -T, --testnet Generate given testnet chain paths seperated by commas (e.g. "atlantic,bitcannadev,cheqdtestnet")
23
+ --authz Generate only authz compatible chains
24
+
25
+ https://github.com/strangelove-ventures/graz
26
+ `;
27
+
28
+ const args = arg({
29
+ "--generate": Boolean,
30
+ "-g": "--generate",
31
+
32
+ "--authz": Boolean,
33
+ "--best": Boolean,
34
+ "--mainnet": String,
35
+ "--testnet": String,
36
+ "-b": "--best",
37
+ "-M": "--mainnet",
38
+ "-T": "--testnet",
39
+
40
+ "--help": Boolean,
41
+ "-h": "--help",
42
+ });
43
+
44
+ async function cli() {
45
+ if (args["--help"]) {
46
+ console.log(HELP_MESSAGE);
47
+ return;
48
+ }
49
+
50
+ if (args["--generate"]) {
51
+ await generate();
52
+ return;
53
+ }
54
+
55
+ console.log(HELP_MESSAGE);
56
+ }
57
+
58
+ async function generate() {
59
+ console.log(`⏳\tGenerating chain list from cosmos.directory...`);
60
+ if (args["--authz"]) {
61
+ console.log(`✍️\tDetected authz flag, generating only compatible chains...`);
62
+ }
63
+ if (args["--best"]) {
64
+ console.log(`💁‍♂️\tDetected best flag, setting REST and RPC endpoints to best latency...`);
65
+ }
66
+ if (args["--mainnet"] || args["--testnet"]) {
67
+ console.log(`🐙\tDetected chain filtering flag, generating only given chain paths...`);
68
+ }
69
+
70
+ const [mainnetRecord, testnetRecord] = await Promise.all([
71
+ makeRecord(createClient(), { filter: args["--mainnet"] }),
72
+ makeRecord(createTestnetClient(), { filter: args["--testnet"] }),
73
+ ]);
74
+
75
+ const [jsStub, mjsStub] = await Promise.all([
76
+ fs.readFile(chainsDir("index.js.stub"), { encoding: "utf-8" }),
77
+ fs.readFile(chainsDir("index.mjs.stub"), { encoding: "utf-8" }),
78
+ ]);
79
+
80
+ const jsContent = jsStub
81
+ .replace("/* REPLACE_MAINNET_DEFS */", makeDefs(mainnetRecord))
82
+ .replace("/* REPLACE_TESTNET_DEFS */", makeDefs(testnetRecord, { testnet: true }))
83
+ .replace("/* REPLACE_MAINNET_CHAINS */", makeChainMap(mainnetRecord))
84
+ .replace("/* REPLACE_TESTNET_CHAINS */", makeChainMap(testnetRecord, { testnet: true }))
85
+ .replace("/* REPLACE_MAINNET_CHAINS_ARRAY */", makeExports(mainnetRecord))
86
+ .replace("/* REPLACE_TESTNET_CHAINS_ARRAY */", makeExports(testnetRecord, { testnet: true }))
87
+ .replace("/* REPLACE_MAINNET_EXPORTS */", makeExports(mainnetRecord))
88
+ .replace("/* REPLACE_TESTNET_EXPORTS */", makeExports(testnetRecord, { testnet: true }))
89
+ .replace(/"(.+)":/g, "$1:")
90
+ .trim();
91
+
92
+ const mjsContent = mjsStub
93
+ .replace("/* REPLACE_MAINNET_DEFS */", makeDefs(mainnetRecord, { mjs: true }))
94
+ .replace("/* REPLACE_TESTNET_DEFS */", makeDefs(testnetRecord, { mjs: true, testnet: true }))
95
+ .replace("/* REPLACE_MAINNET_CHAINS */", makeChainMap(mainnetRecord))
96
+ .replace("/* REPLACE_TESTNET_CHAINS */", makeChainMap(testnetRecord, { testnet: true }))
97
+ .replace("/* REPLACE_MAINNET_CHAINS_ARRAY */", makeExports(mainnetRecord))
98
+ .replace("/* REPLACE_TESTNET_CHAINS_ARRAY */", makeExports(testnetRecord, { testnet: true }))
99
+ .replace(/"(.+)":/g, "$1:")
100
+ .trim();
101
+
102
+ await Promise.all([
103
+ fs.writeFile(chainsDir("index.js"), jsContent, { encoding: "utf-8" }),
104
+ fs.writeFile(chainsDir("index.mjs"), mjsContent.replace('"../dist"', '"../dist/index.mjs"'), { encoding: "utf-8" }),
105
+ fs.writeFile(chainsDir("index.ts"), mjsContent, { encoding: "utf-8" }),
106
+ ]);
107
+
108
+ console.log('✨\tGenerate complete! You can import `mainnetChains` and `testnetChains` from "graz/chains".\n');
109
+ }
110
+
111
+ /** @param {string[]} args */
112
+ function chainsDir(...args) {
113
+ return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "chains", ...args);
114
+ }
115
+
116
+ /**
117
+ * @param {Record<string, import(".").ChainInfoWithPath>} record
118
+ * @param {Record<string, boolean>} opts
119
+ */
120
+ function makeChainMap(record, { testnet = false } = {}) {
121
+ return Object.keys(record)
122
+ .map((k) => ` ${k}: ${k}${testnet ? "Testnet" : ""},`)
123
+ .join("\n");
124
+ }
125
+
126
+ /**
127
+ * @param {Record<string, import(".").ChainInfoWithPath>} record
128
+ * @param {Record<string, boolean>} opts
129
+ */
130
+ function makeDefs(record, { mjs = false, testnet = false } = {}) {
131
+ return Object.entries(record)
132
+ .map(([k, v]) => {
133
+ const jsVariable = `${k}${testnet ? "Testnet" : ""}`;
134
+ const jsChainInfo = JSON.stringify(v, null, 2);
135
+ return `${mjs ? "export " : ""}const ${jsVariable} = defineChainInfo(${jsChainInfo});\n`;
136
+ })
137
+ .join("");
138
+ }
139
+
140
+ /**
141
+ * @param {Record<string, import(".").ChainInfoWithPath>} record
142
+ * @param {Record<string, boolean>} opts
143
+ */
144
+ function makeExports(record, { testnet = false } = {}) {
145
+ return Object.keys(record)
146
+ .map((k) => ` ${k}${testnet ? "Testnet" : ""},`)
147
+ .join("\n");
148
+ }
149
+
150
+ /**
151
+ * @param {import("cosmos-directory-client").DirectoryClient} client
152
+ * @param {{ filter?: string }} opts
153
+ */
154
+ async function makeRecord(client, { filter = "" } = {}) {
155
+ const paths = filter
156
+ ? filter.split(",").map((path) => ({ path }))
157
+ : await client.fetchChains().then((c) => c.chains.map(({ path }) => ({ path })));
158
+
159
+ const chains = await pmap(paths, async (c) => client.fetchChain(c.path).then((x) => x.chain), { concurrency: 4 });
160
+
161
+ /** @type {Record<string, import(".").ChainInfoWithPath>} */
162
+ const record = {};
163
+
164
+ chains.forEach((chain) => {
165
+ try {
166
+ if (args["--authz"] && !chain.params?.authz) {
167
+ return;
168
+ }
169
+
170
+ const apis = args["--best"] ? chain.best_apis : chain.apis;
171
+ if (!apis || !apis.rest?.[0] || !apis.rpc?.[0]) {
172
+ throw new Error(`⚠️\t${chain.name} has no REST/RPC endpoints, skipping codegen...`);
173
+ }
174
+
175
+ if (!chain.assets) {
176
+ throw new Error(`⚠️\t${chain.name} has no assets, skipping codegen...`);
177
+ }
178
+ const mainAsset = chain.assets[0];
179
+
180
+ /** @type{import("@keplr-wallet/types").Currency} */
181
+ const nativeCurrency = {
182
+ coinDenom: mainAsset.denom_units[mainAsset.denom_units.length - 1].denom,
183
+ coinMinimalDenom: mainAsset.denom_units[0].denom,
184
+ coinDecimals: mainAsset.denom_units[mainAsset.denom_units.length - 1].exponent,
185
+ coinGeckoId: mainAsset.coingecko_id,
186
+ };
187
+
188
+ record[chain.path] = {
189
+ chainId: chain.chain_id,
190
+ currencies: chain.assets.map((asset) => ({
191
+ coinDenom: asset.denom_units[asset.denom_units.length - 1].denom,
192
+ coinMinimalDenom: asset.denom_units[0].denom,
193
+ coinDecimals: asset.denom_units[asset.denom_units.length - 1].exponent,
194
+ coinGeckoId: asset.coingecko_id,
195
+ })),
196
+ path: chain.path,
197
+ rest: apis.rest[0].address || "",
198
+ rpc: apis.rpc[0].address || "",
199
+ bech32Config: Bech32Address.defaultBech32Config(chain.bech32_prefix),
200
+ chainName: chain.chain_name,
201
+ feeCurrencies: [nativeCurrency],
202
+ stakeCurrency: nativeCurrency,
203
+ bip44: {
204
+ coinType: chain.slip44 ?? 0,
205
+ },
206
+ };
207
+ } catch (error) {
208
+ console.error(error instanceof Error ? error.message : String(error));
209
+ }
210
+ });
211
+ return record;
212
+ }
213
+
214
+ void cli();
@@ -0,0 +1 @@
1
+ import{createRequire as e}from"module";var r={};(()=>{r.d=(e,t)=>{for(var n in t){if(r.o(t,n)&&!r.o(e,n)){Object.defineProperty(e,n,{enumerable:true,get:t[n]})}}}})();(()=>{r.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r)})();if(typeof r!=="undefined")r.ab=new URL(".",import.meta.url).pathname.slice(import.meta.url.match(/^file:\/\/\/\w:/)?1:0,-1)+"/";var t={};r.d(t,{_L:()=>AbortError,ZP:()=>pMap,Ud:()=>i});function indentString(e,r=1,t={}){const{indent:n=" ",includeEmptyLines:o=false}=t;if(typeof e!=="string"){throw new TypeError(`Expected \`input\` to be a \`string\`, got \`${typeof e}\``)}if(typeof r!=="number"){throw new TypeError(`Expected \`count\` to be a \`number\`, got \`${typeof r}\``)}if(r<0){throw new RangeError(`Expected \`count\` to be at least 0, got \`${r}\``)}if(typeof n!=="string"){throw new TypeError(`Expected \`options.indent\` to be a \`string\`, got \`${typeof n}\``)}if(r===0){return e}const a=o?/^/gm:/^(?!\s*$)/gm;return e.replace(a,n.repeat(r))}const n=e(import.meta.url)("os");function escapeStringRegexp(e){if(typeof e!=="string"){throw new TypeError("Expected a string")}return e.replace(/[|\\{}()[\]^$+*?.]/g,"\\$&").replace(/-/g,"\\x2d")}const o=/\s+at.*[(\s](.*)\)?/;const a=/^(?:(?:(?:node|node:[\w/]+|(?:(?:node:)?internal\/[\w/]*|.*node_modules\/(?:babel-polyfill|pirates)\/.*)?\w+)(?:\.js)?:\d+:\d+)|native)/;const s=typeof n.homedir==="undefined"?"":n.homedir().replace(/\\/g,"/");function cleanStack(e,{pretty:r=false,basePath:t}={}){const n=t&&new RegExp(`(at | \\()${escapeStringRegexp(t.replace(/\\/g,"/"))}`,"g");if(typeof e!=="string"){return undefined}return e.replace(/\\/g,"/").split("\n").filter((e=>{const r=e.match(o);if(r===null||!r[1]){return true}const t=r[1];if(t.includes(".app/Contents/Resources/electron.asar")||t.includes(".app/Contents/Resources/default_app.asar")||t.includes("node_modules/electron/dist/resources/electron.asar")||t.includes("node_modules/electron/dist/resources/default_app.asar")){return false}return!a.test(t)})).filter((e=>e.trim()!=="")).map((e=>{if(n){e=e.replace(n,"$1")}if(r){e=e.replace(o,((e,r)=>e.replace(r,r.replace(s,"~"))))}return e})).join("\n")}const cleanInternalStack=e=>e.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g,"");class AggregateError extends Error{#e;name="AggregateError";constructor(e){if(!Array.isArray(e)){throw new TypeError(`Expected input to be an Array, got ${typeof e}`)}e=e.map((e=>{if(e instanceof Error){return e}if(e!==null&&typeof e==="object"){return Object.assign(new Error(e.message),e)}return new Error(e)}));let r=e.map((e=>typeof e.stack==="string"&&e.stack.length>0?cleanInternalStack(cleanStack(e.stack)):String(e))).join("\n");r="\n"+indentString(r,4);super(r);this.#e=e}get errors(){return this.#e.slice()}}class AbortError extends Error{constructor(e){super();this.name="AbortError";this.message=e}}const getDOMException=e=>globalThis.DOMException===undefined?new AbortError(e):new DOMException(e);const getAbortedReason=e=>{const r=e.reason===undefined?getDOMException("This operation was aborted."):e.reason;return r instanceof Error?r:getDOMException(r)};async function pMap(e,r,{concurrency:t=Number.POSITIVE_INFINITY,stopOnError:n=true,signal:o}={}){return new Promise(((a,s)=>{if(e[Symbol.iterator]===undefined&&e[Symbol.asyncIterator]===undefined){throw new TypeError(`Expected \`input\` to be either an \`Iterable\` or \`AsyncIterable\`, got (${typeof e})`)}if(typeof r!=="function"){throw new TypeError("Mapper function is required")}if(!((Number.isSafeInteger(t)||t===Number.POSITIVE_INFINITY)&&t>=1)){throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${t}\` (${typeof t})`)}const c=[];const p=[];const u=new Map;let f=false;let l=false;let d=false;let g=0;let y=0;const m=e[Symbol.iterator]===undefined?e[Symbol.asyncIterator]():e[Symbol.iterator]();const reject=e=>{f=true;l=true;s(e)};if(o){if(o.aborted){reject(getAbortedReason(o))}o.addEventListener("abort",(()=>{reject(getAbortedReason(o))}))}const next=async()=>{if(l){return}const e=await m.next();const t=y;y++;if(e.done){d=true;if(g===0&&!l){if(!n&&p.length>0){reject(new AggregateError(p));return}l=true;if(u.size===0){a(c);return}const e=[];for(const[r,t]of c.entries()){if(u.get(r)===i){continue}e.push(t)}a(e)}return}g++;(async()=>{try{const n=await e.value;if(l){return}const o=await r(n,t);if(o===i){u.set(t,o)}c[t]=o;g--;await next()}catch(e){if(n){reject(e)}else{p.push(e);g--;try{await next()}catch(e){reject(e)}}}})()};(async()=>{for(let e=0;e<t;e++){try{await next()}catch(e){reject(e);break}if(d||f){break}}})()}))}const i=Symbol("skip");var c=t._L;var p=t.ZP;var u=t.Ud;export{c as AbortError,p as default,u as pMapSkip};
@@ -0,0 +1,123 @@
1
+ export interface Options {
2
+ /**
3
+ Number of concurrently pending promises returned by `mapper`.
4
+
5
+ Must be an integer from 1 and up or `Infinity`.
6
+
7
+ @default Infinity
8
+ */
9
+ readonly concurrency?: number;
10
+
11
+ /**
12
+ When `true`, the first mapper rejection will be rejected back to the consumer.
13
+
14
+ When `false`, instead of stopping when a promise rejects, it will wait for all the promises to settle and then reject with an [aggregated error](https://github.com/sindresorhus/aggregate-error) containing all the errors from the rejected promises.
15
+
16
+ Caveat: When `true`, any already-started async mappers will continue to run until they resolve or reject. In the case of infinite concurrency with sync iterables, *all* mappers are invoked on startup and will continue after the first rejection. [Issue #51](https://github.com/sindresorhus/p-map/issues/51) can be implemented for abort control.
17
+
18
+ @default true
19
+ */
20
+ readonly stopOnError?: boolean;
21
+
22
+ /**
23
+ You can abort the promises using [`AbortController`](https://developer.mozilla.org/en-US/docs/Web/API/AbortController).
24
+
25
+ **Requires Node.js 16 or later.*
26
+
27
+ @example
28
+ ```
29
+ import pMap from 'p-map';
30
+ import delay from 'delay';
31
+
32
+ const abortController = new AbortController();
33
+
34
+ setTimeout(() => {
35
+ abortController.abort();
36
+ }, 500);
37
+
38
+ const mapper = async value => value;
39
+
40
+ await pMap([delay(1000), delay(1000)], mapper, {signal: abortController.signal});
41
+ // Throws AbortError (DOMException) after 500 ms.
42
+ ```
43
+ */
44
+ readonly signal?: AbortSignal;
45
+ }
46
+
47
+ type MaybePromise<T> = T | Promise<T>;
48
+
49
+ /**
50
+ Function which is called for every item in `input`. Expected to return a `Promise` or value.
51
+
52
+ @param element - Iterated element.
53
+ @param index - Index of the element in the source array.
54
+ */
55
+ export type Mapper<Element = any, NewElement = unknown> = (
56
+ element: Element,
57
+ index: number
58
+ ) => MaybePromise<NewElement | typeof pMapSkip>;
59
+
60
+ /**
61
+ @param input - Synchronous or asynchronous iterable that is iterated over concurrently, calling the `mapper` function for each element. Each iterated item is `await`'d before the `mapper` is invoked so the iterable may return a `Promise` that resolves to an item. Asynchronous iterables (different from synchronous iterables that return `Promise` that resolves to an item) can be used when the next item may not be ready without waiting for an asynchronous process to complete and/or the end of the iterable may be reached after the asynchronous process completes. For example, reading from a remote queue when the queue has reached empty, or reading lines from a stream.
62
+ @param mapper - Function which is called for every item in `input`. Expected to return a `Promise` or value.
63
+ @returns A `Promise` that is fulfilled when all promises in `input` and ones returned from `mapper` are fulfilled, or rejects if any of the promises reject. The fulfilled value is an `Array` of the fulfilled values returned from `mapper` in `input` order.
64
+
65
+ @example
66
+ ```
67
+ import pMap from 'p-map';
68
+ import got from 'got';
69
+
70
+ const sites = [
71
+ getWebsiteFromUsername('sindresorhus'), //=> Promise
72
+ 'https://avajs.dev',
73
+ 'https://github.com'
74
+ ];
75
+
76
+ const mapper = async site => {
77
+ const {requestUrl} = await got.head(site);
78
+ return requestUrl;
79
+ };
80
+
81
+ const result = await pMap(sites, mapper, {concurrency: 2});
82
+
83
+ console.log(result);
84
+ //=> ['https://sindresorhus.com/', 'https://avajs.dev/', 'https://github.com/']
85
+ ```
86
+ */
87
+ export default function pMap<Element, NewElement>(
88
+ input: AsyncIterable<Element | Promise<Element>> | Iterable<Element | Promise<Element>>,
89
+ mapper: Mapper<Element, NewElement>,
90
+ options?: Options
91
+ ): Promise<Array<Exclude<NewElement, typeof pMapSkip>>>;
92
+
93
+ /**
94
+ Return this value from a `mapper` function to skip including the value in the returned array.
95
+
96
+ @example
97
+ ```
98
+ import pMap, {pMapSkip} from 'p-map';
99
+ import got from 'got';
100
+
101
+ const sites = [
102
+ getWebsiteFromUsername('sindresorhus'), //=> Promise
103
+ 'https://avajs.dev',
104
+ 'https://example.invalid',
105
+ 'https://github.com'
106
+ ];
107
+
108
+ const mapper = async site => {
109
+ try {
110
+ const {requestUrl} = await got.head(site);
111
+ return requestUrl;
112
+ } catch {
113
+ return pMapSkip;
114
+ }
115
+ };
116
+
117
+ const result = await pMap(sites, mapper, {concurrency: 2});
118
+
119
+ console.log(result);
120
+ //=> ['https://sindresorhus.com/', 'https://avajs.dev/', 'https://github.com/']
121
+ ```
122
+ */
123
+ export const pMapSkip: unique symbol;
package/dist/index.d.ts CHANGED
@@ -2,16 +2,20 @@ 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
4
  import { Coin, OfflineSigner, OfflineDirectSigner } from '@cosmjs/proto-signing';
5
- import * as _keplr_wallet_types from '@keplr-wallet/types';
6
- import { AppCurrency, Key, ChainInfo, Keplr } from '@keplr-wallet/types';
5
+ import { ChainInfo, AppCurrency, Key, Keplr } from '@keplr-wallet/types';
7
6
  import * as _cosmjs_stargate from '@cosmjs/stargate';
8
7
  import { StargateClient, SigningStargateClient, SigningStargateClientOptions } from '@cosmjs/stargate';
9
8
  import * as _tanstack_react_query from '@tanstack/react-query';
9
+ import { QueryClientProviderProps } from '@tanstack/react-query';
10
10
  import * as _cosmjs_amino from '@cosmjs/amino';
11
- import { ReactNode } from 'react';
12
11
 
13
12
  declare type Dictionary<T = string> = Record<string, T>;
14
13
  declare type Maybe<T> = T | undefined;
14
+ declare type WalletType = "keplr";
15
+
16
+ interface ChainInfoWithPath extends ChainInfo {
17
+ path: string;
18
+ }
15
19
 
16
20
  interface GrazChain {
17
21
  chainId: string;
@@ -69,6 +73,27 @@ declare function defineChains<T extends Dictionary<GrazChain>>(chains: T): T;
69
73
  * ```
70
74
  */
71
75
  declare function defineChain<T extends GrazChain>(chain: T): T;
76
+ /**
77
+ * Helper function to define Keplr's `ChainInfo` object.
78
+ *
79
+ * This function does not do anything special else than providing type safety
80
+ * when defining chain information.
81
+ *
82
+ * @example
83
+ * ```ts
84
+ * import { defineChainInfo } from "graz";
85
+ *
86
+ * const cosmoshub = defineChainInfo({
87
+ * chainId: "cosmoshub-4",
88
+ * currencies: [ ... ],
89
+ * path: "cosmoshub",
90
+ * rest: "https://lcd-cosmoshub.blockapsis.com/",
91
+ * rpc: "https://rpc-cosmoshub.ecostake.com/",
92
+ * ...
93
+ * });
94
+ * ```
95
+ */
96
+ declare function defineChainInfo<T extends ChainInfo | ChainInfoWithPath>(chain: T): T;
72
97
  /**
73
98
  * Provided mainnet chains
74
99
  *
@@ -81,20 +106,20 @@ declare function defineChain<T extends GrazChain>(chain: T): T;
81
106
  * @see {@link testnetChains}
82
107
  */
83
108
  declare const mainnetChains: {
84
- axelar: _keplr_wallet_types.ChainInfo;
109
+ axelar: ChainInfo;
85
110
  /** @deprecated kept for compatibilty purposes; change to `mainnetChains.cosmoshub` */
86
- cosmos: _keplr_wallet_types.ChainInfo;
87
- cosmoshub: _keplr_wallet_types.ChainInfo;
88
- juno: _keplr_wallet_types.ChainInfo;
89
- osmosis: _keplr_wallet_types.ChainInfo;
90
- sommelier: _keplr_wallet_types.ChainInfo;
111
+ cosmos: ChainInfo;
112
+ cosmoshub: ChainInfo;
113
+ juno: ChainInfo;
114
+ osmosis: ChainInfo;
115
+ sommelier: ChainInfo;
91
116
  };
92
117
  /**
93
118
  * Arary version on {@link mainnetChains}
94
119
  *
95
120
  * @see {@link mainnetChains}
96
121
  */
97
- declare const mainnetChainsArray: _keplr_wallet_types.ChainInfo[];
122
+ declare const mainnetChainsArray: ChainInfo[];
98
123
  /**
99
124
  * Provided testnet chains
100
125
  *
@@ -107,27 +132,28 @@ declare const mainnetChainsArray: _keplr_wallet_types.ChainInfo[];
107
132
  * @see {@link mainnetChains}
108
133
  */
109
134
  declare const testnetChains: {
110
- crescent: _keplr_wallet_types.ChainInfo;
111
- juno: _keplr_wallet_types.ChainInfo;
112
- osmosis: _keplr_wallet_types.ChainInfo;
135
+ crescent: ChainInfo;
136
+ juno: ChainInfo;
137
+ osmosis: ChainInfo;
113
138
  };
114
139
  /**
115
140
  * Arary version on {@link testnetChains}
116
141
  *
117
142
  * @see {@link testnetChains}
118
143
  */
119
- declare const testnetChainsArray: _keplr_wallet_types.ChainInfo[];
144
+ declare const testnetChainsArray: ChainInfo[];
120
145
 
121
146
  declare type ConnectArgs = Maybe<GrazChain & {
122
147
  signerOpts?: SigningCosmWasmClientOptions;
148
+ walletType?: WalletType;
123
149
  }>;
124
150
  declare function connect(args?: ConnectArgs): Promise<Key>;
125
151
  declare function disconnect(clearRecentChain?: boolean): Promise<void>;
126
152
  declare function getBalances(bech32Address: string): Promise<Coin[]>;
127
153
  declare function reconnect(): void;
128
154
 
129
- declare function getRecentChain(): GrazChain | null;
130
155
  declare function clearRecentChain(): void;
156
+ declare function getRecentChain(): GrazChain | null;
131
157
  declare function suggestChain(chainInfo: ChainInfo): Promise<ChainInfo>;
132
158
  declare function suggestChainAndConnect(chainInfo: ChainInfo): Promise<{
133
159
  account: Key;
@@ -153,9 +179,9 @@ interface GrazStore {
153
179
  stargate: SigningStargateClient;
154
180
  } | null;
155
181
  status: "connected" | "connecting" | "reconnecting" | "disconnected";
182
+ walletType: WalletType;
156
183
  _notFoundFn: () => void;
157
184
  _reconnect: boolean;
158
- _supported: boolean;
159
185
  }
160
186
 
161
187
  declare type CreateClientArgs = Pick<GrazChain, "rpc" | "rpcHeaders">;
@@ -170,10 +196,21 @@ declare function createSigningClients(args: CreateSigningClientArgs): Promise<Gr
170
196
  interface ConfigureGrazArgs {
171
197
  defaultChain?: GrazChain;
172
198
  defaultSigningClient?: GrazStore["defaultSigningClient"];
173
- onKeplrNotFound?: () => void;
199
+ defaultWallet?: WalletType;
200
+ onNotFound?: () => void;
174
201
  }
175
202
  declare function configureGraz(args?: ConfigureGrazArgs): ConfigureGrazArgs;
176
203
 
204
+ /**
205
+ * Function to check whether given {@link WalletType} or default configured wallet exists.
206
+ *
207
+ * @example
208
+ * ```ts
209
+ * const isSupported = checkWallet();
210
+ * const isKeplrSupported = checkWallet("keplr");
211
+ * ```
212
+ */
213
+ declare function checkWallet(type?: WalletType): boolean;
177
214
  /**
178
215
  * Function to return {@link Keplr} object and throws and error if it does not exist on `window`.
179
216
  *
@@ -190,24 +227,18 @@ declare function configureGraz(args?: ConfigureGrazArgs): ConfigureGrazArgs;
190
227
  */
191
228
  declare function getKeplr(): Keplr;
192
229
  /**
193
- * Register a callback to run when invoking {@link getKeplr} throws an error.
230
+ * Function to return wallet object based on given {@link WalletType} or from store and throws an error if it does not
231
+ * exist on `window` or unknown wallet type.
194
232
  *
195
233
  * @example
196
234
  * ```ts
197
- * registerKeplrNotFound(() => {
198
- * console.error("keplr not found");
199
- * });
235
+ * const wallet = getWallet();
236
+ * const keplr = getWallet("keplr");
200
237
  * ```
201
238
  *
202
- * @see {@link unregisterKeplrNotFound}
203
- */
204
- declare function registerKeplrNotFound(fn: () => void): void;
205
- /**
206
- * Clear registered callback when using {@link registerKeplrNotFound}.
207
- *
208
- * @see {@link registerKeplrNotFound}
239
+ * @see {@link getKeplr}
209
240
  */
210
- declare function unregisterKeplrNotFound(): void;
241
+ declare function getWallet(type?: WalletType): Keplr;
211
242
 
212
243
  interface MutationEventArgs<TInitial = unknown, TSuccess = TInitial> {
213
244
  onError?: (error: unknown, data: TInitial) => unknown;
@@ -273,7 +304,7 @@ declare function useBalances(bech32Address?: string): {
273
304
  isRefetching: boolean;
274
305
  isSuccess: boolean;
275
306
  refetch: <TPageData>(options?: (_tanstack_react_query.RefetchOptions & _tanstack_react_query.RefetchQueryFilters<TPageData>) | undefined) => Promise<_tanstack_react_query.QueryObserverResult<_cosmjs_amino.Coin[], unknown>>;
276
- status: "error" | "loading" | "success";
307
+ status: "error" | "success" | "loading";
277
308
  };
278
309
  declare type UseConnectChainArgs = MutationEventArgs<ConnectArgs, Key>;
279
310
  /**
@@ -315,7 +346,7 @@ declare function useConnect({ onError, onLoading, onSuccess }?: UseConnectChainA
315
346
  isLoading: boolean;
316
347
  isSuccess: boolean;
317
348
  isSupported: boolean;
318
- status: "error" | "loading" | "success" | "idle";
349
+ status: "error" | "success" | "loading" | "idle";
319
350
  };
320
351
  /**
321
352
  * graz mutation hook to execute wallet disconnection with optional arguments to
@@ -347,7 +378,7 @@ declare function useDisconnect({ onError, onLoading, onSuccess }?: MutationEvent
347
378
  error: unknown;
348
379
  isLoading: boolean;
349
380
  isSuccess: boolean;
350
- status: "error" | "loading" | "success" | "idle";
381
+ status: "error" | "success" | "loading" | "idle";
351
382
  };
352
383
  /**
353
384
  * graz hook to retrieve offline signer objects (default, amino enabled, and auto).
@@ -419,7 +450,7 @@ declare function useSuggestChain({ onError, onLoading, onSuccess }?: UseSuggestC
419
450
  isSuccess: boolean;
420
451
  suggest: _tanstack_react_query.UseMutateFunction<ChainInfo, unknown, ChainInfo, unknown>;
421
452
  suggestAsync: _tanstack_react_query.UseMutateAsyncFunction<ChainInfo, unknown, ChainInfo, unknown>;
422
- status: "error" | "loading" | "success" | "idle";
453
+ status: "error" | "success" | "loading" | "idle";
423
454
  };
424
455
  declare type UseSuggestChainAndConnectArgs = MutationEventArgs<ChainInfo, {
425
456
  chain: ChainInfo;
@@ -457,7 +488,7 @@ declare function useSuggestChainAndConnect({ onError, onLoading, onSuccess }?: U
457
488
  isLoading: boolean;
458
489
  isSuccess: boolean;
459
490
  isSupported: boolean;
460
- status: "error" | "loading" | "success" | "idle";
491
+ status: "error" | "success" | "loading" | "idle";
461
492
  suggestAndConnect: _tanstack_react_query.UseMutateFunction<{
462
493
  account: Key;
463
494
  chain: ChainInfo;
@@ -499,7 +530,7 @@ declare function useClients(args?: WithRefetchOpts<CreateClientArgs>): {
499
530
  cosmWasm: _cosmjs_cosmwasm_stargate.CosmWasmClient;
500
531
  stargate: _cosmjs_stargate.StargateClient;
501
532
  } | null, unknown>>;
502
- status: "error" | "loading" | "success";
533
+ status: "error" | "success" | "loading";
503
534
  };
504
535
  /**
505
536
  * graz query hook to retrieve a SigningCosmWasmClient. If there's no given args it will be using the current connected signer
@@ -533,7 +564,7 @@ declare function useSigningClients(args?: WithRefetchOpts<CreateSigningClientArg
533
564
  cosmWasm: _cosmjs_cosmwasm_stargate.SigningCosmWasmClient;
534
565
  stargate: _cosmjs_stargate.SigningStargateClient;
535
566
  } | null, unknown>>;
536
- status: "error" | "loading" | "success";
567
+ status: "error" | "success" | "loading";
537
568
  };
538
569
 
539
570
  /**
@@ -543,22 +574,31 @@ declare function useSigningClients(args?: WithRefetchOpts<CreateSigningClientArg
543
574
  * ```ts
544
575
  * import { useCheckKeplr } from "graz";
545
576
  *
546
- * // basic example
547
- * const isSupported = useCheckKeplr();
548
- * if (isSupported) {
549
- * ...
550
- * }
577
+ * const { data: isSupported } = useCheckKeplr();
551
578
  * ```
552
579
  *
553
- * @see {@link getKeplr}
580
+ * @deprecated prefer using {@link useCheckWallet}
554
581
  */
555
- declare function useCheckKeplr(): boolean;
582
+ declare function useCheckKeplr(): _tanstack_react_query.UseQueryResult<boolean, unknown>;
583
+ /**
584
+ * graz query hook to check whether given {@link WalletType} or default configured wallet is supported
585
+ *
586
+ * @example
587
+ * ```ts
588
+ * import { useCheckWallet } from "graz";
589
+ *
590
+ * const { data: isSupported } = useCheckWallet();
591
+ * const { data: isKeplrSupported } = useCheckWallet("keplr");
592
+ * ```
593
+ */
594
+ declare function useCheckWallet(type?: WalletType): _tanstack_react_query.UseQueryResult<boolean, unknown>;
556
595
 
557
- interface GrazProviderProps {
558
- children: ReactNode;
559
- }
596
+ declare type GrazProviderProps = Partial<QueryClientProviderProps> & {
597
+ grazOptions?: ConfigureGrazArgs;
598
+ };
560
599
  /**
561
- * Provider component which wraps `@tanstack/react-query`'s {@link QueryClientProvider} and various `graz` side effects
600
+ * Provider component which extends `@tanstack/react-query`'s {@link QueryClientProvider} with built-in query client
601
+ * and various `graz` side effects
562
602
  *
563
603
  * @example
564
604
  * ```tsx
@@ -574,7 +614,19 @@ interface GrazProviderProps {
574
614
  *
575
615
  * @see https://tanstack.com/query
576
616
  */
577
- declare function GrazProvider({ children }: GrazProviderProps): JSX.Element;
578
- declare const GRAZ_PROVIDER_COMPONENT_KEY = "graz-query-client";
617
+ declare function GrazProvider({ children, grazOptions, ...props }: GrazProviderProps): JSX.Element;
618
+
619
+ /**
620
+ * Graz custom hook to track `keplr_keystorechange` event and reconnect state
621
+ *
622
+ * **Note: only use this hook if not using graz's provider component.**
623
+ */
624
+ declare function useGrazEvents(): null;
625
+ /**
626
+ * Null component to run {@link useGrazEvents} without affecting component tree.
627
+ *
628
+ * **Note: only use this component if not using graz's provider component.**
629
+ */
630
+ declare function GrazEvents(): null;
579
631
 
580
- export { ConfigureGrazArgs, ConnectArgs, CreateClientArgs, CreateSigningClientArgs, GRAZ_PROVIDER_COMPONENT_KEY, GrazChain, GrazProvider, GrazProviderProps, UseAccountArgs, UseConnectChainArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, clearRecentChain, configureGraz, connect, createClients, createSigningClients, defineChain, 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 };
632
+ export { ChainInfoWithPath, ConfigureGrazArgs, ConnectArgs, CreateClientArgs, CreateSigningClientArgs, Dictionary, GrazChain, GrazEvents, GrazProvider, GrazProviderProps, Maybe, UseAccountArgs, UseConnectChainArgs, UseSuggestChainAndConnectArgs, UseSuggestChainArgs, WalletType, checkWallet, clearRecentChain, configureGraz, connect, createClients, createSigningClients, defineChain, defineChainInfo, defineChains, disconnect, getBalances, getKeplr, getRecentChain, getWallet, mainnetChains, mainnetChainsArray, reconnect, suggestChain, suggestChainAndConnect, testnetChains, testnetChainsArray, useAccount, useActiveChain, useBalances, useCheckKeplr, useCheckWallet, useClients, useConnect, useDisconnect, useGrazEvents, useRecentChain, useSigners, useSigningClients, useSuggestChain, useSuggestChainAndConnect };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var Ie=Object.create;var d=Object.defineProperty;var De=Object.getOwnPropertyDescriptor;var ve=Object.getOwnPropertyNames;var be=Object.getPrototypeOf,Ge=Object.prototype.hasOwnProperty;var je=(e,t)=>{for(var o in t)d(e,o,{get:t[o],enumerable:!0})},L=(e,t,o,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of ve(t))!Ge.call(e,n)&&n!==o&&d(e,n,{get:()=>t[n],enumerable:!(i=De(t,n))||i.enumerable});return e};var H=(e,t,o)=>(o=e!=null?Ie(be(e)):{},L(t||!e||!e.__esModule?d(o,"default",{value:e,enumerable:!0}):o,e)),ze=e=>L(d({},"__esModule",{value:!0}),e);var yn={};je(yn,{GRAZ_PROVIDER_COMPONENT_KEY:()=>we,GrazProvider:()=>dn,clearRecentChain:()=>z,configureGraz:()=>Ue,connect:()=>p,createClients:()=>u,createSigningClients:()=>l,defineChain:()=>en,defineChains:()=>Ze,disconnect:()=>G,getBalances:()=>j,getKeplr:()=>g,getRecentChain:()=>Ke,mainnetChains:()=>nn,mainnetChainsArray:()=>tn,reconnect:()=>m,registerKeplrNotFound:()=>b,suggestChain:()=>S,suggestChainAndConnect:()=>O,testnetChains:()=>on,testnetChainsArray:()=>rn,unregisterKeplrNotFound:()=>Me,useAccount:()=>de,useActiveChain:()=>pn,useBalances:()=>sn,useCheckKeplr:()=>h,useClients:()=>hn,useConnect:()=>cn,useDisconnect:()=>an,useRecentChain:()=>un,useSigners:()=>mn,useSigningClients:()=>fn,useSuggestChain:()=>ln,useSuggestChainAndConnect:()=>gn});module.exports=ze(yn);var Q=require("@cosmjs/stargate");var J=H(require("zustand")),y=require("zustand/middleware"),I={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",_notFoundFn:()=>null,_reconnect:!1,_supported:!1},Oe={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},r=(0,J.default)((0,y.subscribeWithSelector)((0,y.persist)(()=>I,Oe)));var D=require("@cosmjs/cosmwasm-stargate"),v=require("@cosmjs/stargate");async function u({rpc:e,rpcHeaders:t}){let o={url:e,headers:{...t||{}}},[i,n]=await Promise.all([D.SigningCosmWasmClient.connect(o),v.SigningStargateClient.connect(o)]);return{cosmWasm:i,stargate:n}}async function l(e){let{rpc:t,rpcHeaders:o,offlineSignerAuto:i,cosmWasmSignerOptions:n={},stargateSignerOptions:s={}}=e,a={url:t,headers:{...o||{}}},[C,x]=await Promise.all([D.SigningCosmWasmClient.connectWithSigner(a,i,n),v.SigningStargateClient.connectWithSigner(a,i,s)]);return{cosmWasm:C,stargate:x}}function g(){if(typeof window.keplr<"u")return window.keplr;throw r.getState()._notFoundFn(),new Error("Keplr is not defined")}function b(e){r.setState({_notFoundFn:e})}function Me(){r.setState({_notFoundFn:()=>null})}async function p(e){try{let t=g(),{defaultChain:o,recentChain:i}=r.getState(),n=e||i||o;if(!n)throw new Error("No last known connected chain, connect action requires chain info");r.setState(k=>{let ke=k._reconnect;return k.activeChain&&k.activeChain.chainId!==n.chainId?{status:"connecting"}:ke?{status:"reconnecting"}:{status:"connecting"}}),await t.enable(n.chainId);let s=t.getOfflineSigner(n.chainId),a=t.getOfflineSignerOnlyAmino(n.chainId),C=await t.getOfflineSignerAuto(n.chainId),x=n.gas?Q.GasPrice.fromString(`${n.gas.price}${n.gas.denom}`):void 0,[F,Ae,xe]=await Promise.all([t.getKey(n.chainId),u(n),l({...n,offlineSignerAuto:C,cosmWasmSignerOptions:{gasPrice:x,...(e==null?void 0:e.signerOpts)||{}}})]);return r.setState({account:F,activeChain:n,clients:Ae,offlineSigner:s,offlineSignerAmino:a,offlineSignerAuto:C,recentChain:n,signingClients:xe,status:"connected",_reconnect:!0}),F}catch(t){throw r.getState().account===null&&r.setState({status:"disconnected"}),t}}async function G(e=!1){return r.setState(t=>({...I,recentChain:e?null:t.recentChain,_supported:t._supported})),Promise.resolve()}async function j(e){let{activeChain:t,signingClients:o}=r.getState();if(!t||!o)throw new Error("No connected account detected");let{defaultSigningClient:i}=r.getState();return await Promise.all(t.currencies.map(async s=>o[i].getBalance(e,s.coinMinimalDenom)))}function m(){let{activeChain:e}=r.getState();e&&p(e)}function Ke(){return r.getState().recentChain}function z(){r.setState({recentChain:null})}async function S(e){return await g().experimentalSuggestChain(e),e}async function O(e){let t=await S(e);return{account:await p(e),chain:t}}function Ue(e={}){return e.defaultChain&&r.setState({defaultChain:e.defaultChain}),e.defaultSigningClient&&r.setState({defaultSigningClient:e.defaultSigningClient}),e.onKeplrNotFound&&b(e.onKeplrNotFound),e}var X=require("@keplr-wallet/cosmos"),$={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},qe={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},Te={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},Ne={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,Te,Ne,Pe,Be],M={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:$,bip44:{coinType:118},bech32Config:X.Bech32Address.defaultBech32Config("axelar"),currencies:V,feeCurrencies:V};var Z=require("@keplr-wallet/cosmos"),ee={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Y=[ee],w={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:ee,bip44:{coinType:118},bech32Config:Z.Bech32Address.defaultBech32Config("cosmos"),currencies:Y,feeCurrencies:Y};var te=require("@keplr-wallet/cosmos"),oe={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},ne=[oe],K={rpc:"https://testnet-endpoint.crescent.network/rpc/crescent",rest:"https://testnet-endpoint.crescent.network/api/crescent",chainId:"mooncat-1-1",chainName:"Crescent Testnet",bip44:{coinType:118},bech32Config:te.Bech32Address.defaultBech32Config("CRE"),currencies:ne,feeCurrencies:ne,stakeCurrency:oe,coinType:118};var re=require("@keplr-wallet/cosmos"),se={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Re={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},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],T={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],N={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}function en(e){return e}var nn={axelar:M,cosmos:w,cosmoshub:w,juno:U,osmosis:N,sommelier:R},tn=[M,w,U,N,R],on={crescent:K,juno:T,osmosis:B},rn=[K,T,B];var f=require("@tanstack/react-query"),fe=require("react"),Ce=H(require("zustand/shallow"));function h(){return r(e=>e._supported)}function de({onConnect:e,onDisconnect:t}={}){let o=r(n=>n.account),i=r(n=>n.status);return(0,fe.useEffect)(()=>r.subscribe(n=>n.status,(n,s)=>{if(n==="connected"){let a=r.getState();e==null||e({account:a.account,isReconnect:s==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:Boolean(o),isConnecting:i==="connecting",isDisconnected:i==="disconnected",isReconnecting:i==="reconnecting",reconnect:m,status:i}}function sn(e){let{data:t}=de(),o=e||(t==null?void 0:t.bech32Address),n=(0,f.useQuery)(["USE_BALANCES",o],({queryKey:[,s]})=>j(s),{enabled:Boolean(o)});return{data:n.data,error:n.error,isFetching:n.isFetching,isLoading:n.isLoading,isRefetching:n.isRefetching,isSuccess:n.isSuccess,refetch:n.refetch,status:n.status}}function cn({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 an({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,f.useMutation)(["USE_DISCONNECT",e,t,o],G,{onError:s=>Promise.resolve(e==null?void 0:e(s,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return{disconnect:s=>n.mutate(s),disconnectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}}function mn(){return r(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Ce.default)}var E=require("@tanstack/react-query");function pn(){return r(e=>e.activeChain)}function un(){return{data:r(t=>t.recentChain),clear:z}}function ln({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 gn({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,E.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],O,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:h(),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}}var W=require("@tanstack/react-query");function hn(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 fn(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 A=require("@tanstack/react-query");var ye=require("react");function Se(){return(0,ye.useEffect)(()=>{r.setState({_supported:typeof window.keplr<"u"});let{_reconnect:e}=r.getState();return e&&m(),window.addEventListener("keplr_keystorechange",m),()=>{window.removeEventListener("keplr_keystorechange",m)}},[]),null}var _=require("react/jsx-runtime"),Cn=new A.QueryClient({});function dn({children:e}){return(0,_.jsxs)(A.QueryClientProvider,{client:Cn,children:[(0,_.jsx)(Se,{}),e]},we)}var we="graz-query-client";0&&(module.exports={GRAZ_PROVIDER_COMPONENT_KEY,GrazProvider,clearRecentChain,configureGraz,connect,createClients,createSigningClients,defineChain,defineChains,disconnect,getBalances,getKeplr,getRecentChain,mainnetChains,mainnetChainsArray,reconnect,registerKeplrNotFound,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,unregisterKeplrNotFound,useAccount,useActiveChain,useBalances,useCheckKeplr,useClients,useConnect,useDisconnect,useRecentChain,useSigners,useSigningClients,useSuggestChain,useSuggestChainAndConnect});
1
+ "use strict";var ze=Object.create;var C=Object.defineProperty;var je=Object.getOwnPropertyDescriptor;var Te=Object.getOwnPropertyNames;var Oe=Object.getPrototypeOf,We=Object.prototype.hasOwnProperty;var Me=(e,t)=>{for(var o in t)C(e,o,{get:t[o],enumerable:!0})},J=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Te(t))!We.call(e,n)&&n!==o&&C(e,n,{get:()=>t[n],enumerable:!(r=je(t,n))||r.enumerable});return e};var V=(e,t,o)=>(o=e!=null?ze(Oe(e)):{},J(t||!e||!e.__esModule?C(o,"default",{value:e,enumerable:!0}):o,e)),Ue=e=>J(C({},"__esModule",{value:!0}),e);var kn={};Me(kn,{GrazEvents:()=>L,GrazProvider:()=>xn,checkWallet:()=>G,clearRecentChain:()=>j,configureGraz:()=>O,connect:()=>l,createClients:()=>h,createSigningClients:()=>f,defineChain:()=>on,defineChainInfo:()=>rn,defineChains:()=>tn,disconnect:()=>b,getBalances:()=>z,getKeplr:()=>$,getRecentChain:()=>Pe,getWallet:()=>u,mainnetChains:()=>sn,mainnetChainsArray:()=>cn,reconnect:()=>p,suggestChain:()=>w,suggestChainAndConnect:()=>T,testnetChains:()=>an,testnetChainsArray:()=>mn,useAccount:()=>xe,useActiveChain:()=>fn,useBalances:()=>un,useCheckKeplr:()=>pn,useCheckWallet:()=>g,useClients:()=>wn,useConnect:()=>ln,useDisconnect:()=>gn,useGrazEvents:()=>Ie,useRecentChain:()=>yn,useSigners:()=>hn,useSigningClients:()=>Sn,useSuggestChain:()=>Cn,useSuggestChainAndConnect:()=>dn});module.exports=Ue(kn);var Y=require("@cosmjs/stargate");var X=V(require("zustand")),d=require("zustand/middleware"),I={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",walletType:"keplr",_notFoundFn:()=>null,_reconnect:!1},qe={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},i=(0,X.default)((0,d.subscribeWithSelector)((0,d.persist)(()=>I,qe)));var D=require("@cosmjs/cosmwasm-stargate"),v=require("@cosmjs/stargate");async function h({rpc:e,rpcHeaders:t}){let o={url:e,headers:{...t||{}}},[r,n]=await Promise.all([D.SigningCosmWasmClient.connect(o),v.SigningStargateClient.connect(o)]);return{cosmWasm:r,stargate:n}}async function f(e){let{rpc:t,rpcHeaders:o,offlineSignerAuto:r,cosmWasmSignerOptions:n={},stargateSignerOptions:c={}}=e,s={url:t,headers:{...o||{}}},[m,x]=await Promise.all([D.SigningCosmWasmClient.connectWithSigner(s,r,n),v.SigningStargateClient.connectWithSigner(s,r,c)]);return{cosmWasm:m,stargate:x}}function G(e=i.getState().walletType){try{return u(e),!0}catch(t){return console.error(t),!1}}function $(){if(typeof window.keplr<"u")return window.keplr;throw i.getState()._notFoundFn(),new Error("window.keplr is not defined")}function u(e=i.getState().walletType){switch(e){case"keplr":return $();default:throw new Error("Unknown wallet type")}}async function l(e){try{let{defaultChain:t,recentChain:o,walletType:r}=i.getState(),n=(e==null?void 0:e.walletType)||r,c=u(n),s=e||o||t;if(!s)throw new Error("No last known connected chain, connect action requires chain info");i.setState(k=>{let be=k._reconnect;return k.activeChain&&k.activeChain.chainId!==s.chainId?{status:"connecting"}:be?{status:"reconnecting"}:{status:"connecting"}}),await c.enable(s.chainId);let m=c.getOfflineSigner(s.chainId),x=c.getOfflineSignerOnlyAmino(s.chainId),H=await c.getOfflineSignerAuto(s.chainId),De=s.gas?Y.GasPrice.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[Q,ve,Ge]=await Promise.all([c.getKey(s.chainId),h(s),f({...s,offlineSignerAuto:H,cosmWasmSignerOptions:{gasPrice:De,...(e==null?void 0:e.signerOpts)||{}}})]);return i.setState({account:Q,activeChain:s,clients:ve,offlineSigner:m,offlineSignerAmino:x,offlineSignerAuto:H,recentChain:s,signingClients:Ge,status:"connected",walletType:n,_reconnect:!0}),Q}catch(t){throw i.getState().account===null&&i.setState({status:"disconnected"}),t}}async function b(e=!1){return i.setState(t=>({...I,recentChain:e?null:t.recentChain})),Promise.resolve()}async function z(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 c=>o[r].getBalance(e,c.coinMinimalDenom)))}function p(){let{activeChain:e}=i.getState();e&&l(e)}function j(){i.setState({recentChain:null})}function Pe(){return i.getState().recentChain}async function w(e){return await u().experimentalSuggestChain(e),e}async function T(e){let t=await w(e);return{account:await l(e),chain:t}}function O(e={}){return i.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||e.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn})),e}var ee=require("@keplr-wallet/cosmos"),ne={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},Ke={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},Be={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},Ee={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"},Re={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},Z=[ne,Ke,Be,Ee,Ne,Re],W={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:ne,bip44:{coinType:118},bech32Config:ee.Bech32Address.defaultBech32Config("axelar"),currencies:Z,feeCurrencies:Z};var oe=require("@keplr-wallet/cosmos"),re={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},te=[re],S={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:re,bip44:{coinType:118},bech32Config:oe.Bech32Address.defaultBech32Config("cosmos"),currencies:te,feeCurrencies:te};var se=require("@keplr-wallet/cosmos"),ce={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Fe={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},Le={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},_e={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},He={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Qe={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Je={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Ve={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},Xe={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},$e={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Ye={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},ie=[ce,Fe,Le,_e,He,Qe,Je,Ve,Xe,$e,Ye],M={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:ce,bip44:{coinType:118},bech32Config:se.Bech32Address.defaultBech32Config("juno"),currencies:ie,feeCurrencies:ie};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"},Ze={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ae=[pe,Ze],U={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 le=require("@keplr-wallet/cosmos"),ge={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},ue=[ge],q={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:ge,bip44:{coinType:118},bech32Config:le.Bech32Address.defaultBech32Config("somm"),currencies:ue,feeCurrencies:ue};var fe=require("@keplr-wallet/cosmos"),ye={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},he=[ye],P={rpc:"https://testnet-endpoint.crescent.network/rpc/crescent",rest:"https://testnet-endpoint.crescent.network/api/crescent",chainId:"mooncat-1-1",chainName:"Crescent Testnet",bip44:{coinType:118},bech32Config:fe.Bech32Address.defaultBech32Config("CRE"),currencies:he,feeCurrencies:he,stakeCurrency:ye,coinType:118};var Ce=require("@keplr-wallet/cosmos"),K={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},en=[K],B={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-3",chainName:"Juno Testnet",stakeCurrency:K,bip44:{coinType:118},bech32Config:Ce.Bech32Address.defaultBech32Config("juno"),currencies:en,feeCurrencies:[K],coinType:118};var de=require("@keplr-wallet/cosmos"),E={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},nn=[E],N={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:E,bip44:{coinType:118},bech32Config:de.Bech32Address.defaultBech32Config("osmo"),currencies:nn,feeCurrencies:[E],coinType:118};function tn(e){return e}function on(e){return e}function rn(e){return e}var sn={axelar:W,cosmos:S,cosmoshub:S,juno:M,osmosis:U,sommelier:q},cn=[W,S,M,U,q],an={crescent:P,juno:B,osmosis:N},mn=[P,B,N];var y=require("@tanstack/react-query"),Se=require("react"),Ae=V(require("zustand/shallow"));var we=require("@tanstack/react-query");function pn(){return g("keplr")}function g(e){let t=i(r=>e||r.walletType);return(0,we.useQuery)(["USE_CHECK_WALLET",t],({queryKey:[,r]})=>G(r))}function xe({onConnect:e,onDisconnect:t}={}){let o=i(n=>n.account),r=i(n=>n.status);return(0,Se.useEffect)(()=>i.subscribe(n=>n.status,(n,c)=>{if(n==="connected"){let s=i.getState();e==null||e({account:s.account,isReconnect:c==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:Boolean(o),isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",reconnect:p,status:r}}function un(e){let{data:t}=xe(),o=e||(t==null?void 0:t.bech32Address),n=(0,y.useQuery)(["USE_BALANCES",o],({queryKey:[,c]})=>z(c),{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 ln({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,y.useMutation)(["USE_CONNECT",e,t,o],l,{onError:(s,m)=>Promise.resolve(e==null?void 0:e(s,m)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:c}=g();return{connect:s=>n.mutate(s),connectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(c),status:n.status}}function gn({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,y.useMutation)(["USE_DISCONNECT",e,t,o],b,{onError:c=>Promise.resolve(e==null?void 0:e(c,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return{disconnect:c=>n.mutate(c),disconnectAsync:c=>n.mutateAsync(c),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}}function hn(){return i(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Ae.default)}var R=require("@tanstack/react-query");function fn(){return i(e=>e.activeChain)}function yn(){return{data:i(t=>t.recentChain),clear:j}}function Cn({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,R.useMutation)(["USE_SUGGEST_CHAIN",e,t,o],w,{onError:(c,s)=>Promise.resolve(e==null?void 0:e(c,s)),onMutate:t,onSuccess:c=>Promise.resolve(o==null?void 0:o(c))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}}function dn({onError:e,onLoading:t,onSuccess:o}={}){let n=(0,R.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],T,{onError:(s,m)=>Promise.resolve(e==null?void 0:e(s,m)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:c}=g();return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(c),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}}var F=require("@tanstack/react-query");function wn(e){let t=i(n=>n.clients),r=(0,F.useQuery)(["USE_CLIENTS",e,t],({queryKey:[,n,c]})=>n!=null&&n.rpc?h(n):c,{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 Sn(e){let t=i(n=>n.signingClients),r=(0,F.useQuery)(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,c]})=>n!=null&&n.rpc?f(n):c,{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}}var A=require("@tanstack/react-query");var ke=require("react");function Ie(){return(0,ke.useEffect)(()=>{let{_reconnect:e}=i.getState();return e&&p(),window.addEventListener("keplr_keystorechange",p),()=>{window.removeEventListener("keplr_keystorechange",p)}},[]),null}function L(){return Ie(),null}var _=require("react/jsx-runtime"),An=new A.QueryClient({});function xn({children:e,grazOptions:t,...o}){return t&&O(t),(0,_.jsxs)(A.QueryClientProvider,{client:An,...o,children:[(0,_.jsx)(L,{}),e]})}0&&(module.exports={GrazEvents,GrazProvider,checkWallet,clearRecentChain,configureGraz,connect,createClients,createSigningClients,defineChain,defineChainInfo,defineChains,disconnect,getBalances,getKeplr,getRecentChain,getWallet,mainnetChains,mainnetChainsArray,reconnect,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,useAccount,useActiveChain,useBalances,useCheckKeplr,useCheckWallet,useClients,useConnect,useDisconnect,useGrazEvents,useRecentChain,useSigners,useSigningClients,useSuggestChain,useSuggestChainAndConnect});
package/dist/index.mjs CHANGED
@@ -1 +1 @@
1
- import{GasPrice as ce}from"@cosmjs/stargate";import oe from"zustand";import{persist as ie,subscribeWithSelector as re}from"zustand/middleware";var S={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",_notFoundFn:()=>null,_reconnect:!1,_supported:!1},se={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},i=oe(re(ie(()=>S,se)));import{SigningCosmWasmClient as O}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as M}from"@cosmjs/stargate";async function l({rpc:e,rpcHeaders:t}){let o={url:e,headers:{...t||{}}},[r,n]=await Promise.all([O.connect(o),M.connect(o)]);return{cosmWasm:r,stargate:n}}async function g(e){let{rpc:t,rpcHeaders:o,offlineSignerAuto:r,cosmWasmSignerOptions:n={},stargateSignerOptions:s={}}=e,a={url:t,headers:{...o||{}}},[u,d]=await Promise.all([O.connectWithSigner(a,r,n),M.connectWithSigner(a,r,s)]);return{cosmWasm:u,stargate:d}}function h(){if(typeof window.keplr<"u")return window.keplr;throw i.getState()._notFoundFn(),new Error("Keplr is not defined")}function K(e){i.setState({_notFoundFn:e})}function Ze(){i.setState({_notFoundFn:()=>null})}async function p(e){try{let t=h(),{defaultChain:o,recentChain:r}=i.getState(),n=e||r||o;if(!n)throw new Error("No last known connected chain, connect action requires chain info");i.setState(y=>{let te=y._reconnect;return y.activeChain&&y.activeChain.chainId!==n.chainId?{status:"connecting"}:te?{status:"reconnecting"}:{status:"connecting"}}),await t.enable(n.chainId);let s=t.getOfflineSigner(n.chainId),a=t.getOfflineSignerOnlyAmino(n.chainId),u=await t.getOfflineSignerAuto(n.chainId),d=n.gas?ce.fromString(`${n.gas.price}${n.gas.denom}`):void 0,[z,ee,ne]=await Promise.all([t.getKey(n.chainId),l(n),g({...n,offlineSignerAuto:u,cosmWasmSignerOptions:{gasPrice:d,...(e==null?void 0:e.signerOpts)||{}}})]);return i.setState({account:z,activeChain:n,clients:ee,offlineSigner:s,offlineSignerAmino:a,offlineSignerAuto:u,recentChain:n,signingClients:ne,status:"connected",_reconnect:!0}),z}catch(t){throw i.getState().account===null&&i.setState({status:"disconnected"}),t}}async function U(e=!1){return i.setState(t=>({...S,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 T(){i.setState({recentChain:null})}async function w(e){return await h().experimentalSuggestChain(e),e}async function N(e){let t=await w(e);return{account:await p(e),chain:t}}function hn(e={}){return e.defaultChain&&i.setState({defaultChain:e.defaultChain}),e.defaultSigningClient&&i.setState({defaultSigningClient:e.defaultSigningClient}),e.onKeplrNotFound&&K(e.onKeplrNotFound),e}import{Bech32Address as ae}from"@keplr-wallet/cosmos";var B={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},me={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},pe={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},ue={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},le={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},ge={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},P=[B,me,pe,ue,le,ge],A={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:B,bip44:{coinType:118},bech32Config:ae.defaultBech32Config("axelar"),currencies: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],f={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"},de={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},ye={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},Se={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},we={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Ae={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},xe={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},ke={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},Ie={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},De={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},ve={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},F=[L,de,ye,Se,we,Ae,xe,ke,Ie,De,ve],k={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:L,bip44:{coinType:118},bech32Config:Ce.defaultBech32Config("juno"),currencies:F,feeCurrencies:F};import{Bech32Address as be}from"@keplr-wallet/cosmos";var I={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Ge=[I],D={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-3",chainName:"Juno Testnet",stakeCurrency:I,bip44:{coinType:118},bech32Config:be.defaultBech32Config("juno"),currencies:Ge,feeCurrencies:[I],coinType:118};import{Bech32Address as je}from"@keplr-wallet/cosmos";var J={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},ze={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},H=[J,ze],v={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:J,bip44:{coinType:118},bech32Config:je.defaultBech32Config("osmo"),currencies:H,feeCurrencies:H};import{Bech32Address as Oe}from"@keplr-wallet/cosmos";var b={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Me=[b],G={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:b,bip44:{coinType:118},bech32Config:Oe.defaultBech32Config("osmo"),currencies:Me,feeCurrencies:[b],coinType:118};import{Bech32Address as Ke}from"@keplr-wallet/cosmos";var V={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},Q=[V],j={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:V,bip44:{coinType:118},bech32Config:Ke.defaultBech32Config("somm"),currencies:Q,feeCurrencies:Q};function Rn(e){return e}function En(e){return e}var Wn={axelar:A,cosmos:f,cosmoshub:f,juno:k,osmosis:v,sommelier:j},_n=[A,f,k,v,j],Fn={crescent:x,juno:D,osmosis:G},Ln=[x,D,G];import{useMutation as X,useQuery as Ue}from"@tanstack/react-query";import{useEffect as qe}from"react";import Te from"zustand/shallow";function C(){return i(e=>e._supported)}function Ne({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 nt(e){let{data:t}=Ne(),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 tt({onError:e,onLoading:t,onSuccess:o}={}){let n=X(["USE_CONNECT",e,t,o],p,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return{connect:s=>n.mutate(s),connectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:C(),status:n.status}}function ot({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 it(){return i(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Te)}import{useMutation as $}from"@tanstack/react-query";function pt(){return i(e=>e.activeChain)}function ut(){return{data:i(t=>t.recentChain),clear:T}}function lt({onError:e,onLoading:t,onSuccess:o}={}){let n=$(["USE_SUGGEST_CHAIN",e,t,o],w,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}}function gt({onError:e,onLoading:t,onSuccess:o}={}){let n=$(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],N,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:C(),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}}import{useQuery as Y}from"@tanstack/react-query";function 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 St(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 bt({children:e}){return Fe(Re,{client:Ee,children:[_e(Z,{}),e]},We)}var We="graz-query-client";export{We as GRAZ_PROVIDER_COMPONENT_KEY,bt as GrazProvider,T as clearRecentChain,hn as configureGraz,p as connect,l as createClients,g as createSigningClients,En as defineChain,Rn as defineChains,U as disconnect,q as getBalances,h as getKeplr,pn as getRecentChain,Wn as mainnetChains,_n as mainnetChainsArray,m as reconnect,K as registerKeplrNotFound,w as suggestChain,N as suggestChainAndConnect,Fn as testnetChains,Ln as testnetChainsArray,Ze as unregisterKeplrNotFound,Ne as useAccount,pt as useActiveChain,nt as useBalances,C as useCheckKeplr,yt as useClients,tt as useConnect,ot as useDisconnect,ut as useRecentChain,it as useSigners,St as useSigningClients,lt as useSuggestChain,gt as useSuggestChainAndConnect};
1
+ import{GasPrice as ue}from"@cosmjs/stargate";import se from"zustand";import{persist as ce,subscribeWithSelector as ae}from"zustand/middleware";var w={account:null,activeChain:null,balances:null,clients:null,defaultChain:null,defaultSigningClient:"stargate",offlineSigner:null,offlineSignerAmino:null,offlineSignerAuto:null,recentChain:null,signingClients:null,status:"disconnected",walletType:"keplr",_notFoundFn:()=>null,_reconnect:!1},me={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect}),version:1},i=se(ae(ce(()=>w,me)));import{SigningCosmWasmClient as O}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as W}from"@cosmjs/stargate";async function h({rpc:e,rpcHeaders:t}){let o={url:e,headers:{...t||{}}},[r,n]=await Promise.all([O.connect(o),W.connect(o)]);return{cosmWasm:r,stargate:n}}async function f(e){let{rpc:t,rpcHeaders:o,offlineSignerAuto:r,cosmWasmSignerOptions:n={},stargateSignerOptions:c={}}=e,s={url:t,headers:{...o||{}}},[m,C]=await Promise.all([O.connectWithSigner(s,r,n),W.connectWithSigner(s,r,c)]);return{cosmWasm:m,stargate:C}}function M(e=i.getState().walletType){try{return u(e),!0}catch(t){return console.error(t),!1}}function pe(){if(typeof window.keplr<"u")return window.keplr;throw i.getState()._notFoundFn(),new Error("window.keplr is not defined")}function u(e=i.getState().walletType){switch(e){case"keplr":return pe();default:throw new Error("Unknown wallet type")}}async function l(e){try{let{defaultChain:t,recentChain:o,walletType:r}=i.getState(),n=(e==null?void 0:e.walletType)||r,c=u(n),s=e||o||t;if(!s)throw new Error("No last known connected chain, connect action requires chain info");i.setState(d=>{let ie=d._reconnect;return d.activeChain&&d.activeChain.chainId!==s.chainId?{status:"connecting"}:ie?{status:"reconnecting"}:{status:"connecting"}}),await c.enable(s.chainId);let m=c.getOfflineSigner(s.chainId),C=c.getOfflineSignerOnlyAmino(s.chainId),j=await c.getOfflineSignerAuto(s.chainId),te=s.gas?ue.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[T,oe,re]=await Promise.all([c.getKey(s.chainId),h(s),f({...s,offlineSignerAuto:j,cosmWasmSignerOptions:{gasPrice:te,...(e==null?void 0:e.signerOpts)||{}}})]);return i.setState({account:T,activeChain:s,clients:oe,offlineSigner:m,offlineSignerAmino:C,offlineSignerAuto:j,recentChain:s,signingClients:re,status:"connected",walletType:n,_reconnect:!0}),T}catch(t){throw i.getState().account===null&&i.setState({status:"disconnected"}),t}}async function U(e=!1){return i.setState(t=>({...w,recentChain:e?null:t.recentChain})),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 c=>o[r].getBalance(e,c.coinMinimalDenom)))}function p(){let{activeChain:e}=i.getState();e&&l(e)}function P(){i.setState({recentChain:null})}function hn(){return i.getState().recentChain}async function S(e){return await u().experimentalSuggestChain(e),e}async function K(e){let t=await S(e);return{account:await l(e),chain:t}}function B(e={}){return i.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||e.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn})),e}import{Bech32Address as le}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"},ge={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},he={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},fe={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},ye={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},Ce={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},E=[N,ge,he,fe,ye,Ce],A={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:N,bip44:{coinType:118},bech32Config:le.defaultBech32Config("axelar"),currencies:E,feeCurrencies:E};import{Bech32Address as de}from"@keplr-wallet/cosmos";var F={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},R=[F],y={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:F,bip44:{coinType:118},bech32Config:de.defaultBech32Config("cosmos"),currencies:R,feeCurrencies:R};import{Bech32Address as we}from"@keplr-wallet/cosmos";var _={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Se={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},Ae={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},xe={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},ke={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Ie={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},De={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},ve={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},Ge={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},be={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},ze={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},L=[_,Se,Ae,xe,ke,Ie,De,ve,Ge,be,ze],x={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:_,bip44:{coinType:118},bech32Config:we.defaultBech32Config("juno"),currencies:L,feeCurrencies:L};import{Bech32Address as je}from"@keplr-wallet/cosmos";var Q={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Te={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},H=[Q,Te],k={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Q,bip44:{coinType:118},bech32Config:je.defaultBech32Config("osmo"),currencies:H,feeCurrencies:H};import{Bech32Address as Oe}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"},J=[V],I={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:V,bip44:{coinType:118},bech32Config:Oe.defaultBech32Config("somm"),currencies:J,feeCurrencies:J};import{Bech32Address as We}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"},X=[$],D={rpc:"https://testnet-endpoint.crescent.network/rpc/crescent",rest:"https://testnet-endpoint.crescent.network/api/crescent",chainId:"mooncat-1-1",chainName:"Crescent Testnet",bip44:{coinType:118},bech32Config:We.defaultBech32Config("CRE"),currencies:X,feeCurrencies:X,stakeCurrency:$,coinType:118};import{Bech32Address as Me}from"@keplr-wallet/cosmos";var v={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Ue=[v],G={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-3",chainName:"Juno Testnet",stakeCurrency:v,bip44:{coinType:118},bech32Config:Me.defaultBech32Config("juno"),currencies:Ue,feeCurrencies:[v],coinType:118};import{Bech32Address as qe}from"@keplr-wallet/cosmos";var b={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Pe=[b],z={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:qe.defaultBech32Config("osmo"),currencies:Pe,feeCurrencies:[b],coinType:118};function Rn(e){return e}function Fn(e){return e}function Ln(e){return e}var _n={axelar:A,cosmos:y,cosmoshub:y,juno:x,osmosis:k,sommelier:I},Hn=[A,y,x,k,I],Qn={crescent:D,juno:G,osmosis:z},Jn=[D,G,z];import{useMutation as Y,useQuery as Be}from"@tanstack/react-query";import{useEffect as Ee}from"react";import Ne from"zustand/shallow";import{useQuery as Ke}from"@tanstack/react-query";function Zn(){return g("keplr")}function g(e){let t=i(r=>e||r.walletType);return Ke(["USE_CHECK_WALLET",t],({queryKey:[,r]})=>M(r))}function Re({onConnect:e,onDisconnect:t}={}){let o=i(n=>n.account),r=i(n=>n.status);return Ee(()=>i.subscribe(n=>n.status,(n,c)=>{if(n==="connected"){let s=i.getState();e==null||e({account:s.account,isReconnect:c==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:Boolean(o),isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",reconnect:p,status:r}}function ct(e){let{data:t}=Re(),o=e||(t==null?void 0:t.bech32Address),n=Be(["USE_BALANCES",o],({queryKey:[,c]})=>q(c),{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 at({onError:e,onLoading:t,onSuccess:o}={}){let n=Y(["USE_CONNECT",e,t,o],l,{onError:(s,m)=>Promise.resolve(e==null?void 0:e(s,m)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:c}=g();return{connect:s=>n.mutate(s),connectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(c),status:n.status}}function mt({onError:e,onLoading:t,onSuccess:o}={}){let n=Y(["USE_DISCONNECT",e,t,o],U,{onError:c=>Promise.resolve(e==null?void 0:e(c,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return{disconnect:c=>n.mutate(c),disconnectAsync:c=>n.mutateAsync(c),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}}function pt(){return i(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Ne)}import{useMutation as Z}from"@tanstack/react-query";function yt(){return i(e=>e.activeChain)}function Ct(){return{data:i(t=>t.recentChain),clear:P}}function dt({onError:e,onLoading:t,onSuccess:o}={}){let n=Z(["USE_SUGGEST_CHAIN",e,t,o],S,{onError:(c,s)=>Promise.resolve(e==null?void 0:e(c,s)),onMutate:t,onSuccess:c=>Promise.resolve(o==null?void 0:o(c))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}}function wt({onError:e,onLoading:t,onSuccess:o}={}){let n=Z(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],K,{onError:(s,m)=>Promise.resolve(e==null?void 0:e(s,m)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:c}=g();return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(c),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}}import{useQuery as ee}from"@tanstack/react-query";function It(e){let t=i(n=>n.clients),r=ee(["USE_CLIENTS",e,t],({queryKey:[,n,c]})=>n!=null&&n.rpc?h(n):c,{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=ee(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,c]})=>n!=null&&n.rpc?f(n):c,{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 _e,QueryClientProvider as He}from"@tanstack/react-query";import{useEffect as Fe}from"react";function Le(){return Fe(()=>{let{_reconnect:e}=i.getState();return e&&p(),window.addEventListener("keplr_keystorechange",p),()=>{window.removeEventListener("keplr_keystorechange",p)}},[]),null}function ne(){return Le(),null}import{jsx as Je,jsxs as Ve}from"react/jsx-runtime";var Qe=new _e({});function Mt({children:e,grazOptions:t,...o}){return t&&B(t),Ve(He,{client:Qe,...o,children:[Je(ne,{}),e]})}export{ne as GrazEvents,Mt as GrazProvider,M as checkWallet,P as clearRecentChain,B as configureGraz,l as connect,h as createClients,f as createSigningClients,Fn as defineChain,Ln as defineChainInfo,Rn as defineChains,U as disconnect,q as getBalances,pe as getKeplr,hn as getRecentChain,u as getWallet,_n as mainnetChains,Hn as mainnetChainsArray,p as reconnect,S as suggestChain,K as suggestChainAndConnect,Qn as testnetChains,Jn as testnetChainsArray,Re as useAccount,yt as useActiveChain,ct as useBalances,Zn as useCheckKeplr,g as useCheckWallet,It as useClients,at as useConnect,mt as useDisconnect,Le as useGrazEvents,Ct as useRecentChain,pt as useSigners,Dt as useSigningClients,dt as useSuggestChain,wt as useSuggestChainAndConnect};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "graz",
3
3
  "description": "React hooks for Cosmos",
4
- "version": "0.0.16",
4
+ "version": "0.0.21",
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",
@@ -28,26 +28,22 @@
28
28
  "files": [
29
29
  "chains/*.stub",
30
30
  "cli.js",
31
+ "compiled/**",
32
+ "dist/*.d.ts",
31
33
  "dist/*.js",
32
- "dist/*.mjs",
33
- "dist/*.d.ts"
34
+ "dist/*.mjs"
34
35
  ],
35
36
  "sideEffects": false,
36
- "scripts": {
37
- "build": "tsup",
38
- "cli": "node dist/cli.js",
39
- "dev": "tsup --watch"
40
- },
41
37
  "dependencies": {
42
- "@cosmjs/cosmwasm-stargate": "^0.28.11",
43
- "@cosmjs/proto-signing": "^0.28.11",
44
- "@cosmjs/stargate": "^0.28.11",
45
- "@keplr-wallet/cosmos": "^0.10.13",
46
- "@keplr-wallet/types": "^0.10.13",
47
- "@tanstack/react-query": "^4.0.10",
38
+ "@cosmjs/cosmwasm-stargate": "^0",
39
+ "@cosmjs/proto-signing": "^0",
40
+ "@cosmjs/stargate": "^0",
41
+ "@keplr-wallet/cosmos": "^0",
42
+ "@keplr-wallet/types": "^0",
43
+ "@tanstack/react-query": "^4",
48
44
  "arg": "^5",
49
45
  "cosmos-directory-client": "0.0.6",
50
- "zustand": "^4.0.0"
46
+ "zustand": "^4"
51
47
  },
52
48
  "devDependencies": {
53
49
  "@types/node": "^16",
@@ -71,5 +67,10 @@
71
67
  "eslint --fix"
72
68
  ]
73
69
  },
74
- "license": "MIT"
75
- }
70
+ "license": "MIT",
71
+ "scripts": {
72
+ "build": "tsup",
73
+ "cli": "node cli.mjs",
74
+ "dev": "tsup --watch"
75
+ }
76
+ }
package/dist/.gitkeep DELETED
File without changes