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