edge-currency-accountbased 2.18.8 → 3.0.1

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/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 3.0.1 (2024-01-14)
6
+
7
+ - added: (Cosmos) Add signMessage method
8
+ - added: (Cosmos) Add staked balance query
9
+ - fixed: (Tron) Stop saving zero fee EdgeTransactions
10
+
11
+ ## 3.0.0 (2024-01-06)
12
+
13
+ - changed: Moved FIO staked balances from the balances object to stakingStatus
14
+
5
15
  ## 2.18.8 (2024-01-03)
6
16
 
7
17
  - added: (Optimism) Add Tarot token
@@ -37,7 +47,7 @@
37
47
 
38
48
  ## 2.18.1 (2023-12-18)
39
49
 
40
- added: (Solana) Add BONK
50
+ - added: (Solana) Add BONK
41
51
 
42
52
  ## 2.18.0 (2023-12-15)
43
53
 
@@ -1,2 +1,2 @@
1
- (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[1973],{79014:function(Fe,ne,f){"use strict";f.d(ne,{Q:function(){return K},k:function(){return O}});var q=f(77591),de=f.n(q),L=f(24350),W=f(84564),S=f.n(W),te=f(76714),D=Object.defineProperty,Y=Object.getOwnPropertySymbols,re=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable,Z=(a,k,T)=>k in a?D(a,k,{enumerable:!0,configurable:!0,writable:!0,value:T}):a[k]=T,J=(a,k)=>{for(var T in k||(k={}))re.call(k,T)&&Z(a,T,k[T]);if(Y)for(var T of Y(k))oe.call(k,T)&&Z(a,T,k[T]);return a};function O(a,k,T,w,_=[]){const v=J({},S()(k,{},!0)),G=k.startsWith(`${a.pluginId}://`);if(v.protocol!=null&&(v.protocol=v.protocol.replace(":","")),v.protocol!=null&&v.protocol!==""&&!T[v.protocol])throw new Error(`Uri protocol '${v.protocol}' is not supported for ${a.pluginId}.`);if(v.host===""&&v.pathname==="")throw new Error("Path and host not found in uri.");const B={publicAddress:v.host!==""?v.host:v.pathname.split("/")[0]},H=v.query.label,Q=v.query.message,se=v.query.category;(H!=null||Q!=null||se!=null||G)&&(B.metadata={},B.metadata.name=H,B.metadata.notes=Q,B.metadata.category=se,B.metadata.gateway=G!=null?G:!1);const z=v.query.amount;if(z!=null&&typeof z=="string"){w==null&&(w=a.currencyCode);const j=(0,te.Qs)(w!=null?w:"",a,_);if(j==null)throw new Error("InternalErrorInvalidCurrencyCode");let ee=(0,q.mul)(z,j.multiplier);ee=(0,q.toFixed)(ee,0,0),B.nativeAmount=ee,B.currencyCode=w}return{edgeParsedUri:B,parsedUri:v}}function K(a,k,T){if(a.publicAddress==null)throw new Error("InvalidPublicAddressError");if(T==null&&a.label==null&&a.message==null)return a.publicAddress;{let w="";T!=null&&(w+="amount="+T+"&"),(a.label!=null||a.message!=null)&&(typeof a.label=="string"&&(w+="label="+a.label+"&"),typeof a.message=="string"&&(w+="message="+a.message+"&")),w=w.substr(0,w.length-1);const _={scheme:k,path:a.publicAddress,query:w};return(0,L.qC)(_)}}},94831:function(Fe,ne,f){"use strict";f.r(ne),f.d(ne,{CosmosTools:function(){return Me},makeCurrencyEngine:function(){return On},makeCurrencyTools:function(){return xn}});var q=f(87137),de=f(79562),L=f(28972),W=f(74087),S=f(77591),te=f(2153),D=f(79325),Y=f(20918),re=f(79014),oe=f(76714),Z=f(98994),J=f(33359),O=f(24658),K=f(73034),a=f(82448),k=f(62177);const T=["coin_spent.spender","coin_received.receiver"],w=(0,a.su)({archivedTxLastCheckTime:(0,a.Vk)(a.mH,0),"coin_spent.spender":(0,a.Vk)(a.XC),"coin_received.receiver":(0,a.Vk)(a.XC)}),_=(0,k.jd)((0,a.su)({bech32Address:a.XC,publicKey:a.XC})),v=e=>{const n=(0,a.su)({[`${e}Mnemonic`]:a.XC});return(0,a.W1)(t=>({mnemonic:n(t)[`${e}Mnemonic`]}),t=>({[`${e}Mnemonic`]:t.mnemonic}))},G=(0,a.su)({ninerealmsClientId:(0,a.Zz)(a.XC)}),fe=(0,a.su)({denom:a.XC,amount:a.XC}),B=(0,a.su)({gasFeeCoin:fe,gasLimit:a.XC,unsignedTxHex:a.XC});var H=(e,n,t)=>new Promise((s,o)=>{var r=i=>{try{c(t.next(i))}catch(l){o(l)}},u=i=>{try{c(t.throw(i))}catch(l){o(l)}},c=i=>i.done?s(i.value):Promise.resolve(i.value).then(r,u);c((t=t.apply(e,n)).next())});const Q=(e,n)=>{const t=G(n),s={},o=/{{(.*?)}}/g;for(const[r,u]of Object.entries(e.headers)){const c=o.exec(u);c!=null&&(s[r]=t[c[1]])}return{url:e.url,headers:s}},se=(e,n)=>{const{url:t,headers:s}=n;return{execute:o=>H(void 0,null,function*(){const r={method:"POST",headers:s,body:JSON.stringify(o)};return yield(yield e(t,r)).json()}),disconnect:()=>{}}},z=e=>H(void 0,null,function*(){const n=yield K.Tendermint37Client.create(e);return(yield n.status()).nodeInfo.version.startsWith("0.37.")?n:yield K.Tendermint34Client.create(e)}),j=(e,n)=>H(void 0,null,function*(){const t=yield O.StargateClient.create(yield z(se(e,n))),s=t.forceGetQueryClient(),o=t.forceGetCometClient();return{queryClient:s,stargateClient:t,cometClient:o}}),ee=e=>{var n;const[t,...s]=e.split("."),o=e.includes("/"),r=s.join("."),u=(n=r==null?void 0:r.split("-"))==null?void 0:n[0];return{chain:t,symbol:r,ticker:u,synth:o}},Le=e=>e.reduce((n,t)=>{try{return(0,J.addCoins)(n,t)}catch{}return n}),he=(0,a.Wf)("amount"),We=(0,a.Wf)("receiver"),Je=(0,a.Wf)("spender"),Ke=(0,a.Wf)("amount","receiver","spender"),_e=(0,a.su)({type:(0,a.Wf)("coin_received"),attributes:(0,a.vq)((0,a.su)({key:he,value:a.XC}),(0,a.su)({key:We,value:a.XC}))}),He=(0,a.su)({type:(0,a.Wf)("coin_spent"),attributes:(0,a.vq)((0,a.su)({key:he,value:a.XC}),(0,a.su)({key:Je,value:a.XC}))}),$e=(e,n)=>{const t=new Map;for(const o of e){const r={type:o.type,attributes:o.attributes.filter(i=>(0,a.Vk)(Ke)(i.key)!=null).sort((i,l)=>i.key<l.key?-1:1)},u=(0,a.Vk)(_e)(r);if(u!=null){const[i,l]=u.attributes.map(h=>h.value);if(l!==n)continue;(0,O.parseCoins)(i).forEach(h=>{var y;const g=h.amount,p=(y=t.get(h.denom))!=null?y:"0";t.set(h.denom,(0,S.add)(g,p))});continue}const c=(0,a.Vk)(He)(r);if(c!=null){const[i,l]=c.attributes.map(h=>h.value);if(l!==n)continue;(0,O.parseCoins)(i).forEach(h=>{var y;const g=`-${h.amount}`,p=(y=t.get(h.denom))!=null?y:"0";t.set(h.denom,(0,S.add)(g,p))})}}const s=[];return t.forEach((o,r)=>{o!=="0"&&s.push({denom:r,amount:o})}),s};var Ve=f(43720),P=f.n(Ve),Xe=f(62100),d=f.n(Xe);const Bn="common";function me(){return{chain:"",symbol:"",ticker:"",synth:!1}}const $={encode(e,n=d().Writer.create()){return e.chain!==""&&n.uint32(10).string(e.chain),e.symbol!==""&&n.uint32(18).string(e.symbol),e.ticker!==""&&n.uint32(26).string(e.ticker),e.synth===!0&&n.uint32(32).bool(e.synth),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=me();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.chain=t.string();continue;case 2:if(r!==18)break;o.symbol=t.string();continue;case 3:if(r!==26)break;o.ticker=t.string();continue;case 4:if(r!==32)break;o.synth=t.bool();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{chain:A(e.chain)?globalThis.String(e.chain):"",symbol:A(e.symbol)?globalThis.String(e.symbol):"",ticker:A(e.ticker)?globalThis.String(e.ticker):"",synth:A(e.synth)?globalThis.Boolean(e.synth):!1}},toJSON(e){const n={};return e.chain!==""&&(n.chain=e.chain),e.symbol!==""&&(n.symbol=e.symbol),e.ticker!==""&&(n.ticker=e.ticker),e.synth===!0&&(n.synth=e.synth),n},create(e){return $.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,s,o;const r=me();return r.chain=(n=e.chain)!=null?n:"",r.symbol=(t=e.symbol)!=null?t:"",r.ticker=(s=e.ticker)!=null?s:"",r.synth=(o=e.synth)!=null?o:!1,r}};function ye(){return{asset:void 0,amount:"",decimals:P().ZERO}}const C={encode(e,n=d().Writer.create()){return e.asset!==void 0&&$.encode(e.asset,n.uint32(10).fork()).ldelim(),e.amount!==""&&n.uint32(18).string(e.amount),e.decimals.isZero()||n.uint32(24).int64(e.decimals),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=ye();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.asset=$.decode(t,t.uint32());continue;case 2:if(r!==18)break;o.amount=t.string();continue;case 3:if(r!==24)break;o.decimals=t.int64();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{asset:A(e.asset)?$.fromJSON(e.asset):void 0,amount:A(e.amount)?globalThis.String(e.amount):"",decimals:A(e.decimals)?P().fromValue(e.decimals):P().ZERO}},toJSON(e){const n={};return e.asset!==void 0&&(n.asset=$.toJSON(e.asset)),e.amount!==""&&(n.amount=e.amount),e.decimals.isZero()||(n.decimals=(e.decimals||P().ZERO).toString()),n},create(e){return C.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=ye();return t.asset=e.asset!==void 0&&e.asset!==null?$.fromPartial(e.asset):void 0,t.amount=(n=e.amount)!=null?n:"",t.decimals=e.decimals!==void 0&&e.decimals!==null?P().fromValue(e.decimals):P().ZERO,t}};function ge(){return{secp256k1:"",ed25519:""}}const qe={encode(e,n=d().Writer.create()){return e.secp256k1!==""&&n.uint32(10).string(e.secp256k1),e.ed25519!==""&&n.uint32(18).string(e.ed25519),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=ge();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.secp256k1=t.string();continue;case 2:if(r!==18)break;o.ed25519=t.string();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{secp256k1:A(e.secp256k1)?globalThis.String(e.secp256k1):"",ed25519:A(e.ed25519)?globalThis.String(e.ed25519):""}},toJSON(e){const n={};return e.secp256k1!==""&&(n.secp256k1=e.secp256k1),e.ed25519!==""&&(n.ed25519=e.ed25519),n},create(e){return qe.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const s=ge();return s.secp256k1=(n=e.secp256k1)!=null?n:"",s.ed25519=(t=e.ed25519)!=null?t:"",s}};function pe(){return{id:"",chain:"",fromAddress:"",toAddress:"",coins:[],gas:[],memo:""}}const Ye={encode(e,n=d().Writer.create()){e.id!==""&&n.uint32(10).string(e.id),e.chain!==""&&n.uint32(18).string(e.chain),e.fromAddress!==""&&n.uint32(26).string(e.fromAddress),e.toAddress!==""&&n.uint32(34).string(e.toAddress);for(const t of e.coins)C.encode(t,n.uint32(42).fork()).ldelim();for(const t of e.gas)C.encode(t,n.uint32(50).fork()).ldelim();return e.memo!==""&&n.uint32(58).string(e.memo),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=pe();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.id=t.string();continue;case 2:if(r!==18)break;o.chain=t.string();continue;case 3:if(r!==26)break;o.fromAddress=t.string();continue;case 4:if(r!==34)break;o.toAddress=t.string();continue;case 5:if(r!==42)break;o.coins.push(C.decode(t,t.uint32()));continue;case 6:if(r!==50)break;o.gas.push(C.decode(t,t.uint32()));continue;case 7:if(r!==58)break;o.memo=t.string();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{id:A(e.id)?globalThis.String(e.id):"",chain:A(e.chain)?globalThis.String(e.chain):"",fromAddress:A(e.fromAddress)?globalThis.String(e.fromAddress):"",toAddress:A(e.toAddress)?globalThis.String(e.toAddress):"",coins:globalThis.Array.isArray(e==null?void 0:e.coins)?e.coins.map(n=>C.fromJSON(n)):[],gas:globalThis.Array.isArray(e==null?void 0:e.gas)?e.gas.map(n=>C.fromJSON(n)):[],memo:A(e.memo)?globalThis.String(e.memo):""}},toJSON(e){var n,t;const s={};return e.id!==""&&(s.id=e.id),e.chain!==""&&(s.chain=e.chain),e.fromAddress!==""&&(s.fromAddress=e.fromAddress),e.toAddress!==""&&(s.toAddress=e.toAddress),(n=e.coins)!=null&&n.length&&(s.coins=e.coins.map(o=>C.toJSON(o))),(t=e.gas)!=null&&t.length&&(s.gas=e.gas.map(o=>C.toJSON(o))),e.memo!==""&&(s.memo=e.memo),s},create(e){return Ye.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,s,o,r,u,c;const i=pe();return i.id=(n=e.id)!=null?n:"",i.chain=(t=e.chain)!=null?t:"",i.fromAddress=(s=e.fromAddress)!=null?s:"",i.toAddress=(o=e.toAddress)!=null?o:"",i.coins=((r=e.coins)==null?void 0:r.map(l=>C.fromPartial(l)))||[],i.gas=((u=e.gas)==null?void 0:u.map(l=>C.fromPartial(l)))||[],i.memo=(c=e.memo)!=null?c:"",i}};function ve(){return{coins:[],poolDeduct:""}}const Ze={encode(e,n=d().Writer.create()){for(const t of e.coins)C.encode(t,n.uint32(10).fork()).ldelim();return e.poolDeduct!==""&&n.uint32(18).string(e.poolDeduct),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=ve();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.coins.push(C.decode(t,t.uint32()));continue;case 2:if(r!==18)break;o.poolDeduct=t.string();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{coins:globalThis.Array.isArray(e==null?void 0:e.coins)?e.coins.map(n=>C.fromJSON(n)):[],poolDeduct:A(e.poolDeduct)?globalThis.String(e.poolDeduct):""}},toJSON(e){var n;const t={};return(n=e.coins)!=null&&n.length&&(t.coins=e.coins.map(s=>C.toJSON(s))),e.poolDeduct!==""&&(t.poolDeduct=e.poolDeduct),t},create(e){return Ze.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const s=ve();return s.coins=((n=e.coins)==null?void 0:n.map(o=>C.fromPartial(o)))||[],s.poolDeduct=(t=e.poolDeduct)!=null?t:"",s}};function Ce(){return{value:""}}const Ge={encode(e,n=d().Writer.create()){return e.value!==""&&n.uint32(10).string(e.value),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=Ce();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.value=t.string();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{value:A(e.value)?globalThis.String(e.value):""}},toJSON(e){const n={};return e.value!==""&&(n.value=e.value),n},create(e){return Ge.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=Ce();return t.value=(n=e.value)!=null?n:"",t}};d().util.Long!==P()&&(d().util.Long=P(),d().configure());function A(e){return e!=null}const Nn="types";function ke(){return{coins:[],memo:"",signer:new Uint8Array(0)}}const ie={encode(e,n=d().Writer.create()){for(const t of e.coins)C.encode(t,n.uint32(10).fork()).ldelim();return e.memo!==""&&n.uint32(18).string(e.memo),e.signer.length!==0&&n.uint32(26).bytes(e.signer),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=ke();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.coins.push(C.decode(t,t.uint32()));continue;case 2:if(r!==18)break;o.memo=t.string();continue;case 3:if(r!==26)break;o.signer=t.bytes();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{coins:globalThis.Array.isArray(e==null?void 0:e.coins)?e.coins.map(n=>C.fromJSON(n)):[],memo:Te(e.memo)?globalThis.String(e.memo):"",signer:Te(e.signer)?Qe(e.signer):new Uint8Array(0)}},toJSON(e){var n;const t={};return(n=e.coins)!=null&&n.length&&(t.coins=e.coins.map(s=>C.toJSON(s))),e.memo!==""&&(t.memo=e.memo),e.signer.length!==0&&(t.signer=ze(e.signer)),t},create(e){return ie.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,s;const o=ke();return o.coins=((n=e.coins)==null?void 0:n.map(r=>C.fromPartial(r)))||[],o.memo=(t=e.memo)!=null?t:"",o.signer=(s=e.signer)!=null?s:new Uint8Array(0),o}};function Qe(e){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(e,"base64"));{const n=globalThis.atob(e),t=new Uint8Array(n.length);for(let s=0;s<n.length;++s)t[s]=n.charCodeAt(s);return t}}function ze(e){if(globalThis.Buffer)return globalThis.Buffer.from(e).toString("base64");{const n=[];return e.forEach(t=>{n.push(globalThis.String.fromCharCode(t))}),globalThis.btoa(n.join(""))}}d().util.Long!==P()&&(d().util.Long=P(),d().configure());function Te(e){return e!=null}const Un="cosmos.base.v1beta1";function Ae(){return{denom:"",amount:""}}const V={encode(e,n=d().Writer.create()){return e.denom!==""&&n.uint32(10).string(e.denom),e.amount!==""&&n.uint32(18).string(e.amount),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=Ae();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.denom=t.string();continue;case 2:if(r!==18)break;o.amount=t.string();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{denom:X(e.denom)?globalThis.String(e.denom):"",amount:X(e.amount)?globalThis.String(e.amount):""}},toJSON(e){const n={};return e.denom!==""&&(n.denom=e.denom),e.amount!==""&&(n.amount=e.amount),n},create(e){return V.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const s=Ae();return s.denom=(n=e.denom)!=null?n:"",s.amount=(t=e.amount)!=null?t:"",s}};function we(){return{denom:"",amount:""}}const je={encode(e,n=d().Writer.create()){return e.denom!==""&&n.uint32(10).string(e.denom),e.amount!==""&&n.uint32(18).string(e.amount),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=we();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.denom=t.string();continue;case 2:if(r!==18)break;o.amount=t.string();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{denom:X(e.denom)?globalThis.String(e.denom):"",amount:X(e.amount)?globalThis.String(e.amount):""}},toJSON(e){const n={};return e.denom!==""&&(n.denom=e.denom),e.amount!==""&&(n.amount=e.amount),n},create(e){return je.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const s=we();return s.denom=(n=e.denom)!=null?n:"",s.amount=(t=e.amount)!=null?t:"",s}};function be(){return{int:""}}const en={encode(e,n=d().Writer.create()){return e.int!==""&&n.uint32(10).string(e.int),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=be();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.int=t.string();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{int:X(e.int)?globalThis.String(e.int):""}},toJSON(e){const n={};return e.int!==""&&(n.int=e.int),n},create(e){return en.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=be();return t.int=(n=e.int)!=null?n:"",t}};function Pe(){return{dec:""}}const nn={encode(e,n=d().Writer.create()){return e.dec!==""&&n.uint32(10).string(e.dec),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=Pe();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.dec=t.string();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{dec:X(e.dec)?globalThis.String(e.dec):""}},toJSON(e){const n={};return e.dec!==""&&(n.dec=e.dec),n},create(e){return nn.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=Pe();return t.dec=(n=e.dec)!=null?n:"",t}};d().util.Long!==P()&&(d().util.Long=P(),d().configure());function X(e){return e!=null}const Rn="types";function Se(){return{fromAddress:new Uint8Array(0),toAddress:new Uint8Array(0),amount:[]}}const ae={encode(e,n=d().Writer.create()){e.fromAddress.length!==0&&n.uint32(10).bytes(e.fromAddress),e.toAddress.length!==0&&n.uint32(18).bytes(e.toAddress);for(const t of e.amount)V.encode(t,n.uint32(26).fork()).ldelim();return n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=Se();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.fromAddress=t.bytes();continue;case 2:if(r!==18)break;o.toAddress=t.bytes();continue;case 3:if(r!==26)break;o.amount.push(V.decode(t,t.uint32()));continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{fromAddress:Ee(e.fromAddress)?Ie(e.fromAddress):new Uint8Array(0),toAddress:Ee(e.toAddress)?Ie(e.toAddress):new Uint8Array(0),amount:globalThis.Array.isArray(e==null?void 0:e.amount)?e.amount.map(n=>V.fromJSON(n)):[]}},toJSON(e){var n;const t={};return e.fromAddress.length!==0&&(t.fromAddress=Oe(e.fromAddress)),e.toAddress.length!==0&&(t.toAddress=Oe(e.toAddress)),(n=e.amount)!=null&&n.length&&(t.amount=e.amount.map(s=>V.toJSON(s))),t},create(e){return ae.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,s;const o=Se();return o.fromAddress=(n=e.fromAddress)!=null?n:new Uint8Array(0),o.toAddress=(t=e.toAddress)!=null?t:new Uint8Array(0),o.amount=((s=e.amount)==null?void 0:s.map(r=>V.fromPartial(r)))||[],o}};function Ie(e){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(e,"base64"));{const n=globalThis.atob(e),t=new Uint8Array(n.length);for(let s=0;s<n.length;++s)t[s]=n.charCodeAt(s);return t}}function Oe(e){if(globalThis.Buffer)return globalThis.Buffer.from(e).toString("base64");{const n=[];return e.forEach(t=>{n.push(globalThis.String.fromCharCode(t))}),globalThis.btoa(n.join(""))}}d().util.Long!==P()&&(d().util.Long=P(),d().configure());function Ee(e){return e!=null}var tn=Object.defineProperty,rn=Object.defineProperties,on=Object.getOwnPropertyDescriptors,xe=Object.getOwnPropertySymbols,sn=Object.prototype.hasOwnProperty,an=Object.prototype.propertyIsEnumerable,De=(e,n,t)=>n in e?tn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,cn=(e,n)=>{for(var t in n||(n={}))sn.call(n,t)&&De(e,t,n[t]);if(xe)for(var t of xe(n))an.call(n,t)&&De(e,t,n[t]);return e},ln=(e,n)=>rn(e,on(n));const un=e=>{const n=new W.Registry;let t=s=>{const{amount:o,fromAddress:r,toAddress:u}=s;return{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Z.MsgSend.encode(Z.MsgSend.fromPartial({fromAddress:r,toAddress:u,amount:o})).finish()}};switch(e){case"thorchainrune":{const s="/types.MsgDeposit";n.register(s,ie);const o=u=>{const{assets:c,memo:i,signer:l}=u,m=c.map(y=>ln(cn({},y),{asset:ee(y.asset)}));return{typeUrl:s,value:ie.encode(ie.fromPartial({coins:m,memo:i,signer:(0,L.fromBech32)(l).data})).finish()}},r="/types.MsgSend";return n.register(r,ae),t=u=>{const{amount:c,fromAddress:i,toAddress:l}=u;return{typeUrl:r,value:ae.encode(ae.fromPartial({fromAddress:(0,L.fromBech32)(i).data,toAddress:(0,L.fromBech32)(l).data,amount:c})).finish()}},{methods:{deposit:o,transfer:t},registry:n}}}return{methods:{transfer:t},registry:n}};var dn=f(7416),fn=f(45504),R=f(29639),hn=f(94935),mn=f(84650),yn=f(72681),gn=Object.defineProperty,pn=Object.defineProperties,vn=Object.getOwnPropertyDescriptors,Be=Object.getOwnPropertySymbols,Cn=Object.getPrototypeOf,kn=Object.prototype.hasOwnProperty,Tn=Object.prototype.propertyIsEnumerable,An=Reflect.get,Ne=(e,n,t)=>n in e?gn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,wn=(e,n)=>{for(var t in n||(n={}))kn.call(n,t)&&Ne(e,t,n[t]);if(Be)for(var t of Be(n))Tn.call(n,t)&&Ne(e,t,n[t]);return e},bn=(e,n)=>pn(e,vn(n)),Ue=(e,n,t)=>An(Cn(e),t,n),b=(e,n,t)=>new Promise((s,o)=>{var r=i=>{try{c(t.next(i))}catch(l){o(l)}},u=i=>{try{c(t.throw(i))}catch(l){o(l)}},c=i=>i.done?s(i.value):Promise.resolve(i.value).then(r,u);c((t=t.apply(e,n)).next())});const Re=5e3,Pn=3e3,Sn=1e3*60*60*24*14,In=1e3*60*2;class ce extends mn.P{constructor(n,t,s,o){super(n,t,s,o),this.networkInfo=n.networkInfo,this.fetchCors=n.io.fetchCors,this.accountNumber=0,this.sequence=0,this.unconfirmedTransactionCache={cacheSequence:0,txids:new Map},this.feeCache=new Map,this.otherMethods={getMaxTx:r=>b(this,null,function*(){switch(r.type){case"MakeTxDeposit":{if(this.tools.methods.deposit==null)throw new Error(`${this.currencyInfo.displayName} does not support the deposit method`);const{assets:u,memo:c}=r;if(u.length!==1)throw new Error("Cannot calculate max tx for more than one asset");const i=this.tools.methods.deposit({assets:u,memo:c,signer:this.walletInfo.keys.bech32Address}),{networkFee:l}=yield this.calculateFee({messages:[i],memo:c}),m=this.getBalance({currencyCode:this.currencyInfo.currencyCode});return(0,S.sub)(m,l)}default:throw new Error(`Invalid type: ${r.type}`)}}),makeTx:r=>b(this,null,function*(){switch(r.type){case"MakeTxDeposit":{if(this.tools.methods.deposit==null)throw new Error(`${this.currencyInfo.displayName} does not support the deposit method`);const{assets:u,memo:c,metadata:i}=r,l=this.tools.methods.deposit({assets:u,memo:c,signer:this.walletInfo.keys.bech32Address}),m=this.createUnsignedTxHex([l],c),{gasFeeCoin:h,gasLimit:y,networkFee:g}=yield this.calculateFee({messages:[l],memo:c}),p={gasFeeCoin:h,gasLimit:y,unsignedTxHex:m};return{blockHeight:0,currencyCode:this.currencyInfo.currencyCode,date:Date.now()/1e3,isSend:!0,memos:[],metadata:i,nativeAmount:`-${g}`,networkFee:g,otherParams:p,ourReceiveAddresses:[],signedTx:"",txid:"",walletId:this.walletId}}default:throw new Error(`Invalid type: ${r.type}`)}})}}setOtherData(n){this.otherData=w(n)}getClients(){if(this.tools.clients==null)throw new Error("No StargateClient");return this.tools.clients}queryBalance(){return b(this,null,function*(){var n;try{const{stargateClient:t}=this.getClients(),s=yield t.getAllBalances(this.walletInfo.keys.bech32Address),o=s.find(c=>c.denom===this.networkInfo.nativeDenom);this.updateBalance(this.currencyInfo.currencyCode,(n=o==null?void 0:o.amount)!=null?n:"0"),this.enabledTokenIds.forEach(c=>{var i;const l=this.allTokensMap[c],m=s.find(h=>h.denom===c);this.updateBalance(l.currencyCode,(i=m==null?void 0:m.amount)!=null?i:"0")});const{accountNumber:r,sequence:u}=yield t.getSequence(this.walletInfo.keys.bech32Address);this.accountNumber=r,this.sequence=u}catch(t){String(t).includes("does not exist on chain")?this.updateBalance(this.currencyInfo.currencyCode,"0"):this.log.warn("queryBalance error:",t)}})}queryBlockheight(){return b(this,null,function*(){try{const{stargateClient:n}=this.getClients(),t=yield n.getHeight();t>this.walletLocalData.blockHeight&&(this.walletLocalData.blockHeight=t,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight))}catch(n){this.error("queryBlockheight Error ",n)}})}queryTransactions(){return b(this,null,function*(){let n=0;const t=[this.currencyInfo.currencyCode,...this.enabledTokenIds.map(o=>this.allTokensMap[o].currencyCode)],s=Date.now()-Sn>this.otherData.archivedTxLastCheckTime?yield j(this.fetchCors,Q(this.networkInfo.archiveNode,this.tools.initOptions)):this.getClients();for(const o of T){const r=yield this.queryTransactionsInner(o,s);r!=null&&this.otherData[o]!==r&&(this.otherData[o]=r,this.walletLocalDataDirty=!0),n+=.5,t.forEach(u=>this.tokenCheckTransactionsStatus[u]=n),this.updateOnAddressesChecked()}this.otherData.archivedTxLastCheckTime=Date.now(),this.transactionsChangedArray.length>0&&(this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[])})}queryTransactionsInner(n,t){return b(this,null,function*(){const s={query:`${n}='${this.walletInfo.keys.bech32Address}'`,per_page:50,order_by:"desc"};let o,r=0,u,c=0,i=!1;try{do{const l=yield t.cometClient.txSearch(bn(wn({},s),{page:++r})),{totalCount:m,txs:h}=l;u==null&&(u=m),c=c+h.length;for(const y of h){const g=(0,L.toHex)(y.hash).toUpperCase();if(this.removeFromUnconfirmedCache(g),o==null&&(o=g),g===this.otherData[n]){i=!0;break}const p=y.result.events.map(O.fromTendermintEvent),E=$e(p,this.walletInfo.keys.bech32Address);if(E.length===0)continue;const x=yield t.stargateClient.getBlock(y.height),U=(0,K.toSeconds)((0,K.fromRfc3339WithNanoseconds)(x.header.time)).seconds,{height:M,tx:N}=y,le=D.YU.stringify(N),{authInfo:{fee:F},body:{memo:ue}}=(0,W.decodeTxRaw)(N);E.forEach(Dn=>{this.processCosmosTransaction(g,U,le,Dn,ue,M,F)})}}while(u>c&&!i)}catch(l){throw this.log.warn("queryTransactions error:",l),l}return o})}processCosmosTransaction(n,t,s,o,r,u,c){var i,l;const{amount:m,denom:h}=o,y=this.networkInfo.nativeDenom===h,g=this.networkInfo.nativeDenom===h?this.currencyInfo.currencyCode:this.allTokensMap[h]!=null?this.allTokensMap[h].currencyCode:void 0;if(g==null)return;let p=(l=(i=this.networkInfo.defaultTransactionFee)==null?void 0:i.amount)!=null?l:"0";if(c!=null){const{amount:F}=c,ue=Le([(0,O.coin)("0",this.networkInfo.nativeDenom),...F]);p=(0,S.add)(p,ue.amount)}const E=(0,S.lt)(m,"0"),x=[];let U=m,M;E?y?U=(0,S.sub)(U,p):(p="0",M=p):(x.push(this.walletInfo.keys.bech32Address),p="0");const N=[];r!==""&&N.push({type:"text",value:r});const le={blockHeight:u,currencyCode:g,date:t,isSend:E,memos:N,nativeAmount:U,networkFee:p,ourReceiveAddresses:x,parentNetworkFee:M,signedTx:s,txid:n,walletId:this.walletId};this.addTransaction(g,le)}createUnsignedTxHex(n,t){const s=R.TxBody.fromPartial({messages:n,memo:t}),o=R.TxBody.encode(s).finish(),r=R.TxRaw.fromPartial({bodyBytes:o});return D.YU.stringify(R.TxRaw.encode(r).finish())}addToUnconfirmedCache(n){const t=new Date(new Date().getTime()+In);this.unconfirmedTransactionCache.txids.size===0&&(this.unconfirmedTransactionCache.cacheSequence=this.sequence),this.unconfirmedTransactionCache.txids.set(n,t)}removeFromUnconfirmedCache(n){this.unconfirmedTransactionCache.txids.has(n)&&(this.unconfirmedTransactionCache.cacheSequence=this.unconfirmedTransactionCache.cacheSequence+1,this.sequence=this.unconfirmedTransactionCache.cacheSequence,this.unconfirmedTransactionCache.txids.delete(n))}getSequence(){return this.unconfirmedTransactionCache.txids.size===0?this.sequence:[...this.unconfirmedTransactionCache.txids.values()].some(n=>n<new Date)?(this.unconfirmedTransactionCache.txids=new Map,this.sequence):this.unconfirmedTransactionCache.cacheSequence+this.unconfirmedTransactionCache.txids.size}calculateFee(n){return b(this,null,function*(){let t=(0,O.coin)("0",this.networkInfo.nativeDenom),s="0",o="0";if(this.networkInfo.defaultTransactionFee==null){const{messages:r,memo:u,networkFeeOption:c}=n,{queryClient:i}=this.getClients(),{gasInfo:l}=yield i.tx.simulate(r,u,(0,J.encodeSecp256k1Pubkey)(D.YU.parse(this.walletInfo.keys.publicKey)),this.getSequence());if((l==null?void 0:l.gasUsed)==null)throw new Error("simulate didn't return gasUsed ");s=(0,S.ceil)((0,S.mul)(l==null?void 0:l.gasUsed.toString(),"1.5"),0);const{low:m,average:h,high:y}=(0,dn.getGasPriceStep)(this.tools.chainData);let g=h;switch(c){case"low":{g=m;break}case"high":{g=y;break}case"custom":throw new Error("Custom fee not supported")}const p=(0,S.ceil)((0,S.mul)(s,g.toString()),0);t=(0,O.coin)(p,this.networkInfo.nativeDenom),o=t.amount}else o=this.networkInfo.defaultTransactionFee.amount;return{gasFeeCoin:t,gasLimit:s,networkFee:o}})}startEngine(){return b(this,null,function*(){this.engineOn=!0,yield this.tools.connectClient(),this.addToLoop("queryBalance",Re).catch(()=>{}),this.addToLoop("queryBlockheight",Re).catch(()=>{}),this.addToLoop("queryTransactions",Pn).catch(()=>{}),yield Ue(ce.prototype,this,"startEngine").call(this)})}killEngine(){return b(this,null,function*(){yield this.tools.disconnectClient(),yield Ue(ce.prototype,this,"killEngine").call(this)})}resyncBlockchain(){return b(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}makeSpend(n){return b(this,null,function*(){var t;n=(0,yn.s)(n,this.currencyInfo);const{edgeSpendInfo:s,currencyCode:o}=this.makeSpendCheck(n),{memos:r=[],networkFeeOption:u,tokenId:c}=s,i=(t=r[0])==null?void 0:t.value;if(s.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{nativeAmount:l,publicAddress:m}=s.spendTargets[0];if(l==null)throw new hn.$D;if(m==null)throw new Error("makeSpend Missing publicAddress");const h=this.tools.methods.transfer({amount:[(0,O.coin)(l,c!=null?c:this.networkInfo.nativeDenom)],fromAddress:this.walletInfo.keys.bech32Address,toAddress:m});let y,g,p;const E=`${m}${String(u)}`,x=this.feeCache.get(E);if(l==="0")y=(0,O.coin)("0",this.networkInfo.nativeDenom),g="0",p="0";else if(x==null){const F=yield this.calculateFee({messages:[h],memo:i,networkFeeOption:u});y=F.gasFeeCoin,g=F.gasLimit,p=F.networkFee,this.feeCache.set(E,F)}else y=x.gasFeeCoin,g=x.gasLimit,p=x.networkFee;const U=this.createUnsignedTxHex([h],i),M={gasFeeCoin:y,gasLimit:g,unsignedTxHex:U},N=this.makeEdgeTransactionAmounts(l,p,c);return this.checkBalances(N,c),{blockHeight:0,currencyCode:o,date:0,isSend:!0,memos:r,nativeAmount:N.nativeAmount,networkFee:N.networkFee,otherParams:M,ourReceiveAddresses:[],parentNetworkFee:N.parentNetworkFee,signedTx:"",txid:"",walletId:this.walletId}})}signTx(n,t){return b(this,null,function*(){const{gasFeeCoin:s,gasLimit:o,unsignedTxHex:r}=B(n.otherParams),u=v(this.currencyInfo.pluginId)(t),c=D.YU.parse(r),{bodyBytes:i}=R.TxRaw.decode(c),l=D.YU.parse(this.walletInfo.keys.publicKey),m=(0,J.encodeSecp256k1Pubkey)(l),h=(0,W.makeAuthInfoBytes)([{pubkey:(0,W.encodePubkey)(m),sequence:this.getSequence()}],[s],parseInt(o),void 0,void 0,1),y=R.SignDoc.fromPartial({accountNumber:(0,fn.longify)(this.accountNumber),authInfoBytes:h,bodyBytes:i,chainId:this.tools.chainData.chain_id}),p=yield(yield this.tools.createSigner(u.mnemonic)).signDirect(this.walletInfo.keys.bech32Address,y),E=(0,J.decodeSignature)(p.signature),x=R.TxRaw.fromPartial({authInfoBytes:h,bodyBytes:i,signatures:[E.signature]}),U=R.TxRaw.encode(x).finish(),M=D.YU.stringify(U);return n.signedTx=M,n})}broadcastTx(n){return b(this,null,function*(){try{const t=D.YU.parse(n.signedTx),{stargateClient:s}=this.getClients(),o=yield s.broadcastTxSync(t);return this.warn(`SUCCESS broadcastTx
2
- ${(0,oe.oX)(n)}`),n.txid=o,n.date=Date.now()/1e3,this.addToUnconfirmedCache(o),n}catch(t){throw this.warn("FAILURE broadcastTx failed: ",t),t}})}getFreshAddress(n){return b(this,null,function*(){const{bech32Address:t}=this.walletInfo.keys;return{publicAddress:t}})}}function On(e,n,t,s){return b(this,null,function*(){const o=_(t),r=new ce(e,n,o,s);return yield r.loadEngine(),r})}var En=f(48764).Buffer,I=(e,n,t)=>new Promise((s,o)=>{var r=i=>{try{c(t.next(i))}catch(l){o(l)}},u=i=>{try{c(t.throw(i))}catch(l){o(l)}},c=i=>i.done?s(i.value):Promise.resolve(i.value).then(r,u);c((t=t.apply(e,n)).next())});class Me{constructor(n){const{builtinTokens:t,currencyInfo:s,initOptions:o,io:r,networkInfo:u}=n;this.io=r,this.currencyInfo=s,this.builtinTokens=t,this.networkInfo=u,this.initOptions=o,this.clientCount=0;const{methods:c,registry:i}=un(s.pluginId);this.methods=c,this.registry=i;const{data:l,name:m,url:h}=this.networkInfo.chainInfo;this.chainData=l;const y=new q.ChainRegistryFetcher;y.fetch(h).then(()=>{this.chainData=y.getChain(m)}).catch(g=>{})}createSigner(n){return I(this,null,function*(){const{bech32AddressPrefix:t,bip39Path:s}=this.networkInfo,o=(0,de.stringToPath)(s);return yield W.DirectSecp256k1HdWallet.fromMnemonic(n,{hdPaths:[o],prefix:t})})}getDisplayPrivateKey(n){return I(this,null,function*(){const{pluginId:t}=this.currencyInfo;return v(t)(n.keys).mnemonic})}getDisplayPublicKey(n){return I(this,null,function*(){const{keys:t}=_(n);return t.publicKey})}importPrivateKey(n){return I(this,null,function*(){if(!(0,te.validateMnemonic)(n))throw new Error("Invalid mnemonic");return yield this.createSigner(n),{[this.networkInfo.pluginMnemonicKeyName]:n}})}createPrivateKey(n){return I(this,null,function*(){if(n!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const t=En.from(this.io.random(32)),s=(0,te.entropyToMnemonic)(t);return yield this.importPrivateKey(s)})}derivePublicKey(n){return I(this,null,function*(){if(n.type!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const{mnemonic:t}=v(this.currencyInfo.pluginId)(n.keys),o=yield(yield this.createSigner(t)).getAccounts(),{address:r,pubkey:u}=o[0],c=D.YU.stringify(u);return{bech32Address:r,publicKey:c}})}isValidAddress(n){try{if((0,L.fromBech32)(n).prefix===this.networkInfo.bech32AddressPrefix)return!0}catch{}return!1}parseUri(n,t,s){return I(this,null,function*(){const{pluginId:o}=this.currencyInfo,r={[o]:!0},{parsedUri:u,edgeParsedUri:c}=(0,re.k)(this.currencyInfo,n,r,t!=null?t:this.currencyInfo.currencyCode,s);let i="";if(c.publicAddress!=null&&(i=c.publicAddress),!this.isValidAddress(i))throw new Error("InvalidPublicAddressError");return c.uniqueIdentifier=u.query.memo,c})}encodeUri(n){return I(this,arguments,function*(t,s=[]){const{pluginId:o}=this.currencyInfo,{nativeAmount:r,currencyCode:u,publicAddress:c}=t;if(!this.isValidAddress(c))throw new Error("InvalidPublicAddressError");let i;if(typeof r=="string"){const m=(0,oe.Qs)(u!=null?u:this.currencyInfo.currencyCode,this.currencyInfo,s);if(m==null)throw new Error("InternalErrorInvalidCurrencyCode");i=(0,S.div)(r,m.multiplier,18)}return(0,re.Q)(t,o,i)})}connectClient(){return I(this,null,function*(){this.clients==null&&(this.clients=yield j(this.io.fetchCors,Q(this.networkInfo.rpcNode,this.initOptions))),++this.clientCount})}disconnectClient(){return I(this,null,function*(){var n,t;--this.clientCount,this.clientCount===0&&(yield(t=(n=this.clients)==null?void 0:n.stargateClient)==null?void 0:t.disconnect(),this.clients=void 0)})}getTokenId(n){return I(this,null,function*(){(0,Y.Rp)(n);const t=(0,Y.Oj)(n.networkLocation);if(t==null)throw new Error("ErrorInvalidContractAddress");return t.contractAddress})}}function xn(e){return I(this,null,function*(){return new Me(e)})}},89214:function(){},20131:function(){},16026:function(){},52361:function(){},94616:function(){}}]);
1
+ (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[1973],{79014:function(Fe,ne,f){"use strict";f.d(ne,{Q:function(){return K},k:function(){return E}});var q=f(77591),de=f.n(q),L=f(24350),W=f(84564),P=f.n(W),te=f(76714),I=Object.defineProperty,Y=Object.getOwnPropertySymbols,re=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable,Z=(a,C,T)=>C in a?I(a,C,{enumerable:!0,configurable:!0,writable:!0,value:T}):a[C]=T,J=(a,C)=>{for(var T in C||(C={}))re.call(C,T)&&Z(a,T,C[T]);if(Y)for(var T of Y(C))oe.call(C,T)&&Z(a,T,C[T]);return a};function E(a,C,T,b,_=[]){const v=J({},P()(C,{},!0)),G=C.startsWith(`${a.pluginId}://`);if(v.protocol!=null&&(v.protocol=v.protocol.replace(":","")),v.protocol!=null&&v.protocol!==""&&!T[v.protocol])throw new Error(`Uri protocol '${v.protocol}' is not supported for ${a.pluginId}.`);if(v.host===""&&v.pathname==="")throw new Error("Path and host not found in uri.");const R={publicAddress:v.host!==""?v.host:v.pathname.split("/")[0]},H=v.query.label,Q=v.query.message,se=v.query.category;(H!=null||Q!=null||se!=null||G)&&(R.metadata={},R.metadata.name=H,R.metadata.notes=Q,R.metadata.category=se,R.metadata.gateway=G!=null?G:!1);const z=v.query.amount;if(z!=null&&typeof z=="string"){b==null&&(b=a.currencyCode);const j=(0,te.Qs)(b!=null?b:"",a,_);if(j==null)throw new Error("InternalErrorInvalidCurrencyCode");let ee=(0,q.mul)(z,j.multiplier);ee=(0,q.toFixed)(ee,0,0),R.nativeAmount=ee,R.currencyCode=b}return{edgeParsedUri:R,parsedUri:v}}function K(a,C,T){if(a.publicAddress==null)throw new Error("InvalidPublicAddressError");if(T==null&&a.label==null&&a.message==null)return a.publicAddress;{let b="";T!=null&&(b+="amount="+T+"&"),(a.label!=null||a.message!=null)&&(typeof a.label=="string"&&(b+="label="+a.label+"&"),typeof a.message=="string"&&(b+="message="+a.message+"&")),b=b.substr(0,b.length-1);const _={scheme:C,path:a.publicAddress,query:b};return(0,L.qC)(_)}}},94831:function(Fe,ne,f){"use strict";f.r(ne),f.d(ne,{CosmosTools:function(){return Me},makeCurrencyEngine:function(){return On},makeCurrencyTools:function(){return xn}});var q=f(87137),de=f(79562),L=f(28972),W=f(74087),P=f(77591),te=f(2153),I=f(79325),Y=f(20918),re=f(79014),oe=f(76714),Z=f(98994),J=f(33359),E=f(24658),K=f(73034),a=f(82448),C=f(62177);const T=["coin_spent.spender","coin_received.receiver"],b=(0,a.su)({archivedTxLastCheckTime:(0,a.Vk)(a.mH,0),"coin_spent.spender":(0,a.Vk)(a.XC),"coin_received.receiver":(0,a.Vk)(a.XC)}),_=(0,C.jd)((0,a.su)({bech32Address:a.XC,publicKey:a.XC})),v=e=>{const n=(0,a.su)({[`${e}Mnemonic`]:a.XC});return(0,a.W1)(t=>({mnemonic:n(t)[`${e}Mnemonic`]}),t=>({[`${e}Mnemonic`]:t.mnemonic}))},G=(0,a.su)({ninerealmsClientId:(0,a.Zz)(a.XC)}),fe=(0,a.su)({denom:a.XC,amount:a.XC}),R=(0,a.su)({gasFeeCoin:fe,gasLimit:a.XC,unsignedTxHex:a.XC});var H=(e,n,t)=>new Promise((s,o)=>{var r=i=>{try{c(t.next(i))}catch(l){o(l)}},u=i=>{try{c(t.throw(i))}catch(l){o(l)}},c=i=>i.done?s(i.value):Promise.resolve(i.value).then(r,u);c((t=t.apply(e,n)).next())});const Q=(e,n)=>{const t=G(n),s={},o=/{{(.*?)}}/g;for(const[r,u]of Object.entries(e.headers)){const c=o.exec(u);c!=null&&(s[r]=t[c[1]])}return{url:e.url,headers:s}},se=(e,n)=>{const{url:t,headers:s}=n;return{execute:o=>H(void 0,null,function*(){const r={method:"POST",headers:s,body:JSON.stringify(o)};return yield(yield e(t,r)).json()}),disconnect:()=>{}}},z=e=>H(void 0,null,function*(){const n=yield K.Tendermint37Client.create(e);return(yield n.status()).nodeInfo.version.startsWith("0.37.")?n:yield K.Tendermint34Client.create(e)}),j=(e,n)=>H(void 0,null,function*(){const t=yield E.StargateClient.create(yield z(se(e,n))),s=t.forceGetQueryClient(),o=t.forceGetCometClient();return{queryClient:s,stargateClient:t,cometClient:o}}),ee=e=>{var n;const[t,...s]=e.split("."),o=e.includes("/"),r=s.join("."),u=(n=r==null?void 0:r.split("-"))==null?void 0:n[0];return{chain:t,symbol:r,ticker:u,synth:o}},Le=e=>e.reduce((n,t)=>{try{return(0,J.addCoins)(n,t)}catch{}return n}),he=(0,a.Wf)("amount"),We=(0,a.Wf)("receiver"),Je=(0,a.Wf)("spender"),Ke=(0,a.Wf)("amount","receiver","spender"),_e=(0,a.su)({type:(0,a.Wf)("coin_received"),attributes:(0,a.vq)((0,a.su)({key:he,value:a.XC}),(0,a.su)({key:We,value:a.XC}))}),He=(0,a.su)({type:(0,a.Wf)("coin_spent"),attributes:(0,a.vq)((0,a.su)({key:he,value:a.XC}),(0,a.su)({key:Je,value:a.XC}))}),$e=(e,n)=>{const t=new Map;for(const o of e){const r={type:o.type,attributes:o.attributes.filter(i=>(0,a.Vk)(Ke)(i.key)!=null).sort((i,l)=>i.key<l.key?-1:1)},u=(0,a.Vk)(_e)(r);if(u!=null){const[i,l]=u.attributes.map(h=>h.value);if(l!==n)continue;(0,E.parseCoins)(i).forEach(h=>{var m;const g=h.amount,p=(m=t.get(h.denom))!=null?m:"0";t.set(h.denom,(0,P.add)(g,p))});continue}const c=(0,a.Vk)(He)(r);if(c!=null){const[i,l]=c.attributes.map(h=>h.value);if(l!==n)continue;(0,E.parseCoins)(i).forEach(h=>{var m;const g=`-${h.amount}`,p=(m=t.get(h.denom))!=null?m:"0";t.set(h.denom,(0,P.add)(g,p))})}}const s=[];return t.forEach((o,r)=>{o!=="0"&&s.push({denom:r,amount:o})}),s};var Ve=f(43720),S=f.n(Ve),Xe=f(62100),d=f.n(Xe);const Bn="common";function me(){return{chain:"",symbol:"",ticker:"",synth:!1}}const $={encode(e,n=d().Writer.create()){return e.chain!==""&&n.uint32(10).string(e.chain),e.symbol!==""&&n.uint32(18).string(e.symbol),e.ticker!==""&&n.uint32(26).string(e.ticker),e.synth===!0&&n.uint32(32).bool(e.synth),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=me();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.chain=t.string();continue;case 2:if(r!==18)break;o.symbol=t.string();continue;case 3:if(r!==26)break;o.ticker=t.string();continue;case 4:if(r!==32)break;o.synth=t.bool();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{chain:A(e.chain)?globalThis.String(e.chain):"",symbol:A(e.symbol)?globalThis.String(e.symbol):"",ticker:A(e.ticker)?globalThis.String(e.ticker):"",synth:A(e.synth)?globalThis.Boolean(e.synth):!1}},toJSON(e){const n={};return e.chain!==""&&(n.chain=e.chain),e.symbol!==""&&(n.symbol=e.symbol),e.ticker!==""&&(n.ticker=e.ticker),e.synth===!0&&(n.synth=e.synth),n},create(e){return $.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,s,o;const r=me();return r.chain=(n=e.chain)!=null?n:"",r.symbol=(t=e.symbol)!=null?t:"",r.ticker=(s=e.ticker)!=null?s:"",r.synth=(o=e.synth)!=null?o:!1,r}};function ye(){return{asset:void 0,amount:"",decimals:S().ZERO}}const k={encode(e,n=d().Writer.create()){return e.asset!==void 0&&$.encode(e.asset,n.uint32(10).fork()).ldelim(),e.amount!==""&&n.uint32(18).string(e.amount),e.decimals.isZero()||n.uint32(24).int64(e.decimals),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=ye();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.asset=$.decode(t,t.uint32());continue;case 2:if(r!==18)break;o.amount=t.string();continue;case 3:if(r!==24)break;o.decimals=t.int64();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{asset:A(e.asset)?$.fromJSON(e.asset):void 0,amount:A(e.amount)?globalThis.String(e.amount):"",decimals:A(e.decimals)?S().fromValue(e.decimals):S().ZERO}},toJSON(e){const n={};return e.asset!==void 0&&(n.asset=$.toJSON(e.asset)),e.amount!==""&&(n.amount=e.amount),e.decimals.isZero()||(n.decimals=(e.decimals||S().ZERO).toString()),n},create(e){return k.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=ye();return t.asset=e.asset!==void 0&&e.asset!==null?$.fromPartial(e.asset):void 0,t.amount=(n=e.amount)!=null?n:"",t.decimals=e.decimals!==void 0&&e.decimals!==null?S().fromValue(e.decimals):S().ZERO,t}};function ge(){return{secp256k1:"",ed25519:""}}const qe={encode(e,n=d().Writer.create()){return e.secp256k1!==""&&n.uint32(10).string(e.secp256k1),e.ed25519!==""&&n.uint32(18).string(e.ed25519),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=ge();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.secp256k1=t.string();continue;case 2:if(r!==18)break;o.ed25519=t.string();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{secp256k1:A(e.secp256k1)?globalThis.String(e.secp256k1):"",ed25519:A(e.ed25519)?globalThis.String(e.ed25519):""}},toJSON(e){const n={};return e.secp256k1!==""&&(n.secp256k1=e.secp256k1),e.ed25519!==""&&(n.ed25519=e.ed25519),n},create(e){return qe.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const s=ge();return s.secp256k1=(n=e.secp256k1)!=null?n:"",s.ed25519=(t=e.ed25519)!=null?t:"",s}};function pe(){return{id:"",chain:"",fromAddress:"",toAddress:"",coins:[],gas:[],memo:""}}const Ye={encode(e,n=d().Writer.create()){e.id!==""&&n.uint32(10).string(e.id),e.chain!==""&&n.uint32(18).string(e.chain),e.fromAddress!==""&&n.uint32(26).string(e.fromAddress),e.toAddress!==""&&n.uint32(34).string(e.toAddress);for(const t of e.coins)k.encode(t,n.uint32(42).fork()).ldelim();for(const t of e.gas)k.encode(t,n.uint32(50).fork()).ldelim();return e.memo!==""&&n.uint32(58).string(e.memo),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=pe();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.id=t.string();continue;case 2:if(r!==18)break;o.chain=t.string();continue;case 3:if(r!==26)break;o.fromAddress=t.string();continue;case 4:if(r!==34)break;o.toAddress=t.string();continue;case 5:if(r!==42)break;o.coins.push(k.decode(t,t.uint32()));continue;case 6:if(r!==50)break;o.gas.push(k.decode(t,t.uint32()));continue;case 7:if(r!==58)break;o.memo=t.string();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{id:A(e.id)?globalThis.String(e.id):"",chain:A(e.chain)?globalThis.String(e.chain):"",fromAddress:A(e.fromAddress)?globalThis.String(e.fromAddress):"",toAddress:A(e.toAddress)?globalThis.String(e.toAddress):"",coins:globalThis.Array.isArray(e==null?void 0:e.coins)?e.coins.map(n=>k.fromJSON(n)):[],gas:globalThis.Array.isArray(e==null?void 0:e.gas)?e.gas.map(n=>k.fromJSON(n)):[],memo:A(e.memo)?globalThis.String(e.memo):""}},toJSON(e){var n,t;const s={};return e.id!==""&&(s.id=e.id),e.chain!==""&&(s.chain=e.chain),e.fromAddress!==""&&(s.fromAddress=e.fromAddress),e.toAddress!==""&&(s.toAddress=e.toAddress),(n=e.coins)!=null&&n.length&&(s.coins=e.coins.map(o=>k.toJSON(o))),(t=e.gas)!=null&&t.length&&(s.gas=e.gas.map(o=>k.toJSON(o))),e.memo!==""&&(s.memo=e.memo),s},create(e){return Ye.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,s,o,r,u,c;const i=pe();return i.id=(n=e.id)!=null?n:"",i.chain=(t=e.chain)!=null?t:"",i.fromAddress=(s=e.fromAddress)!=null?s:"",i.toAddress=(o=e.toAddress)!=null?o:"",i.coins=((r=e.coins)==null?void 0:r.map(l=>k.fromPartial(l)))||[],i.gas=((u=e.gas)==null?void 0:u.map(l=>k.fromPartial(l)))||[],i.memo=(c=e.memo)!=null?c:"",i}};function ve(){return{coins:[],poolDeduct:""}}const Ze={encode(e,n=d().Writer.create()){for(const t of e.coins)k.encode(t,n.uint32(10).fork()).ldelim();return e.poolDeduct!==""&&n.uint32(18).string(e.poolDeduct),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=ve();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.coins.push(k.decode(t,t.uint32()));continue;case 2:if(r!==18)break;o.poolDeduct=t.string();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{coins:globalThis.Array.isArray(e==null?void 0:e.coins)?e.coins.map(n=>k.fromJSON(n)):[],poolDeduct:A(e.poolDeduct)?globalThis.String(e.poolDeduct):""}},toJSON(e){var n;const t={};return(n=e.coins)!=null&&n.length&&(t.coins=e.coins.map(s=>k.toJSON(s))),e.poolDeduct!==""&&(t.poolDeduct=e.poolDeduct),t},create(e){return Ze.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const s=ve();return s.coins=((n=e.coins)==null?void 0:n.map(o=>k.fromPartial(o)))||[],s.poolDeduct=(t=e.poolDeduct)!=null?t:"",s}};function ke(){return{value:""}}const Ge={encode(e,n=d().Writer.create()){return e.value!==""&&n.uint32(10).string(e.value),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=ke();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.value=t.string();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{value:A(e.value)?globalThis.String(e.value):""}},toJSON(e){const n={};return e.value!==""&&(n.value=e.value),n},create(e){return Ge.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=ke();return t.value=(n=e.value)!=null?n:"",t}};d().util.Long!==S()&&(d().util.Long=S(),d().configure());function A(e){return e!=null}const Rn="types";function Ce(){return{coins:[],memo:"",signer:new Uint8Array(0)}}const ie={encode(e,n=d().Writer.create()){for(const t of e.coins)k.encode(t,n.uint32(10).fork()).ldelim();return e.memo!==""&&n.uint32(18).string(e.memo),e.signer.length!==0&&n.uint32(26).bytes(e.signer),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=Ce();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.coins.push(k.decode(t,t.uint32()));continue;case 2:if(r!==18)break;o.memo=t.string();continue;case 3:if(r!==26)break;o.signer=t.bytes();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{coins:globalThis.Array.isArray(e==null?void 0:e.coins)?e.coins.map(n=>k.fromJSON(n)):[],memo:Te(e.memo)?globalThis.String(e.memo):"",signer:Te(e.signer)?Qe(e.signer):new Uint8Array(0)}},toJSON(e){var n;const t={};return(n=e.coins)!=null&&n.length&&(t.coins=e.coins.map(s=>k.toJSON(s))),e.memo!==""&&(t.memo=e.memo),e.signer.length!==0&&(t.signer=ze(e.signer)),t},create(e){return ie.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,s;const o=Ce();return o.coins=((n=e.coins)==null?void 0:n.map(r=>k.fromPartial(r)))||[],o.memo=(t=e.memo)!=null?t:"",o.signer=(s=e.signer)!=null?s:new Uint8Array(0),o}};function Qe(e){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(e,"base64"));{const n=globalThis.atob(e),t=new Uint8Array(n.length);for(let s=0;s<n.length;++s)t[s]=n.charCodeAt(s);return t}}function ze(e){if(globalThis.Buffer)return globalThis.Buffer.from(e).toString("base64");{const n=[];return e.forEach(t=>{n.push(globalThis.String.fromCharCode(t))}),globalThis.btoa(n.join(""))}}d().util.Long!==S()&&(d().util.Long=S(),d().configure());function Te(e){return e!=null}const Un="cosmos.base.v1beta1";function Ae(){return{denom:"",amount:""}}const V={encode(e,n=d().Writer.create()){return e.denom!==""&&n.uint32(10).string(e.denom),e.amount!==""&&n.uint32(18).string(e.amount),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=Ae();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.denom=t.string();continue;case 2:if(r!==18)break;o.amount=t.string();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{denom:X(e.denom)?globalThis.String(e.denom):"",amount:X(e.amount)?globalThis.String(e.amount):""}},toJSON(e){const n={};return e.denom!==""&&(n.denom=e.denom),e.amount!==""&&(n.amount=e.amount),n},create(e){return V.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const s=Ae();return s.denom=(n=e.denom)!=null?n:"",s.amount=(t=e.amount)!=null?t:"",s}};function we(){return{denom:"",amount:""}}const je={encode(e,n=d().Writer.create()){return e.denom!==""&&n.uint32(10).string(e.denom),e.amount!==""&&n.uint32(18).string(e.amount),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=we();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.denom=t.string();continue;case 2:if(r!==18)break;o.amount=t.string();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{denom:X(e.denom)?globalThis.String(e.denom):"",amount:X(e.amount)?globalThis.String(e.amount):""}},toJSON(e){const n={};return e.denom!==""&&(n.denom=e.denom),e.amount!==""&&(n.amount=e.amount),n},create(e){return je.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const s=we();return s.denom=(n=e.denom)!=null?n:"",s.amount=(t=e.amount)!=null?t:"",s}};function be(){return{int:""}}const en={encode(e,n=d().Writer.create()){return e.int!==""&&n.uint32(10).string(e.int),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=be();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.int=t.string();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{int:X(e.int)?globalThis.String(e.int):""}},toJSON(e){const n={};return e.int!==""&&(n.int=e.int),n},create(e){return en.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=be();return t.int=(n=e.int)!=null?n:"",t}};function Se(){return{dec:""}}const nn={encode(e,n=d().Writer.create()){return e.dec!==""&&n.uint32(10).string(e.dec),n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=Se();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.dec=t.string();continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{dec:X(e.dec)?globalThis.String(e.dec):""}},toJSON(e){const n={};return e.dec!==""&&(n.dec=e.dec),n},create(e){return nn.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=Se();return t.dec=(n=e.dec)!=null?n:"",t}};d().util.Long!==S()&&(d().util.Long=S(),d().configure());function X(e){return e!=null}const Nn="types";function Pe(){return{fromAddress:new Uint8Array(0),toAddress:new Uint8Array(0),amount:[]}}const ae={encode(e,n=d().Writer.create()){e.fromAddress.length!==0&&n.uint32(10).bytes(e.fromAddress),e.toAddress.length!==0&&n.uint32(18).bytes(e.toAddress);for(const t of e.amount)V.encode(t,n.uint32(26).fork()).ldelim();return n},decode(e,n){const t=e instanceof d().Reader?e:d().Reader.create(e);let s=n===void 0?t.len:t.pos+n;const o=Pe();for(;t.pos<s;){const r=t.uint32();switch(r>>>3){case 1:if(r!==10)break;o.fromAddress=t.bytes();continue;case 2:if(r!==18)break;o.toAddress=t.bytes();continue;case 3:if(r!==26)break;o.amount.push(V.decode(t,t.uint32()));continue}if((r&7)===4||r===0)break;t.skipType(r&7)}return o},fromJSON(e){return{fromAddress:Ee(e.fromAddress)?Ie(e.fromAddress):new Uint8Array(0),toAddress:Ee(e.toAddress)?Ie(e.toAddress):new Uint8Array(0),amount:globalThis.Array.isArray(e==null?void 0:e.amount)?e.amount.map(n=>V.fromJSON(n)):[]}},toJSON(e){var n;const t={};return e.fromAddress.length!==0&&(t.fromAddress=Oe(e.fromAddress)),e.toAddress.length!==0&&(t.toAddress=Oe(e.toAddress)),(n=e.amount)!=null&&n.length&&(t.amount=e.amount.map(s=>V.toJSON(s))),t},create(e){return ae.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,s;const o=Pe();return o.fromAddress=(n=e.fromAddress)!=null?n:new Uint8Array(0),o.toAddress=(t=e.toAddress)!=null?t:new Uint8Array(0),o.amount=((s=e.amount)==null?void 0:s.map(r=>V.fromPartial(r)))||[],o}};function Ie(e){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(e,"base64"));{const n=globalThis.atob(e),t=new Uint8Array(n.length);for(let s=0;s<n.length;++s)t[s]=n.charCodeAt(s);return t}}function Oe(e){if(globalThis.Buffer)return globalThis.Buffer.from(e).toString("base64");{const n=[];return e.forEach(t=>{n.push(globalThis.String.fromCharCode(t))}),globalThis.btoa(n.join(""))}}d().util.Long!==S()&&(d().util.Long=S(),d().configure());function Ee(e){return e!=null}var tn=Object.defineProperty,rn=Object.defineProperties,on=Object.getOwnPropertyDescriptors,xe=Object.getOwnPropertySymbols,sn=Object.prototype.hasOwnProperty,an=Object.prototype.propertyIsEnumerable,De=(e,n,t)=>n in e?tn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,cn=(e,n)=>{for(var t in n||(n={}))sn.call(n,t)&&De(e,t,n[t]);if(xe)for(var t of xe(n))an.call(n,t)&&De(e,t,n[t]);return e},ln=(e,n)=>rn(e,on(n));const un=e=>{const n=new W.Registry;let t=s=>{const{amount:o,fromAddress:r,toAddress:u}=s;return{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:Z.MsgSend.encode(Z.MsgSend.fromPartial({fromAddress:r,toAddress:u,amount:o})).finish()}};switch(e){case"thorchainrune":{const s="/types.MsgDeposit";n.register(s,ie);const o=u=>{const{assets:c,memo:i,signer:l}=u,y=c.map(m=>ln(cn({},m),{asset:ee(m.asset)}));return{typeUrl:s,value:ie.encode(ie.fromPartial({coins:y,memo:i,signer:(0,L.fromBech32)(l).data})).finish()}},r="/types.MsgSend";return n.register(r,ae),t=u=>{const{amount:c,fromAddress:i,toAddress:l}=u;return{typeUrl:r,value:ae.encode(ae.fromPartial({fromAddress:(0,L.fromBech32)(i).data,toAddress:(0,L.fromBech32)(l).data,amount:c})).finish()}},{methods:{deposit:o,transfer:t},registry:n}}}return{methods:{transfer:t},registry:n}};var dn=f(7416),fn=f(45504),x=f(29639),hn=f(94935),mn=f(84650),yn=f(72681),gn=Object.defineProperty,pn=Object.defineProperties,vn=Object.getOwnPropertyDescriptors,Be=Object.getOwnPropertySymbols,kn=Object.getPrototypeOf,Cn=Object.prototype.hasOwnProperty,Tn=Object.prototype.propertyIsEnumerable,An=Reflect.get,Re=(e,n,t)=>n in e?gn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,wn=(e,n)=>{for(var t in n||(n={}))Cn.call(n,t)&&Re(e,t,n[t]);if(Be)for(var t of Be(n))Tn.call(n,t)&&Re(e,t,n[t]);return e},bn=(e,n)=>pn(e,vn(n)),Ue=(e,n,t)=>An(kn(e),t,n),w=(e,n,t)=>new Promise((s,o)=>{var r=i=>{try{c(t.next(i))}catch(l){o(l)}},u=i=>{try{c(t.throw(i))}catch(l){o(l)}},c=i=>i.done?s(i.value):Promise.resolve(i.value).then(r,u);c((t=t.apply(e,n)).next())});const Ne=5e3,Sn=3e3,Pn=1e3*60*60*24*14,In=1e3*60*2;class ce extends mn.P{constructor(n,t,s,o){super(n,t,s,o),this.networkInfo=n.networkInfo,this.fetchCors=n.io.fetchCors,this.accountNumber=0,this.sequence=0,this.unconfirmedTransactionCache={cacheSequence:0,txids:new Map},this.feeCache=new Map,this.stakedBalanceCache="0",this.otherMethods={getMaxTx:r=>w(this,null,function*(){switch(r.type){case"MakeTxDeposit":{if(this.tools.methods.deposit==null)throw new Error(`${this.currencyInfo.displayName} does not support the deposit method`);const{assets:u,memo:c}=r;if(u.length!==1)throw new Error("Cannot calculate max tx for more than one asset");const i=this.tools.methods.deposit({assets:u,memo:c,signer:this.walletInfo.keys.bech32Address}),{networkFee:l}=yield this.calculateFee({messages:[i],memo:c}),y=this.getBalance({currencyCode:this.currencyInfo.currencyCode});return(0,P.sub)(y,l)}default:throw new Error(`Invalid type: ${r.type}`)}}),makeTx:r=>w(this,null,function*(){switch(r.type){case"MakeTxDeposit":{if(this.tools.methods.deposit==null)throw new Error(`${this.currencyInfo.displayName} does not support the deposit method`);const{assets:u,memo:c,metadata:i}=r,l=this.tools.methods.deposit({assets:u,memo:c,signer:this.walletInfo.keys.bech32Address}),y=this.createUnsignedTxHex([l],c),{gasFeeCoin:h,gasLimit:m,networkFee:g}=yield this.calculateFee({messages:[l],memo:c}),p={gasFeeCoin:h,gasLimit:m,unsignedTxHex:y};return{blockHeight:0,currencyCode:this.currencyInfo.currencyCode,date:Date.now()/1e3,isSend:!0,memos:[],metadata:i,nativeAmount:`-${g}`,networkFee:g,otherParams:p,ourReceiveAddresses:[],signedTx:"",txid:"",walletId:this.walletId}}default:throw new Error(`Invalid type: ${r.type}`)}})}}setOtherData(n){this.otherData=b(n)}getClients(){if(this.tools.clients==null)throw new Error("No StargateClient");return this.tools.clients}queryBalance(){return w(this,null,function*(){var n;try{const{stargateClient:t}=this.getClients(),s=yield t.getAllBalances(this.walletInfo.keys.bech32Address),o=s.find(i=>i.denom===this.networkInfo.nativeDenom);this.updateBalance(this.currencyInfo.currencyCode,(n=o==null?void 0:o.amount)!=null?n:"0"),this.enabledTokenIds.forEach(i=>{var l;const y=this.allTokensMap[i],h=s.find(m=>m.denom===i);this.updateBalance(y.currencyCode,(l=h==null?void 0:h.amount)!=null?l:"0")});const r=yield t.getBalanceStaked(this.walletInfo.keys.bech32Address);if(r!=null&&this.stakedBalanceCache!==r.amount){const i={stakedAmounts:[{nativeAmount:r.amount}]};this.currencyEngineCallbacks.onStakingStatusChanged(i),this.stakedBalanceCache=r.amount}const{accountNumber:u,sequence:c}=yield t.getSequence(this.walletInfo.keys.bech32Address);this.accountNumber=u,this.sequence=c}catch(t){String(t).includes("does not exist on chain")?this.updateBalance(this.currencyInfo.currencyCode,"0"):this.log.warn("queryBalance error:",t)}})}queryBlockheight(){return w(this,null,function*(){try{const{stargateClient:n}=this.getClients(),t=yield n.getHeight();t>this.walletLocalData.blockHeight&&(this.walletLocalData.blockHeight=t,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight))}catch(n){this.error("queryBlockheight Error ",n)}})}queryTransactions(){return w(this,null,function*(){let n=0;const t=[this.currencyInfo.currencyCode,...this.enabledTokenIds.map(o=>this.allTokensMap[o].currencyCode)],s=Date.now()-Pn>this.otherData.archivedTxLastCheckTime?yield j(this.fetchCors,Q(this.networkInfo.archiveNode,this.tools.initOptions)):this.getClients();for(const o of T){const r=yield this.queryTransactionsInner(o,s);r!=null&&this.otherData[o]!==r&&(this.otherData[o]=r,this.walletLocalDataDirty=!0),n+=.5,t.forEach(u=>this.tokenCheckTransactionsStatus[u]=n),this.updateOnAddressesChecked()}this.otherData.archivedTxLastCheckTime=Date.now(),this.transactionsChangedArray.length>0&&(this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[])})}queryTransactionsInner(n,t){return w(this,null,function*(){const s={query:`${n}='${this.walletInfo.keys.bech32Address}'`,per_page:50,order_by:"desc"};let o,r=0,u,c=0,i=!1;try{do{const l=yield t.cometClient.txSearch(bn(wn({},s),{page:++r})),{totalCount:y,txs:h}=l;u==null&&(u=y),c=c+h.length;for(const m of h){const g=(0,L.toHex)(m.hash).toUpperCase();if(this.removeFromUnconfirmedCache(g),o==null&&(o=g),g===this.otherData[n]){i=!0;break}const p=m.result.events.map(E.fromTendermintEvent),D=$e(p,this.walletInfo.keys.bech32Address);if(D.length===0)continue;const B=yield t.stargateClient.getBlock(m.height),N=(0,K.toSeconds)((0,K.fromRfc3339WithNanoseconds)(B.header.time)).seconds,{height:M,tx:U}=m,le=I.YU.stringify(U),{authInfo:{fee:F},body:{memo:ue}}=(0,W.decodeTxRaw)(U);D.forEach(Dn=>{this.processCosmosTransaction(g,N,le,Dn,ue,M,F)})}}while(u>c&&!i)}catch(l){throw this.log.warn("queryTransactions error:",l),l}return o})}processCosmosTransaction(n,t,s,o,r,u,c){var i,l;const{amount:y,denom:h}=o,m=this.networkInfo.nativeDenom===h,g=this.networkInfo.nativeDenom===h?this.currencyInfo.currencyCode:this.allTokensMap[h]!=null?this.allTokensMap[h].currencyCode:void 0;if(g==null)return;let p=(l=(i=this.networkInfo.defaultTransactionFee)==null?void 0:i.amount)!=null?l:"0";if(c!=null){const{amount:F}=c,ue=Le([(0,E.coin)("0",this.networkInfo.nativeDenom),...F]);p=(0,P.add)(p,ue.amount)}const D=(0,P.lt)(y,"0"),B=[];let N=y,M;D?m?N=(0,P.sub)(N,p):(p="0",M=p):(B.push(this.walletInfo.keys.bech32Address),p="0");const U=[];r!==""&&U.push({type:"text",value:r});const le={blockHeight:u,currencyCode:g,date:t,isSend:D,memos:U,nativeAmount:N,networkFee:p,ourReceiveAddresses:B,parentNetworkFee:M,signedTx:s,txid:n,walletId:this.walletId};this.addTransaction(g,le)}createUnsignedTxHex(n,t){const s=x.TxBody.fromPartial({messages:n,memo:t}),o=x.TxBody.encode(s).finish(),r=x.TxRaw.fromPartial({bodyBytes:o});return I.YU.stringify(x.TxRaw.encode(r).finish())}addToUnconfirmedCache(n){const t=new Date(new Date().getTime()+In);this.unconfirmedTransactionCache.txids.size===0&&(this.unconfirmedTransactionCache.cacheSequence=this.sequence),this.unconfirmedTransactionCache.txids.set(n,t)}removeFromUnconfirmedCache(n){this.unconfirmedTransactionCache.txids.has(n)&&(this.unconfirmedTransactionCache.cacheSequence=this.unconfirmedTransactionCache.cacheSequence+1,this.sequence=this.unconfirmedTransactionCache.cacheSequence,this.unconfirmedTransactionCache.txids.delete(n))}getSequence(){return this.unconfirmedTransactionCache.txids.size===0?this.sequence:[...this.unconfirmedTransactionCache.txids.values()].some(n=>n<new Date)?(this.unconfirmedTransactionCache.txids=new Map,this.sequence):this.unconfirmedTransactionCache.cacheSequence+this.unconfirmedTransactionCache.txids.size}calculateFee(n){return w(this,null,function*(){let t=(0,E.coin)("0",this.networkInfo.nativeDenom),s="0",o="0";if(this.networkInfo.defaultTransactionFee==null){const{messages:r,memo:u,networkFeeOption:c}=n,{queryClient:i}=this.getClients(),{gasInfo:l}=yield i.tx.simulate(r,u,(0,J.encodeSecp256k1Pubkey)(I.YU.parse(this.walletInfo.keys.publicKey)),this.getSequence());if((l==null?void 0:l.gasUsed)==null)throw new Error("simulate didn't return gasUsed ");s=(0,P.ceil)((0,P.mul)(l==null?void 0:l.gasUsed.toString(),"1.5"),0);const{low:y,average:h,high:m}=(0,dn.getGasPriceStep)(this.tools.chainData);let g=h;switch(c){case"low":{g=y;break}case"high":{g=m;break}case"custom":throw new Error("Custom fee not supported")}const p=(0,P.ceil)((0,P.mul)(s,g.toString()),0);t=(0,E.coin)(p,this.networkInfo.nativeDenom),o=t.amount}else o=this.networkInfo.defaultTransactionFee.amount;return{gasFeeCoin:t,gasLimit:s,networkFee:o}})}startEngine(){return w(this,null,function*(){this.engineOn=!0,yield this.tools.connectClient(),this.addToLoop("queryBalance",Ne).catch(()=>{}),this.addToLoop("queryBlockheight",Ne).catch(()=>{}),this.addToLoop("queryTransactions",Sn).catch(()=>{}),yield Ue(ce.prototype,this,"startEngine").call(this)})}killEngine(){return w(this,null,function*(){yield this.tools.disconnectClient(),yield Ue(ce.prototype,this,"killEngine").call(this)})}resyncBlockchain(){return w(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}makeSpend(n){return w(this,null,function*(){var t;n=(0,yn.s)(n,this.currencyInfo);const{edgeSpendInfo:s,currencyCode:o}=this.makeSpendCheck(n),{memos:r=[],networkFeeOption:u,tokenId:c}=s,i=(t=r[0])==null?void 0:t.value;if(s.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{nativeAmount:l,publicAddress:y}=s.spendTargets[0];if(l==null)throw new hn.$D;if(y==null)throw new Error("makeSpend Missing publicAddress");const h=this.tools.methods.transfer({amount:[(0,E.coin)(l,c!=null?c:this.networkInfo.nativeDenom)],fromAddress:this.walletInfo.keys.bech32Address,toAddress:y});let m,g,p;const D=`${y}${String(u)}`,B=this.feeCache.get(D);if(l==="0")m=(0,E.coin)("0",this.networkInfo.nativeDenom),g="0",p="0";else if(B==null){const F=yield this.calculateFee({messages:[h],memo:i,networkFeeOption:u});m=F.gasFeeCoin,g=F.gasLimit,p=F.networkFee,this.feeCache.set(D,F)}else m=B.gasFeeCoin,g=B.gasLimit,p=B.networkFee;const N=this.createUnsignedTxHex([h],i),M={gasFeeCoin:m,gasLimit:g,unsignedTxHex:N},U=this.makeEdgeTransactionAmounts(l,p,c);return this.checkBalances(U,c),{blockHeight:0,currencyCode:o,date:0,isSend:!0,memos:r,nativeAmount:U.nativeAmount,networkFee:U.networkFee,otherParams:M,ourReceiveAddresses:[],parentNetworkFee:U.parentNetworkFee,signedTx:"",txid:"",walletId:this.walletId}})}signMessage(n,t){return w(this,null,function*(){const s=v(this.currencyInfo.pluginId)(t),o=I.YU.parse(n),r=x.SignDoc.decode(o),c=yield(yield this.tools.createSigner(s.mnemonic)).signDirect(this.walletInfo.keys.bech32Address,r),i=(0,J.decodeSignature)(c.signature),l=x.TxRaw.fromPartial({authInfoBytes:r.authInfoBytes,bodyBytes:r.bodyBytes,signatures:[i.signature]}),y=x.TxRaw.encode(l).finish();return I.YU.stringify(y)})}signTx(n,t){return w(this,null,function*(){const{gasFeeCoin:s,gasLimit:o,unsignedTxHex:r}=R(n.otherParams),u=v(this.currencyInfo.pluginId)(t),c=I.YU.parse(r),{bodyBytes:i}=x.TxRaw.decode(c),l=I.YU.parse(this.walletInfo.keys.publicKey),y=(0,J.encodeSecp256k1Pubkey)(l),h=(0,W.makeAuthInfoBytes)([{pubkey:(0,W.encodePubkey)(y),sequence:this.getSequence()}],[s],parseInt(o),void 0,void 0,1),m=x.SignDoc.fromPartial({accountNumber:(0,fn.longify)(this.accountNumber),authInfoBytes:h,bodyBytes:i,chainId:this.tools.chainData.chain_id}),p=yield(yield this.tools.createSigner(u.mnemonic)).signDirect(this.walletInfo.keys.bech32Address,m),D=(0,J.decodeSignature)(p.signature),B=x.TxRaw.fromPartial({authInfoBytes:h,bodyBytes:i,signatures:[D.signature]}),N=x.TxRaw.encode(B).finish(),M=I.YU.stringify(N);return n.signedTx=M,n})}broadcastTx(n){return w(this,null,function*(){try{const t=I.YU.parse(n.signedTx),{stargateClient:s}=this.getClients(),o=yield s.broadcastTxSync(t);return this.warn(`SUCCESS broadcastTx
2
+ ${(0,oe.oX)(n)}`),n.txid=o,n.date=Date.now()/1e3,this.addToUnconfirmedCache(o),n}catch(t){throw this.warn("FAILURE broadcastTx failed: ",t),t}})}getFreshAddress(n){return w(this,null,function*(){const{bech32Address:t}=this.walletInfo.keys;return{publicAddress:t}})}}function On(e,n,t,s){return w(this,null,function*(){const o=_(t),r=new ce(e,n,o,s);return yield r.loadEngine(),r})}var En=f(48764).Buffer,O=(e,n,t)=>new Promise((s,o)=>{var r=i=>{try{c(t.next(i))}catch(l){o(l)}},u=i=>{try{c(t.throw(i))}catch(l){o(l)}},c=i=>i.done?s(i.value):Promise.resolve(i.value).then(r,u);c((t=t.apply(e,n)).next())});class Me{constructor(n){const{builtinTokens:t,currencyInfo:s,initOptions:o,io:r,networkInfo:u}=n;this.io=r,this.currencyInfo=s,this.builtinTokens=t,this.networkInfo=u,this.initOptions=o,this.clientCount=0;const{methods:c,registry:i}=un(s.pluginId);this.methods=c,this.registry=i;const{data:l,name:y,url:h}=this.networkInfo.chainInfo;this.chainData=l;const m=new q.ChainRegistryFetcher;m.fetch(h).then(()=>{this.chainData=m.getChain(y)}).catch(g=>{})}createSigner(n){return O(this,null,function*(){const{bech32AddressPrefix:t,bip39Path:s}=this.networkInfo,o=(0,de.stringToPath)(s);return yield W.DirectSecp256k1HdWallet.fromMnemonic(n,{hdPaths:[o],prefix:t})})}getDisplayPrivateKey(n){return O(this,null,function*(){const{pluginId:t}=this.currencyInfo;return v(t)(n.keys).mnemonic})}getDisplayPublicKey(n){return O(this,null,function*(){const{keys:t}=_(n);return t.publicKey})}importPrivateKey(n){return O(this,null,function*(){if(!(0,te.validateMnemonic)(n))throw new Error("Invalid mnemonic");return yield this.createSigner(n),{[this.networkInfo.pluginMnemonicKeyName]:n}})}createPrivateKey(n){return O(this,null,function*(){if(n!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const t=En.from(this.io.random(32)),s=(0,te.entropyToMnemonic)(t);return yield this.importPrivateKey(s)})}derivePublicKey(n){return O(this,null,function*(){if(n.type!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const{mnemonic:t}=v(this.currencyInfo.pluginId)(n.keys),o=yield(yield this.createSigner(t)).getAccounts(),{address:r,pubkey:u}=o[0],c=I.YU.stringify(u);return{bech32Address:r,publicKey:c}})}isValidAddress(n){try{if((0,L.fromBech32)(n).prefix===this.networkInfo.bech32AddressPrefix)return!0}catch{}return!1}parseUri(n,t,s){return O(this,null,function*(){const{pluginId:o}=this.currencyInfo,r={[o]:!0},{parsedUri:u,edgeParsedUri:c}=(0,re.k)(this.currencyInfo,n,r,t!=null?t:this.currencyInfo.currencyCode,s);let i="";if(c.publicAddress!=null&&(i=c.publicAddress),!this.isValidAddress(i))throw new Error("InvalidPublicAddressError");return c.uniqueIdentifier=u.query.memo,c})}encodeUri(n){return O(this,arguments,function*(t,s=[]){const{pluginId:o}=this.currencyInfo,{nativeAmount:r,currencyCode:u,publicAddress:c}=t;if(!this.isValidAddress(c))throw new Error("InvalidPublicAddressError");let i;if(typeof r=="string"){const y=(0,oe.Qs)(u!=null?u:this.currencyInfo.currencyCode,this.currencyInfo,s);if(y==null)throw new Error("InternalErrorInvalidCurrencyCode");i=(0,P.div)(r,y.multiplier,18)}return(0,re.Q)(t,o,i)})}connectClient(){return O(this,null,function*(){this.clients==null&&(this.clients=yield j(this.io.fetchCors,Q(this.networkInfo.rpcNode,this.initOptions))),++this.clientCount})}disconnectClient(){return O(this,null,function*(){var n,t;--this.clientCount,this.clientCount===0&&(yield(t=(n=this.clients)==null?void 0:n.stargateClient)==null?void 0:t.disconnect(),this.clients=void 0)})}getTokenId(n){return O(this,null,function*(){(0,Y.Rp)(n);const t=(0,Y.Oj)(n.networkLocation);if(t==null)throw new Error("ErrorInvalidContractAddress");return t.contractAddress})}}function xn(e){return O(this,null,function*(){return new Me(e)})}},89214:function(){},20131:function(){},16026:function(){},52361:function(){},94616:function(){}}]);