UNPKG

@quirks/store

Version:
2 lines (1 loc) 3.76 kB
"use strict";var b=Object.create;var P=Object.defineProperty;var v=Object.getOwnPropertyDescriptor;var _=Object.getOwnPropertyNames;var q=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var G=(t,i,n,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let g of _(i))!F.call(t,g)&&g!==n&&P(t,g,{get:()=>i[g],enumerable:!(s=v(i,g))||s.enumerable});return t};var m=(t,i,n)=>(n=t!=null?b(q(t)):{},G(i||!t||!t.__esModule?P(n,"default",{value:t,enumerable:!0}):n,t));Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./index2.cjs"),e=require("@quirks/core"),w=require("./index7.cjs");function E(t,i="auto"){const n=u.store.getState();switch(e.assertIsDefined(n.wallet,"wallet is undefined"),i){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(t,i,n="auto",s="auto",g,S,l,c=1.4,f){var I;const a=u.store.getState();e.assertIsDefined(a.wallet,"wallet is undefined");const o=typeof t=="string"?w.getChain(t):t;e.assertIsDefined(o);const d=typeof t=="string"?e.getEndpoint(t,a.chains):e.getEndpoint(t),p=typeof t=="string"?w.getAddress(t):f;e.assertIsDefined(p);const A=await E(o.chain_id,s);let r;const y=(I=a.signerOptions)==null?void 0:I.signingStargate;y&&(r=await y(o));const W=await import("@cosmjs/stargate"),D=await(W.SigningStargateClient??W.default.SigningStargateClient).connectWithSigner(d.rpc.address,A,r);if(n==="auto"){let C=r==null?void 0:r.gasPrice;C||(C=await e.getGasPrice(o)),n=await e.estimateFee(D,p,i,C,g,c)}return e.openWCDeeplink(a.wallet,a.openDeeplink),D.sign(p,i,n,g??"",S,l)}async function M(t,i,n="auto",s="auto",g,S,l,c=1.4,f){var I;const a=u.store.getState();e.assertIsDefined(a.wallet);const o=typeof t=="string"?w.getChain(t):t;e.assertIsDefined(o);const d=typeof t=="string"?e.getEndpoint(t,a.chains):e.getEndpoint(t),p=typeof t=="string"?w.getAddress(t):f;e.assertIsDefined(p);const A=await E(o.chain_id,s);let r;const y=(I=a.signerOptions)==null?void 0:I.signingCosmwasm;y&&(r=await y(o));const W=await import("@cosmjs/cosmwasm-stargate"),D=await(W.SigningCosmWasmClient??W.default.SigningCosmWasmClient).connectWithSigner(d.rpc.address,A,r);if(n==="auto"){let C=r==null?void 0:r.gasPrice;C||(C=await e.getGasPrice(o)),n=await e.estimateFee(D,p,i,C,g,c)}return e.openWCDeeplink(a.wallet,a.openDeeplink),D.sign(p,i,n,g??"",S,l)}function T(t,i,n){const s=u.store.getState();return e.assertIsDefined(s.wallet),e.openWCDeeplink(s.wallet,s.openDeeplink),s.wallet.signArbitrary(t,i,n)}async function x(t,i="auto"){var d;const n=u.store.getState();e.assertIsDefined(n.wallet,"wallet is undefined");const s=typeof t=="string"?w.getChain(t):t;e.assertIsDefined(s);const g=typeof t=="string"?e.getEndpoint(t,n.chains):e.getEndpoint(t),S=await E(s.chain_id,i);let l;const c=(d=n.signerOptions)==null?void 0:d.signingStargate;c&&(l=await c(s));const f=await import("@cosmjs/stargate");return await(f.SigningStargateClient??f.default.SigningStargateClient).connectWithSigner(g.rpc.address,S,l)}async function z(t,i="auto"){var d;const n=u.store.getState();e.assertIsDefined(n.wallet);const s=typeof t=="string"?w.getChain(t):t;e.assertIsDefined(s);const g=typeof t=="string"?e.getEndpoint(t,n.chains):e.getEndpoint(t),S=await E(s.chain_id,i);let l;const c=(d=n.signerOptions)==null?void 0:d.signingCosmwasm;c&&(l=await c(s));const f=await import("@cosmjs/cosmwasm-stargate");return await(f.SigningCosmWasmClient??f.default.SigningCosmWasmClient).connectWithSigner(g.rpc.address,S,l)}exports.getOfflineSigner=E;exports.getSigningCosmWasmClient=z;exports.getSigningStargateClient=x;exports.sign=j;exports.signArbitrary=T;exports.signCW=M;