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