edge-currency-accountbased 4.4.0 → 4.5.0
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 +6 -0
- package/android/src/main/assets/edge-currency-accountbased/4935.chunk.js +1 -0
- package/android/src/main/assets/edge-currency-accountbased/6757.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/7224.chunk.js +2 -0
- package/android/src/main/assets/edge-currency-accountbased/algorand.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/axelar.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/bnb.chunk.js +3 -3
- package/android/src/main/assets/edge-currency-accountbased/cardano.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/edge-currency-accountbased.js +7 -2
- package/android/src/main/assets/edge-currency-accountbased/ethereum.chunk.js +9 -9
- package/android/src/main/assets/edge-currency-accountbased/filecoin.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/hedera.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/polkadot.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/ripple.chunk.js +5 -5
- package/android/src/main/assets/edge-currency-accountbased/solana.chunk.js +3 -3
- package/android/src/main/assets/edge-currency-accountbased/stellar.chunk.js +6 -6
- package/android/src/main/assets/edge-currency-accountbased/tezos.chunk.js +3 -3
- package/android/src/main/assets/edge-currency-accountbased/tron.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/zcash.chunk.js +4 -4
- package/lib/algorand/algorandInfo.js +2 -1
- package/lib/algorand/algorandTestnetInfo.js +2 -1
- package/lib/algorand/algorandTypes.js +5 -0
- package/lib/binance/binanceInfo.js +2 -1
- package/lib/binance/binanceTypes.js +5 -0
- package/lib/cardano/cardanoInfo.js +2 -1
- package/lib/cardano/cardanoTestnetInfo.js +2 -1
- package/lib/cardano/cardanoTypes.js +6 -0
- package/lib/common/innerPlugin.js +23 -2
- package/lib/common/utils.js +5 -6
- package/lib/cosmos/CosmosTools.js +15 -3
- package/lib/cosmos/cosmosTypes.js +8 -0
- package/lib/cosmos/info/axelarInfo.js +2 -1
- package/lib/cosmos/info/coreumInfo.js +2 -1
- package/lib/cosmos/info/cosmoshubInfo.js +2 -1
- package/lib/cosmos/info/osmosisInfo.js +2 -1
- package/lib/cosmos/info/thorchainruneInfo.js +72 -1
- package/lib/eos/eosTypes.js +15 -1
- package/lib/eos/info/eosInfo.js +4 -0
- package/lib/eos/info/telosInfo.js +4 -0
- package/lib/eos/info/waxInfo.js +4 -0
- package/lib/ethereum/EthereumEngine.js +4 -4
- package/lib/ethereum/ethereumTypes.js +29 -0
- package/lib/ethereum/fees/ethMiningFees.js +10 -2
- package/lib/ethereum/info/arbitrumInfo.js +5 -0
- package/lib/ethereum/info/avalancheInfo.js +5 -0
- package/lib/ethereum/info/baseInfo.js +5 -0
- package/lib/ethereum/info/binancesmartchainInfo.js +5 -0
- package/lib/ethereum/info/celoInfo.js +5 -0
- package/lib/ethereum/info/ethDevInfo.js +5 -0
- package/lib/ethereum/info/ethereumInfo.js +9 -0
- package/lib/ethereum/info/ethereumclassicInfo.js +5 -0
- package/lib/ethereum/info/ethereumpowInfo.js +5 -0
- package/lib/ethereum/info/fantomInfo.js +5 -0
- package/lib/ethereum/info/filecoinFevmCalibrationInfo.js +5 -0
- package/lib/ethereum/info/filecoinFevmInfo.js +5 -0
- package/lib/ethereum/info/goerliInfo.js +5 -0
- package/lib/ethereum/info/kovanInfo.js +5 -0
- package/lib/ethereum/info/optimismInfo.js +5 -0
- package/lib/ethereum/info/polygonInfo.js +5 -0
- package/lib/ethereum/info/pulsechainInfo.js +5 -0
- package/lib/ethereum/info/rinkebyInfo.js +5 -0
- package/lib/ethereum/info/ropstenInfo.js +5 -0
- package/lib/ethereum/info/rskInfo.js +5 -0
- package/lib/ethereum/info/zksyncInfo.js +5 -0
- package/lib/filecoin/calibrationInfo.js +2 -1
- package/lib/filecoin/filecoinInfo.js +2 -1
- package/lib/filecoin/filecoinTypes.js +12 -0
- package/lib/fio/fioInfo.js +5 -0
- package/lib/fio/fioTypes.js +10 -1
- package/lib/hedera/hederaInfo.js +2 -1
- package/lib/hedera/hederaTestnetInfo.js +2 -1
- package/lib/hedera/hederaTypes.js +5 -0
- package/lib/piratechain/piratechainInfo.js +4 -0
- package/lib/piratechain/piratechainTypes.js +12 -0
- package/lib/polkadot/info/liberlandInfo.js +2 -1
- package/lib/polkadot/info/liberlandTestnetInfo.js +2 -1
- package/lib/polkadot/info/polkadotInfo.js +2 -1
- package/lib/polkadot/polkadotTypes.js +4 -0
- package/lib/ripple/rippleInfo.js +2 -1
- package/lib/ripple/rippleTypes.js +7 -2
- package/lib/solana/solanaInfo.js +2 -1
- package/lib/solana/solanaTypes.js +5 -0
- package/lib/stellar/stellarInfo.js +2 -1
- package/lib/stellar/stellarTypes.js +12 -1
- package/lib/tezos/tezosInfo.js +2 -1
- package/lib/tezos/tezosTypes.js +13 -1
- package/lib/tron/tronInfo.js +2 -1
- package/lib/tron/tronTypes.js +7 -2
- package/lib/zcash/zcashInfo.js +2 -1
- package/lib/zcash/zcashTypes.js +12 -0
- package/package.json +1 -1
- package/android/src/main/assets/edge-currency-accountbased/4843.chunk.js +0 -2
- package/android/src/main/assets/edge-currency-accountbased/7428.chunk.js +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 4.5.0 (2024-05-15)
|
|
6
|
+
|
|
7
|
+
- added: (EVM) Hardcode gas limit values for some tokens to be prioritized over eth_estimateGas result
|
|
8
|
+
- added: (Thorchain) Add synth assets
|
|
9
|
+
- added: Update node and server lists from info server payload provided by the core
|
|
10
|
+
|
|
5
11
|
## 4.4.0 (2024-05-14)
|
|
6
12
|
|
|
7
13
|
- added: `EdgeCurrencyInfo.customTokenTemplate` fields for all chains that support custom templates.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[4935],{18595:function(la,r,h){var n;n={value:!0};var a=h(47630),f=h(55352);const C=a.asCodec(s=>f.base16.parse(a.asString(s)),s=>f.base16.stringify(s).toLowerCase()),I=a.asCodec(s=>f.base32.parse(a.asString(s),{loose:!0}),s=>f.base32.stringify(s,{pad:!1})),c=a.asCodec(s=>f.base64.parse(a.asString(s)),s=>f.base64.stringify(s)),A=a.asObject({voucherId:a.asString,activates:a.asDate,created:a.asDate,ip:a.asString,ipDescription:a.asString,deviceDescription:a.asOptional(a.asString)}),t=a.asObject({encryptionType:a.asNumber,data_base64:c,iv_hex:C}),g=a.asObject({salt_hex:C,n:a.asNumber,r:a.asNumber,p:a.asNumber}),L=a.asObject({loginRequest:a.asOptional(a.asObject({appId:a.asString}).withRest),publicKey:c,timeout:a.asOptional(a.asNumber)}).withRest,j=a.asObject({publicKey:c,box:t}),_=a.asArray(c),p=a.asObject({data:a.asUnknown,challengeId:a.asOptional(a.asString),deviceDescription:a.asOptional(a.asString),otp:a.asOptional(a.asString),syncToken:a.asOptional(a.asString),voucherId:a.asOptional(a.asString),voucherAuth:a.asOptional(c),loginId:a.asOptional(c),loginAuth:a.asOptional(c),userId:a.asOptional(c),passwordAuth:a.asOptional(c),pin2Id:a.asOptional(c),pin2Auth:a.asOptional(c),recovery2Id:a.asOptional(c),recovery2Auth:a.asOptional(_),loginIds:a.asOptional(a.asArray(c)),otpResetAuth:a.asOptional(a.asString),did:a.asOptional(a.asString),l1:a.asOptional(c),lp1:a.asOptional(c),lpin1:a.asOptional(c),lra1:a.asOptional(c),recoveryAuth:a.asOptional(c)}),u=a.asObject({results:a.asOptional(a.asUnknown),status_code:a.asNumber,message:a.asString}),l=a.asObject({otpTimeout:a.asOptional(a.asNumber,7*24*60*60),otpKey:I}),B=a.asObject({passwordAuth:c,passwordAuthBox:t,passwordAuthSnrp:g,passwordBox:t,passwordKeySnrp:g}),O=a.asObject({pin2Id:c}),v=a.asObject({pin2Id:a.asOptional(c),pin2Auth:a.asOptional(c),pin2Box:a.asOptional(t),pin2KeyBox:a.asOptional(t),pin2TextBox:t}),m=a.asObject({recovery2Id:c}),w=a.asObject({recovery2Id:c,recovery2Auth:_,recovery2Box:t,recovery2KeyBox:t,question2Box:t}),b=a.asObject({loginAuthBox:t,loginAuth:c}),S=a.asObject({userId:c,userTextBox:t}),E=a.asObject({approvedVouchers:a.asOptional(a.asArray(a.asString)),rejectedVouchers:a.asOptional(a.asArray(a.asString))}),D=a.asObject({keyBoxes:a.asArray(t),newSyncKeys:a.asOptional(a.asArray(a.asString),()=>[])}),ra=a.asObject({appId:a.asString,loginId:c,parentBox:a.asOptional(t)}),na=a.asObject({challengeId:a.asString,challengeUri:a.asString}),ea=a.asObject({request:L,replies:a.asArray(j)}),k=a.asValue(!0),M=a.asObject({appId:a.asString,created:a.asDate,loginId:c,syncToken:a.asOptional(a.asString),children:a.asOptional(a.asArray(s=>M(s))),parentBox:a.asOptional(t),otpKey:a.asOptional(a.asEither(k,I)),otpResetDate:a.asOptional(a.asDate),otpTimeout:a.asOptional(a.asNumber),passwordAuthBox:a.asOptional(t),passwordAuthSnrp:a.asOptional(g),passwordBox:a.asOptional(a.asEither(k,t)),passwordKeySnrp:a.asOptional(g),pin2Box:a.asOptional(a.asEither(k,t)),pin2KeyBox:a.asOptional(t),pin2TextBox:a.asOptional(t),question2Box:a.asOptional(t),recovery2Box:a.asOptional(a.asEither(k,t)),recovery2KeyBox:a.asOptional(t),loginAuthBox:a.asOptional(t),userId:a.asOptional(c),userTextBox:a.asOptional(t),pendingVouchers:a.asOptional(a.asArray(A),()=>[]),keyBoxes:a.asOptional(a.asArray(t)),mnemonicBox:a.asOptional(t),rootKeyBox:a.asOptional(t),syncKeyBox:a.asOptional(t)}),oa=a.asArray(a.asObject({loginId:c,otpResetPending:a.asOptional(a.asBoolean,!1),pendingVouchers:a.asOptional(a.asArray(A),()=>[]),recovery2Corrupt:a.asOptional(a.asBoolean,!1)})),R=a.asObject({login_id:a.asOptional(c),otp_reset_auth:a.asOptional(a.asString),otp_timeout_date:a.asOptional(a.asDate),reason:a.asOptional(a.asValue("ip","otp"),"otp"),voucher_activates:a.asOptional(a.asDate),voucher_auth:a.asOptional(c),voucher_id:a.asOptional(a.asString)}),ta=a.asObject({otpResetDate:a.asDate}),T=a.asObject({wait_seconds:a.asOptional(a.asNumber)}),sa=a.asObject({question2Box:t}),ia=a.asObject({loginId:c,passwordAuthSnrp:a.asOptional(g),questionBox:a.asOptional(t),questionKeySnrp:a.asOptional(g),recoveryAuthSnrp:a.asOptional(g)}),da=a.uncleaner(t),pa=a.uncleaner(j),ya=a.uncleaner(L),wa=a.uncleaner(p),ba=a.uncleaner(u),ga=a.uncleaner(l),ha=a.uncleaner(B),fa=a.uncleaner(O),Ea=a.uncleaner(v),Oa=a.uncleaner(m),va=a.uncleaner(w),Pa=a.uncleaner(b),Sa=a.uncleaner(S),ma=a.uncleaner(E),Ca=a.uncleaner(D),Ia=a.uncleaner(ra),_a=a.uncleaner(na),Ba=a.uncleaner(ea),Aa=a.uncleaner(M),La=a.uncleaner(oa),ja=a.uncleaner(R),Da=a.uncleaner(ta),ka=a.uncleaner(T),Ma=a.uncleaner(sa),Ra=a.uncleaner(ia);function U(s,e="Login requires a CAPTCHA"){if(!(this instanceof U))throw new TypeError("Class constructor ChallengeError cannot be invoked without 'new'");var o;function i(d){return o=new Error(d),Object.defineProperty(o,"constructor",{value:U,configurable:!0,writable:!0}),o}return i(e),o.name="ChallengeError",o.challengeId=s.challengeId,o.challengeUri=s.challengeUri,o}function N(s="Please send a larger amount"){if(!(this instanceof N))throw new TypeError("Class constructor DustSpendError cannot be invoked without 'new'");var e;function o(i){return e=new Error(i),Object.defineProperty(e,"constructor",{value:N,configurable:!0,writable:!0}),e}return o(s),e.name="DustSpendError",e}function K(s){if(!(this instanceof K))throw new TypeError("Class constructor InsufficientFundsError cannot be invoked without 'new'");var e;function o(P){return e=new Error(P),Object.defineProperty(e,"constructor",{value:K,configurable:!0,writable:!0}),e}const{tokenId:i=null,networkFee:d}=s!=null?s:{};return o(`Insufficient ${i!=null?i:"funds"}`),e.tokenId=i,e.networkFee=d,e.name="InsufficientFundsError",e}function q(s="Cannot reach the network"){if(!(this instanceof q))throw new TypeError("Class constructor NetworkError cannot be invoked without 'new'");var e;function o(i){return e=new Error(i),Object.defineProperty(e,"constructor",{value:q,configurable:!0,writable:!0}),e}return o(s),e.name="NetworkError",e}function F(s="Unable to create zero-amount transaction."){if(!(this instanceof F))throw new TypeError("Class constructor NoAmountSpecifiedError cannot be invoked without 'new'");var e;function o(i){return e=new Error(i),Object.defineProperty(e,"constructor",{value:F,configurable:!0,writable:!0}),e}return o(s),e.name="NoAmountSpecifiedError",e}function $(s="The application is too old. Please upgrade."){if(!(this instanceof $))throw new TypeError("Class constructor ObsoleteApiError cannot be invoked without 'new'");var e;function o(i){return e=new Error(i),Object.defineProperty(e,"constructor",{value:$,configurable:!0,writable:!0}),e}return o(s),e.name="ObsoleteApiError",e}function V(s,e="Invalid OTP token"){if(!(this instanceof V))throw new TypeError("Class constructor OtpError cannot be invoked without 'new'");var o;function i(P){return o=new Error(P),Object.defineProperty(o,"constructor",{value:V,configurable:!0,writable:!0}),o}i(e),o.name="OtpError",o.reason="otp";const d=a.asMaybe(R)(s);if(d!=null)return d.login_id!=null&&(o.loginId=f.base64.stringify(d.login_id)),o.resetToken=d.otp_reset_auth,o.reason=d.reason,o.resetDate=d.otp_timeout_date,o.voucherActivates=d.voucher_activates,d.voucher_auth!=null&&(o.voucherAuth=f.base64.stringify(d.voucher_auth)),o.voucherId=d.voucher_id,o}function z(s,e="Invalid password"){if(!(this instanceof z))throw new TypeError("Class constructor PasswordError cannot be invoked without 'new'");var o;function i(P){return o=new Error(P),Object.defineProperty(o,"constructor",{value:z,configurable:!0,writable:!0}),o}i(e),o.name="PasswordError";const d=a.asMaybe(T)(s);if(d!=null)return o.wait=d.wait_seconds,o}function G(s="Not enough confirmed funds"){if(!(this instanceof G))throw new TypeError("Class constructor PendingFundsError cannot be invoked without 'new'");var e;function o(i){return e=new Error(i),Object.defineProperty(e,"constructor",{value:G,configurable:!0,writable:!0}),e}return o(s),e.name="PendingFundsError",e}function Y(s="Wallets can not be the same currency"){if(!(this instanceof Y))throw new TypeError("Class constructor SameCurrencyError cannot be invoked without 'new'");var e;function o(i){return e=new Error(i),Object.defineProperty(e,"constructor",{value:Y,configurable:!0,writable:!0}),e}return o(s),e.name="SameCurrencyError",e}function W(s="Spending to self"){if(!(this instanceof W))throw new TypeError("Class constructor SpendToSelfError cannot be invoked without 'new'");var e;function o(i){return e=new Error(i),Object.defineProperty(e,"constructor",{value:W,configurable:!0,writable:!0}),e}return o(s),e.name="SpendToSelfError",e}function H(s,e,o="from"){if(!(this instanceof H))throw new TypeError("Class constructor SwapAboveLimitError cannot be invoked without 'new'");var i;function d(P){return i=new Error(P),Object.defineProperty(i,"constructor",{value:H,configurable:!0,writable:!0}),i}return d("Amount is too high"),i.name="SwapAboveLimitError",i.pluginId=s.pluginId,i.nativeMax=e,i.direction=o,i}function Z(s,e,o="from"){if(!(this instanceof Z))throw new TypeError("Class constructor SwapBelowLimitError cannot be invoked without 'new'");var i;function d(P){return i=new Error(P),Object.defineProperty(i,"constructor",{value:Z,configurable:!0,writable:!0}),i}return d("Amount is too low"),i.name="SwapBelowLimitError",i.pluginId=s.pluginId,i.nativeMin=e,i.direction=o,i}function Q(s,e){if(!(this instanceof Q))throw new TypeError("Class constructor SwapCurrencyError cannot be invoked without 'new'");var o;function i(tr){return o=new Error(tr),Object.defineProperty(o,"constructor",{value:Q,configurable:!0,writable:!0}),o}const{fromWallet:d,toWallet:P,fromTokenId:x,toTokenId:aa}=e,rr=d.currencyConfig.currencyInfo.pluginId,nr=P.currencyConfig.currencyInfo.pluginId,er=`${rr}:${String(x)}`,or=`${nr}:${String(aa)}`;return i(`${s.displayName} does not support ${er} to ${or}`),o.name="SwapCurrencyError",o.pluginId=s.pluginId,o.fromTokenId=x!=null?x:null,o.toTokenId=aa!=null?aa:null,o}function J(s,e){if(!(this instanceof J))throw new TypeError("Class constructor SwapPermissionError cannot be invoked without 'new'");var o;function i(d){return o=new Error(d),Object.defineProperty(o,"constructor",{value:J,configurable:!0,writable:!0}),o}return e!=null?i(e):i("You are not allowed to make this trade"),o.name="SwapPermissionError",o.pluginId=s.pluginId,o.reason=e,o}function X(s="Invalid username"){if(!(this instanceof X))throw new TypeError("Class constructor UsernameError cannot be invoked without 'new'");var e;function o(i){return e=new Error(i),Object.defineProperty(e,"constructor",{value:X,configurable:!0,writable:!0}),e}return o(s),e.name="UsernameError",e}function y(s){return function(o){if(o instanceof Error&&o.name===s)return o}}const Ta=y("ChallengeError"),Ua=y("DustSpendError"),Na=y("InsufficientFundsError"),Ka=y("NetworkError"),qa=y("NoAmountSpecifiedError"),Fa=y("ObsoleteApiError"),$a=y("OtpError"),Va=y("PasswordError"),za=y("PendingFundsError"),Ga=y("SameCurrencyError"),Ya=y("SpendToSelfError"),Wa=y("SwapAboveLimitError"),Ha=y("SwapBelowLimitError"),Za=y("SwapCurrencyError"),Qa=y("SwapPermissionError"),Ja=y("UsernameError"),ca=a.asObject(t),Xa=a.asObject({loginId:c,voucherAuth:c,voucherId:a.asString,created:a.asDate,activates:a.asDate,status:a.asValue("pending","approved","rejected"),ip:a.asString,ipDescription:a.asString,deviceDescription:a.asOptional(a.asString)}),ua=a.asObject({appId:a.asString,created:a.asOptional(a.asDate,()=>new Date),loginId:c,children:a.asOptional(a.asArray(s=>ua(s)),()=>[]),parentBox:a.asOptional(t),parentId:()=>{},otpKey:a.asOptional(I),otpResetAuth:a.asOptional(a.asString),otpResetDate:a.asOptional(a.asDate),otpTimeout:a.asOptional(a.asNumber),passwordAuth:a.asOptional(c),passwordAuthBox:a.asOptional(t),passwordAuthSnrp:a.asOptional(g),passwordBox:a.asOptional(t),passwordKeySnrp:a.asOptional(g),pin2Id:a.asOptional(c),pin2Auth:a.asOptional(c),pin2Box:a.asOptional(t),pin2KeyBox:a.asOptional(t),pin2TextBox:a.asOptional(t),recovery2Id:a.asOptional(c),recovery2Auth:a.asOptional(_),question2Box:a.asOptional(t),recovery2Box:a.asOptional(t),recovery2KeyBox:a.asOptional(t),loginAuth:a.asOptional(c),loginAuthBox:a.asOptional(t),userId:a.asOptional(c),userTextBox:a.asOptional(t),keyBoxes:a.asOptional(a.asArray(t),()=>[]),mnemonicBox:a.asOptional(t),rootKeyBox:a.asOptional(t),syncKeyBox:a.asOptional(t),vouchers:a.asOptional(a.asArray(Xa),()=>[]),pinBox:a.asOptional(t),pinId:a.asOptional(a.asString),pinKeyBox:a.asOptional(t)}),xa=a.uncleaner(ua),ar=a.uncleaner(ca);r.lJ=U,r.Yy=N,r.C_=K,r.F7=q,r.$D=F,r.D1=$,r.XH=V,r.Yr=z,r.Vq=G,r.AQ=Y,r.l0=W,r.I9=H,r.q0=Z,r.Iz=Q,r.d2=J,r.cI=X,r.rS=C,r.rZ=I,r._y=c,r.Uk=na,r.zr=l,r.lK=B,r.t3=O,r.Bp=v,r.bt=m,r.D0=w,r.gN=b,r.oN=S,r.xK=E,r.mm=D,r.jS=ra,r.Ei=t,r.NF=j,r.Nz=L,r.OU=ua,r.mG=A,r.TU=ca,r.Ko=g,r.EG=Xa,r.$5=ea,r.dg=M,r.Wo=p,r.zB=u,r.aQ=Ta,r.y$=Ua,r.X7=Na,r.g4=Ka,r.xz=qa,r.fT=Fa,r.zQ=$a,r.sl=Va,r.mc=za,r.q=Ga,r.SS=Ya,r.Yl=Wa,r.Gq=Ha,r.UW=Za,r.J_=Qa,r.L=Ja,r.pZ=oa,r.gd=R,r.IW=ta,r.j5=T,r.BB=_,r.gg=sa,r.v0=ia,r.O5=_a,r.qF=ga,r.Mu=ha,r.c4=fa,r.kd=Ea,r.JC=Oa,r.hf=va,r.aD=Pa,r.Yn=Sa,r.E3=ma,r.xc=Ca,r.Ml=Ia,r.ZT=da,r.Lh=pa,r.wN=ya,r.yd=xa,r.zP=ar,r.i5=Ba,r.YU=Aa,r.it=wa,r.Ho=ba,r.lG=La,r.xP=ja,r.KG=Da,r.Iq=ka,r.zi=Ma,r.iZ=Ra},55352:function(la,r){Object.defineProperty(r,"__esModule",{value:!0});function h(p,u,l){var B;if(l===void 0&&(l={}),!u.codes){u.codes={};for(var O=0;O<u.chars.length;++O)u.codes[u.chars[O]]=O}if(!l.loose&&p.length*u.bits&7)throw new SyntaxError("Invalid padding");for(var v=p.length;p[v-1]==="=";)if(--v,!l.loose&&!((p.length-v)*u.bits&7))throw new SyntaxError("Invalid padding");for(var m=new((B=l.out)!=null?B:Uint8Array)(v*u.bits/8|0),w=0,b=0,S=0,E=0;E<v;++E){var D=u.codes[p[E]];if(D===void 0)throw new SyntaxError("Invalid character "+p[E]);b=b<<u.bits|D,w+=u.bits,w>=8&&(w-=8,m[S++]=255&b>>w)}if(w>=u.bits||255&b<<8-w)throw new SyntaxError("Unexpected end of data");return m}function n(p,u,l){l===void 0&&(l={});for(var B=l,O=B.pad,v=O===void 0?!0:O,m=(1<<u.bits)-1,w="",b=0,S=0,E=0;E<p.length;++E)for(S=S<<8|255&p[E],b+=8;b>u.bits;)b-=u.bits,w+=u.chars[m&S>>b];if(b&&(w+=u.chars[m&S<<u.bits-b]),v)for(;w.length*u.bits&7;)w+="=";return w}var a={chars:"0123456789ABCDEF",bits:4},f={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bits:5},C={chars:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bits:5},I={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},c={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6},A={parse:function(u,l){return h(u.toUpperCase(),a,l)},stringify:function(u,l){return n(u,a,l)}},t={parse:function(u,l){return l===void 0&&(l={}),h(l.loose?u.toUpperCase().replace(/0/g,"O").replace(/1/g,"L").replace(/8/g,"B"):u,f,l)},stringify:function(u,l){return n(u,f,l)}},g={parse:function(u,l){return h(u,C,l)},stringify:function(u,l){return n(u,C,l)}},L={parse:function(u,l){return h(u,I,l)},stringify:function(u,l){return n(u,I,l)}},j={parse:function(u,l){return h(u,c,l)},stringify:function(u,l){return n(u,c,l)}},_={parse:h,stringify:n};r.base16=A,r.base32=t,r.base32hex=g,r.base64=L,r.base64url=j,r.codec=_},94935:function(la,r,h){h.d(r,{$D:function(){return c},C_:function(){return C},l0:function(){return _}});var n=h(18595);const a=n.lJ,f=n.Yy,C=n.C_,I=n.F7,c=n.$D,A=n.D1,t=n.XH,g=n.Yr,L=n.Vq,j=n.AQ,_=n.l0,p=n.I9,u=n.q0,l=n.Iz,B=n.d2,O=n.cI,v=n.rS,m=n.rZ,w=n._y,b=n.Uk,S=n.zr,E=n.lK,D=n.t3,ra=n.Bp,na=n.bt,ea=n.D0,k=n.gN,M=n.oN,oa=n.xK,R=n.mm,ta=n.jS,T=n.Ei,sa=n.NF,ia=n.Nz,da=n.OU,pa=n.mG,ya=n.TU,wa=n.Ko,ba=n.EG,ga=n.$5,ha=n.dg,fa=n.Wo,Ea=n.zB,Oa=n.aQ,va=n.y$,Pa=n.X7,Sa=n.g4,ma=n.xz,Ca=n.fT,Ia=n.zQ,_a=n.sl,Ba=n.mc,Aa=n.q,La=n.SS,ja=n.Yl,Da=n.Gq,ka=n.UW,Ma=n.J_,Ra=n.L,U=n.pZ,N=n.gd,K=n.IW,q=n.j5,F=n.BB,$=n.gg,V=n.v0,z=n.O5,G=n.qF,Y=n.Mu,W=n.c4,H=n.kd,Z=n.JC,Q=n.hf,J=n.aD,X=n.Yn,y=n.E3,Ta=n.xc,Ua=n.Ml,Na=n.ZT,Ka=n.Lh,qa=n.wN,Fa=n.yd,$a=n.zP,Va=n.i5,za=n.YU,Ga=n.it,Ya=n.Ho,Wa=n.lG,Ha=n.xP,Za=n.KG,Qa=n.Iq,Ja=n.zi,ca=n.iZ}}]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[6757],{16757:function(nt,X,L){L.d(X,{P:function(){return Y}});var k=L(77591),_=L(94935),K=L(20918),u=L(62177),S=L(76714),v=L(82448);function W(w,t){var n;const{memos:i=[]}=w,{displayName:r,memoOptions:c=[],multipleMemos:o=!1}=t,{memoName:h="memo"}=(n=c[0])!=null?n:{};for(const d of i){const g=c.filter(D=>d.type===D.type);if(g.length<1)throw new Error(`${r} ${h}: cannot be type ${d.type}`);const C=g.map(D=>U(d,D)).find(D=>D!=null);if(C!=null)throw new Error(`${r} ${h}: ${C}`)}if(!o&&i.length>1)throw new Error(`${r} only supports one ${h}`)}function U(w,t){if(t.type==="text"&&t.maxLength!=null&&w.value.length>t.maxLength)return`cannot be longer than ${t.maxLength} characters`;if(t.type==="number"){const n=(0,v.Vk)(u.jD)(w.value);if(n==null)return"is not a valid number";if(t.maxValue!=null&&(0,k.gt)(n,t.maxValue))return`cannot be greater than ${t.maxValue}`}if(t.type==="hex"){const n=(0,v.Vk)(u.rS)(w.value);if(n==null)return"is not valid hexadecimal";if(t.maxBytes!=null&&n.length>t.maxBytes)return`cannot be longer than ${t.maxBytes} bytes`;if(t.minBytes!=null&&n.length<t.minBytes)return`cannot be shorter than ${t.minBytes} bytes`}}var q=Object.defineProperty,j=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,Z=Object.prototype.propertyIsEnumerable,R=(w,t,n)=>t in w?q(w,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):w[t]=n,$=(w,t)=>{for(var n in t||(t={}))F.call(t,n)&&R(w,n,t[n]);if(j)for(var n of j(t))Z.call(t,n)&&R(w,n,t[n]);return w},p=(w,t,n)=>new Promise((i,r)=>{var c=d=>{try{h(n.next(d))}catch(g){r(g)}},o=d=>{try{h(n.throw(d))}catch(g){r(g)}},h=d=>d.done?i(d.value):Promise.resolve(d.value).then(c,o);h((n=n.apply(w,t)).next())});const z=1e4,V=1e3,Q=3600*24;class Y{constructor(t,n,i,r){this.allTokens=[],this.allTokensMap={},this.builtinTokens={},this.customTokens={},this.enabledTokenIds=[],this.enabledTokens=[];const{builtinTokens:c,currencyInfo:o}=t,{callbacks:h,customTokens:d,enabledTokenIds:g,log:C,walletLocalDisklet:D}=r;this.tools=n,this.log=C,this.warn=(I,b)=>this.log.warn(I+(0,S.HY)(b)),this.error=(I,b)=>this.log.error(I+(0,S.HY)(b)),this.engineOn=!1,this.addressesChecked=!1,this.tokenCheckBalanceStatus={},this.tokenCheckTransactionsStatus={},this.walletLocalDataDirty=!1,this.transactionsChangedArray=[],this.transactionList={},this.transactionListDirty=!1,this.transactionsLoaded=!1,this.txIdMap={},this.txIdList={},this.walletInfo=i,this.walletId=i.id,this.currencyInfo=o,this.timers={},this.otherData=void 0,this.minimumAddressBalance="0";const{currencyCode:E}=o;this.transactionList[E]=[],this.txIdMap[E]={},this.txIdList[E]=[],this.builtinTokens=c,this.changeCustomTokensSync(d),this.changeEnabledTokenIdsSync(g),r.userSettings!=null?this.currentSettings=r.userSettings:this.currentSettings=this.currencyInfo.defaultSettings,this.currencyEngineCallbacks=h,this.walletLocalDisklet=D,typeof this.walletInfo.keys.publicKey!="string"&&(this.walletInfo.keys.publicKey=i.keys.publicKey),this.walletLocalData={blockHeight:0,lastAddressQueryHeight:0,lastTransactionQueryHeight:{},lastTransactionDate:{},publicKey:"",totalBalances:{},lastCheckedTxsDropped:0,numUnconfirmedSpendTxs:0,numTransactions:{},unactivatedTokenIds:[],otherData:void 0},this.log(`Created Wallet Type ${this.walletInfo.type} for Currency Plugin ${this.currencyInfo.pluginId}`),this.checkBalances=(I,b)=>{var P,A;const{nativeAmount:B,parentNetworkFee:O}=I,N=this.currencyInfo.currencyCode,G=b!=null?this.allTokensMap[b].currencyCode:N,e=(P=this.walletLocalData.totalBalances[G])!=null?P:"0",s=N,a=(A=this.walletLocalData.totalBalances[s])!=null?A:"0";if((0,k.gt)((0,k.abs)(B),e))throw new _.C_({tokenId:b});if(O!=null&&(0,k.gt)(O,a))throw new _.C_({networkFee:O,tokenId:null})},this.makeEdgeTransactionAmounts=(I,b,P)=>{let A=`-${I}`,B=b,O;return P!=null?(O=B,B="0"):A=(0,k.sub)(A,B),{nativeAmount:A,networkFee:B,parentNetworkFee:O}}}isSpendTx(t){if(t.nativeAmount!==""){if(t.nativeAmount.slice(0,1)==="-")return!0;if((0,k.gt)(t.nativeAmount,"0"))return!1}let n=!0;if(t.ourReceiveAddresses.length>0)for(const i of t.ourReceiveAddresses)i===this.walletLocalData.publicKey&&(n=!1);return n}setOtherData(t){throw new Error(`Unimplemented setOtherData for ${this.walletInfo.type}`)}loadTransactions(){return p(this,null,function*(){if(this.transactionsLoaded){this.log("Transactions already loaded");return}this.transactionsLoaded=!0;const t=this.walletLocalDisklet;let n;try{const o=yield t.getText(u.TD);n=JSON.parse(o)}catch{this.log("Could not load txidList file. Failure is ok on new device"),yield t.setText(u.TD,JSON.stringify(this.txIdList))}let i;try{const o=yield t.getText(u.DZ);i=JSON.parse(o)}catch{this.log("Could not load txidMap file. Failure is ok on new device"),yield t.setText(u.DZ,JSON.stringify(this.txIdMap))}let r;try{const o=yield t.getText(u.tC);r=JSON.parse(o)}catch(o){o.code==="ENOENT"?(this.log("Could not load transactionList file. Failure is ok on new device"),yield t.setText(u.tC,JSON.stringify(this.transactionList))):this.log.crash(o,this.walletLocalData)}let c=!0;for(const o of Object.keys(this.transactionList))if(this.transactionList[o]!=null&&this.transactionList[o].length>0){c=!1;break}if(c)this.transactionList=r!=null?r:this.transactionList,this.txIdList=n!=null?n:this.txIdList,this.txIdMap=i!=null?i:this.txIdMap;else if(r!=null)for(const o of Object.keys(r))for(const h of r[o])this.addTransaction(o,h);for(const o in this.transactionList)this.walletLocalData.numTransactions[o]=this.transactionList[o].length})}loadEngine(){return p(this,null,function*(){var t;const{walletInfo:n}=this,{currencyCode:i}=this.currencyInfo;this.walletInfo.keys.publicKey==null&&(this.walletInfo.keys.publicKey=n.keys.publicKey);const r=this.walletLocalDisklet;try{const c=yield r.getText(u.Pe);this.walletLocalData=(0,u.O2)(JSON.parse(c)),this.walletLocalData.publicKey=this.walletInfo.keys.publicKey}catch{try{this.log("No walletLocalData setup yet: Failure is ok"),this.walletLocalData=(0,u.O2)({}),this.walletLocalData.publicKey=this.walletInfo.keys.publicKey,yield r.setText(u.Pe,JSON.stringify(this.walletLocalData))}catch(o){throw this.error("Error writing to localDataStore. Engine not started: ",o),o}}this.setOtherData((t=this.walletLocalData.otherData)!=null?t:{}),this.walletLocalDataDirty=!(0,S.dQ)(this.otherData,this.walletLocalData.otherData),this.tokenCheckBalanceStatus[i]=0,this.tokenCheckTransactionsStatus[i]=0,this.doInitialBalanceCallback(),this.doInitialUnactivatedTokenIdsCallback()})}findTransaction(t,n){if(this.txIdMap[t]!=null){const i=this.txIdMap[t][n];if(typeof i=="number")return i}return-1}sortTxByDate(t,n){return n.date-t.date}addTransaction(t,n,i){this.log("executing addTransaction: ",n.txid),n.otherParams==null&&(n.otherParams={}),n.blockHeight<1&&(n.otherParams.lastSeenTime=i!=null?i:Math.round(Date.now()/1e3));const r=(0,S.f0)(n.txid),c=this.findTransaction(t,r);let o=!1;if(c===-1){if(this.isSpendTx(n)&&n.blockHeight===0&&(this.walletLocalData.numUnconfirmedSpendTxs++,this.walletLocalDataDirty=!0),o=!0,typeof this.transactionList[t]>"u")this.transactionList[t]=[];else if(this.transactionList[t].length>=V)return;this.transactionList[t].push(n),this.walletLocalData.numTransactions[t]=this.transactionList[t].length,this.walletLocalDataDirty=!0,this.transactionListDirty=!0,this.transactionsChangedArray.push(n),this.warn(`addTransaction new tx: ${n.txid}`)}else{const d=this.transactionList[t][c],{otherParams:g={}}=d,{otherParams:C={}}=n;(d.blockHeight<n.blockHeight||d.blockHeight===0&&n.blockHeight<0||d.blockHeight===n.blockHeight&&(d.networkFee!==n.networkFee||d.nativeAmount!==n.nativeAmount||g.lastSeenTime!==C.lastSeenTime||d.date!==n.date))&&(this.isSpendTx(n)&&n.blockHeight!==0&&d.blockHeight===0&&this.walletLocalData.numUnconfirmedSpendTxs--,d.date!==n.date&&(o=!0),this.warn(`addTransaction: update ${n.txid} height:${n.blockHeight}`),this.walletLocalDataDirty=!0,this.updateTransaction(t,n,c))}o&&this.sortTransactions(t)}sortTransactions(t){this.transactionList[t].sort(this.sortTxByDate);const n=[];let i=0;for(const r of this.transactionList[t])this.txIdMap[t]==null&&(this.txIdMap[t]={}),this.txIdMap[t][(0,S.f0)(r.txid)]=i,n.push((0,S.f0)(r.txid)),i++;this.txIdList[t]=n}checkDroppedTransactionsThrottled(){const t=Date.now()/1e3;t-this.walletLocalData.lastCheckedTxsDropped>Q&&(this.checkDroppedTransactions(t),this.walletLocalData.lastCheckedTxsDropped=t,this.walletLocalDataDirty=!0,this.transactionsChangedArray.length>0&&(this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[]))}checkDroppedTransactions(t){let n=0;for(const i in this.transactionList)for(let r=0;r<this.transactionList[i].length;r++){const c=this.transactionList[i][r];if(c.blockHeight===0){const{otherParams:o={}}=c,h=o.lastSeenTime;t-h>Q?(c.blockHeight=-1,c.nativeAmount="0",this.transactionsChangedArray.push(c)):this.isSpendTx(c)&&n++}}this.walletLocalData.numUnconfirmedSpendTxs=n,this.walletLocalDataDirty=!0}updateBalance(t,n){const i=this.walletLocalData.totalBalances[t];this.walletLocalData.totalBalances[t]==null&&(this.walletLocalData.totalBalances[t]="0"),(i==null||!(0,k.eq)(n,i))&&(this.walletLocalData.totalBalances[t]=n,this.walletLocalDataDirty=!0,this.warn(`${t}: token Address balance: ${n}`),this.currencyEngineCallbacks.onBalanceChanged(t,n)),this.tokenCheckBalanceStatus[t]=1,this.updateOnAddressesChecked()}updateTransaction(t,n,i){this.transactionList[t][i]=n,this.transactionListDirty=!0,this.transactionsChangedArray.push(n),this.warn(`updateTransaction: ${n.txid}`)}saveWalletLoop(){return p(this,null,function*(){const t=this.walletLocalDisklet,n=[];if(this.transactionListDirty){yield this.loadTransactions(),this.log("transactionListDirty. Saving...");let i=JSON.stringify(this.transactionList);n.push(t.setText(u.tC,i).catch(r=>{this.error("Error saving transactionList ",r)})),i=JSON.stringify(this.txIdList),n.push(t.setText(u.TD,i).catch(r=>{this.error("Error saving txIdList ",r)})),i=JSON.stringify(this.txIdMap),n.push(t.setText(u.DZ,i).catch(r=>{this.error("Error saving txIdMap ",r)})),yield Promise.all(n),this.transactionListDirty=!1}if(this.walletLocalDataDirty){this.log("walletLocalDataDirty. Saving..."),this.walletLocalData.otherData=this.otherData;const i=JSON.stringify(this.walletLocalData);yield t.setText(u.Pe,i).then(()=>{this.walletLocalDataDirty=!1}).catch(r=>{this.error("Error saving walletLocalData ",r)})}})}doInitialBalanceCallback(){var t;for(const n of this.enabledTokens)try{this.currencyEngineCallbacks.onBalanceChanged(n,(t=this.walletLocalData.totalBalances[n])!=null?t:"0")}catch(i){this.error(`doInitialBalanceCallback Error for currencyCode ${n}`,i)}}doInitialUnactivatedTokenIdsCallback(){try{this.walletLocalData.unactivatedTokenIds!=null&&this.walletLocalData.unactivatedTokenIds.length>0&&this.currencyEngineCallbacks.onUnactivatedTokenIdsChanged(this.walletLocalData.unactivatedTokenIds)}catch(t){this.error("doInitialUnactivatedTokenIdsCallback Error",t)}}addToLoop(t,n){return p(this,null,function*(){try{yield this[t]()}catch(i){this.error(`Error in Loop: ${t} `,i)}return this.engineOn&&(this.timers[t]=setTimeout(()=>{this.engineOn&&this.addToLoop(t,n).catch(i=>this.log(i.message))},n)),!0})}getTokenInfo(t){return this.allTokens.find(n=>n.currencyCode===t)}updateOnAddressesChecked(){var t,n;if(this.addressesChecked)return;const i=this.enabledTokens,r=1/i.length;let c=0,o=0;for(const h of i){const d=(t=this.tokenCheckBalanceStatus[h])!=null?t:0,g=(n=this.tokenCheckTransactionsStatus[h])!=null?n:0;c+=(d+g)/2*r,d===1&&g===1&&o++}o===i.length&&(c=1,this.addressesChecked=!0),this.log(`${this.walletId} syncRatio of: ${c}`),this.currencyEngineCallbacks.onAddressesChecked(c)}clearBlockchainCache(){return p(this,null,function*(){this.walletLocalData=(0,u.O2)({publicKey:this.walletLocalData.publicKey}),this.walletLocalDataDirty=!0,this.addressesChecked=!1,this.tokenCheckBalanceStatus={},this.tokenCheckTransactionsStatus={},this.transactionList={},this.txIdList={},this.txIdMap={},this.transactionListDirty=!0,this.setOtherData({}),yield this.saveWalletLoop()})}startEngine(){return p(this,null,function*(){this.addToLoop("saveWalletLoop",z).catch(()=>{})})}killEngine(){return p(this,null,function*(){this.engineOn=!1;for(const t in this.timers)clearTimeout(this.timers[t]);this.timers={}})}changeUserSettings(t){return p(this,null,function*(){this.currentSettings=t})}getBlockHeight(){return this.walletLocalData.blockHeight}changeCustomTokensSync(t){this.customTokens={};for(const n of Object.keys(t)){const i=t[n];try{(0,K.Rp)(i)}catch{this.log.warn(`Dropping custom token "${i.currencyCode}" / ${n}`);continue}this.customTokens[n]=i}this.allTokensMap=$($({},this.customTokens),this.builtinTokens),this.allTokens=(0,K.ZS)(this.allTokensMap)}changeCustomTokens(t){return p(this,null,function*(){this.changeCustomTokensSync(t)})}changeEnabledTokenIdsSync(t){const{currencyCode:n}=this.currencyInfo,i=new Set,r=new Set;for(const c of t){const o=this.allTokensMap[c];o!=null&&(i.add(o.currencyCode),r.add(c))}this.enabledTokens=[...i,n],this.enabledTokenIds=[...r]}changeEnabledTokenIds(t){return p(this,null,function*(){this.changeEnabledTokenIdsSync(t)})}getBalance(t){const{tokenId:n}=t,{currencyCode:i}=n==null?this.currencyInfo:this.allTokensMap[n],r=this.walletLocalData.totalBalances[i];return r==null?"0":r}getNumTransactions(t){const{tokenId:n}=t,{currencyCode:i}=n==null?this.currencyInfo:this.allTokensMap[n];return this.walletLocalData.numTransactions[i]==null?0:this.walletLocalData.numTransactions[i]}getTransactions(t){return p(this,null,function*(){const{startDate:n,endDate:i,tokenId:r}=t,{currencyCode:c}=r==null?this.currencyInfo:this.allTokensMap[r];return yield this.loadTransactions(),this.transactionList[c]==null?[]:this.transactionList[c].filter(h=>new Date(h.date)>=(n!=null?n:new Date(0))&&new Date(h.date)<=(i!=null?i:new Date))})}getFreshAddress(t){return p(this,null,function*(){return{publicAddress:this.walletLocalData.publicKey}})}addGapLimitAddresses(t){return p(this,null,function*(){})}isAddressUsed(t){return p(this,null,function*(){return!1})}dumpData(){return p(this,null,function*(){return{walletId:this.walletId.split(" - ")[0],walletType:this.walletInfo.type,data:{pluginType:{pluginId:this.currencyInfo.pluginId},walletLocalData:this.walletLocalData}}})}makeSpendCheck(t){var n,i,r;const{skipChecks:c=!1,tokenId:o}=t;W(t,this.currencyInfo);for(const D of t.spendTargets)if(!c&&D.publicAddress===this.walletLocalData.publicKey)throw new _.l0;if(o!=null&&!this.enabledTokenIds.includes(o))throw new Error("Error: Token not enabled");const{currencyCode:h}=o==null?this.currencyInfo:this.allTokensMap[o],d=(n=this.walletLocalData.totalBalances[h])!=null?n:"0",g={};for(const D of t.spendTargets){const{nativeAmount:E}=D;E!=null&&(g[h]=(i=g[h])!=null?i:"0",g[h]=(0,k.add)(g[h],E))}for(const[D,E]of Object.entries(g)){const I=(r=this.walletLocalData.totalBalances[D])!=null?r:"0";if(!c&&(0,k.lt)(I,E))throw new _.C_({tokenId:o})}const C=(0,S.aL)(h,this.currencyInfo,this.allTokensMap);if(C==null)throw new Error("InternalErrorInvalidCurrencyCode");return{edgeSpendInfo:t,nativeBalance:d,currencyCode:h,denom:C,skipChecks:c}}checkRecipientMinimumBalance(t,n,i){return p(this,null,function*(){if((0,k.gte)(n,this.minimumAddressBalance))return;const r=yield t(i);if((0,k.lt)((0,k.add)(n,r),this.minimumAddressBalance)){const c=this.currencyInfo.denominations.find(h=>h.name===this.currencyInfo.currencyCode);if(c==null)throw new Error("Unknown denom");const o=(0,k.div)(this.minimumAddressBalance,c.multiplier);throw new Error(`Recipient address not activated. A minimum ${o} ${this.currencyInfo.currencyCode} transfer is required to send funds to this address`)}})}saveTx(t){return p(this,null,function*(){this.addTransaction(t.currencyCode,t),this.transactionsChangedArray.forEach(n=>this.warn(`executing back in saveTx and this.transactionsChangedArray is: ${(0,S.oX)(n)}`)),this.transactionsChangedArray.length>0&&this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray)})}resyncBlockchain(){return p(this,null,function*(){throw new Error("not implemented")})}makeSpend(t,n){return p(this,null,function*(){throw new Error("not implemented")})}signTx(t,n){return p(this,null,function*(){throw new Error("not implemented")})}broadcastTx(t,n){return p(this,null,function*(){throw new Error("not implemented")})}}},76714:function(nt,X,L){L.d(X,{EE:function(){return E},HB:function(){return n},HY:function(){return b},KT:function(){return $},NC:function(){return F},QJ:function(){return o},Qs:function(){return Y},Sy:function(){return U},Vs:function(){return c},Wp:function(){return i},X0:function(){return z},Xp:function(){return d},Y7:function(){return A},Z8:function(){return p},a7:function(){return G},aL:function(){return w},ah:function(){return Z},dQ:function(){return O},dg:function(){return V},f0:function(){return W},gc:function(){return R},jT:function(){return g},ml:function(){return r},nu:function(){return P},oX:function(){return D},sD:function(){return h},vq:function(){return j},zR:function(){return I}});var k=L(77591),_=L.n(k),K=L(48764),u=L(82448),S=L(79325),v=(e,s,a)=>new Promise((l,f)=>{var m=T=>{try{x(a.next(T))}catch(M){f(M)}},y=T=>{try{x(a.throw(T))}catch(M){f(M)}},x=T=>T.done?l(T.value):Promise.resolve(T.value).then(m,y);x((a=a.apply(e,s)).next())});function W(e){return e.toLowerCase().replace("0x","")}function U(e){let s=e.length,a,l;for(;s!==0;)l=Math.floor(Math.random()*s),s-=1,a=e[s],e[s]=e[l],e[l]=a;return e}function q(e){return Object.keys(e).length!==0}function j(e){return/^[0-9A-F]+$/i.test($(e))}function F(e){return(0,k.add)(e,"0",16)}function Z(e){const s=e.replace("0x","");return K.Buffer.from(s,"hex")}function R(e,s){return 2*s-e.length>0?e.padStart(2*s,"0"):e}function $(e){return e.indexOf("0x")===0?e.substring(2):e}function p(e){const s=e.toLowerCase(),a=s.startsWith("0x")?s:`0x${s}`;return(0,k.add)(a,"0",10)}function z(e){return(0,k.add)(e,"0",16)}function V(e){return"0x"+S.YU.stringify(e).toLowerCase()}function Q(e){return"0x"+Buffer2.from(e).toString("hex")}function Y(e,s,a,l){for(const f of s.denominations)if(f.name===e)return f;for(const f of a)for(const m of f.denominations)if(m.name===e)return m;for(const f of Object.values(l))for(const m of f.denominations)if(m.name===e)return m}function w(e,s,a){for(const l of s.denominations)if(l.name===e)return l;for(const l of Object.keys(a)){const f=a[l];for(const m of f.denominations)if(m.name===e)return m}}const t=e=>v(void 0,null,function*(){return yield new Promise((s,a)=>setTimeout(a,e))}),n=e=>v(void 0,null,function*(){return yield new Promise(s=>setTimeout(s,e))});function i(e){return v(this,null,function*(){return yield new Promise((s,a)=>{let l=e.length;for(const f of e)f.then(m=>{s(m)},m=>{--l===0&&a(m)})})})}function r(e,s){return v(this,arguments,function*(a,l,f=a.length){const m={};return yield new Promise((y,x)=>{let T=0,M=0,tt=!1;for(const et of a)et.then(J=>{const H=l(J);H!==void 0?(T++,m[H]!==void 0?m[H]++:m[H]=1,!tt&&m[H]>=f&&(tt=!0,y(J))):++M+T===a.length&&x(Error(`Could not resolve ${f} promises`))},J=>{++M+T===a.length&&x(J)})})})}function c(e,s){return v(this,arguments,function*(a,l,f=new Error(`Timeout of ${l}ms exceeded`)){return yield new Promise((m,y)=>{const x=setTimeout(()=>y(f),l);a.then(T=>{m(T),clearTimeout(x)},T=>{y(T),clearTimeout(x)})})})}function o(e,s=5e3){return v(this,null,function*(){let a=e.length;const l=[];for(const f of e){const m=l.length;l.push(f().catch(y=>{throw y.index=m,y})),a>1&&l.push(new Promise(y=>{n(s).then(()=>{y("async_waterfall_timed_out")})}));try{const y=yield Promise.race(l);if(y==="async_waterfall_timed_out"){const x=l.pop();x==null||x.then().catch(),--a}else return y}catch(y){const x=y.index;l.splice(x,1);const T=l.pop();if(T==null||T.then().catch(),--a,a===0)throw y}}})}function h(e,s){if(e.length<=s)return e;const a=[];for(let l=0;l<e.length&&a.length<s;++l){const f=(s-a.length)/(e.length-l);Math.random()<=f&&a.push(e[l])}return a}function d(e){const s=e.otherParams;if(s==null)throw new TypeError("Transaction is missing otherParams");return s}function g(){let e=!1;const s=[];return function(l){return v(this,null,function*(){e&&(yield new Promise(f=>s.push(()=>f(void 0))));try{return e=!0,yield l()}finally{e=!1;const f=s.shift();f!=null&&f()}})}}const C=(0,u.su)({txid:u.XC,spendTargets:(0,u.Zz)((0,u._2)((0,u.su)({currencyCode:u.XC,nativeAmount:u.XC,publicAddress:u.XC,uniqueIdentifier:(0,u.Zz)(u.XC)}))),signedTx:u.XC,otherParams:(0,u.Zz)((0,u.su)({gas:(0,u.Zz)(u.XC),gasPrice:(0,u.Zz)(u.XC),nonceUsed:(0,u.Zz)(u.XC)}))});function D(e){return JSON.stringify(C(e),null,2)}function E(e){const[s,a]=e.split("e");return a==null?e:(0,k.mul)(s,"1"+"0".repeat(parseInt(a))).toString()}function I(e){var s;return(s=e.fetchCors)!=null?s:e.fetch}function b(e){let s="";return e!=null&&(e.name!=null&&(s+=`${e.name} `),e.message!=null&&(s+=e.message)),s}function P(...e){const s={};for(const a of e)if(a!=null)for(const l of Object.keys(a))a[l]!=null&&(s[l]=s[l]!=null&&typeof a[l]=="object"?P(s[l],a[l]):a[l]);return s}function A(e){const[s,a]=e.split(".");return a==null?s:parseInt(a[0])>=5?(0,k.add)(s,"1"):s}const B=e=>console.log(JSON.stringify(e,null,2));function O(e,s){if(typeof e!="object"||typeof s!="object"||e==null||s==null)return e===s;const a=Array.isArray(e),l=Array.isArray(s);if(a!==l)return!1;if(a){if(e.length!==s.length)return!1;for(let y=0;y<e.length;++y)if(!O(e[y],s[y]))return!1;return!0}const f=Object.getOwnPropertyNames(e).filter(y=>e[y]!==void 0),m=Object.getOwnPropertyNames(s).filter(y=>s[y]!==void 0);if(f.length!==m.length)return!1;for(const y of f)if(!Object.prototype.hasOwnProperty.call(s,y)||!O(e[y],s[y]))return!1;return!0}const N=(e,s)=>{for(const a of Object.keys(e)){if(typeof e[a]=="object"){if(typeof s[a]!="object"||!N(e[a],s[a]))return!1;continue}if(e[a]!==s[a])return!1}return!0},G=e=>v(void 0,null,function*(){const{func:s,providers:a}=e,l=a.map(f=>()=>v(void 0,null,function*(){return yield s(f)}));return yield o(U(l))})}}]);
|
|
1
|
+
"use strict";(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[6757],{16757:function(V,O,g){g.d(O,{P:function(){return U}});var d=g(77591),I=g(94935),C=g(20918),h=g(62177),m=g(76714),v=g(82448);function M(u,t){var e;const{memos:n=[]}=u,{displayName:a,memoOptions:i=[],multipleMemos:s=!1}=t,{memoName:l="memo"}=(e=i[0])!=null?e:{};for(const r of n){const c=i.filter(f=>r.type===f.type);if(c.length<1)throw new Error(`${a} ${l}: cannot be type ${r.type}`);const y=c.map(f=>$(r,f)).find(f=>f!=null);if(y!=null)throw new Error(`${a} ${l}: ${y}`)}if(!s&&n.length>1)throw new Error(`${a} only supports one ${l}`)}function $(u,t){if(t.type==="text"&&t.maxLength!=null&&u.value.length>t.maxLength)return`cannot be longer than ${t.maxLength} characters`;if(t.type==="number"){const e=(0,v.Vk)(h.jD)(u.value);if(e==null)return"is not a valid number";if(t.maxValue!=null&&(0,d.gt)(e,t.maxValue))return`cannot be greater than ${t.maxValue}`}if(t.type==="hex"){const e=(0,v.Vk)(h.rS)(u.value);if(e==null)return"is not valid hexadecimal";if(t.maxBytes!=null&&e.length>t.maxBytes)return`cannot be longer than ${t.maxBytes} bytes`;if(t.minBytes!=null&&e.length<t.minBytes)return`cannot be shorter than ${t.minBytes} bytes`}}var P=Object.defineProperty,S=Object.getOwnPropertySymbols,N=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable,E=(u,t,e)=>t in u?P(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,A=(u,t)=>{for(var e in t||(t={}))N.call(t,e)&&E(u,e,t[e]);if(S)for(var e of S(t))H.call(t,e)&&E(u,e,t[e]);return u},o=(u,t,e)=>new Promise((n,a)=>{var i=r=>{try{l(e.next(r))}catch(c){a(c)}},s=r=>{try{l(e.throw(r))}catch(c){a(c)}},l=r=>r.done?n(r.value):Promise.resolve(r.value).then(i,s);l((e=e.apply(u,t)).next())});const K=1e4,_=1e3,B=3600*24;class U{constructor(t,e,n,a){this.allTokens=[],this.allTokensMap={},this.builtinTokens={},this.customTokens={},this.enabledTokenIds=[],this.enabledTokens=[];const{builtinTokens:i,currencyInfo:s}=t,{callbacks:l,customTokens:r,enabledTokenIds:c,log:y,walletLocalDisklet:f}=a;this.tools=e,this.log=y,this.warn=(k,p)=>this.log.warn(k+(0,m.HY)(p)),this.error=(k,p)=>this.log.error(k+(0,m.HY)(p)),this.engineOn=!1,this.addressesChecked=!1,this.tokenCheckBalanceStatus={},this.tokenCheckTransactionsStatus={},this.walletLocalDataDirty=!1,this.transactionsChangedArray=[],this.transactionList={},this.transactionListDirty=!1,this.transactionsLoaded=!1,this.txIdMap={},this.txIdList={},this.walletInfo=n,this.walletId=n.id,this.currencyInfo=s,this.timers={},this.otherData=void 0,this.minimumAddressBalance="0";const{currencyCode:w}=s;this.transactionList[w]=[],this.txIdMap[w]={},this.txIdList[w]=[],this.builtinTokens=i,this.changeCustomTokensSync(r),this.changeEnabledTokenIdsSync(c),a.userSettings!=null?this.currentSettings=a.userSettings:this.currentSettings=this.currencyInfo.defaultSettings,this.currencyEngineCallbacks=l,this.walletLocalDisklet=f,typeof this.walletInfo.keys.publicKey!="string"&&(this.walletInfo.keys.publicKey=n.keys.publicKey),this.walletLocalData={blockHeight:0,lastAddressQueryHeight:0,lastTransactionQueryHeight:{},lastTransactionDate:{},publicKey:"",totalBalances:{},lastCheckedTxsDropped:0,numUnconfirmedSpendTxs:0,numTransactions:{},unactivatedTokenIds:[],otherData:void 0},this.log(`Created Wallet Type ${this.walletInfo.type} for Currency Plugin ${this.currencyInfo.pluginId}`),this.checkBalances=(k,p)=>{var b,L;const{nativeAmount:D,parentNetworkFee:T}=k,x=this.currencyInfo.currencyCode,J=p!=null?this.allTokensMap[p].currencyCode:x,F=(b=this.walletLocalData.totalBalances[J])!=null?b:"0",R=x,j=(L=this.walletLocalData.totalBalances[R])!=null?L:"0";if((0,d.gt)((0,d.abs)(D),F))throw new I.C_({tokenId:p});if(T!=null&&(0,d.gt)(T,j))throw new I.C_({networkFee:T,tokenId:null})},this.makeEdgeTransactionAmounts=(k,p,b)=>{let L=`-${k}`,D=p,T;return b!=null?(T=D,D="0"):L=(0,d.sub)(L,D),{nativeAmount:L,networkFee:D,parentNetworkFee:T}}}isSpendTx(t){if(t.nativeAmount!==""){if(t.nativeAmount.slice(0,1)==="-")return!0;if((0,d.gt)(t.nativeAmount,"0"))return!1}let e=!0;if(t.ourReceiveAddresses.length>0)for(const n of t.ourReceiveAddresses)n===this.walletLocalData.publicKey&&(e=!1);return e}setOtherData(t){throw new Error(`Unimplemented setOtherData for ${this.walletInfo.type}`)}loadTransactions(){return o(this,null,function*(){if(this.transactionsLoaded){this.log("Transactions already loaded");return}this.transactionsLoaded=!0;const t=this.walletLocalDisklet;let e;try{const s=yield t.getText(h.TD);e=JSON.parse(s)}catch{this.log("Could not load txidList file. Failure is ok on new device"),yield t.setText(h.TD,JSON.stringify(this.txIdList))}let n;try{const s=yield t.getText(h.DZ);n=JSON.parse(s)}catch{this.log("Could not load txidMap file. Failure is ok on new device"),yield t.setText(h.DZ,JSON.stringify(this.txIdMap))}let a;try{const s=yield t.getText(h.tC);a=JSON.parse(s)}catch(s){s.code==="ENOENT"?(this.log("Could not load transactionList file. Failure is ok on new device"),yield t.setText(h.tC,JSON.stringify(this.transactionList))):this.log.crash(s,this.walletLocalData)}let i=!0;for(const s of Object.keys(this.transactionList))if(this.transactionList[s]!=null&&this.transactionList[s].length>0){i=!1;break}if(i)this.transactionList=a!=null?a:this.transactionList,this.txIdList=e!=null?e:this.txIdList,this.txIdMap=n!=null?n:this.txIdMap;else if(a!=null)for(const s of Object.keys(a))for(const l of a[s])this.addTransaction(s,l);for(const s in this.transactionList)this.walletLocalData.numTransactions[s]=this.transactionList[s].length})}loadEngine(){return o(this,null,function*(){var t;const{walletInfo:e}=this,{currencyCode:n}=this.currencyInfo;this.walletInfo.keys.publicKey==null&&(this.walletInfo.keys.publicKey=e.keys.publicKey);const a=this.walletLocalDisklet;try{const i=yield a.getText(h.Pe);this.walletLocalData=(0,h.O2)(JSON.parse(i)),this.walletLocalData.publicKey=this.walletInfo.keys.publicKey}catch{try{this.log("No walletLocalData setup yet: Failure is ok"),this.walletLocalData=(0,h.O2)({}),this.walletLocalData.publicKey=this.walletInfo.keys.publicKey,yield a.setText(h.Pe,JSON.stringify(this.walletLocalData))}catch(s){throw this.error("Error writing to localDataStore. Engine not started: ",s),s}}this.setOtherData((t=this.walletLocalData.otherData)!=null?t:{}),this.walletLocalDataDirty=!(0,m.dQ)(this.otherData,this.walletLocalData.otherData),this.tokenCheckBalanceStatus[n]=0,this.tokenCheckTransactionsStatus[n]=0,this.doInitialBalanceCallback(),this.doInitialUnactivatedTokenIdsCallback()})}findTransaction(t,e){if(this.txIdMap[t]!=null){const n=this.txIdMap[t][e];if(typeof n=="number")return n}return-1}sortTxByDate(t,e){return e.date-t.date}addTransaction(t,e,n){this.log("executing addTransaction: ",e.txid),e.otherParams==null&&(e.otherParams={}),e.blockHeight<1&&(e.otherParams.lastSeenTime=n!=null?n:Math.round(Date.now()/1e3));const a=(0,m.f0)(e.txid),i=this.findTransaction(t,a);let s=!1;if(i===-1){if(this.isSpendTx(e)&&e.blockHeight===0&&(this.walletLocalData.numUnconfirmedSpendTxs++,this.walletLocalDataDirty=!0),s=!0,typeof this.transactionList[t]>"u")this.transactionList[t]=[];else if(this.transactionList[t].length>=_)return;this.transactionList[t].push(e),this.walletLocalData.numTransactions[t]=this.transactionList[t].length,this.walletLocalDataDirty=!0,this.transactionListDirty=!0,this.transactionsChangedArray.push(e),this.warn(`addTransaction new tx: ${e.txid}`)}else{const r=this.transactionList[t][i],{otherParams:c={}}=r,{otherParams:y={}}=e;(r.blockHeight<e.blockHeight||r.blockHeight===0&&e.blockHeight<0||r.blockHeight===e.blockHeight&&(r.networkFee!==e.networkFee||r.nativeAmount!==e.nativeAmount||c.lastSeenTime!==y.lastSeenTime||r.date!==e.date))&&(this.isSpendTx(e)&&e.blockHeight!==0&&r.blockHeight===0&&this.walletLocalData.numUnconfirmedSpendTxs--,r.date!==e.date&&(s=!0),this.warn(`addTransaction: update ${e.txid} height:${e.blockHeight}`),this.walletLocalDataDirty=!0,this.updateTransaction(t,e,i))}s&&this.sortTransactions(t)}sortTransactions(t){this.transactionList[t].sort(this.sortTxByDate);const e=[];let n=0;for(const a of this.transactionList[t])this.txIdMap[t]==null&&(this.txIdMap[t]={}),this.txIdMap[t][(0,m.f0)(a.txid)]=n,e.push((0,m.f0)(a.txid)),n++;this.txIdList[t]=e}checkDroppedTransactionsThrottled(){const t=Date.now()/1e3;t-this.walletLocalData.lastCheckedTxsDropped>B&&(this.checkDroppedTransactions(t),this.walletLocalData.lastCheckedTxsDropped=t,this.walletLocalDataDirty=!0,this.transactionsChangedArray.length>0&&(this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[]))}checkDroppedTransactions(t){let e=0;for(const n in this.transactionList)for(let a=0;a<this.transactionList[n].length;a++){const i=this.transactionList[n][a];if(i.blockHeight===0){const{otherParams:s={}}=i,l=s.lastSeenTime;t-l>B?(i.blockHeight=-1,i.nativeAmount="0",this.transactionsChangedArray.push(i)):this.isSpendTx(i)&&e++}}this.walletLocalData.numUnconfirmedSpendTxs=e,this.walletLocalDataDirty=!0}updateBalance(t,e){const n=this.walletLocalData.totalBalances[t];this.walletLocalData.totalBalances[t]==null&&(this.walletLocalData.totalBalances[t]="0"),(n==null||!(0,d.eq)(e,n))&&(this.walletLocalData.totalBalances[t]=e,this.walletLocalDataDirty=!0,this.warn(`${t}: token Address balance: ${e}`),this.currencyEngineCallbacks.onBalanceChanged(t,e)),this.tokenCheckBalanceStatus[t]=1,this.updateOnAddressesChecked()}updateTransaction(t,e,n){this.transactionList[t][n]=e,this.transactionListDirty=!0,this.transactionsChangedArray.push(e),this.warn(`updateTransaction: ${e.txid}`)}saveWalletLoop(){return o(this,null,function*(){const t=this.walletLocalDisklet,e=[];if(this.transactionListDirty){yield this.loadTransactions(),this.log("transactionListDirty. Saving...");let n=JSON.stringify(this.transactionList);e.push(t.setText(h.tC,n).catch(a=>{this.error("Error saving transactionList ",a)})),n=JSON.stringify(this.txIdList),e.push(t.setText(h.TD,n).catch(a=>{this.error("Error saving txIdList ",a)})),n=JSON.stringify(this.txIdMap),e.push(t.setText(h.DZ,n).catch(a=>{this.error("Error saving txIdMap ",a)})),yield Promise.all(e),this.transactionListDirty=!1}if(this.walletLocalDataDirty){this.log("walletLocalDataDirty. Saving..."),this.walletLocalData.otherData=this.otherData;const n=JSON.stringify(this.walletLocalData);yield t.setText(h.Pe,n).then(()=>{this.walletLocalDataDirty=!1}).catch(a=>{this.error("Error saving walletLocalData ",a)})}})}doInitialBalanceCallback(){var t;for(const e of this.enabledTokens)try{this.currencyEngineCallbacks.onBalanceChanged(e,(t=this.walletLocalData.totalBalances[e])!=null?t:"0")}catch(n){this.error(`doInitialBalanceCallback Error for currencyCode ${e}`,n)}}doInitialUnactivatedTokenIdsCallback(){try{this.walletLocalData.unactivatedTokenIds!=null&&this.walletLocalData.unactivatedTokenIds.length>0&&this.currencyEngineCallbacks.onUnactivatedTokenIdsChanged(this.walletLocalData.unactivatedTokenIds)}catch(t){this.error("doInitialUnactivatedTokenIdsCallback Error",t)}}addToLoop(t,e){return o(this,null,function*(){try{yield this[t]()}catch(n){this.error(`Error in Loop: ${t} `,n)}return this.engineOn&&(this.timers[t]=setTimeout(()=>{this.engineOn&&this.addToLoop(t,e).catch(n=>this.log(n.message))},e)),!0})}getTokenInfo(t){return this.allTokens.find(e=>e.currencyCode===t)}updateOnAddressesChecked(){var t,e;if(this.addressesChecked)return;const n=this.enabledTokens,a=1/n.length;let i=0,s=0;for(const l of n){const r=(t=this.tokenCheckBalanceStatus[l])!=null?t:0,c=(e=this.tokenCheckTransactionsStatus[l])!=null?e:0;i+=(r+c)/2*a,r===1&&c===1&&s++}s===n.length&&(i=1,this.addressesChecked=!0),this.log(`${this.walletId} syncRatio of: ${i}`),this.currencyEngineCallbacks.onAddressesChecked(i)}clearBlockchainCache(){return o(this,null,function*(){this.walletLocalData=(0,h.O2)({publicKey:this.walletLocalData.publicKey}),this.walletLocalDataDirty=!0,this.addressesChecked=!1,this.tokenCheckBalanceStatus={},this.tokenCheckTransactionsStatus={},this.transactionList={},this.txIdList={},this.txIdMap={},this.transactionListDirty=!0,this.setOtherData({}),yield this.saveWalletLoop()})}startEngine(){return o(this,null,function*(){this.addToLoop("saveWalletLoop",K).catch(()=>{})})}killEngine(){return o(this,null,function*(){this.engineOn=!1;for(const t in this.timers)clearTimeout(this.timers[t]);this.timers={}})}changeUserSettings(t){return o(this,null,function*(){this.currentSettings=t})}getBlockHeight(){return this.walletLocalData.blockHeight}changeCustomTokensSync(t){this.customTokens={};for(const e of Object.keys(t)){const n=t[e];try{(0,C.Rp)(n)}catch{this.log.warn(`Dropping custom token "${n.currencyCode}" / ${e}`);continue}this.customTokens[e]=n}this.allTokensMap=A(A({},this.customTokens),this.builtinTokens),this.allTokens=(0,C.ZS)(this.allTokensMap)}changeCustomTokens(t){return o(this,null,function*(){this.changeCustomTokensSync(t)})}changeEnabledTokenIdsSync(t){const{currencyCode:e}=this.currencyInfo,n=new Set,a=new Set;for(const i of t){const s=this.allTokensMap[i];s!=null&&(n.add(s.currencyCode),a.add(i))}this.enabledTokens=[...n,e],this.enabledTokenIds=[...a]}changeEnabledTokenIds(t){return o(this,null,function*(){this.changeEnabledTokenIdsSync(t)})}getBalance(t){const{tokenId:e}=t,{currencyCode:n}=e==null?this.currencyInfo:this.allTokensMap[e],a=this.walletLocalData.totalBalances[n];return a==null?"0":a}getNumTransactions(t){const{tokenId:e}=t,{currencyCode:n}=e==null?this.currencyInfo:this.allTokensMap[e];return this.walletLocalData.numTransactions[n]==null?0:this.walletLocalData.numTransactions[n]}getTransactions(t){return o(this,null,function*(){const{startDate:e,endDate:n,tokenId:a}=t,{currencyCode:i}=a==null?this.currencyInfo:this.allTokensMap[a];return yield this.loadTransactions(),this.transactionList[i]==null?[]:this.transactionList[i].filter(l=>new Date(l.date)>=(e!=null?e:new Date(0))&&new Date(l.date)<=(n!=null?n:new Date))})}getFreshAddress(t){return o(this,null,function*(){return{publicAddress:this.walletLocalData.publicKey}})}addGapLimitAddresses(t){return o(this,null,function*(){})}isAddressUsed(t){return o(this,null,function*(){return!1})}dumpData(){return o(this,null,function*(){return{walletId:this.walletId.split(" - ")[0],walletType:this.walletInfo.type,data:{pluginType:{pluginId:this.currencyInfo.pluginId},walletLocalData:this.walletLocalData}}})}makeSpendCheck(t){var e,n,a;const{skipChecks:i=!1,tokenId:s}=t;M(t,this.currencyInfo);for(const f of t.spendTargets)if(!i&&f.publicAddress===this.walletLocalData.publicKey)throw new I.l0;if(s!=null&&!this.enabledTokenIds.includes(s))throw new Error("Error: Token not enabled");const{currencyCode:l}=s==null?this.currencyInfo:this.allTokensMap[s],r=(e=this.walletLocalData.totalBalances[l])!=null?e:"0",c={};for(const f of t.spendTargets){const{nativeAmount:w}=f;w!=null&&(c[l]=(n=c[l])!=null?n:"0",c[l]=(0,d.add)(c[l],w))}for(const[f,w]of Object.entries(c)){const k=(a=this.walletLocalData.totalBalances[f])!=null?a:"0";if(!i&&(0,d.lt)(k,w))throw new I.C_({tokenId:s})}const y=(0,m.aL)(l,this.currencyInfo,this.allTokensMap);if(y==null)throw new Error("InternalErrorInvalidCurrencyCode");return{edgeSpendInfo:t,nativeBalance:r,currencyCode:l,denom:y,skipChecks:i}}checkRecipientMinimumBalance(t,e,n){return o(this,null,function*(){if((0,d.gte)(e,this.minimumAddressBalance))return;const a=yield t(n);if((0,d.lt)((0,d.add)(e,a),this.minimumAddressBalance)){const i=this.currencyInfo.denominations.find(l=>l.name===this.currencyInfo.currencyCode);if(i==null)throw new Error("Unknown denom");const s=(0,d.div)(this.minimumAddressBalance,i.multiplier);throw new Error(`Recipient address not activated. A minimum ${s} ${this.currencyInfo.currencyCode} transfer is required to send funds to this address`)}})}saveTx(t){return o(this,null,function*(){this.addTransaction(t.currencyCode,t),this.transactionsChangedArray.forEach(e=>this.warn(`executing back in saveTx and this.transactionsChangedArray is: ${(0,m.oX)(e)}`)),this.transactionsChangedArray.length>0&&this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray)})}resyncBlockchain(){return o(this,null,function*(){throw new Error("not implemented")})}makeSpend(t,e){return o(this,null,function*(){throw new Error("not implemented")})}signTx(t,e){return o(this,null,function*(){throw new Error("not implemented")})}broadcastTx(t,e){return o(this,null,function*(){throw new Error("not implemented")})}}}}]);
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[7224],{79014:function(L,S,u){"use strict";u.d(S,{Q:function(){return K},k:function(){return M}});var m=u(77591),B=u.n(m),H=u(24350),U=u(84564),P=u.n(U),A=u(76714),I=Object.defineProperty,b=Object.getOwnPropertySymbols,D=Object.prototype.hasOwnProperty,N=Object.prototype.propertyIsEnumerable,T=(o,g,p)=>g in o?I(o,g,{enumerable:!0,configurable:!0,writable:!0,value:p}):o[g]=p,O=(o,g)=>{for(var p in g||(g={}))D.call(g,p)&&T(o,p,g[p]);if(b)for(var p of b(g))N.call(g,p)&&T(o,p,g[p]);return o};function M(o,g,p,v,w,d=[]){const y=O({},P()(g,{},!0)),k=g.startsWith(`${o.pluginId}://`);if(y.protocol!=null&&(y.protocol=y.protocol.replace(":","")),y.protocol!=null&&y.protocol!==""&&!p[y.protocol])throw new Error(`Uri protocol '${y.protocol}' is not supported for ${o.pluginId}.`);if(y.host===""&&y.pathname==="")throw new Error("Path and host not found in uri.");const f={publicAddress:y.host!==""?y.host:y.pathname.split("/")[0]},C=y.query.label,z=y.query.message,l=y.query.category;(C!=null||z!=null||l!=null||k)&&(f.metadata={},f.metadata.name=C,f.metadata.notes=z,f.metadata.category=l,f.metadata.gateway=k!=null?k:!1);const t=y.query.amount;if(t!=null&&typeof t=="string"){w==null&&(w=o.currencyCode);const e=(0,A.Qs)(w!=null?w:"",o,d,v);if(e==null)throw new Error("InternalErrorInvalidCurrencyCode");let n=(0,m.mul)(t,e.multiplier);n=(0,m.toFixed)(n,0,0),f.nativeAmount=n,f.currencyCode=w}return{edgeParsedUri:f,parsedUri:y}}function K(o,g,p){if(o.publicAddress==null)throw new Error("InvalidPublicAddressError");if(p==null&&o.label==null&&o.message==null)return o.publicAddress;{let v="";p!=null&&(v+="amount="+p+"&"),(o.label!=null||o.message!=null)&&(typeof o.label=="string"&&(v+="label="+o.label+"&"),typeof o.message=="string"&&(v+="message="+o.message+"&")),v=v.substr(0,v.length-1);const w={scheme:g,path:o.publicAddress,query:v};return(0,H.qC)(w)}}},43391:function(L,S,u){"use strict";u.r(S),u.d(S,{PiratechainTools:function(){return C},makeCurrencyEngine:function(){return x},makeCurrencyTools:function(){return z}});var m=u(77591),B=u(2153),H=u(48764),U=u(62177),P=u(79014),A=u(76714),I=u(64910),b=u(94935),D=u(79325),N=u(16757),T=Object.defineProperty,O=Object.getOwnPropertySymbols,M=Object.getPrototypeOf,K=Object.prototype.hasOwnProperty,o=Object.prototype.propertyIsEnumerable,g=Reflect.get,p=(l,t,e)=>t in l?T(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e,v=(l,t)=>{for(var e in t||(t={}))K.call(t,e)&&p(l,e,t[e]);if(O)for(var e of O(t))o.call(t,e)&&p(l,e,t[e]);return l},w=(l,t,e)=>g(M(l),e,t),d=(l,t,e)=>new Promise((n,r)=>{var s=a=>{try{c(e.next(a))}catch(h){r(h)}},i=a=>{try{c(e.throw(a))}catch(h){r(h)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((e=e.apply(l,t)).next())});const y=3e4;class k extends N.P{constructor(t,e,n,r,s){super(t,e,n,r);const{networkInfo:i}=t;this.pluginId=this.currencyInfo.pluginId,this.networkInfo=i,this.makeSynchronizer=s,this.queryMutex=!1,this.started=!1,this.progressRatio=0}setOtherData(t){this.otherData=(0,I.Zk)(t)}initData(){const{birthdayHeight:t}=this.initializer;this.otherData.blockRange.first===0&&(this.otherData.blockRange={first:t,last:t}),this.initialNumBlocksToDownload=-1,this.synchronizerStatus="DISCONNECTED",this.availableZatoshi="0"}initSubscriptions(){this.synchronizer!=null&&(this.synchronizer.on("update",t=>d(this,null,function*(){const{lastDownloadedHeight:e,scanProgress:n,networkBlockHeight:r}=t;this.onUpdateBlockHeight(r),this.onUpdateProgress(e,n,r),yield this.queryAll()})),this.synchronizer.on("statusChanged",t=>d(this,null,function*(){this.synchronizerStatus=t.name,yield this.queryAll()})))}queryAll(){return d(this,null,function*(){if(this.lastUpdateFromSynchronizer=Date.now(),!this.queryMutex){this.queryMutex=!0;try{yield this.queryBalance(),yield this.queryTransactions(),this.onUpdateTransactions()}catch{}this.queryMutex=!1}})}onUpdateBlockHeight(t){this.walletLocalData.blockHeight!==t&&(this.walletLocalData.blockHeight=t,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight))}onUpdateTransactions(){this.transactionsChangedArray.length>0&&(this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[])}onUpdateProgress(t,e,n){if(!this.addressesChecked&&!this.isSynced()){const r=e*.99,s=e*.8;this.tokenCheckBalanceStatus[this.currencyInfo.currencyCode]=r/100,this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=s/100;const i=(r+s)/2;i>this.progressRatio&&(this.progressRatio=i,this.log.warn(`Scan and download progress: ${Math.floor(i)}%`),this.updateOnAddressesChecked())}}bumpSynchronizer(){return d(this,null,function*(){var t;this.isSynced()||this.lastUpdateFromSynchronizer==null||Date.now()<this.lastUpdateFromSynchronizer+y||(this.log.warn("Haven't heard from the synchronizer in a while. Applying the Fonzie Method..."),yield(t=this.synchronizer)==null?void 0:t.stop(),this.stopSyncing!=null&&(yield this.stopSyncing(5e3),this.stopSyncing=void 0),this.log.warn("\u{1F44D} Ayyy \u{1F44D}"),this.lastUpdateFromSynchronizer=void 0)})}startEngine(){return d(this,null,function*(){this.engineOn=!0,this.started=!0,this.addToLoop("bumpSynchronizer",y).catch(()=>{}),yield w(k.prototype,this,"startEngine").call(this)})}isSynced(){return this.synchronizerStatus==="SYNCED"}queryBalance(){return d(this,null,function*(){if(!(!this.isSynced()||this.synchronizer==null))try{const t=yield this.synchronizer.getBalance();if(t.totalZatoshi==="-1")return;this.availableZatoshi=t.availableZatoshi,this.updateBalance(this.currencyInfo.currencyCode,t.totalZatoshi)}catch(t){this.warn("Failed to update balances",t),this.updateBalance(this.currencyInfo.currencyCode,"0")}})}queryTransactions(){return d(this,null,function*(){if(this.synchronizer!=null)try{let t=this.otherData.blockRange.first,e=this.otherData.blockRange.last;for(;this.isSynced()&&e<=this.walletLocalData.blockHeight;){if((yield this.synchronizer.getTransactions({first:t,last:e})).forEach(r=>this.processTransaction(r)),e===this.walletLocalData.blockHeight){t=this.walletLocalData.blockHeight,this.walletLocalDataDirty=!0,this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=1,this.updateOnAddressesChecked();break}t=e+1,e=e+this.networkInfo.transactionQueryLimit<this.walletLocalData.blockHeight?e+this.networkInfo.transactionQueryLimit:this.walletLocalData.blockHeight,this.otherData.blockRange={first:t,last:e},this.walletLocalDataDirty=!0}}catch(t){this.error(`Error querying ${this.currencyInfo.currencyCode} transactions `,t)}})}processTransaction(t){let e=t.value;const n=[];t.toAddress!=null?e=`-${(0,m.add)(e,this.networkInfo.defaultNetworkFee)}`:n.push(this.walletInfo.keys.publicKey);const r=t.memos.filter(i=>i!=="").map(i=>({memoName:"memo",type:"text",value:i})),s={blockHeight:t.minedHeight,currencyCode:this.currencyInfo.currencyCode,date:t.blockTimeInSeconds,isSend:e.startsWith("-"),memos:r,nativeAmount:e,networkFee:this.networkInfo.defaultNetworkFee,otherParams:{},ourReceiveAddresses:n,signedTx:"",tokenId:null,txid:t.rawTransactionId,walletId:this.walletId};this.addTransaction(this.currencyInfo.currencyCode,s)}syncNetwork(t){return d(this,null,function*(){if(!this.started)return 1e3;const e=(0,I.mJ)(this.currencyInfo.pluginId)(t==null?void 0:t.privateKeys),{rpcNode:n}=this.networkInfo;return this.initializer=v({mnemonicSeed:e.mnemonic,birthdayHeight:e.birthdayHeight,alias:D.YU.stringify(D.US.parse(this.walletId))},n),this.synchronizer=yield this.makeSynchronizer(this.initializer),this.initData(),this.initSubscriptions(),yield new Promise(r=>{this.stopSyncing=r})})}killEngine(){return d(this,null,function*(){var t;this.started=!1,this.stopSyncing!=null&&(yield this.stopSyncing(1e3),this.stopSyncing=void 0),yield(t=this.synchronizer)==null?void 0:t.stop(),yield w(k.prototype,this,"killEngine").call(this)})}clearBlockchainCache(){return d(this,null,function*(){yield w(k.prototype,this,"clearBlockchainCache").call(this)})}resyncBlockchain(){return d(this,null,function*(){var t;yield w(k.prototype,this,"killEngine").call(this),yield this.clearBlockchainCache(),yield this.startEngine(),(t=this.synchronizer)==null||t.rescan().catch(e=>this.warn("resyncBlockchain failed: ",e)),this.initData(),this.progressRatio=0,this.synchronizerStatus="SYNCING"})}getMaxSpendable(){return d(this,null,function*(){const t=(0,m.sub)(this.availableZatoshi,this.networkInfo.defaultNetworkFee);if((0,m.lte)(t,"0"))throw new b.C_({tokenId:null});return t})}makeSpend(t){return d(this,null,function*(){var e;if(!this.isSynced())throw new Error("Cannot spend until wallet is synced");const{edgeSpendInfo:n,currencyCode:r}=this.makeSpendCheck(t),{memos:s=[],tokenId:i}=n,c=n.spendTargets[0],{publicAddress:a,nativeAmount:h}=c;if(a==null)throw new Error("makeSpend Missing publicAddress");if(h==null)throw new b.$D;if((0,m.eq)(h,"0"))throw new b.$D;const E=(0,m.add)(h,this.networkInfo.defaultNetworkFee);if((0,m.gt)(E,(e=this.walletLocalData.totalBalances[this.currencyInfo.currencyCode])!=null?e:"0"))throw new b.C_({tokenId:i});if((0,m.gt)(E,this.availableZatoshi))throw new b.C_({tokenId:i});const R=(0,m.mul)(E,"-1");return{blockHeight:0,currencyCode:r,date:0,isSend:!0,memos:s,nativeAmount:R,networkFee:this.networkInfo.defaultNetworkFee,ourReceiveAddresses:[],signedTx:"",tokenId:i,txid:"",walletId:this.walletId}})}signTx(t){return d(this,null,function*(){return t})}broadcastTx(t,e){return d(this,null,function*(){var n;if(this.synchronizer==null)throw new Error("Synchronizer undefined");const{memos:r}=t,s=(0,I.mJ)(this.pluginId)(e==null?void 0:e.privateKeys);if(t.spendTargets==null||t.spendTargets.length!==1)throw new Error("Invalid spend targets");const i=((n=r[0])==null?void 0:n.type)==="text"?r[0].value:"",c=t.spendTargets[0],a={zatoshi:(0,m.sub)((0,m.abs)(t.nativeAmount),t.networkFee),toAddress:c.publicAddress,memo:i,fromAccountIndex:0,mnemonicSeed:s.mnemonic};try{const h=yield this.synchronizer.sendToAddress(a);t.txid=h.txId,t.signedTx=h.raw,t.date=Date.now()/1e3,this.warn(`SUCCESS broadcastTx
|
|
2
|
+
${(0,A.oX)(t)}`)}catch(h){throw this.warn("FAILURE broadcastTx failed: ",h),h}return t})}getFreshAddress(){return d(this,null,function*(){if(this.synchronizer==null)throw new Error("Synchronizer undefined");return{publicAddress:(yield this.synchronizer.deriveUnifiedAddress()).saplingAddress}})}}function x(l,t,e,n){return d(this,null,function*(){const r=(0,I.wY)(e),{makeSynchronizer:s}=l.nativeIo["edge-currency-accountbased"].piratechain,i=new k(l,t,r,n,s);return yield i.loadEngine(),i})}var f=(l,t,e)=>new Promise((n,r)=>{var s=a=>{try{c(e.next(a))}catch(h){r(h)}},i=a=>{try{c(e.throw(a))}catch(h){r(h)}},c=a=>a.done?n(a.value):Promise.resolve(a.value).then(s,i);c((e=e.apply(l,t)).next())});class C{constructor(t){const{builtinTokens:e,currencyInfo:n,io:r,networkInfo:s}=t;this.builtinTokens=e,this.currencyInfo=n,this.io=r,this.networkInfo=s;const i=t.nativeIo["edge-currency-accountbased"];if(i==null)throw new Error("Need opts");const{Tools:c}=i.piratechain;this.nativeTools=c}getDisplayPrivateKey(t){return f(this,null,function*(){const{pluginId:e}=this.currencyInfo;return(0,I.mJ)(e)(t.keys).mnemonic})}getDisplayPublicKey(t){return f(this,null,function*(){const{keys:e}=(0,I.wY)(t);return e.publicKey})}getNewWalletBirthdayBlockheight(){return f(this,null,function*(){try{return yield this.nativeTools.getBirthdayHeight(this.networkInfo.rpcNode.defaultHost,this.networkInfo.rpcNode.defaultPort)}catch{return this.networkInfo.defaultBirthday}})}isValidAddress(t){return f(this,null,function*(){return yield this.nativeTools.isValidAddress(t)})}importPrivateKey(t){return f(this,arguments,function*(e,n={}){const{pluginId:r}=this.currencyInfo,s=(0,B.validateMnemonic)(e);if(e.split(" ").length!==24)throw new Error("Mnemonic must be 24 words");if(!s)throw new Error(`Invalid ${this.currencyInfo.currencyCode} mnemonic`);const i=yield this.getNewWalletBirthdayBlockheight();let c=i;const{birthdayHeight:a}=n;if(a!=null){(0,U.jD)(a);const h=parseInt(a);if(h>i)throw new Error("InvalidBirthdayHeight");c=h}return{[`${r}Mnemonic`]:e,[`${r}BirthdayHeight`]:c}})}createPrivateKey(t){return f(this,null,function*(){if(t!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const e=H.Buffer.from(this.io.random(32)).toString("hex"),n=(0,B.entropyToMnemonic)(e);return yield this.importPrivateKey(n)})}checkPublicKey(t){return f(this,null,function*(){try{return(0,I.x_)(t),!0}catch{return!1}})}derivePublicKey(t){return f(this,null,function*(){const{pluginId:e}=this.currencyInfo,n=(0,I.mJ)(e)(t.keys);if(t.type!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const r=n.mnemonic;if(typeof r!="string")throw new Error("InvalidMnemonic");const s=yield this.nativeTools.deriveViewingKey(r,this.networkInfo.rpcNode.networkName);return{birthdayHeight:n.birthdayHeight,publicKey:s}})}parseUri(t,e,n){return f(this,null,function*(){const{pluginId:r}=this.currencyInfo,s={[r]:!0},{edgeParsedUri:i,edgeParsedUri:{publicAddress:c}}=(0,P.k)(this.currencyInfo,t,s,this.builtinTokens,e!=null?e:this.currencyInfo.currencyCode,n);if(c==null||!(yield this.isValidAddress(c)))throw new Error("InvalidPublicAddressError");return i})}encodeUri(t){return f(this,arguments,function*(e,n=[]){const{pluginId:r}=this.currencyInfo,{nativeAmount:s,currencyCode:i,publicAddress:c}=e;if(!(yield this.isValidAddress(c)))throw new Error("InvalidPublicAddressError");let a;if(s!=null){const E=(0,A.Qs)(i!=null?i:this.currencyInfo.currencyCode,this.currencyInfo,n,this.builtinTokens);if(E==null)throw new Error("InternalErrorInvalidCurrencyCode");a=(0,m.div)(s,E.multiplier,18)}return(0,P.Q)(e,`${r}`,a)})}}function z(l){return f(this,null,function*(){return new C(l)})}},52361:function(){},94616:function(){}}]);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[7741],{37011:function(ae,_,p){"use strict";p.r(_),p.d(_,{AlgorandTools:function(){return he},makeCurrencyEngine:function(){return Ee},makeCurrencyTools:function(){return De}});var I=p(88814),d=p(77591),S=p(20918),b=p(79014),k=p(76714),e=p(82448),F=p(62177);const Q=(0,e.su)({latestRound:(0,e.Vk)(e.mH,0),latestTxid:(0,e.Vk)(e.XC,"")}),J=(0,e.su)({amount:e.mH,assets:(0,e._2)((0,e.su)({amount:e.mH,"asset-id":e.mH})),"min-balance":e.mH,round:e.mH}),Y=(0,e.su)({"confirmed-round":e.mH,fee:e.mH,"first-valid":e.mH,id:e.XC,note:(0,e.Zz)(e.XC),"round-time":e.mH,sender:e.XC,"tx-type":e.XC}).withRest,$=(0,e.Wf)("pay"),G=(0,e.su)({"payment-transaction":(0,e.su)({amount:e.mH,"close-amount":e.mH,receiver:e.XC}),"tx-type":$}),ee=(0,e.Wf)("axfer"),te=(0,e.su)({"asset-transfer-transaction":(0,e.su)({amount:e.mH,"asset-id":e.mH,receiver:e.XC}),"tx-type":ee}),y=(0,e.su)({"confirmed-round":e.mH,fee:e.mH,"first-valid":e.mH,note:(0,e.Zz)(e.XC),"round-time":e.mH,sender:e.XC,"tx-type":e.XC}).withRest,v=(0,e.Wf)("appl"),x=(0,e.su)({"inner-txns":(0,e.Zz)((0,e._2)(y)),"tx-type":v}).withRest,O=(0,e.su)({"current-round":e.mH,"next-token":(0,e.Zz)(e.XC),transactions:(0,e._2)(Y)}),K=(0,e.su)({flatFee:e.jK,fee:e.mH,firstRound:e.mH,lastRound:e.mH,genesisID:e.XC,genesisHash:e.XC}),j=(0,e.su)({type:e.XC}).withRest,w=(0,e.su)({encodedTx:e.XC,recipient:(0,e.Zz)(e.XC)}),V=(0,e.su)({type:$,to:e.XC,amount:e.mH}).withRest,ne=(0,e.Vk)((0,e.su)({fee:(0,e.Zz)(e.XC)}),{fee:void 0}),D=(0,e.Vk)((0,e.su)({contractAddress:F.jD})),Z=F.BQ,W=g=>{const t=(0,e.su)({[`${g}Mnemonic`]:e.XC});return(0,e.W1)(n=>({mnemonic:t(n)[`${g}Mnemonic`]}),n=>({[`${g}Mnemonic`]:n.mnemonic}))},se=(0,e.su)({id:(0,e._C)(e.XC,e.mH),method:(0,e.Wf)("algo_signTxn"),params:(0,e.vq)((0,e.vq)((0,e.su)({txn:e.XC,message:(0,e.Zz)(e.XC)})))}),z=(0,e.su)({id:e.mH,jsonrpc:(0,e.Wf)("2.0"),method:(0,e.Wf)("algo_signTxn"),params:(0,e.vq)((0,e._2)((0,e.su)({txn:e.XC,message:(0,e.Zz)(e.XC)})))}).withRest;var X=p(94935),P=p(79325),pe=p(16757),ie=p(99599),ge=Object.defineProperty,we=Object.defineProperties,Te=Object.getOwnPropertyDescriptors,le=Object.getOwnPropertySymbols,Ie=Object.getPrototypeOf,ke=Object.prototype.hasOwnProperty,ve=Object.prototype.propertyIsEnumerable,xe=Reflect.get,ce=(g,t,n)=>t in g?ge(g,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):g[t]=n,q=(g,t)=>{for(var n in t||(t={}))ke.call(t,n)&&ce(g,n,t[n]);if(le)for(var n of le(t))ve.call(t,n)&&ce(g,n,t[n]);return g},Ce=(g,t)=>we(g,Te(t)),Ae=(g,t,n)=>xe(Ie(g),n,t),m=(g,t,n)=>new Promise((s,i)=>{var o=r=>{try{a(n.next(r))}catch(u){i(u)}},c=r=>{try{a(n.throw(r))}catch(u){i(u)}},a=r=>r.done?s(r.value):Promise.resolve(r.value).then(o,c);a((n=n.apply(g,t)).next())});const{Algodv2:re,Indexer:Pe}=I.ZP,ue=5e3,be=3e3;class oe extends pe.P{constructor(t,n,s,i){super(t,n,s,i),this.getRecipientBalance=o=>m(this,null,function*(){try{return(yield this.fetchAccountInfo(o)).amount.toString()}catch{return this.minimumAddressBalance}}),this.engineGetActivationAssets=o=>m(this,null,function*(){return{assetOptions:[{tokenId:null,paymentWalletId:this.walletId,currencyPluginId:this.currencyInfo.pluginId}]}}),this.engineActivateWallet=o=>m(this,[o],function*({activateTokenIds:c,paymentInfo:a}){var r;if(c==null)throw new Error(`Must specify activateTokenIds for ${this.currencyInfo.currencyCode}`);const{tokenId:u,wallet:h}=a!=null?a:{tokenId:null};if(u!=null)throw new Error(`Must activate with ${this.currencyInfo.currencyCode}`);if((h==null?void 0:h.id)!==this.walletId)throw new Error("Must pay with same wallet you are activating token with");const l=this.networkInfo.minimumTxFee.toFixed();let f="0";const A=[];for(const E of c){if(E!==null&&this.allTokensMap[E]==null)throw new Error(`Invalid tokenId to activate ${E}`);const U={tokenId:E,skipChecks:!0,spendTargets:[{publicAddress:this.walletInfo.keys.publicKey,nativeAmount:"0"}]};try{const H=yield this.makeSpend(U);f=(0,d.add)(f,(r=H.parentNetworkFee)!=null?r:l)}catch{f=(0,d.add)(f,l)}A.push(U)}return{paymentTokenId:u,paymentWalletId:this.walletId,fromNativeAmount:"0",networkFee:{tokenId:null,nativeAmount:f,currencyPluginId:this.currencyInfo.pluginId},approve:(...E)=>m(this,[...E],function*(U={}){const{metadata:H}=U,T=[];for(const C of A){const L=yield this.makeSpend(C);L.metadata=q({},H);let M=yield h.signTx(L);M=yield h.broadcastTx(M),T.push(M),yield h.saveTx(M)}return{transactions:T}}),close:()=>m(this,null,function*(){})}}),this.networkInfo=t.networkInfo,this.queryTxMutex=(0,k.jT)(),this.suggestedTransactionParams={flatFee:!1,fee:0,firstRound:0,lastRound:0,genesisID:this.networkInfo.genesisID,genesisHash:this.networkInfo.genesisHash},this.minimumAddressBalance=this.networkInfo.minimumAddressBalance,this.totalReserve=this.minimumAddressBalance,this.otherMethods={parseWalletConnectV2Payload:o=>m(this,null,function*(){try{const a=z(o).params[0][0],r=(0,I.wj)(P.US.parse(a.txn)),u=r.amount!=null?r.amount.toString():"0",h=r.fee.toFixed();let l=null;if(r.type==="axfer"){const f=r.assetIndex.toString();if(this.allTokensMap[f]==null)throw new Error("Unrecognized token");l=f}return{nativeAmount:u,networkFee:h,tokenId:l}}catch(c){throw this.warn("Wallet connect call_request ",c),c}})}}setOtherData(t){this.otherData=Q(t)}fetchAccountInfo(t){return m(this,null,function*(){return yield(0,k.QJ)(this.networkInfo.algodServers.map(n=>()=>m(this,null,function*(){const i=yield new re("",n,"").accountInformation(t).do();return J(i)})))})}queryBalance(){return m(this,null,function*(){try{const t=yield this.fetchAccountInfo(this.walletLocalData.publicKey),{assets:n,amount:s,"min-balance":i,round:o}=t;this.updateBalance(this.currencyInfo.currencyCode,s.toString()),this.totalReserve=i.toString();const c=[],a=[];for(const[r,u]of Object.entries(this.allTokensMap)){const h=n.find(l=>l["asset-id"].toFixed()===r);if(h!=null){const l=h.amount.toString();this.updateBalance(u.currencyCode,l),(0,d.gt)(l,"0")&&!this.enabledTokenIds.includes(r)&&c.push(r)}else this.updateBalance(u.currencyCode,"0"),this.enabledTokenIds.includes(r)&&a.push(r)}c.length>0&&this.currencyEngineCallbacks.onNewTokens(c),o>this.walletLocalData.blockHeight&&(this.walletLocalData.blockHeight=o,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight)),(0,k.dQ)(a,this.walletLocalData.unactivatedTokenIds)||(this.walletLocalData.unactivatedTokenIds=a,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onUnactivatedTokenIdsChanged(this.walletLocalData.unactivatedTokenIds))}catch(t){this.log.warn("queryBalance Error ",t)}})}queryTransactionParams(){return m(this,null,function*(){try{const t=yield(0,k.QJ)(this.networkInfo.algodServers.map(n=>()=>m(this,null,function*(){const i=yield new re("",n,"").getTransactionParams().do(),o=K(i);if(o.genesisHash!==this.networkInfo.genesisHash)throw new Error("Server genesisHash mismatch");return o})));this.suggestedTransactionParams=t}catch(t){this.log.warn("queryTransactionParams error:",t)}})}processAlgorandTransaction(t){const{"confirmed-round":n,"round-time":s,"tx-type":i,fee:o,id:c,note:a,sender:r}=t;let u,h,l,f,A,R=!1;const E=[];switch(i){case"pay":{const{amount:T,receiver:C}=G(t)["payment-transaction"];if(l=T.toString(),f=o.toString(),r===this.walletInfo.keys.publicKey)l=`-${(0,d.add)(l,f)}`,R=!0;else if(C===this.walletInfo.keys.publicKey)f="0",E.push(this.walletInfo.keys.publicKey);else return;u=this.currencyInfo.currencyCode,h=null;break}case"axfer":{const{amount:T,"asset-id":C,receiver:L}=te(t)["asset-transfer-transaction"];if(l=T.toString(),f="0",r===this.walletInfo.keys.publicKey)l=`-${l}`,A=o.toString(),R=!0;else if(L===this.walletInfo.keys.publicKey)E.push(this.walletInfo.keys.publicKey);else return;const M=this.allTokensMap[C];if(M==null)return;u=M.currencyCode,h=C.toString();break}case"appl":{const{"inner-txns":T=[]}=x(t);if(T.forEach(C=>this.processAlgorandTransaction(Ce(q({},C),{id:c}))),l="0",f=o.toString(),r===this.walletInfo.keys.publicKey)l=`-${(0,d.add)(l,f)}`,R=!0;else return;u=this.currencyInfo.currencyCode,h=null;break}default:return}const U=[];if(a!=null){const T=P.US.parse(a);try{U.push({memoName:"note",type:"text",value:ie.K.stringify(T)})}catch{U.push({memoName:"note",type:"hex",value:P.YU.stringify(T).toLowerCase()})}}const H={blockHeight:n,currencyCode:u,date:s,isSend:R,memos:U,nativeAmount:l,networkFee:f,ourReceiveAddresses:E,parentNetworkFee:A,signedTx:"",tokenId:h,txid:c,walletId:this.walletId};this.addTransaction(this.currencyInfo.currencyCode,H)}queryTransactions(){return m(this,null,function*(){return yield this.queryTxMutex(()=>m(this,null,function*(){return yield this.queryTransactionsInner()}))})}queryTransactionsInner(){return m(this,null,function*(){const t=this.otherData.latestRound;let n,s=this.otherData.latestRound,i=0,o,c=!0;do{const a=yield(0,k.QJ)(this.networkInfo.indexerServers.map(l=>()=>m(this,null,function*(){const A=yield new Pe({},l,"").lookupAccountTransactions(this.walletLocalData.publicKey).minRound(t).nextToken(o!=null?o:"").do();return O(A)}))),{"next-token":r,transactions:u}=a;if(u.length===0)break;for(const l of u){if(n==null&&(n=l.id,s=l["confirmed-round"]),i=l["confirmed-round"],l.id===this.otherData.latestTxid){c=!1;break}try{this.processAlgorandTransaction(l)}catch(f){this.log.warn("processAlgorandTransaction error:",f)}}s=s!=null?s:this.walletLocalData.blockHeight;const h=(s-i)/(s-t);this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=h,this.updateOnAddressesChecked(),o=r}while(o!=null&&c);n!=null&&this.otherData.latestTxid!==n&&(this.otherData.latestTxid=n,this.otherData.latestRound=s,this.walletLocalDataDirty=!0);for(const a of this.enabledTokens)this.tokenCheckTransactionsStatus[a]=1;this.updateOnAddressesChecked(),this.transactionsChangedArray.length>0&&(this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[])})}startEngine(){return m(this,null,function*(){this.engineOn=!0,this.addToLoop("queryBalance",ue).catch(()=>{}),this.addToLoop("queryTransactionParams",ue).catch(()=>{}),this.addToLoop("queryTransactions",be).catch(()=>{}),yield Ae(oe.prototype,this,"startEngine").call(this)})}resyncBlockchain(){return m(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}calcFee(t){const n=t.estimateSize();return Math.max(this.suggestedTransactionParams.fee*n,this.networkInfo.minimumTxFee).toString()}getMaxSpendable(t){return m(this,null,function*(){const{tokenId:n}=t;let s=this.getBalance({tokenId:n});if(n==null&&(s=(0,d.sub)(s,this.totalReserve)),t.spendTargets[0].publicAddress==null)throw new Error("makeSpend Missing publicAddress");const{customNetworkFee:o}=t;let a=ne(o).fee;a==null&&(t.spendTargets[0].nativeAmount="1",a=(yield this.makeSpend(t)).networkFee);const r=(u,h)=>m(this,null,function*(){const l=(0,d.sub)(h,u);if((0,d.lte)(l,"1"))return u;const f=(0,d.add)(u,(0,d.div)(l,"2"));t.spendTargets[0].nativeAmount=f;const A=(0,d.add)(f,a!=null?a:this.networkInfo.minimumTxFee.toString());return(0,d.gt)(A,s)?yield r(u,f):yield r(f,h)});return yield r("0",(0,d.add)(s,"1"))})}makeSpend(t){return m(this,null,function*(){var n,s,i,o;const{edgeSpendInfo:c,currencyCode:a,nativeBalance:r}=this.makeSpendCheck(t),{customNetworkFee:u,memos:h=[],tokenId:l}=c,f=(0,d.sub)(this.getBalance({tokenId:l}),this.totalReserve);if(c.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{nativeAmount:A,publicAddress:R}=c.spendTargets[0];if(R==null)throw new Error("makeSpend Missing publicAddress");if(A==null)throw new X.$D;const{type:E}=(n=(0,e.Vk)(j)(c.otherParams))!=null?n:{type:a===this.currencyInfo.currencyCode?"pay":"axfer"},U=((s=h[0])==null?void 0:s.type)==="text"?ie.K.parse(h[0].value):void 0,H=ne(u).fee;let T,C=A,L="0",M,N,fe;switch(E){case"pay":{if(T=I.ZP.makePaymentTxnWithSuggestedParamsFromObject({to:R,from:this.walletInfo.keys.publicKey,amount:BigInt(A),note:U,suggestedParams:q({},this.suggestedTransactionParams)}),N=H!=null?H:this.calcFee(T),L=N,C=`-${(0,d.add)(C,L)}`,fe=R,(0,d.gt)((0,d.abs)(C),f))throw new X.C_({tokenId:l});break}case"axfer":{const ye=Object.keys(this.allTokensMap).find(Ue=>this.allTokensMap[Ue].currencyCode===a);if(ye==null)throw new Error("Unrecognized asset");const me=D((o=(i=this.allTokensMap)==null?void 0:i[ye])==null?void 0:o.networkLocation);if(me==null)throw new Error("Unrecognized asset");if(T=I.ZP.makeAssetTransferTxnWithSuggestedParamsFromObject({assetIndex:parseInt(me.contractAddress),to:R,from:this.walletInfo.keys.publicKey,amount:BigInt(A),note:U,suggestedParams:q({},this.suggestedTransactionParams)}),N=H!=null?H:this.calcFee(T),C=`-${C}`,M=N,(0,d.gt)(M,f))throw new X.C_({networkFee:N,tokenId:l});if((0,d.gt)((0,d.abs)(C),r))throw new X.C_({tokenId:l});break}default:throw new Error("Unrecognized transaction type")}T.flatFee=!0,T.fee=parseInt(N);const Re={encodedTx:P.YU.stringify((0,I.nJ)(T)),recipient:fe};return{blockHeight:0,currencyCode:a,date:0,isSend:!0,memos:h,nativeAmount:C,networkFee:L,otherParams:Re,ourReceiveAddresses:[],parentNetworkFee:M,signedTx:"",tokenId:l,txid:"",walletId:this.walletId}})}signMessage(t,n){return m(this,null,function*(){const s=W(this.currencyInfo.pluginId)(n),i=(0,I.wj)(P.US.parse(t)),o=I.ZP.mnemonicToSecretKey(s.mnemonic),c=i.signTxn(o.sk);return P.US.stringify(c)})}signTx(t,n){return m(this,null,function*(){const{encodedTx:s,recipient:i}=w((0,k.Xp)(t)),o=(0,I.wj)(Uint8Array.from(P.YU.parse(s)));i!=null&&(yield this.checkRecipientMinimumBalance(this.getRecipientBalance,o.amount.toString(),i));const c=W(this.currencyInfo.pluginId)(n),a=I.ZP.mnemonicToSecretKey(c.mnemonic),r=o.signTxn(a.sk),u=P.YU.stringify(r);return t.signedTx=u,t})}broadcastTx(t){return m(this,null,function*(){const n=Uint8Array.from(P.YU.parse(t.signedTx));try{const{txId:s}=yield(0,k.QJ)(this.networkInfo.algodServers.map(i=>()=>m(this,null,function*(){return yield new re("",i,"").sendRawTransaction(n).do()})));t.txid=s,t.date=Date.now()/1e3}catch(s){throw this.warn("FAILURE broadcastTx failed: ",s),s}return this.warn(`SUCCESS broadcastTx
|
|
2
|
-
${(0,k.oX)(
|
|
1
|
+
(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[7741],{70509:function(te,N,g){"use strict";g.r(N),g.d(N,{AlgorandTools:function(){return se},makeCurrencyEngine:function(){return Y},makeCurrencyTools:function(){return ue}});var T=g(88814),h=g(77591),C=g(20918),x=g(79014),k=g(76714),d=g(61808),W=g(82448),R=g(94935),S=g(79325),J=g(16757),Q=g(99599),q=Object.defineProperty,X=Object.defineProperties,ee=Object.getOwnPropertyDescriptors,f=Object.getOwnPropertySymbols,v=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,L=Reflect.get,z=(w,e,t)=>e in w?q(w,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):w[e]=t,m=(w,e)=>{for(var t in e||(e={}))P.call(e,t)&&z(w,t,e[t]);if(f)for(var t of f(e))O.call(e,t)&&z(w,t,e[t]);return w},Z=(w,e)=>X(w,ee(e)),ne=(w,e,t)=>L(v(w),t,e),c=(w,e,t)=>new Promise((n,i)=>{var s=r=>{try{o(t.next(r))}catch(u){i(u)}},l=r=>{try{o(t.throw(r))}catch(u){i(u)}},o=r=>r.done?n(r.value):Promise.resolve(r.value).then(s,l);o((t=t.apply(w,e)).next())});const{Algodv2:_,Indexer:G}=T.ZP,V=5e3,j=3e3;class $ extends J.P{constructor(e,t,n,i){super(e,t,n,i),this.getRecipientBalance=s=>c(this,null,function*(){try{return(yield this.fetchAccountInfo(s)).amount.toString()}catch{return this.minimumAddressBalance}}),this.engineGetActivationAssets=s=>c(this,null,function*(){return{assetOptions:[{tokenId:null,paymentWalletId:this.walletId,currencyPluginId:this.currencyInfo.pluginId}]}}),this.engineActivateWallet=s=>c(this,[s],function*({activateTokenIds:l,paymentInfo:o}){var r;if(l==null)throw new Error(`Must specify activateTokenIds for ${this.currencyInfo.currencyCode}`);const{tokenId:u,wallet:y}=o!=null?o:{tokenId:null};if(u!=null)throw new Error(`Must activate with ${this.currencyInfo.currencyCode}`);if((y==null?void 0:y.id)!==this.walletId)throw new Error("Must pay with same wallet you are activating token with");const a=this.networkInfo.minimumTxFee.toFixed();let p="0";const A=[];for(const E of l){if(E!==null&&this.allTokensMap[E]==null)throw new Error(`Invalid tokenId to activate ${E}`);const U={tokenId:E,skipChecks:!0,spendTargets:[{publicAddress:this.walletInfo.keys.publicKey,nativeAmount:"0"}]};try{const B=yield this.makeSpend(U);p=(0,h.add)(p,(r=B.parentNetworkFee)!=null?r:a)}catch{p=(0,h.add)(p,a)}A.push(U)}return{paymentTokenId:u,paymentWalletId:this.walletId,fromNativeAmount:"0",networkFee:{tokenId:null,nativeAmount:p,currencyPluginId:this.currencyInfo.pluginId},approve:(...E)=>c(this,[...E],function*(U={}){const{metadata:B}=U,I=[];for(const b of A){const F=yield this.makeSpend(b);F.metadata=m({},B);let K=yield y.signTx(F);K=yield y.broadcastTx(K),I.push(K),yield y.saveTx(K)}return{transactions:I}}),close:()=>c(this,null,function*(){})}}),this.networkInfo=e.networkInfo,this.queryTxMutex=(0,k.jT)(),this.suggestedTransactionParams={flatFee:!1,fee:0,firstRound:0,lastRound:0,genesisID:this.networkInfo.genesisID,genesisHash:this.networkInfo.genesisHash},this.minimumAddressBalance=this.networkInfo.minimumAddressBalance,this.totalReserve=this.minimumAddressBalance,this.otherMethods={parseWalletConnectV2Payload:s=>c(this,null,function*(){try{const o=(0,d.u1)(s).params[0][0],r=(0,T.wj)(S.US.parse(o.txn)),u=r.amount!=null?r.amount.toString():"0",y=r.fee.toFixed();let a=null;if(r.type==="axfer"){const p=r.assetIndex.toString();if(this.allTokensMap[p]==null)throw new Error("Unrecognized token");a=p}return{nativeAmount:u,networkFee:y,tokenId:a}}catch(l){throw this.warn("Wallet connect call_request ",l),l}})}}setOtherData(e){this.otherData=(0,d.te)(e)}fetchAccountInfo(e){return c(this,null,function*(){return yield(0,k.QJ)(this.networkInfo.algodServers.map(t=>()=>c(this,null,function*(){const i=yield new _("",t,"").accountInformation(e).do();return(0,d.UO)(i)})))})}queryBalance(){return c(this,null,function*(){try{const e=yield this.fetchAccountInfo(this.walletLocalData.publicKey),{assets:t,amount:n,"min-balance":i,round:s}=e;this.updateBalance(this.currencyInfo.currencyCode,n.toString()),this.totalReserve=i.toString();const l=[],o=[];for(const[r,u]of Object.entries(this.allTokensMap)){const y=t.find(a=>a["asset-id"].toFixed()===r);if(y!=null){const a=y.amount.toString();this.updateBalance(u.currencyCode,a),(0,h.gt)(a,"0")&&!this.enabledTokenIds.includes(r)&&l.push(r)}else this.updateBalance(u.currencyCode,"0"),this.enabledTokenIds.includes(r)&&o.push(r)}l.length>0&&this.currencyEngineCallbacks.onNewTokens(l),s>this.walletLocalData.blockHeight&&(this.walletLocalData.blockHeight=s,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight)),(0,k.dQ)(o,this.walletLocalData.unactivatedTokenIds)||(this.walletLocalData.unactivatedTokenIds=o,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onUnactivatedTokenIdsChanged(this.walletLocalData.unactivatedTokenIds))}catch(e){this.log.warn("queryBalance Error ",e)}})}queryTransactionParams(){return c(this,null,function*(){try{const e=yield(0,k.QJ)(this.networkInfo.algodServers.map(t=>()=>c(this,null,function*(){const i=yield new _("",t,"").getTransactionParams().do(),s=(0,d.NY)(i);if(s.genesisHash!==this.networkInfo.genesisHash)throw new Error("Server genesisHash mismatch");return s})));this.suggestedTransactionParams=e}catch(e){this.log.warn("queryTransactionParams error:",e)}})}processAlgorandTransaction(e){const{"confirmed-round":t,"round-time":n,"tx-type":i,fee:s,id:l,note:o,sender:r}=e;let u,y,a,p,A,D=!1;const E=[];switch(i){case"pay":{const{amount:I,receiver:b}=(0,d.sB)(e)["payment-transaction"];if(a=I.toString(),p=s.toString(),r===this.walletInfo.keys.publicKey)a=`-${(0,h.add)(a,p)}`,D=!0;else if(b===this.walletInfo.keys.publicKey)p="0",E.push(this.walletInfo.keys.publicKey);else return;u=this.currencyInfo.currencyCode,y=null;break}case"axfer":{const{amount:I,"asset-id":b,receiver:F}=(0,d.zI)(e)["asset-transfer-transaction"];if(a=I.toString(),p="0",r===this.walletInfo.keys.publicKey)a=`-${a}`,A=s.toString(),D=!0;else if(F===this.walletInfo.keys.publicKey)E.push(this.walletInfo.keys.publicKey);else return;const K=this.allTokensMap[b];if(K==null)return;u=K.currencyCode,y=b.toString();break}case"appl":{const{"inner-txns":I=[]}=(0,d.FG)(e);if(I.forEach(b=>this.processAlgorandTransaction(Z(m({},b),{id:l}))),a="0",p=s.toString(),r===this.walletInfo.keys.publicKey)a=`-${(0,h.add)(a,p)}`,D=!0;else return;u=this.currencyInfo.currencyCode,y=null;break}default:return}const U=[];if(o!=null){const I=S.US.parse(o);try{U.push({memoName:"note",type:"text",value:Q.K.stringify(I)})}catch{U.push({memoName:"note",type:"hex",value:S.YU.stringify(I).toLowerCase()})}}const B={blockHeight:t,currencyCode:u,date:n,isSend:D,memos:U,nativeAmount:a,networkFee:p,ourReceiveAddresses:E,parentNetworkFee:A,signedTx:"",tokenId:y,txid:l,walletId:this.walletId};this.addTransaction(this.currencyInfo.currencyCode,B)}queryTransactions(){return c(this,null,function*(){return yield this.queryTxMutex(()=>c(this,null,function*(){return yield this.queryTransactionsInner()}))})}queryTransactionsInner(){return c(this,null,function*(){const e=this.otherData.latestRound;let t,n=this.otherData.latestRound,i=0,s,l=!0;do{const o=yield(0,k.QJ)(this.networkInfo.indexerServers.map(a=>()=>c(this,null,function*(){const A=yield new G({},a,"").lookupAccountTransactions(this.walletLocalData.publicKey).minRound(e).nextToken(s!=null?s:"").do();return(0,d.vy)(A)}))),{"next-token":r,transactions:u}=o;if(u.length===0)break;for(const a of u){if(t==null&&(t=a.id,n=a["confirmed-round"]),i=a["confirmed-round"],a.id===this.otherData.latestTxid){l=!1;break}try{this.processAlgorandTransaction(a)}catch(p){this.log.warn("processAlgorandTransaction error:",p)}}n=n!=null?n:this.walletLocalData.blockHeight;const y=(n-i)/(n-e);this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=y,this.updateOnAddressesChecked(),s=r}while(s!=null&&l);t!=null&&this.otherData.latestTxid!==t&&(this.otherData.latestTxid=t,this.otherData.latestRound=n,this.walletLocalDataDirty=!0);for(const o of this.enabledTokens)this.tokenCheckTransactionsStatus[o]=1;this.updateOnAddressesChecked(),this.transactionsChangedArray.length>0&&(this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[])})}startEngine(){return c(this,null,function*(){this.engineOn=!0,this.addToLoop("queryBalance",V).catch(()=>{}),this.addToLoop("queryTransactionParams",V).catch(()=>{}),this.addToLoop("queryTransactions",j).catch(()=>{}),yield ne($.prototype,this,"startEngine").call(this)})}resyncBlockchain(){return c(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}calcFee(e){const t=e.estimateSize();return Math.max(this.suggestedTransactionParams.fee*t,this.networkInfo.minimumTxFee).toString()}getMaxSpendable(e){return c(this,null,function*(){const{tokenId:t}=e;let n=this.getBalance({tokenId:t});if(t==null&&(n=(0,h.sub)(n,this.totalReserve)),e.spendTargets[0].publicAddress==null)throw new Error("makeSpend Missing publicAddress");const{customNetworkFee:s}=e;let o=(0,d.V$)(s).fee;o==null&&(e.spendTargets[0].nativeAmount="1",o=(yield this.makeSpend(e)).networkFee);const r=(u,y)=>c(this,null,function*(){const a=(0,h.sub)(y,u);if((0,h.lte)(a,"1"))return u;const p=(0,h.add)(u,(0,h.div)(a,"2"));e.spendTargets[0].nativeAmount=p;const A=(0,h.add)(p,o!=null?o:this.networkInfo.minimumTxFee.toString());return(0,h.gt)(A,n)?yield r(u,p):yield r(p,y)});return yield r("0",(0,h.add)(n,"1"))})}makeSpend(e){return c(this,null,function*(){var t,n,i,s;const{edgeSpendInfo:l,currencyCode:o,nativeBalance:r}=this.makeSpendCheck(e),{customNetworkFee:u,memos:y=[],tokenId:a}=l,p=(0,h.sub)(this.getBalance({tokenId:a}),this.totalReserve);if(l.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{nativeAmount:A,publicAddress:D}=l.spendTargets[0];if(D==null)throw new Error("makeSpend Missing publicAddress");if(A==null)throw new R.$D;const{type:E}=(t=(0,W.Vk)(d.Eg)(l.otherParams))!=null?t:{type:o===this.currencyInfo.currencyCode?"pay":"axfer"},U=((n=y[0])==null?void 0:n.type)==="text"?Q.K.parse(y[0].value):void 0,B=(0,d.V$)(u).fee;let I,b=A,F="0",K,H,oe;switch(E){case"pay":{if(I=T.ZP.makePaymentTxnWithSuggestedParamsFromObject({to:D,from:this.walletInfo.keys.publicKey,amount:BigInt(A),note:U,suggestedParams:m({},this.suggestedTransactionParams)}),H=B!=null?B:this.calcFee(I),F=H,b=`-${(0,h.add)(b,F)}`,oe=D,(0,h.gt)((0,h.abs)(b),p))throw new R.C_({tokenId:a});break}case"axfer":{const ie=Object.keys(this.allTokensMap).find(he=>this.allTokensMap[he].currencyCode===o);if(ie==null)throw new Error("Unrecognized asset");const ae=(0,d.NO)((s=(i=this.allTokensMap)==null?void 0:i[ie])==null?void 0:s.networkLocation);if(ae==null)throw new Error("Unrecognized asset");if(I=T.ZP.makeAssetTransferTxnWithSuggestedParamsFromObject({assetIndex:parseInt(ae.contractAddress),to:D,from:this.walletInfo.keys.publicKey,amount:BigInt(A),note:U,suggestedParams:m({},this.suggestedTransactionParams)}),H=B!=null?B:this.calcFee(I),b=`-${b}`,K=H,(0,h.gt)(K,p))throw new R.C_({networkFee:H,tokenId:a});if((0,h.gt)((0,h.abs)(b),r))throw new R.C_({tokenId:a});break}default:throw new Error("Unrecognized transaction type")}I.flatFee=!0,I.fee=parseInt(H);const de={encodedTx:S.YU.stringify((0,T.nJ)(I)),recipient:oe};return{blockHeight:0,currencyCode:o,date:0,isSend:!0,memos:y,nativeAmount:b,networkFee:F,otherParams:de,ourReceiveAddresses:[],parentNetworkFee:K,signedTx:"",tokenId:a,txid:"",walletId:this.walletId}})}signMessage(e,t){return c(this,null,function*(){const n=(0,d.Dh)(this.currencyInfo.pluginId)(t),i=(0,T.wj)(S.US.parse(e)),s=T.ZP.mnemonicToSecretKey(n.mnemonic),l=i.signTxn(s.sk);return S.US.stringify(l)})}signTx(e,t){return c(this,null,function*(){const{encodedTx:n,recipient:i}=(0,d.Cf)((0,k.Xp)(e)),s=(0,T.wj)(Uint8Array.from(S.YU.parse(n)));i!=null&&(yield this.checkRecipientMinimumBalance(this.getRecipientBalance,s.amount.toString(),i));const l=(0,d.Dh)(this.currencyInfo.pluginId)(t),o=T.ZP.mnemonicToSecretKey(l.mnemonic),r=s.signTxn(o.sk),u=S.YU.stringify(r);return e.signedTx=u,e})}broadcastTx(e){return c(this,null,function*(){const t=Uint8Array.from(S.YU.parse(e.signedTx));try{const{txId:n}=yield(0,k.QJ)(this.networkInfo.algodServers.map(i=>()=>c(this,null,function*(){return yield new _("",i,"").sendRawTransaction(t).do()})));e.txid=n,e.date=Date.now()/1e3}catch(n){throw this.warn("FAILURE broadcastTx failed: ",n),n}return this.warn(`SUCCESS broadcastTx
|
|
2
|
+
${(0,k.oX)(e)}`),e})}}function Y(w,e,t,n){return c(this,null,function*(){const i=(0,d.Ug)(t),s=new $(w,e,i,n);return yield s.loadEngine(),s})}var le=g(48764).Buffer,M=(w,e,t)=>new Promise((n,i)=>{var s=r=>{try{o(t.next(r))}catch(u){i(u)}},l=r=>{try{o(t.throw(r))}catch(u){i(u)}},o=r=>r.done?n(r.value):Promise.resolve(r.value).then(s,l);o((t=t.apply(w,e)).next())});const{isValidAddress:re,mnemonicFromSeed:ce}=T.ZP;class se{constructor(e){const{builtinTokens:t,currencyInfo:n,io:i}=e;this.io=i,this.currencyInfo=n,this.builtinTokens=t}getDisplayPrivateKey(e){return M(this,null,function*(){const{pluginId:t}=this.currencyInfo;return(0,d.Dh)(t)(e.keys).mnemonic})}getDisplayPublicKey(e){return M(this,null,function*(){const{keys:t}=(0,d.Ug)(e);return t.publicKey})}importPrivateKey(e){return M(this,null,function*(){const{pluginId:t}=this.currencyInfo;return T.ZP.mnemonicToSecretKey(e),{[`${t}Mnemonic`]:e}})}createPrivateKey(e){return M(this,null,function*(){if(e!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const t=le.from(this.io.random(32)),n=ce(t);return yield this.importPrivateKey(n)})}derivePublicKey(e){return M(this,null,function*(){const{pluginId:t}=this.currencyInfo;if(e.type!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const n=(0,d.Dh)(t)(e.keys);return{publicKey:T.ZP.mnemonicToSecretKey(n.mnemonic).addr}})}parseUri(e,t,n){return M(this,null,function*(){const{pluginId:i}=this.currencyInfo,s={[i]:!0},{parsedUri:l,edgeParsedUri:o}=(0,x.k)(this.currencyInfo,e,s,this.builtinTokens,t!=null?t:this.currencyInfo.currencyCode,n);let r="";if(o.publicAddress!=null&&(r=o.publicAddress),!re(r))throw new Error("InvalidPublicAddressError");return o.uniqueIdentifier=l.query.memo,o})}encodeUri(e){return M(this,arguments,function*(t,n=[]){const{pluginId:i}=this.currencyInfo,{nativeAmount:s,currencyCode:l,publicAddress:o}=t;if(!re(o))throw new Error("InvalidPublicAddressError");let r;if(typeof s=="string"){const y=(0,k.Qs)(l!=null?l:this.currencyInfo.currencyCode,this.currencyInfo,n,this.builtinTokens);if(y==null)throw new Error("InternalErrorInvalidCurrencyCode");r=(0,h.div)(s,y.multiplier,18)}return(0,x.Q)(t,i,r)})}getTokenId(e){return M(this,null,function*(){(0,C.Rp)(e);const t=(0,d.NO)(e.networkLocation);if(t==null)throw new Error("ErrorInvalidContractAddress");return t.contractAddress})}}function ue(w){return M(this,null,function*(){return new se(w)})}},79014:function(te,N,g){"use strict";g.d(N,{Q:function(){return ee},k:function(){return X}});var T=g(77591),h=g.n(T),C=g(24350),x=g(84564),k=g.n(x),d=g(76714),W=Object.defineProperty,R=Object.getOwnPropertySymbols,S=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable,Q=(f,v,P)=>v in f?W(f,v,{enumerable:!0,configurable:!0,writable:!0,value:P}):f[v]=P,q=(f,v)=>{for(var P in v||(v={}))S.call(v,P)&&Q(f,P,v[P]);if(R)for(var P of R(v))J.call(v,P)&&Q(f,P,v[P]);return f};function X(f,v,P,O,L,z=[]){const m=q({},k()(v,{},!0)),Z=v.startsWith(`${f.pluginId}://`);if(m.protocol!=null&&(m.protocol=m.protocol.replace(":","")),m.protocol!=null&&m.protocol!==""&&!P[m.protocol])throw new Error(`Uri protocol '${m.protocol}' is not supported for ${f.pluginId}.`);if(m.host===""&&m.pathname==="")throw new Error("Path and host not found in uri.");const c={publicAddress:m.host!==""?m.host:m.pathname.split("/")[0]},_=m.query.label,G=m.query.message,V=m.query.category;(_!=null||G!=null||V!=null||Z)&&(c.metadata={},c.metadata.name=_,c.metadata.notes=G,c.metadata.category=V,c.metadata.gateway=Z!=null?Z:!1);const j=m.query.amount;if(j!=null&&typeof j=="string"){L==null&&(L=f.currencyCode);const $=(0,d.Qs)(L!=null?L:"",f,z,O);if($==null)throw new Error("InternalErrorInvalidCurrencyCode");let Y=(0,T.mul)(j,$.multiplier);Y=(0,T.toFixed)(Y,0,0),c.nativeAmount=Y,c.currencyCode=L}return{edgeParsedUri:c,parsedUri:m}}function ee(f,v,P){if(f.publicAddress==null)throw new Error("InvalidPublicAddressError");if(P==null&&f.label==null&&f.message==null)return f.publicAddress;{let O="";P!=null&&(O+="amount="+P+"&"),(f.label!=null||f.message!=null)&&(typeof f.label=="string"&&(O+="label="+f.label+"&"),typeof f.message=="string"&&(O+="message="+f.message+"&")),O=O.substr(0,O.length-1);const L={scheme:v,path:f.publicAddress,query:O};return(0,C.qC)(L)}}},99599:function(te,N,g){"use strict";g.d(N,{K:function(){return T}});const T={parse(h){const C=encodeURI(h),x=new Uint8Array(C.length);let k=0;for(let d=0;d<C.length;++d){const W=C.charCodeAt(d);W===37?(x[k++]=parseInt(C.slice(d+1,d+3),16),d+=2):x[k++]=W}return x.subarray(0,k)},stringify(h){let C="";for(let x=0;x<h.length;++x){const k=h[x];C+="%"+(k>>4).toString(16)+(k&15).toString(16)}return decodeURIComponent(C)}}},55024:function(){}}]);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[8222],{79014:function(Qe,ne,y){"use strict";y.d(ne,{Q:function(){return K},k:function(){return re}});var q=y(77591),Te=y.n(q),M=y(24350),L=y(84564),S=y.n(L),te=y(76714),J=Object.defineProperty,I=Object.getOwnPropertySymbols,Y=Object.prototype.hasOwnProperty,oe=Object.prototype.propertyIsEnumerable,z=(k,C,p)=>C in k?J(k,C,{enumerable:!0,configurable:!0,writable:!0,value:p}):k[C]=p,se=(k,C)=>{for(var p in C||(C={}))Y.call(C,p)&&z(k,p,C[p]);if(I)for(var p of I(C))oe.call(C,p)&&z(k,p,C[p]);return k};function re(k,C,p,E,c,ie=[]){const A=se({},S()(C,{},!0)),Z=C.startsWith(`${k.pluginId}://`);if(A.protocol!=null&&(A.protocol=A.protocol.replace(":","")),A.protocol!=null&&A.protocol!==""&&!p[A.protocol])throw new Error(`Uri protocol '${A.protocol}' is not supported for ${k.pluginId}.`);if(A.host===""&&A.pathname==="")throw new Error("Path and host not found in uri.");const B={publicAddress:A.host!==""?A.host:A.pathname.split("/")[0]},ae=A.query.label,ce=A.query.message,le=A.query.category;(ae!=null||ce!=null||le!=null||Z)&&(B.metadata={},B.metadata.name=ae,B.metadata.notes=ce,B.metadata.category=le,B.metadata.gateway=Z!=null?Z:!1);const G=A.query.amount;if(G!=null&&typeof G=="string"){c==null&&(c=k.currencyCode);const ue=(0,te.Qs)(c!=null?c:"",k,ie,E);if(ue==null)throw new Error("InternalErrorInvalidCurrencyCode");let Q=(0,q.mul)(G,ue.multiplier);Q=(0,q.toFixed)(Q,0,0),B.nativeAmount=Q,B.currencyCode=c}return{edgeParsedUri:B,parsedUri:A}}function K(k,C,p){if(k.publicAddress==null)throw new Error("InvalidPublicAddressError");if(p==null&&k.label==null&&k.message==null)return k.publicAddress;{let E="";p!=null&&(E+="amount="+p+"&"),(k.label!=null||k.message!=null)&&(typeof k.label=="string"&&(E+="label="+k.label+"&"),typeof k.message=="string"&&(E+="message="+k.message+"&")),E=E.substr(0,E.length-1);const c={scheme:C,path:k.publicAddress,query:E};return(0,M.qC)(c)}}},94831:function(Qe,ne,y){"use strict";y.r(ne),y.d(ne,{CosmosTools:function(){return Ge},makeCurrencyEngine:function(){return Kn},makeCurrencyTools:function(){return Xn}});var q=y(87137),Te=y(79562),M=y(28972),L=y(74087),S=y(77591),te=y(2153),J=y(42150),I=y(79325),Y=y(20918),oe=y(79014),z=y(76714),se=y(98994),re=y(2387),K=y(39385),k=y(7416),C=y(33359),p=y(24658),E=y(73034),c=y(82448),ie=y(62177);const A=["coin_spent.spender","coin_received.receiver"],Z=(0,c.su)({archivedTxLastCheckTime:(0,c.Vk)(c.mH,0),"coin_spent.spender":(0,c.Vk)(c.XC),"coin_received.receiver":(0,c.Vk)(c.XC)}),pe=(0,ie.jd)((0,c.su)({bech32Address:c.XC,publicKey:c.XC})),B=e=>{const n=(0,c.su)({[`${e}Mnemonic`]:c.XC});return(0,c.W1)(t=>({mnemonic:n(t)[`${e}Mnemonic`]}),t=>({[`${e}Mnemonic`]:t.mnemonic}))},ae=(0,c.su)({ninerealmsClientId:(0,c.Zz)(c.XC)}),ce=(0,c.su)({denom:c.XC,amount:c.XC}),le=(0,c.su)({gasFeeCoin:ce,gasLimit:c.XC,unsignedTxHex:c.XC}),G=(0,c.su)({native_outbound_fee_rune:c.XC,native_tx_fee_rune:c.XC}),ue=(0,c.su)({method:(0,c.Wf)("cosmos_getAccounts"),params:(0,c.su)({})}),Q=(0,c.Wf)("cosmos_signDirect"),we=(0,c.su)({method:Q,params:(0,c.su)({signerAddress:c.XC,signDoc:(0,c.su)({chainId:c.XC,accountNumber:c.XC,authInfoBytes:c.XC,bodyBytes:c.XC})})}),Ae=(0,c.su)({method:(0,c.Wf)("cosmos_signAmino"),params:(0,c.su)({signerAddress:c.XC,signDoc:(0,c.su)({chain_id:c.XC,account_number:c.XC,sequence:c.XC,memo:c.XC,msgs:(0,c._2)((0,c.su)({type:c.XC,value:c.JC})),fee:(0,c.su)({amount:(0,c._2)((0,c.su)({denom:c.XC,amount:c.XC})),gas:c.XC})})})});var ve=(e,n,t)=>new Promise((r,s)=>{var o=i=>{try{a(t.next(i))}catch(u){s(u)}},l=i=>{try{a(t.throw(i))}catch(u){s(u)}},a=i=>i.done?r(i.value):Promise.resolve(i.value).then(o,l);a((t=t.apply(e,n)).next())});const ke=(e,n)=>{const t=ae(n),r={},s=/{{(.*?)}}/g;for(const[o,l]of Object.entries(e.headers)){const a=s.exec(l);a!=null&&(r[o]=t[a[1]])}return{url:e.url,headers:r}},je=(e,n)=>{const{url:t,headers:r}=n;return{execute:s=>ve(void 0,null,function*(){const o={method:"POST",headers:r,body:JSON.stringify(s)};return yield(yield e(t,o)).json()}),disconnect:()=>{}}},en=e=>ve(void 0,null,function*(){const n=yield E.Comet38Client.create(e),t=(yield n.status()).nodeInfo.version;return t.startsWith("0.38.")?n:t.startsWith("0.37.")?yield E.Tendermint37Client.create(e):yield E.Tendermint34Client.create(e)}),be=(e,n)=>ve(void 0,null,function*(){const t=yield p.StargateClient.create(yield en(je(e,n))),r=t.forceGetCometClient();return{queryClient:p.QueryClient.withExtensions(r,p.setupAuthExtension,p.setupBankExtension,p.setupStakingExtension,p.setupTxExtension,p.setupIbcExtension),stargateClient:t,cometClient:r}}),nn=e=>{var n;const[t,...r]=e.split("."),s=e.includes("/"),o=r.join("."),l=(n=o==null?void 0:o.split("-"))==null?void 0:n[0];return{chain:t,symbol:o,ticker:l,synth:s}},$=e=>e.reduce((n,t)=>{try{return(0,C.addCoins)(n,t)}catch{}return n}),Se=(0,c.Wf)("amount"),tn=(0,c.Wf)("receiver"),on=(0,c.Wf)("spender"),sn=(0,c.Wf)("amount","receiver","spender"),rn=(0,c.su)({type:(0,c.Wf)("coin_received"),attributes:(0,c.vq)((0,c.su)({key:Se,value:c.XC}),(0,c.su)({key:tn,value:c.XC}))}),an=(0,c.su)({type:(0,c.Wf)("coin_spent"),attributes:(0,c.vq)((0,c.su)({key:Se,value:c.XC}),(0,c.su)({key:on,value:c.XC}))}),cn=(e,n)=>{const t=new Map;for(const s of e){const o={type:s.type,attributes:s.attributes.filter(i=>(0,c.Vk)(sn)(i.key)!=null).sort((i,u)=>i.key<u.key?-1:1)},l=(0,c.Vk)(rn)(o);if(l!=null){const[i,u]=l.attributes.map(d=>d.value);if(u!==n)continue;Ie(i).forEach(d=>{var v;const g=d.amount,h=(v=t.get(d.denom))!=null?v:"0";t.set(d.denom,(0,S.add)(g,h))});continue}const a=(0,c.Vk)(an)(o);if(a!=null){const[i,u]=a.attributes.map(d=>d.value);if(u!==n)continue;Ie(i).forEach(d=>{var v;const g=`-${d.amount}`,h=(v=t.get(d.denom))!=null?v:"0";t.set(d.denom,(0,S.add)(g,h))})}}const r=[];return t.forEach((s,o)=>{s!=="0"&&r.push({denom:o,amount:s})}),r},de=e=>{try{return I.YU.parse(e)}catch{return I.US.parse(e)}},Ie=e=>e.replace(/\s/g,"").split(",").filter(Boolean).map(n=>{var t;const r=n.match(/^([0-9]+)([a-zA-Z][a-zA-Z0-9/-]{2,127})$/);if(r==null)throw new Error(`Got an invalid coin string: ${e}`);return{amount:(t=r[1].replace(/^0+/,""))!=null?t:"0",denom:r[2]}}),ln=(e,n)=>{const t=J.chains.find(l=>l.bech32_prefix===(0,M.fromBech32)(n).prefix);if(t==null)throw new Error("Unrecognized denom");const r=t.chain_name,s=(0,k.getIbcInfo)(J.ibc,e,r);if(s==null)throw new Error(`No IBC channels between ${e} and ${r}`);const o=(0,k.getTransferChannel)(s);return e<r?{channel:o.chain_1.channel_id,port:o.chain_1.port_id}:{channel:o.chain_2.channel_id,port:o.chain_2.port_id}};var un=y(43720),x=y.n(un),dn=y(62100),f=y.n(dn);const Hn="common";function Pe(){return{chain:"",symbol:"",ticker:"",synth:!1}}const X={encode(e,n=f().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 f().Reader?e:f().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=Pe();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.chain=t.string();continue;case 2:if(o!==18)break;s.symbol=t.string();continue;case 3:if(o!==26)break;s.ticker=t.string();continue;case 4:if(o!==32)break;s.synth=t.bool();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{chain:P(e.chain)?globalThis.String(e.chain):"",symbol:P(e.symbol)?globalThis.String(e.symbol):"",ticker:P(e.ticker)?globalThis.String(e.ticker):"",synth:P(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 X.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,r,s;const o=Pe();return o.chain=(n=e.chain)!=null?n:"",o.symbol=(t=e.symbol)!=null?t:"",o.ticker=(r=e.ticker)!=null?r:"",o.synth=(s=e.synth)!=null?s:!1,o}};function Ee(){return{asset:void 0,amount:"",decimals:x().ZERO}}const w={encode(e,n=f().Writer.create()){return e.asset!==void 0&&X.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 f().Reader?e:f().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=Ee();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.asset=X.decode(t,t.uint32());continue;case 2:if(o!==18)break;s.amount=t.string();continue;case 3:if(o!==24)break;s.decimals=t.int64();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{asset:P(e.asset)?X.fromJSON(e.asset):void 0,amount:P(e.amount)?globalThis.String(e.amount):"",decimals:P(e.decimals)?x().fromValue(e.decimals):x().ZERO}},toJSON(e){const n={};return e.asset!==void 0&&(n.asset=X.toJSON(e.asset)),e.amount!==""&&(n.amount=e.amount),e.decimals.isZero()||(n.decimals=(e.decimals||x().ZERO).toString()),n},create(e){return w.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=Ee();return t.asset=e.asset!==void 0&&e.asset!==null?X.fromPartial(e.asset):void 0,t.amount=(n=e.amount)!=null?n:"",t.decimals=e.decimals!==void 0&&e.decimals!==null?x().fromValue(e.decimals):x().ZERO,t}};function xe(){return{secp256k1:"",ed25519:""}}const hn={encode(e,n=f().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 f().Reader?e:f().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=xe();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.secp256k1=t.string();continue;case 2:if(o!==18)break;s.ed25519=t.string();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{secp256k1:P(e.secp256k1)?globalThis.String(e.secp256k1):"",ed25519:P(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 hn.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const r=xe();return r.secp256k1=(n=e.secp256k1)!=null?n:"",r.ed25519=(t=e.ed25519)!=null?t:"",r}};function Oe(){return{id:"",chain:"",fromAddress:"",toAddress:"",coins:[],gas:[],memo:""}}const fn={encode(e,n=f().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)w.encode(t,n.uint32(42).fork()).ldelim();for(const t of e.gas)w.encode(t,n.uint32(50).fork()).ldelim();return e.memo!==""&&n.uint32(58).string(e.memo),n},decode(e,n){const t=e instanceof f().Reader?e:f().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=Oe();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.id=t.string();continue;case 2:if(o!==18)break;s.chain=t.string();continue;case 3:if(o!==26)break;s.fromAddress=t.string();continue;case 4:if(o!==34)break;s.toAddress=t.string();continue;case 5:if(o!==42)break;s.coins.push(w.decode(t,t.uint32()));continue;case 6:if(o!==50)break;s.gas.push(w.decode(t,t.uint32()));continue;case 7:if(o!==58)break;s.memo=t.string();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{id:P(e.id)?globalThis.String(e.id):"",chain:P(e.chain)?globalThis.String(e.chain):"",fromAddress:P(e.fromAddress)?globalThis.String(e.fromAddress):"",toAddress:P(e.toAddress)?globalThis.String(e.toAddress):"",coins:globalThis.Array.isArray(e==null?void 0:e.coins)?e.coins.map(n=>w.fromJSON(n)):[],gas:globalThis.Array.isArray(e==null?void 0:e.gas)?e.gas.map(n=>w.fromJSON(n)):[],memo:P(e.memo)?globalThis.String(e.memo):""}},toJSON(e){var n,t;const r={};return e.id!==""&&(r.id=e.id),e.chain!==""&&(r.chain=e.chain),e.fromAddress!==""&&(r.fromAddress=e.fromAddress),e.toAddress!==""&&(r.toAddress=e.toAddress),(n=e.coins)!=null&&n.length&&(r.coins=e.coins.map(s=>w.toJSON(s))),(t=e.gas)!=null&&t.length&&(r.gas=e.gas.map(s=>w.toJSON(s))),e.memo!==""&&(r.memo=e.memo),r},create(e){return fn.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,r,s,o,l,a;const i=Oe();return i.id=(n=e.id)!=null?n:"",i.chain=(t=e.chain)!=null?t:"",i.fromAddress=(r=e.fromAddress)!=null?r:"",i.toAddress=(s=e.toAddress)!=null?s:"",i.coins=((o=e.coins)==null?void 0:o.map(u=>w.fromPartial(u)))||[],i.gas=((l=e.gas)==null?void 0:l.map(u=>w.fromPartial(u)))||[],i.memo=(a=e.memo)!=null?a:"",i}};function De(){return{coins:[],poolDeduct:""}}const mn={encode(e,n=f().Writer.create()){for(const t of e.coins)w.encode(t,n.uint32(10).fork()).ldelim();return e.poolDeduct!==""&&n.uint32(18).string(e.poolDeduct),n},decode(e,n){const t=e instanceof f().Reader?e:f().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=De();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.coins.push(w.decode(t,t.uint32()));continue;case 2:if(o!==18)break;s.poolDeduct=t.string();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{coins:globalThis.Array.isArray(e==null?void 0:e.coins)?e.coins.map(n=>w.fromJSON(n)):[],poolDeduct:P(e.poolDeduct)?globalThis.String(e.poolDeduct):""}},toJSON(e){var n;const t={};return(n=e.coins)!=null&&n.length&&(t.coins=e.coins.map(r=>w.toJSON(r))),e.poolDeduct!==""&&(t.poolDeduct=e.poolDeduct),t},create(e){return mn.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const r=De();return r.coins=((n=e.coins)==null?void 0:n.map(s=>w.fromPartial(s)))||[],r.poolDeduct=(t=e.poolDeduct)!=null?t:"",r}};function Be(){return{value:""}}const gn={encode(e,n=f().Writer.create()){return e.value!==""&&n.uint32(10).string(e.value),n},decode(e,n){const t=e instanceof f().Reader?e:f().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=Be();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.value=t.string();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{value:P(e.value)?globalThis.String(e.value):""}},toJSON(e){const n={};return e.value!==""&&(n.value=e.value),n},create(e){return gn.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=Be();return t.value=(n=e.value)!=null?n:"",t}};f().util.Long!==x()&&(f().util.Long=x(),f().configure());function P(e){return e!=null}const Vn="types";function Ue(){return{coins:[],memo:"",signer:new Uint8Array(0)}}const he={encode(e,n=f().Writer.create()){for(const t of e.coins)w.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 f().Reader?e:f().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=Ue();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.coins.push(w.decode(t,t.uint32()));continue;case 2:if(o!==18)break;s.memo=t.string();continue;case 3:if(o!==26)break;s.signer=t.bytes();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{coins:globalThis.Array.isArray(e==null?void 0:e.coins)?e.coins.map(n=>w.fromJSON(n)):[],memo:Ne(e.memo)?globalThis.String(e.memo):"",signer:Ne(e.signer)?yn(e.signer):new Uint8Array(0)}},toJSON(e){var n;const t={};return(n=e.coins)!=null&&n.length&&(t.coins=e.coins.map(r=>w.toJSON(r))),e.memo!==""&&(t.memo=e.memo),e.signer.length!==0&&(t.signer=pn(e.signer)),t},create(e){return he.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,r;const s=Ue();return s.coins=((n=e.coins)==null?void 0:n.map(o=>w.fromPartial(o)))||[],s.memo=(t=e.memo)!=null?t:"",s.signer=(r=e.signer)!=null?r:new Uint8Array(0),s}};function yn(e){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(e,"base64"));{const n=globalThis.atob(e),t=new Uint8Array(n.length);for(let r=0;r<n.length;++r)t[r]=n.charCodeAt(r);return t}}function pn(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(""))}}f().util.Long!==x()&&(f().util.Long=x(),f().configure());function Ne(e){return e!=null}const qn="cosmos.base.v1beta1";function Re(){return{denom:"",amount:""}}const H={encode(e,n=f().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 f().Reader?e:f().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=Re();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.denom=t.string();continue;case 2:if(o!==18)break;s.amount=t.string();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{denom:V(e.denom)?globalThis.String(e.denom):"",amount:V(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 H.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const r=Re();return r.denom=(n=e.denom)!=null?n:"",r.amount=(t=e.amount)!=null?t:"",r}};function Me(){return{denom:"",amount:""}}const vn={encode(e,n=f().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 f().Reader?e:f().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=Me();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.denom=t.string();continue;case 2:if(o!==18)break;s.amount=t.string();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{denom:V(e.denom)?globalThis.String(e.denom):"",amount:V(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 vn.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const r=Me();return r.denom=(n=e.denom)!=null?n:"",r.amount=(t=e.amount)!=null?t:"",r}};function _e(){return{int:""}}const kn={encode(e,n=f().Writer.create()){return e.int!==""&&n.uint32(10).string(e.int),n},decode(e,n){const t=e instanceof f().Reader?e:f().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=_e();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.int=t.string();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{int:V(e.int)?globalThis.String(e.int):""}},toJSON(e){const n={};return e.int!==""&&(n.int=e.int),n},create(e){return kn.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=_e();return t.int=(n=e.int)!=null?n:"",t}};function Fe(){return{dec:""}}const Cn={encode(e,n=f().Writer.create()){return e.dec!==""&&n.uint32(10).string(e.dec),n},decode(e,n){const t=e instanceof f().Reader?e:f().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=Fe();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.dec=t.string();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{dec:V(e.dec)?globalThis.String(e.dec):""}},toJSON(e){const n={};return e.dec!==""&&(n.dec=e.dec),n},create(e){return Cn.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=Fe();return t.dec=(n=e.dec)!=null?n:"",t}};f().util.Long!==x()&&(f().util.Long=x(),f().configure());function V(e){return e!=null}const Yn="types";function Le(){return{fromAddress:new Uint8Array(0),toAddress:new Uint8Array(0),amount:[]}}const fe={encode(e,n=f().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)H.encode(t,n.uint32(26).fork()).ldelim();return n},decode(e,n){const t=e instanceof f().Reader?e:f().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=Le();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.fromAddress=t.bytes();continue;case 2:if(o!==18)break;s.toAddress=t.bytes();continue;case 3:if(o!==26)break;s.amount.push(H.decode(t,t.uint32()));continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{fromAddress:Ke(e.fromAddress)?We(e.fromAddress):new Uint8Array(0),toAddress:Ke(e.toAddress)?We(e.toAddress):new Uint8Array(0),amount:globalThis.Array.isArray(e==null?void 0:e.amount)?e.amount.map(n=>H.fromJSON(n)):[]}},toJSON(e){var n;const t={};return e.fromAddress.length!==0&&(t.fromAddress=Je(e.fromAddress)),e.toAddress.length!==0&&(t.toAddress=Je(e.toAddress)),(n=e.amount)!=null&&n.length&&(t.amount=e.amount.map(r=>H.toJSON(r))),t},create(e){return fe.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,r;const s=Le();return s.fromAddress=(n=e.fromAddress)!=null?n:new Uint8Array(0),s.toAddress=(t=e.toAddress)!=null?t:new Uint8Array(0),s.amount=((r=e.amount)==null?void 0:r.map(o=>H.fromPartial(o)))||[],s}};function We(e){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(e,"base64"));{const n=globalThis.atob(e),t=new Uint8Array(n.length);for(let r=0;r<n.length;++r)t[r]=n.charCodeAt(r);return t}}function Je(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(""))}}f().util.Long!==x()&&(f().util.Long=x(),f().configure());function Ke(e){return e!=null}var Tn=Object.defineProperty,wn=Object.defineProperties,An=Object.getOwnPropertyDescriptors,$e=Object.getOwnPropertySymbols,bn=Object.prototype.hasOwnProperty,Sn=Object.prototype.propertyIsEnumerable,Xe=(e,n,t)=>n in e?Tn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,In=(e,n)=>{for(var t in n||(n={}))bn.call(n,t)&&Xe(e,t,n[t]);if($e)for(var t of $e(n))Sn.call(n,t)&&Xe(e,t,n[t]);return e},Pn=(e,n)=>wn(e,An(n));const En=1e3*60*60*24,xn=e=>{const n=new L.Registry([["/ibc.applications.transfer.v1.MsgTransfer",K.MsgTransfer],["/cosmwasm.wasm.v1.MsgExecuteContract",re.$n]]);let t=s=>{const{amount:o,fromAddress:l,toAddress:a}=s;return{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:se.MsgSend.encode(se.MsgSend.fromPartial({fromAddress:l,toAddress:a,amount:o})).finish()}};const r=s=>{const{memo:o,toAddress:l,fromAddress:a,channel:i,port:u,amount:m}=s;return{typeUrl:"/ibc.applications.transfer.v1.MsgTransfer",value:K.MsgTransfer.encode(K.MsgTransfer.fromPartial({memo:o,receiver:l,sender:a,sourceChannel:i,sourcePort:u,token:m,timeoutTimestamp:BigInt((Date.now()+En)*1e6)})).finish()}};switch(e){case"thorchainrune":{const s="/types.MsgDeposit";n.register(s,he);const o=a=>{const{assets:i,memo:u,signer:m}=a,d=i.map(g=>Pn(In({},g),{asset:nn(g.asset)}));return{typeUrl:s,value:he.encode(he.fromPartial({coins:d,memo:u,signer:(0,M.fromBech32)(m).data})).finish()}},l="/types.MsgSend";return n.register(l,fe),t=a=>{const{amount:i,fromAddress:u,toAddress:m}=a;return{typeUrl:l,value:fe.encode(fe.fromPartial({fromAddress:(0,M.fromBech32)(u).data,toAddress:(0,M.fromBech32)(m).data,amount:i})).finish()}},{methods:{deposit:o,ibcTransfer:r,transfer:t},registry:n}}}return{methods:{ibcTransfer:r,transfer:t},registry:n}};var He=y(45504),O=y(29639),On=y(94935),Dn=y(16757),Bn=Object.defineProperty,Un=Object.defineProperties,Nn=Object.getOwnPropertyDescriptors,Ve=Object.getOwnPropertySymbols,Rn=Object.getPrototypeOf,Mn=Object.prototype.hasOwnProperty,_n=Object.prototype.propertyIsEnumerable,Fn=Reflect.get,qe=(e,n,t)=>n in e?Bn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,me=(e,n)=>{for(var t in n||(n={}))Mn.call(n,t)&&qe(e,t,n[t]);if(Ve)for(var t of Ve(n))_n.call(n,t)&&qe(e,t,n[t]);return e},Ye=(e,n)=>Un(e,Nn(n)),ze=(e,n,t)=>Fn(Rn(e),t,n),b=(e,n,t)=>new Promise((r,s)=>{var o=i=>{try{a(t.next(i))}catch(u){s(u)}},l=i=>{try{a(t.throw(i))}catch(u){s(u)}},a=i=>i.done?r(i.value):Promise.resolve(i.value).then(o,l);a((t=t.apply(e,n)).next())});const Ze=5e3,Ln=3e3,Wn=1e3*60*60*24*14,Jn=1e3*60*2;class ge extends Dn.P{constructor(n,t,r,s){super(n,t,r,s),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.stakingSupported=!0,this.otherMethods={getMaxTx:o=>b(this,null,function*(){switch(o.type){case"MakeTxDeposit":{if(this.tools.methods.deposit==null)throw new Error(`${this.currencyInfo.displayName} does not support the deposit method`);const{assets:l,memo:a}=o;if(l.length!==1)throw new Error("Cannot calculate max tx for more than one asset");const i=this.tools.methods.deposit({assets:l,memo:a,signer:this.walletInfo.keys.bech32Address}),{networkFee:u}=yield this.calculateFee({messages:[i],memo:a}),m=this.getBalance({tokenId:null});return(0,S.sub)(m,u)}default:throw new Error(`Invalid type: ${o.type}`)}}),makeTx:o=>b(this,null,function*(){switch(o.type){case"MakeTxDeposit":{if(this.tools.methods.deposit==null)throw new Error(`${this.currencyInfo.displayName} does not support the deposit method`);const{assets:l,memo:a,metadata:i}=o,u=this.tools.methods.deposit({assets:l,memo:a,signer:this.walletInfo.keys.bech32Address}),m=this.createUnsignedTxHex([u],a),{gasFeeCoin:d,gasLimit:v,networkFee:g}=yield this.calculateFee({messages:[u],memo:a}),h={gasFeeCoin:d,gasLimit:v,unsignedTxHex:m};return{blockHeight:0,currencyCode:this.currencyInfo.currencyCode,date:Date.now()/1e3,isSend:!0,memos:[],metadata:i,nativeAmount:`-${g}`,networkFee:g,otherParams:h,ourReceiveAddresses:[],signedTx:"",tokenId:null,txid:"",walletId:this.walletId}}default:throw new Error(`Invalid type: ${o.type}`)}}),parseWalletConnectV2Payload:o=>b(this,null,function*(){try{switch(o==null?void 0:o.method){case"cosmos_getAccounts":return{nativeAmount:"0",networkFee:"0",tokenId:null};case"cosmos_signDirect":{const l=we(o),{authInfoBytes:a,bodyBytes:i}=l.params.signDoc,u=O.TxBody.decode(de(i)),{nativeAmount:m,tokenId:d}=this.getAmountAndTokenIdFromKnownMessageTypes(u.messages),v=O.AuthInfo.decode(de(a));let g="0";const h=v.fee;return h!=null&&(g=$([(0,p.coin)("0",this.networkInfo.nativeDenom),...h.amount]).amount),{nativeAmount:m,networkFee:g,tokenId:d}}case"cosmos_signAmino":{const l=Ae(o),{signDoc:a}=l.params,i=(0,C.makeSignDoc)(a.msgs,a.fee,a.chain_id,a.memo,a.account_number,a.sequence),u=new p.AminoTypes(me(me({},p.createBankAminoConverters),p.createIbcAminoConverters)),m=i.msgs.map(T=>u.fromAmino(T)),{nativeAmount:d,tokenId:v}=this.getAmountAndTokenIdFromKnownMessageTypes(m);let g="0";const h=a.fee;return h!=null&&(g=$([(0,p.coin)("0",this.networkInfo.nativeDenom),...h.amount]).amount),{nativeAmount:d,networkFee:g,tokenId:v}}default:throw new Error(`Invalid method: ${o==null?void 0:o.method}`)}}catch(l){throw this.warn("Wallet connect call_request ",l),l}})}}tokenIdFromDenom(n){if(this.networkInfo.nativeDenom===n)return null;const t=Object.keys(this.allTokensMap).find(r=>{var s;return((s=this.allTokensMap[r].networkLocation)==null?void 0:s.contractAddress)===n});if(t===void 0)throw new Error(`Unrecognized denom: ${n}`);return t}getAmountAndTokenIdFromKnownMessageTypes(n){var t;let r=null,s;for(const o of n)switch(o.typeUrl){case"/ibc.applications.transfer.v1.MsgTransfer":{const l=this.tools.registry.decode(o),a=K.MsgTransfer.fromPartial(l);r===void 0&&(r=this.tokenIdFromDenom(a.token.denom));const i=(0,p.coin)(a.token.amount,a.token.denom);s==null?s=i:s=$([s,i]);break}case"/cosmwasm.wasm.v1.MsgExecuteContract":{const l=this.tools.registry.decode(o),a=re.$n.fromPartial(l),{funds:i}=a;if(i.length>0){const{denom:u}=i[0];r===void 0&&(r=this.tokenIdFromDenom(u));let m=(0,p.coin)("0",u);for(const d of i)m=$([m,d]);s==null?s=m:s=$([s,m])}break}default:}return{nativeAmount:(t=s==null?void 0:s.amount)!=null?t:"0",tokenId:r}}setOtherData(n){this.otherData=Z(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(),r=yield t.getAllBalances(this.walletInfo.keys.bech32Address),s=r.find(i=>i.denom===this.networkInfo.nativeDenom);this.updateBalance(this.currencyInfo.currencyCode,(n=s==null?void 0:s.amount)!=null?n:"0");const o=[];if(Object.keys(this.allTokensMap).forEach(i=>{var u;const m=this.allTokensMap[i],d=r.find(g=>{var h;return g.denom===((h=m.networkLocation)==null?void 0:h.contractAddress)}),v=(u=d==null?void 0:d.amount)!=null?u:"0";this.updateBalance(m.currencyCode,v),(0,S.gt)(v,"0")&&!this.enabledTokenIds.includes(i)&&o.push(i)}),o.length>0&&this.currencyEngineCallbacks.onNewTokens(o),this.stakingSupported)try{const i=yield t.getBalanceStaked(this.walletInfo.keys.bech32Address);if(i!=null&&this.stakedBalanceCache!==i.amount){const u={stakedAmounts:[{nativeAmount:i.amount}]};this.currencyEngineCallbacks.onStakingStatusChanged(u),this.stakedBalanceCache=i.amount}}catch(i){if(String(i).includes("unknown query path"))this.stakingSupported=!1;else throw i}const{accountNumber:l,sequence:a}=yield t.getSequence(this.walletInfo.keys.bech32Address);this.accountNumber=l,this.sequence=a}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(s=>this.allTokensMap[s].currencyCode)],r=Date.now()-Wn>this.otherData.archivedTxLastCheckTime?yield be(this.fetchCors,ke(this.networkInfo.archiveNode,this.tools.initOptions)):this.getClients();for(const s of A){const o=yield this.queryTransactionsInner(s,r);o!=null&&this.otherData[s]!==o&&(this.otherData[s]=o,this.walletLocalDataDirty=!0),n+=.5,t.forEach(l=>this.tokenCheckTransactionsStatus[l]=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 r={query:`${n}='${this.walletInfo.keys.bech32Address}'`,per_page:50,order_by:"desc"};let s,o=0,l,a=0,i=!1;try{do{const u=yield t.cometClient.txSearch(Ye(me({},r),{page:++o})),{totalCount:m,txs:d}=u;l==null&&(l=m),a=a+d.length;for(const v of d){const g=(0,M.toHex)(v.hash).toUpperCase();if(this.removeFromUnconfirmedCache(g),s==null&&(s=g),g===this.otherData[n]){i=!0;break}const h=v.result.events.map(p.fromTendermintEvent);let T=[];try{T=cn(h,this.walletInfo.keys.bech32Address)}catch(ee){this.log.warn("reduceCoinEventsForAddress error:",String(ee))}if(T.length===0)continue;const D=yield t.stargateClient.getBlock(v.height),U=(0,E.toSeconds)((0,E.fromRfc3339WithNanoseconds)(D.header.time)).seconds,{height:N,tx:W}=v,j=I.YU.stringify(W),{authInfo:{fee:_},body:{memo:ye,messages:F}}=(0,L.decodeTxRaw)(W),Ce=yield this.totalDynamicNetworkFee(F,D.header.height);T.forEach(ee=>{this.processCosmosTransaction(g,U,j,ee,ye,N,Ce,_)})}}while(l>a&&!i)}catch(u){throw this.log.warn("queryTransactions error:",u),u}return s})}processCosmosTransaction(n,t,r,s,o,l,a,i){const{amount:u,denom:m}=s,d=this.networkInfo.nativeDenom===m;let v;try{v=this.tokenIdFromDenom(m)}catch{return}const{currencyCode:g}=v==null?this.currencyInfo:this.allTokensMap[v];let h="0";if(i!=null){const{amount:_}=i,ye=$([(0,p.coin)("0",this.networkInfo.nativeDenom),..._]);h=(0,S.add)(h,ye.amount)}const T=(0,S.lt)(u,"0"),D=[];let U=u,N;T?d?(h=(0,S.add)(h,a),U=(0,S.sub)(U,h)):(h="0",N=a!=="0"?a:void 0):(D.push(this.walletInfo.keys.bech32Address),h="0");const W=[];o!==""&&W.push({type:"text",value:o});const j={blockHeight:l,currencyCode:g,date:t,isSend:T,memos:W,nativeAmount:U,networkFee:h,ourReceiveAddresses:D,parentNetworkFee:N,signedTx:r,tokenId:v,txid:n,walletId:this.walletId};this.addTransaction(g,j)}createUnsignedTxHex(n,t){const r=O.TxBody.fromPartial({messages:n,memo:t}),s=O.TxBody.encode(r).finish(),o=O.TxRaw.fromPartial({bodyBytes:s});return I.YU.stringify(O.TxRaw.encode(o).finish())}addToUnconfirmedCache(n){const t=new Date(new Date().getTime()+Jn);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}totalDynamicNetworkFee(n,t){return b(this,null,function*(){let r="0";if(this.networkInfo.defaultTransactionFeeUrl==null)return r;const{url:s,headers:o}=ke(this.networkInfo.defaultTransactionFeeUrl,this.tools.initOptions),l=t==null?"":`?height=${t}`,i=yield(yield this.fetchCors(`${s}${l}`,{method:"GET",headers:o})).json(),u=G(i);for(const m of n)switch(m.typeUrl){case"/types.MsgDeposit":r=(0,S.add)(r,u.native_outbound_fee_rune);break;case"/types.MsgSend":r=(0,S.add)(r,u.native_tx_fee_rune)}return r})}calculateFee(n){return b(this,null,function*(){const{messages:t,memo:r,networkFeeOption:s}=n;let o=(0,p.coin)("0",this.networkInfo.nativeDenom),l="0",a="0";if(this.networkInfo.defaultTransactionFeeUrl==null){const{queryClient:i}=this.getClients(),{gasInfo:u}=yield i.tx.simulate(t,r,(0,C.encodeSecp256k1Pubkey)(I.YU.parse(this.walletInfo.keys.publicKey)),this.getSequence());if((u==null?void 0:u.gasUsed)==null)throw new Error("simulate didn't return gasUsed ");l=(0,S.ceil)((0,S.mul)(u==null?void 0:u.gasUsed.toString(),"1.5"),0);const{low:m,average:d,high:v}=(0,k.getGasPriceStep)(this.tools.chainData);let g=d;switch(s){case"low":{g=m;break}case"high":{g=v;break}case"custom":throw new Error("Custom fee not supported")}const h=(0,S.ceil)((0,S.mul)(l,g.toString()),0);o=(0,p.coin)(h,this.networkInfo.nativeDenom),a=o.amount}else a=yield this.totalDynamicNetworkFee(t),a=(0,S.mul)(a,"1.01");return{gasFeeCoin:o,gasLimit:l,networkFee:a}})}startEngine(){return b(this,null,function*(){this.engineOn=!0,yield this.tools.connectClient(),this.addToLoop("queryBalance",Ze).catch(()=>{}),this.addToLoop("queryBlockheight",Ze).catch(()=>{}),this.addToLoop("queryTransactions",Ln).catch(()=>{}),yield ze(ge.prototype,this,"startEngine").call(this)})}killEngine(){return b(this,null,function*(){yield this.tools.disconnectClient(),yield ze(ge.prototype,this,"killEngine").call(this)})}resyncBlockchain(){return b(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}validateTransfer(n,t,r){return b(this,null,function*(){var s;if(t==null)return;const o=this.allTokensMap[t],l=(0,Y.Oj)(o.networkLocation),a=l==null?void 0:l.contractAddress;if(a==null)throw new Error("Unknown denom");const{queryClient:i}=this.getClients();try{yield i.bank.denomMetadata(a);return}catch{const d=(s=(yield i.ibc.transfer.denomTrace(a)).denomTrace)==null?void 0:s.path.match(/transfer\/channel-\d+/);if(d==null||`${r.port}/${r.channel}`===d[0])return}throw new Error("Invalid transfer")})}makeSpend(n){return b(this,null,function*(){var t,r;const{edgeSpendInfo:s,currencyCode:o}=this.makeSpendCheck(n),{memos:l=[],networkFeeOption:a,tokenId:i}=s,u=(t=l[0])==null?void 0:t.value;if(s.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{nativeAmount:m,publicAddress:d}=s.spendTargets[0];if(m==null)throw new On.$D;if(d==null)throw new Error("makeSpend Missing publicAddress");const v=i!=null?(r=this.allTokensMap[i].networkLocation)==null?void 0:r.contractAddress:this.networkInfo.nativeDenom;if(v==null)throw new Error("Unknown denom");let g;if(this.networkInfo.bech32AddressPrefix!==(0,M.fromBech32)(d).prefix){const F=ln(this.tools.chainData.chain_name,d);yield this.validateTransfer(d,i,F);const{channel:Ce,port:ee}=F;g=this.tools.methods.ibcTransfer({channel:Ce,port:ee,memo:u,amount:(0,p.coin)(m,v),fromAddress:this.walletInfo.keys.bech32Address,toAddress:d})}else g=this.tools.methods.transfer({amount:[(0,p.coin)(m,v)],fromAddress:this.walletInfo.keys.bech32Address,toAddress:d});let h,T,D;const U=`${d}${String(a)}`,N=this.feeCache.get(U);if(m==="0")h=(0,p.coin)("0",this.networkInfo.nativeDenom),T="0",D="0";else if(N==null){const F=yield this.calculateFee({messages:[g],memo:u,networkFeeOption:a});h=F.gasFeeCoin,T=F.gasLimit,D=F.networkFee,this.feeCache.set(U,F)}else h=N.gasFeeCoin,T=N.gasLimit,D=N.networkFee;const W=this.createUnsignedTxHex([g],u),j={gasFeeCoin:h,gasLimit:T,unsignedTxHex:W},_=this.makeEdgeTransactionAmounts(m,D,i);return this.checkBalances(_,i),{blockHeight:0,currencyCode:o,date:0,isSend:!0,memos:l,nativeAmount:_.nativeAmount,networkFee:_.networkFee,otherParams:j,ourReceiveAddresses:[],parentNetworkFee:_.parentNetworkFee,signedTx:"",tokenId:i,txid:"",walletId:this.walletId}})}signMessage(n,t,r){return b(this,null,function*(){const s=B(this.currencyInfo.pluginId)(t),o=yield this.tools.createSigner(s.mnemonic);if((r==null?void 0:r.otherParams)!=null)switch(r.otherParams.method){case"cosmos_getAccounts":{ue(r.otherParams);const h=(yield o.getAccounts()).map(T=>Ye(me({},T),{pubkey:I.US.stringify(T.pubkey)}));return JSON.stringify(h)}case"cosmos_signDirect":{const g=we(r.otherParams),{signDoc:h}=g.params,T=O.SignDoc.fromPartial({accountNumber:(0,He.longify)(h.accountNumber),authInfoBytes:de(h.authInfoBytes),bodyBytes:de(h.bodyBytes),chainId:h.chainId}),U={signature:(yield o.signDirect(this.walletInfo.keys.bech32Address,T)).signature,signed:g.params.signDoc};return JSON.stringify(U)}case"cosmos_signAmino":{const g=Ae(r.otherParams),{signDoc:h}=g.params,T=(0,C.makeSignDoc)(h.msgs,h.fee,h.chain_id,h.memo,h.account_number,h.sequence),N={signature:(yield(yield C.Secp256k1HdWallet.fromMnemonic(o.mnemonic)).signAmino(this.walletInfo.keys.bech32Address,T)).signature,signed:h};return JSON.stringify(N)}default:throw new Error(`Invalid method: ${r.method}`)}const l=I.YU.parse(n),a=O.SignDoc.decode(l),i=yield o.signDirect(this.walletInfo.keys.bech32Address,a),u=(0,C.decodeSignature)(i.signature),m=O.TxRaw.fromPartial({authInfoBytes:a.authInfoBytes,bodyBytes:a.bodyBytes,signatures:[u.signature]}),d=O.TxRaw.encode(m).finish();return I.YU.stringify(d)})}signTx(n,t){return b(this,null,function*(){const{gasFeeCoin:r,gasLimit:s,unsignedTxHex:o}=le(n.otherParams),l=B(this.currencyInfo.pluginId)(t),a=I.YU.parse(o),{bodyBytes:i}=O.TxRaw.decode(a),u=I.YU.parse(this.walletInfo.keys.publicKey),m=(0,C.encodeSecp256k1Pubkey)(u),d=(0,L.makeAuthInfoBytes)([{pubkey:(0,L.encodePubkey)(m),sequence:this.getSequence()}],[r],parseInt(s),void 0,void 0,1),v=O.SignDoc.fromPartial({accountNumber:(0,He.longify)(this.accountNumber),authInfoBytes:d,bodyBytes:i,chainId:this.tools.chainData.chain_id}),h=yield(yield this.tools.createSigner(l.mnemonic)).signDirect(this.walletInfo.keys.bech32Address,v),T=(0,C.decodeSignature)(h.signature),D=O.TxRaw.fromPartial({authInfoBytes:d,bodyBytes:i,signatures:[T.signature]}),U=O.TxRaw.encode(D).finish(),N=I.YU.stringify(U);return n.signedTx=N,n})}broadcastTx(n){return b(this,null,function*(){try{const t=I.YU.parse(n.signedTx),{stargateClient:r}=this.getClients(),s=yield r.broadcastTxSync(t);return this.warn(`SUCCESS broadcastTx
|
|
2
|
-
${(0,
|
|
1
|
+
(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[8222],{79014:function(Ve,oe,g){"use strict";g.d(oe,{Q:function(){return V},k:function(){return ae}});var G=g(77591),pe=g.n(G),M=g(24350),W=g(84564),S=g.n(W),re=g(76714),H=Object.defineProperty,P=Object.getOwnPropertySymbols,Q=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable,X=(k,T,y)=>T in k?H(k,T,{enumerable:!0,configurable:!0,writable:!0,value:y}):k[T]=y,ie=(k,T)=>{for(var y in T||(T={}))Q.call(T,y)&&X(k,y,T[y]);if(P)for(var y of P(T))se.call(T,y)&&X(k,y,T[y]);return k};function ae(k,T,y,x,v,b=[]){const A=ie({},S()(T,{},!0)),K=T.startsWith(`${k.pluginId}://`);if(A.protocol!=null&&(A.protocol=A.protocol.replace(":","")),A.protocol!=null&&A.protocol!==""&&!y[A.protocol])throw new Error(`Uri protocol '${A.protocol}' is not supported for ${k.pluginId}.`);if(A.host===""&&A.pathname==="")throw new Error("Path and host not found in uri.");const F={publicAddress:A.host!==""?A.host:A.pathname.split("/")[0]},j=A.query.label,ce=A.query.message,_=A.query.category;(j!=null||ce!=null||_!=null||K)&&(F.metadata={},F.metadata.name=j,F.metadata.notes=ce,F.metadata.category=_,F.metadata.gateway=K!=null?K:!1);const q=A.query.amount;if(q!=null&&typeof q=="string"){v==null&&(v=k.currencyCode);const le=(0,re.Qs)(v!=null?v:"",k,b,x);if(le==null)throw new Error("InternalErrorInvalidCurrencyCode");let ee=(0,G.mul)(q,le.multiplier);ee=(0,G.toFixed)(ee,0,0),F.nativeAmount=ee,F.currencyCode=v}return{edgeParsedUri:F,parsedUri:A}}function V(k,T,y){if(k.publicAddress==null)throw new Error("InvalidPublicAddressError");if(y==null&&k.label==null&&k.message==null)return k.publicAddress;{let x="";y!=null&&(x+="amount="+y+"&"),(k.label!=null||k.message!=null)&&(typeof k.label=="string"&&(x+="label="+k.label+"&"),typeof k.message=="string"&&(x+="message="+k.message+"&")),x=x.substr(0,x.length-1);const v={scheme:T,path:k.publicAddress,query:x};return(0,M.qC)(v)}}},20119:function(Ve,oe,g){"use strict";g.r(oe),g.d(oe,{CosmosTools:function(){return He},makeCurrencyEngine:function(){return On},makeCurrencyTools:function(){return Bn}});var G=g(87137),pe=g(79562),M=g(28972),W=g(74087),S=g(77591),re=g(2153),H=g(42150),P=g(79325),Q=g(20918),se=g(79014),X=g(76714),ie=g(98994),ae=g(2387),V=g(39385),k=g(7416),T=g(33359),y=g(24658),x=g(73034),v=g(82448),b=g(43854),A=(e,n,t)=>new Promise((r,s)=>{var o=i=>{try{a(t.next(i))}catch(l){s(l)}},c=i=>{try{a(t.throw(i))}catch(l){s(l)}},a=i=>i.done?r(i.value):Promise.resolve(i.value).then(o,c);a((t=t.apply(e,n)).next())});const K=(e,n)=>{const t=(0,b.j4)(n),r={},s=/{{(.*?)}}/g;for(const[o,c]of Object.entries(e.headers)){const a=s.exec(c);a!=null&&(r[o]=t[a[1]])}return{url:e.url,headers:r}},ve=(e,n)=>{const{url:t,headers:r}=n;return{execute:s=>A(void 0,null,function*(){const o={method:"POST",headers:r,body:JSON.stringify(s)};return yield(yield e(t,o)).json()}),disconnect:()=>{}}},F=e=>A(void 0,null,function*(){const n=yield x.Comet38Client.create(e),t=(yield n.status()).nodeInfo.version;return t.startsWith("0.38.")?n:t.startsWith("0.37.")?yield x.Tendermint37Client.create(e):yield x.Tendermint34Client.create(e)}),j=(e,n)=>A(void 0,null,function*(){const t=yield y.StargateClient.create(yield F(ve(e,n))),r=t.forceGetCometClient();return{queryClient:y.QueryClient.withExtensions(r,y.setupAuthExtension,y.setupBankExtension,y.setupStakingExtension,y.setupTxExtension,y.setupIbcExtension),stargateClient:t,cometClient:r}}),ce=e=>{var n;const[t,...r]=e.split("."),s=e.includes("/"),o=r.join("."),c=(n=o==null?void 0:o.split("-"))==null?void 0:n[0];return{chain:t,symbol:o,ticker:c,synth:s}},_=e=>e.reduce((n,t)=>{try{return(0,T.addCoins)(n,t)}catch{}return n}),q=(0,v.Wf)("amount"),le=(0,v.Wf)("receiver"),ee=(0,v.Wf)("spender"),qe=(0,v.Wf)("amount","receiver","spender"),ze=(0,v.su)({type:(0,v.Wf)("coin_received"),attributes:(0,v.vq)((0,v.su)({key:q,value:v.XC}),(0,v.su)({key:le,value:v.XC}))}),Ye=(0,v.su)({type:(0,v.Wf)("coin_spent"),attributes:(0,v.vq)((0,v.su)({key:q,value:v.XC}),(0,v.su)({key:ee,value:v.XC}))}),Ze=(e,n)=>{const t=new Map;for(const s of e){const o={type:s.type,attributes:s.attributes.filter(i=>(0,v.Vk)(qe)(i.key)!=null).sort((i,l)=>i.key<l.key?-1:1)},c=(0,v.Vk)(ze)(o);if(c!=null){const[i,l]=c.attributes.map(u=>u.value);if(l!==n)continue;ke(i).forEach(u=>{var p;const m=u.amount,d=(p=t.get(u.denom))!=null?p:"0";t.set(u.denom,(0,S.add)(m,d))});continue}const a=(0,v.Vk)(Ye)(o);if(a!=null){const[i,l]=a.attributes.map(u=>u.value);if(l!==n)continue;ke(i).forEach(u=>{var p;const m=`-${u.amount}`,d=(p=t.get(u.denom))!=null?p:"0";t.set(u.denom,(0,S.add)(m,d))})}}const r=[];return t.forEach((s,o)=>{s!=="0"&&r.push({denom:o,amount:s})}),r},ue=e=>{try{return P.YU.parse(e)}catch{return P.US.parse(e)}},ke=e=>e.replace(/\s/g,"").split(",").filter(Boolean).map(n=>{var t;const r=n.match(/^([0-9]+)([a-zA-Z][a-zA-Z0-9/-]{2,127})$/);if(r==null)throw new Error(`Got an invalid coin string: ${e}`);return{amount:(t=r[1].replace(/^0+/,""))!=null?t:"0",denom:r[2]}}),Ge=(e,n)=>{const t=H.chains.find(c=>c.bech32_prefix===(0,M.fromBech32)(n).prefix);if(t==null)throw new Error("Unrecognized denom");const r=t.chain_name,s=(0,k.getIbcInfo)(H.ibc,e,r);if(s==null)throw new Error(`No IBC channels between ${e} and ${r}`);const o=(0,k.getTransferChannel)(s);return e<r?{channel:o.chain_1.channel_id,port:o.chain_1.port_id}:{channel:o.chain_2.channel_id,port:o.chain_2.port_id}};var Qe=g(43720),O=g.n(Qe),Xe=g(62100),h=g.n(Xe);const Un="common";function Te(){return{chain:"",symbol:"",ticker:"",synth:!1}}const z={encode(e,n=h().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 h().Reader?e:h().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=Te();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.chain=t.string();continue;case 2:if(o!==18)break;s.symbol=t.string();continue;case 3:if(o!==26)break;s.ticker=t.string();continue;case 4:if(o!==32)break;s.synth=t.bool();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{chain:E(e.chain)?globalThis.String(e.chain):"",symbol:E(e.symbol)?globalThis.String(e.symbol):"",ticker:E(e.ticker)?globalThis.String(e.ticker):"",synth:E(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 z.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,r,s;const o=Te();return o.chain=(n=e.chain)!=null?n:"",o.symbol=(t=e.symbol)!=null?t:"",o.ticker=(r=e.ticker)!=null?r:"",o.synth=(s=e.synth)!=null?s:!1,o}};function we(){return{asset:void 0,amount:"",decimals:O().ZERO}}const C={encode(e,n=h().Writer.create()){return e.asset!==void 0&&z.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 h().Reader?e:h().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=we();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.asset=z.decode(t,t.uint32());continue;case 2:if(o!==18)break;s.amount=t.string();continue;case 3:if(o!==24)break;s.decimals=t.int64();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{asset:E(e.asset)?z.fromJSON(e.asset):void 0,amount:E(e.amount)?globalThis.String(e.amount):"",decimals:E(e.decimals)?O().fromValue(e.decimals):O().ZERO}},toJSON(e){const n={};return e.asset!==void 0&&(n.asset=z.toJSON(e.asset)),e.amount!==""&&(n.amount=e.amount),e.decimals.isZero()||(n.decimals=(e.decimals||O().ZERO).toString()),n},create(e){return C.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=we();return t.asset=e.asset!==void 0&&e.asset!==null?z.fromPartial(e.asset):void 0,t.amount=(n=e.amount)!=null?n:"",t.decimals=e.decimals!==void 0&&e.decimals!==null?O().fromValue(e.decimals):O().ZERO,t}};function Ae(){return{secp256k1:"",ed25519:""}}const je={encode(e,n=h().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 h().Reader?e:h().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=Ae();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.secp256k1=t.string();continue;case 2:if(o!==18)break;s.ed25519=t.string();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{secp256k1:E(e.secp256k1)?globalThis.String(e.secp256k1):"",ed25519:E(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 je.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const r=Ae();return r.secp256k1=(n=e.secp256k1)!=null?n:"",r.ed25519=(t=e.ed25519)!=null?t:"",r}};function Ce(){return{id:"",chain:"",fromAddress:"",toAddress:"",coins:[],gas:[],memo:""}}const en={encode(e,n=h().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 h().Reader?e:h().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=Ce();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.id=t.string();continue;case 2:if(o!==18)break;s.chain=t.string();continue;case 3:if(o!==26)break;s.fromAddress=t.string();continue;case 4:if(o!==34)break;s.toAddress=t.string();continue;case 5:if(o!==42)break;s.coins.push(C.decode(t,t.uint32()));continue;case 6:if(o!==50)break;s.gas.push(C.decode(t,t.uint32()));continue;case 7:if(o!==58)break;s.memo=t.string();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{id:E(e.id)?globalThis.String(e.id):"",chain:E(e.chain)?globalThis.String(e.chain):"",fromAddress:E(e.fromAddress)?globalThis.String(e.fromAddress):"",toAddress:E(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:E(e.memo)?globalThis.String(e.memo):""}},toJSON(e){var n,t;const r={};return e.id!==""&&(r.id=e.id),e.chain!==""&&(r.chain=e.chain),e.fromAddress!==""&&(r.fromAddress=e.fromAddress),e.toAddress!==""&&(r.toAddress=e.toAddress),(n=e.coins)!=null&&n.length&&(r.coins=e.coins.map(s=>C.toJSON(s))),(t=e.gas)!=null&&t.length&&(r.gas=e.gas.map(s=>C.toJSON(s))),e.memo!==""&&(r.memo=e.memo),r},create(e){return en.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,r,s,o,c,a;const i=Ce();return i.id=(n=e.id)!=null?n:"",i.chain=(t=e.chain)!=null?t:"",i.fromAddress=(r=e.fromAddress)!=null?r:"",i.toAddress=(s=e.toAddress)!=null?s:"",i.coins=((o=e.coins)==null?void 0:o.map(l=>C.fromPartial(l)))||[],i.gas=((c=e.gas)==null?void 0:c.map(l=>C.fromPartial(l)))||[],i.memo=(a=e.memo)!=null?a:"",i}};function be(){return{coins:[],poolDeduct:""}}const nn={encode(e,n=h().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 h().Reader?e:h().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=be();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.coins.push(C.decode(t,t.uint32()));continue;case 2:if(o!==18)break;s.poolDeduct=t.string();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{coins:globalThis.Array.isArray(e==null?void 0:e.coins)?e.coins.map(n=>C.fromJSON(n)):[],poolDeduct:E(e.poolDeduct)?globalThis.String(e.poolDeduct):""}},toJSON(e){var n;const t={};return(n=e.coins)!=null&&n.length&&(t.coins=e.coins.map(r=>C.toJSON(r))),e.poolDeduct!==""&&(t.poolDeduct=e.poolDeduct),t},create(e){return nn.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const r=be();return r.coins=((n=e.coins)==null?void 0:n.map(s=>C.fromPartial(s)))||[],r.poolDeduct=(t=e.poolDeduct)!=null?t:"",r}};function Ie(){return{value:""}}const tn={encode(e,n=h().Writer.create()){return e.value!==""&&n.uint32(10).string(e.value),n},decode(e,n){const t=e instanceof h().Reader?e:h().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=Ie();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.value=t.string();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{value:E(e.value)?globalThis.String(e.value):""}},toJSON(e){const n={};return e.value!==""&&(n.value=e.value),n},create(e){return tn.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=Ie();return t.value=(n=e.value)!=null?n:"",t}};h().util.Long!==O()&&(h().util.Long=O(),h().configure());function E(e){return e!=null}const Nn="types";function Se(){return{coins:[],memo:"",signer:new Uint8Array(0)}}const de={encode(e,n=h().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 h().Reader?e:h().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=Se();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.coins.push(C.decode(t,t.uint32()));continue;case 2:if(o!==18)break;s.memo=t.string();continue;case 3:if(o!==26)break;s.signer=t.bytes();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{coins:globalThis.Array.isArray(e==null?void 0:e.coins)?e.coins.map(n=>C.fromJSON(n)):[],memo:Pe(e.memo)?globalThis.String(e.memo):"",signer:Pe(e.signer)?on(e.signer):new Uint8Array(0)}},toJSON(e){var n;const t={};return(n=e.coins)!=null&&n.length&&(t.coins=e.coins.map(r=>C.toJSON(r))),e.memo!==""&&(t.memo=e.memo),e.signer.length!==0&&(t.signer=rn(e.signer)),t},create(e){return de.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,r;const s=Se();return s.coins=((n=e.coins)==null?void 0:n.map(o=>C.fromPartial(o)))||[],s.memo=(t=e.memo)!=null?t:"",s.signer=(r=e.signer)!=null?r:new Uint8Array(0),s}};function on(e){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(e,"base64"));{const n=globalThis.atob(e),t=new Uint8Array(n.length);for(let r=0;r<n.length;++r)t[r]=n.charCodeAt(r);return t}}function rn(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(""))}}h().util.Long!==O()&&(h().util.Long=O(),h().configure());function Pe(e){return e!=null}const Rn="cosmos.base.v1beta1";function Ee(){return{denom:"",amount:""}}const Y={encode(e,n=h().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 h().Reader?e:h().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=Ee();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.denom=t.string();continue;case 2:if(o!==18)break;s.amount=t.string();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{denom:Z(e.denom)?globalThis.String(e.denom):"",amount:Z(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 Y.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const r=Ee();return r.denom=(n=e.denom)!=null?n:"",r.amount=(t=e.amount)!=null?t:"",r}};function xe(){return{denom:"",amount:""}}const sn={encode(e,n=h().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 h().Reader?e:h().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=xe();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.denom=t.string();continue;case 2:if(o!==18)break;s.amount=t.string();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{denom:Z(e.denom)?globalThis.String(e.denom):"",amount:Z(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 sn.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const r=xe();return r.denom=(n=e.denom)!=null?n:"",r.amount=(t=e.amount)!=null?t:"",r}};function Oe(){return{int:""}}const an={encode(e,n=h().Writer.create()){return e.int!==""&&n.uint32(10).string(e.int),n},decode(e,n){const t=e instanceof h().Reader?e:h().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=Oe();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.int=t.string();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{int:Z(e.int)?globalThis.String(e.int):""}},toJSON(e){const n={};return e.int!==""&&(n.int=e.int),n},create(e){return an.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=Oe();return t.int=(n=e.int)!=null?n:"",t}};function De(){return{dec:""}}const cn={encode(e,n=h().Writer.create()){return e.dec!==""&&n.uint32(10).string(e.dec),n},decode(e,n){const t=e instanceof h().Reader?e:h().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=De();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.dec=t.string();continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{dec:Z(e.dec)?globalThis.String(e.dec):""}},toJSON(e){const n={};return e.dec!==""&&(n.dec=e.dec),n},create(e){return cn.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=De();return t.dec=(n=e.dec)!=null?n:"",t}};h().util.Long!==O()&&(h().util.Long=O(),h().configure());function Z(e){return e!=null}const Mn="types";function Be(){return{fromAddress:new Uint8Array(0),toAddress:new Uint8Array(0),amount:[]}}const he={encode(e,n=h().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)Y.encode(t,n.uint32(26).fork()).ldelim();return n},decode(e,n){const t=e instanceof h().Reader?e:h().Reader.create(e);let r=n===void 0?t.len:t.pos+n;const s=Be();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.fromAddress=t.bytes();continue;case 2:if(o!==18)break;s.toAddress=t.bytes();continue;case 3:if(o!==26)break;s.amount.push(Y.decode(t,t.uint32()));continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{fromAddress:Re(e.fromAddress)?Ue(e.fromAddress):new Uint8Array(0),toAddress:Re(e.toAddress)?Ue(e.toAddress):new Uint8Array(0),amount:globalThis.Array.isArray(e==null?void 0:e.amount)?e.amount.map(n=>Y.fromJSON(n)):[]}},toJSON(e){var n;const t={};return e.fromAddress.length!==0&&(t.fromAddress=Ne(e.fromAddress)),e.toAddress.length!==0&&(t.toAddress=Ne(e.toAddress)),(n=e.amount)!=null&&n.length&&(t.amount=e.amount.map(r=>Y.toJSON(r))),t},create(e){return he.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,r;const s=Be();return s.fromAddress=(n=e.fromAddress)!=null?n:new Uint8Array(0),s.toAddress=(t=e.toAddress)!=null?t:new Uint8Array(0),s.amount=((r=e.amount)==null?void 0:r.map(o=>Y.fromPartial(o)))||[],s}};function Ue(e){if(globalThis.Buffer)return Uint8Array.from(globalThis.Buffer.from(e,"base64"));{const n=globalThis.atob(e),t=new Uint8Array(n.length);for(let r=0;r<n.length;++r)t[r]=n.charCodeAt(r);return t}}function Ne(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(""))}}h().util.Long!==O()&&(h().util.Long=O(),h().configure());function Re(e){return e!=null}var ln=Object.defineProperty,un=Object.defineProperties,dn=Object.getOwnPropertyDescriptors,Me=Object.getOwnPropertySymbols,hn=Object.prototype.hasOwnProperty,fn=Object.prototype.propertyIsEnumerable,Fe=(e,n,t)=>n in e?ln(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,mn=(e,n)=>{for(var t in n||(n={}))hn.call(n,t)&&Fe(e,t,n[t]);if(Me)for(var t of Me(n))fn.call(n,t)&&Fe(e,t,n[t]);return e},gn=(e,n)=>un(e,dn(n));const yn=1e3*60*60*24,pn=e=>{const n=new W.Registry([["/ibc.applications.transfer.v1.MsgTransfer",V.MsgTransfer],["/cosmwasm.wasm.v1.MsgExecuteContract",ae.$n]]);let t=s=>{const{amount:o,fromAddress:c,toAddress:a}=s;return{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:ie.MsgSend.encode(ie.MsgSend.fromPartial({fromAddress:c,toAddress:a,amount:o})).finish()}};const r=s=>{const{memo:o,toAddress:c,fromAddress:a,channel:i,port:l,amount:f}=s;return{typeUrl:"/ibc.applications.transfer.v1.MsgTransfer",value:V.MsgTransfer.encode(V.MsgTransfer.fromPartial({memo:o,receiver:c,sender:a,sourceChannel:i,sourcePort:l,token:f,timeoutTimestamp:BigInt((Date.now()+yn)*1e6)})).finish()}};switch(e){case"thorchainrune":{const s="/types.MsgDeposit";n.register(s,de);const o=a=>{const{assets:i,memo:l,signer:f}=a,u=i.map(m=>gn(mn({},m),{asset:ce(m.asset)}));return{typeUrl:s,value:de.encode(de.fromPartial({coins:u,memo:l,signer:(0,M.fromBech32)(f).data})).finish()}},c="/types.MsgSend";return n.register(c,he),t=a=>{const{amount:i,fromAddress:l,toAddress:f}=a;return{typeUrl:c,value:he.encode(he.fromPartial({fromAddress:(0,M.fromBech32)(l).data,toAddress:(0,M.fromBech32)(f).data,amount:i})).finish()}},{methods:{deposit:o,ibcTransfer:r,transfer:t},registry:n}}}return{methods:{ibcTransfer:r,transfer:t},registry:n}};var _e=g(45504),D=g(29639),vn=g(94935),kn=g(16757),Tn=Object.defineProperty,wn=Object.defineProperties,An=Object.getOwnPropertyDescriptors,Le=Object.getOwnPropertySymbols,Cn=Object.getPrototypeOf,bn=Object.prototype.hasOwnProperty,In=Object.prototype.propertyIsEnumerable,Sn=Reflect.get,Je=(e,n,t)=>n in e?Tn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,fe=(e,n)=>{for(var t in n||(n={}))bn.call(n,t)&&Je(e,t,n[t]);if(Le)for(var t of Le(n))In.call(n,t)&&Je(e,t,n[t]);return e},We=(e,n)=>wn(e,An(n)),Ke=(e,n,t)=>Sn(Cn(e),t,n),I=(e,n,t)=>new Promise((r,s)=>{var o=i=>{try{a(t.next(i))}catch(l){s(l)}},c=i=>{try{a(t.throw(i))}catch(l){s(l)}},a=i=>i.done?r(i.value):Promise.resolve(i.value).then(o,c);a((t=t.apply(e,n)).next())});const $e=5e3,Pn=3e3,En=1e3*60*60*24*14,xn=1e3*60*2;class me extends kn.P{constructor(n,t,r,s){super(n,t,r,s),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.stakingSupported=!0,this.otherMethods={getMaxTx:o=>I(this,null,function*(){switch(o.type){case"MakeTxDeposit":{if(this.tools.methods.deposit==null)throw new Error(`${this.currencyInfo.displayName} does not support the deposit method`);const{assets:c,memo:a}=o;if(c.length!==1)throw new Error("Cannot calculate max tx for more than one asset");const i=this.tools.methods.deposit({assets:c,memo:a,signer:this.walletInfo.keys.bech32Address}),{networkFee:l}=yield this.calculateFee({messages:[i],memo:a}),f=this.getBalance({tokenId:null});return(0,S.sub)(f,l)}default:throw new Error(`Invalid type: ${o.type}`)}}),makeTx:o=>I(this,null,function*(){switch(o.type){case"MakeTxDeposit":{if(this.tools.methods.deposit==null)throw new Error(`${this.currencyInfo.displayName} does not support the deposit method`);const{assets:c,memo:a,metadata:i}=o,l=this.tools.methods.deposit({assets:c,memo:a,signer:this.walletInfo.keys.bech32Address}),f=this.createUnsignedTxHex([l],a),{gasFeeCoin:u,gasLimit:p,networkFee:m}=yield this.calculateFee({messages:[l],memo:a}),d={gasFeeCoin:u,gasLimit:p,unsignedTxHex:f};return{blockHeight:0,currencyCode:this.currencyInfo.currencyCode,date:Date.now()/1e3,isSend:!0,memos:[],metadata:i,nativeAmount:`-${m}`,networkFee:m,otherParams:d,ourReceiveAddresses:[],signedTx:"",tokenId:null,txid:"",walletId:this.walletId}}default:throw new Error(`Invalid type: ${o.type}`)}}),parseWalletConnectV2Payload:o=>I(this,null,function*(){try{switch(o==null?void 0:o.method){case"cosmos_getAccounts":return{nativeAmount:"0",networkFee:"0",tokenId:null};case"cosmos_signDirect":{const c=(0,b.B)(o),{authInfoBytes:a,bodyBytes:i}=c.params.signDoc,l=D.TxBody.decode(ue(i)),{nativeAmount:f,tokenId:u}=this.getAmountAndTokenIdFromKnownMessageTypes(l.messages),p=D.AuthInfo.decode(ue(a));let m="0";const d=p.fee;return d!=null&&(m=_([(0,y.coin)("0",this.networkInfo.nativeDenom),...d.amount]).amount),{nativeAmount:f,networkFee:m,tokenId:u}}case"cosmos_signAmino":{const c=(0,b.Af)(o),{signDoc:a}=c.params,i=(0,T.makeSignDoc)(a.msgs,a.fee,a.chain_id,a.memo,a.account_number,a.sequence),l=new y.AminoTypes(fe(fe({},y.createBankAminoConverters),y.createIbcAminoConverters)),f=i.msgs.map(w=>l.fromAmino(w)),{nativeAmount:u,tokenId:p}=this.getAmountAndTokenIdFromKnownMessageTypes(f);let m="0";const d=a.fee;return d!=null&&(m=_([(0,y.coin)("0",this.networkInfo.nativeDenom),...d.amount]).amount),{nativeAmount:u,networkFee:m,tokenId:p}}default:throw new Error(`Invalid method: ${o==null?void 0:o.method}`)}}catch(c){throw this.warn("Wallet connect call_request ",c),c}})}}tokenIdFromDenom(n){if(this.networkInfo.nativeDenom===n)return null;const t=Object.keys(this.allTokensMap).find(r=>{var s;return((s=this.allTokensMap[r].networkLocation)==null?void 0:s.contractAddress)===n});if(t===void 0)throw new Error(`Unrecognized denom: ${n}`);return t}getAmountAndTokenIdFromKnownMessageTypes(n){var t;let r=null,s;for(const o of n)switch(o.typeUrl){case"/ibc.applications.transfer.v1.MsgTransfer":{const c=this.tools.registry.decode(o),a=V.MsgTransfer.fromPartial(c);r===void 0&&(r=this.tokenIdFromDenom(a.token.denom));const i=(0,y.coin)(a.token.amount,a.token.denom);s==null?s=i:s=_([s,i]);break}case"/cosmwasm.wasm.v1.MsgExecuteContract":{const c=this.tools.registry.decode(o),a=ae.$n.fromPartial(c),{funds:i}=a;if(i.length>0){const{denom:l}=i[0];r===void 0&&(r=this.tokenIdFromDenom(l));let f=(0,y.coin)("0",l);for(const u of i)f=_([f,u]);s==null?s=f:s=_([s,f])}break}default:}return{nativeAmount:(t=s==null?void 0:s.amount)!=null?t:"0",tokenId:r}}setOtherData(n){this.otherData=(0,b.I_)(n)}getClients(){if(this.tools.clients==null)throw new Error("No StargateClient");return this.tools.clients}queryBalance(){return I(this,null,function*(){var n;try{const{stargateClient:t}=this.getClients(),r=yield t.getAllBalances(this.walletInfo.keys.bech32Address),s=r.find(i=>i.denom===this.networkInfo.nativeDenom);this.updateBalance(this.currencyInfo.currencyCode,(n=s==null?void 0:s.amount)!=null?n:"0");const o=[];if(Object.keys(this.allTokensMap).forEach(i=>{var l;const f=this.allTokensMap[i],u=r.find(m=>{var d;return m.denom===((d=f.networkLocation)==null?void 0:d.contractAddress)}),p=(l=u==null?void 0:u.amount)!=null?l:"0";this.updateBalance(f.currencyCode,p),(0,S.gt)(p,"0")&&!this.enabledTokenIds.includes(i)&&o.push(i)}),o.length>0&&this.currencyEngineCallbacks.onNewTokens(o),this.stakingSupported)try{const i=yield t.getBalanceStaked(this.walletInfo.keys.bech32Address);if(i!=null&&this.stakedBalanceCache!==i.amount){const l={stakedAmounts:[{nativeAmount:i.amount}]};this.currencyEngineCallbacks.onStakingStatusChanged(l),this.stakedBalanceCache=i.amount}}catch(i){if(String(i).includes("unknown query path"))this.stakingSupported=!1;else throw i}const{accountNumber:c,sequence:a}=yield t.getSequence(this.walletInfo.keys.bech32Address);this.accountNumber=c,this.sequence=a}catch(t){String(t).includes("does not exist on chain")?this.updateBalance(this.currencyInfo.currencyCode,"0"):this.log.warn("queryBalance error:",t)}})}queryBlockheight(){return I(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 I(this,null,function*(){let n=0;const t=[this.currencyInfo.currencyCode,...this.enabledTokenIds.map(s=>this.allTokensMap[s].currencyCode)],r=Date.now()-En>this.otherData.archivedTxLastCheckTime?yield j(this.fetchCors,K(this.networkInfo.archiveNode,this.tools.initOptions)):this.getClients();for(const s of b.sn){const o=yield this.queryTransactionsInner(s,r);o!=null&&this.otherData[s]!==o&&(this.otherData[s]=o,this.walletLocalDataDirty=!0),n+=.5,t.forEach(c=>this.tokenCheckTransactionsStatus[c]=n),this.updateOnAddressesChecked()}this.otherData.archivedTxLastCheckTime=Date.now(),this.transactionsChangedArray.length>0&&(this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[])})}queryTransactionsInner(n,t){return I(this,null,function*(){const r={query:`${n}='${this.walletInfo.keys.bech32Address}'`,per_page:50,order_by:"desc"};let s,o=0,c,a=0,i=!1;try{do{const l=yield t.cometClient.txSearch(We(fe({},r),{page:++o})),{totalCount:f,txs:u}=l;c==null&&(c=f),a=a+u.length;for(const p of u){const m=(0,M.toHex)(p.hash).toUpperCase();if(this.removeFromUnconfirmedCache(m),s==null&&(s=m),m===this.otherData[n]){i=!0;break}const d=p.result.events.map(y.fromTendermintEvent);let w=[];try{w=Ze(d,this.walletInfo.keys.bech32Address)}catch(te){this.log.warn("reduceCoinEventsForAddress error:",String(te))}if(w.length===0)continue;const B=yield t.stargateClient.getBlock(p.height),U=(0,x.toSeconds)((0,x.fromRfc3339WithNanoseconds)(B.header.time)).seconds,{height:N,tx:$}=p,ne=P.YU.stringify($),{authInfo:{fee:L},body:{memo:ge,messages:J}}=(0,W.decodeTxRaw)($),ye=yield this.totalDynamicNetworkFee(J,B.header.height);w.forEach(te=>{this.processCosmosTransaction(m,U,ne,te,ge,N,ye,L)})}}while(c>a&&!i)}catch(l){throw this.log.warn("queryTransactions error:",l),l}return s})}processCosmosTransaction(n,t,r,s,o,c,a,i){const{amount:l,denom:f}=s,u=this.networkInfo.nativeDenom===f;let p;try{p=this.tokenIdFromDenom(f)}catch{return}const{currencyCode:m}=p==null?this.currencyInfo:this.allTokensMap[p];let d="0";if(i!=null){const{amount:L}=i,ge=_([(0,y.coin)("0",this.networkInfo.nativeDenom),...L]);d=(0,S.add)(d,ge.amount)}const w=(0,S.lt)(l,"0"),B=[];let U=l,N;w?u?(d=(0,S.add)(d,a),U=(0,S.sub)(U,d)):(d="0",N=a!=="0"?a:void 0):(B.push(this.walletInfo.keys.bech32Address),d="0");const $=[];o!==""&&$.push({type:"text",value:o});const ne={blockHeight:c,currencyCode:m,date:t,isSend:w,memos:$,nativeAmount:U,networkFee:d,ourReceiveAddresses:B,parentNetworkFee:N,signedTx:r,tokenId:p,txid:n,walletId:this.walletId};this.addTransaction(m,ne)}createUnsignedTxHex(n,t){const r=D.TxBody.fromPartial({messages:n,memo:t}),s=D.TxBody.encode(r).finish(),o=D.TxRaw.fromPartial({bodyBytes:s});return P.YU.stringify(D.TxRaw.encode(o).finish())}addToUnconfirmedCache(n){const t=new Date(new Date().getTime()+xn);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}totalDynamicNetworkFee(n,t){return I(this,null,function*(){let r="0";if(this.networkInfo.defaultTransactionFeeUrl==null)return r;const{url:s,headers:o}=K(this.networkInfo.defaultTransactionFeeUrl,this.tools.initOptions),c=t==null?"":`?height=${t}`,i=yield(yield this.fetchCors(`${s}${c}`,{method:"GET",headers:o})).json(),l=(0,b.m$)(i);for(const f of n)switch(f.typeUrl){case"/types.MsgDeposit":r=(0,S.add)(r,l.native_outbound_fee_rune);break;case"/types.MsgSend":r=(0,S.add)(r,l.native_tx_fee_rune)}return r})}calculateFee(n){return I(this,null,function*(){const{messages:t,memo:r,networkFeeOption:s}=n;let o=(0,y.coin)("0",this.networkInfo.nativeDenom),c="0",a="0";if(this.networkInfo.defaultTransactionFeeUrl==null){const{queryClient:i}=this.getClients(),{gasInfo:l}=yield i.tx.simulate(t,r,(0,T.encodeSecp256k1Pubkey)(P.YU.parse(this.walletInfo.keys.publicKey)),this.getSequence());if((l==null?void 0:l.gasUsed)==null)throw new Error("simulate didn't return gasUsed ");c=(0,S.ceil)((0,S.mul)(l==null?void 0:l.gasUsed.toString(),"1.5"),0);const{low:f,average:u,high:p}=(0,k.getGasPriceStep)(this.tools.chainData);let m=u;switch(s){case"low":{m=f;break}case"high":{m=p;break}case"custom":throw new Error("Custom fee not supported")}const d=(0,S.ceil)((0,S.mul)(c,m.toString()),0);o=(0,y.coin)(d,this.networkInfo.nativeDenom),a=o.amount}else a=yield this.totalDynamicNetworkFee(t),a=(0,S.mul)(a,"1.01");return{gasFeeCoin:o,gasLimit:c,networkFee:a}})}startEngine(){return I(this,null,function*(){this.engineOn=!0,yield this.tools.connectClient(),this.addToLoop("queryBalance",$e).catch(()=>{}),this.addToLoop("queryBlockheight",$e).catch(()=>{}),this.addToLoop("queryTransactions",Pn).catch(()=>{}),yield Ke(me.prototype,this,"startEngine").call(this)})}killEngine(){return I(this,null,function*(){yield this.tools.disconnectClient(),yield Ke(me.prototype,this,"killEngine").call(this)})}resyncBlockchain(){return I(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}validateTransfer(n,t,r){return I(this,null,function*(){var s;if(t==null)return;const o=this.allTokensMap[t],c=(0,Q.Oj)(o.networkLocation),a=c==null?void 0:c.contractAddress;if(a==null)throw new Error("Unknown denom");const{queryClient:i}=this.getClients();try{yield i.bank.denomMetadata(a);return}catch{const u=(s=(yield i.ibc.transfer.denomTrace(a)).denomTrace)==null?void 0:s.path.match(/transfer\/channel-\d+/);if(u==null||`${r.port}/${r.channel}`===u[0])return}throw new Error("Invalid transfer")})}makeSpend(n){return I(this,null,function*(){var t,r;const{edgeSpendInfo:s,currencyCode:o}=this.makeSpendCheck(n),{memos:c=[],networkFeeOption:a,tokenId:i}=s,l=(t=c[0])==null?void 0:t.value;if(s.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{nativeAmount:f,publicAddress:u}=s.spendTargets[0];if(f==null)throw new vn.$D;if(u==null)throw new Error("makeSpend Missing publicAddress");const p=i!=null?(r=this.allTokensMap[i].networkLocation)==null?void 0:r.contractAddress:this.networkInfo.nativeDenom;if(p==null)throw new Error("Unknown denom");let m;if(this.networkInfo.bech32AddressPrefix!==(0,M.fromBech32)(u).prefix){const J=Ge(this.tools.chainData.chain_name,u);yield this.validateTransfer(u,i,J);const{channel:ye,port:te}=J;m=this.tools.methods.ibcTransfer({channel:ye,port:te,memo:l,amount:(0,y.coin)(f,p),fromAddress:this.walletInfo.keys.bech32Address,toAddress:u})}else m=this.tools.methods.transfer({amount:[(0,y.coin)(f,p)],fromAddress:this.walletInfo.keys.bech32Address,toAddress:u});let d,w,B;const U=`${u}${String(a)}`,N=this.feeCache.get(U);if(f==="0")d=(0,y.coin)("0",this.networkInfo.nativeDenom),w="0",B="0";else if(N==null){const J=yield this.calculateFee({messages:[m],memo:l,networkFeeOption:a});d=J.gasFeeCoin,w=J.gasLimit,B=J.networkFee,this.feeCache.set(U,J)}else d=N.gasFeeCoin,w=N.gasLimit,B=N.networkFee;const $=this.createUnsignedTxHex([m],l),ne={gasFeeCoin:d,gasLimit:w,unsignedTxHex:$},L=this.makeEdgeTransactionAmounts(f,B,i);return this.checkBalances(L,i),{blockHeight:0,currencyCode:o,date:0,isSend:!0,memos:c,nativeAmount:L.nativeAmount,networkFee:L.networkFee,otherParams:ne,ourReceiveAddresses:[],parentNetworkFee:L.parentNetworkFee,signedTx:"",tokenId:i,txid:"",walletId:this.walletId}})}signMessage(n,t,r){return I(this,null,function*(){const s=(0,b._E)(this.currencyInfo.pluginId)(t),o=yield this.tools.createSigner(s.mnemonic);if((r==null?void 0:r.otherParams)!=null)switch(r.otherParams.method){case"cosmos_getAccounts":{(0,b.KQ)(r.otherParams);const d=(yield o.getAccounts()).map(w=>We(fe({},w),{pubkey:P.US.stringify(w.pubkey)}));return JSON.stringify(d)}case"cosmos_signDirect":{const m=(0,b.B)(r.otherParams),{signDoc:d}=m.params,w=D.SignDoc.fromPartial({accountNumber:(0,_e.longify)(d.accountNumber),authInfoBytes:ue(d.authInfoBytes),bodyBytes:ue(d.bodyBytes),chainId:d.chainId}),U={signature:(yield o.signDirect(this.walletInfo.keys.bech32Address,w)).signature,signed:m.params.signDoc};return JSON.stringify(U)}case"cosmos_signAmino":{const m=(0,b.Af)(r.otherParams),{signDoc:d}=m.params,w=(0,T.makeSignDoc)(d.msgs,d.fee,d.chain_id,d.memo,d.account_number,d.sequence),N={signature:(yield(yield T.Secp256k1HdWallet.fromMnemonic(o.mnemonic)).signAmino(this.walletInfo.keys.bech32Address,w)).signature,signed:d};return JSON.stringify(N)}default:throw new Error(`Invalid method: ${r.method}`)}const c=P.YU.parse(n),a=D.SignDoc.decode(c),i=yield o.signDirect(this.walletInfo.keys.bech32Address,a),l=(0,T.decodeSignature)(i.signature),f=D.TxRaw.fromPartial({authInfoBytes:a.authInfoBytes,bodyBytes:a.bodyBytes,signatures:[l.signature]}),u=D.TxRaw.encode(f).finish();return P.YU.stringify(u)})}signTx(n,t){return I(this,null,function*(){const{gasFeeCoin:r,gasLimit:s,unsignedTxHex:o}=(0,b.Tr)(n.otherParams),c=(0,b._E)(this.currencyInfo.pluginId)(t),a=P.YU.parse(o),{bodyBytes:i}=D.TxRaw.decode(a),l=P.YU.parse(this.walletInfo.keys.publicKey),f=(0,T.encodeSecp256k1Pubkey)(l),u=(0,W.makeAuthInfoBytes)([{pubkey:(0,W.encodePubkey)(f),sequence:this.getSequence()}],[r],parseInt(s),void 0,void 0,1),p=D.SignDoc.fromPartial({accountNumber:(0,_e.longify)(this.accountNumber),authInfoBytes:u,bodyBytes:i,chainId:this.tools.chainData.chain_id}),d=yield(yield this.tools.createSigner(c.mnemonic)).signDirect(this.walletInfo.keys.bech32Address,p),w=(0,T.decodeSignature)(d.signature),B=D.TxRaw.fromPartial({authInfoBytes:u,bodyBytes:i,signatures:[w.signature]}),U=D.TxRaw.encode(B).finish(),N=P.YU.stringify(U);return n.signedTx=N,n})}broadcastTx(n){return I(this,null,function*(){try{const t=P.YU.parse(n.signedTx),{stargateClient:r}=this.getClients(),s=yield r.broadcastTxSync(t);return this.warn(`SUCCESS broadcastTx
|
|
2
|
+
${(0,X.oX)(n)}`),n.txid=s,n.date=Date.now()/1e3,this.addToUnconfirmedCache(s),n}catch(t){throw this.warn("FAILURE broadcastTx failed: ",t),t}})}getFreshAddress(n){return I(this,null,function*(){const{bech32Address:t}=this.walletInfo.keys;return{publicAddress:t}})}}function On(e,n,t,r){return I(this,null,function*(){const s=(0,b.zh)(t),o=new me(e,n,s,r);return yield o.loadEngine(),o})}var Dn=g(48764).Buffer,R=(e,n,t)=>new Promise((r,s)=>{var o=i=>{try{a(t.next(i))}catch(l){s(l)}},c=i=>{try{a(t.throw(i))}catch(l){s(l)}},a=i=>i.done?r(i.value):Promise.resolve(i.value).then(o,c);a((t=t.apply(e,n)).next())});class He{constructor(n){const{builtinTokens:t,currencyInfo:r,initOptions:s,io:o,networkInfo:c}=n;this.io=o,this.currencyInfo=r,this.builtinTokens=t,this.networkInfo=c,this.initOptions=s,this.clientCount=0;const{methods:a,registry:i}=pn(r.pluginId);this.methods=a,this.registry=i;const{chainId:l,url:f}=this.networkInfo.chainInfo,u=H.chains.find(m=>m.chain_id===l&&m.network_type==="mainnet");if(u==null)throw new Error("Unknown chain");this.chainData=u;const p=new G.ChainRegistryFetcher;p.fetch(f).then(()=>{this.chainData=p.getChain(this.chainData.chain_name)}).catch(m=>{})}createSigner(n){return R(this,null,function*(){const{bech32AddressPrefix:t,bip39Path:r}=this.networkInfo,s=(0,pe.stringToPath)(r);return yield W.DirectSecp256k1HdWallet.fromMnemonic(n,{hdPaths:[s],prefix:t})})}getDisplayPrivateKey(n){return R(this,null,function*(){const{pluginId:t}=this.currencyInfo;return(0,b._E)(t)(n.keys).mnemonic})}getDisplayPublicKey(n){return R(this,null,function*(){const{keys:t}=(0,b.zh)(n);return t.publicKey})}importPrivateKey(n){return R(this,null,function*(){if(!(0,re.validateMnemonic)(n))throw new Error("Invalid mnemonic");return yield this.createSigner(n),{[this.networkInfo.pluginMnemonicKeyName]:n}})}createPrivateKey(n){return R(this,null,function*(){if(n!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const t=Dn.from(this.io.random(32)),r=(0,re.entropyToMnemonic)(t);return yield this.importPrivateKey(r)})}derivePublicKey(n){return R(this,null,function*(){if(n.type!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const{mnemonic:t}=(0,b._E)(this.currencyInfo.pluginId)(n.keys),s=yield(yield this.createSigner(t)).getAccounts(),{address:o,pubkey:c}=s[0],a=P.YU.stringify(c);return{bech32Address:o,publicKey:a}})}isValidOurAddress(n){try{if((0,M.fromBech32)(n).prefix===this.networkInfo.bech32AddressPrefix)return!0}catch{}return!1}isValidTargetAddress(n){try{const t=(0,M.fromBech32)(n);if(H.chains.find(s=>s.bech32_prefix===t.prefix)!=null)return!0}catch{}return!1}parseUri(n,t,r){return R(this,null,function*(){const{pluginId:s}=this.currencyInfo,o={[s]:!0},{parsedUri:c,edgeParsedUri:a}=(0,se.k)(this.currencyInfo,n,o,this.builtinTokens,t!=null?t:this.currencyInfo.currencyCode,r);let i="";if(a.publicAddress!=null&&(i=a.publicAddress),!this.isValidTargetAddress(i))throw new Error("InvalidPublicAddressError");return a.uniqueIdentifier=c.query.memo,a})}encodeUri(n){return R(this,arguments,function*(t,r=[]){const{pluginId:s}=this.currencyInfo,{nativeAmount:o,currencyCode:c,publicAddress:a}=t;if(!this.isValidOurAddress(a))throw new Error("InvalidPublicAddressError");let i;if(typeof o=="string"){const f=(0,X.Qs)(c!=null?c:this.currencyInfo.currencyCode,this.currencyInfo,r,this.builtinTokens);if(f==null)throw new Error("InternalErrorInvalidCurrencyCode");i=(0,S.div)(o,f.multiplier,18)}return(0,se.Q)(t,s,i)})}connectClient(){return R(this,null,function*(){this.clients==null&&(this.clients=yield j(this.io.fetchCors,K(this.networkInfo.rpcNode,this.initOptions))),++this.clientCount})}disconnectClient(){return R(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 R(this,null,function*(){var t;(0,Q.Rp)(n);const{contractAddress:r}=(t=(0,Q.Oj)(n.networkLocation))!=null?t:{},s=/^ibc\/[0-9A-F]{64}$/,o=/^(?!ibc)[a-z][a-z0-9/]{2,127}/;if(r==null||!s.test(r)&&!o.test(r))throw new Error("ErrorInvalidContractAddress");return r.toLowerCase().replace(/\//g,"")})}}function Bn(e){return R(this,null,function*(){return new He(e)})}},89214:function(){},20131:function(){},16026:function(){},52361:function(){},94616:function(){}}]);
|