graz 0.0.37 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cli.mjs +20 -26
- package/compiled/p-map/index.d.ts +121 -0
- package/compiled/p-map/index.mjs +1 -1
- package/dist/chunk-V3YUCPIG.mjs +1 -0
- package/dist/constant.mjs +1 -1
- package/dist/cosmjs.js +1 -1
- package/dist/index.d.ts +15 -15
- package/dist/index.js +1 -1
- package/dist/index.mjs +1 -1
- package/dist/keplr.js +1 -1
- package/dist/tendermint.js +1 -1
- package/package.json +15 -33
- package/dist/chunk-ETISV7IF.mjs +0 -1
package/cli.mjs
CHANGED
|
@@ -1,24 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
// @ts-check
|
|
3
|
+
import * as fs from "node:fs/promises";
|
|
4
|
+
import * as path from "node:path";
|
|
5
|
+
import { fileURLToPath } from "node:url";
|
|
6
|
+
|
|
3
7
|
import { Bech32Address } from "@keplr-wallet/cosmos";
|
|
4
8
|
import arg from "arg";
|
|
5
9
|
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
|
|
|
10
11
|
import pmap from "./compiled/p-map/index.mjs";
|
|
11
12
|
|
|
12
|
-
|
|
13
|
-
return /^\d+$/.test(char);
|
|
14
|
-
}
|
|
13
|
+
const isNumber = (char) => /^\d+$/.test(char);
|
|
15
14
|
|
|
16
|
-
|
|
15
|
+
const chainNaming = (name) => {
|
|
17
16
|
if (isNumber(name[0])) {
|
|
18
17
|
return `_${name}`;
|
|
19
18
|
}
|
|
20
19
|
return name;
|
|
21
|
-
}
|
|
20
|
+
};
|
|
22
21
|
|
|
23
22
|
const HELP_MESSAGE = `Usage: graz [options]
|
|
24
23
|
|
|
@@ -52,7 +51,7 @@ const args = arg({
|
|
|
52
51
|
"-h": "--help",
|
|
53
52
|
});
|
|
54
53
|
|
|
55
|
-
async
|
|
54
|
+
const cli = async () => {
|
|
56
55
|
if (args["--help"]) {
|
|
57
56
|
console.log(HELP_MESSAGE);
|
|
58
57
|
return;
|
|
@@ -64,9 +63,9 @@ async function cli() {
|
|
|
64
63
|
}
|
|
65
64
|
|
|
66
65
|
console.log(HELP_MESSAGE);
|
|
67
|
-
}
|
|
66
|
+
};
|
|
68
67
|
|
|
69
|
-
async
|
|
68
|
+
const generate = async () => {
|
|
70
69
|
console.log(`⏳\tGenerating chain list from cosmos.directory...`);
|
|
71
70
|
if (args["--authz"]) {
|
|
72
71
|
console.log(`✍️\tDetected authz flag, generating only compatible chains...`);
|
|
@@ -117,52 +116,47 @@ async function generate() {
|
|
|
117
116
|
]);
|
|
118
117
|
|
|
119
118
|
console.log('✨\tGenerate complete! You can import `mainnetChains` and `testnetChains` from "graz/chains".\n');
|
|
120
|
-
}
|
|
119
|
+
};
|
|
121
120
|
|
|
122
121
|
/** @param {string[]} args */
|
|
123
|
-
|
|
124
|
-
return path.resolve(path.dirname(fileURLToPath(import.meta.url)), "chains", ...args);
|
|
125
|
-
}
|
|
122
|
+
const chainsDir = (...args) => path.resolve(path.dirname(fileURLToPath(import.meta.url)), "chains", ...args);
|
|
126
123
|
|
|
127
124
|
/**
|
|
128
125
|
* @param {Record<string, import(".").ChainInfoWithPath>} record
|
|
129
126
|
* @param {Record<string, boolean>} opts
|
|
130
127
|
*/
|
|
131
|
-
|
|
132
|
-
|
|
128
|
+
const makeChainMap = (record, { testnet = false } = {}) =>
|
|
129
|
+
Object.keys(record)
|
|
133
130
|
.map((k) => ` ${chainNaming(k)}: ${chainNaming(k)},`)
|
|
134
131
|
.join("\n");
|
|
135
|
-
}
|
|
136
132
|
|
|
137
133
|
/**
|
|
138
134
|
* @param {Record<string, import(".").ChainInfoWithPath>} record
|
|
139
135
|
* @param {Record<string, boolean>} opts
|
|
140
136
|
*/
|
|
141
|
-
|
|
142
|
-
|
|
137
|
+
const makeDefs = (record, { mjs = false, testnet = false } = {}) =>
|
|
138
|
+
Object.entries(record)
|
|
143
139
|
.map(([k, v]) => {
|
|
144
140
|
const jsVariable = `${chainNaming(k)}`;
|
|
145
141
|
const jsChainInfo = JSON.stringify(v, null, 2);
|
|
146
142
|
return `${mjs ? "export " : ""}const ${jsVariable} = defineChainInfo(${jsChainInfo});\n`;
|
|
147
143
|
})
|
|
148
144
|
.join("");
|
|
149
|
-
}
|
|
150
145
|
|
|
151
146
|
/**
|
|
152
147
|
* @param {Record<string, import(".").ChainInfoWithPath>} record
|
|
153
148
|
* @param {Record<string, boolean>} opts
|
|
154
149
|
*/
|
|
155
|
-
|
|
156
|
-
|
|
150
|
+
const makeExports = (record, { testnet = false } = {}) =>
|
|
151
|
+
Object.keys(record)
|
|
157
152
|
.map((k) => ` ${chainNaming(k)},`)
|
|
158
153
|
.join("\n");
|
|
159
|
-
}
|
|
160
154
|
|
|
161
155
|
/**
|
|
162
156
|
* @param {import("cosmos-directory-client").DirectoryClient} client
|
|
163
157
|
* @param {{ filter?: string }} opts
|
|
164
158
|
*/
|
|
165
|
-
async
|
|
159
|
+
const makeRecord = async (client, { filter = "" } = {}) => {
|
|
166
160
|
const paths = filter
|
|
167
161
|
? filter.split(",").map((path) => ({ path }))
|
|
168
162
|
: await client.fetchChains().then((c) => c.chains.map(({ path }) => ({ path })));
|
|
@@ -220,6 +214,6 @@ async function makeRecord(client, { filter = "" } = {}) {
|
|
|
220
214
|
}
|
|
221
215
|
});
|
|
222
216
|
return record;
|
|
223
|
-
}
|
|
217
|
+
};
|
|
224
218
|
|
|
225
219
|
void cli();
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
export type 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 [`AggregateError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError) 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
|
+
@example
|
|
26
|
+
```
|
|
27
|
+
import pMap from 'p-map';
|
|
28
|
+
import delay from 'delay';
|
|
29
|
+
|
|
30
|
+
const abortController = new AbortController();
|
|
31
|
+
|
|
32
|
+
setTimeout(() => {
|
|
33
|
+
abortController.abort();
|
|
34
|
+
}, 500);
|
|
35
|
+
|
|
36
|
+
const mapper = async value => value;
|
|
37
|
+
|
|
38
|
+
await pMap([delay(1000), delay(1000)], mapper, {signal: abortController.signal});
|
|
39
|
+
// Throws AbortError (DOMException) after 500 ms.
|
|
40
|
+
```
|
|
41
|
+
*/
|
|
42
|
+
readonly signal?: AbortSignal;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
Function which is called for every item in `input`. Expected to return a `Promise` or value.
|
|
49
|
+
|
|
50
|
+
@param element - Iterated element.
|
|
51
|
+
@param index - Index of the element in the source array.
|
|
52
|
+
*/
|
|
53
|
+
export type Mapper<Element = any, NewElement = unknown> = (
|
|
54
|
+
element: Element,
|
|
55
|
+
index: number
|
|
56
|
+
) => MaybePromise<NewElement | typeof pMapSkip>;
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
@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.
|
|
60
|
+
@param mapper - Function which is called for every item in `input`. Expected to return a `Promise` or value.
|
|
61
|
+
@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.
|
|
62
|
+
|
|
63
|
+
@example
|
|
64
|
+
```
|
|
65
|
+
import pMap from 'p-map';
|
|
66
|
+
import got from 'got';
|
|
67
|
+
|
|
68
|
+
const sites = [
|
|
69
|
+
getWebsiteFromUsername('sindresorhus'), //=> Promise
|
|
70
|
+
'https://avajs.dev',
|
|
71
|
+
'https://github.com'
|
|
72
|
+
];
|
|
73
|
+
|
|
74
|
+
const mapper = async site => {
|
|
75
|
+
const {requestUrl} = await got.head(site);
|
|
76
|
+
return requestUrl;
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
const result = await pMap(sites, mapper, {concurrency: 2});
|
|
80
|
+
|
|
81
|
+
console.log(result);
|
|
82
|
+
//=> ['https://sindresorhus.com/', 'https://avajs.dev/', 'https://github.com/']
|
|
83
|
+
```
|
|
84
|
+
*/
|
|
85
|
+
export default function pMap<Element, NewElement>(
|
|
86
|
+
input: AsyncIterable<Element | Promise<Element>> | Iterable<Element | Promise<Element>>,
|
|
87
|
+
mapper: Mapper<Element, NewElement>,
|
|
88
|
+
options?: Options
|
|
89
|
+
): Promise<Array<Exclude<NewElement, typeof pMapSkip>>>;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
Return this value from a `mapper` function to skip including the value in the returned array.
|
|
93
|
+
|
|
94
|
+
@example
|
|
95
|
+
```
|
|
96
|
+
import pMap, {pMapSkip} from 'p-map';
|
|
97
|
+
import got from 'got';
|
|
98
|
+
|
|
99
|
+
const sites = [
|
|
100
|
+
getWebsiteFromUsername('sindresorhus'), //=> Promise
|
|
101
|
+
'https://avajs.dev',
|
|
102
|
+
'https://example.invalid',
|
|
103
|
+
'https://github.com'
|
|
104
|
+
];
|
|
105
|
+
|
|
106
|
+
const mapper = async site => {
|
|
107
|
+
try {
|
|
108
|
+
const {requestUrl} = await got.head(site);
|
|
109
|
+
return requestUrl;
|
|
110
|
+
} catch {
|
|
111
|
+
return pMapSkip;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
|
|
115
|
+
const result = await pMap(sites, mapper, {concurrency: 2});
|
|
116
|
+
|
|
117
|
+
console.log(result);
|
|
118
|
+
//=> ['https://sindresorhus.com/', 'https://avajs.dev/', 'https://github.com/']
|
|
119
|
+
```
|
|
120
|
+
*/
|
|
121
|
+
export const pMapSkip: unique symbol;
|
package/compiled/p-map/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
var e={};(()=>{e.d=(r,t)=>{for(var n in t){if(e.o(t,n)&&!e.o(r,n)){Object.defineProperty(r,n,{enumerable:true,get:t[n]})}}}})();(()=>{e.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r)})();if(typeof e!=="undefined")e.ab=new URL(".",import.meta.url).pathname.slice(import.meta.url.match(/^file:\/\/\/\w:/)?1:0,-1)+"/";var r={};e.d(r,{Ud:()=>t,ZP:()=>pMap,_L:()=>AbortError});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:n=Number.POSITIVE_INFINITY,stopOnError:o=true,signal:a}={}){return new Promise(((i,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(n)||n===Number.POSITIVE_INFINITY)&&n>=1)){throw new TypeError(`Expected \`concurrency\` to be an integer from 1 and up or \`Infinity\`, got \`${n}\` (${typeof n})`)}const c=[];const f=[];const u=new Map;let p=false;let l=false;let y=false;let b=0;let d=0;const w=e[Symbol.iterator]===undefined?e[Symbol.asyncIterator]():e[Symbol.iterator]();const reject=e=>{p=true;l=true;s(e)};if(a){if(a.aborted){reject(getAbortedReason(a))}a.addEventListener("abort",(()=>{reject(getAbortedReason(a))}))}const next=async()=>{if(l){return}const e=await w.next();const n=d;d++;if(e.done){y=true;if(b===0&&!l){if(!o&&f.length>0){reject(new AggregateError(f));return}l=true;if(u.size===0){i(c);return}const e=[];for(const[r,n]of c.entries()){if(u.get(r)===t){continue}e.push(n)}i(e)}return}b++;(async()=>{try{const o=await e.value;if(l){return}const a=await r(o,n);if(a===t){u.set(n,a)}c[n]=a;b--;await next()}catch(e){if(o){reject(e)}else{f.push(e);b--;try{await next()}catch(e){reject(e)}}}})()};(async()=>{for(let e=0;e<n;e++){try{await next()}catch(e){reject(e);break}if(y||p){break}}})()}))}const t=Symbol("skip");var n=r._L;var o=r.ZP;var a=r.Ud;export{n as AbortError,o as default,a as pMapSkip};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e="graz-reconnect-session";export{e as a};
|
package/dist/constant.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a}from"./chunk-
|
|
1
|
+
import{a}from"./chunk-V3YUCPIG.mjs";export{a as RECONNECT_SESSION_KEY};
|
package/dist/cosmjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,e,p,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of c(e))!d.call(f,m)&&m!==p&&a(f,m,{get:()=>e[m],enumerable:!(x=b(e,m))||x.enumerable});return f},r=(f,e,p)=>(t(f,e,"default"),p&&t(p,e,"default"));var g=f=>t(a({},"__esModule",{value:!0}),f);var o={};module.exports=g(o);r(o,require("@cosmjs/cosmwasm-stargate"),module.exports);r(o,require("@cosmjs/proto-signing"),module.exports);r(o,require("@cosmjs/stargate"),module.exports);
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,e,p,x)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of c(e))!d.call(f,m)&&m!==p&&a(f,m,{get:()=>e[m],enumerable:!(x=b(e,m))||x.enumerable});return f},r=(f,e,p)=>(t(f,e,"default"),p&&t(p,e,"default"));var g=f=>t(a({},"__esModule",{value:!0}),f);var o={};module.exports=g(o);r(o,require("@cosmjs/cosmwasm-stargate"),module.exports);r(o,require("@cosmjs/proto-signing"),module.exports);r(o,require("@cosmjs/stargate"),module.exports);0&&(module.exports={...require("@cosmjs/cosmwasm-stargate"),...require("@cosmjs/proto-signing"),...require("@cosmjs/stargate")});
|
package/dist/index.d.ts
CHANGED
|
@@ -13,8 +13,8 @@ import { BondStatusString } from '@cosmjs/stargate/build/modules/staking/queries
|
|
|
13
13
|
import { QueryValidatorsResponse } from 'cosmjs-types/cosmos/staking/v1beta1/query';
|
|
14
14
|
import { FC } from 'react';
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
type Dictionary<T = string> = Record<string, T>;
|
|
17
|
+
type Maybe<T> = T | undefined;
|
|
18
18
|
|
|
19
19
|
interface ChainInfoWithPath extends ChainInfo {
|
|
20
20
|
path: string;
|
|
@@ -162,7 +162,7 @@ declare enum WalletType {
|
|
|
162
162
|
}
|
|
163
163
|
declare const WALLET_TYPES: WalletType[];
|
|
164
164
|
|
|
165
|
-
|
|
165
|
+
type ConnectArgs = Maybe<{
|
|
166
166
|
chain?: GrazChain;
|
|
167
167
|
signerOpts?: SigningCosmWasmClientOptions;
|
|
168
168
|
walletType?: WalletType;
|
|
@@ -170,12 +170,12 @@ declare type ConnectArgs = Maybe<{
|
|
|
170
170
|
}>;
|
|
171
171
|
declare const connect: (args?: ConnectArgs) => Promise<Key>;
|
|
172
172
|
declare const disconnect: (clearRecentChain?: boolean) => Promise<void>;
|
|
173
|
-
|
|
173
|
+
type ReconnectArgs = Maybe<{
|
|
174
174
|
onError?: (error: unknown) => void;
|
|
175
175
|
}>;
|
|
176
176
|
declare const reconnect: (args?: ReconnectArgs) => Promise<Key | undefined>;
|
|
177
177
|
|
|
178
|
-
|
|
178
|
+
type ExtensionSetup<P extends object = object> = (queryClient: QueryClient) => P;
|
|
179
179
|
|
|
180
180
|
interface CreateQueryClient {
|
|
181
181
|
(): QueryClient;
|
|
@@ -243,9 +243,9 @@ interface GrazStore {
|
|
|
243
243
|
_onReconnectFailed: () => void;
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
|
|
246
|
+
type CreateClientArgs = Pick<GrazChain, "rpc" | "rpcHeaders">;
|
|
247
247
|
declare const createClients: ({ rpc, rpcHeaders }: CreateClientArgs) => Promise<GrazStore["clients"]>;
|
|
248
|
-
|
|
248
|
+
type CreateSigningClientArgs = CreateClientArgs & {
|
|
249
249
|
offlineSignerAuto: OfflineSigner | OfflineDirectSigner;
|
|
250
250
|
cosmWasmSignerOptions?: SigningCosmWasmClientOptions;
|
|
251
251
|
stargateSignerOptions?: SigningStargateClientOptions;
|
|
@@ -295,7 +295,7 @@ interface InstantiateContractArgs<Message extends Record<string, unknown>> {
|
|
|
295
295
|
senderAddress: string;
|
|
296
296
|
codeId: number;
|
|
297
297
|
}
|
|
298
|
-
|
|
298
|
+
type InstantiateContractMutationArgs<Message extends Record<string, unknown>> = Omit<InstantiateContractArgs<Message>, "codeId" | "senderAddress" | "fee"> & {
|
|
299
299
|
fee?: StdFee | "auto" | number;
|
|
300
300
|
};
|
|
301
301
|
declare const instantiateContract: <Message extends Record<string, unknown>>({ senderAddress, msg, fee, options, label, codeId, }: InstantiateContractArgs<Message>) => Promise<_cosmjs_cosmwasm_stargate.InstantiateResult>;
|
|
@@ -307,7 +307,7 @@ interface ExecuteContractArgs<Message extends Record<string, unknown>> {
|
|
|
307
307
|
funds: Coin[];
|
|
308
308
|
memo: string;
|
|
309
309
|
}
|
|
310
|
-
|
|
310
|
+
type ExecuteContractMutationArgs<Message extends Record<string, unknown>> = Omit<ExecuteContractArgs<Message>, "contractAddress" | "senderAddress" | "fee" | "funds" | "memo"> & {
|
|
311
311
|
fee?: StdFee | "auto" | number;
|
|
312
312
|
funds?: Coin[];
|
|
313
313
|
memo?: string;
|
|
@@ -466,7 +466,7 @@ declare const useBalances: (bech32Address?: string) => UseQueryResult<Coin[]>;
|
|
|
466
466
|
* ```
|
|
467
467
|
*/
|
|
468
468
|
declare const useBalance: (denom: string, bech32Address?: string) => UseQueryResult<Coin | undefined>;
|
|
469
|
-
|
|
469
|
+
type UseConnectChainArgs = MutationEventArgs<ConnectArgs, Key>;
|
|
470
470
|
/**
|
|
471
471
|
* graz mutation hook to execute wallet connection with optional arguments to
|
|
472
472
|
* invoke given functions on error, loading, or success event.
|
|
@@ -645,7 +645,7 @@ declare const useRecentChain: () => {
|
|
|
645
645
|
data: GrazChain | null;
|
|
646
646
|
clear: () => void;
|
|
647
647
|
};
|
|
648
|
-
|
|
648
|
+
type UseSuggestChainArgs = MutationEventArgs<ChainInfo>;
|
|
649
649
|
/**
|
|
650
650
|
* graz mutation hook to suggest chain to a Wallet
|
|
651
651
|
*
|
|
@@ -670,7 +670,7 @@ declare const useSuggestChain: ({ onError, onLoading, onSuccess }?: UseSuggestCh
|
|
|
670
670
|
suggestAsync: _tanstack_react_query.UseMutateAsyncFunction<ChainInfo, unknown, ChainInfo, unknown>;
|
|
671
671
|
status: "error" | "idle" | "loading" | "success";
|
|
672
672
|
};
|
|
673
|
-
|
|
673
|
+
type UseSuggestChainAndConnectArgs = MutationEventArgs<SuggestChainAndConnectArgs, {
|
|
674
674
|
chain: ChainInfo;
|
|
675
675
|
account: Key;
|
|
676
676
|
}>;
|
|
@@ -844,7 +844,7 @@ declare const useSendIbcTokens: ({ onError, onLoading, onSuccess, }?: MutationEv
|
|
|
844
844
|
sendIbcTokensAsync: _tanstack_react_query.UseMutateAsyncFunction<DeliverTxResponse, unknown, SendIbcTokensArgs, unknown>;
|
|
845
845
|
status: "error" | "idle" | "loading" | "success";
|
|
846
846
|
};
|
|
847
|
-
|
|
847
|
+
type UseInstantiateContractArgs<Message extends Record<string, unknown>> = {
|
|
848
848
|
codeId: number;
|
|
849
849
|
} & MutationEventArgs<InstantiateContractMutationArgs<Message>, InstantiateResult>;
|
|
850
850
|
/**
|
|
@@ -874,7 +874,7 @@ declare const useInstantiateContract: <Message extends Record<string, unknown>>(
|
|
|
874
874
|
instantiateContractAsync: _tanstack_react_query.UseMutateAsyncFunction<InstantiateResult, unknown, InstantiateContractMutationArgs<Message>, unknown>;
|
|
875
875
|
status: "error" | "idle" | "loading" | "success";
|
|
876
876
|
};
|
|
877
|
-
|
|
877
|
+
type UseExecuteContractArgs<Message extends Record<string, unknown>> = {
|
|
878
878
|
contractAddress: string;
|
|
879
879
|
} & MutationEventArgs<ExecuteContractMutationArgs<Message>, ExecuteResult>;
|
|
880
880
|
/**
|
|
@@ -954,7 +954,7 @@ declare const useCheckKeplr: () => UseQueryResult<boolean>;
|
|
|
954
954
|
*/
|
|
955
955
|
declare const useCheckWallet: (type?: WalletType) => UseQueryResult<boolean>;
|
|
956
956
|
|
|
957
|
-
|
|
957
|
+
type GrazProviderProps = Partial<QueryClientProviderProps> & {
|
|
958
958
|
grazOptions?: ConfigureGrazArgs;
|
|
959
959
|
};
|
|
960
960
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Je=Object.create;var k=Object.defineProperty;var $e=Object.getOwnPropertyDescriptor;var Xe=Object.getOwnPropertyNames;var Ze=Object.getPrototypeOf,et=Object.prototype.hasOwnProperty;var tt=(e,t)=>{for(var n in t)k(e,n,{get:t[n],enumerable:!0})},le=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Xe(t))!et.call(e,o)&&o!==n&&k(e,o,{get:()=>t[o],enumerable:!(r=$e(t,o))||r.enumerable});return e};var de=(e,t,n)=>(n=e!=null?Je(Ze(e)):{},le(t||!e||!e.__esModule?k(n,"default",{value:e,enumerable:!0}):n,e)),nt=e=>le(k({},"__esModule",{value:!0}),e);var Zt={};tt(Zt,{GrazEvents:()=>ue,GrazProvider:()=>Xt,WALLET_TYPES:()=>G,WalletType:()=>v,checkWallet:()=>x,clearRecentChain:()=>z,configureGraz:()=>W,connect:()=>A,createClients:()=>b,createQueryClient:()=>q,createSigningClients:()=>j,defineChain:()=>bt,defineChainInfo:()=>jt,defineChains:()=>ie,disconnect:()=>T,executeContract:()=>L,getActiveChainCurrency:()=>K,getAvailableWallets:()=>st,getBalanceStaked:()=>_,getBalances:()=>F,getKeplr:()=>fe,getLeap:()=>xe,getQueryRaw:()=>Y,getQuerySmart:()=>V,getRecentChain:()=>rt,getWallet:()=>h,instantiateContract:()=>H,mainnetChains:()=>Dt,mainnetChainsArray:()=>kt,reconnect:()=>d,sendIbcTokens:()=>N,sendTokens:()=>P,suggestChain:()=>B,suggestChainAndConnect:()=>O,testnetChains:()=>It,testnetChainsArray:()=>Tt,useAccount:()=>g,useActiveChain:()=>Mt,useActiveChainCurrency:()=>Qt,useActiveChainValidators:()=>zt,useBalance:()=>Rt,useBalanceStaked:()=>qt,useBalances:()=>_e,useCheckKeplr:()=>Bt,useCheckWallet:()=>S,useClients:()=>_t,useConnect:()=>vt,useDisconnect:()=>Gt,useExecuteContract:()=>Vt,useGrazEvents:()=>He,useInstantiateContract:()=>Lt,useOfflineSigners:()=>Pe,useQueryClient:()=>Ft,useQueryRaw:()=>Jt,useQuerySmart:()=>Yt,useRecentChain:()=>Kt,useSendIbcTokens:()=>Ht,useSendTokens:()=>Nt,useSigners:()=>Ut,useSigningClients:()=>Pt,useSuggestChain:()=>Ot,useSuggestChainAndConnect:()=>Wt});module.exports=nt(Zt);var he=require("@cosmjs/stargate");var w="graz-reconnect-session";var ge=de(require("zustand")),I=require("zustand/middleware");var v=(n=>(n.KEPLR="keplr",n.LEAP="leap",n))(v||{}),G=["keplr","leap"];var U={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,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},ot={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector}),version:2},c=(0,ge.default)((0,I.subscribeWithSelector)((0,I.persist)(()=>U,ot)));var M=require("@cosmjs/cosmwasm-stargate"),Q=require("@cosmjs/stargate"),Ce=require("@cosmjs/tendermint-rpc");var ye=require("@cosmjs/stargate"),f=require("@cosmjs/utils");var q=(...e)=>{let{tendermint:t}=c.getState().clients,n=new ye.QueryClient(t),r=e.map(o=>o(n));for(let o of r){(0,f.assert)((0,f.isNonNullObject)(o),"Extension must be a non-null object");for(let[i,s]of Object.entries(o)){(0,f.assert)((0,f.isNonNullObject)(s),`Module must be a non-null object. Found type ${typeof s} for module "${i}".`);let u=n[i]||{};n[i]={...u,...s}}}return n};var b=async({rpc:e,rpcHeaders:t})=>{let n={url:e,headers:{...t||{}}},[r,o,i]=await Promise.all([M.SigningCosmWasmClient.connect(n),Q.SigningStargateClient.connect(n),Ce.Tendermint34Client.connect(e)]);return{cosmWasm:r,stargate:o,tendermint:i}},j=async e=>{let{rpc:t,rpcHeaders:n,offlineSignerAuto:r,cosmWasmSignerOptions:o={},stargateSignerOptions:i={}}=e,s={url:t,headers:{...n||{}}},[u,p]=await Promise.all([M.SigningCosmWasmClient.connectWithSigner(s,r,o),Q.SigningStargateClient.connectWithSigner(s,r,i)]);return{cosmWasm:u,stargate:p}};var x=(e=c.getState().walletType)=>{try{return h(e),!0}catch(t){return console.error(t),!1}},fe=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},xe=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},h=(e=c.getState().walletType)=>{switch(e){case"keplr":return fe();case"leap":return xe();default:throw new Error("Unknown wallet type")}},st=()=>Object.fromEntries(G.map(e=>[e,x(e)]));var A=async e=>{try{let{defaultChain:t,recentChain:n,walletType:r}=c.getState(),o=(e==null?void 0:e.walletType)||r,i=h(o),s=(e==null?void 0:e.chain)||n||t;if(!s)throw new Error("No last known connected chain, connect action requires chain info");c.setState(D=>{let Ye=D._reconnect||Boolean(D._reconnectConnector)||Boolean(s);return D.activeChain&&D.activeChain.chainId!==s.chainId?{status:"connecting"}:Ye?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(s.chainId);let u=i.getOfflineSigner(s.chainId),p=i.getOfflineSignerOnlyAmino(s.chainId),m=await i.getOfflineSignerAuto(s.chainId),l=s.gas?he.GasPrice.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[me,Le,Ve]=await Promise.all([i.getKey(s.chainId),b(s),j({...s,offlineSignerAuto:m,cosmWasmSignerOptions:{gasPrice:l,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:me,activeChain:s,clients:Le,offlineSigner:u,offlineSignerAmino:p,offlineSignerAuto:m,recentChain:s,signingClients:Ve,status:"connected",walletType:o,_reconnect:Boolean(e==null?void 0:e.autoReconnect),_reconnectConnector:o}),typeof window<"u"&&window.sessionStorage.setItem(w,"Active"),me}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},T=async(e=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(w),c.setState(t=>({...U,recentChain:e?null:t.recentChain})),Promise.resolve()),d=async e=>{var i;let{recentChain:t,_reconnectConnector:n,_reconnect:r}=c.getState(),o=x(n||void 0);try{if(t&&o&&n)return await A({chain:t,walletType:n,autoReconnect:r})}catch(s){(i=e==null?void 0:e.onError)==null||i.call(e,s),T()}};var z=()=>{c.setState({recentChain:null})},K=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(n=>n.coinMinimalDenom===e)},rt=()=>c.getState().recentChain,B=async e=>(await h().experimentalSuggestChain(e),e),O=async({chainInfo:e,rpcHeaders:t,gas:n,path:r,...o})=>{let i=await B(e);return{account:await A({chain:{chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,rpcHeaders:t,gas:n,path:r},...o}),chain:i}};var W=(e={})=>(c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||t.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var F=async e=>{let{activeChain:t,signingClients:n}=c.getState();if(!t||!n)throw new Error("No connected account detected");let{defaultSigningClient:r}=c.getState();return await Promise.all(t.currencies.map(async i=>{let s=i.coinMinimalDenom.startsWith("cw20:");return n[r].getBalance(e,s?i.coinMinimalDenom.replace("cw20:",""):i.coinMinimalDenom)}))},_=async e=>{let{clients:t}=c.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)},P=async({senderAddress:e,recipientAddress:t,amount:n,fee:r,memo:o})=>{let{signingClients:i,defaultSigningClient:s}=c.getState();if(!i)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return i[s].sendTokens(e,t,n,r,o)},N=async({senderAddress:e,recipientAddress:t,transferAmount:n,sourcePort:r,sourceChannel:o,timeoutHeight:i,timeoutTimestamp:s,fee:u,memo:p})=>{let{signingClients:m}=c.getState();if(!(m!=null&&m.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return m.stargate.sendIbcTokens(e,t,n,r,o,i,s,u,p)},H=async({senderAddress:e,msg:t,fee:n,options:r,label:o,codeId:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.instantiate(e,i,t,o,n,r)},L=async({senderAddress:e,msg:t,fee:n,contractAddress:r,funds:o,memo:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.execute(e,r,t,n,i,o)},V=async(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");return await n.cosmWasm.queryContractSmart(e,t)},Y=(e,t)=>{let{clients:n}=c.getState();if(!(n!=null&&n.cosmWasm))throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(t);return n.cosmWasm.queryContractRaw(e,r)};var Se=require("@keplr-wallet/cosmos"),Ee={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},it={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},ct={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},at={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},ut={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},pt={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},Ae=[Ee,it,ct,at,ut,pt],J={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:Ee,bip44:{coinType:118},bech32Config:Se.Bech32Address.defaultBech32Config("axelar"),currencies:Ae,feeCurrencies:Ae};var be=require("@keplr-wallet/cosmos"),je={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},we=[je],$={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:je,bip44:{coinType:118},bech32Config:be.Bech32Address.defaultBech32Config("cosmos"),currencies:we,feeCurrencies:we};var ke=require("@keplr-wallet/cosmos"),Ie={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},mt={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},lt={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},dt={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},gt={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},yt={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Ct={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},ft={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},xt={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},ht={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},At={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},De=[Ie,mt,lt,dt,gt,yt,Ct,ft,xt,ht,At],X={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:Ie,bip44:{coinType:118},bech32Config:ke.Bech32Address.defaultBech32Config("juno"),currencies:De,feeCurrencies:De};var Be=require("@keplr-wallet/cosmos"),Re={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},St={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},Te=[Re,St],Z={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Re,bip44:{coinType:118},bech32Config:Be.Bech32Address.defaultBech32Config("osmo"),currencies:Te,feeCurrencies:Te};var Ge=require("@keplr-wallet/cosmos"),Ue={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},ve=[Ue],ee={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:Ue,bip44:{coinType:118},bech32Config:Ge.Bech32Address.defaultBech32Config("somm"),currencies:ve,feeCurrencies:ve};var Me=require("@keplr-wallet/cosmos"),Qe={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},qe=[Qe],te={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:Me.Bech32Address.defaultBech32Config("CRE"),currencies:qe,feeCurrencies:qe,stakeCurrency:Qe,coinType:118};var ze=require("@keplr-wallet/cosmos"),ne={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Et=[ne],oe={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:ne,bip44:{coinType:118},bech32Config:ze.Bech32Address.defaultBech32Config("juno"),currencies:Et,feeCurrencies:[ne],coinType:118};var Ke=require("@keplr-wallet/cosmos"),se={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},wt=[se],re={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:se,bip44:{coinType:118},bech32Config:Ke.Bech32Address.defaultBech32Config("osmo"),currencies:wt,feeCurrencies:[se],coinType:118};var ie=e=>e,bt=e=>e,jt=e=>e,Dt=ie({axelar:J,cosmoshub:$,juno:X,osmosis:Z,sommelier:ee}),kt=[J,$,X,Z,ee],It=ie({crescent:te,juno:oe,osmosis:re}),Tt=[te,oe,re];var C=require("@tanstack/react-query"),We=require("react"),Fe=de(require("zustand/shallow"));var Oe=require("@tanstack/react-query");var Bt=()=>S("keplr"),S=e=>{let t=c(o=>e||o.walletType);return(0,Oe.useQuery)(["USE_CHECK_WALLET",t],({queryKey:[,o]})=>x(o))};var g=({onConnect:e,onDisconnect:t}={})=>{let n=c(o=>o.account),r=c(o=>o.status);return(0,We.useEffect)(()=>c.subscribe(o=>o.status,(o,i)=>{if(o==="connected"){let s=c.getState();e==null||e({account:s.account,isReconnect:i==="reconnecting"})}o==="disconnected"&&(t==null||t())}),[e,t]),{data:n,isConnected:Boolean(n),isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",isLoading:r==="connecting"||r==="reconnecting",reconnect:d,status:r}},_e=e=>{let{data:t}=g(),n=e||(t==null?void 0:t.bech32Address);return(0,C.useQuery)(["USE_BALANCES",n],({queryKey:[,i]})=>F(i),{enabled:Boolean(n)})},Rt=(e,t)=>{let{data:n}=_e(t);return(0,C.useQuery)(["USE_BALANCE",n,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===e),{enabled:Boolean(n)})},vt=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=(0,C.useMutation)(["USE_CONNECT",e,t,n],A,{onError:(s,u)=>Promise.resolve(e==null?void 0:e(s,u)),onMutate:t,onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=S();return{connect:s=>o.mutate(s),connectAsync:s=>o.mutateAsync(s),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:Boolean(i),status:o.status}},Gt=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=(0,C.useMutation)(["USE_DISCONNECT",e,t,n],T,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(n==null?void 0:n(void 0))});return{disconnect:i=>o.mutate(i),disconnectAsync:i=>o.mutateAsync(i),error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,status:o.status}},Pe=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Fe.default),Ut=()=>Pe(),qt=e=>{let{data:t}=g(),n=e||(t==null?void 0:t.bech32Address);return(0,C.useQuery)(["USE_BALANCE_STAKED",n],({queryKey:[,i]})=>_(n),{enabled:Boolean(n)})};var E=require("@tanstack/react-query");var Mt=()=>c(e=>e.activeChain),Qt=e=>(0,E.useQuery)(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>K(r)),zt=(e,t="BOND_STATUS_BONDED")=>(0,E.useQuery)(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,o,i]})=>o.staking.validators(i),{enabled:typeof e<"u"}),Kt=()=>({data:c(t=>t.recentChain),clear:z}),Ot=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=(0,E.useMutation)(["USE_SUGGEST_CHAIN",e,t,n],B,{onError:(i,s)=>Promise.resolve(e==null?void 0:e(i,s)),onMutate:t,onSuccess:i=>Promise.resolve(n==null?void 0:n(i))});return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,suggest:o.mutate,suggestAsync:o.mutateAsync,status:o.status}},Wt=({onError:e,onLoading:t,onSuccess:n}={})=>{let o=(0,E.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,n],O,{onError:(s,u)=>Promise.resolve(e==null?void 0:e(s,u)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(n==null?void 0:n(s))}),{data:i}=S();return{error:o.error,isLoading:o.isLoading,isSuccess:o.isSuccess,isSupported:Boolean(i),status:o.status,suggestAndConnect:o.mutate,suggestAndConnectAsync:o.mutateAsync}};var ce=require("@tanstack/react-query");var Ne=require("@tanstack/react-query");var Ft=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return(0,Ne.useQuery)(t,({queryKey:[,...r]})=>q(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var _t=e=>{let t=c(o=>o.clients);return(0,ce.useQuery)(["USE_CLIENTS",e,t],({queryKey:[,o,i]})=>o!=null&&o.rpc?b(o):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:o=>{c.setState({clients:o})}})},Pt=e=>{let t=c(o=>o.signingClients);return(0,ce.useQuery)(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,o,i]})=>o!=null&&o.rpc?j(o):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:o=>{c.setState({signingClients:o})}})};var y=require("@tanstack/react-query");var Nt=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:r}=g(),o=r==null?void 0:r.bech32Address,s=(0,y.useMutation)(["USE_SEND_TOKENS",e,t,n,o],u=>P({senderAddress:o,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(n==null?void 0:n(u))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}},Ht=({onError:e,onLoading:t,onSuccess:n}={})=>{let{data:r}=g(),o=r==null?void 0:r.bech32Address,s=(0,y.useMutation)(["USE_SEND_IBC_TOKENS",e,t,n,o],u=>N({senderAddress:o,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(n==null?void 0:n(u))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}},Lt=({codeId:e,onError:t,onLoading:n,onSuccess:r})=>{let{data:o}=g(),i=o==null?void 0:o.bech32Address,p=(0,y.useMutation)(["USE_INSTANTIATE_CONTRACT",t,n,r,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,codeId:e};return H(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:n,onSuccess:m=>Promise.resolve(r==null?void 0:r(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,instantiateContract:p.mutate,instantiateContractAsync:p.mutateAsync,status:p.status}},Vt=({contractAddress:e,onError:t,onLoading:n,onSuccess:r})=>{let{data:o}=g(),i=o==null?void 0:o.bech32Address,p=(0,y.useMutation)(["USE_EXECUTE_CONTRACT",t,n,r,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,contractAddress:e,memo:m.memo??"",funds:m.funds??[]};return L(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:n,onSuccess:m=>Promise.resolve(r==null?void 0:r(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,executeContract:p.mutate,executeContractAsync:p.mutateAsync,status:p.status}},Yt=(e,t)=>(0,y.useQuery)(["USE_QUERY_SMART",e,t],({queryKey:[,o]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return V(e,t)},{enabled:Boolean(e)&&Boolean(t)}),Jt=(e,t)=>(0,y.useQuery)(["USE_QUERY_RAW",t,e],({queryKey:[,o]})=>{if(!e||!t)throw new Error("address or key undefined");return Y(e,t)},{enabled:Boolean(e)&&Boolean(t)});var R=require("@tanstack/react-query");var ae=require("react");var He=()=>{let e=typeof window<"u"&&window.sessionStorage.getItem(w)==="Active",{activeChain:t,_reconnect:n,_onReconnectFailed:r}=c.getState();return(0,ae.useEffect)(()=>{e&&Boolean(t)?d({onError:r}):!e&&n&&d({onError:r})},[]),(0,ae.useEffect)(()=>(window.addEventListener("keplr_keystorechange",()=>void d({onError:r})),()=>{window.removeEventListener("keplr_keystorechange",()=>void d({onError:r}))}),[]),null},ue=()=>(He(),null);var pe=require("react/jsx-runtime"),$t=new R.QueryClient({}),Xt=({children:e,grazOptions:t,...n})=>(t&&W(t),(0,pe.jsxs)(R.QueryClientProvider,{client:$t,...n,children:[(0,pe.jsx)(ue,{}),e]}));0&&(module.exports={GrazEvents,GrazProvider,WALLET_TYPES,WalletType,checkWallet,clearRecentChain,configureGraz,connect,createClients,createQueryClient,createSigningClients,defineChain,defineChainInfo,defineChains,disconnect,executeContract,getActiveChainCurrency,getAvailableWallets,getBalanceStaked,getBalances,getKeplr,getLeap,getQueryRaw,getQuerySmart,getRecentChain,getWallet,instantiateContract,mainnetChains,mainnetChainsArray,reconnect,sendIbcTokens,sendTokens,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,useAccount,useActiveChain,useActiveChainCurrency,useActiveChainValidators,useBalance,useBalanceStaked,useBalances,useCheckKeplr,useCheckWallet,useClients,useConnect,useDisconnect,useExecuteContract,useGrazEvents,useInstantiateContract,useOfflineSigners,useQueryClient,useQueryRaw,useQuerySmart,useRecentChain,useSendIbcTokens,useSendTokens,useSigners,useSigningClients,useSuggestChain,useSuggestChainAndConnect});
|
|
1
|
+
"use strict";var Ve=Object.create;var D=Object.defineProperty;var Ye=Object.getOwnPropertyDescriptor;var Je=Object.getOwnPropertyNames;var $e=Object.getPrototypeOf,Xe=Object.prototype.hasOwnProperty;var Ze=(e,t)=>{for(var o in t)D(e,o,{get:t[o],enumerable:!0})},me=(e,t,o,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let n of Je(t))!Xe.call(e,n)&&n!==o&&D(e,n,{get:()=>t[n],enumerable:!(r=Ye(t,n))||r.enumerable});return e};var et=(e,t,o)=>(o=e!=null?Ve($e(e)):{},me(t||!e||!e.__esModule?D(o,"default",{value:e,enumerable:!0}):o,e)),tt=e=>me(D({},"__esModule",{value:!0}),e);var Xt={};Ze(Xt,{GrazEvents:()=>ue,GrazProvider:()=>$t,WALLET_TYPES:()=>G,WalletType:()=>v,checkWallet:()=>f,clearRecentChain:()=>z,configureGraz:()=>W,connect:()=>h,createClients:()=>w,createQueryClient:()=>q,createSigningClients:()=>b,defineChain:()=>wt,defineChainInfo:()=>bt,defineChains:()=>ie,disconnect:()=>T,executeContract:()=>L,getActiveChainCurrency:()=>K,getAvailableWallets:()=>ot,getBalanceStaked:()=>_,getBalances:()=>F,getKeplr:()=>ye,getLeap:()=>Ce,getQueryRaw:()=>Y,getQuerySmart:()=>V,getRecentChain:()=>st,getWallet:()=>x,instantiateContract:()=>H,mainnetChains:()=>jt,mainnetChainsArray:()=>Dt,reconnect:()=>l,sendIbcTokens:()=>N,sendTokens:()=>P,suggestChain:()=>I,suggestChainAndConnect:()=>O,testnetChains:()=>kt,testnetChainsArray:()=>Tt,useAccount:()=>d,useActiveChain:()=>qt,useActiveChainCurrency:()=>Mt,useActiveChainValidators:()=>Qt,useBalance:()=>Bt,useBalanceStaked:()=>Ut,useBalances:()=>We,useCheckKeplr:()=>It,useCheckWallet:()=>A,useClients:()=>Ft,useConnect:()=>Rt,useDisconnect:()=>vt,useExecuteContract:()=>Lt,useGrazEvents:()=>Pe,useInstantiateContract:()=>Ht,useOfflineSigners:()=>Fe,useQueryClient:()=>Wt,useQueryRaw:()=>Yt,useQuerySmart:()=>Vt,useRecentChain:()=>zt,useSendIbcTokens:()=>Nt,useSendTokens:()=>Pt,useSigners:()=>Gt,useSigningClients:()=>_t,useSuggestChain:()=>Kt,useSuggestChainAndConnect:()=>Ot});module.exports=tt(Xt);var fe=require("@cosmjs/stargate");var E="graz-reconnect-session";var le=require("zustand"),k=require("zustand/middleware");var v=(o=>(o.KEPLR="keplr",o.LEAP="leap",o))(v||{}),G=["keplr","leap"];var U={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,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},nt={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector}),version:2},c=(0,le.create)((0,k.subscribeWithSelector)((0,k.persist)(()=>U,nt)));var M=require("@cosmjs/cosmwasm-stargate"),Q=require("@cosmjs/stargate"),ge=require("@cosmjs/tendermint-rpc");var de=require("@cosmjs/stargate"),C=require("@cosmjs/utils");var q=(...e)=>{let{tendermint:t}=c.getState().clients,o=new de.QueryClient(t),r=e.map(n=>n(o));for(let n of r){(0,C.assert)((0,C.isNonNullObject)(n),"Extension must be a non-null object");for(let[i,s]of Object.entries(n)){(0,C.assert)((0,C.isNonNullObject)(s),`Module must be a non-null object. Found type ${typeof s} for module "${i}".`);let a=o[i]||{};o[i]={...a,...s}}}return o};var w=async({rpc:e,rpcHeaders:t})=>{let o={url:e,headers:{...t||{}}},[r,n,i]=await Promise.all([M.SigningCosmWasmClient.connect(o),Q.SigningStargateClient.connect(o),ge.Tendermint34Client.connect(e)]);return{cosmWasm:r,stargate:n,tendermint:i}},b=async e=>{let{rpc:t,rpcHeaders:o,offlineSignerAuto:r,cosmWasmSignerOptions:n={},stargateSignerOptions:i={}}=e,s={url:t,headers:{...o||{}}},[a,u]=await Promise.all([M.SigningCosmWasmClient.connectWithSigner(s,r,n),Q.SigningStargateClient.connectWithSigner(s,r,i)]);return{cosmWasm:a,stargate:u}};var f=(e=c.getState().walletType)=>{try{return x(e),!0}catch(t){return console.error(t),!1}},ye=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},Ce=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},x=(e=c.getState().walletType)=>{switch(e){case"keplr":return ye();case"leap":return Ce();default:throw new Error("Unknown wallet type")}},ot=()=>Object.fromEntries(G.map(e=>[e,f(e)]));var h=async e=>{try{let{defaultChain:t,recentChain:o,walletType:r}=c.getState(),n=(e==null?void 0:e.walletType)||r,i=x(n),s=(e==null?void 0:e.chain)||o||t;if(!s)throw new Error("No last known connected chain, connect action requires chain info");c.setState(j=>{let Le=j._reconnect||!!j._reconnectConnector||!!s;return j.activeChain&&j.activeChain.chainId!==s.chainId?{status:"connecting"}:Le?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(s.chainId);let a=i.getOfflineSigner(s.chainId),u=i.getOfflineSignerOnlyAmino(s.chainId),p=await i.getOfflineSignerAuto(s.chainId),m=s.gas?fe.GasPrice.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[pe,Ne,He]=await Promise.all([i.getKey(s.chainId),w(s),b({...s,offlineSignerAuto:p,cosmWasmSignerOptions:{gasPrice:m,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:pe,activeChain:s,clients:Ne,offlineSigner:a,offlineSignerAmino:u,offlineSignerAuto:p,recentChain:s,signingClients:He,status:"connected",walletType:n,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:n}),typeof window<"u"&&window.sessionStorage.setItem(E,"Active"),pe}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},T=async(e=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(E),c.setState(t=>({...U,recentChain:e?null:t.recentChain})),Promise.resolve()),l=async e=>{var i;let{recentChain:t,_reconnectConnector:o,_reconnect:r}=c.getState(),n=f(o||void 0);try{if(t&&n&&o)return await h({chain:t,walletType:o,autoReconnect:r})}catch(s){(i=e==null?void 0:e.onError)==null||i.call(e,s),T()}};var z=()=>{c.setState({recentChain:null})},K=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(o=>o.coinMinimalDenom===e)},st=()=>c.getState().recentChain,I=async e=>(await x().experimentalSuggestChain(e),e),O=async({chainInfo:e,rpcHeaders:t,gas:o,path:r,...n})=>{let i=await I(e);return{account:await h({chain:{chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,rpcHeaders:t,gas:o,path:r},...n}),chain:i}};var W=(e={})=>(c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||t.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var F=async e=>{let{activeChain:t,signingClients:o}=c.getState();if(!t||!o)throw new Error("No connected account detected");let{defaultSigningClient:r}=c.getState();return await Promise.all(t.currencies.map(async i=>{let s=i.coinMinimalDenom.startsWith("cw20:");return o[r].getBalance(e,s?i.coinMinimalDenom.replace("cw20:",""):i.coinMinimalDenom)}))},_=async e=>{let{clients:t}=c.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)},P=async({senderAddress:e,recipientAddress:t,amount:o,fee:r,memo:n})=>{let{signingClients:i,defaultSigningClient:s}=c.getState();if(!i)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return i[s].sendTokens(e,t,o,r,n)},N=async({senderAddress:e,recipientAddress:t,transferAmount:o,sourcePort:r,sourceChannel:n,timeoutHeight:i,timeoutTimestamp:s,fee:a,memo:u})=>{let{signingClients:p}=c.getState();if(!(p!=null&&p.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return p.stargate.sendIbcTokens(e,t,o,r,n,i,s,a,u)},H=async({senderAddress:e,msg:t,fee:o,options:r,label:n,codeId:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.instantiate(e,i,t,n,o,r)},L=async({senderAddress:e,msg:t,fee:o,contractAddress:r,funds:n,memo:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.execute(e,r,t,o,i,n)},V=async(e,t)=>{let{clients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm client is not ready");return await o.cosmWasm.queryContractSmart(e,t)},Y=(e,t)=>{let{clients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(t);return o.cosmWasm.queryContractRaw(e,r)};var he=require("@keplr-wallet/cosmos"),Ae={coinDenom:"axl",coinMinimalDenom:"uaxl",coinDecimals:6,coinGeckoId:"axelar-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/axl.png"},rt={coinDenom:"usdc",coinMinimalDenom:"uusdc",coinDecimals:6,coinGeckoId:"usd-coin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdc.png"},it={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},ct={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},at={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},ut={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},xe=[Ae,rt,it,ct,at,ut],J={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:Ae,bip44:{coinType:118},bech32Config:he.Bech32Address.defaultBech32Config("axelar"),currencies:xe,feeCurrencies:xe};var Ee=require("@keplr-wallet/cosmos"),we={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},Se=[we],$={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:we,bip44:{coinType:118},bech32Config:Ee.Bech32Address.defaultBech32Config("cosmos"),currencies:Se,feeCurrencies:Se};var je=require("@keplr-wallet/cosmos"),De={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},pt={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},mt={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},lt={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},dt={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},gt={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},yt={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Ct={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},ft={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},xt={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},ht={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},be=[De,pt,mt,lt,dt,gt,yt,Ct,ft,xt,ht],X={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:De,bip44:{coinType:118},bech32Config:je.Bech32Address.defaultBech32Config("juno"),currencies:be,feeCurrencies:be};var Te=require("@keplr-wallet/cosmos"),Ie={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},At={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ke=[Ie,At],Z={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:Ie,bip44:{coinType:118},bech32Config:Te.Bech32Address.defaultBech32Config("osmo"),currencies:ke,feeCurrencies:ke};var Re=require("@keplr-wallet/cosmos"),ve={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},Be=[ve],ee={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:ve,bip44:{coinType:118},bech32Config:Re.Bech32Address.defaultBech32Config("somm"),currencies:Be,feeCurrencies:Be};var Ue=require("@keplr-wallet/cosmos"),qe={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},Ge=[qe],te={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:Ue.Bech32Address.defaultBech32Config("CRE"),currencies:Ge,feeCurrencies:Ge,stakeCurrency:qe,coinType:118};var Me=require("@keplr-wallet/cosmos"),ne={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},St=[ne],oe={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:ne,bip44:{coinType:118},bech32Config:Me.Bech32Address.defaultBech32Config("juno"),currencies:St,feeCurrencies:[ne],coinType:118};var Qe=require("@keplr-wallet/cosmos"),se={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},Et=[se],re={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:se,bip44:{coinType:118},bech32Config:Qe.Bech32Address.defaultBech32Config("osmo"),currencies:Et,feeCurrencies:[se],coinType:118};var ie=e=>e,wt=e=>e,bt=e=>e,jt=ie({axelar:J,cosmoshub:$,juno:X,osmosis:Z,sommelier:ee}),Dt=[J,$,X,Z,ee],kt=ie({crescent:te,juno:oe,osmosis:re}),Tt=[te,oe,re];var y=require("@tanstack/react-query"),Ke=require("react"),Oe=et(require("zustand/shallow"));var ze=require("@tanstack/react-query");var It=()=>A("keplr"),A=e=>{let o=["USE_CHECK_WALLET",c(n=>e||n.walletType)];return(0,ze.useQuery)(o,({queryKey:[,n]})=>f(n))};var d=({onConnect:e,onDisconnect:t}={})=>{let o=c(n=>n.account),r=c(n=>n.status);return(0,Ke.useEffect)(()=>c.subscribe(n=>n.status,(n,i)=>{if(n==="connected"){let s=c.getState();e==null||e({account:s.account,isReconnect:i==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:!!o,isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",isLoading:r==="connecting"||r==="reconnecting",reconnect:l,status:r}},We=e=>{let{data:t}=d(),o=e||(t==null?void 0:t.bech32Address);return(0,y.useQuery)(["USE_BALANCES",o],({queryKey:[,i]})=>F(i),{enabled:!!o})},Bt=(e,t)=>{let{data:o}=We(t);return(0,y.useQuery)(["USE_BALANCE",o,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===e),{enabled:!!o})},Rt=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=(0,y.useMutation)(["USE_CONNECT",e,t,o],h,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=A();return{connect:s=>n.mutate(s),connectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:!!i,status:n.status}},vt=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=(0,y.useMutation)(["USE_DISCONNECT",e,t,o],T,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return{disconnect:i=>n.mutate(i),disconnectAsync:i=>n.mutateAsync(i),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}},Fe=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),Oe.default),Gt=()=>Fe(),Ut=e=>{let{data:t}=d(),o=e||(t==null?void 0:t.bech32Address);return(0,y.useQuery)(["USE_BALANCE_STAKED",o],({queryKey:[,i]})=>_(o),{enabled:!!o})};var S=require("@tanstack/react-query");var qt=()=>c(e=>e.activeChain),Mt=e=>(0,S.useQuery)(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>K(r)),Qt=(e,t="BOND_STATUS_BONDED")=>(0,S.useQuery)(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,n,i]})=>n.staking.validators(i),{enabled:typeof e<"u"}),zt=()=>({data:c(t=>t.recentChain),clear:z}),Kt=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=(0,S.useMutation)(["USE_SUGGEST_CHAIN",e,t,o],I,{onError:(i,s)=>Promise.resolve(e==null?void 0:e(i,s)),onMutate:t,onSuccess:i=>Promise.resolve(o==null?void 0:o(i))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}},Ot=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=(0,S.useMutation)(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],O,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=A();return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:!!i,status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}};var ce=require("@tanstack/react-query");var _e=require("@tanstack/react-query");var Wt=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return(0,_e.useQuery)(t,({queryKey:[,...r]})=>q(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var Ft=e=>{let t=c(n=>n.clients);return(0,ce.useQuery)(["USE_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?w(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({clients:n})}})},_t=e=>{let t=c(n=>n.signingClients);return(0,ce.useQuery)(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?b(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({signingClients:n})}})};var g=require("@tanstack/react-query");var Pt=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=d(),n=r==null?void 0:r.bech32Address,s=(0,g.useMutation)(["USE_SEND_TOKENS",e,t,o,n],a=>P({senderAddress:n,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}},Nt=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=d(),n=r==null?void 0:r.bech32Address,s=(0,g.useMutation)(["USE_SEND_IBC_TOKENS",e,t,o,n],a=>N({senderAddress:n,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}},Ht=({codeId:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=d(),i=n==null?void 0:n.bech32Address,u=(0,g.useMutation)(["USE_INSTANTIATE_CONTRACT",t,o,r,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,codeId:e};return H(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:o,onSuccess:p=>Promise.resolve(r==null?void 0:r(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,instantiateContract:u.mutate,instantiateContractAsync:u.mutateAsync,status:u.status}},Lt=({contractAddress:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=d(),i=n==null?void 0:n.bech32Address,u=(0,g.useMutation)(["USE_EXECUTE_CONTRACT",t,o,r,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,contractAddress:e,memo:p.memo??"",funds:p.funds??[]};return L(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:o,onSuccess:p=>Promise.resolve(r==null?void 0:r(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,executeContract:u.mutate,executeContractAsync:u.mutateAsync,status:u.status}},Vt=(e,t)=>(0,g.useQuery)(["USE_QUERY_SMART",e,t],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return V(e,t)},{enabled:!!e&&!!t}),Yt=(e,t)=>(0,g.useQuery)(["USE_QUERY_RAW",t,e],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or key undefined");return Y(e,t)},{enabled:!!e&&!!t});var B=require("@tanstack/react-query");var ae=require("react");var Pe=()=>{let e=typeof window<"u"&&window.sessionStorage.getItem(E)==="Active",{activeChain:t,_reconnect:o,_onReconnectFailed:r,_reconnectConnector:n}=c();return(0,ae.useEffect)(()=>{e&&t?l({onError:r}):!e&&o&&l({onError:r})},[]),(0,ae.useEffect)(()=>{if(n)return window.addEventListener(n==="keplr"?"keplr_keystorechange":"leap_keystorechange",()=>void l({onError:r})),()=>{window.removeEventListener(n==="keplr"?"keplr_keystorechange":"leap_keystorechange",()=>void l({onError:r}))}},[n]),null},ue=()=>(Pe(),null);var R=require("react/jsx-runtime"),Jt=new B.QueryClient({}),$t=({children:e,grazOptions:t,...o})=>(t&&W(t),(0,R.jsxs)(B.QueryClientProvider,{client:Jt,...o,children:[(0,R.jsx)(ue,{}),e]}));0&&(module.exports={GrazEvents,GrazProvider,WALLET_TYPES,WalletType,checkWallet,clearRecentChain,configureGraz,connect,createClients,createQueryClient,createSigningClients,defineChain,defineChainInfo,defineChains,disconnect,executeContract,getActiveChainCurrency,getAvailableWallets,getBalanceStaked,getBalances,getKeplr,getLeap,getQueryRaw,getQuerySmart,getRecentChain,getWallet,instantiateContract,mainnetChains,mainnetChainsArray,reconnect,sendIbcTokens,sendTokens,suggestChain,suggestChainAndConnect,testnetChains,testnetChainsArray,useAccount,useActiveChain,useActiveChainCurrency,useActiveChainValidators,useBalance,useBalanceStaked,useBalances,useCheckKeplr,useCheckWallet,useClients,useConnect,useDisconnect,useExecuteContract,useGrazEvents,useInstantiateContract,useOfflineSigners,useQueryClient,useQueryRaw,useQuerySmart,useRecentChain,useSendIbcTokens,useSendTokens,useSigners,useSigningClients,useSuggestChain,useSuggestChainAndConnect});
|
package/dist/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as y}from"./chunk-ETISV7IF.mjs";import{GasPrice as qe}from"@cosmjs/stargate";import ke from"zustand";import{persist as Ie,subscribeWithSelector as Te}from"zustand/middleware";var K=(o=>(o.KEPLR="keplr",o.LEAP="leap",o))(K||{}),W=["keplr","leap"];var b={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,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},Be={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector}),version:2},c=ke(Te(Ie(()=>b,Be)));import{SigningCosmWasmClient as P}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as N}from"@cosmjs/stargate";import{Tendermint34Client as ve}from"@cosmjs/tendermint-rpc";import{QueryClient as Re}from"@cosmjs/stargate";import{assert as O,isNonNullObject as F}from"@cosmjs/utils";var _=(...e)=>{let{tendermint:t}=c.getState().clients,o=new Re(t),r=e.map(n=>n(o));for(let n of r){O(F(n),"Extension must be a non-null object");for(let[i,s]of Object.entries(n)){O(F(s),`Module must be a non-null object. Found type ${typeof s} for module "${i}".`);let u=o[i]||{};o[i]={...u,...s}}}return o};var S=async({rpc:e,rpcHeaders:t})=>{let o={url:e,headers:{...t||{}}},[r,n,i]=await Promise.all([P.connect(o),N.connect(o),ve.connect(e)]);return{cosmWasm:r,stargate:n,tendermint:i}},E=async e=>{let{rpc:t,rpcHeaders:o,offlineSignerAuto:r,cosmWasmSignerOptions:n={},stargateSignerOptions:i={}}=e,s={url:t,headers:{...o||{}}},[u,p]=await Promise.all([P.connectWithSigner(s,r,n),N.connectWithSigner(s,r,i)]);return{cosmWasm:u,stargate:p}};var C=(e=c.getState().walletType)=>{try{return f(e),!0}catch(t){return console.error(t),!1}},Ge=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},Ue=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},f=(e=c.getState().walletType)=>{switch(e){case"keplr":return Ge();case"leap":return Ue();default:throw new Error("Unknown wallet type")}},Mt=()=>Object.fromEntries(W.map(e=>[e,C(e)]));var x=async e=>{try{let{defaultChain:t,recentChain:o,walletType:r}=c.getState(),n=(e==null?void 0:e.walletType)||r,i=f(n),s=(e==null?void 0:e.chain)||o||t;if(!s)throw new Error("No last known connected chain, connect action requires chain info");c.setState(A=>{let De=A._reconnect||Boolean(A._reconnectConnector)||Boolean(s);return A.activeChain&&A.activeChain.chainId!==s.chainId?{status:"connecting"}:De?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(s.chainId);let u=i.getOfflineSigner(s.chainId),p=i.getOfflineSignerOnlyAmino(s.chainId),m=await i.getOfflineSignerAuto(s.chainId),l=s.gas?qe.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[z,be,je]=await Promise.all([i.getKey(s.chainId),S(s),E({...s,offlineSignerAuto:m,cosmWasmSignerOptions:{gasPrice:l,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:z,activeChain:s,clients:be,offlineSigner:u,offlineSignerAmino:p,offlineSignerAuto:m,recentChain:s,signingClients:je,status:"connected",walletType:n,_reconnect:Boolean(e==null?void 0:e.autoReconnect),_reconnectConnector:n}),typeof window<"u"&&window.sessionStorage.setItem(y,"Active"),z}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},j=async(e=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(y),c.setState(t=>({...b,recentChain:e?null:t.recentChain})),Promise.resolve()),d=async e=>{var i;let{recentChain:t,_reconnectConnector:o,_reconnect:r}=c.getState(),n=C(o||void 0);try{if(t&&n&&o)return await x({chain:t,walletType:o,autoReconnect:r})}catch(s){(i=e==null?void 0:e.onError)==null||i.call(e,s),j()}};var H=()=>{c.setState({recentChain:null})},L=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(o=>o.coinMinimalDenom===e)},Lt=()=>c.getState().recentChain,D=async e=>(await f().experimentalSuggestChain(e),e),V=async({chainInfo:e,rpcHeaders:t,gas:o,path:r,...n})=>{let i=await D(e);return{account:await x({chain:{chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,rpcHeaders:t,gas:o,path:r},...n}),chain:i}};var Y=(e={})=>(c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||t.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var J=async e=>{let{activeChain:t,signingClients:o}=c.getState();if(!t||!o)throw new Error("No connected account detected");let{defaultSigningClient:r}=c.getState();return await Promise.all(t.currencies.map(async i=>{let s=i.coinMinimalDenom.startsWith("cw20:");return o[r].getBalance(e,s?i.coinMinimalDenom.replace("cw20:",""):i.coinMinimalDenom)}))},$=async e=>{let{clients:t}=c.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)},X=async({senderAddress:e,recipientAddress:t,amount:o,fee:r,memo:n})=>{let{signingClients:i,defaultSigningClient:s}=c.getState();if(!i)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return i[s].sendTokens(e,t,o,r,n)},Z=async({senderAddress:e,recipientAddress:t,transferAmount:o,sourcePort:r,sourceChannel:n,timeoutHeight:i,timeoutTimestamp:s,fee:u,memo:p})=>{let{signingClients:m}=c.getState();if(!(m!=null&&m.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return m.stargate.sendIbcTokens(e,t,o,r,n,i,s,u,p)},ee=async({senderAddress:e,msg:t,fee:o,options:r,label:n,codeId:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.instantiate(e,i,t,n,o,r)},te=async({senderAddress:e,msg:t,fee:o,contractAddress:r,funds:n,memo:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.execute(e,r,t,o,i,n)},ne=async(e,t)=>{let{clients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm client is not ready");return await o.cosmWasm.queryContractSmart(e,t)},oe=(e,t)=>{let{clients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(t);return o.cosmWasm.queryContractRaw(e,r)};import{Bech32Address as Me}from"@keplr-wallet/cosmos";var re={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"},ze={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},Ke={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},We={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},Oe={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},se=[re,Qe,ze,Ke,We,Oe],k={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:re,bip44:{coinType:118},bech32Config:Me.defaultBech32Config("axelar"),currencies:se,feeCurrencies:se};import{Bech32Address as Fe}from"@keplr-wallet/cosmos";var ce={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},ie=[ce],I={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:ce,bip44:{coinType:118},bech32Config:Fe.defaultBech32Config("cosmos"),currencies:ie,feeCurrencies:ie};import{Bech32Address as _e}from"@keplr-wallet/cosmos";var ue={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},Pe={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},Ne={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},He={coinDenom:"hope",coinMinimalDenom:"cw20:juno1re3x67ppxap48ygndmrc7har2cnc7tcxtm9nplcas4v0gc3wnmvs3s807z",coinDecimals:6,coinGeckoId:"hope-galaxy",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hope.png"},Le={coinDenom:"rac",coinMinimalDenom:"cw20:juno1r4pzw8f9z0sypct5l9j906d47z998ulwvhvqe5xdwgy8wf84583sxwh0pa",coinDecimals:6,coinGeckoId:"racoon",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/rac.png"},Ve={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Ye={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Je={coinDenom:"raw",coinMinimalDenom:"cw20:juno15u3dt79t6sxxa3x3kpkhzsy56edaa5a66wvt3kxmukqjz2sx0hes5sn38g",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/raw.png",coinGeckoId:"junoswap-raw-dao"},$e={coinDenom:"asvt",coinMinimalDenom:"cw20:juno17wzaxtfdw5em7lc94yed4ylgjme63eh73lm3lutp2rhcxttyvpwsypjm4w",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/asvt.png"},Xe={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"},ae=[ue,Pe,Ne,He,Le,Ve,Ye,Je,$e,Xe,Ze],T={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:ue,bip44:{coinType:118},bech32Config:_e.defaultBech32Config("juno"),currencies:ae,feeCurrencies:ae};import{Bech32Address as et}from"@keplr-wallet/cosmos";var me={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},tt={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},pe=[me,tt],B={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:me,bip44:{coinType:118},bech32Config:et.defaultBech32Config("osmo"),currencies:pe,feeCurrencies:pe};import{Bech32Address as nt}from"@keplr-wallet/cosmos";var de={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},le=[de],R={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:de,bip44:{coinType:118},bech32Config:nt.defaultBech32Config("somm"),currencies:le,feeCurrencies:le};import{Bech32Address as ot}from"@keplr-wallet/cosmos";var ye={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},ge=[ye],v={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:ot.defaultBech32Config("CRE"),currencies:ge,feeCurrencies:ge,stakeCurrency:ye,coinType:118};import{Bech32Address as st}from"@keplr-wallet/cosmos";var G={coinDenom:"junox",coinMinimalDenom:"ujunox",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},rt=[G],U={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:G,bip44:{coinType:118},bech32Config:st.defaultBech32Config("juno"),currencies:rt,feeCurrencies:[G],coinType:118};import{Bech32Address as it}from"@keplr-wallet/cosmos";var q={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},ct=[q],M={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:q,bip44:{coinType:118},bech32Config:it.defaultBech32Config("osmo"),currencies:ct,feeCurrencies:[q],coinType:118};var Ce=e=>e,jn=e=>e,Dn=e=>e,kn=Ce({axelar:k,cosmoshub:I,juno:T,osmosis:B,sommelier:R}),In=[k,I,T,B,R],Tn=Ce({crescent:v,juno:U,osmosis:M}),Bn=[v,U,M];import{useMutation as fe,useQuery as Q}from"@tanstack/react-query";import{useEffect as ut}from"react";import pt from"zustand/shallow";import{useQuery as at}from"@tanstack/react-query";var qn=()=>h("keplr"),h=e=>{let t=c(n=>e||n.walletType);return at(["USE_CHECK_WALLET",t],({queryKey:[,n]})=>C(n))};var g=({onConnect:e,onDisconnect:t}={})=>{let o=c(n=>n.account),r=c(n=>n.status);return ut(()=>c.subscribe(n=>n.status,(n,i)=>{if(n==="connected"){let s=c.getState();e==null||e({account:s.account,isReconnect:i==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:Boolean(o),isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",isLoading:r==="connecting"||r==="reconnecting",reconnect:d,status:r}},mt=e=>{let{data:t}=g(),o=e||(t==null?void 0:t.bech32Address);return Q(["USE_BALANCES",o],({queryKey:[,i]})=>J(i),{enabled:Boolean(o)})},Pn=(e,t)=>{let{data:o}=mt(t);return Q(["USE_BALANCE",o,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===e),{enabled:Boolean(o)})},Nn=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=fe(["USE_CONNECT",e,t,o],x,{onError:(s,u)=>Promise.resolve(e==null?void 0:e(s,u)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=h();return{connect:s=>n.mutate(s),connectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(i),status:n.status}},Hn=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=fe(["USE_DISCONNECT",e,t,o],j,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return{disconnect:i=>n.mutate(i),disconnectAsync:i=>n.mutateAsync(i),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}},lt=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),pt),Ln=()=>lt(),Vn=e=>{let{data:t}=g(),o=e||(t==null?void 0:t.bech32Address);return Q(["USE_BALANCE_STAKED",o],({queryKey:[,i]})=>$(o),{enabled:Boolean(o)})};import{useMutation as xe,useQuery as he}from"@tanstack/react-query";var eo=()=>c(e=>e.activeChain),to=e=>he(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>L(r)),no=(e,t="BOND_STATUS_BONDED")=>he(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,n,i]})=>n.staking.validators(i),{enabled:typeof e<"u"}),oo=()=>({data:c(t=>t.recentChain),clear:H}),so=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=xe(["USE_SUGGEST_CHAIN",e,t,o],D,{onError:(i,s)=>Promise.resolve(e==null?void 0:e(i,s)),onMutate:t,onSuccess:i=>Promise.resolve(o==null?void 0:o(i))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}},ro=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=xe(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],V,{onError:(s,u)=>Promise.resolve(e==null?void 0:e(s,u)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=h();return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:Boolean(i),status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}};import{useQuery as Ae}from"@tanstack/react-query";import{useQuery as dt}from"@tanstack/react-query";var uo=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return dt(t,({queryKey:[,...r]})=>_(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var yo=e=>{let t=c(n=>n.clients);return Ae(["USE_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?S(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({clients:n})}})},Co=e=>{let t=c(n=>n.signingClients);return Ae(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?E(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({signingClients:n})}})};import{useMutation as w,useQuery as Se}from"@tanstack/react-query";var Eo=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=g(),n=r==null?void 0:r.bech32Address,s=w(["USE_SEND_TOKENS",e,t,o,n],u=>X({senderAddress:n,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(o==null?void 0:o(u))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}},wo=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=g(),n=r==null?void 0:r.bech32Address,s=w(["USE_SEND_IBC_TOKENS",e,t,o,n],u=>Z({senderAddress:n,...u}),{onError:(u,p)=>Promise.resolve(e==null?void 0:e(u,p)),onMutate:t,onSuccess:u=>Promise.resolve(o==null?void 0:o(u))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}},bo=({codeId:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=g(),i=n==null?void 0:n.bech32Address,p=w(["USE_INSTANTIATE_CONTRACT",t,o,r,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,codeId:e};return ee(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:o,onSuccess:m=>Promise.resolve(r==null?void 0:r(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,instantiateContract:p.mutate,instantiateContractAsync:p.mutateAsync,status:p.status}},jo=({contractAddress:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=g(),i=n==null?void 0:n.bech32Address,p=w(["USE_EXECUTE_CONTRACT",t,o,r,e,i],m=>{if(!i)throw new Error("senderAddress is undefined");let l={...m,fee:m.fee??"auto",senderAddress:i,contractAddress:e,memo:m.memo??"",funds:m.funds??[]};return te(l)},{onError:(m,l)=>Promise.resolve(t==null?void 0:t(m,l)),onMutate:o,onSuccess:m=>Promise.resolve(r==null?void 0:r(m))});return{error:p.error,isLoading:p.isLoading,isSuccess:p.isSuccess,executeContract:p.mutate,executeContractAsync:p.mutateAsync,status:p.status}},Do=(e,t)=>Se(["USE_QUERY_SMART",e,t],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return ne(e,t)},{enabled:Boolean(e)&&Boolean(t)}),ko=(e,t)=>Se(["USE_QUERY_RAW",t,e],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or key undefined");return oe(e,t)},{enabled:Boolean(e)&&Boolean(t)});import{QueryClient as yt,QueryClientProvider as Ct}from"@tanstack/react-query";import{useEffect as Ee}from"react";var gt=()=>{let e=typeof window<"u"&&window.sessionStorage.getItem(y)==="Active",{activeChain:t,_reconnect:o,_onReconnectFailed:r}=c.getState();return Ee(()=>{e&&Boolean(t)?d({onError:r}):!e&&o&&d({onError:r})},[]),Ee(()=>(window.addEventListener("keplr_keystorechange",()=>void d({onError:r})),()=>{window.removeEventListener("keplr_keystorechange",()=>void d({onError:r}))}),[]),null},we=()=>(gt(),null);import{jsx as xt,jsxs as ht}from"react/jsx-runtime";var ft=new yt({}),Qo=({children:e,grazOptions:t,...o})=>(t&&Y(t),ht(Ct,{client:ft,...o,children:[xt(we,{}),e]}));export{we as GrazEvents,Qo as GrazProvider,W as WALLET_TYPES,K as WalletType,C as checkWallet,H as clearRecentChain,Y as configureGraz,x as connect,S as createClients,_ as createQueryClient,E as createSigningClients,jn as defineChain,Dn as defineChainInfo,Ce as defineChains,j as disconnect,te as executeContract,L as getActiveChainCurrency,Mt as getAvailableWallets,$ as getBalanceStaked,J as getBalances,Ge as getKeplr,Ue as getLeap,oe as getQueryRaw,ne as getQuerySmart,Lt as getRecentChain,f as getWallet,ee as instantiateContract,kn as mainnetChains,In as mainnetChainsArray,d as reconnect,Z as sendIbcTokens,X as sendTokens,D as suggestChain,V as suggestChainAndConnect,Tn as testnetChains,Bn as testnetChainsArray,g as useAccount,eo as useActiveChain,to as useActiveChainCurrency,no as useActiveChainValidators,Pn as useBalance,Vn as useBalanceStaked,mt as useBalances,qn as useCheckKeplr,h as useCheckWallet,yo as useClients,Nn as useConnect,Hn as useDisconnect,jo as useExecuteContract,gt as useGrazEvents,bo as useInstantiateContract,lt as useOfflineSigners,uo as useQueryClient,ko as useQueryRaw,Do as useQuerySmart,oo as useRecentChain,wo as useSendIbcTokens,Eo as useSendTokens,Ln as useSigners,Co as useSigningClients,so as useSuggestChain,ro as useSuggestChainAndConnect};
|
|
1
|
+
import{a as g}from"./chunk-V3YUCPIG.mjs";import{GasPrice as Ue}from"@cosmjs/stargate";import{create as De}from"zustand";import{persist as ke,subscribeWithSelector as Te}from"zustand/middleware";var z=(o=>(o.KEPLR="keplr",o.LEAP="leap",o))(z||{}),K=["keplr","leap"];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,_onReconnectFailed:()=>null,_reconnect:!1,_reconnectConnector:null},Ie={name:"graz",partialize:e=>({activeChain:e.activeChain,recentChain:e.recentChain,_reconnect:e._reconnect,_reconnectConnector:e._reconnectConnector}),version:2},c=De(Te(ke(()=>w,Ie)));import{SigningCosmWasmClient as _}from"@cosmjs/cosmwasm-stargate";import{SigningStargateClient as P}from"@cosmjs/stargate";import{Tendermint34Client as Re}from"@cosmjs/tendermint-rpc";import{QueryClient as Be}from"@cosmjs/stargate";import{assert as W,isNonNullObject as O}from"@cosmjs/utils";var F=(...e)=>{let{tendermint:t}=c.getState().clients,o=new Be(t),r=e.map(n=>n(o));for(let n of r){W(O(n),"Extension must be a non-null object");for(let[i,s]of Object.entries(n)){W(O(s),`Module must be a non-null object. Found type ${typeof s} for module "${i}".`);let a=o[i]||{};o[i]={...a,...s}}}return o};var A=async({rpc:e,rpcHeaders:t})=>{let o={url:e,headers:{...t||{}}},[r,n,i]=await Promise.all([_.connect(o),P.connect(o),Re.connect(e)]);return{cosmWasm:r,stargate:n,tendermint:i}},S=async e=>{let{rpc:t,rpcHeaders:o,offlineSignerAuto:r,cosmWasmSignerOptions:n={},stargateSignerOptions:i={}}=e,s={url:t,headers:{...o||{}}},[a,u]=await Promise.all([_.connectWithSigner(s,r,n),P.connectWithSigner(s,r,i)]);return{cosmWasm:a,stargate:u}};var y=(e=c.getState().walletType)=>{try{return C(e),!0}catch(t){return console.error(t),!1}},ve=()=>{if(typeof window.keplr<"u")return window.keplr;throw c.getState()._notFoundFn(),new Error("window.keplr is not defined")},Ge=()=>{if(typeof window.leap<"u")return window.leap;throw c.getState()._notFoundFn(),new Error("window.leap is not defined")},C=(e=c.getState().walletType)=>{switch(e){case"keplr":return ve();case"leap":return Ge();default:throw new Error("Unknown wallet type")}},qt=()=>Object.fromEntries(K.map(e=>[e,y(e)]));var f=async e=>{try{let{defaultChain:t,recentChain:o,walletType:r}=c.getState(),n=(e==null?void 0:e.walletType)||r,i=C(n),s=(e==null?void 0:e.chain)||o||t;if(!s)throw new Error("No last known connected chain, connect action requires chain info");c.setState(h=>{let je=h._reconnect||!!h._reconnectConnector||!!s;return h.activeChain&&h.activeChain.chainId!==s.chainId?{status:"connecting"}:je?{status:"reconnecting"}:{status:"connecting"}}),await i.enable(s.chainId);let a=i.getOfflineSigner(s.chainId),u=i.getOfflineSignerOnlyAmino(s.chainId),p=await i.getOfflineSignerAuto(s.chainId),m=s.gas?Ue.fromString(`${s.gas.price}${s.gas.denom}`):void 0,[Q,we,be]=await Promise.all([i.getKey(s.chainId),A(s),S({...s,offlineSignerAuto:p,cosmWasmSignerOptions:{gasPrice:m,...(e==null?void 0:e.signerOpts)||{}}})]);return c.setState({account:Q,activeChain:s,clients:we,offlineSigner:a,offlineSignerAmino:u,offlineSignerAuto:p,recentChain:s,signingClients:be,status:"connected",walletType:n,_reconnect:!!(e!=null&&e.autoReconnect),_reconnectConnector:n}),typeof window<"u"&&window.sessionStorage.setItem(g,"Active"),Q}catch(t){throw c.getState().account===null&&c.setState({status:"disconnected"}),t}},b=async(e=!1)=>(typeof window<"u"&&window.sessionStorage.removeItem(g),c.setState(t=>({...w,recentChain:e?null:t.recentChain})),Promise.resolve()),l=async e=>{var i;let{recentChain:t,_reconnectConnector:o,_reconnect:r}=c.getState(),n=y(o||void 0);try{if(t&&n&&o)return await f({chain:t,walletType:o,autoReconnect:r})}catch(s){(i=e==null?void 0:e.onError)==null||i.call(e,s),b()}};var N=()=>{c.setState({recentChain:null})},H=e=>{let{activeChain:t}=c.getState();return t==null?void 0:t.currencies.find(o=>o.coinMinimalDenom===e)},Ht=()=>c.getState().recentChain,j=async e=>(await C().experimentalSuggestChain(e),e),L=async({chainInfo:e,rpcHeaders:t,gas:o,path:r,...n})=>{let i=await j(e);return{account:await f({chain:{chainId:e.chainId,currencies:e.currencies,rest:e.rest,rpc:e.rpc,rpcHeaders:t,gas:o,path:r},...n}),chain:i}};var V=(e={})=>(c.setState(t=>({defaultChain:e.defaultChain||t.defaultChain,defaultSigningClient:e.defaultSigningClient||t.defaultSigningClient,walletType:e.defaultWallet||t.walletType,_notFoundFn:e.onNotFound||t._notFoundFn,_onReconnectFailed:e.onReconnectFailed||t._onReconnectFailed,_reconnect:e.autoReconnect===void 0?!0:e.autoReconnect||t._reconnect})),e);var Y=async e=>{let{activeChain:t,signingClients:o}=c.getState();if(!t||!o)throw new Error("No connected account detected");let{defaultSigningClient:r}=c.getState();return await Promise.all(t.currencies.map(async i=>{let s=i.coinMinimalDenom.startsWith("cw20:");return o[r].getBalance(e,s?i.coinMinimalDenom.replace("cw20:",""):i.coinMinimalDenom)}))},J=async e=>{let{clients:t}=c.getState();if(!(t!=null&&t.stargate))throw new Error("Stargate client is not ready");return t.stargate.getBalanceStaked(e)},$=async({senderAddress:e,recipientAddress:t,amount:o,fee:r,memo:n})=>{let{signingClients:i,defaultSigningClient:s}=c.getState();if(!i)throw new Error("No connected account detected");if(!e)throw new Error("senderAddress is not defined");return i[s].sendTokens(e,t,o,r,n)},X=async({senderAddress:e,recipientAddress:t,transferAmount:o,sourcePort:r,sourceChannel:n,timeoutHeight:i,timeoutTimestamp:s,fee:a,memo:u})=>{let{signingClients:p}=c.getState();if(!(p!=null&&p.stargate))throw new Error("Stargate signing client is not ready");if(!e)throw new Error("senderAddress is not defined");return p.stargate.sendIbcTokens(e,t,o,r,n,i,s,a,u)},Z=async({senderAddress:e,msg:t,fee:o,options:r,label:n,codeId:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.instantiate(e,i,t,n,o,r)},ee=async({senderAddress:e,msg:t,fee:o,contractAddress:r,funds:n,memo:i})=>{let{signingClients:s}=c.getState();if(!(s!=null&&s.cosmWasm))throw new Error("CosmWasm signing client is not ready");return s.cosmWasm.execute(e,r,t,o,i,n)},te=async(e,t)=>{let{clients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm client is not ready");return await o.cosmWasm.queryContractSmart(e,t)},ne=(e,t)=>{let{clients:o}=c.getState();if(!(o!=null&&o.cosmWasm))throw new Error("CosmWasm client is not ready");let r=new TextEncoder().encode(t);return o.cosmWasm.queryContractRaw(e,r)};import{Bech32Address as qe}from"@keplr-wallet/cosmos";var se={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"},Qe={coinDenom:"dai",coinMinimalDenom:"dai-wei",coinDecimals:18,coinGeckoId:"dai",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/dai.png"},ze={coinDenom:"usdt",coinMinimalDenom:"uusdt",coinDecimals:6,coinGeckoId:"tether",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/usdt.png"},Ke={coinDenom:"weth-wei",coinMinimalDenom:"weth",coinDecimals:18,coinGeckoId:"weth",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/weth.png"},We={coinDenom:"wbtc-satoshi",coinMinimalDenom:"wbtc",coinDecimals:8,coinGeckoId:"wrapped-bitcoin",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/axelar/images/wbtc.png"},oe=[se,Me,Qe,ze,Ke,We],D={rpc:"https://rpc.axelar.strange.love",rest:"https://api.axelar.strange.love",chainId:"axelar-dojo-1",chainName:"Axelar",stakeCurrency:se,bip44:{coinType:118},bech32Config:qe.defaultBech32Config("axelar"),currencies:oe,feeCurrencies:oe};import{Bech32Address as Oe}from"@keplr-wallet/cosmos";var ie={coinDenom:"atom",coinMinimalDenom:"uatom",coinDecimals:6,coinGeckoId:"cosmos",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},re=[ie],k={rpc:"https://rpc.cosmoshub.strange.love",rest:"https://api.cosmoshub.strange.love",chainId:"cosmoshub-4",chainName:"Cosmos Hub",stakeCurrency:ie,bip44:{coinType:118},bech32Config:Oe.defaultBech32Config("cosmos"),currencies:re,feeCurrencies:re};import{Bech32Address as Fe}from"@keplr-wallet/cosmos";var ae={coinDenom:"juno",coinMinimalDenom:"ujuno",coinDecimals:6,coinGeckoId:"juno-network",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/juno.png"},_e={coinDenom:"neta",coinMinimalDenom:"cw20:juno168ctmpyppk90d34p3jjy658zf5a5l3w8wk35wht6ccqj4mr0yv8s4j5awr",coinDecimals:6,coinGeckoId:"neta",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/neta.png"},Pe={coinDenom:"marble",coinMinimalDenom:"cw20:juno1g2g7ucurum66d42g8k5twk34yegdq8c82858gz0tq2fc75zy7khssgnhjl",coinDecimals:3,coinGeckoId:"marble",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/marble.png"},Ne={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"},Le={coinDenom:"block",coinMinimalDenom:"cw20:juno1y9rf7ql6ffwkv02hsgd4yruz23pn4w97p75e2slsnkm0mnamhzysvqnxaq",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/block.png"},Ve={coinDenom:"dhk",coinMinimalDenom:"cw20:juno1tdjwrqmnztn2j3sj2ln9xnyps5hs48q3ddwjrz7jpv6mskappjys5czd49",coinDecimals:0,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/dhk.png"},Ye={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"},$e={coinDenom:"hns",coinMinimalDenom:"cw20:juno1ur4jx0sxchdevahep7fwq28yk4tqsrhshdtylz46yka3uf6kky5qllqp4k",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/hns.svg"},Xe={coinDenom:"joe",coinMinimalDenom:"cw20:juno1n7n7d5088qlzlj37e9mgmkhx6dfgtvt02hqxq66lcap4dxnzdhwqfmgng3",coinDecimals:6,coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/juno/images/joe.png"},ce=[ae,_e,Pe,Ne,He,Le,Ve,Ye,Je,$e,Xe],T={rpc:"https://rpc.juno.strange.love",rest:"https://api.juno.strange.love",chainId:"juno-1",chainName:"Juno",stakeCurrency:ae,bip44:{coinType:118},bech32Config:Fe.defaultBech32Config("juno"),currencies:ce,feeCurrencies:ce};import{Bech32Address as Ze}from"@keplr-wallet/cosmos";var pe={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/cosmoshub/images/atom.png"},et={coinDenom:"ion",coinMinimalDenom:"uion",coinDecimals:6,coinGeckoId:"ion",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/osmosis/images/ion.png"},ue=[pe,et],I={rpc:"https://rpc.osmosis.strange.love",rest:"https://api.osmosis.strange.love",chainId:"osmosis-1",chainName:"Osmosis",stakeCurrency:pe,bip44:{coinType:118},bech32Config:Ze.defaultBech32Config("osmo"),currencies:ue,feeCurrencies:ue};import{Bech32Address as tt}from"@keplr-wallet/cosmos";var le={coinDenom:"somm",coinMinimalDenom:"usomm",coinDecimals:6,coinGeckoId:"sommelier",coinImageUrl:"https://raw.githubusercontent.com/cosmos/chain-registry/master/sommelier/images/somm.png"},me=[le],B={rpc:"https://rpc.sommelier.strange.love",rest:"https://api.sommelier.strange.love",chainId:"sommelier-3",chainName:"Sommelier",stakeCurrency:le,bip44:{coinType:118},bech32Config:tt.defaultBech32Config("somm"),currencies:me,feeCurrencies:me};import{Bech32Address as nt}from"@keplr-wallet/cosmos";var ge={coinDenom:"CRE",coinMinimalDenom:"ucre",coinDecimals:6,coinGeckoId:"crescent",coinImageUrl:"https://raw.githubusercontent.com/crescent-network/asset/main/images/coin/CRE.png"},de=[ge],R={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:nt.defaultBech32Config("CRE"),currencies:de,feeCurrencies:de,stakeCurrency:ge,coinType:118};import{Bech32Address as ot}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"},st=[v],G={rpc:"https://rpc.uni.junonetwork.io",rest:"https://api.uni.junonetwork.io",chainId:"uni-5",chainName:"Juno Testnet",stakeCurrency:v,bip44:{coinType:118},bech32Config:ot.defaultBech32Config("juno"),currencies:st,feeCurrencies:[v],coinType:118};import{Bech32Address as rt}from"@keplr-wallet/cosmos";var U={coinDenom:"osmo",coinMinimalDenom:"uosmo",coinDecimals:6,coinGeckoId:"osmosis",coinImageUrl:"https://dhj8dql1kzq2v.cloudfront.net/white/osmo.png"},it=[U],q={rpc:"https://testnet-rpc.osmosis.zone",rest:"https://testnet-rest.osmosis.zone",chainId:"osmo-test-4",chainName:"Osmosis Testnet",stakeCurrency:U,bip44:{coinType:118},bech32Config:rt.defaultBech32Config("osmo"),currencies:it,feeCurrencies:[U],coinType:118};var ye=e=>e,bn=e=>e,jn=e=>e,Dn=ye({axelar:D,cosmoshub:k,juno:T,osmosis:I,sommelier:B}),kn=[D,k,T,I,B],Tn=ye({crescent:R,juno:G,osmosis:q}),In=[R,G,q];import{useMutation as Ce,useQuery as M}from"@tanstack/react-query";import{useEffect as at}from"react";import ut from"zustand/shallow";import{useQuery as ct}from"@tanstack/react-query";var Un=()=>x("keplr"),x=e=>{let o=["USE_CHECK_WALLET",c(n=>e||n.walletType)];return ct(o,({queryKey:[,n]})=>y(n))};var d=({onConnect:e,onDisconnect:t}={})=>{let o=c(n=>n.account),r=c(n=>n.status);return at(()=>c.subscribe(n=>n.status,(n,i)=>{if(n==="connected"){let s=c.getState();e==null||e({account:s.account,isReconnect:i==="reconnecting"})}n==="disconnected"&&(t==null||t())}),[e,t]),{data:o,isConnected:!!o,isConnecting:r==="connecting",isDisconnected:r==="disconnected",isReconnecting:r==="reconnecting",isLoading:r==="connecting"||r==="reconnecting",reconnect:l,status:r}},pt=e=>{let{data:t}=d(),o=e||(t==null?void 0:t.bech32Address);return M(["USE_BALANCES",o],({queryKey:[,i]})=>Y(i),{enabled:!!o})},_n=(e,t)=>{let{data:o}=pt(t);return M(["USE_BALANCE",o,e,t],({queryKey:[,i]})=>i==null?void 0:i.find(s=>s.denom===e),{enabled:!!o})},Pn=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=Ce(["USE_CONNECT",e,t,o],f,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:t,onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=x();return{connect:s=>n.mutate(s),connectAsync:s=>n.mutateAsync(s),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:!!i,status:n.status}},Nn=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=Ce(["USE_DISCONNECT",e,t,o],b,{onError:i=>Promise.resolve(e==null?void 0:e(i,void 0)),onMutate:t,onSuccess:()=>Promise.resolve(o==null?void 0:o(void 0))});return{disconnect:i=>n.mutate(i),disconnectAsync:i=>n.mutateAsync(i),error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,status:n.status}},mt=()=>c(e=>({signer:e.offlineSigner,signerAmino:e.offlineSignerAmino,signerAuto:e.offlineSignerAuto}),ut),Hn=()=>mt(),Ln=e=>{let{data:t}=d(),o=e||(t==null?void 0:t.bech32Address);return M(["USE_BALANCE_STAKED",o],({queryKey:[,i]})=>J(o),{enabled:!!o})};import{useMutation as fe,useQuery as xe}from"@tanstack/react-query";var Zn=()=>c(e=>e.activeChain),eo=e=>xe(["USE_ACTIVE_CHAIN_CURRENCY",e],({queryKey:[,r]})=>H(r)),to=(e,t="BOND_STATUS_BONDED")=>xe(["USE_ACTIVE_CHAIN_VALIDATORS",e,t],({queryKey:[,n,i]})=>n.staking.validators(i),{enabled:typeof e<"u"}),no=()=>({data:c(t=>t.recentChain),clear:N}),oo=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=fe(["USE_SUGGEST_CHAIN",e,t,o],j,{onError:(i,s)=>Promise.resolve(e==null?void 0:e(i,s)),onMutate:t,onSuccess:i=>Promise.resolve(o==null?void 0:o(i))});return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,suggest:n.mutate,suggestAsync:n.mutateAsync,status:n.status}},so=({onError:e,onLoading:t,onSuccess:o}={})=>{let n=fe(["USE_SUGGEST_CHAIN_AND_CONNECT",e,t,o],L,{onError:(s,a)=>Promise.resolve(e==null?void 0:e(s,a)),onMutate:s=>t==null?void 0:t(s),onSuccess:s=>Promise.resolve(o==null?void 0:o(s))}),{data:i}=x();return{error:n.error,isLoading:n.isLoading,isSuccess:n.isSuccess,isSupported:!!i,status:n.status,suggestAndConnect:n.mutate,suggestAndConnectAsync:n.mutateAsync}};import{useQuery as he}from"@tanstack/react-query";import{useQuery as lt}from"@tanstack/react-query";var ao=(...e)=>{let t=["USE_QUERY_CLIENT",...e];return lt(t,({queryKey:[,...r]})=>F(...e),{refetchOnMount:!1,refetchOnWindowFocus:!1})};var go=e=>{let t=c(n=>n.clients);return he(["USE_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?A(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({clients:n})}})},yo=e=>{let t=c(n=>n.signingClients);return he(["USE_SIGNING_CLIENTS",e,t],({queryKey:[,n,i]})=>n!=null&&n.rpc?S(n):i,{refetchOnMount:!1,refetchOnWindowFocus:!1,onSuccess:n=>{c.setState({signingClients:n})}})};import{useMutation as E,useQuery as Ae}from"@tanstack/react-query";var So=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=d(),n=r==null?void 0:r.bech32Address,s=E(["USE_SEND_TOKENS",e,t,o,n],a=>$({senderAddress:n,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendTokens:s.mutate,sendTokensAsync:s.mutateAsync,status:s.status}},Eo=({onError:e,onLoading:t,onSuccess:o}={})=>{let{data:r}=d(),n=r==null?void 0:r.bech32Address,s=E(["USE_SEND_IBC_TOKENS",e,t,o,n],a=>X({senderAddress:n,...a}),{onError:(a,u)=>Promise.resolve(e==null?void 0:e(a,u)),onMutate:t,onSuccess:a=>Promise.resolve(o==null?void 0:o(a))});return{error:s.error,isLoading:s.isLoading,isSuccess:s.isSuccess,sendIbcTokens:s.mutate,sendIbcTokensAsync:s.mutateAsync,status:s.status}},wo=({codeId:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=d(),i=n==null?void 0:n.bech32Address,u=E(["USE_INSTANTIATE_CONTRACT",t,o,r,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,codeId:e};return Z(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:o,onSuccess:p=>Promise.resolve(r==null?void 0:r(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,instantiateContract:u.mutate,instantiateContractAsync:u.mutateAsync,status:u.status}},bo=({contractAddress:e,onError:t,onLoading:o,onSuccess:r})=>{let{data:n}=d(),i=n==null?void 0:n.bech32Address,u=E(["USE_EXECUTE_CONTRACT",t,o,r,e,i],p=>{if(!i)throw new Error("senderAddress is undefined");let m={...p,fee:p.fee??"auto",senderAddress:i,contractAddress:e,memo:p.memo??"",funds:p.funds??[]};return ee(m)},{onError:(p,m)=>Promise.resolve(t==null?void 0:t(p,m)),onMutate:o,onSuccess:p=>Promise.resolve(r==null?void 0:r(p))});return{error:u.error,isLoading:u.isLoading,isSuccess:u.isSuccess,executeContract:u.mutate,executeContractAsync:u.mutateAsync,status:u.status}},jo=(e,t)=>Ae(["USE_QUERY_SMART",e,t],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or queryMsg undefined");return te(e,t)},{enabled:!!e&&!!t}),Do=(e,t)=>Ae(["USE_QUERY_RAW",t,e],({queryKey:[,n]})=>{if(!e||!t)throw new Error("address or key undefined");return ne(e,t)},{enabled:!!e&&!!t});import{QueryClient as gt,QueryClientProvider as yt}from"@tanstack/react-query";import{useEffect as Se}from"react";var dt=()=>{let e=typeof window<"u"&&window.sessionStorage.getItem(g)==="Active",{activeChain:t,_reconnect:o,_onReconnectFailed:r,_reconnectConnector:n}=c();return Se(()=>{e&&t?l({onError:r}):!e&&o&&l({onError:r})},[]),Se(()=>{if(n)return window.addEventListener(n==="keplr"?"keplr_keystorechange":"leap_keystorechange",()=>void l({onError:r})),()=>{window.removeEventListener(n==="keplr"?"keplr_keystorechange":"leap_keystorechange",()=>void l({onError:r}))}},[n]),null},Ee=()=>(dt(),null);import{jsx as ft,jsxs as xt}from"react/jsx-runtime";var Ct=new gt({}),Mo=({children:e,grazOptions:t,...o})=>(t&&V(t),xt(yt,{client:Ct,...o,children:[ft(Ee,{}),e]}));export{Ee as GrazEvents,Mo as GrazProvider,K as WALLET_TYPES,z as WalletType,y as checkWallet,N as clearRecentChain,V as configureGraz,f as connect,A as createClients,F as createQueryClient,S as createSigningClients,bn as defineChain,jn as defineChainInfo,ye as defineChains,b as disconnect,ee as executeContract,H as getActiveChainCurrency,qt as getAvailableWallets,J as getBalanceStaked,Y as getBalances,ve as getKeplr,Ge as getLeap,ne as getQueryRaw,te as getQuerySmart,Ht as getRecentChain,C as getWallet,Z as instantiateContract,Dn as mainnetChains,kn as mainnetChainsArray,l as reconnect,X as sendIbcTokens,$ as sendTokens,j as suggestChain,L as suggestChainAndConnect,Tn as testnetChains,In as testnetChainsArray,d as useAccount,Zn as useActiveChain,eo as useActiveChainCurrency,to as useActiveChainValidators,_n as useBalance,Ln as useBalanceStaked,pt as useBalances,Un as useCheckKeplr,x as useCheckWallet,go as useClients,Pn as useConnect,Nn as useDisconnect,bo as useExecuteContract,dt as useGrazEvents,wo as useInstantiateContract,mt as useOfflineSigners,ao as useQueryClient,Do as useQueryRaw,jo as useQuerySmart,no as useRecentChain,Eo as useSendIbcTokens,So as useSendTokens,Hn as useSigners,yo as useSigningClients,oo as useSuggestChain,so as useSuggestChainAndConnect};
|
package/dist/keplr.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var t=(f,o,p,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let m of c(o))!d.call(f,m)&&m!==p&&a(f,m,{get:()=>o[m],enumerable:!(x=b(o,m))||x.enumerable});return f},e=(f,o,p)=>(t(f,o,"default"),p&&t(p,o,"default"));var g=f=>t(a({},"__esModule",{value:!0}),f);var r={};module.exports=g(r);e(r,require("@keplr-wallet/cosmos"),module.exports);e(r,require("@keplr-wallet/types"),module.exports);0&&(module.exports={...require("@keplr-wallet/cosmos"),...require("@keplr-wallet/types")});
|
package/dist/tendermint.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var
|
|
1
|
+
"use strict";var a=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var d=Object.prototype.hasOwnProperty;var p=(r,o,f,x)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of c(o))!d.call(r,e)&&e!==f&&a(r,e,{get:()=>o[e],enumerable:!(x=b(o,e))||x.enumerable});return r},t=(r,o,f)=>(p(r,o,"default"),f&&p(f,o,"default"));var g=r=>p(a({},"__esModule",{value:!0}),r);var m={};module.exports=g(m);t(m,require("@cosmjs/tendermint-rpc"),module.exports);0&&(module.exports={...require("@cosmjs/tendermint-rpc")});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "graz",
|
|
3
3
|
"description": "React hooks for Cosmos",
|
|
4
|
-
"version": "0.0.
|
|
4
|
+
"version": "0.0.39",
|
|
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",
|
|
@@ -9,19 +9,6 @@
|
|
|
9
9
|
"main": "./dist/index.js",
|
|
10
10
|
"module": "./dist/index.mjs",
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
|
-
"exports": {
|
|
13
|
-
".": {
|
|
14
|
-
"types": "./dist/index.d.ts",
|
|
15
|
-
"module": "./dist/index.mjs",
|
|
16
|
-
"import": "./dist/index.mjs",
|
|
17
|
-
"default": "./dist/index.js"
|
|
18
|
-
},
|
|
19
|
-
"./chains": {
|
|
20
|
-
"module": "./chains/index.mjs",
|
|
21
|
-
"import": "./chains/index.mjs",
|
|
22
|
-
"default": "./chains/index.js"
|
|
23
|
-
}
|
|
24
|
-
},
|
|
25
12
|
"bin": {
|
|
26
13
|
"graz": "./cli.mjs"
|
|
27
14
|
},
|
|
@@ -35,23 +22,23 @@
|
|
|
35
22
|
],
|
|
36
23
|
"sideEffects": false,
|
|
37
24
|
"dependencies": {
|
|
38
|
-
"@cosmjs/cosmwasm-stargate": "^0",
|
|
39
|
-
"@cosmjs/launchpad": "^0",
|
|
40
|
-
"@cosmjs/proto-signing": "^0",
|
|
41
|
-
"@cosmjs/stargate": "^0",
|
|
42
|
-
"@cosmjs/tendermint-rpc": "^0",
|
|
43
|
-
"@keplr-wallet/cosmos": "^0",
|
|
44
|
-
"@keplr-wallet/types": "^0",
|
|
45
|
-
"@tanstack/react-query": "^4",
|
|
46
|
-
"arg": "^5",
|
|
25
|
+
"@cosmjs/cosmwasm-stargate": "^0.30.1",
|
|
26
|
+
"@cosmjs/launchpad": "^0.27.1",
|
|
27
|
+
"@cosmjs/proto-signing": "^0.30.1",
|
|
28
|
+
"@cosmjs/stargate": "^0.30.1",
|
|
29
|
+
"@cosmjs/tendermint-rpc": "^0.30.1",
|
|
30
|
+
"@keplr-wallet/cosmos": "^0.11.59",
|
|
31
|
+
"@keplr-wallet/types": "^0.11.59",
|
|
32
|
+
"@tanstack/react-query": "^4.29.5",
|
|
33
|
+
"arg": "^5.0.2",
|
|
47
34
|
"cosmos-directory-client": "0.0.6",
|
|
48
|
-
"zustand": "^4"
|
|
35
|
+
"zustand": "^4.3.8"
|
|
49
36
|
},
|
|
50
37
|
"devDependencies": {
|
|
51
|
-
"@types/node": "^16",
|
|
52
|
-
"@types/react": "^18",
|
|
53
|
-
"react": "^18",
|
|
54
|
-
"typescript": "^4"
|
|
38
|
+
"@types/node": "^18.16.3",
|
|
39
|
+
"@types/react": "^18.2.5",
|
|
40
|
+
"react": "^18.2.0",
|
|
41
|
+
"typescript": "^5.0.4"
|
|
55
42
|
},
|
|
56
43
|
"peerDependencies": {
|
|
57
44
|
"react": ">=17"
|
|
@@ -64,11 +51,6 @@
|
|
|
64
51
|
"strangelove-ventures",
|
|
65
52
|
"use-keplr"
|
|
66
53
|
],
|
|
67
|
-
"lint-staged": {
|
|
68
|
-
"**/*.ts": [
|
|
69
|
-
"eslint --fix"
|
|
70
|
-
]
|
|
71
|
-
},
|
|
72
54
|
"license": "MIT",
|
|
73
55
|
"scripts": {
|
|
74
56
|
"build": "tsup",
|
package/dist/chunk-ETISV7IF.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var n="graz-reconnect-session";export{n as a};
|