@quirks/store
Version:
135 lines (134 loc) • 3.68 kB
JavaScript
import { store as u } from "./index2.js";
import { assertIsDefined as g, getEndpoint as p, getGasPrice as _, estimateFee as b, openWCDeeplink as v } from "@quirks/core";
import { getChain as D, getAddress as x } from "./index7.js";
function P(t, e = "auto") {
const n = u.getState();
switch (g(n.wallet, "wallet is undefined"), e) {
case "auto":
return n.wallet.getOfflineSignerAuto(t, n.signOptions);
case "amino":
return n.wallet.getOfflineSignerOnlyAmino(t, n.signOptions);
case "direct":
return n.wallet.getOfflineSigner(t, n.signOptions);
}
}
async function q(t, e, n = "auto", i = "auto", l, w, r, c = 1.4, S) {
var A;
const s = u.getState();
g(s.wallet, "wallet is undefined");
const o = typeof t == "string" ? D(t) : t;
g(o);
const f = typeof t == "string" ? p(t, s.chains) : p(t), d = typeof t == "string" ? x(t) : S;
g(d);
const k = await P(o.chain_id, i);
let a;
const y = (A = s.signerOptions) == null ? void 0 : A.signingStargate;
y && (a = await y(o));
const W = await import("@cosmjs/stargate"), m = await (W.SigningStargateClient ?? W.default.SigningStargateClient).connectWithSigner(
f.rpc.address,
k,
a
);
if (n === "auto") {
let C = a == null ? void 0 : a.gasPrice;
C || (C = await _(o)), n = await b(
m,
d,
e,
C,
l,
c
);
}
return v(s.wallet, s.openDeeplink), m.sign(
d,
e,
n,
l ?? "",
w,
r
);
}
async function z(t, e, n = "auto", i = "auto", l, w, r, c = 1.4, S) {
var A;
const s = u.getState();
g(s.wallet);
const o = typeof t == "string" ? D(t) : t;
g(o);
const f = typeof t == "string" ? p(t, s.chains) : p(t), d = typeof t == "string" ? x(t) : S;
g(d);
const k = await P(o.chain_id, i);
let a;
const y = (A = s.signerOptions) == null ? void 0 : A.signingCosmwasm;
y && (a = await y(o));
const W = await import("@cosmjs/cosmwasm-stargate"), m = await (W.SigningCosmWasmClient ?? W.default.SigningCosmWasmClient).connectWithSigner(
f.rpc.address,
k,
a
);
if (n === "auto") {
let C = a == null ? void 0 : a.gasPrice;
C || (C = await _(o)), n = await b(
m,
d,
e,
C,
l,
c
);
}
return v(s.wallet, s.openDeeplink), m.sign(
d,
e,
n,
l ?? "",
w,
r
);
}
function B(t, e, n) {
const i = u.getState();
return g(i.wallet), v(i.wallet, i.openDeeplink), i.wallet.signArbitrary(t, e, n);
}
async function H(t, e = "auto") {
var f;
const n = u.getState();
g(n.wallet, "wallet is undefined");
const i = typeof t == "string" ? D(t) : t;
g(i);
const l = typeof t == "string" ? p(t, n.chains) : p(t), w = await P(i.chain_id, e);
let r;
const c = (f = n.signerOptions) == null ? void 0 : f.signingStargate;
c && (r = await c(i));
const S = await import("@cosmjs/stargate");
return await (S.SigningStargateClient ?? S.default.SigningStargateClient).connectWithSigner(
l.rpc.address,
w,
r
);
}
async function J(t, e = "auto") {
var f;
const n = u.getState();
g(n.wallet);
const i = typeof t == "string" ? D(t) : t;
g(i);
const l = typeof t == "string" ? p(t, n.chains) : p(t), w = await P(i.chain_id, e);
let r;
const c = (f = n.signerOptions) == null ? void 0 : f.signingCosmwasm;
c && (r = await c(i));
const S = await import("@cosmjs/cosmwasm-stargate");
return await (S.SigningCosmWasmClient ?? S.default.SigningCosmWasmClient).connectWithSigner(
l.rpc.address,
w,
r
);
}
export {
P as getOfflineSigner,
J as getSigningCosmWasmClient,
H as getSigningStargateClient,
q as sign,
B as signArbitrary,
z as signCW
};