edge-currency-accountbased 4.23.0 → 4.24.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/android/src/main/assets/edge-currency-accountbased/4163.chunk.js +3 -3
  3. package/android/src/main/assets/edge-currency-accountbased/597.chunk.js +1 -0
  4. package/android/src/main/assets/edge-currency-accountbased/8330.chunk.js +1 -1
  5. package/android/src/main/assets/edge-currency-accountbased/axelar.chunk.js +2 -2
  6. package/android/src/main/assets/edge-currency-accountbased/cardano.chunk.js +2 -2
  7. package/android/src/main/assets/edge-currency-accountbased/edge-currency-accountbased.js +7 -2
  8. package/android/src/main/assets/edge-currency-accountbased/fio.chunk.js +2 -2
  9. package/android/src/main/assets/edge-currency-accountbased/zcash.chunk.js +3 -3
  10. package/lib/algorand/AlgorandEngine.js +1 -1
  11. package/lib/cardano/CardanoEngine.js +27 -7
  12. package/lib/common/innerPlugin.js +29 -0
  13. package/lib/common/tokenHelpers.js +14 -0
  14. package/lib/common/types.js +30 -2
  15. package/lib/cosmos/CosmosTools.js +1 -1
  16. package/lib/cosmos/cosmosEngines.js +32 -0
  17. package/lib/cosmos/cosmosTypes.js +0 -29
  18. package/lib/cosmos/{CosmosEngine.js → engine/CosmosEngine.js} +44 -136
  19. package/lib/cosmos/engine/ThorchainEngine.js +258 -0
  20. package/lib/cosmos/info/thorchainruneInfo.js +6 -5
  21. package/lib/cosmos/thorchainTypes.js +106 -0
  22. package/lib/ethereum/info/amoyInfo.js +1 -0
  23. package/lib/ethereum/info/arbitrumInfo.js +1 -0
  24. package/lib/ethereum/info/avalancheInfo.js +1 -0
  25. package/lib/ethereum/info/baseInfo.js +1 -0
  26. package/lib/ethereum/info/binancesmartchainInfo.js +1 -0
  27. package/lib/ethereum/info/bobevmInfo.js +1 -0
  28. package/lib/ethereum/info/celoInfo.js +1 -0
  29. package/lib/ethereum/info/ethDevInfo.js +1 -0
  30. package/lib/ethereum/info/ethereumInfo.js +1 -0
  31. package/lib/ethereum/info/ethereumclassicInfo.js +1 -0
  32. package/lib/ethereum/info/ethereumpowInfo.js +1 -0
  33. package/lib/ethereum/info/fantomInfo.js +1 -0
  34. package/lib/ethereum/info/filecoinFevmCalibrationInfo.js +1 -0
  35. package/lib/ethereum/info/filecoinFevmInfo.js +1 -0
  36. package/lib/ethereum/info/holeskyInfo.js +1 -0
  37. package/lib/ethereum/info/optimismInfo.js +1 -0
  38. package/lib/ethereum/info/polygonInfo.js +1 -0
  39. package/lib/ethereum/info/pulsechainInfo.js +1 -0
  40. package/lib/ethereum/info/rskInfo.js +1 -0
  41. package/lib/ethereum/info/sepoliaInfo.js +1 -0
  42. package/lib/ethereum/info/zksyncInfo.js +1 -0
  43. package/lib/fio/FioEngine.js +162 -171
  44. package/lib/fio/fioSchema.js +4 -4
  45. package/lib/piratechain/PiratechainEngine.js +14 -5
  46. package/lib/piratechain/piratechainTypes.js +4 -61
  47. package/lib/react-native.js +7 -2
  48. package/lib/solana/solanaInfo.js +4 -0
  49. package/lib/zcash/ZcashEngine.js +7 -0
  50. package/lib/zcash/ZcashTools.js +4 -6
  51. package/lib/zcash/zcashTypes.js +2 -0
  52. package/package.json +5 -5
  53. package/android/src/main/assets/edge-currency-accountbased/2963.chunk.js +0 -6
package/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 4.24.1 (2024-09-10)
6
+
7
+ - fixed: (ADA) Correctly parse txid after broadcasting a transaction
8
+ - fixed: (ADA) Fixed metadata for staking transactions
9
+
10
+ ## 4.24.0 (2024-09-05)
11
+
12
+ - added: (Ethereum/Solana) Support additional tokens provided by info server
13
+ - added: (Thorchain) Add Midgard API for transaction queries
14
+ - changed: (Thorchain) Move most Thorchain-specific functionality out of CosmosEngine and into to ThorchainEngine subclass
15
+ - fixed: (ADA) Update tx_info request to include inputs in order to fix all transactions show as receive bug
16
+
5
17
  ## 4.23.0 (2024-09-03)
6
18
 
7
19
  - added: (ADA) `isStakeTx` to `EdgeTransaction.otherParams` for staking transaction signing
@@ -16,6 +28,8 @@
16
28
  ## 4.21.0 (2024-08-29)
17
29
 
18
30
  - added: POL token on Ethereum.
31
+ - added: (Zcash/Piratechain) Log errors thrown by synchronizer
32
+ - added: (Zcash/Piratechain) Restart engine after receiving critical error
19
33
  - changed: Rename MATIC to POL on the Polygon chain.
20
34
  - fixed: Display name COMBO (Ethereum) to Furucombo
21
35
  - fixed: Calculate Arbitrum fees more correctly.
@@ -1,6 +1,6 @@
1
- (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[4163],{62351:function(U,H,y){"use strict";y.d(H,{Nn:function(){return I},Nt:function(){return P},fi:function(){return B},zp:function(){return O}});var f=y(44276),C=(p,u,d)=>new Promise((w,v)=>{var T=g=>{try{S(d.next(g))}catch(k){v(k)}},b=g=>{try{S(d.throw(g))}catch(k){v(k)}},S=g=>g.done?w(g.value):Promise.resolve(g.value).then(T,b);S((d=d.apply(p,u)).next())});const x=["https://info1.edge.app","https://info2.edge.app"];function N(p,u,d){return C(this,arguments,function*(w,v,T,b=5e3,S=fetch){const g=w.map(k=>()=>C(this,null,function*(){const E=yield S(k+"/"+v,T);if(typeof E!="object"){const l=`Invalid return value ${v} in ${k}`;throw console.log(l),new Error(l)}return E}));return yield(0,f.NN)(g,b)})}function O(p,u,d,w,v=5e3,T){return C(this,null,function*(){const b=yield N((0,f.R3)(u),d,w,v,T);if(!b.ok){const k=yield b.text();throw console.error(k),new Error(`Error fetching ${d}: ${k}`)}const S=yield b.json();return p(S)})}function z(p,u,d,w=5e3,v){return C(this,null,function*(){return yield N((0,f.R3)(p),u,d,w,v)})}const I=(p,u,d,w)=>C(void 0,null,function*(){return yield z(x,p,u,d,w)}),P=p=>Object.keys(p).map(u=>{const d=p[u];return d==null?u:`${u}=${encodeURIComponent(d)}`}).join("&"),B=(p,u=5e3)=>p+Math.random()*u*2-u},99649:function(U,H,y){"use strict";y.r(H),y.d(H,{PiratechainTools:function(){return L},makeCurrencyEngine:function(){return K},makeCurrencyTools:function(){return V},updateInfoPayload:function(){return W}});var f=y(66001),C=y(90749),x=y(48287),N=y(36856),O=y(96542),z=y(44276),I=y(62071),P=y(82671),B=y(65828),p=y(26277),u=y(62351),d=Object.defineProperty,w=Object.getOwnPropertySymbols,v=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable,S=Reflect.get,g=(s,t,e)=>t in s?d(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,k=(s,t)=>{for(var e in t||(t={}))T.call(t,e)&&g(s,e,t[e]);if(w)for(var e of w(t))b.call(t,e)&&g(s,e,t[e]);return s},E=(s,t,e)=>S(v(s),e,t),l=(s,t,e)=>new Promise((n,r)=>{var o=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(o,i);c((e=e.apply(s,t)).next())});const R=(0,u.fi)(3e4);class D extends p.k{constructor(t,e,n,r,o){super(t,e,n,r);const{networkInfo:i}=t;this.pluginId=this.currencyInfo.pluginId,this.networkInfo=i,this.makeSynchronizer=o,this.queryMutex=!1,this.started=!1,this.progressRatio=0}setOtherData(t){this.otherData=(0,I.Gb)(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=>l(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=>l(this,null,function*(){this.synchronizerStatus=t.name,yield this.queryAll()})))}queryAll(){return l(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,o=e*.8;this.tokenCheckBalanceStatus[this.currencyInfo.currencyCode]=r/100,this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=o/100;const i=(r+o)/2;i>this.progressRatio&&(this.progressRatio=i,this.log.warn(`Scan and download progress: ${Math.floor(i)}%`),this.updateOnAddressesChecked())}}bumpSynchronizer(){return l(this,null,function*(){var t;this.isSynced()||this.lastUpdateFromSynchronizer==null||Date.now()<this.lastUpdateFromSynchronizer+R||(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 l(this,null,function*(){this.engineOn=!0,this.started=!0,this.addToLoop("bumpSynchronizer",R).catch(()=>{}),yield E(D.prototype,this,"startEngine").call(this)})}isSynced(){return this.synchronizerStatus==="SYNCED"}queryBalance(){return l(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 l(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,f.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})),o={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,o)}syncNetwork(t){return l(this,null,function*(){if(!this.started)return 1e3;const e=(0,I.cl)(this.currencyInfo.pluginId)(t==null?void 0:t.privateKeys),{rpcNode:n}=this.networkInfo;this.initializer=k({mnemonicSeed:e.mnemonic,birthdayHeight:e.birthdayHeight,alias:B.xn.stringify(B.K3.parse(this.walletId))},n);try{this.synchronizer=yield this.makeSynchronizer(this.initializer)}catch(r){if(String(r)==="Invariant Violation: `new NativeEventEmitter()` requires a non-null argument.")this.log.warn("SDK not present");else throw r}return this.initData(),this.initSubscriptions(),yield new Promise(r=>{this.stopSyncing=r})})}killEngine(){return l(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 E(D.prototype,this,"killEngine").call(this)})}clearBlockchainCache(){return l(this,null,function*(){yield E(D.prototype,this,"clearBlockchainCache").call(this)})}resyncBlockchain(){return l(this,null,function*(){var t;yield E(D.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 l(this,null,function*(){const t=(0,f.sub)(this.availableZatoshi,this.networkInfo.defaultNetworkFee);if((0,f.lte)(t,"0"))throw new P.k5({tokenId:null});return t})}makeSpend(t){return l(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:o=[],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 P.ef;if((0,f.eq)(h,"0"))throw new P.ef;const A=(0,f.add)(h,this.networkInfo.defaultNetworkFee);if((0,f.gt)(A,(e=this.walletLocalData.totalBalances[this.currencyInfo.currencyCode])!=null?e:"0"))throw new P.k5({tokenId:i});if((0,f.gt)(A,this.availableZatoshi))throw new P.k5({tokenId:i});const Z=(0,f.mul)(A,"-1");return{blockHeight:0,currencyCode:r,date:0,isSend:!0,memos:o,nativeAmount:Z,networkFee:this.networkInfo.defaultNetworkFee,ourReceiveAddresses:[],signedTx:"",tokenId:i,txid:"",walletId:this.walletId}})}signTx(t){return l(this,null,function*(){return t})}broadcastTx(t,e){return l(this,null,function*(){var n;if(this.synchronizer==null)throw new Error("Synchronizer undefined");const{memos:r}=t,o=(0,I.cl)(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,f.sub)((0,f.abs)(t.nativeAmount),t.networkFee),toAddress:c.publicAddress,memo:i,fromAccountIndex:0,mnemonicSeed:o.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,z.T5)(t)}`)}catch(h){throw this.warn("FAILURE broadcastTx failed: ",h),h}return t})}getFreshAddress(){return l(this,null,function*(){const t=()=>l(this,null,function*(){if(this.synchronizer==null)throw new Error("Synchronizer undefined");const{saplingAddress:e}=yield this.synchronizer.deriveUnifiedAddress();return this.otherData.cachedAddress=e,this.walletLocalDataDirty=!0,{publicAddress:e}});return this.otherData.cachedAddress==null?yield t():(t().catch(e=>{throw e}),{publicAddress:this.otherData.cachedAddress})})}}function K(s,t,e,n){return l(this,null,function*(){const r=(0,I.xH)(e),{makeSynchronizer:o}=s.nativeIo["edge-currency-accountbased"].piratechain,i=new D(s,t,r,n,o);return yield i.loadEngine(),i})}var F=Object.getOwnPropertySymbols,M=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,j=(s,t)=>{var e={};for(var n in s)M.call(s,n)&&t.indexOf(n)<0&&(e[n]=s[n]);if(s!=null&&F)for(var n of F(s))t.indexOf(n)<0&&$.call(s,n)&&(e[n]=s[n]);return e},m=(s,t,e)=>new Promise((n,r)=>{var o=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(o,i);c((e=e.apply(s,t)).next())});class L{constructor(t){const{builtinTokens:e,currencyInfo:n,io:r,networkInfo:o}=t;this.builtinTokens=e,this.currencyInfo=n,this.io=r,this.networkInfo=o;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 m(this,null,function*(){const{pluginId:e}=this.currencyInfo,n=(0,I.cl)(e)(t.keys);return`Seed Phrase:
1
+ (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[4163],{62351:function(L,H,y){"use strict";y.d(H,{Nn:function(){return I},Nt:function(){return P},fi:function(){return B},zp:function(){return O}});var f=y(44276),C=(p,u,d)=>new Promise((w,v)=>{var E=g=>{try{S(d.next(g))}catch(k){v(k)}},b=g=>{try{S(d.throw(g))}catch(k){v(k)}},S=g=>g.done?w(g.value):Promise.resolve(g.value).then(E,b);S((d=d.apply(p,u)).next())});const x=["https://info1.edge.app","https://info2.edge.app"];function N(p,u,d){return C(this,arguments,function*(w,v,E,b=5e3,S=fetch){const g=w.map(k=>()=>C(this,null,function*(){const T=yield S(k+"/"+v,E);if(typeof T!="object"){const l=`Invalid return value ${v} in ${k}`;throw console.log(l),new Error(l)}return T}));return yield(0,f.NN)(g,b)})}function O(p,u,d,w,v=5e3,E){return C(this,null,function*(){const b=yield N((0,f.R3)(u),d,w,v,E);if(!b.ok){const k=yield b.text();throw console.error(k),new Error(`Error fetching ${d}: ${k}`)}const S=yield b.json();return p(S)})}function z(p,u,d,w=5e3,v){return C(this,null,function*(){return yield N((0,f.R3)(p),u,d,w,v)})}const I=(p,u,d,w)=>C(void 0,null,function*(){return yield z(x,p,u,d,w)}),P=p=>Object.keys(p).map(u=>{const d=p[u];return d==null?u:`${u}=${encodeURIComponent(d)}`}).join("&"),B=(p,u=5e3)=>p+Math.random()*u*2-u},99649:function(L,H,y){"use strict";y.r(H),y.d(H,{PiratechainTools:function(){return U},makeCurrencyEngine:function(){return K},makeCurrencyTools:function(){return V},updateInfoPayload:function(){return W}});var f=y(66001),C=y(90749),x=y(48287),N=y(36856),O=y(96542),z=y(44276),I=y(62071),P=y(82671),B=y(65828),p=y(26277),u=y(62351),d=Object.defineProperty,w=Object.getOwnPropertySymbols,v=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty,b=Object.prototype.propertyIsEnumerable,S=Reflect.get,g=(s,t,e)=>t in s?d(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,k=(s,t)=>{for(var e in t||(t={}))E.call(t,e)&&g(s,e,t[e]);if(w)for(var e of w(t))b.call(t,e)&&g(s,e,t[e]);return s},T=(s,t,e)=>S(v(s),e,t),l=(s,t,e)=>new Promise((n,r)=>{var o=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(o,i);c((e=e.apply(s,t)).next())});const R=(0,u.fi)(3e4);class D extends p.k{constructor(t,e,n,r,o){super(t,e,n,r);const{networkInfo:i}=t;this.pluginId=this.currencyInfo.pluginId,this.networkInfo=i,this.makeSynchronizer=o,this.queryMutex=!1,this.started=!1,this.progressRatio=0}setOtherData(t){this.otherData=(0,I.Gb)(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=>l(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=>l(this,null,function*(){this.synchronizerStatus=t.name,yield this.queryAll()})),this.synchronizer.on("error",t=>l(this,null,function*(){this.log.warn(`Synchronizer error: ${t.message}`),t.level==="critical"&&(yield this.killEngine(),this.lastUpdateFromSynchronizer=void 0,yield this.startEngine())})))}queryAll(){return l(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,o=e*.8;this.tokenCheckBalanceStatus[this.currencyInfo.currencyCode]=r/100,this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=o/100;const i=(r+o)/2;i>this.progressRatio&&(this.progressRatio=i,this.log.warn(`Scan and download progress: ${Math.floor(i)}%`),this.updateOnAddressesChecked())}}bumpSynchronizer(){return l(this,null,function*(){var t;this.isSynced()||this.lastUpdateFromSynchronizer==null||Date.now()<this.lastUpdateFromSynchronizer+R||(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 l(this,null,function*(){this.engineOn=!0,this.started=!0,this.addToLoop("bumpSynchronizer",R).catch(()=>{}),yield T(D.prototype,this,"startEngine").call(this)})}isSynced(){return this.synchronizerStatus==="SYNCED"}queryBalance(){return l(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 l(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,f.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})),o={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,o)}syncNetwork(t){return l(this,null,function*(){if(!this.started)return 1e3;const e=(0,I.cl)(this.currencyInfo.pluginId)(t==null?void 0:t.privateKeys),{rpcNode:n}=this.networkInfo;this.initializer=k({mnemonicSeed:e.mnemonic,birthdayHeight:e.birthdayHeight,alias:B.xn.stringify(B.K3.parse(this.walletId))},n);try{this.synchronizer=yield this.makeSynchronizer(this.initializer)}catch(r){if(String(r)==="Invariant Violation: `new NativeEventEmitter()` requires a non-null argument.")this.log.warn("SDK not present");else throw r}return this.initData(),this.initSubscriptions(),yield new Promise(r=>{this.stopSyncing=r})})}killEngine(){return l(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 T(D.prototype,this,"killEngine").call(this)})}clearBlockchainCache(){return l(this,null,function*(){yield T(D.prototype,this,"clearBlockchainCache").call(this)})}resyncBlockchain(){return l(this,null,function*(){var t;yield T(D.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 l(this,null,function*(){const t=(0,f.sub)(this.availableZatoshi,this.networkInfo.defaultNetworkFee);if((0,f.lte)(t,"0"))throw new P.k5({tokenId:null});return t})}makeSpend(t){return l(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:o=[],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 P.ef;if((0,f.eq)(h,"0"))throw new P.ef;const A=(0,f.add)(h,this.networkInfo.defaultNetworkFee);if((0,f.gt)(A,(e=this.walletLocalData.totalBalances[this.currencyInfo.currencyCode])!=null?e:"0"))throw new P.k5({tokenId:i});if((0,f.gt)(A,this.availableZatoshi))throw new P.k5({tokenId:i});const Z=(0,f.mul)(A,"-1");return{blockHeight:0,currencyCode:r,date:0,isSend:!0,memos:o,nativeAmount:Z,networkFee:this.networkInfo.defaultNetworkFee,ourReceiveAddresses:[],signedTx:"",tokenId:i,txid:"",walletId:this.walletId}})}signTx(t){return l(this,null,function*(){return t})}broadcastTx(t,e){return l(this,null,function*(){var n;if(this.synchronizer==null)throw new Error("Synchronizer undefined");const{memos:r}=t,o=(0,I.cl)(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,f.sub)((0,f.abs)(t.nativeAmount),t.networkFee),toAddress:c.publicAddress,memo:i,mnemonicSeed:o.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,z.T5)(t)}`)}catch(h){throw this.warn("FAILURE broadcastTx failed: ",h),h}return t})}getFreshAddress(){return l(this,null,function*(){const t=()=>l(this,null,function*(){if(this.synchronizer==null)throw new Error("Synchronizer undefined");const{saplingAddress:e}=yield this.synchronizer.deriveUnifiedAddress();return this.otherData.cachedAddress=e,this.walletLocalDataDirty=!0,{publicAddress:e}});return this.otherData.cachedAddress==null?yield t():(t().catch(e=>{throw e}),{publicAddress:this.otherData.cachedAddress})})}}function K(s,t,e,n){return l(this,null,function*(){const r=(0,I.xH)(e),{makeSynchronizer:o}=s.nativeIo["edge-currency-accountbased"].piratechain,i=new D(s,t,r,n,o);return yield i.loadEngine(),i})}var F=Object.getOwnPropertySymbols,M=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,j=(s,t)=>{var e={};for(var n in s)M.call(s,n)&&t.indexOf(n)<0&&(e[n]=s[n]);if(s!=null&&F)for(var n of F(s))t.indexOf(n)<0&&$.call(s,n)&&(e[n]=s[n]);return e},m=(s,t,e)=>new Promise((n,r)=>{var o=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(o,i);c((e=e.apply(s,t)).next())});class U{constructor(t){const{builtinTokens:e,currencyInfo:n,io:r,networkInfo:o}=t;this.builtinTokens=e,this.currencyInfo=n,this.io=r,this.networkInfo=o;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 m(this,null,function*(){const{pluginId:e}=this.currencyInfo,n=(0,I.cl)(e)(t.keys);return`Seed Phrase:
3
3
  ${n.mnemonic}
4
4
 
5
5
  Birthday Height:
6
- ${n.birthdayHeight}`})}getDisplayPublicKey(t){return m(this,null,function*(){const{keys:e}=(0,I.xH)(t);return e.publicKey})}getNewWalletBirthdayBlockheight(){return m(this,null,function*(){return yield this.nativeTools.getBirthdayHeight(this.networkInfo.rpcNode.defaultHost,this.networkInfo.rpcNode.defaultPort)})}isValidAddress(t){return m(this,null,function*(){return yield this.nativeTools.isValidAddress(t)})}importPrivateKey(t){return m(this,arguments,function*(e,n={}){const{pluginId:r}=this.currencyInfo,o=(0,C.validateMnemonic)(e);if(e.split(" ").length!==24)throw new Error("Mnemonic must be 24 words");if(!o)throw new Error(`Invalid ${this.currencyInfo.currencyCode} mnemonic`);const i=yield this.getNewWalletBirthdayBlockheight();let c=i;const{birthdayHeight:a}=n;if(a!=null){(0,N.ym)(a);const h=parseInt(a);if(h>i)throw new Error("InvalidBirthdayHeight");c=h}return{[`${r}Mnemonic`]:e,[`${r}BirthdayHeight`]:c}})}createPrivateKey(t){return m(this,null,function*(){if(t!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const e=x.Buffer.from(this.io.random(32)).toString("hex"),n=(0,C.entropyToMnemonic)(e);return yield this.importPrivateKey(n)})}checkPublicKey(t){return m(this,null,function*(){try{return(0,I.QC)(t).publicKey.length>0}catch{return!1}})}derivePublicKey(t){return m(this,null,function*(){const{pluginId:e}=this.currencyInfo,n=(0,I.cl)(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 o=yield this.nativeTools.deriveViewingKey(r,this.networkInfo.rpcNode.networkName);return{birthdayHeight:n.birthdayHeight,publicKey:o}})}parseUri(t,e,n){return m(this,null,function*(){const{pluginId:r}=this.currencyInfo,o={[r]:!0},{edgeParsedUri:i,edgeParsedUri:{publicAddress:c}}=yield(0,O.x)({currencyInfo:this.currencyInfo,uri:t,networks:o,builtinTokens:this.builtinTokens,currencyCode:e!=null?e:this.currencyInfo.currencyCode,customTokens:n});if(c==null||!(yield this.isValidAddress(c)))throw new Error("InvalidPublicAddressError");return i})}encodeUri(t){return m(this,arguments,function*(e,n=[]){const{pluginId:r}=this.currencyInfo,{nativeAmount:o,currencyCode:i,publicAddress:c}=e;if(!(yield this.isValidAddress(c)))throw new Error("InvalidPublicAddressError");let a;if(o!=null){const A=(0,z.FQ)(i!=null?i:this.currencyInfo.currencyCode,this.currencyInfo,n,this.builtinTokens);if(A==null)throw new Error("InternalErrorInvalidCurrencyCode");a=(0,f.div)(o,A.multiplier,18)}return(0,O.m)(e,`${r}`,a)})}}function V(s){return m(this,null,function*(){return new L(s)})}function W(s,t){return m(this,null,function*(){const e=j(t,[]);s.networkInfo=(0,z.wy)(s.networkInfo,e)})}},15340:function(){},79838:function(){}}]);
6
+ ${n.birthdayHeight}`})}getDisplayPublicKey(t){return m(this,null,function*(){const{keys:e}=(0,I.xH)(t);return e.publicKey})}getNewWalletBirthdayBlockheight(){return m(this,null,function*(){return yield this.nativeTools.getBirthdayHeight(this.networkInfo.rpcNode.defaultHost,this.networkInfo.rpcNode.defaultPort)})}isValidAddress(t){return m(this,null,function*(){return yield this.nativeTools.isValidAddress(t)})}importPrivateKey(t){return m(this,arguments,function*(e,n={}){const{pluginId:r}=this.currencyInfo,o=(0,C.validateMnemonic)(e);if(e.split(" ").length!==24)throw new Error("Mnemonic must be 24 words");if(!o)throw new Error(`Invalid ${this.currencyInfo.currencyCode} mnemonic`);const i=yield this.getNewWalletBirthdayBlockheight();let c=i;const{birthdayHeight:a}=n;if(a!=null){(0,N.ym)(a);const h=parseInt(a);if(h>i)throw new Error("InvalidBirthdayHeight");c=h}return{[`${r}Mnemonic`]:e,[`${r}BirthdayHeight`]:c}})}createPrivateKey(t){return m(this,null,function*(){if(t!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const e=x.Buffer.from(this.io.random(32)).toString("hex"),n=(0,C.entropyToMnemonic)(e);return yield this.importPrivateKey(n)})}checkPublicKey(t){return m(this,null,function*(){try{return(0,I.QC)(t).publicKey.length>0}catch{return!1}})}derivePublicKey(t){return m(this,null,function*(){const{pluginId:e}=this.currencyInfo,n=(0,I.cl)(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 o=yield this.nativeTools.deriveViewingKey(r,this.networkInfo.rpcNode.networkName);return{birthdayHeight:n.birthdayHeight,publicKey:o}})}parseUri(t,e,n){return m(this,null,function*(){const{pluginId:r}=this.currencyInfo,o={[r]:!0},{edgeParsedUri:i,edgeParsedUri:{publicAddress:c}}=yield(0,O.x)({currencyInfo:this.currencyInfo,uri:t,networks:o,builtinTokens:this.builtinTokens,currencyCode:e!=null?e:this.currencyInfo.currencyCode,customTokens:n});if(c==null||!(yield this.isValidAddress(c)))throw new Error("InvalidPublicAddressError");return i})}encodeUri(t){return m(this,arguments,function*(e,n=[]){const{pluginId:r}=this.currencyInfo,{nativeAmount:o,currencyCode:i,publicAddress:c}=e;if(!(yield this.isValidAddress(c)))throw new Error("InvalidPublicAddressError");let a;if(o!=null){const A=(0,z.FQ)(i!=null?i:this.currencyInfo.currencyCode,this.currencyInfo,n,this.builtinTokens);if(A==null)throw new Error("InternalErrorInvalidCurrencyCode");a=(0,f.div)(o,A.multiplier,18)}return(0,O.m)(e,`${r}`,a)})}}function V(s){return m(this,null,function*(){return new U(s)})}function W(s,t){return m(this,null,function*(){const e=j(t,[]);s.networkInfo=(0,z.wy)(s.networkInfo,e)})}},15340:function(){},79838:function(){}}]);
@@ -0,0 +1 @@
1
+ "use strict";(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[597],{93689:function(fe,o,v){var a;a={value:!0};var e=v(53662),q=v(99211);const N=e.asCodec(w=>q.base16.parse(e.asString(w)),w=>q.base16.stringify(w).toLowerCase()),W=e.asCodec(w=>q.base32.parse(e.asString(w),{loose:!0}),w=>q.base32.stringify(w,{pad:!1})),y=e.asCodec(w=>q.base64.parse(e.asString(w)),w=>q.base64.stringify(w)),L=e.asObject({voucherId:e.asString,activates:e.asDate,created:e.asDate,ip:e.asString,ipDescription:e.asString,deviceDescription:e.asOptional(e.asString)}),p=e.asObject({encryptionType:e.asNumber,data_base64:y,iv_hex:N}),I=e.asObject({salt_hex:N,n:e.asNumber,r:e.asNumber,p:e.asNumber}),D=e.asObject({loginRequest:e.asOptional(e.asObject({appId:e.asString}).withRest),publicKey:y,timeout:e.asOptional(e.asNumber)}).withRest,V=e.asObject({publicKey:y,box:p}),j=e.asArray(y),A=e.asObject({data:e.asUnknown,challengeId:e.asOptional(e.asString),deviceDescription:e.asOptional(e.asString),otp:e.asOptional(e.asString),syncToken:e.asOptional(e.asString),voucherId:e.asOptional(e.asString),voucherAuth:e.asOptional(y),loginId:e.asOptional(y),loginAuth:e.asOptional(y),userId:e.asOptional(y),passwordAuth:e.asOptional(y),pin2Id:e.asOptional(y),pin2Auth:e.asOptional(y),recovery2Id:e.asOptional(y),recovery2Auth:e.asOptional(j),loginIds:e.asOptional(e.asArray(y)),otpResetAuth:e.asOptional(e.asString),did:e.asOptional(e.asString),l1:e.asOptional(y),lp1:e.asOptional(y),lpin1:e.asOptional(y),lra1:e.asOptional(y),recoveryAuth:e.asOptional(y)}),C=e.asObject({results:e.asOptional(e.asUnknown),status_code:e.asNumber,message:e.asString}),P=e.asObject({otpTimeout:e.asOptional(e.asNumber,7*24*60*60),otpKey:W}),F=e.asObject({passwordAuth:y,passwordAuthBox:p,passwordAuthSnrp:I,passwordBox:p,passwordKeySnrp:I}),K=e.asObject({pin2Id:y}),z=e.asObject({pin2Id:e.asOptional(y),pin2Auth:e.asOptional(y),pin2Box:e.asOptional(p),pin2KeyBox:e.asOptional(p),pin2TextBox:p}),f=e.asObject({recovery2Id:y}),u=e.asObject({recovery2Id:y,recovery2Auth:j,recovery2Box:p,recovery2KeyBox:p,question2Box:p}),l=e.asObject({loginAuthBox:p,loginAuth:y}),c=e.asObject({userId:y,userTextBox:p}),O=e.asObject({approvedVouchers:e.asOptional(e.asArray(e.asString)),rejectedVouchers:e.asOptional(e.asArray(e.asString))}),S=e.asObject({keyBoxes:e.asArray(p),newSyncKeys:e.asOptional(e.asArray(e.asString),()=>[])}),m=e.asObject({appId:e.asString,loginId:y,parentBox:e.asOptional(p)}),R=e.asObject({challengeId:e.asString,challengeUri:e.asString}),H=e.asObject({request:D,replies:e.asArray(V)}),re=e.asValue(!0),ie=e.asObject({appId:e.asString,created:e.asDate,loginId:y,syncToken:e.asOptional(e.asString),children:e.asOptional(e.asArray(w=>ie(w))),parentBox:e.asOptional(p),otpKey:e.asOptional(e.asEither(re,W)),otpResetDate:e.asOptional(e.asDate),otpTimeout:e.asOptional(e.asNumber),passwordAuthBox:e.asOptional(p),passwordAuthSnrp:e.asOptional(I),passwordBox:e.asOptional(e.asEither(re,p)),passwordKeySnrp:e.asOptional(I),pin2Box:e.asOptional(e.asEither(re,p)),pin2KeyBox:e.asOptional(p),pin2TextBox:e.asOptional(p),question2Box:e.asOptional(p),recovery2Box:e.asOptional(e.asEither(re,p)),recovery2KeyBox:e.asOptional(p),loginAuthBox:e.asOptional(p),userId:e.asOptional(y),userTextBox:e.asOptional(p),pendingVouchers:e.asOptional(e.asArray(L),()=>[]),keyBoxes:e.asOptional(e.asArray(p)),mnemonicBox:e.asOptional(p),rootKeyBox:e.asOptional(p),syncKeyBox:e.asOptional(p)}),g=e.asArray(e.asObject({loginId:y,otpResetPending:e.asOptional(e.asBoolean,!1),pendingVouchers:e.asOptional(e.asArray(L),()=>[]),recovery2Corrupt:e.asOptional(e.asBoolean,!1)})),ne=e.asObject({login_id:e.asOptional(y),otp_reset_auth:e.asOptional(e.asString),otp_timeout_date:e.asOptional(e.asDate),reason:e.asOptional(e.asValue("ip","otp"),"otp"),voucher_activates:e.asOptional(e.asDate),voucher_auth:e.asOptional(y),voucher_id:e.asOptional(e.asString)}),Re=e.asObject({otpResetDate:e.asDate}),ye=e.asObject({wait_seconds:e.asOptional(e.asNumber)}),_e=e.asObject({question2Box:p}),tr=e.asObject({loginId:y,passwordAuthSnrp:e.asOptional(I),questionBox:e.asOptional(p),questionKeySnrp:e.asOptional(I),recoveryAuthSnrp:e.asOptional(I)}),Or=e.uncleaner(p),br=e.uncleaner(V),de=e.uncleaner(D),Y=e.uncleaner(A),Q=e.uncleaner(C),he=e.uncleaner(P),De=e.uncleaner(F),ar=e.uncleaner(K),or=e.uncleaner(z),te=e.uncleaner(f),sr=e.uncleaner(u),je=e.uncleaner(l),He=e.uncleaner(c),qe=e.uncleaner(O),Cr=e.uncleaner(S),ir=e.uncleaner(m),pe=e.uncleaner(R),J=e.uncleaner(H),cr=e.uncleaner(ie),Sr=e.uncleaner(g),Pr=e.uncleaner(ne),Ir=e.uncleaner(Re),Ar=e.uncleaner(ye),ae=e.uncleaner(_e),ge=e.uncleaner(tr);function Te(w,d="Login requires a CAPTCHA"){if(!(this instanceof Te))throw new TypeError("Class constructor ChallengeError cannot be invoked without 'new'");var h;function b($){return h=new Error($),Object.defineProperty(h,"constructor",{value:Te,configurable:!0,writable:!0}),h}return b(d),h.name="ChallengeError",h.challengeId=w.challengeId,h.challengeUri=w.challengeUri,h}function ve(w="Please send a larger amount"){if(!(this instanceof ve))throw new TypeError("Class constructor DustSpendError cannot be invoked without 'new'");var d;function h(b){return d=new Error(b),Object.defineProperty(d,"constructor",{value:ve,configurable:!0,writable:!0}),d}return h(w),d.name="DustSpendError",d}function Ve(w){if(!(this instanceof Ve))throw new TypeError("Class constructor InsufficientFundsError cannot be invoked without 'new'");var d;function h(ee){return d=new Error(ee),Object.defineProperty(d,"constructor",{value:Ve,configurable:!0,writable:!0}),d}const{tokenId:b=null,networkFee:$}=w!=null?w:{};return h(`Insufficient ${b!=null?b:"funds"}`),d.tokenId=b,d.networkFee=$,d.name="InsufficientFundsError",d}function Ee(w="Cannot reach the network"){if(!(this instanceof Ee))throw new TypeError("Class constructor NetworkError cannot be invoked without 'new'");var d;function h(b){return d=new Error(b),Object.defineProperty(d,"constructor",{value:Ee,configurable:!0,writable:!0}),d}return h(w),d.name="NetworkError",d}function G(w="Unable to create zero-amount transaction."){if(!(this instanceof G))throw new TypeError("Class constructor NoAmountSpecifiedError cannot be invoked without 'new'");var d;function h(b){return d=new Error(b),Object.defineProperty(d,"constructor",{value:G,configurable:!0,writable:!0}),d}return h(w),d.name="NoAmountSpecifiedError",d}function we(w="The application is too old. Please upgrade."){if(!(this instanceof we))throw new TypeError("Class constructor ObsoleteApiError cannot be invoked without 'new'");var d;function h(b){return d=new Error(b),Object.defineProperty(d,"constructor",{value:we,configurable:!0,writable:!0}),d}return h(w),d.name="ObsoleteApiError",d}function ce(w,d="Invalid OTP token"){if(!(this instanceof ce))throw new TypeError("Class constructor OtpError cannot be invoked without 'new'");var h;function b(ee){return h=new Error(ee),Object.defineProperty(h,"constructor",{value:ce,configurable:!0,writable:!0}),h}b(d),h.name="OtpError",h.reason="otp";const $=e.asMaybe(ne)(w);if($!=null)return $.login_id!=null&&(h.loginId=q.base64.stringify($.login_id)),h.resetToken=$.otp_reset_auth,h.reason=$.reason,h.resetDate=$.otp_timeout_date,h.voucherActivates=$.voucher_activates,$.voucher_auth!=null&&(h.voucherAuth=q.base64.stringify($.voucher_auth)),h.voucherId=$.voucher_id,h}function Oe(w,d="Invalid password"){if(!(this instanceof Oe))throw new TypeError("Class constructor PasswordError cannot be invoked without 'new'");var h;function b(ee){return h=new Error(ee),Object.defineProperty(h,"constructor",{value:Oe,configurable:!0,writable:!0}),h}b(d),h.name="PasswordError";const $=e.asMaybe(ye)(w);if($!=null)return h.wait=$.wait_seconds,h}function be(w="Not enough confirmed funds"){if(!(this instanceof be))throw new TypeError("Class constructor PendingFundsError cannot be invoked without 'new'");var d;function h(b){return d=new Error(b),Object.defineProperty(d,"constructor",{value:be,configurable:!0,writable:!0}),d}return h(w),d.name="PendingFundsError",d}function Ce(w="Wallets can not be the same currency"){if(!(this instanceof Ce))throw new TypeError("Class constructor SameCurrencyError cannot be invoked without 'new'");var d;function h(b){return d=new Error(b),Object.defineProperty(d,"constructor",{value:Ce,configurable:!0,writable:!0}),d}return h(w),d.name="SameCurrencyError",d}function $e(w="Spending to self"){if(!(this instanceof $e))throw new TypeError("Class constructor SpendToSelfError cannot be invoked without 'new'");var d;function h(b){return d=new Error(b),Object.defineProperty(d,"constructor",{value:$e,configurable:!0,writable:!0}),d}return h(w),d.name="SpendToSelfError",d}function Ue(w,d,h="from"){if(!(this instanceof Ue))throw new TypeError("Class constructor SwapAboveLimitError cannot be invoked without 'new'");var b;function $(ee){return b=new Error(ee),Object.defineProperty(b,"constructor",{value:Ue,configurable:!0,writable:!0}),b}return $("Amount is too high"),b.name="SwapAboveLimitError",b.pluginId=w.pluginId,b.nativeMax=d,b.direction=h,b}function Ne(w,d,h="from"){if(!(this instanceof Ne))throw new TypeError("Class constructor SwapBelowLimitError cannot be invoked without 'new'");var b;function $(ee){return b=new Error(ee),Object.defineProperty(b,"constructor",{value:Ne,configurable:!0,writable:!0}),b}return $("Amount is too low"),b.name="SwapBelowLimitError",b.pluginId=w.pluginId,b.nativeMin=d,b.direction=h,b}function Se(w,d){if(!(this instanceof Se))throw new TypeError("Class constructor SwapCurrencyError cannot be invoked without 'new'");var h;function b(s){return h=new Error(s),Object.defineProperty(h,"constructor",{value:Se,configurable:!0,writable:!0}),h}const{fromWallet:$,toWallet:ee,fromTokenId:Me,toTokenId:Ie}=d,Tr=$.currencyConfig.currencyInfo.pluginId,r=ee.currencyConfig.currencyInfo.pluginId,n=`${Tr}:${String(Me)}`,t=`${r}:${String(Ie)}`;return b(`${w.displayName} does not support ${n} to ${t}`),h.name="SwapCurrencyError",h.pluginId=w.pluginId,h.fromTokenId=Me!=null?Me:null,h.toTokenId=Ie!=null?Ie:null,h}function Pe(w,d){if(!(this instanceof Pe))throw new TypeError("Class constructor SwapPermissionError cannot be invoked without 'new'");var h;function b($){return h=new Error($),Object.defineProperty(h,"constructor",{value:Pe,configurable:!0,writable:!0}),h}return d!=null?b(d):b("You are not allowed to make this trade"),h.name="SwapPermissionError",h.pluginId=w.pluginId,h.reason=d,h}function Le(w="Invalid username"){if(!(this instanceof Le))throw new TypeError("Class constructor UsernameError cannot be invoked without 'new'");var d;function h(b){return d=new Error(b),Object.defineProperty(d,"constructor",{value:Le,configurable:!0,writable:!0}),d}return h(w),d.name="UsernameError",d}function k(w){return function(h){if(h instanceof Error&&h.name===w)return h}}const ur=k("ChallengeError"),Ke=k("DustSpendError"),ze=k("InsufficientFundsError"),Ge=k("NetworkError"),lr=k("NoAmountSpecifiedError"),Ze=k("ObsoleteApiError"),Xe=k("OtpError"),fr=k("PasswordError"),mr=k("PendingFundsError"),dr=k("SameCurrencyError"),ue=k("SpendToSelfError"),hr=k("SwapAboveLimitError"),Rr=k("SwapBelowLimitError"),We=k("SwapCurrencyError"),pr=k("SwapPermissionError"),_r=k("UsernameError"),Er=e.asObject(p),Fe=e.asObject({loginId:y,voucherAuth:y,voucherId:e.asString,created:e.asDate,activates:e.asDate,status:e.asValue("pending","approved","rejected"),ip:e.asString,ipDescription:e.asString,deviceDescription:e.asOptional(e.asString)}),Ye=e.asObject({appId:e.asString,created:e.asOptional(e.asDate,()=>new Date),loginId:y,children:e.asOptional(e.asArray(w=>Ye(w)),()=>[]),parentBox:e.asOptional(p),parentId:()=>{},otpKey:e.asOptional(W),otpResetAuth:e.asOptional(e.asString),otpResetDate:e.asOptional(e.asDate),otpTimeout:e.asOptional(e.asNumber),passwordAuth:e.asOptional(y),passwordAuthBox:e.asOptional(p),passwordAuthSnrp:e.asOptional(I),passwordBox:e.asOptional(p),passwordKeySnrp:e.asOptional(I),pin2Id:e.asOptional(y),pin2Auth:e.asOptional(y),pin2Box:e.asOptional(p),pin2KeyBox:e.asOptional(p),pin2TextBox:e.asOptional(p),recovery2Id:e.asOptional(y),recovery2Auth:e.asOptional(j),question2Box:e.asOptional(p),recovery2Box:e.asOptional(p),recovery2KeyBox:e.asOptional(p),loginAuth:e.asOptional(y),loginAuthBox:e.asOptional(p),userId:e.asOptional(y),userTextBox:e.asOptional(p),keyBoxes:e.asOptional(e.asArray(p),()=>[]),mnemonicBox:e.asOptional(p),rootKeyBox:e.asOptional(p),syncKeyBox:e.asOptional(p),vouchers:e.asOptional(e.asArray(Fe),()=>[]),pinBox:e.asOptional(p),pinId:e.asOptional(e.asString),pinKeyBox:e.asOptional(p)}),yr=e.uncleaner(Ye),Dr=e.uncleaner(Er);o.WK=Te,o.DE=ve,o.k5=Ve,o.Dr=Ee,o.ef=G,o.GY=we,o.WM=ce,o.Kz=Oe,o.uX=be,o.IK=Ce,o.gw=$e,o.WU=Ue,o.G8=Ne,o.xQ=Se,o.D7=Pe,o.hi=Le,o.zU=N,o.dq=W,o.m$=y,o.MU=R,o.ID=P,o.k0=F,o.D4=K,o.kL=z,o.jx=f,o.A_=u,o.v1=l,o.TL=c,o.Og=O,o.ft=S,o.KU=m,o.ZU=p,o.ye=V,o.Xj=D,o.Rn=Ye,o.bo=L,o.KL=Er,o.rW=I,o.U3=Fe,o.$Y=H,o.EJ=ie,o.XY=A,o.v7=C,o.up=ur,o.h=Ke,o.Cx=ze,o.Zz=Ge,o.CU=lr,o.ib=Ze,o.eT=Xe,o._0=fr,o.UR=mr,o.Up=dr,o.y0=ue,o.A2=hr,o.ql=Rr,o.FX=We,o.Jr=pr,o.zS=_r,o.pK=g,o.ud=ne,o.Zk=Re,o.Mf=ye,o.U0=j,o.CX=_e,o.l4=tr,o.Jv=pe,o.T0=he,o.z8=De,o.Gt=ar,o.Fm=or,o.b4=te,o.N2=sr,o.K8=je,o.gB=He,o.bd=qe,o.GG=Cr,o.V$=ir,o.CC=Or,o.dT=br,o.uT=de,o._j=yr,o.p4=Dr,o.W0=J,o.zk=cr,o.AB=Y,o.sn=Q,o._u=Sr,o.Py=Pr,o.iu=Ir,o.l7=Ar,o.JU=ae,o.O6=ge},73992:function(fe,o){var v=Object.prototype.hasOwnProperty,a;function e(y){try{return decodeURIComponent(y.replace(/\+/g," "))}catch{return null}}function q(y){try{return encodeURIComponent(y)}catch{return null}}function N(y){for(var L=/([^=?&]+)=?([^&]*)/g,p={},I;I=L.exec(y);){var D=e(I[1]),V=e(I[2]);D===null||V===null||D in p||(p[D]=V)}return p}function W(y,L){L=L||"";var p=[],I,D;typeof L!="string"&&(L="?");for(D in y)if(v.call(y,D)){if(I=y[D],!I&&(I===null||I===a||isNaN(I))&&(I=""),D=encodeURIComponent(D),I=encodeURIComponent(I),D===null||I===null)continue;p.push(D+"="+I)}return p.length?L+p.join("&"):""}o.stringify=W,o.parse=N},92063:function(fe){fe.exports=function(v,a){if(a=a.split(":")[0],v=+v,!v)return!1;switch(a){case"http":case"ws":return v!==80;case"https":case"wss":return v!==443;case"ftp":return v!==21;case"gopher":return v!==70;case"file":return!1}return v!==0}},63054:function(fe,o,v){v.d(o,{lK:function(){return J}});function a(...r){if(r.length>1){r[0]=r[0].slice(0,-1);const n=r.length-1;for(let t=1;t<n;++t)r[t]=r[t].slice(1,-1);return r[n]=r[n].slice(1),r.join("")}else return r[0]}function e(r){return"(?:"+r+")"}function q(r){return r===void 0?"undefined":r===null?"null":Object.prototype.toString.call(r).split(" ").pop().split("]").shift().toLowerCase()}function N(r){return r.toUpperCase()}function W(r){return r!=null?r instanceof Array?r:typeof r.length!="number"||r.split||r.setInterval||r.call?[r]:Array.prototype.slice.call(r):[]}function y(r){const n="[A-Za-z]",t="[\\x0D]",s="[0-9]",i="[\\x22]",E=a(s,"[A-Fa-f]"),T="[\\x0A]",x="[\\x20]",U=e(e("%[EFef]"+E+"%"+E+E+"%"+E+E)+"|"+e("%[89A-Fa-f]"+E+"%"+E+E)+"|"+e("%"+E+E)),Z="[\\:\\/\\?\\#\\[\\]\\@]",_="[\\!\\$\\&\\'\\(\\)\\*\\+\\,\\;\\=]",X=a(Z,_),oe=r?"[\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF]":"[]",se=r?"[\\uE000-\\uF8FF]":"[]",B=a(n,s,"[\\-\\.\\_\\~]",oe),Ae=e(n+a(n,s,"[\\+\\-\\.]")+"*"),Qe=e(e(U+"|"+a(B,_,"[\\:]"))+"*"),gr=e(e("25[0-5]")+"|"+e("2[0-4]"+s)+"|"+e("1"+s+s)+"|"+e("[1-9]"+s)+"|"+s),$r=e(gr+"\\."+gr+"\\."+gr+"\\."+gr),M=e(E+"{1,4}"),me=e(e(M+"\\:"+M)+"|"+$r),xr=e(e(M+"\\:")+"{6}"+me),Br=e("\\:\\:"+e(M+"\\:")+"{5}"+me),kr=e(e(M)+"?\\:\\:"+e(M+"\\:")+"{4}"+me),jr=e(e(e(M+"\\:")+"{0,1}"+M)+"?\\:\\:"+e(M+"\\:")+"{3}"+me),Hr=e(e(e(M+"\\:")+"{0,2}"+M)+"?\\:\\:"+e(M+"\\:")+"{2}"+me),qr=e(e(e(M+"\\:")+"{0,3}"+M)+"?\\:\\:"+M+"\\:"+me),Vr=e(e(e(M+"\\:")+"{0,4}"+M)+"?\\:\\:"+me),Kr=e(e(e(M+"\\:")+"{0,5}"+M)+"?\\:\\:"+M),zr=e(e(e(M+"\\:")+"{0,6}"+M)+"?\\:\\:"),Ur=e([xr,Br,kr,jr,Hr,qr,Vr,Kr,zr].join("|")),Gr=e("[vV]"+E+"+\\."+a(B,_,"[\\:]")+"+"),Zr=e("\\["+e(Ur+"|"+Gr)+"\\]"),Nr=e(e(U+"|"+a(B,_))+"*"),Je=e(Zr+"|"+$r+"(?!"+Nr+")|"+Nr),er=e(s+"*"),Lr=e(e(Qe+"@")+"?"+Je+e("\\:"+er)+"?"),rr=e(U+"|"+a(B,_,"[\\:\\@]")),Xr=e(rr+"*"),Fr=e(rr+"+"),Wr=e(e(U+"|"+a(B,_,"[\\@]"))+"+"),le=e(e("\\/"+Xr)+"*"),xe=e("\\/"+e(Fr+le)+"?"),vr=e(Wr+le),wr=e(Fr+le),Be="(?!"+rr+")",en=e(le+"|"+xe+"|"+vr+"|"+wr+"|"+Be),ke=e(e(rr+"|"+a("[\\/\\?]",se))+"*"),nr=e(e(rr+"|[\\/\\?]")+"*"),Mr=e(e("\\/\\/"+Lr+le)+"|"+xe+"|"+wr+"|"+Be),Yr=e(Ae+"\\:"+Mr+e("\\?"+ke)+"?"+e("\\#"+nr)+"?"),Qr=e(e("\\/\\/"+Lr+le)+"|"+xe+"|"+vr+"|"+Be),Jr=e(Qr+e("\\?"+ke)+"?"+e("\\#"+nr)+"?"),rn=e(Yr+"|"+Jr),nn=e(Ae+"\\:"+Mr+e("\\?"+ke)+"?"),tn="^("+Ae+")\\:"+e(e("\\/\\/("+e("("+Qe+")@")+"?("+Je+")"+e("\\:("+er+")")+"?)")+"?("+le+"|"+xe+"|"+wr+"|"+Be+")")+e("\\?("+ke+")")+"?"+e("\\#("+nr+")")+"?$",an="^(){0}"+e(e("\\/\\/("+e("("+Qe+")@")+"?("+Je+")"+e("\\:("+er+")")+"?)")+"?("+le+"|"+xe+"|"+vr+"|"+Be+")")+e("\\?("+ke+")")+"?"+e("\\#("+nr+")")+"?$",on="^("+Ae+")\\:"+e(e("\\/\\/("+e("("+Qe+")@")+"?("+Je+")"+e("\\:("+er+")")+"?)")+"?("+le+"|"+xe+"|"+wr+"|"+Be+")")+e("\\?("+ke+")")+"?$",sn="^"+e("\\#("+nr+")")+"?$",cn="^"+e("("+Qe+")@")+"?("+Je+")"+e("\\:("+er+")")+"?$";return{NOT_SCHEME:new RegExp(a("[^]",n,s,"[\\+\\-\\.]"),"g"),NOT_USERINFO:new RegExp(a("[^\\%\\:]",B,_),"g"),NOT_HOST:new RegExp(a("[^\\%\\[\\]\\:]",B,_),"g"),NOT_PATH:new RegExp(a("[^\\%\\/\\:\\@]",B,_),"g"),NOT_PATH_NOSCHEME:new RegExp(a("[^\\%\\/\\@]",B,_),"g"),NOT_QUERY:new RegExp(a("[^\\%]",B,_,"[\\:\\@\\/\\?]",se),"g"),NOT_FRAGMENT:new RegExp(a("[^\\%]",B,_,"[\\:\\@\\/\\?]"),"g"),ESCAPE:new RegExp(a("[^]",B,_),"g"),UNRESERVED:new RegExp(B,"g"),OTHER_CHARS:new RegExp(a("[^\\%]",B,X),"g"),PCT_ENCODED:new RegExp(U,"g"),IPV6ADDRESS:new RegExp("\\[?("+Ur+")\\]?","g")}}var L=y(!1),p=y(!0);const I=2147483647,D=36,V=1,j=26,A=38,C=700,P=72,F=128,K="-",z=/^xn--/,f=/[^\0-\x7E]/,u=/[\x2E\u3002\uFF0E\uFF61]/g,l={overflow:"Overflow: input needs wider integers to process","not-basic":"Illegal input >= 0x80 (not a basic code point)","invalid-input":"Invalid input"},c=D-V,O=Math.floor,S=String.fromCharCode;function m(r){throw new RangeError(l[r])}function R(r,n){const t=[];let s=r.length;for(;s--;)t[s]=n(r[s]);return t}function H(r,n){const t=r.split("@");let s="";t.length>1&&(s=t[0]+"@",r=t[1]),r=r.replace(u,".");const i=r.split("."),E=R(i,n).join(".");return s+E}function re(r){const n=[];let t=0;const s=r.length;for(;t<s;){const i=r.charCodeAt(t++);if(i>=55296&&i<=56319&&t<s){const E=r.charCodeAt(t++);(E&64512)==56320?n.push(((i&1023)<<10)+(E&1023)+65536):(n.push(i),t--)}else n.push(i)}return n}const ie=r=>String.fromCodePoint(...r),g=function(r){return r-48<10?r-22:r-65<26?r-65:r-97<26?r-97:D},ne=function(r,n){return r+22+75*(r<26)-((n!=0)<<5)},Re=function(r,n,t){let s=0;for(r=t?O(r/C):r>>1,r+=O(r/n);r>c*j>>1;s+=D)r=O(r/c);return O(s+(c+1)*r/(r+A))},ye=function(r){const n=[],t=r.length;let s=0,i=F,E=P,T=r.lastIndexOf(K);T<0&&(T=0);for(let x=0;x<T;++x)r.charCodeAt(x)>=128&&m("not-basic"),n.push(r.charCodeAt(x));for(let x=T>0?T+1:0;x<t;){let U=s;for(let _=1,X=D;;X+=D){x>=t&&m("invalid-input");const oe=g(r.charCodeAt(x++));(oe>=D||oe>O((I-s)/_))&&m("overflow"),s+=oe*_;const se=X<=E?V:X>=E+j?j:X-E;if(oe<se)break;const B=D-se;_>O(I/B)&&m("overflow"),_*=B}const Z=n.length+1;E=Re(s-U,Z,U==0),O(s/Z)>I-i&&m("overflow"),i+=O(s/Z),s%=Z,n.splice(s++,0,i)}return String.fromCodePoint(...n)},_e=function(r){const n=[];r=re(r);let t=r.length,s=F,i=0,E=P;for(const U of r)U<128&&n.push(S(U));let T=n.length,x=T;for(T&&n.push(K);x<t;){let U=I;for(const _ of r)_>=s&&_<U&&(U=_);const Z=x+1;U-s>O((I-i)/Z)&&m("overflow"),i+=(U-s)*Z,s=U;for(const _ of r)if(_<s&&++i>I&&m("overflow"),_==s){let X=i;for(let oe=D;;oe+=D){const se=oe<=E?V:oe>=E+j?j:oe-E;if(X<se)break;const B=X-se,Ae=D-se;n.push(S(ne(se+B%Ae,0))),X=O(B/Ae)}n.push(S(ne(X,0))),E=Re(i,Z,x==T),i=0,++x}++i,++s}return n.join("")};var de={version:"2.1.0",ucs2:{decode:re,encode:ie},decode:ye,encode:_e,toASCII:function(r){return H(r,function(n){return f.test(n)?"xn--"+_e(n):n})},toUnicode:function(r){return H(r,function(n){return z.test(n)?ye(n.slice(4).toLowerCase()):n})}};const Y={};function Q(r){const n=r.charCodeAt(0);let t;return n<16?t="%0"+n.toString(16).toUpperCase():n<128?t="%"+n.toString(16).toUpperCase():n<2048?t="%"+(n>>6|192).toString(16).toUpperCase()+"%"+(n&63|128).toString(16).toUpperCase():t="%"+(n>>12|224).toString(16).toUpperCase()+"%"+(n>>6&63|128).toString(16).toUpperCase()+"%"+(n&63|128).toString(16).toUpperCase(),t}function he(r){let n="",t=0;const s=r.length;for(;t<s;){const i=parseInt(r.substr(t+1,2),16);if(i<128)n+=String.fromCharCode(i),t+=3;else if(i>=194&&i<224){if(s-t>=6){const E=parseInt(r.substr(t+4,2),16);n+=String.fromCharCode((i&31)<<6|E&63)}else n+=r.substr(t,6);t+=6}else if(i>=224){if(s-t>=9){const E=parseInt(r.substr(t+4,2),16),T=parseInt(r.substr(t+7,2),16);n+=String.fromCharCode((i&15)<<12|(E&63)<<6|T&63)}else n+=r.substr(t,9);t+=9}else n+=r.substr(t,3),t+=3}return n}function De(r,n){function t(s){const i=he(s);return i.match(n.UNRESERVED)?i:s}return r.scheme&&(r.scheme=String(r.scheme).replace(n.PCT_ENCODED,t).toLowerCase().replace(n.NOT_SCHEME,"")),r.userinfo!==void 0&&(r.userinfo=String(r.userinfo).replace(n.PCT_ENCODED,t).replace(n.NOT_USERINFO,Q).replace(n.PCT_ENCODED,N)),r.host!==void 0&&(r.host=String(r.host).replace(n.PCT_ENCODED,t).toLowerCase().replace(n.NOT_HOST,Q).replace(n.PCT_ENCODED,N)),r.path!==void 0&&(r.path=String(r.path).replace(n.PCT_ENCODED,t).replace(r.scheme?n.NOT_PATH:n.NOT_PATH_NOSCHEME,Q).replace(n.PCT_ENCODED,N)),r.query!==void 0&&(r.query=String(r.query).replace(n.PCT_ENCODED,t).replace(n.NOT_QUERY,Q).replace(n.PCT_ENCODED,N)),r.fragment!==void 0&&(r.fragment=String(r.fragment).replace(n.PCT_ENCODED,t).replace(n.NOT_FRAGMENT,Q).replace(n.PCT_ENCODED,N)),r}const ar=/^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[\dA-F:.]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i,or="".match(/(){0}/)[1]===void 0;function te(r,n={}){const t={},s=n.iri!==!1?IRI_PROTOCOL:URI_PROTOCOL;n.reference==="suffix"&&(r=(n.scheme?n.scheme+":":"")+"//"+r);const i=r.match(ar);if(i){or?(t.scheme=i[1],t.userinfo=i[3],t.host=i[4],t.port=parseInt(i[5],10),t.path=i[6]||"",t.query=i[7],t.fragment=i[8],isNaN(t.port)&&(t.port=i[5])):(t.scheme=i[1]||void 0,t.userinfo=r.indexOf("@")!==-1?i[3]:void 0,t.host=r.indexOf("//")!==-1?i[4]:void 0,t.port=parseInt(i[5],10),t.path=i[6]||"",t.query=r.indexOf("?")!==-1?i[7]:void 0,t.fragment=r.indexOf("#")!==-1?i[8]:void 0,isNaN(t.port)&&(t.port=r.match(/\/\/(?:.|\n)*\:(?:\/|\?|\#|$)/)?i[4]:void 0)),t.host&&(t.host=t.host.replace(s.IPV6ADDRESS,"$1")),t.scheme===void 0&&t.userinfo===void 0&&t.host===void 0&&t.port===void 0&&!t.path&&t.query===void 0?t.reference="same-document":t.scheme===void 0?t.reference="relative":t.fragment===void 0?t.reference="absolute":t.reference="uri",n.reference&&n.reference!=="suffix"&&n.reference!==t.reference&&(t.error=t.error||"URI is not a "+n.reference+" reference.");const E=Y[(n.scheme||t.scheme||"").toLowerCase()];if(!n.unicodeSupport&&(!E||!E.unicodeSupport)){if(t.host&&(n.domainHost||E&&E.domainHost))try{t.host=punycode.toASCII(t.host.replace(s.PCT_ENCODED,he).toLowerCase())}catch(T){t.error=t.error||"Host's domain name can not be converted to ASCII via punycode: "+T}De(t,URI_PROTOCOL)}else De(t,s);E&&E.parse&&E.parse(t,n)}else t.error=t.error||"URI can not be parsed.";return t}function sr(r,n){const t=n.iri!==!1?p:L,s=[];return r.userinfo!==void 0&&(s.push(r.userinfo),s.push("@")),r.host!==void 0&&s.push(String(r.host).replace(t.IPV6ADDRESS,"[$1]")),typeof r.port=="number"&&(s.push(":"),s.push(r.port.toString(10))),s.length?s.join(""):void 0}const je=/^\.\.?\//,He=/^\/\.(\/|$)/,qe=/^\/\.\.(\/|$)/,Cr=/^\.\.?$/,ir=/^\/?(?:.|\n)*?(?=\/|$)/;function pe(r){const n=[];for(;r.length;)if(r.match(je))r=r.replace(je,"");else if(r.match(He))r=r.replace(He,"/");else if(r.match(qe))r=r.replace(qe,"/"),n.pop();else if(r==="."||r==="..")r="";else{const t=r.match(ir);if(t){const s=t[0];r=r.slice(s.length),n.push(s)}else throw new Error("Unexpected dot segment condition")}return n.join("")}function J(r,n={}){const t=n.iri?p:L,s=[],i=Y[(n.scheme||r.scheme||"").toLowerCase()];if(i&&i.serialize&&i.serialize(r,n),r.host&&!t.IPV6ADDRESS.test(r.host)){if(n.domainHost||i&&i.domainHost)try{r.host=n.iri?de.toUnicode(r.host):de.toASCII(r.host.replace(t.PCT_ENCODED,he).toLowerCase())}catch(T){r.error=r.error||"Host's domain name can not be converted to "+(n.iri?"Unicode":"ASCII")+" via punycode: "+T}}De(r,t),n.reference!=="suffix"&&r.scheme&&(s.push(r.scheme),s.push(":"));const E=sr(r,n);if(E!==void 0&&(n.reference!=="suffix"&&s.push("//"),s.push(E),r.path&&r.path.charAt(0)!=="/"&&s.push("/")),r.path!==void 0){let T=r.path;!n.absolutePath&&(!i||!i.absolutePath)&&(T=pe(T)),E===void 0&&(T=T.replace(/^\/\//,"/%2F")),s.push(T)}return r.query!==void 0&&(s.push("?"),s.push(r.query)),r.fragment!==void 0&&(s.push("#"),s.push(r.fragment)),s.join("")}function cr(r,n,t={},s){const i={};return s||(r=te(J(r,t),t),n=te(J(n,t),t)),t=t||{},!t.tolerant&&n.scheme?(i.scheme=n.scheme,i.userinfo=n.userinfo,i.host=n.host,i.port=n.port,i.path=pe(n.path||""),i.query=n.query):(n.userinfo!==void 0||n.host!==void 0||n.port!==void 0?(i.userinfo=n.userinfo,i.host=n.host,i.port=n.port,i.path=pe(n.path||""),i.query=n.query):(n.path?(n.path.charAt(0)==="/"?i.path=pe(n.path):((r.userinfo!==void 0||r.host!==void 0||r.port!==void 0)&&!r.path?i.path="/"+n.path:r.path?i.path=r.path.slice(0,r.path.lastIndexOf("/")+1)+n.path:i.path=n.path,i.path=pe(i.path)),i.query=n.query):(i.path=r.path,n.query!==void 0?i.query=n.query:i.query=r.query),i.userinfo=r.userinfo,i.host=r.host,i.port=r.port),i.scheme=r.scheme),i.fragment=n.fragment,i}function Sr(r,n,t){return J(cr(te(r,t),te(n,t),t,!0),t)}function Pr(r,n){return typeof r=="string"?r=J(te(r,n),n):typeOf(r)==="object"&&(r=te(J(r,n),n)),r}function Ir(r,n,t){return typeof r=="string"?r=J(te(r,t),t):typeOf(r)==="object"&&(r=J(r,t)),typeof n=="string"?n=J(te(n,t),t):typeOf(n)==="object"&&(n=J(n,t)),r===n}function Ar(r,n){return r&&r.toString().replace(!n||!n.iri?URI_PROTOCOL.ESCAPE:IRI_PROTOCOL.ESCAPE,Q)}function ae(r,n){return r&&r.toString().replace(!n||!n.iri?L.PCT_ENCODED:p.PCT_ENCODED,he)}var ge={scheme:"http",domainHost:!0,parse:function(r,n){return r.host||(r.error=r.error||"HTTP URIs must have a host."),r},serialize:function(r,n){return(r.port===(String(r.scheme).toLowerCase()!=="https"?80:443)||r.port==="")&&(r.port=void 0),r.path||(r.path="/"),r}},Te={scheme:"https",domainHost:ge.domainHost,parse:ge.parse,serialize:ge.serialize};const ve={},Ee="[A-Za-z0-9\\-\\.\\_\\~"+(!0?"\\xA0-\\u200D\\u2010-\\u2029\\u202F-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFEF":"")+"]",G="[0-9A-Fa-f]",we=e(e("%[EFef]"+G+"%"+G+G+"%"+G+G)+"|"+e("%[89A-Fa-f]"+G+"%"+G+G)+"|"+e("%"+G+G)),ce="[A-Za-z0-9\\!\\$\\%\\'\\*\\+\\-\\^\\_\\`\\{\\|\\}\\~]",Oe="[\\!\\$\\%\\'\\(\\)\\*\\+\\,\\-\\.0-9\\<\\>A-Z\\x5E-\\x7E]",be=a(Oe,'[\\"\\\\]'),Ce=e(ce+"+"+e("\\."+ce+"+")+"*"),$e=e("\\\\"+be),Ue=e(Oe+"|"+$e),Ne=e('\\"'+Ue+'*\\"'),Se="[\\x21-\\x5A\\x5E-\\x7E]",Pe="[\\!\\$\\'\\(\\)\\*\\+\\,\\;\\:\\@]",Le=e(Ee+"|"+we+"|"+Pe),k=e(Ce+"|\\["+Se+"*\\]"),ur=e(Ce+"|"+Ne),Ke=e(ur+"\\@"+k),ze=e(Ke+e("\\,"+Ke)+"*"),Ge=e(Le+"*"),lr=Ge,Ze=e(Ge+"\\="+lr),Xe=e(Ze+e("\\&"+Ze)+"*"),fr=e("\\?"+Xe),mr=new RegExp("^mailto\\:"+ze+"?"+fr+"?$"),dr=new RegExp(Ee,"g"),ue=new RegExp(we,"g"),hr=new RegExp(a("[^]",ce,"[\\.]",'[\\"]',be),"g"),Rr=new RegExp(a("[^]",ce,"[\\.]","[\\[]",Se,"[\\]]"),"g"),We=new RegExp(a("[^]",Ee,Pe),"g"),pr=We,_r=new RegExp("^"+ze+"$"),Er=new RegExp("^"+Xe+"$");function Fe(r){const n=he(r);return n.match(dr)?n:r}var Ye={scheme:"mailto",parse:function(r,n){const t=r.to=r.path?r.path.split(","):[];if(r.path=void 0,r.query){let s=!1;const i={},E=r.query.split("&");for(let T=0,x=E.length;T<x;++T){const U=E[T].split("=");switch(U[0]){case"to":const Z=U[1].split(",");for(let _=0,X=Z.length;_<X;++_)t.push(Z[_]);break;case"subject":r.subject=ae(U[1],n);break;case"body":r.body=ae(U[1],n);break;default:s=!0,i[ae(U[0],n)]=ae(U[1],n);break}}s&&(r.headers=i)}r.query=void 0;for(let s=0,i=t.length;s<i;++s){const E=t[s].split("@");if(E[0]=ae(E[0]),n.unicodeSupport)E[1]=ae(E[1],n).toLowerCase();else try{E[1]=de.toASCII(ae(E[1],n).toLowerCase())}catch(T){r.error=r.error||"Email address's domain name can not be converted to ASCII via punycode: "+T}t[s]=E.join("@")}return r},serialize:function(r,n){const t=W(r.to);if(t){for(let E=0,T=t.length;E<T;++E){const x=String(t[E]),U=x.lastIndexOf("@"),Z=x.slice(0,U).replace(ue,Fe).replace(ue,N).replace(hr,Q);let _=x.slice(U+1);try{_=n.iri?de.toUnicode(_):de.toASCII(ae(_,n).toLowerCase())}catch(X){r.error=r.error||"Email address's domain name can not be converted to "+(n.iri?"Unicode":"ASCII")+" via punycode: "+X}t[E]=Z+"@"+_}r.path=t.join(",")}const s=r.headers=r.headers||{};r.subject&&(s.subject=r.subject),r.body&&(s.body=r.body);const i=[];for(const E in s)s[E]!==ve[E]&&i.push(E.replace(ue,Fe).replace(ue,N).replace(We,Q)+"="+s[E].replace(ue,Fe).replace(ue,N).replace(pr,Q));return i.length&&(r.query=i.join("&")),r}};const yr="(?:[0-9A-Za-z][0-9A-Za-z\\-]{1,31})",Dr="(?:\\%[0-9A-Fa-f]{2})",w="[0-9A-Za-z\\(\\)\\+\\,\\-\\.\\:\\=\\@\\;\\$\\_\\!\\*\\'\\/\\?\\#]",d="(?:(?:"+Dr+"|"+w+")+)",h=new RegExp("^urn\\:("+yr+")$"),b=new RegExp("^("+yr+")\\:("+d+")$"),$=/^([^\:]+)\:(.*)/,ee=/[\x00-\x20\\\"\&\<\>\[\]\^\`\{\|\}\~\x7F-\xFF]/g;var Me={scheme:"urn",parse:function(r,n){const t=r.path&&r.path.match($);if(t){const s="urn:"+t[1].toLowerCase();let i=Y[s];i||(i=Y[s]={scheme:s,parse:function(E,T){return E},serialize:Y.urn.serialize}),r.scheme=s,r.path=t[2],r=i.parse(r,n)}else r.error=r.error||"URN can not be parsed.";return r},serialize:function(r,n){const t=r.scheme||n.scheme;if(t&&t!=="urn"){const s=t.match(h)||["urn:"+t,t];r.scheme="urn",r.path=s[1]+":"+(r.path?r.path.replace(ee,Q):"")}return r}};const Ie=/^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/;var Tr={scheme:"urn:uuid",parse:function(r,n){return!n.tolerant&&(!r.path||!r.path.match(Ie))&&(r.error=r.error||"UUID is not valid."),r},serialize:function(r,n){return!n.tolerant&&(!r.path||!r.path.match(Ie))?r.scheme=void 0:r.path=(r.path||"").toLowerCase(),Y.urn.serialize(r,n)}};Y.http=ge,Y.https=Te,Y.mailto=Ye,Y.urn=Me,Y["urn:uuid"]=Tr},61160:function(fe,o,v){var a=v(92063),e=v(73992),q=/^[\x00-\x20\u00a0\u1680\u2000-\u200a\u2028\u2029\u202f\u205f\u3000\ufeff]+/,N=/[\n\r\t]/g,W=/^[A-Za-z][A-Za-z0-9+-.]*:\/\//,y=/:\d+$/,L=/^([a-z][a-z0-9.+-]*:)?(\/\/)?([\\/]+)?([\S\s]*)/i,p=/^[a-zA-Z]:/;function I(f){return(f||"").toString().replace(q,"")}var D=[["#","hash"],["?","query"],function(u,l){return A(l.protocol)?u.replace(/\\/g,"/"):u},["/","pathname"],["@","auth",1],[NaN,"host",void 0,1,1],[/:(\d*)$/,"port",void 0,1],[NaN,"hostname",void 0,1,1]],V={hash:1,query:1};function j(f){var u;typeof window<"u"?u=window:typeof v.g<"u"?u=v.g:typeof self<"u"?u=self:u={};var l=u.location||{};f=f||l;var c={},O=typeof f,S;if(f.protocol==="blob:")c=new F(unescape(f.pathname),{});else if(O==="string"){c=new F(f,{});for(S in V)delete c[S]}else if(O==="object"){for(S in f)S in V||(c[S]=f[S]);c.slashes===void 0&&(c.slashes=W.test(f.href))}return c}function A(f){return f==="file:"||f==="ftp:"||f==="http:"||f==="https:"||f==="ws:"||f==="wss:"}function C(f,u){f=I(f),f=f.replace(N,""),u=u||{};var l=L.exec(f),c=l[1]?l[1].toLowerCase():"",O=!!l[2],S=!!l[3],m=0,R;return O?S?(R=l[2]+l[3]+l[4],m=l[2].length+l[3].length):(R=l[2]+l[4],m=l[2].length):S?(R=l[3]+l[4],m=l[3].length):R=l[4],c==="file:"?m>=2&&(R=R.slice(2)):A(c)?R=l[4]:c?O&&(R=R.slice(2)):m>=2&&A(u.protocol)&&(R=l[4]),{protocol:c,slashes:O||A(c),slashesCount:m,rest:R}}function P(f,u){if(f==="")return u;for(var l=(u||"/").split("/").slice(0,-1).concat(f.split("/")),c=l.length,O=l[c-1],S=!1,m=0;c--;)l[c]==="."?l.splice(c,1):l[c]===".."?(l.splice(c,1),m++):m&&(c===0&&(S=!0),l.splice(c,1),m--);return S&&l.unshift(""),(O==="."||O==="..")&&l.push(""),l.join("/")}function F(f,u,l){if(f=I(f),f=f.replace(N,""),!(this instanceof F))return new F(f,u,l);var c,O,S,m,R,H,re=D.slice(),ie=typeof u,g=this,ne=0;for(ie!=="object"&&ie!=="string"&&(l=u,u=null),l&&typeof l!="function"&&(l=e.parse),u=j(u),O=C(f||"",u),c=!O.protocol&&!O.slashes,g.slashes=O.slashes||c&&u.slashes,g.protocol=O.protocol||u.protocol||"",f=O.rest,(O.protocol==="file:"&&(O.slashesCount!==2||p.test(f))||!O.slashes&&(O.protocol||O.slashesCount<2||!A(g.protocol)))&&(re[3]=[/(.*)/,"pathname"]);ne<re.length;ne++){if(m=re[ne],typeof m=="function"){f=m(f,g);continue}S=m[0],H=m[1],S!==S?g[H]=f:typeof S=="string"?(R=S==="@"?f.lastIndexOf(S):f.indexOf(S),~R&&(typeof m[2]=="number"?(g[H]=f.slice(0,R),f=f.slice(R+m[2])):(g[H]=f.slice(R),f=f.slice(0,R)))):(R=S.exec(f))&&(g[H]=R[1],f=f.slice(0,R.index)),g[H]=g[H]||c&&m[3]&&u[H]||"",m[4]&&(g[H]=g[H].toLowerCase())}l&&(g.query=l(g.query)),c&&u.slashes&&g.pathname.charAt(0)!=="/"&&(g.pathname!==""||u.pathname!=="")&&(g.pathname=P(g.pathname,u.pathname)),g.pathname.charAt(0)!=="/"&&A(g.protocol)&&(g.pathname="/"+g.pathname),a(g.port,g.protocol)||(g.host=g.hostname,g.port=""),g.username=g.password="",g.auth&&(R=g.auth.indexOf(":"),~R?(g.username=g.auth.slice(0,R),g.username=encodeURIComponent(decodeURIComponent(g.username)),g.password=g.auth.slice(R+1),g.password=encodeURIComponent(decodeURIComponent(g.password))):g.username=encodeURIComponent(decodeURIComponent(g.auth)),g.auth=g.password?g.username+":"+g.password:g.username),g.origin=g.protocol!=="file:"&&A(g.protocol)&&g.host?g.protocol+"//"+g.host:"null",g.href=g.toString()}function K(f,u,l){var c=this;switch(f){case"query":typeof u=="string"&&u.length&&(u=(l||e.parse)(u)),c[f]=u;break;case"port":c[f]=u,a(u,c.protocol)?u&&(c.host=c.hostname+":"+u):(c.host=c.hostname,c[f]="");break;case"hostname":c[f]=u,c.port&&(u+=":"+c.port),c.host=u;break;case"host":c[f]=u,y.test(u)?(u=u.split(":"),c.port=u.pop(),c.hostname=u.join(":")):(c.hostname=u,c.port="");break;case"protocol":c.protocol=u.toLowerCase(),c.slashes=!l;break;case"pathname":case"hash":if(u){var O=f==="pathname"?"/":"#";c[f]=u.charAt(0)!==O?O+u:u}else c[f]=u;break;case"username":case"password":c[f]=encodeURIComponent(u);break;case"auth":var S=u.indexOf(":");~S?(c.username=u.slice(0,S),c.username=encodeURIComponent(decodeURIComponent(c.username)),c.password=u.slice(S+1),c.password=encodeURIComponent(decodeURIComponent(c.password))):c.username=encodeURIComponent(decodeURIComponent(u))}for(var m=0;m<D.length;m++){var R=D[m];R[4]&&(c[R[1]]=c[R[1]].toLowerCase())}return c.auth=c.password?c.username+":"+c.password:c.username,c.origin=c.protocol!=="file:"&&A(c.protocol)&&c.host?c.protocol+"//"+c.host:"null",c.href=c.toString(),c}function z(f){(!f||typeof f!="function")&&(f=e.stringify);var u,l=this,c=l.host,O=l.protocol;O&&O.charAt(O.length-1)!==":"&&(O+=":");var S=O+(l.protocol&&l.slashes||A(l.protocol)?"//":"");return l.username?(S+=l.username,l.password&&(S+=":"+l.password),S+="@"):l.password?(S+=":"+l.password,S+="@"):l.protocol!=="file:"&&A(l.protocol)&&!c&&l.pathname!=="/"&&(S+="@"),(c[c.length-1]===":"||y.test(l.hostname)&&!l.port)&&(c+=":"),S+=c+l.pathname,u=typeof l.query=="object"?f(l.query):l.query,u&&(S+=u.charAt(0)!=="?"?"?"+u:u),l.hash&&(S+=l.hash),S}F.prototype={set:K,toString:z},F.extractProtocol=C,F.location=j,F.trimLeft=I,F.qs=e,fe.exports=F},99211:function(fe,o){Object.defineProperty(o,"__esModule",{value:!0});function v(A,C,P){var F;if(P===void 0&&(P={}),!C.codes){C.codes={};for(var K=0;K<C.chars.length;++K)C.codes[C.chars[K]]=K}if(!P.loose&&A.length*C.bits&7)throw new SyntaxError("Invalid padding");for(var z=A.length;A[z-1]==="=";)if(--z,!P.loose&&!((A.length-z)*C.bits&7))throw new SyntaxError("Invalid padding");for(var f=new((F=P.out)!=null?F:Uint8Array)(z*C.bits/8|0),u=0,l=0,c=0,O=0;O<z;++O){var S=C.codes[A[O]];if(S===void 0)throw new SyntaxError("Invalid character "+A[O]);l=l<<C.bits|S,u+=C.bits,u>=8&&(u-=8,f[c++]=255&l>>u)}if(u>=C.bits||255&l<<8-u)throw new SyntaxError("Unexpected end of data");return f}function a(A,C,P){P===void 0&&(P={});for(var F=P,K=F.pad,z=K===void 0?!0:K,f=(1<<C.bits)-1,u="",l=0,c=0,O=0;O<A.length;++O)for(c=c<<8|255&A[O],l+=8;l>C.bits;)l-=C.bits,u+=C.chars[f&c>>l];if(l&&(u+=C.chars[f&c<<C.bits-l]),z)for(;u.length*C.bits&7;)u+="=";return u}var e={chars:"0123456789ABCDEF",bits:4},q={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bits:5},N={chars:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bits:5},W={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bits:6},y={chars:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bits:6},L={parse:function(C,P){return v(C.toUpperCase(),e,P)},stringify:function(C,P){return a(C,e,P)}},p={parse:function(C,P){return P===void 0&&(P={}),v(P.loose?C.toUpperCase().replace(/0/g,"O").replace(/1/g,"L").replace(/8/g,"B"):C,q,P)},stringify:function(C,P){return a(C,q,P)}},I={parse:function(C,P){return v(C,N,P)},stringify:function(C,P){return a(C,N,P)}},D={parse:function(C,P){return v(C,W,P)},stringify:function(C,P){return a(C,W,P)}},V={parse:function(C,P){return v(C,y,P)},stringify:function(C,P){return a(C,y,P)}},j={parse:v,stringify:a};o.base16=L,o.base32=p,o.base32hex=I,o.base64=D,o.base64url=V,o.codec=j},82671:function(fe,o,v){v.d(o,{ef:function(){return y},gw:function(){return j},k5:function(){return N}});var a=v(93689);const e=a.WK,q=a.DE,N=a.k5,W=a.Dr,y=a.ef,L=a.GY,p=a.WM,I=a.Kz,D=a.uX,V=a.IK,j=a.gw,A=a.WU,C=a.G8,P=a.xQ,F=a.D7,K=a.hi,z=a.zU,f=a.dq,u=a.m$,l=a.MU,c=a.ID,O=a.k0,S=a.D4,m=a.kL,R=a.jx,H=a.A_,re=a.v1,ie=a.TL,g=a.Og,ne=a.ft,Re=a.KU,ye=a.ZU,_e=a.ye,tr=a.Xj,Or=a.Rn,br=a.bo,de=a.KL,Y=a.rW,Q=a.U3,he=a.$Y,De=a.EJ,ar=a.XY,or=a.v7,te=a.up,sr=a.h,je=a.Cx,He=a.Zz,qe=a.CU,Cr=a.ib,ir=a.eT,pe=a._0,J=a.UR,cr=a.Up,Sr=a.y0,Pr=a.A2,Ir=a.ql,Ar=a.FX,ae=a.Jr,ge=a.zS,Te=a.pK,ve=a.ud,Ve=a.Zk,Ee=a.Mf,G=a.U0,we=a.CX,ce=a.l4,Oe=a.Jv,be=a.T0,Ce=a.z8,$e=a.Gt,Ue=a.Fm,Ne=a.b4,Se=a.N2,Pe=a.K8,Le=a.gB,k=a.bd,ur=a.GG,Ke=a.V$,ze=a.CC,Ge=a.dT,lr=a.uT,Ze=a._j,Xe=a.p4,fr=a.W0,mr=a.zk,dr=a.AB,ue=a.sn,hr=a._u,Rr=a.Py,We=a.iu,pr=a.l7,_r=a.JU,Er=a.O6}}]);
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[8330],{26277:function(nt,V,L){L.d(V,{k:function(){return b}});var T=L(66001),J=L(82671),M=L(14483),u=L(36856),_=L(44276),E=L(99818);function z(w,t){var n;const{memos:s=[]}=w,{displayName:r,memoOptions:l=[],multipleMemos:h=!1}=t,{memoName:o="memo"}=(n=l[0])!=null?n:{};for(const d of s){const v=l.filter(I=>d.type===I.type);if(v.length<1)throw new Error(`${r} ${o}: cannot be type ${d.type}`);const O=v.map(I=>K(d,I)).find(I=>I!=null);if(O!=null)throw new Error(`${r} ${o}: ${O}`)}if(!h&&s.length>1)throw new Error(`${r} only supports one ${o}`)}function K(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,E.HS)(u.ym)(w.value);if(n==null)return"is not a valid number";if(t.maxValue!=null&&(0,T.gt)(n,t.maxValue))return`cannot be greater than ${t.maxValue}`}if(t.type==="hex"){const n=(0,E.HS)(u.zU)(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 Y=Object.defineProperty,R=Object.getOwnPropertySymbols,W=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,j=(w,t,n)=>t in w?Y(w,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):w[t]=n,N=(w,t)=>{for(var n in t||(t={}))W.call(t,n)&&j(w,n,t[n]);if(R)for(var n of R(t))X.call(t,n)&&j(w,n,t[n]);return w},g=(w,t,n)=>new Promise((s,r)=>{var l=d=>{try{o(n.next(d))}catch(v){r(v)}},h=d=>{try{o(n.throw(d))}catch(v){r(v)}},o=d=>d.done?s(d.value):Promise.resolve(d.value).then(l,h);o((n=n.apply(w,t)).next())});const m=1e4,D=1e3,p=3600*24;class b{constructor(t,n,s,r){this.allTokens=[],this.allTokensMap={},this.builtinTokens={},this.customTokens={},this.enabledTokenIds=[],this.enabledTokens=[];const{builtinTokens:l,currencyInfo:h}=t,{callbacks:o,customTokens:d,enabledTokenIds:v,log:O,walletLocalDisklet:I}=r;this.tools=n,this.log=O,this.warn=(C,S)=>this.log.warn(C+(0,_.Jo)(S)),this.error=(C,S)=>this.log.error(C+(0,_.Jo)(S)),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=s,this.walletId=s.id,this.currencyInfo=h,this.timers={},this.otherData=void 0,this.minimumAddressBalance="0";const{currencyCode:A}=h;this.transactionList[A]=[],this.txIdMap[A]={},this.txIdList[A]=[],this.builtinTokens=l,this.changeCustomTokensSync(d),this.changeEnabledTokenIdsSync(v),r.userSettings!=null?this.currentSettings=r.userSettings:this.currentSettings=this.currencyInfo.defaultSettings,this.currencyEngineCallbacks=o,this.walletLocalDisklet=I,typeof this.walletInfo.keys.publicKey!="string"&&(this.walletInfo.keys.publicKey=s.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=(C,S)=>{var F,B;const{nativeAmount:$,parentNetworkFee:H}=C,U=this.currencyInfo.currencyCode,q=S!=null?this.allTokensMap[S].currencyCode:U,tt=(F=this.walletLocalData.totalBalances[q])!=null?F:"0",e=U,i=(B=this.walletLocalData.totalBalances[e])!=null?B:"0";if((0,T.gt)((0,T.abs)($),tt))throw new J.k5({tokenId:S});if(H!=null&&(0,T.gt)(H,i))throw new J.k5({networkFee:H,tokenId:null})},this.makeEdgeTransactionAmounts=(C,S,F)=>{let B=`-${C}`,$=S,H;return F!=null?(H=$,$="0"):B=(0,T.sub)(B,$),{nativeAmount:B,networkFee:$,parentNetworkFee:H}}}isSpendTx(t){if(t.nativeAmount!==""){if(t.nativeAmount.slice(0,1)==="-")return!0;if((0,T.gt)(t.nativeAmount,"0"))return!1}let n=!0;if(t.ourReceiveAddresses.length>0)for(const s of t.ourReceiveAddresses)s===this.walletLocalData.publicKey&&(n=!1);return n}setOtherData(t){throw new Error(`Unimplemented setOtherData for ${this.walletInfo.type}`)}loadTransactions(){return g(this,null,function*(){var t;if(this.transactionsLoaded){this.log("Transactions already loaded");return}this.transactionsLoaded=!0;const n=this.walletLocalDisklet;let s;try{const o=yield n.getText(u._6);s=JSON.parse(o)}catch{this.log("Could not load txidList file. Failure is ok on new device"),yield n.setText(u._6,JSON.stringify(this.txIdList))}let r;try{const o=yield n.getText(u.wV);r=JSON.parse(o)}catch{this.log("Could not load txidMap file. Failure is ok on new device"),yield n.setText(u.wV,JSON.stringify(this.txIdMap))}let l;try{const o=yield n.getText(u.Kw);l=JSON.parse(o)}catch(o){o.code==="ENOENT"||((t=o.message)==null?void 0:t.includes("No such file"))===!0?(this.log("Could not load transactionList file. Failure is ok on new device"),yield n.setText(u.Kw,JSON.stringify(this.transactionList))):this.log.crash(o,{currencyPluginId:this.currencyInfo.pluginId})}let h=!0;for(const o of Object.keys(this.transactionList))if(this.transactionList[o]!=null&&this.transactionList[o].length>0){h=!1;break}if(h)this.transactionList=l!=null?l:this.transactionList,this.txIdList=s!=null?s:this.txIdList,this.txIdMap=r!=null?r:this.txIdMap;else if(l!=null)for(const o of Object.keys(l))for(const d of l[o])this.addTransaction(o,d);for(const o in this.transactionList)this.walletLocalData.numTransactions[o]=this.transactionList[o].length})}loadEngine(){return g(this,null,function*(){var t;const{walletInfo:n}=this,{currencyCode:s}=this.currencyInfo;this.walletInfo.keys.publicKey==null&&(this.walletInfo.keys.publicKey=n.keys.publicKey);const r=this.walletLocalDisklet;try{const l=yield r.getText(u.e1);this.walletLocalData=(0,u.TS)(JSON.parse(l)),this.walletLocalData.publicKey=this.walletInfo.keys.publicKey}catch{try{this.log("No walletLocalData setup yet: Failure is ok"),this.walletLocalData=(0,u.TS)({}),this.walletLocalData.publicKey=this.walletInfo.keys.publicKey,yield r.setText(u.e1,JSON.stringify(this.walletLocalData))}catch(h){throw this.error("Error writing to localDataStore. Engine not started: ",h),h}}this.setOtherData((t=this.walletLocalData.otherData)!=null?t:{}),this.walletLocalDataDirty=!(0,_.AP)(this.otherData,this.walletLocalData.otherData),this.tokenCheckBalanceStatus[s]=0,this.tokenCheckTransactionsStatus[s]=0,this.doInitialBalanceCallback(),this.doInitialUnactivatedTokenIdsCallback()})}findTransaction(t,n){if(this.txIdMap[t]!=null){const s=this.txIdMap[t][n];if(typeof s=="number")return s}return-1}sortTxByDate(t,n){return n.date-t.date}addTransaction(t,n,s){this.log("executing addTransaction: ",n.txid),n.otherParams==null&&(n.otherParams={}),n.blockHeight<1&&(n.otherParams.lastSeenTime=s!=null?s:Math.round(Date.now()/1e3));const r=(0,_.Qh)(n.txid),l=this.findTransaction(t,r);let h=!1;if(l===-1){if(this.isSpendTx(n)&&n.blockHeight===0&&(this.walletLocalData.numUnconfirmedSpendTxs++,this.walletLocalDataDirty=!0),h=!0,typeof this.transactionList[t]>"u")this.transactionList[t]=[];else if(this.transactionList[t].length>=D)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][l],{otherParams:v={}}=d,{otherParams:O={}}=n;(d.blockHeight<n.blockHeight||d.blockHeight===0&&n.blockHeight<0||d.blockHeight===n.blockHeight&&(d.networkFee!==n.networkFee||d.nativeAmount!==n.nativeAmount||v.lastSeenTime!==O.lastSeenTime||d.date!==n.date))&&(this.isSpendTx(n)&&n.blockHeight!==0&&d.blockHeight===0&&this.walletLocalData.numUnconfirmedSpendTxs--,d.date!==n.date&&(h=!0),this.warn(`addTransaction: update ${n.txid} height:${n.blockHeight}`),this.walletLocalDataDirty=!0,this.updateTransaction(t,n,l))}h&&this.sortTransactions(t)}sortTransactions(t){this.transactionList[t].sort(this.sortTxByDate);const n=[];let s=0;for(const r of this.transactionList[t])this.txIdMap[t]==null&&(this.txIdMap[t]={}),this.txIdMap[t][(0,_.Qh)(r.txid)]=s,n.push((0,_.Qh)(r.txid)),s++;this.txIdList[t]=n}checkDroppedTransactionsThrottled(){const t=Date.now()/1e3;t-this.walletLocalData.lastCheckedTxsDropped>p&&(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 s in this.transactionList)for(let r=0;r<this.transactionList[s].length;r++){const l=this.transactionList[s][r];if(l.blockHeight===0){const{otherParams:h={}}=l,o=h.lastSeenTime;t-o>p?(l.blockHeight=-1,l.nativeAmount="0",this.transactionsChangedArray.push(l)):this.isSpendTx(l)&&n++}}this.walletLocalData.numUnconfirmedSpendTxs=n,this.walletLocalDataDirty=!0}updateBalance(t,n){const s=this.walletLocalData.totalBalances[t];if(this.walletLocalData.totalBalances[t]==null&&(this.walletLocalData.totalBalances[t]="0"),s==null||!(0,T.eq)(n,s)){this.walletLocalData.totalBalances[t]=n,this.walletLocalDataDirty=!0,this.warn(`${t}: token Address balance: ${n}`);const r=(0,M.jE)(t,this.currencyInfo.currencyCode,this.allTokensMap);if(r===void 0)return;this.currencyEngineCallbacks.onTokenBalanceChanged(r,n)}this.tokenCheckBalanceStatus[t]=1,this.updateOnAddressesChecked()}updateTransaction(t,n,s){this.transactionList[t][s]=n,this.transactionListDirty=!0,this.transactionsChangedArray.push(n),this.warn(`updateTransaction: ${n.txid}`)}saveWalletLoop(){return g(this,null,function*(){const t=this.walletLocalDisklet,n=[];if(this.transactionListDirty){yield this.loadTransactions(),this.log("transactionListDirty. Saving...");let s=JSON.stringify(this.transactionList);n.push(t.setText(u.Kw,s).catch(r=>{this.error("Error saving transactionList ",r)})),s=JSON.stringify(this.txIdList),n.push(t.setText(u._6,s).catch(r=>{this.error("Error saving txIdList ",r)})),s=JSON.stringify(this.txIdMap),n.push(t.setText(u.wV,s).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 s=JSON.stringify(this.walletLocalData);yield t.setText(u.e1,s).then(()=>{this.walletLocalDataDirty=!1}).catch(r=>{this.error("Error saving walletLocalData ",r)})}})}doInitialBalanceCallback(){var t;for(const n of this.enabledTokens)try{const s=(0,M.jE)(n,this.currencyInfo.currencyCode,this.allTokensMap);if(s===void 0)continue;this.currencyEngineCallbacks.onTokenBalanceChanged(s,(t=this.walletLocalData.totalBalances[n])!=null?t:"0")}catch(s){this.error(`doInitialBalanceCallback Error for currencyCode ${n}`,s)}}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 g(this,null,function*(){try{yield this[t]()}catch(s){this.error(`Error in Loop: ${t} `,s)}return this.engineOn&&(this.timers[t]=setTimeout(()=>{this.engineOn&&this.addToLoop(t,n).catch(s=>this.log(s.message))},n)),!0})}getTokenInfo(t){return this.allTokens.find(n=>n.currencyCode===t)}updateOnAddressesChecked(){var t,n;if(this.addressesChecked)return;const s=this.enabledTokens,r=1/s.length;let l=0,h=0;for(const o of s){const d=(t=this.tokenCheckBalanceStatus[o])!=null?t:0,v=(n=this.tokenCheckTransactionsStatus[o])!=null?n:0;l+=(d+v)/2*r,d===1&&v===1&&h++}h===s.length&&(l=1,this.addressesChecked=!0),this.log(`${this.walletId} syncRatio of: ${l}`),this.currencyEngineCallbacks.onAddressesChecked(l)}clearBlockchainCache(){return g(this,null,function*(){this.walletLocalData=(0,u.TS)({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 g(this,null,function*(){this.addToLoop("saveWalletLoop",m).catch(()=>{})})}killEngine(){return g(this,null,function*(){this.engineOn=!1;for(const t in this.timers)clearTimeout(this.timers[t]);this.timers={}})}changeUserSettings(t){return g(this,null,function*(){this.currentSettings=t})}getBlockHeight(){return this.walletLocalData.blockHeight}changeCustomTokensSync(t){this.customTokens={};for(const n of Object.keys(t)){const s=t[n];try{(0,M.k9)(s)}catch{this.log.warn(`Dropping custom token "${s.currencyCode}" / ${n}`);continue}this.customTokens[n]=s}this.allTokensMap=N(N({},this.customTokens),this.builtinTokens),this.allTokens=(0,M.yQ)(this.allTokensMap)}changeCustomTokens(t){return g(this,null,function*(){this.changeCustomTokensSync(t)})}changeEnabledTokenIdsSync(t){const{currencyCode:n}=this.currencyInfo,s=new Set,r=new Set;for(const l of t){const h=this.allTokensMap[l];h!=null&&(s.add(h.currencyCode),r.add(l))}this.enabledTokens=[...s,n],this.enabledTokenIds=[...r]}changeEnabledTokenIds(t){return g(this,null,function*(){this.changeEnabledTokenIdsSync(t)})}getBalance(t){const{tokenId:n}=t,{currencyCode:s}=n==null?this.currencyInfo:this.allTokensMap[n],r=this.walletLocalData.totalBalances[s];return r==null?"0":r}getNumTransactions(t){const{tokenId:n}=t,{currencyCode:s}=n==null?this.currencyInfo:this.allTokensMap[n];return this.walletLocalData.numTransactions[s]==null?0:this.walletLocalData.numTransactions[s]}getTransactions(t){return g(this,null,function*(){const{startDate:n,endDate:s,tokenId:r}=t,{currencyCode:l}=r==null?this.currencyInfo:this.allTokensMap[r];return yield this.loadTransactions(),this.transactionList[l]==null?[]:this.transactionList[l].filter(o=>new Date(o.date)>=(n!=null?n:new Date(0))&&new Date(o.date)<=(s!=null?s:new Date))})}getFreshAddress(t){return g(this,null,function*(){return{publicAddress:this.walletLocalData.publicKey}})}addGapLimitAddresses(t){return g(this,null,function*(){})}isAddressUsed(t){return g(this,null,function*(){return!1})}dumpData(){return g(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,s,r;const{skipChecks:l=!1,tokenId:h}=t;z(t,this.currencyInfo);for(const I of t.spendTargets)if(!l&&I.publicAddress===this.walletLocalData.publicKey)throw new J.gw;if(h!=null&&!this.enabledTokenIds.includes(h))throw new Error("Error: Token not enabled");const{currencyCode:o}=h==null?this.currencyInfo:this.allTokensMap[h],d=(n=this.walletLocalData.totalBalances[o])!=null?n:"0",v={};for(const I of t.spendTargets){const{nativeAmount:A}=I;A!=null&&(v[o]=(s=v[o])!=null?s:"0",v[o]=(0,T.add)(v[o],A))}for(const[I,A]of Object.entries(v)){const C=(r=this.walletLocalData.totalBalances[I])!=null?r:"0";if(!l&&(0,T.lt)(C,A))throw new J.k5({tokenId:h})}const O=(0,_._r)(o,this.currencyInfo,this.allTokensMap);if(O==null)throw new Error("InternalErrorInvalidCurrencyCode");return{edgeSpendInfo:t,nativeBalance:d,currencyCode:o,denom:O,skipChecks:l}}checkRecipientMinimumBalance(t,n,s){return g(this,null,function*(){if((0,T.gte)(n,this.minimumAddressBalance))return;const r=yield t(s);if((0,T.lt)((0,T.add)(n,r),this.minimumAddressBalance)){const l=this.currencyInfo.denominations.find(o=>o.name===this.currencyInfo.currencyCode);if(l==null)throw new Error("Unknown denom");const h=(0,T.div)(this.minimumAddressBalance,l.multiplier);throw new Error(`Recipient address not activated. A minimum ${h} ${this.currencyInfo.currencyCode} transfer is required to send funds to this address`)}})}saveTx(t){return g(this,null,function*(){this.addTransaction(t.currencyCode,t),this.transactionsChangedArray.forEach(n=>this.warn(`executing back in saveTx and this.transactionsChangedArray is: ${(0,_.T5)(n)}`)),this.transactionsChangedArray.length>0&&this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray)})}resyncBlockchain(){return g(this,null,function*(){throw new Error("not implemented")})}makeSpend(t,n){return g(this,null,function*(){throw new Error("not implemented")})}signTx(t,n){return g(this,null,function*(){throw new Error("not implemented")})}broadcastTx(t,n){return g(this,null,function*(){throw new Error("not implemented")})}}},96542:function(nt,V,L){L.d(V,{m:function(){return g},x:function(){return N}});var T=L(66001),J=L.n(T),M=L(63054),u=L(61160),_=L.n(u),E=L(44276),z=Object.defineProperty,K=Object.getOwnPropertySymbols,Y=Object.prototype.hasOwnProperty,R=Object.prototype.propertyIsEnumerable,W=(m,D,p)=>D in m?z(m,D,{enumerable:!0,configurable:!0,writable:!0,value:p}):m[D]=p,X=(m,D)=>{for(var p in D||(D={}))Y.call(D,p)&&W(m,p,D[p]);if(K)for(var p of K(D))R.call(D,p)&&W(m,p,D[p]);return m},j=(m,D,p)=>new Promise((b,w)=>{var t=r=>{try{s(p.next(r))}catch(l){w(l)}},n=r=>{try{s(p.throw(r))}catch(l){w(l)}},s=r=>r.done?b(r.value):Promise.resolve(r.value).then(t,n);s((p=p.apply(m,D)).next())});function N(m){return j(this,null,function*(){const{currencyInfo:D,uri:p,networks:b,builtinTokens:w,customTokens:t=[],testPrivateKeys:n}=m;let{currencyCode:s}=m;const r=X({},_()(p,{},!0)),l=p.startsWith(`${D.pluginId}://`);if(r.protocol!=null&&(r.protocol=r.protocol.replace(":","")),r.protocol!=null&&r.protocol!==""&&!b[r.protocol])throw new Error(`Uri protocol '${r.protocol}' is not supported for ${D.pluginId}.`);if(r.host===""&&r.pathname==="")throw new Error("Path and host not found in uri.");const o={publicAddress:r.host!==""?r.host:r.pathname.split("/")[0]},d=r.query.label,v=r.query.message,O=r.query.category;(d!=null||v!=null||O!=null||l)&&(o.metadata={},o.metadata.name=d,o.metadata.notes=v,o.metadata.category=O,o.metadata.gateway=l!=null?l:!1);const I=r.query.amount;if(I!=null&&typeof I=="string"){s==null&&(s=D.currencyCode);const A=(0,E.FQ)(s!=null?s:"",D,t,w);if(A==null)throw new Error("InternalErrorInvalidCurrencyCode");let C=(0,T.mul)(I,A.multiplier);C=(0,T.toFixed)(C,0,0),o.nativeAmount=C,o.currencyCode=s}if(n!=null)try{yield n(p),o.privateKeys=[p],o.publicAddress=void 0}catch{}return{edgeParsedUri:o,parsedUri:r}})}function g(m,D,p){if(m.publicAddress==null)throw new Error("InvalidPublicAddressError");if(p==null&&m.label==null&&m.message==null)return m.publicAddress;{let b="";p!=null&&(b+="amount="+p+"&"),(m.label!=null||m.message!=null)&&(typeof m.label=="string"&&(b+="label="+m.label+"&"),typeof m.message=="string"&&(b+="message="+m.message+"&")),b=b.substr(0,b.length-1);const w={scheme:D,path:m.publicAddress,query:b};return(0,M.lK)(w)}}},44276:function(nt,V,L){L.d(V,{AP:function(){return U},Ao:function(){return m},BB:function(){return o},CY:function(){return S},EY:function(){return D},FQ:function(){return b},I0:function(){return g},Je:function(){return v},Jo:function(){return F},KI:function(){return X},M0:function(){return O},NN:function(){return h},QR:function(){return s},Qh:function(){return z},R3:function(){return K},RK:function(){return C},T5:function(){return A},X5:function(){return d},XM:function(){return r},_r:function(){return w},db:function(){return j},jD:function(){return $},nj:function(){return W},ow:function(){return N},qv:function(){return R},wR:function(){return l},wy:function(){return B},yH:function(){return tt}});var T=L(66001),J=L.n(T),M=L(48287),u=L(99818),_=L(65828),E=(e,i,a)=>new Promise((c,f)=>{var k=x=>{try{P(a.next(x))}catch(Q){f(Q)}},y=x=>{try{P(a.throw(x))}catch(Q){f(Q)}},P=x=>x.done?c(x.value):Promise.resolve(x.value).then(k,y);P((a=a.apply(e,i)).next())});function z(e){return e.toLowerCase().replace("0x","")}function K(e){let i=e.length,a,c;for(;i!==0;)c=Math.floor(Math.random()*i),i-=1,a=e[i],e[i]=e[c],e[c]=a;return e}function Y(e){return Object.keys(e).length!==0}function R(e){return/^[0-9A-F]+$/i.test(N(e))}function W(e){return(0,T.add)(e,"0",16)}function X(e){const i=e.replace("0x","");return M.Buffer.from(i,"hex")}function j(e,i){return 2*i-e.length>0?e.padStart(2*i,"0"):e}function N(e){return e.indexOf("0x")===0?e.substring(2):e}function g(e){const i=e.toLowerCase(),a=i.startsWith("0x")?i:`0x${i}`;return(0,T.add)(a,"0",10)}function m(e){return(0,T.add)(e,"0",16)}function D(e){return"0x"+_.xn.stringify(e).toLowerCase()}function p(e){return"0x"+Buffer2.from(e).toString("hex")}function b(e,i,a,c){for(const f of i.denominations)if(f.name===e)return f;for(const f of a)for(const k of f.denominations)if(k.name===e)return k;for(const f of Object.values(c))for(const k of f.denominations)if(k.name===e)return k}function w(e,i,a){for(const c of i.denominations)if(c.name===e)return c;for(const c of Object.keys(a)){const f=a[c];for(const k of f.denominations)if(k.name===e)return k}}const t=e=>E(void 0,null,function*(){return yield new Promise((i,a)=>setTimeout(a,e))}),n=e=>E(void 0,null,function*(){return yield new Promise(i=>setTimeout(i,e))});function s(e){return E(this,null,function*(){return yield new Promise((i,a)=>{let c=e.length;for(const f of e)f.then(k=>{i(k)},k=>{--c===0&&a(k)})})})}function r(e,i){return E(this,arguments,function*(a,c,f=a.length){const k={};return yield new Promise((y,P)=>{let x=0,Q=0,et=!1;for(const st of a)st.then(Z=>{const G=c(Z);G!==void 0?(x++,k[G]!==void 0?k[G]++:k[G]=1,!et&&k[G]>=f&&(et=!0,y(Z))):++Q+x===a.length&&P(Error(`Could not resolve ${f} promises`))},Z=>{++Q+x===a.length&&P(Z)})})})}function l(e,i){return E(this,arguments,function*(a,c,f=new Error(`Timeout of ${c}ms exceeded`)){return yield new Promise((k,y)=>{const P=setTimeout(()=>y(f),c);a.then(x=>{k(x),clearTimeout(P)},x=>{y(x),clearTimeout(P)})})})}function h(e,i=5e3){return E(this,null,function*(){let a=e.length;const c=[];for(const f of e){const k=c.length;c.push(f().catch(y=>{throw y.index=k,y})),a>1&&c.push(new Promise(y=>{n(i).then(()=>{y("async_waterfall_timed_out")})}));try{const y=yield Promise.race(c);if(y==="async_waterfall_timed_out"){const P=c.pop();P==null||P.then().catch(),--a}else return y}catch(y){const P=y.index;c.splice(P,1);const x=c.pop();if(x==null||x.then().catch(),--a,a===0)throw y}}})}function o(e,i){if(e.length<=i)return e;const a=[];for(let c=0;c<e.length&&a.length<i;++c){const f=(i-a.length)/(e.length-c);Math.random()<=f&&a.push(e[c])}return a}function d(e){return e[Math.floor(Math.random()*e.length)]}function v(e){const i=e.otherParams;if(i==null)throw new TypeError("Transaction is missing otherParams");return i}function O(){let e=!1;const i=[];return function(c){return E(this,null,function*(){e&&(yield new Promise(f=>i.push(()=>f(void 0))));try{return e=!0,yield c()}finally{e=!1;const f=i.shift();f!=null&&f()}})}}const I=(0,u.eB)({txid:u.oJ,spendTargets:(0,u.H7)((0,u._j)((0,u.eB)({currencyCode:u.oJ,nativeAmount:u.oJ,publicAddress:u.oJ,uniqueIdentifier:(0,u.H7)(u.oJ)}))),signedTx:u.oJ,otherParams:(0,u.H7)((0,u.eB)({gas:(0,u.H7)(u.oJ),gasPrice:(0,u.H7)(u.oJ),nonceUsed:(0,u.H7)(u.oJ)}))});function A(e){return JSON.stringify(I(e),null,2)}function C(e){const[i,a]=e.split("e");return a==null?e:(0,T.mul)(i,"1"+"0".repeat(parseInt(a))).toString()}function S(e){var i;return(i=e.fetchCors)!=null?i:e.fetch}function F(e){let i="";return e!=null&&(e.name!=null&&(i+=`${e.name} `),e.message!=null&&(i+=e.message)),i}function B(...e){const i={};for(const a of e)if(a!=null)for(const c of Object.keys(a)){if(a[c]===void 0)continue;const f=i[c]!=null&&typeof a[c]=="object"&&!Array.isArray(a[c]);i[c]=f?B(i[c],a[c]):a[c]}return i}function $(e){const[i,a]=e.split(".");return a==null?i:parseInt(a[0])>=5?(0,T.add)(i,"1"):i}const H=e=>console.log(JSON.stringify(e,null,2));function U(e,i){if(typeof e!="object"||typeof i!="object"||e==null||i==null)return e===i;const a=Array.isArray(e),c=Array.isArray(i);if(a!==c)return!1;if(a){if(e.length!==i.length)return!1;for(let y=0;y<e.length;++y)if(!U(e[y],i[y]))return!1;return!0}const f=Object.getOwnPropertyNames(e).filter(y=>e[y]!==void 0),k=Object.getOwnPropertyNames(i).filter(y=>i[y]!==void 0);if(f.length!==k.length)return!1;for(const y of f)if(!Object.prototype.hasOwnProperty.call(i,y)||!U(e[y],i[y]))return!1;return!0}const q=(e,i)=>{for(const a of Object.keys(e)){if(typeof e[a]=="object"){if(typeof i[a]!="object"||!q(e[a],i[a]))return!1;continue}if(e[a]!==i[a])return!1}return!0},tt=e=>E(void 0,null,function*(){const{func:i,providers:a}=e,c=a.map(f=>()=>E(void 0,null,function*(){return yield i(f)}));return yield h(K(c))})}}]);
1
+ "use strict";(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[8330],{26277:function(R,$,k){k.d($,{k:function(){return w}});var p=k(66001),E=k(82671),v=k(14483),y=k(36856),D=k(44276),S=k(99818);function K(u,t){var e;const{memos:n=[]}=u,{displayName:s,memoOptions:i=[],multipleMemos:l=!1}=t,{memoName:a="memo"}=(e=i[0])!=null?e:{};for(const r of n){const f=i.filter(m=>r.type===m.type);if(f.length<1)throw new Error(`${s} ${a}: cannot be type ${r.type}`);const T=f.map(m=>A(r,m)).find(m=>m!=null);if(T!=null)throw new Error(`${s} ${a}: ${T}`)}if(!l&&n.length>1)throw new Error(`${s} only supports one ${a}`)}function A(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,S.HS)(y.ym)(u.value);if(e==null)return"is not a valid number";if(t.maxValue!=null&&(0,p.gt)(e,t.maxValue))return`cannot be greater than ${t.maxValue}`}if(t.type==="hex"){const e=(0,S.HS)(y.zU)(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 N=Object.defineProperty,O=Object.getOwnPropertySymbols,_=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,B=(u,t,e)=>t in u?N(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,P=(u,t)=>{for(var e in t||(t={}))_.call(t,e)&&B(u,e,t[e]);if(O)for(var e of O(t))U.call(t,e)&&B(u,e,t[e]);return u},h=(u,t,e)=>new Promise((n,s)=>{var i=r=>{try{a(e.next(r))}catch(f){s(f)}},l=r=>{try{a(e.throw(r))}catch(f){s(f)}},a=r=>r.done?n(r.value):Promise.resolve(r.value).then(i,l);a((e=e.apply(u,t)).next())});const c=1e4,d=1e3,o=3600*24;class w{constructor(t,e,n,s){this.allTokens=[],this.allTokensMap={},this.builtinTokens={},this.customTokens={},this.enabledTokenIds=[],this.enabledTokens=[];const{builtinTokens:i,currencyInfo:l}=t,{callbacks:a,customTokens:r,enabledTokenIds:f,log:T,walletLocalDisklet:m}=s;this.tools=e,this.log=T,this.warn=(g,I)=>this.log.warn(g+(0,D.Jo)(I)),this.error=(g,I)=>this.log.error(g+(0,D.Jo)(I)),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=l,this.timers={},this.otherData=void 0,this.minimumAddressBalance="0";const{currencyCode:L}=l;this.transactionList[L]=[],this.txIdMap[L]={},this.txIdList[L]=[],this.builtinTokens=i,this.changeCustomTokensSync(r),this.changeEnabledTokenIdsSync(f),s.userSettings!=null?this.currentSettings=s.userSettings:this.currentSettings=this.currencyInfo.defaultSettings,this.currencyEngineCallbacks=a,this.walletLocalDisklet=m,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=(g,I)=>{var M,b;const{nativeAmount:x,parentNetworkFee:C}=g,H=this.currencyInfo.currencyCode,J=I!=null?this.allTokensMap[I].currencyCode:H,F=(M=this.walletLocalData.totalBalances[J])!=null?M:"0",W=H,V=(b=this.walletLocalData.totalBalances[W])!=null?b:"0";if((0,p.gt)((0,p.abs)(x),F))throw new E.k5({tokenId:I});if(C!=null&&(0,p.gt)(C,V))throw new E.k5({networkFee:C,tokenId:null})},this.makeEdgeTransactionAmounts=(g,I,M)=>{let b=`-${g}`,x=I,C;return M!=null?(C=x,x="0"):b=(0,p.sub)(b,x),{nativeAmount:b,networkFee:x,parentNetworkFee:C}}}isSpendTx(t){if(t.nativeAmount!==""){if(t.nativeAmount.slice(0,1)==="-")return!0;if((0,p.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 h(this,null,function*(){var t;if(this.transactionsLoaded){this.log("Transactions already loaded");return}this.transactionsLoaded=!0;const e=this.walletLocalDisklet;let n;try{const a=yield e.getText(y._6);n=JSON.parse(a)}catch{this.log("Could not load txidList file. Failure is ok on new device"),yield e.setText(y._6,JSON.stringify(this.txIdList))}let s;try{const a=yield e.getText(y.wV);s=JSON.parse(a)}catch{this.log("Could not load txidMap file. Failure is ok on new device"),yield e.setText(y.wV,JSON.stringify(this.txIdMap))}let i;try{const a=yield e.getText(y.Kw);i=JSON.parse(a)}catch(a){a.code==="ENOENT"||((t=a.message)==null?void 0:t.includes("No such file"))===!0?(this.log("Could not load transactionList file. Failure is ok on new device"),yield e.setText(y.Kw,JSON.stringify(this.transactionList))):this.log.crash(a,{currencyPluginId:this.currencyInfo.pluginId})}let l=!0;for(const a of Object.keys(this.transactionList))if(this.transactionList[a]!=null&&this.transactionList[a].length>0){l=!1;break}if(l)this.transactionList=i!=null?i:this.transactionList,this.txIdList=n!=null?n:this.txIdList,this.txIdMap=s!=null?s:this.txIdMap;else if(i!=null)for(const a of Object.keys(i))for(const r of i[a])this.addTransaction(a,r);for(const a in this.transactionList)this.walletLocalData.numTransactions[a]=this.transactionList[a].length})}loadEngine(){return h(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 s=this.walletLocalDisklet;try{const i=yield s.getText(y.e1);this.walletLocalData=(0,y.TS)(JSON.parse(i)),this.walletLocalData.publicKey=this.walletInfo.keys.publicKey}catch{try{this.log("No walletLocalData setup yet: Failure is ok"),this.walletLocalData=(0,y.TS)({}),this.walletLocalData.publicKey=this.walletInfo.keys.publicKey,yield s.setText(y.e1,JSON.stringify(this.walletLocalData))}catch(l){throw this.error("Error writing to localDataStore. Engine not started: ",l),l}}this.setOtherData((t=this.walletLocalData.otherData)!=null?t:{}),this.walletLocalDataDirty=!(0,D.AP)(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 s=(0,D.Qh)(e.txid),i=this.findTransaction(t,s);let l=!1;if(i===-1){if(this.isSpendTx(e)&&e.blockHeight===0&&(this.walletLocalData.numUnconfirmedSpendTxs++,this.walletLocalDataDirty=!0),l=!0,typeof this.transactionList[t]>"u")this.transactionList[t]=[];else if(this.transactionList[t].length>=d)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:f={}}=r,{otherParams:T={}}=e;(r.blockHeight<e.blockHeight||r.blockHeight===0&&e.blockHeight<0||r.blockHeight===e.blockHeight&&(r.networkFee!==e.networkFee||r.nativeAmount!==e.nativeAmount||f.lastSeenTime!==T.lastSeenTime||r.date!==e.date))&&(this.isSpendTx(e)&&e.blockHeight!==0&&r.blockHeight===0&&this.walletLocalData.numUnconfirmedSpendTxs--,r.date!==e.date&&(l=!0),this.warn(`addTransaction: update ${e.txid} height:${e.blockHeight}`),this.walletLocalDataDirty=!0,this.updateTransaction(t,e,i))}l&&this.sortTransactions(t)}sortTransactions(t){this.transactionList[t].sort(this.sortTxByDate);const e=[];let n=0;for(const s of this.transactionList[t])this.txIdMap[t]==null&&(this.txIdMap[t]={}),this.txIdMap[t][(0,D.Qh)(s.txid)]=n,e.push((0,D.Qh)(s.txid)),n++;this.txIdList[t]=e}checkDroppedTransactionsThrottled(){const t=Date.now()/1e3;t-this.walletLocalData.lastCheckedTxsDropped>o&&(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 s=0;s<this.transactionList[n].length;s++){const i=this.transactionList[n][s];if(i.blockHeight===0){const{otherParams:l={}}=i,a=l.lastSeenTime;t-a>o?(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];if(this.walletLocalData.totalBalances[t]==null&&(this.walletLocalData.totalBalances[t]="0"),n==null||!(0,p.eq)(e,n)){this.walletLocalData.totalBalances[t]=e,this.walletLocalDataDirty=!0,this.warn(`${t}: token Address balance: ${e}`);const s=(0,v.jE)(t,this.currencyInfo.currencyCode,this.allTokensMap);if(s===void 0)return;this.currencyEngineCallbacks.onTokenBalanceChanged(s,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 h(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(y.Kw,n).catch(s=>{this.error("Error saving transactionList ",s)})),n=JSON.stringify(this.txIdList),e.push(t.setText(y._6,n).catch(s=>{this.error("Error saving txIdList ",s)})),n=JSON.stringify(this.txIdMap),e.push(t.setText(y.wV,n).catch(s=>{this.error("Error saving txIdMap ",s)})),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(y.e1,n).then(()=>{this.walletLocalDataDirty=!1}).catch(s=>{this.error("Error saving walletLocalData ",s)})}})}doInitialBalanceCallback(){var t;for(const e of this.enabledTokens)try{const n=(0,v.jE)(e,this.currencyInfo.currencyCode,this.allTokensMap);if(n===void 0)continue;this.currencyEngineCallbacks.onTokenBalanceChanged(n,(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 h(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,s=1/n.length;let i=0,l=0;for(const a of n){const r=(t=this.tokenCheckBalanceStatus[a])!=null?t:0,f=(e=this.tokenCheckTransactionsStatus[a])!=null?e:0;i+=(r+f)/2*s,r===1&&f===1&&l++}l===n.length&&(i=1,this.addressesChecked=!0),this.log(`${this.walletId} syncRatio of: ${i}`),this.currencyEngineCallbacks.onAddressesChecked(i)}clearBlockchainCache(){return h(this,null,function*(){this.walletLocalData=(0,y.TS)({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 h(this,null,function*(){this.addToLoop("saveWalletLoop",c).catch(()=>{})})}killEngine(){return h(this,null,function*(){this.engineOn=!1;for(const t in this.timers)clearTimeout(this.timers[t]);this.timers={}})}changeUserSettings(t){return h(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,v.k9)(n)}catch{this.log.warn(`Dropping custom token "${n.currencyCode}" / ${e}`);continue}this.customTokens[e]=n}this.allTokensMap=P(P({},this.customTokens),this.builtinTokens),this.allTokens=(0,v.yQ)(this.allTokensMap)}changeCustomTokens(t){return h(this,null,function*(){this.changeCustomTokensSync(t)})}changeEnabledTokenIdsSync(t){const{currencyCode:e}=this.currencyInfo,n=new Set,s=new Set;for(const i of t){const l=this.allTokensMap[i];l!=null&&(n.add(l.currencyCode),s.add(i))}this.enabledTokens=[...n,e],this.enabledTokenIds=[...s]}changeEnabledTokenIds(t){return h(this,null,function*(){this.changeEnabledTokenIdsSync(t)})}getBalance(t){const{tokenId:e}=t,{currencyCode:n}=e==null?this.currencyInfo:this.allTokensMap[e],s=this.walletLocalData.totalBalances[n];return s==null?"0":s}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 h(this,null,function*(){const{startDate:e,endDate:n,tokenId:s}=t,{currencyCode:i}=s==null?this.currencyInfo:this.allTokensMap[s];return yield this.loadTransactions(),this.transactionList[i]==null?[]:this.transactionList[i].filter(a=>new Date(a.date)>=(e!=null?e:new Date(0))&&new Date(a.date)<=(n!=null?n:new Date))})}getFreshAddress(t){return h(this,null,function*(){return{publicAddress:this.walletLocalData.publicKey}})}addGapLimitAddresses(t){return h(this,null,function*(){})}isAddressUsed(t){return h(this,null,function*(){return!1})}dumpData(){return h(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,s;const{skipChecks:i=!1,tokenId:l}=t;K(t,this.currencyInfo);for(const m of t.spendTargets)if(!i&&m.publicAddress===this.walletLocalData.publicKey)throw new E.gw;if(l!=null&&!this.enabledTokenIds.includes(l))throw new Error("Error: Token not enabled");const{currencyCode:a}=l==null?this.currencyInfo:this.allTokensMap[l],r=(e=this.walletLocalData.totalBalances[a])!=null?e:"0",f={};for(const m of t.spendTargets){const{nativeAmount:L}=m;L!=null&&(f[a]=(n=f[a])!=null?n:"0",f[a]=(0,p.add)(f[a],L))}for(const[m,L]of Object.entries(f)){const g=(s=this.walletLocalData.totalBalances[m])!=null?s:"0";if(!i&&(0,p.lt)(g,L))throw new E.k5({tokenId:l})}const T=(0,D._r)(a,this.currencyInfo,this.allTokensMap);if(T==null)throw new Error("InternalErrorInvalidCurrencyCode");return{edgeSpendInfo:t,nativeBalance:r,currencyCode:a,denom:T,skipChecks:i}}checkRecipientMinimumBalance(t,e,n){return h(this,null,function*(){if((0,p.gte)(e,this.minimumAddressBalance))return;const s=yield t(n);if((0,p.lt)((0,p.add)(e,s),this.minimumAddressBalance)){const i=this.currencyInfo.denominations.find(a=>a.name===this.currencyInfo.currencyCode);if(i==null)throw new Error("Unknown denom");const l=(0,p.div)(this.minimumAddressBalance,i.multiplier);throw new Error(`Recipient address not activated. A minimum ${l} ${this.currencyInfo.currencyCode} transfer is required to send funds to this address`)}})}saveTx(t){return h(this,null,function*(){this.addTransaction(t.currencyCode,t),this.transactionsChangedArray.forEach(e=>this.warn(`executing back in saveTx and this.transactionsChangedArray is: ${(0,D.T5)(e)}`)),this.transactionsChangedArray.length>0&&this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray)})}resyncBlockchain(){return h(this,null,function*(){throw new Error("not implemented")})}makeSpend(t,e){return h(this,null,function*(){throw new Error("not implemented")})}signTx(t,e){return h(this,null,function*(){throw new Error("not implemented")})}broadcastTx(t,e){return h(this,null,function*(){throw new Error("not implemented")})}}},96542:function(R,$,k){k.d($,{m:function(){return h},x:function(){return P}});var p=k(66001),E=k.n(p),v=k(63054),y=k(61160),D=k.n(y),S=k(44276),K=Object.defineProperty,A=Object.getOwnPropertySymbols,N=Object.prototype.hasOwnProperty,O=Object.prototype.propertyIsEnumerable,_=(c,d,o)=>d in c?K(c,d,{enumerable:!0,configurable:!0,writable:!0,value:o}):c[d]=o,U=(c,d)=>{for(var o in d||(d={}))N.call(d,o)&&_(c,o,d[o]);if(A)for(var o of A(d))O.call(d,o)&&_(c,o,d[o]);return c},B=(c,d,o)=>new Promise((w,u)=>{var t=s=>{try{n(o.next(s))}catch(i){u(i)}},e=s=>{try{n(o.throw(s))}catch(i){u(i)}},n=s=>s.done?w(s.value):Promise.resolve(s.value).then(t,e);n((o=o.apply(c,d)).next())});function P(c){return B(this,null,function*(){const{currencyInfo:d,uri:o,networks:w,builtinTokens:u,customTokens:t=[],testPrivateKeys:e}=c;let{currencyCode:n}=c;const s=U({},D()(o,{},!0)),i=o.startsWith(`${d.pluginId}://`);if(s.protocol!=null&&(s.protocol=s.protocol.replace(":","")),s.protocol!=null&&s.protocol!==""&&!w[s.protocol])throw new Error(`Uri protocol '${s.protocol}' is not supported for ${d.pluginId}.`);if(s.host===""&&s.pathname==="")throw new Error("Path and host not found in uri.");const a={publicAddress:s.host!==""?s.host:s.pathname.split("/")[0]},r=s.query.label,f=s.query.message,T=s.query.category;(r!=null||f!=null||T!=null||i)&&(a.metadata={},a.metadata.name=r,a.metadata.notes=f,a.metadata.category=T,a.metadata.gateway=i!=null?i:!1);const m=s.query.amount;if(m!=null&&typeof m=="string"){n==null&&(n=d.currencyCode);const L=(0,S.FQ)(n!=null?n:"",d,t,u);if(L==null)throw new Error("InternalErrorInvalidCurrencyCode");let g=(0,p.mul)(m,L.multiplier);g=(0,p.toFixed)(g,0,0),a.nativeAmount=g,a.currencyCode=n}if(e!=null)try{yield e(o),a.privateKeys=[o],a.publicAddress=void 0}catch{}return{edgeParsedUri:a,parsedUri:s}})}function h(c,d,o){if(c.publicAddress==null)throw new Error("InvalidPublicAddressError");if(o==null&&c.label==null&&c.message==null)return c.publicAddress;{let w="";o!=null&&(w+="amount="+o+"&"),(c.label!=null||c.message!=null)&&(typeof c.label=="string"&&(w+="label="+c.label+"&"),typeof c.message=="string"&&(w+="message="+c.message+"&")),w=w.substr(0,w.length-1);const u={scheme:d,path:c.publicAddress,query:w};return(0,v.lK)(u)}}}}]);
@@ -1,2 +1,2 @@
1
- (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[7854],{62351:function(Ke,te,g){"use strict";g.d(te,{Nn:function(){return z},Nt:function(){return P},fi:function(){return ee},zp:function(){return C}});var j=g(44276),K=(S,A,I)=>new Promise((J,B)=>{var H=p=>{try{W(I.next(p))}catch(D){B(D)}},x=p=>{try{W(I.throw(p))}catch(D){B(D)}},W=p=>p.done?J(p.value):Promise.resolve(p.value).then(H,x);W((I=I.apply(S,A)).next())});const L=["https://info1.edge.app","https://info2.edge.app"];function V(S,A,I){return K(this,arguments,function*(J,B,H,x=5e3,W=fetch){const p=J.map(D=>()=>K(this,null,function*(){const k=yield W(D+"/"+B,H);if(typeof k!="object"){const T=`Invalid return value ${B} in ${D}`;throw console.log(T),new Error(T)}return k}));return yield(0,j.NN)(p,x)})}function C(S,A,I,J,B=5e3,H){return K(this,null,function*(){const x=yield V((0,j.R3)(A),I,J,B,H);if(!x.ok){const D=yield x.text();throw console.error(D),new Error(`Error fetching ${I}: ${D}`)}const W=yield x.json();return S(W)})}function oe(S,A,I,J=5e3,B){return K(this,null,function*(){return yield V((0,j.R3)(S),A,I,J,B)})}const z=(S,A,I,J)=>K(void 0,null,function*(){return yield oe(L,S,A,I,J)}),P=S=>Object.keys(S).map(A=>{const I=S[A];return I==null?A:`${A}=${encodeURIComponent(I)}`}).join("&"),ee=(S,A=5e3)=>S+Math.random()*A*2-A},29286:function(Ke,te,g){"use strict";g.r(te),g.d(te,{CosmosTools:function(){return _e},makeCurrencyEngine:function(){return Mn},makeCurrencyTools:function(){return $n},updateInfoPayload:function(){return Hn}});var j=g(11154),K=g(76005),L=g(44917),V=g(5450),C=g(66001),oe=g(90749),z=g(16856),P=g(65828),ee=g(14483),S=g(96542),A=g(44276),I=g(44941),J=g(2666),B=g(86181),H=g(10338),x=g(78824),W=g(15960),p=g(84007),D=g(67112),k=g(99818),T=g(84397),Ve=g(48287).Buffer,ue=(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 de=(e,n)=>{const t=(0,T.tx)(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}},qe=(e,n)=>{const{url:t,headers:r}=n;return{execute:s=>ue(void 0,null,function*(){var o;const c={method:"POST",headers:r,body:JSON.stringify(s)},i=yield(yield e(t,c)).json();if((0,W.isJsonRpcErrorResponse)(i))throw new Error(String((o=i.error.data)!=null?o:i.error.message));return i}),disconnect:()=>{}}},ze=e=>ue(void 0,null,function*(){const n=yield D.Comet38Client.create(e),t=(yield n.status()).nodeInfo.version;return t.startsWith("0.38.")?n:t.startsWith("0.37.")?yield D.Tendermint37Client.create(e):yield D.Tendermint34Client.create(e)}),fe=(e,n)=>ue(void 0,null,function*(){const t=yield p.StargateClient.create(yield ze(qe(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}}),Ge=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}},G=e=>e.reduce((n,t)=>{try{return(0,x.addCoins)(n,t)}catch{}return n}),me=(0,k.E8)("amount"),Ze=(0,k.E8)("receiver"),Qe=(0,k.E8)("spender"),Xe=(0,k.E8)("amount","receiver","spender"),Ye=(0,k.eB)({type:(0,k.E8)("coin_received"),attributes:(0,k.VA)((0,k.eB)({key:me,value:k.oJ}),(0,k.eB)({key:Ze,value:k.oJ}))}),je=(0,k.eB)({type:(0,k.E8)("coin_spent"),attributes:(0,k.VA)((0,k.eB)({key:me,value:k.oJ}),(0,k.eB)({key:Qe,value:k.oJ}))}),en=(e,n)=>{const t=new Map;for(const s of e){const o={type:s.type,attributes:s.attributes.filter(i=>(0,k.HS)(Xe)(i.key)!=null).sort((i,l)=>i.key<l.key?-1:1)},c=(0,k.HS)(Ye)(o);if(c!=null){const[i,l]=c.attributes.map(u=>u.value);if(l!==n)continue;ge(i).forEach(u=>{var y;const m=u.amount,h=(y=t.get(u.denom))!=null?y:"0";t.set(u.denom,(0,C.add)(m,h))});continue}const a=(0,k.HS)(je)(o);if(a!=null){const[i,l]=a.attributes.map(u=>u.value);if(l!==n)continue;ge(i).forEach(u=>{var y;const m=`-${u.amount}`,h=(y=t.get(u.denom))!=null?y:"0";t.set(u.denom,(0,C.add)(m,h))})}}const r=[];return t.forEach((s,o)=>{s!=="0"&&r.push({denom:o,amount:s})}),r},re=e=>{try{return P.xn.parse(e)}catch{return P.K3.parse(e)}},ge=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]}}),nn=(e,n)=>{const t=z.Bt.find(c=>c.bech32_prefix===(0,L.fromBech32)(n).prefix);if(t==null)throw new Error("Unrecognized denom");const r=t.chain_name,s=(0,H.getIbcInfo)(z.tX,e,r);if(s==null)throw new Error(`No IBC channels between ${e} and ${r}`);const o=(0,H.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}};function tn(e){if(!(()=>(e==null?void 0:e.msgs)!=null&&Array.isArray(e.msgs)&&e.msgs.length===1?e.msgs[0].type==="sign/MsgSignData":!1)())return!1;if(e.chain_id!=="")throw new Error("Chain id should be empty string for ADR-36 signing");if(e.memo!=="")throw new Error("Memo should be empty string for ADR-36 signing");if(e.account_number!=="0")throw new Error('Account number should be "0" for ADR-36 signing');if(e.sequence!=="0")throw new Error('Sequence should be "0" for ADR-36 signing');if(e.fee.gas!=="0")throw new Error('Gas should be "0" for ADR-36 signing');if(e.fee.amount.length!==0)throw new Error("Fee amount should be empty array for ADR-36 signing");const t=e.msgs[0];if(t.type!=="sign/MsgSignData")throw new Error(`Invalid type of ADR-36 sign msg: ${t.type}`);if(t.value==null)throw new Error("Empty value in the msg");const r=t.value.signer;if(r==null)throw new Error("Empty signer in the ADR-36 msg");(0,L.fromBech32)(r);const s=t.value.data;if(s==null)throw new Error("Empty data in the ADR-36 msg");const o=Ve.from(s,"base64");if(o.toString("base64")!==s)throw new Error("Data is not encoded by base64");if(o.length===0)throw new Error("Empty data in the ADR-36 msg");return!0}var on=g(28570),R=g.n(on),rn=g(26946),f=g.n(rn);const _n="common";function ye(){return{chain:"",symbol:"",ticker:"",synth:!1}}const Z={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=ye();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=ye();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 pe(){return{asset:void 0,amount:"",decimals:R().ZERO}}const w={encode(e,n=f().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 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.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)?R().fromValue(e.decimals):R().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||R().ZERO).toString()),n},create(e){return w.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=pe();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?R().fromValue(e.decimals):R().ZERO,t}};function ve(){return{secp256k1:"",ed25519:""}}const sn={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=ve();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 sn.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const r=ve();return r.secp256k1=(n=e.secp256k1)!=null?n:"",r.ed25519=(t=e.ed25519)!=null?t:"",r}};function ke(){return{id:"",chain:"",fromAddress:"",toAddress:"",coins:[],gas:[],memo:""}}const an={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=ke();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: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=>w.fromJSON(n)):[],gas:globalThis.Array.isArray(e==null?void 0:e.gas)?e.gas.map(n=>w.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=>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 an.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,r,s,o,c,a;const i=ke();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=>w.fromPartial(l)))||[],i.gas=((c=e.gas)==null?void 0:c.map(l=>w.fromPartial(l)))||[],i.memo=(a=e.memo)!=null?a:"",i}};function we(){return{coins:[],poolDeduct:""}}const cn={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=we();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: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=>w.toJSON(r))),e.poolDeduct!==""&&(t.poolDeduct=e.poolDeduct),t},create(e){return cn.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const r=we();return r.coins=((n=e.coins)==null?void 0:n.map(s=>w.fromPartial(s)))||[],r.poolDeduct=(t=e.poolDeduct)!=null?t:"",r}};function Te(){return{value:""}}const ln={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=Te();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 ln.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=Te();return t.value=(n=e.value)!=null?n:"",t}};f().util.Long!==R()&&(f().util.Long=R(),f().configure());function E(e){return e!=null}const Kn="types";function be(){return{coins:[],memo:"",signer:new Uint8Array(0)}}const se={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=be();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:Ae(e.memo)?globalThis.String(e.memo):"",signer:Ae(e.signer)?un(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=dn(e.signer)),t},create(e){return se.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,r;const s=be();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 un(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 dn(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!==R()&&(f().util.Long=R(),f().configure());function Ae(e){return e!=null}const Vn="cosmos.base.v1beta1";function Ce(){return{denom:"",amount:""}}const Q={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=Ce();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:X(e.denom)?globalThis.String(e.denom):"",amount:X(e.amount)?globalThis.String(e.amount):""}},toJSON(e){const n={};return e.denom!==""&&(n.denom=e.denom),e.amount!==""&&(n.amount=e.amount),n},create(e){return Q.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const r=Ce();return r.denom=(n=e.denom)!=null?n:"",r.amount=(t=e.amount)!=null?t:"",r}};function Ie(){return{denom:"",amount:""}}const hn={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=Ie();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:X(e.denom)?globalThis.String(e.denom):"",amount:X(e.amount)?globalThis.String(e.amount):""}},toJSON(e){const n={};return e.denom!==""&&(n.denom=e.denom),e.amount!==""&&(n.amount=e.amount),n},create(e){return hn.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const r=Ie();return r.denom=(n=e.denom)!=null?n:"",r.amount=(t=e.amount)!=null?t:"",r}};function Se(){return{int:""}}const fn={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=Se();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:X(e.int)?globalThis.String(e.int):""}},toJSON(e){const n={};return e.int!==""&&(n.int=e.int),n},create(e){return fn.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=Se();return t.int=(n=e.int)!=null?n:"",t}};function xe(){return{dec:""}}const mn={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=xe();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:X(e.dec)?globalThis.String(e.dec):""}},toJSON(e){const n={};return e.dec!==""&&(n.dec=e.dec),n},create(e){return mn.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=xe();return t.dec=(n=e.dec)!=null?n:"",t}};f().util.Long!==R()&&(f().util.Long=R(),f().configure());function X(e){return e!=null}const qn="types";function Ee(){return{fromAddress:new Uint8Array(0),toAddress:new Uint8Array(0),amount:[]}}const ie={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)Q.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=Ee();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(Q.decode(t,t.uint32()));continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{fromAddress:Oe(e.fromAddress)?Pe(e.fromAddress):new Uint8Array(0),toAddress:Oe(e.toAddress)?Pe(e.toAddress):new Uint8Array(0),amount:globalThis.Array.isArray(e==null?void 0:e.amount)?e.amount.map(n=>Q.fromJSON(n)):[]}},toJSON(e){var n;const t={};return e.fromAddress.length!==0&&(t.fromAddress=De(e.fromAddress)),e.toAddress.length!==0&&(t.toAddress=De(e.toAddress)),(n=e.amount)!=null&&n.length&&(t.amount=e.amount.map(r=>Q.toJSON(r))),t},create(e){return ie.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,r;const s=Ee();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=>Q.fromPartial(o)))||[],s}};function Pe(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 De(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!==R()&&(f().util.Long=R(),f().configure());function Oe(e){return e!=null}var gn=Object.defineProperty,yn=Object.defineProperties,pn=Object.getOwnPropertyDescriptors,Be=Object.getOwnPropertySymbols,vn=Object.prototype.hasOwnProperty,kn=Object.prototype.propertyIsEnumerable,Re=(e,n,t)=>n in e?gn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,wn=(e,n)=>{for(var t in n||(n={}))vn.call(n,t)&&Re(e,t,n[t]);if(Be)for(var t of Be(n))kn.call(n,t)&&Re(e,t,n[t]);return e},Tn=(e,n)=>yn(e,pn(n));const bn=1e3*60*60*24,An=e=>{const n=new V.Registry([["/ibc.applications.transfer.v1.MsgTransfer",B.MsgTransfer],["/cosmwasm.wasm.v1.MsgExecuteContract",J.zM]]);let t=s=>{const{amount:o,fromAddress:c,toAddress:a}=s;return{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:I.MsgSend.encode(I.MsgSend.fromPartial({fromAddress:c,toAddress:a,amount:o})).finish()}};const r=s=>{const{memo:o,toAddress:c,fromAddress:a,channel:i,port:l,amount:d}=s;return{typeUrl:"/ibc.applications.transfer.v1.MsgTransfer",value:B.MsgTransfer.encode(B.MsgTransfer.fromPartial({memo:o,receiver:c,sender:a,sourceChannel:i,sourcePort:l,token:d,timeoutTimestamp:BigInt((Date.now()+bn)*1e6)})).finish()}};switch(e){case"thorchainrune":{const s="/types.MsgDeposit";n.register(s,se);const o=a=>{const{assets:i,memo:l,signer:d}=a,u=i.map(m=>Tn(wn({},m),{asset:Ge(m.asset)}));return{typeUrl:s,value:se.encode(se.fromPartial({coins:u,memo:l,signer:(0,L.fromBech32)(d).data})).finish()}},c="/types.MsgSend";return n.register(c,ie),t=a=>{const{amount:i,fromAddress:l,toAddress:d}=a;return{typeUrl:c,value:ie.encode(ie.fromPartial({fromAddress:(0,L.fromBech32)(l).data,toAddress:(0,L.fromBech32)(d).data,amount:i})).finish()}},{methods:{deposit:o,ibcTransfer:r,transfer:t},registry:n}}}return{methods:{ibcTransfer:r,transfer:t},registry:n}};var Ne=g(1267),N=g(6975),Cn=g(82671),In=g(26277),Me=g(62351),Sn=Object.defineProperty,xn=Object.defineProperties,En=Object.getOwnPropertyDescriptors,Fe=Object.getOwnPropertySymbols,Pn=Object.getPrototypeOf,Dn=Object.prototype.hasOwnProperty,On=Object.prototype.propertyIsEnumerable,Bn=Reflect.get,Ue=(e,n,t)=>n in e?Sn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,ae=(e,n)=>{for(var t in n||(n={}))Dn.call(n,t)&&Ue(e,t,n[t]);if(Fe)for(var t of Fe(n))On.call(n,t)&&Ue(e,t,n[t]);return e},Le=(e,n)=>xn(e,En(n)),Je=(e,n,t)=>Bn(Pn(e),t,n),b=(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=(0,Me.fi)(2e4),He=(0,Me.fi)(2e4),Rn=1e3*60*60*24*14,Nn=1e3*60*2,he=50;class ce extends In.k{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.chainId=this.networkInfo.defaultChainId,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: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}),d=this.getBalance({tokenId:null});return(0,C.sub)(d,l)}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:c,memo:a,metadata:i}=o,l=this.tools.methods.deposit({assets:c,memo:a,signer:this.walletInfo.keys.bech32Address}),d=this.createUnsignedTxHex([l],a),{gasFeeCoin:u,gasLimit:y,networkFee:m}=yield this.calculateFee({messages:[l],memo:a}),h={gasFeeCoin:u,gasLimit:y,unsignedTxHex:d};return{blockHeight:0,currencyCode:this.currencyInfo.currencyCode,date:Date.now()/1e3,isSend:!0,memos:[],metadata:i,nativeAmount:`-${m}`,networkFee:m,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 c=(0,T.S4)(o),{authInfoBytes:a,bodyBytes:i}=c.params.signDoc,l=N.TxBody.decode(re(i)),{nativeAmount:d,tokenId:u}=this.getAmountAndTokenIdFromKnownMessageTypes(l.messages),y=N.AuthInfo.decode(re(a));let m="0";const h=y.fee;return h!=null&&(m=G([(0,p.coin)("0",this.networkInfo.nativeDenom),...h.amount]).amount),{nativeAmount:d,networkFee:m,tokenId:u}}case"cosmos_signAmino":{const c=(0,T.tV)(o),{signDoc:a}=c.params,i=(0,x.makeSignDoc)(a.msgs,a.fee,a.chain_id,a.memo,a.account_number,a.sequence),l=new p.AminoTypes(ae(ae({},p.createBankAminoConverters),p.createIbcAminoConverters)),d=i.msgs.filter(v=>v.type!=="sign/MsgSignData").map(v=>l.fromAmino(v)),{nativeAmount:u,tokenId:y}=this.getAmountAndTokenIdFromKnownMessageTypes(d);let m="0";const h=a.fee;return h!=null&&(m=G([(0,p.coin)("0",this.networkInfo.nativeDenom),...h.amount]).amount),{nativeAmount:u,networkFee:m,tokenId:y}}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=B.MsgTransfer.fromPartial(c);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=G([s,i]);break}case"/cosmwasm.wasm.v1.MsgExecuteContract":{const c=this.tools.registry.decode(o),a=J.zM.fromPartial(c),{funds:i}=a;if(i.length>0){const{denom:l}=i[0];r===void 0&&(r=this.tokenIdFromDenom(l));let d=(0,p.coin)("0",l);for(const u of i)d=G([d,u]);s==null?s=d:s=G([s,d])}break}default:}return{nativeAmount:(t=s==null?void 0:s.amount)!=null?t:"0",tokenId:r}}setOtherData(n){this.otherData=(0,T.qd)(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 l;const d=this.allTokensMap[i],u=r.find(m=>{var h;return m.denom===((h=d.networkLocation)==null?void 0:h.contractAddress)}),y=(l=u==null?void 0:u.amount)!=null?l:"0";this.updateBalance(d.currencyCode,y),(0,C.gt)(y,"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 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)}})}queryChainId(){return b(this,null,function*(){if(this.networkInfo.chainIdUpdateUrl!=null)try{const n=yield this.fetchCors(this.networkInfo.chainIdUpdateUrl);if(!n.ok){const s=yield n.text();throw new Error(s)}const t=yield n.json(),r=(0,T.gy)(t);this.chainId=r.result.node_info.network}catch(n){this.error("queryChainId Error ",n);return}clearTimeout(this.timers.queryChainId)})}queryTransactions(){return b(this,null,function*(){var n;let t=0;const r=[this.currencyInfo.currencyCode,...this.enabledTokenIds.map(o=>this.allTokensMap[o].currencyCode)],s=[];if(this.networkInfo.archiveNodes!=null&&Date.now()-Rn>this.otherData.archivedTxLastCheckTime){const o=this.networkInfo.archiveNodes.sort((c,a)=>c.blockTimeRangeSeconds.start-a.blockTimeRangeSeconds.start);for(const c of o)if(c.blockTimeRangeSeconds.end==null||c.blockTimeRangeSeconds.end>this.otherData.archivedTxLastCheckTime){const a=yield fe(this.fetchCors,de(c.endpoint,this.tools.initOptions));s.push(a)}}s.push(this.getClients());for(const o of s){let c=0;for(const a of T.b8){const{newestTxid:i,lastTimestamp:l}=yield this.queryTransactionsInner(a,o);i!=null&&((n=this.otherData[a])==null?void 0:n.newestTxid)!==i&&(this.otherData[a]={newestTxid:i},this.walletLocalDataDirty=!0,c=Math.max(c,l)),t+=.5/s.length,r.forEach(d=>this.tokenCheckTransactionsStatus[d]=t),this.updateOnAddressesChecked()}this.otherData.archivedTxLastCheckTime=c,this.walletLocalDataDirty=!0}this.otherData.archivedTxLastCheckTime=Date.now(),this.walletLocalDataDirty=!0,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:he,order_by:"asc"};let s,o=0,c=1;do{try{const{totalCount:a,txs:i}=yield t.cometClient.txSearch(Le(ae({},r),{page:c})),l=i.findIndex(d=>{var u;return(0,L.toHex)(d.hash).toUpperCase()===((u=this.otherData[n])==null?void 0:u.newestTxid)});for(let d=l+1;d<i.length;d++){const u=i[d];if(u==null)break;const y=(0,L.toHex)(u.hash).toUpperCase();this.removeFromUnconfirmedCache(y);const m=u.result.events.map(p.fromTendermintEvent);let h=[];try{h=en(m,this.walletInfo.keys.bech32Address)}catch(ne){this.log.warn("reduceCoinEventsForAddress error:",String(ne))}if(h.length===0)continue;const v=yield t.stargateClient.getBlock(u.height),O=(0,D.toSeconds)((0,D.fromRfc3339WithNanoseconds)(v.header.time)).seconds,{height:M,tx:F}=u,q=P.xn.stringify(F),{authInfo:{fee:Y},body:{memo:$,messages:le}}=(0,V.decodeTxRaw)(F),_=yield this.totalDynamicNetworkFee(le,v.header.height);h.forEach(ne=>{this.processCosmosTransaction(y,O,q,ne,$,M,_,Y)}),s=y,this.otherData[n]={newestTxid:y},o=O*1e3,this.walletLocalDataDirty=!0}if(i.length<he||a===c*he)break}catch(a){if(String(a).includes("page should be within"))continue;throw this.log.warn("queryTransactions error:",a),a}c++,this.otherData[n]={newestTxid:s},this.walletLocalDataDirty=!0}while(!0);return{newestTxid:s,lastTimestamp:o}})}processCosmosTransaction(n,t,r,s,o,c,a,i){const{amount:l,denom:d}=s,u=this.networkInfo.nativeDenom===d;let y;try{y=this.tokenIdFromDenom(d)}catch{return}const{currencyCode:m}=y==null?this.currencyInfo:this.allTokensMap[y];let h="0";if(i!=null){const{amount:$}=i,le=G([(0,p.coin)("0",this.networkInfo.nativeDenom),...$]);h=(0,C.add)(h,le.amount)}const v=(0,C.lt)(l,"0"),O=[];let M=l,F;v?u?(h=(0,C.add)(h,a),M=(0,C.sub)(M,h)):(h="0",F=a!=="0"?a:void 0):(O.push(this.walletInfo.keys.bech32Address),h="0");const q=[];o!==""&&q.push({type:"text",value:o});const Y={blockHeight:c,currencyCode:m,date:t,isSend:v,memos:q,nativeAmount:M,networkFee:h,ourReceiveAddresses:O,parentNetworkFee:F,signedTx:r,tokenId:y,txid:n,walletId:this.walletId};this.addTransaction(m,Y)}createUnsignedTxHex(n,t){const r=N.TxBody.fromPartial({messages:n,memo:t}),s=N.TxBody.encode(r).finish(),o=N.TxRaw.fromPartial({bodyBytes:s});return P.xn.stringify(N.TxRaw.encode(o).finish())}addToUnconfirmedCache(n){const t=new Date(new Date().getTime()+Nn);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}=de(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,T.cE)(i);for(const d of n)switch(d.typeUrl){case"/types.MsgDeposit":r=(0,C.add)(r,l.native_outbound_fee_rune);break;case"/types.MsgSend":r=(0,C.add)(r,l.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),c="0",a="0";if(this.networkInfo.defaultTransactionFeeUrl==null){const{queryClient:i}=this.getClients(),{gasInfo:l}=yield i.tx.simulate(t,r,(0,x.encodeSecp256k1Pubkey)(P.xn.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,C.ceil)((0,C.mul)(l==null?void 0:l.gasUsed.toString(),"1.5"),0);const{low:d,average:u,high:y}=(0,H.getGasPriceStep)(this.tools.chainData);let m=u;switch(s){case"low":{m=d;break}case"high":{m=y;break}case"custom":throw new Error("Custom fee not supported")}const h=(0,C.ceil)((0,C.mul)(c,m.toString()),0);o=(0,p.coin)(h,this.networkInfo.nativeDenom),a=o.amount}else a=yield this.totalDynamicNetworkFee(t),a=(0,C.mul)(a,"1.01");return{gasFeeCoin:o,gasLimit:c,networkFee:a}})}startEngine(){return b(this,null,function*(){this.engineOn=!0,yield this.tools.connectClient(),this.addToLoop("queryChainId",He).catch(()=>{}),this.addToLoop("queryBalance",$e).catch(()=>{}),this.addToLoop("queryBlockheight",$e).catch(()=>{}),this.addToLoop("queryTransactions",He).catch(()=>{}),yield Je(ce.prototype,this,"startEngine").call(this)})}killEngine(){return b(this,null,function*(){yield this.tools.disconnectClient(),yield Je(ce.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],c=(0,ee.oQ)(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 b(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:d,publicAddress:u}=s.spendTargets[0];if(d==null)throw new Cn.ef;if(u==null)throw new Error("makeSpend Missing publicAddress");const y=i!=null?(r=this.allTokensMap[i].networkLocation)==null?void 0:r.contractAddress:this.networkInfo.nativeDenom;if(y==null)throw new Error("Unknown denom");let m;if(this.networkInfo.bech32AddressPrefix!==(0,L.fromBech32)(u).prefix){const _=nn(this.tools.chainData.chain_name,u);yield this.validateTransfer(u,i,_);const{channel:ne,port:Wn}=_;m=this.tools.methods.ibcTransfer({channel:ne,port:Wn,memo:l,amount:(0,p.coin)(d,y),fromAddress:this.walletInfo.keys.bech32Address,toAddress:u})}else m=this.tools.methods.transfer({amount:[(0,p.coin)(d,y)],fromAddress:this.walletInfo.keys.bech32Address,toAddress:u});let h,v,O;const M=`${u}${String(a)}`,F=this.feeCache.get(M);if(d==="0")h=(0,p.coin)("0",this.networkInfo.nativeDenom),v="0",O="0";else if(F==null){const _=yield this.calculateFee({messages:[m],memo:l,networkFeeOption:a});h=_.gasFeeCoin,v=_.gasLimit,O=_.networkFee,this.feeCache.set(M,_)}else h=F.gasFeeCoin,v=F.gasLimit,O=F.networkFee;const q=this.createUnsignedTxHex([m],l),Y={gasFeeCoin:h,gasLimit:v,unsignedTxHex:q},$=this.makeEdgeTransactionAmounts(d,O,i);return this.checkBalances($,i),{blockHeight:0,currencyCode:o,date:0,isSend:!0,memos:c,nativeAmount:$.nativeAmount,networkFee:$.networkFee,otherParams:Y,ourReceiveAddresses:[],parentNetworkFee:$.parentNetworkFee,signedTx:"",tokenId:i,txid:"",walletId:this.walletId}})}signMessage(n,t,r){return b(this,null,function*(){const s=(0,T.yu)(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,T.yt)(r.otherParams);const h=(yield o.getAccounts()).map(v=>Le(ae({},v),{pubkey:P.K3.stringify(v.pubkey)}));return JSON.stringify(h)}case"cosmos_signDirect":{const m=(0,T.S4)(r.otherParams),{signDoc:h}=m.params,v=N.SignDoc.fromPartial({accountNumber:(0,Ne.longify)(h.accountNumber),authInfoBytes:re(h.authInfoBytes),bodyBytes:re(h.bodyBytes),chainId:h.chainId}),M={signature:(yield o.signDirect(this.walletInfo.keys.bech32Address,v)).signature,signed:m.params.signDoc};return JSON.stringify(M)}case"cosmos_signAmino":{const m=(0,T.tV)(r.otherParams),{signDoc:h}=m.params,v=(0,x.makeSignDoc)(h.msgs,h.fee,h.chain_id,h.memo,h.account_number,h.sequence);tn(v);const{bech32AddressPrefix:O,bip39Path:M}=this.networkInfo,F=(0,K.stringToPath)(M),$={signature:(yield(yield x.Secp256k1HdWallet.fromMnemonic(o.mnemonic,{prefix:O,hdPaths:[F]})).signAmino(this.walletInfo.keys.bech32Address,v)).signature,signed:h};return JSON.stringify($)}default:throw new Error(`Invalid method: ${r.method}`)}const c=P.xn.parse(n),a=N.SignDoc.decode(c),i=yield o.signDirect(this.walletInfo.keys.bech32Address,a),l=(0,x.decodeSignature)(i.signature),d=N.TxRaw.fromPartial({authInfoBytes:a.authInfoBytes,bodyBytes:a.bodyBytes,signatures:[l.signature]}),u=N.TxRaw.encode(d).finish();return P.xn.stringify(u)})}signTx(n,t){return b(this,null,function*(){const{gasFeeCoin:r,gasLimit:s,unsignedTxHex:o}=(0,T.TG)(n.otherParams),c=(0,T.yu)(this.currencyInfo.pluginId)(t),a=P.xn.parse(o),{bodyBytes:i}=N.TxRaw.decode(a),l=P.xn.parse(this.walletInfo.keys.publicKey),d=(0,x.encodeSecp256k1Pubkey)(l),u=(0,V.makeAuthInfoBytes)([{pubkey:(0,V.encodePubkey)(d),sequence:this.getSequence()}],[r],parseInt(s),void 0,void 0,1),y=N.SignDoc.fromPartial({accountNumber:(0,Ne.longify)(this.accountNumber),authInfoBytes:u,bodyBytes:i,chainId:this.chainId}),h=yield(yield this.tools.createSigner(c.mnemonic)).signDirect(this.walletInfo.keys.bech32Address,y),v=(0,x.decodeSignature)(h.signature),O=N.TxRaw.fromPartial({authInfoBytes:u,bodyBytes:i,signatures:[v.signature]}),M=N.TxRaw.encode(O).finish(),F=P.xn.stringify(M);return n.signedTx=F,n})}broadcastTx(n){return b(this,null,function*(){try{const t=P.xn.parse(n.signedTx),{stargateClient:r}=this.getClients(),s=yield r.broadcastTxSync(t);return this.warn(`SUCCESS broadcastTx
2
- ${(0,A.T5)(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 b(this,null,function*(){const{bech32Address:t}=this.walletInfo.keys;return{publicAddress:t}})}}function Mn(e,n,t,r){return b(this,null,function*(){const s=(0,T.r3)(t),o=new ce(e,n,s,r);return yield o.loadEngine(),o})}var Fn=g(48287).Buffer,We=Object.getOwnPropertySymbols,Un=Object.prototype.hasOwnProperty,Ln=Object.prototype.propertyIsEnumerable,Jn=(e,n)=>{var t={};for(var r in e)Un.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&We)for(var r of We(e))n.indexOf(r)<0&&Ln.call(e,r)&&(t[r]=e[r]);return t},U=(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 _e{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}=An(r.pluginId);this.methods=a,this.registry=i;const{chainName:l,url:d}=this.networkInfo.chainInfo,u=z.Bt.find(m=>m.chain_name===l&&m.network_type==="mainnet");if(u==null)throw new Error("Unknown chain");this.chainData=u;const y=new j.ChainRegistryFetcher;y.fetch(d).then(()=>{this.chainData=y.getChain(this.chainData.chain_name)}).catch(m=>{})}createSigner(n){return U(this,null,function*(){const{bech32AddressPrefix:t,bip39Path:r}=this.networkInfo,s=(0,K.stringToPath)(r);return yield V.DirectSecp256k1HdWallet.fromMnemonic(n,{hdPaths:[s],prefix:t})})}getDisplayPrivateKey(n){return U(this,null,function*(){const{pluginId:t}=this.currencyInfo;return(0,T.yu)(t)(n.keys).mnemonic})}getDisplayPublicKey(n){return U(this,null,function*(){const{keys:t}=(0,T.r3)(n);return t.publicKey})}importPrivateKey(n){return U(this,null,function*(){if(!(0,oe.validateMnemonic)(n))throw new Error("Invalid mnemonic");return yield this.createSigner(n),{[this.networkInfo.pluginMnemonicKeyName]:n}})}createPrivateKey(n){return U(this,null,function*(){if(n!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const t=Fn.from(this.io.random(32)),r=(0,oe.entropyToMnemonic)(t);return yield this.importPrivateKey(r)})}derivePublicKey(n){return U(this,null,function*(){if(n.type!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const{mnemonic:t}=(0,T.yu)(this.currencyInfo.pluginId)(n.keys),s=yield(yield this.createSigner(t)).getAccounts(),{address:o,pubkey:c}=s[0],a=P.xn.stringify(c);return{bech32Address:o,publicKey:a}})}isValidOurAddress(n){try{if((0,L.fromBech32)(n).prefix===this.networkInfo.bech32AddressPrefix)return!0}catch{}return!1}isValidTargetAddress(n){try{const t=(0,L.fromBech32)(n);if(z.Bt.find(s=>s.bech32_prefix===t.prefix)!=null)return!0}catch{}return!1}parseUri(n,t,r){return U(this,null,function*(){const{pluginId:s}=this.currencyInfo,o={[s]:!0},{parsedUri:c,edgeParsedUri:a}=yield(0,S.x)({currencyInfo:this.currencyInfo,uri:n,networks:o,builtinTokens:this.builtinTokens,currencyCode:t!=null?t:this.currencyInfo.currencyCode,customTokens: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 U(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 d=(0,A.FQ)(c!=null?c:this.currencyInfo.currencyCode,this.currencyInfo,r,this.builtinTokens);if(d==null)throw new Error("InternalErrorInvalidCurrencyCode");i=(0,C.div)(o,d.multiplier,18)}return(0,S.m)(t,s,i)})}connectClient(){return U(this,null,function*(){this.clients==null&&(this.clients=yield fe(this.io.fetchCors,de(this.networkInfo.rpcNode,this.initOptions))),++this.clientCount})}disconnectClient(){return U(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 U(this,null,function*(){var t;(0,ee.k9)(n);const{contractAddress:r}=(t=(0,ee.oQ)(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 $n(e){return U(this,null,function*(){return new _e(e)})}function Hn(e,n){return U(this,null,function*(){const t=Jn(n,[]);e.networkInfo=(0,A.wy)(e.networkInfo,t)})}},73776:function(){},77667:function(){},76447:function(){},15340:function(){},79838:function(){}}]);
1
+ (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[7854],{62351:function(tn,se,p){"use strict";p.d(se,{Nn:function(){return Z},Nt:function(){return R},fi:function(){return te},zp:function(){return C}});var ne=p(44276),V=(E,A,S)=>new Promise((_,M)=>{var $=v=>{try{W(S.next(v))}catch(N){M(N)}},P=v=>{try{W(S.throw(v))}catch(N){M(N)}},W=v=>v.done?_(v.value):Promise.resolve(v.value).then($,P);W((S=S.apply(E,A)).next())});const L=["https://info1.edge.app","https://info2.edge.app"];function q(E,A,S){return V(this,arguments,function*(_,M,$,P=5e3,W=fetch){const v=_.map(N=>()=>V(this,null,function*(){const u=yield W(N+"/"+M,$);if(typeof u!="object"){const I=`Invalid return value ${M} in ${N}`;throw console.log(I),new Error(I)}return u}));return yield(0,ne.NN)(v,P)})}function C(E,A,S,_,M=5e3,$){return V(this,null,function*(){const P=yield q((0,ne.R3)(A),S,_,M,$);if(!P.ok){const N=yield P.text();throw console.error(N),new Error(`Error fetching ${S}: ${N}`)}const W=yield P.json();return E(W)})}function ie(E,A,S,_=5e3,M){return V(this,null,function*(){return yield q((0,ne.R3)(E),A,S,_,M)})}const Z=(E,A,S,_)=>V(void 0,null,function*(){return yield ie(L,E,A,S,_)}),R=E=>Object.keys(E).map(A=>{const S=E[A];return S==null?A:`${A}=${encodeURIComponent(S)}`}).join("&"),te=(E,A=5e3)=>E+Math.random()*A*2-A},34931:function(tn,se,p){"use strict";p.r(se),p.d(se,{CosmosTools:function(){return je},makeCurrencyEngine:function(){return st},makeCurrencyTools:function(){return dt},updateInfoPayload:function(){return ut}});var ne=p(11154),V=p(76005),L=p(44917),q=p(5450),C=p(66001),ie=p(90749),Z=p(16856),R=p(65828),te=p(14483),E=p(96542),A=p(44276),S=p(44941),_=p(2666),M=p(86181),$=p(10338),P=p(78824),W=p(15960),v=p(84007),N=p(67112),u=p(99818),I=p(84397),on=p(48287).Buffer,ge=(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 ae=(e,n)=>{const t=(0,I.tx)(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}},rn=(e,n)=>{const{url:t,headers:r}=n;return{execute:s=>ge(void 0,null,function*(){var o;const c={method:"POST",headers:r,body:JSON.stringify(s)},i=yield(yield e(t,c)).json();if((0,W.isJsonRpcErrorResponse)(i))throw new Error(String((o=i.error.data)!=null?o:i.error.message));return i}),disconnect:()=>{}}},sn=e=>ge(void 0,null,function*(){const n=yield N.Comet38Client.create(e),t=(yield n.status()).nodeInfo.version;return t.startsWith("0.38.")?n:t.startsWith("0.37.")?yield N.Tendermint37Client.create(e):yield N.Tendermint34Client.create(e)}),ke=(e,n)=>ge(void 0,null,function*(){const t=yield v.StargateClient.create(yield sn(rn(e,n))),r=t.forceGetCometClient();return{queryClient:v.QueryClient.withExtensions(r,v.setupAuthExtension,v.setupBankExtension,v.setupStakingExtension,v.setupTxExtension,v.setupIbcExtension),stargateClient:t,cometClient:r}}),an=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}},X=e=>e.reduce((n,t)=>{try{return(0,P.addCoins)(n,t)}catch{}return n}),we=(0,u.E8)("amount"),cn=(0,u.E8)("receiver"),ln=(0,u.E8)("spender"),dn=(0,u.E8)("amount","receiver","spender"),un=(0,u.eB)({type:(0,u.E8)("coin_received"),attributes:(0,u.VA)((0,u.eB)({key:we,value:u.oJ}),(0,u.eB)({key:cn,value:u.oJ}))}),hn=(0,u.eB)({type:(0,u.E8)("coin_spent"),attributes:(0,u.VA)((0,u.eB)({key:we,value:u.oJ}),(0,u.eB)({key:ln,value:u.oJ}))}),Te=(e,n)=>{const t=new Map;for(const s of e){const o={type:s.type,attributes:s.attributes.filter(i=>(0,u.HS)(dn)(i.key)!=null).sort((i,l)=>i.key<l.key?-1:1)},c=(0,u.HS)(un)(o);if(c!=null){const[i,l]=c.attributes.map(d=>d.value);if(l!==n)continue;be(i).forEach(d=>{var y;const g=d.amount,m=(y=t.get(d.denom))!=null?y:"0";t.set(d.denom,(0,C.add)(g,m))});continue}const a=(0,u.HS)(hn)(o);if(a!=null){const[i,l]=a.attributes.map(d=>d.value);if(l!==n)continue;be(i).forEach(d=>{var y;const g=`-${d.amount}`,m=(y=t.get(d.denom))!=null?y:"0";t.set(d.denom,(0,C.add)(g,m))})}}const r=[];return t.forEach((s,o)=>{s!=="0"&&r.push({denom:o,amount:s})}),r},ce=e=>{try{return R.xn.parse(e)}catch{return R.K3.parse(e)}},be=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]}}),fn=(e,n)=>{const t=Z.Bt.find(c=>c.bech32_prefix===(0,L.fromBech32)(n).prefix);if(t==null)throw new Error("Unrecognized denom");const r=t.chain_name,s=(0,$.getIbcInfo)(Z.tX,e,r);if(s==null)throw new Error(`No IBC channels between ${e} and ${r}`);const o=(0,$.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}};function mn(e){if(!(()=>(e==null?void 0:e.msgs)!=null&&Array.isArray(e.msgs)&&e.msgs.length===1?e.msgs[0].type==="sign/MsgSignData":!1)())return!1;if(e.chain_id!=="")throw new Error("Chain id should be empty string for ADR-36 signing");if(e.memo!=="")throw new Error("Memo should be empty string for ADR-36 signing");if(e.account_number!=="0")throw new Error('Account number should be "0" for ADR-36 signing');if(e.sequence!=="0")throw new Error('Sequence should be "0" for ADR-36 signing');if(e.fee.gas!=="0")throw new Error('Gas should be "0" for ADR-36 signing');if(e.fee.amount.length!==0)throw new Error("Fee amount should be empty array for ADR-36 signing");const t=e.msgs[0];if(t.type!=="sign/MsgSignData")throw new Error(`Invalid type of ADR-36 sign msg: ${t.type}`);if(t.value==null)throw new Error("Empty value in the msg");const r=t.value.signer;if(r==null)throw new Error("Empty signer in the ADR-36 msg");(0,L.fromBech32)(r);const s=t.value.data;if(s==null)throw new Error("Empty data in the ADR-36 msg");const o=on.from(s,"base64");if(o.toString("base64")!==s)throw new Error("Data is not encoded by base64");if(o.length===0)throw new Error("Empty data in the ADR-36 msg");return!0}var gn=p(28570),F=p.n(gn),yn=p(26946),f=p.n(yn);const ft="common";function Ce(){return{chain:"",symbol:"",ticker:"",synth:!1}}const Y={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=Ce();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:D(e.chain)?globalThis.String(e.chain):"",symbol:D(e.symbol)?globalThis.String(e.symbol):"",ticker:D(e.ticker)?globalThis.String(e.ticker):"",synth:D(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 Y.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,r,s;const o=Ce();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 Ae(){return{asset:void 0,amount:"",decimals:F().ZERO}}const T={encode(e,n=f().Writer.create()){return e.asset!==void 0&&Y.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=Ae();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.asset=Y.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:D(e.asset)?Y.fromJSON(e.asset):void 0,amount:D(e.amount)?globalThis.String(e.amount):"",decimals:D(e.decimals)?F().fromValue(e.decimals):F().ZERO}},toJSON(e){const n={};return e.asset!==void 0&&(n.asset=Y.toJSON(e.asset)),e.amount!==""&&(n.amount=e.amount),e.decimals.isZero()||(n.decimals=(e.decimals||F().ZERO).toString()),n},create(e){return T.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=Ae();return t.asset=e.asset!==void 0&&e.asset!==null?Y.fromPartial(e.asset):void 0,t.amount=(n=e.amount)!=null?n:"",t.decimals=e.decimals!==void 0&&e.decimals!==null?F().fromValue(e.decimals):F().ZERO,t}};function Ie(){return{secp256k1:"",ed25519:""}}const pn={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=Ie();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:D(e.secp256k1)?globalThis.String(e.secp256k1):"",ed25519:D(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 pn.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const r=Ie();return r.secp256k1=(n=e.secp256k1)!=null?n:"",r.ed25519=(t=e.ed25519)!=null?t:"",r}};function Se(){return{id:"",chain:"",fromAddress:"",toAddress:"",coins:[],gas:[],memo:""}}const vn={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)T.encode(t,n.uint32(42).fork()).ldelim();for(const t of e.gas)T.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=Se();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(T.decode(t,t.uint32()));continue;case 6:if(o!==50)break;s.gas.push(T.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:D(e.id)?globalThis.String(e.id):"",chain:D(e.chain)?globalThis.String(e.chain):"",fromAddress:D(e.fromAddress)?globalThis.String(e.fromAddress):"",toAddress:D(e.toAddress)?globalThis.String(e.toAddress):"",coins:globalThis.Array.isArray(e==null?void 0:e.coins)?e.coins.map(n=>T.fromJSON(n)):[],gas:globalThis.Array.isArray(e==null?void 0:e.gas)?e.gas.map(n=>T.fromJSON(n)):[],memo:D(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=>T.toJSON(s))),(t=e.gas)!=null&&t.length&&(r.gas=e.gas.map(s=>T.toJSON(s))),e.memo!==""&&(r.memo=e.memo),r},create(e){return vn.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,r,s,o,c,a;const i=Se();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=>T.fromPartial(l)))||[],i.gas=((c=e.gas)==null?void 0:c.map(l=>T.fromPartial(l)))||[],i.memo=(a=e.memo)!=null?a:"",i}};function xe(){return{coins:[],poolDeduct:""}}const kn={encode(e,n=f().Writer.create()){for(const t of e.coins)T.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=xe();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.coins.push(T.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=>T.fromJSON(n)):[],poolDeduct:D(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=>T.toJSON(r))),e.poolDeduct!==""&&(t.poolDeduct=e.poolDeduct),t},create(e){return kn.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const r=xe();return r.coins=((n=e.coins)==null?void 0:n.map(s=>T.fromPartial(s)))||[],r.poolDeduct=(t=e.poolDeduct)!=null?t:"",r}};function Ee(){return{value:""}}const wn={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=Ee();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:D(e.value)?globalThis.String(e.value):""}},toJSON(e){const n={};return e.value!==""&&(n.value=e.value),n},create(e){return wn.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=Ee();return t.value=(n=e.value)!=null?n:"",t}};f().util.Long!==F()&&(f().util.Long=F(),f().configure());function D(e){return e!=null}const mt="types";function Pe(){return{coins:[],memo:"",signer:new Uint8Array(0)}}const le={encode(e,n=f().Writer.create()){for(const t of e.coins)T.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=Pe();for(;t.pos<r;){const o=t.uint32();switch(o>>>3){case 1:if(o!==10)break;s.coins.push(T.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=>T.fromJSON(n)):[],memo:De(e.memo)?globalThis.String(e.memo):"",signer:De(e.signer)?Tn(e.signer):new Uint8Array(0)}},toJSON(e){var n;const t={};return(n=e.coins)!=null&&n.length&&(t.coins=e.coins.map(r=>T.toJSON(r))),e.memo!==""&&(t.memo=e.memo),e.signer.length!==0&&(t.signer=bn(e.signer)),t},create(e){return le.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,r;const s=Pe();return s.coins=((n=e.coins)==null?void 0:n.map(o=>T.fromPartial(o)))||[],s.memo=(t=e.memo)!=null?t:"",s.signer=(r=e.signer)!=null?r:new Uint8Array(0),s}};function Tn(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 bn(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!==F()&&(f().util.Long=F(),f().configure());function De(e){return e!=null}const gt="cosmos.base.v1beta1";function Oe(){return{denom:"",amount:""}}const j={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=Oe();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:ee(e.denom)?globalThis.String(e.denom):"",amount:ee(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 j.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const r=Oe();return r.denom=(n=e.denom)!=null?n:"",r.amount=(t=e.amount)!=null?t:"",r}};function Be(){return{denom:"",amount:""}}const Cn={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=Be();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:ee(e.denom)?globalThis.String(e.denom):"",amount:ee(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 Cn.fromPartial(e!=null?e:{})},fromPartial(e){var n,t;const r=Be();return r.denom=(n=e.denom)!=null?n:"",r.amount=(t=e.amount)!=null?t:"",r}};function Re(){return{int:""}}const An={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=Re();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:ee(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=Re();return t.int=(n=e.int)!=null?n:"",t}};function Ne(){return{dec:""}}const In={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=Ne();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:ee(e.dec)?globalThis.String(e.dec):""}},toJSON(e){const n={};return e.dec!==""&&(n.dec=e.dec),n},create(e){return In.fromPartial(e!=null?e:{})},fromPartial(e){var n;const t=Ne();return t.dec=(n=e.dec)!=null?n:"",t}};f().util.Long!==F()&&(f().util.Long=F(),f().configure());function ee(e){return e!=null}const yt="types";function Me(){return{fromAddress:new Uint8Array(0),toAddress:new Uint8Array(0),amount:[]}}const de={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)j.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=Me();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(j.decode(t,t.uint32()));continue}if((o&7)===4||o===0)break;t.skipType(o&7)}return s},fromJSON(e){return{fromAddress:Ue(e.fromAddress)?Fe(e.fromAddress):new Uint8Array(0),toAddress:Ue(e.toAddress)?Fe(e.toAddress):new Uint8Array(0),amount:globalThis.Array.isArray(e==null?void 0:e.amount)?e.amount.map(n=>j.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=>j.toJSON(r))),t},create(e){return de.fromPartial(e!=null?e:{})},fromPartial(e){var n,t,r;const s=Me();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=>j.fromPartial(o)))||[],s}};function Fe(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!==F()&&(f().util.Long=F(),f().configure());function Ue(e){return e!=null}var Sn=Object.defineProperty,xn=Object.defineProperties,En=Object.getOwnPropertyDescriptors,Le=Object.getOwnPropertySymbols,Pn=Object.prototype.hasOwnProperty,Dn=Object.prototype.propertyIsEnumerable,_e=(e,n,t)=>n in e?Sn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,On=(e,n)=>{for(var t in n||(n={}))Pn.call(n,t)&&_e(e,t,n[t]);if(Le)for(var t of Le(n))Dn.call(n,t)&&_e(e,t,n[t]);return e},Bn=(e,n)=>xn(e,En(n));const Rn=1e3*60*60*24,Nn=e=>{const n=new q.Registry([["/ibc.applications.transfer.v1.MsgTransfer",M.MsgTransfer],["/cosmwasm.wasm.v1.MsgExecuteContract",_.zM]]);let t=s=>{const{amount:o,fromAddress:c,toAddress:a}=s;return{typeUrl:"/cosmos.bank.v1beta1.MsgSend",value:S.MsgSend.encode(S.MsgSend.fromPartial({fromAddress:c,toAddress:a,amount:o})).finish()}};const r=s=>{const{memo:o,toAddress:c,fromAddress:a,channel:i,port:l,amount:h}=s;return{typeUrl:"/ibc.applications.transfer.v1.MsgTransfer",value:M.MsgTransfer.encode(M.MsgTransfer.fromPartial({memo:o,receiver:c,sender:a,sourceChannel:i,sourcePort:l,token:h,timeoutTimestamp:BigInt((Date.now()+Rn)*1e6)})).finish()}};switch(e){case"thorchainrune":{const s="/types.MsgDeposit";n.register(s,le);const o=a=>{const{assets:i,memo:l,signer:h}=a,d=i.map(g=>Bn(On({},g),{asset:an(g.asset)}));return{typeUrl:s,value:le.encode(le.fromPartial({coins:d,memo:l,signer:(0,L.fromBech32)(h).data})).finish()}},c="/types.MsgSend";return n.register(c,de),t=a=>{const{amount:i,fromAddress:l,toAddress:h}=a;return{typeUrl:c,value:de.encode(de.fromPartial({fromAddress:(0,L.fromBech32)(l).data,toAddress:(0,L.fromBech32)(h).data,amount:i})).finish()}},{methods:{deposit:o,ibcTransfer:r,transfer:t},registry:n}}}return{methods:{ibcTransfer:r,transfer:t},registry:n}};var He=p(1267),J=p(6975),Mn=p(82671),Fn=p(26277),ye=p(62351),Jn=Object.defineProperty,Un=Object.defineProperties,Ln=Object.getOwnPropertyDescriptors,$e=Object.getOwnPropertySymbols,_n=Object.getPrototypeOf,Hn=Object.prototype.hasOwnProperty,$n=Object.prototype.propertyIsEnumerable,Wn=Reflect.get,We=(e,n,t)=>n in e?Jn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,ue=(e,n)=>{for(var t in n||(n={}))Hn.call(n,t)&&We(e,t,n[t]);if($e)for(var t of $e(n))$n.call(n,t)&&We(e,t,n[t]);return e},Ke=(e,n)=>Un(e,Ln(n)),Ve=(e,n,t)=>Wn(_n(e),t,n),x=(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 qe=(0,ye.fi)(2e4),Kn=(0,ye.fi)(2e4),Vn=1e3*60*60*24*14,qn=1e3*60*2,pe=50;class oe extends Fn.k{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.chainId=this.networkInfo.defaultChainId,this.otherMethods={getMaxTx:o=>x(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}),h=this.getBalance({tokenId:null});return(0,C.sub)(h,l)}default:throw new Error(`Invalid type: ${o.type}`)}}),makeTx:o=>x(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}),h=this.createUnsignedTxHex([l],a),{gasFeeCoin:d,gasLimit:y,networkFee:g}=yield this.calculateFee({messages:[l],memo:a}),m={gasFeeCoin:d,gasLimit:y,unsignedTxHex:h};return{blockHeight:0,currencyCode:this.currencyInfo.currencyCode,date:Date.now()/1e3,isSend:!0,memos:[],metadata:i,nativeAmount:`-${g}`,networkFee:g,otherParams:m,ourReceiveAddresses:[],signedTx:"",tokenId:null,txid:"",walletId:this.walletId}}default:throw new Error(`Invalid type: ${o.type}`)}}),parseWalletConnectV2Payload:o=>x(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,I.S4)(o),{authInfoBytes:a,bodyBytes:i}=c.params.signDoc,l=J.TxBody.decode(ce(i)),{nativeAmount:h,tokenId:d}=this.getAmountAndTokenIdFromKnownMessageTypes(l.messages),y=J.AuthInfo.decode(ce(a));let g="0";const m=y.fee;return m!=null&&(g=X([(0,v.coin)("0",this.networkInfo.nativeDenom),...m.amount]).amount),{nativeAmount:h,networkFee:g,tokenId:d}}case"cosmos_signAmino":{const c=(0,I.tV)(o),{signDoc:a}=c.params,i=(0,P.makeSignDoc)(a.msgs,a.fee,a.chain_id,a.memo,a.account_number,a.sequence),l=new v.AminoTypes(ue(ue({},v.createBankAminoConverters),v.createIbcAminoConverters)),h=i.msgs.filter(k=>k.type!=="sign/MsgSignData").map(k=>l.fromAmino(k)),{nativeAmount:d,tokenId:y}=this.getAmountAndTokenIdFromKnownMessageTypes(h);let g="0";const m=a.fee;return m!=null&&(g=X([(0,v.coin)("0",this.networkInfo.nativeDenom),...m.amount]).amount),{nativeAmount:d,networkFee:g,tokenId:y}}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=M.MsgTransfer.fromPartial(c);r===void 0&&(r=this.tokenIdFromDenom(a.token.denom));const i=(0,v.coin)(a.token.amount,a.token.denom);s==null?s=i:s=X([s,i]);break}case"/cosmwasm.wasm.v1.MsgExecuteContract":{const c=this.tools.registry.decode(o),a=_.zM.fromPartial(c),{funds:i}=a;if(i.length>0){const{denom:l}=i[0];r===void 0&&(r=this.tokenIdFromDenom(l));let h=(0,v.coin)("0",l);for(const d of i)h=X([h,d]);s==null?s=h:s=X([s,h])}break}default:}return{nativeAmount:(t=s==null?void 0:s.amount)!=null?t:"0",tokenId:r}}setOtherData(n){this.otherData=(0,I.qd)(n)}getClients(){if(this.tools.clients==null)throw new Error("No StargateClient");return this.tools.clients}queryBalance(){return x(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 h=this.allTokensMap[i],d=r.find(g=>{var m;return g.denom===((m=h.networkLocation)==null?void 0:m.contractAddress)}),y=(l=d==null?void 0:d.amount)!=null?l:"0";this.updateBalance(h.currencyCode,y),(0,C.gt)(y,"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 x(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 x(this,null,function*(){var n;let t=0;const r=[this.currencyInfo.currencyCode,...this.enabledTokenIds.map(o=>this.allTokensMap[o].currencyCode)],s=[];if(this.networkInfo.archiveNodes!=null&&Date.now()-Vn>this.otherData.archivedTxLastCheckTime){const o=this.networkInfo.archiveNodes.sort((c,a)=>c.blockTimeRangeSeconds.start-a.blockTimeRangeSeconds.start);for(const c of o)if(c.blockTimeRangeSeconds.end==null||c.blockTimeRangeSeconds.end>this.otherData.archivedTxLastCheckTime){const a=yield ke(this.fetchCors,ae(c.endpoint,this.tools.initOptions));s.push(a)}}s.push(this.getClients());for(const o of s){let c=0;for(const a of I.b8){const{newestTxid:i,lastTimestamp:l}=yield this.queryTransactionsInner(a,o);i!=null&&((n=this.otherData[a])==null?void 0:n.newestTxid)!==i&&(this.otherData[a]={newestTxid:i},this.walletLocalDataDirty=!0,c=Math.max(c,l)),t+=.5/s.length,r.forEach(h=>this.tokenCheckTransactionsStatus[h]=t),this.updateOnAddressesChecked()}this.otherData.archivedTxLastCheckTime=c,this.walletLocalDataDirty=!0}this.otherData.archivedTxLastCheckTime=Date.now(),this.walletLocalDataDirty=!0,this.transactionsChangedArray.length>0&&(this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[])})}queryTransactionsInner(n,t){return x(this,null,function*(){const r={query:`${n}='${this.walletInfo.keys.bech32Address}'`,per_page:pe,order_by:"asc"};let s,o=0,c=1;do{try{const{totalCount:a,txs:i}=yield t.cometClient.txSearch(Ke(ue({},r),{page:c})),l=i.findIndex(h=>{var d;return(0,L.toHex)(h.hash).toUpperCase()===((d=this.otherData[n])==null?void 0:d.newestTxid)});for(let h=l+1;h<i.length;h++){const d=i[h];if(d==null)break;const y=(0,L.toHex)(d.hash).toUpperCase(),g=d.result.events.map(v.fromTendermintEvent);let m=[];try{m=Te(g,this.walletInfo.keys.bech32Address)}catch(G){this.log.warn("reduceCoinEventsForAddress error:",String(G))}if(m.length===0)continue;const k=yield t.stargateClient.getBlock(d.height),b=(0,N.toSeconds)((0,N.fromRfc3339WithNanoseconds)(k.header.time)).seconds,{height:w,tx:O}=d,z=R.xn.stringify(O),{authInfo:{fee:K},body:{memo:B}}=(0,q.decodeTxRaw)(O);m.forEach(G=>{this.processCosmosTransaction(y,b,z,G,B,w,K)}),s=y,this.otherData[n]={newestTxid:y},o=b*1e3,this.walletLocalDataDirty=!0}if(i.length<pe||a===c*pe)break}catch(a){if(String(a).includes("page should be within"))continue;throw this.log.warn("queryTransactions error:",a),a}c++,this.otherData[n]={newestTxid:s},this.walletLocalDataDirty=!0}while(!0);return{newestTxid:s,lastTimestamp:o}})}processCosmosTransaction(n,t,r,s,o,c,a){const{amount:i,denom:l}=s,h=this.networkInfo.nativeDenom===l;let d;try{d=this.tokenIdFromDenom(l)}catch{return}const{currencyCode:y}=d==null?this.currencyInfo:this.allTokensMap[d];let g="0";if(a!=null){const{amount:K}=a,B=X([(0,v.coin)("0",this.networkInfo.nativeDenom),...K]);g=(0,C.add)(g,B.amount)}const m=(0,C.lt)(i,"0"),k=[];let b=i,w;m?h?b=(0,C.sub)(b,g):(g="0",w=g!=="0"?g:void 0):(k.push(this.walletInfo.keys.bech32Address),g="0");const O=[];o!==""&&O.push({type:"text",value:o});const z={blockHeight:c,currencyCode:y,date:t,isSend:m,memos:O,nativeAmount:b,networkFee:g,ourReceiveAddresses:k,parentNetworkFee:w,signedTx:r,tokenId:d,txid:n,walletId:this.walletId};this.addTransaction(y,z)}addTransaction(n,t){this.removeFromUnconfirmedCache(t.txid),super.addTransaction(n,t)}createUnsignedTxHex(n,t){const r=J.TxBody.fromPartial({messages:n,memo:t}),s=J.TxBody.encode(r).finish(),o=J.TxRaw.fromPartial({bodyBytes:s});return R.xn.stringify(J.TxRaw.encode(o).finish())}addToUnconfirmedCache(n){const t=new Date(new Date().getTime()+qn);this.unconfirmedTransactionCache.txids.size===0&&(this.unconfirmedTransactionCache.cacheSequence=this.sequence),this.unconfirmedTransactionCache.txids.set(n,t)}removeFromUnconfirmedCache(n){this.unconfirmedTransactionCache.txids.has(n)&&(this.unconfirmedTransactionCache.cacheSequence=this.unconfirmedTransactionCache.cacheSequence+1,this.sequence=this.unconfirmedTransactionCache.cacheSequence,this.unconfirmedTransactionCache.txids.delete(n))}getSequence(){return this.unconfirmedTransactionCache.txids.size===0?this.sequence:[...this.unconfirmedTransactionCache.txids.values()].some(n=>n<new Date)?(this.unconfirmedTransactionCache.txids=new Map,this.sequence):this.unconfirmedTransactionCache.cacheSequence+this.unconfirmedTransactionCache.txids.size}calculateFee(n){return x(this,null,function*(){const{queryClient:t}=this.getClients(),{gasInfo:r}=yield t.tx.simulate(n.messages,n.memo,(0,P.encodeSecp256k1Pubkey)(R.xn.parse(this.walletInfo.keys.publicKey)),this.getSequence());if((r==null?void 0:r.gasUsed)==null)throw new Error("simulate didn't return gasUsed ");const s=(0,C.ceil)((0,C.mul)(r==null?void 0:r.gasUsed.toString(),"1.5"),0),{low:o,average:c,high:a}=(0,$.getGasPriceStep)(this.tools.chainData);let i=c;switch(n.networkFeeOption){case"low":{i=o;break}case"high":{i=a;break}case"custom":throw new Error("Custom fee not supported")}const l=(0,C.ceil)((0,C.mul)(s,i.toString()),0),h=(0,v.coin)(l,this.networkInfo.nativeDenom);return{gasFeeCoin:h,gasLimit:s,networkFee:h.amount}})}startEngine(){return x(this,null,function*(){this.engineOn=!0,yield this.tools.connectClient(),this.addToLoop("queryBalance",qe).catch(()=>{}),this.addToLoop("queryBlockheight",qe).catch(()=>{}),this.addToLoop("queryTransactions",Kn).catch(()=>{}),yield Ve(oe.prototype,this,"startEngine").call(this)})}killEngine(){return x(this,null,function*(){yield this.tools.disconnectClient(),yield Ve(oe.prototype,this,"killEngine").call(this)})}resyncBlockchain(){return x(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}validateTransfer(n,t,r){return x(this,null,function*(){var s;if(t==null)return;const o=this.allTokensMap[t],c=(0,te.oQ)(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 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 x(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:h,publicAddress:d}=s.spendTargets[0];if(h==null)throw new Mn.ef;if(d==null)throw new Error("makeSpend Missing publicAddress");const y=i!=null?(r=this.allTokensMap[i].networkLocation)==null?void 0:r.contractAddress:this.networkInfo.nativeDenom;if(y==null)throw new Error("Unknown denom");let g;if(this.networkInfo.bech32AddressPrefix!==(0,L.fromBech32)(d).prefix){const H=fn(this.tools.chainData.chain_name,d);yield this.validateTransfer(d,i,H);const{channel:re,port:fe}=H;g=this.tools.methods.ibcTransfer({channel:re,port:fe,memo:l,amount:(0,v.coin)(h,y),fromAddress:this.walletInfo.keys.bech32Address,toAddress:d})}else g=this.tools.methods.transfer({amount:[(0,v.coin)(h,y)],fromAddress:this.walletInfo.keys.bech32Address,toAddress:d});let m,k,b;const w=`${d}${String(a)}`,O=this.feeCache.get(w);if(h==="0")m=(0,v.coin)("0",this.networkInfo.nativeDenom),k="0",b="0";else if(O==null){const H=yield this.calculateFee({messages:[g],memo:l,networkFeeOption:a});m=H.gasFeeCoin,k=H.gasLimit,b=H.networkFee,this.feeCache.set(w,H)}else m=O.gasFeeCoin,k=O.gasLimit,b=O.networkFee;const z=this.createUnsignedTxHex([g],l),K={gasFeeCoin:m,gasLimit:k,unsignedTxHex:z},B=this.makeEdgeTransactionAmounts(h,b,i);return this.checkBalances(B,i),{blockHeight:0,currencyCode:o,date:0,isSend:!0,memos:c,nativeAmount:B.nativeAmount,networkFee:B.networkFee,otherParams:K,ourReceiveAddresses:[],parentNetworkFee:B.parentNetworkFee,signedTx:"",tokenId:i,txid:"",walletId:this.walletId}})}signMessage(n,t,r){return x(this,null,function*(){const s=(0,I.yu)(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,I.yt)(r.otherParams);const m=(yield o.getAccounts()).map(k=>Ke(ue({},k),{pubkey:R.K3.stringify(k.pubkey)}));return JSON.stringify(m)}case"cosmos_signDirect":{const g=(0,I.S4)(r.otherParams),{signDoc:m}=g.params,k=J.SignDoc.fromPartial({accountNumber:(0,He.longify)(m.accountNumber),authInfoBytes:ce(m.authInfoBytes),bodyBytes:ce(m.bodyBytes),chainId:m.chainId}),w={signature:(yield o.signDirect(this.walletInfo.keys.bech32Address,k)).signature,signed:g.params.signDoc};return JSON.stringify(w)}case"cosmos_signAmino":{const g=(0,I.tV)(r.otherParams),{signDoc:m}=g.params,k=(0,P.makeSignDoc)(m.msgs,m.fee,m.chain_id,m.memo,m.account_number,m.sequence);mn(k);const{bech32AddressPrefix:b,bip39Path:w}=this.networkInfo,O=(0,V.stringToPath)(w),B={signature:(yield(yield P.Secp256k1HdWallet.fromMnemonic(o.mnemonic,{prefix:b,hdPaths:[O]})).signAmino(this.walletInfo.keys.bech32Address,k)).signature,signed:m};return JSON.stringify(B)}default:throw new Error(`Invalid method: ${r.method}`)}const c=R.xn.parse(n),a=J.SignDoc.decode(c),i=yield o.signDirect(this.walletInfo.keys.bech32Address,a),l=(0,P.decodeSignature)(i.signature),h=J.TxRaw.fromPartial({authInfoBytes:a.authInfoBytes,bodyBytes:a.bodyBytes,signatures:[l.signature]}),d=J.TxRaw.encode(h).finish();return R.xn.stringify(d)})}signTx(n,t){return x(this,null,function*(){const{gasFeeCoin:r,gasLimit:s,unsignedTxHex:o}=(0,I.TG)(n.otherParams),c=(0,I.yu)(this.currencyInfo.pluginId)(t),a=R.xn.parse(o),{bodyBytes:i}=J.TxRaw.decode(a),l=R.xn.parse(this.walletInfo.keys.publicKey),h=(0,P.encodeSecp256k1Pubkey)(l),d=(0,q.makeAuthInfoBytes)([{pubkey:(0,q.encodePubkey)(h),sequence:this.getSequence()}],[r],parseInt(s),void 0,void 0,1),y=J.SignDoc.fromPartial({accountNumber:(0,He.longify)(this.accountNumber),authInfoBytes:d,bodyBytes:i,chainId:this.chainId}),m=yield(yield this.tools.createSigner(c.mnemonic)).signDirect(this.walletInfo.keys.bech32Address,y),k=(0,P.decodeSignature)(m.signature),b=J.TxRaw.fromPartial({authInfoBytes:d,bodyBytes:i,signatures:[k.signature]}),w=J.TxRaw.encode(b).finish(),O=R.xn.stringify(w);return n.signedTx=O,n})}broadcastTx(n){return x(this,null,function*(){try{const t=R.xn.parse(n.signedTx),{stargateClient:r}=this.getClients(),s=yield r.broadcastTxSync(t);return this.warn(`SUCCESS broadcastTx
2
+ ${(0,A.T5)(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 x(this,null,function*(){const{bech32Address:t}=this.walletInfo.keys;return{publicAddress:t}})}}function ze(e){return e.currencyInfo.pluginId==="thorchainrune"}const zn=(0,u.eB)({result:(0,u.eB)({node_info:(0,u.eB)({network:u.oJ})})}),Qe=(0,u.eB)({address:u.oJ,coins:(0,u._j)((0,u.eB)({amount:u.oJ,asset:u.oJ})),txID:u.oJ}),Qn=(0,u.eB)({actions:(0,u._j)((0,u.eB)({date:u.oJ,height:u.oJ,in:(0,u._j)(Qe),metadata:(0,u.eB)((0,u.eB)({memo:u.oJ,networkFees:(0,u._j)((0,u.eB)({amount:u.oJ,asset:u.oJ}))})),out:(0,u._j)(Qe)})),meta:(0,u.eB)({nextPageToken:u.oJ})}),Gn=(0,u.eB)({midgardTxQueryParams:(0,u.HS)((0,u.eB)({mostRecentHeight:u.oJ,mostRecentTxId:u.oJ}),()=>({mostRecentHeight:"0",mostRecentTxId:""}))}),Zn=(0,u.eB)({native_outbound_fee_rune:u.oJ,native_tx_fee_rune:u.oJ});var Xn=Object.defineProperty,Ge=Object.getOwnPropertySymbols,Yn=Object.getPrototypeOf,jn=Object.prototype.hasOwnProperty,et=Object.prototype.propertyIsEnumerable,nt=Reflect.get,Ze=(e,n,t)=>n in e?Xn(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,Xe=(e,n)=>{for(var t in n||(n={}))jn.call(n,t)&&Ze(e,t,n[t]);if(Ge)for(var t of Ge(n))et.call(n,t)&&Ze(e,t,n[t]);return e},tt=(e,n,t)=>nt(Yn(e),t,n),he=(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 ot=(0,ye.fi)(2e4);class ve extends oe{constructor(n,t,r,s){super(n,t,r,s),this.networkInfo=n.networkInfo}setOtherData(n){const t=(0,I.qd)(n),r=Gn(n);this.otherData=Xe(Xe({},t),r)}queryChainId(){return he(this,null,function*(){try{const n=yield this.fetchCors(this.networkInfo.chainIdUpdateUrl);if(!n.ok){const s=yield n.text();throw new Error(s)}const t=yield n.json(),r=zn(t);this.chainId=r.result.node_info.network,clearTimeout(this.timers.queryChainId)}catch(n){this.error("queryChainId Error ",n)}})}queryTransactions(){return he(this,null,function*(){const n=[this.currencyInfo.currencyCode,...this.enabledTokenIds.map(y=>this.allTokensMap[y].currencyCode)],{url:t,headers:r}=ae(this.networkInfo.midgardConnctionInfo,this.tools.initOptions),s=`${t}/v2/actions?address=${this.walletInfo.keys.bech32Address}`,{mostRecentHeight:o,mostRecentTxId:c}=this.otherData.midgardTxQueryParams,a=o;let i,l=o,h=c,d=!1;for(;;){try{const y=`&fromHeight=${a}`,g=i!=null?`&nextPageToken=${i}`:"",m=yield this.fetchCors(`${s}${y}${g}`,r);if(!m.ok){const w=yield m.text();throw new Error(w)}const k=yield m.json(),b=Qn(k);if(b.actions.length===0||b.meta.nextPageToken==="")break;i=b.meta.nextPageToken;for(const w of b.actions){l=(0,C.max)(l,w.height);const O=parseInt((0,C.div)(w.date,"1000000000")),{memo:z,networkFees:K}=Object.values(w.metadata)[0];let B="";const G=[],H=(Q,en)=>{for(const me of Q){me.txID.length>B.length&&(B=me.txID);for(const nn of me.coins){if(nn.asset!=="THOR.RUNE")continue;const ht=en==="coin_received"?"receiver":"spender";G.push({type:en,attributes:[{key:"amount",value:`${(0,C.abs)(nn.amount)}rune`},{key:ht,value:me.address}]})}}};if(H(w.in,"coin_spent"),H(w.out,"coin_received"),B===c){d=!0;break}h===c&&(h=B);let re=[];try{re=Te(G,this.walletInfo.keys.bech32Address)}catch(Q){this.log.warn("reduceCoinEventsForAddress error:",String(Q))}if(re.length===0)continue;const fe={amount:[],gasLimit:BigInt(0),payer:"",granter:""};for(const Q of K)Q.asset==="THOR.RUNE"&&fe.amount.push({denom:"rune",amount:Q.amount});re.forEach(Q=>{this.processCosmosTransaction(B,O,"",Q,z,parseInt(w.height),fe)})}}catch(y){this.log.warn("queryTransactionsMidgard error:",y)}if(d)break}(l!==o||h!==c)&&(this.otherData.midgardTxQueryParams.mostRecentHeight=l,this.otherData.midgardTxQueryParams.mostRecentTxId=h!=null?h:"",this.walletLocalDataDirty=!0),n.forEach(y=>this.tokenCheckTransactionsStatus[y]=1),this.updateOnAddressesChecked(),this.transactionsChangedArray.length>0&&(this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[])})}calculateFee(n){return he(this,null,function*(){const{url:t,headers:r}=ae(this.networkInfo.transactionFeeConnectionInfo,this.tools.initOptions),o=yield(yield this.fetchCors(t,{method:"GET",headers:r})).json(),c=Zn(o);let a="0";for(const i of n.messages)switch(i.typeUrl){case"/types.MsgDeposit":a=(0,C.add)(a,c.native_outbound_fee_rune);break;case"/types.MsgSend":a=(0,C.add)(a,c.native_tx_fee_rune)}return{gasFeeCoin:(0,v.coin)("0",this.networkInfo.nativeDenom),gasLimit:"0",networkFee:(0,C.mul)(a,"1.01")}})}startEngine(){return he(this,null,function*(){yield tt(ve.prototype,this,"startEngine").call(this),this.addToLoop("queryChainId",ot).catch(()=>{})})}}var rt=(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())});function st(e,n,t,r){return rt(this,null,function*(){const s=(0,I.r3)(t);console.debug("isThorchainEnvironment",ze(e));const o=ze(e)?new ve(e,n,s,r):new oe(e,n,s,r);return yield o.loadEngine(),o})}var it=p(48287).Buffer,Ye=Object.getOwnPropertySymbols,at=Object.prototype.hasOwnProperty,ct=Object.prototype.propertyIsEnumerable,lt=(e,n)=>{var t={};for(var r in e)at.call(e,r)&&n.indexOf(r)<0&&(t[r]=e[r]);if(e!=null&&Ye)for(var r of Ye(e))n.indexOf(r)<0&&ct.call(e,r)&&(t[r]=e[r]);return t},U=(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 je{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}=Nn(r.pluginId);this.methods=a,this.registry=i;const{chainName:l,url:h}=this.networkInfo.chainInfo,d=Z.Bt.find(g=>g.chain_name===l&&g.network_type==="mainnet");if(d==null)throw new Error("Unknown chain");this.chainData=d;const y=new ne.ChainRegistryFetcher;y.fetch(h).then(()=>{this.chainData=y.getChain(this.chainData.chain_name)}).catch(g=>{})}createSigner(n){return U(this,null,function*(){const{bech32AddressPrefix:t,bip39Path:r}=this.networkInfo,s=(0,V.stringToPath)(r);return yield q.DirectSecp256k1HdWallet.fromMnemonic(n,{hdPaths:[s],prefix:t})})}getDisplayPrivateKey(n){return U(this,null,function*(){const{pluginId:t}=this.currencyInfo;return(0,I.yu)(t)(n.keys).mnemonic})}getDisplayPublicKey(n){return U(this,null,function*(){const{keys:t}=(0,I.r3)(n);return t.publicKey})}importPrivateKey(n){return U(this,null,function*(){if(!(0,ie.validateMnemonic)(n))throw new Error("Invalid mnemonic");return yield this.createSigner(n),{[this.networkInfo.pluginMnemonicKeyName]:n}})}createPrivateKey(n){return U(this,null,function*(){if(n!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const t=it.from(this.io.random(32)),r=(0,ie.entropyToMnemonic)(t);return yield this.importPrivateKey(r)})}derivePublicKey(n){return U(this,null,function*(){if(n.type!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const{mnemonic:t}=(0,I.yu)(this.currencyInfo.pluginId)(n.keys),s=yield(yield this.createSigner(t)).getAccounts(),{address:o,pubkey:c}=s[0],a=R.xn.stringify(c);return{bech32Address:o,publicKey:a}})}isValidOurAddress(n){try{if((0,L.fromBech32)(n).prefix===this.networkInfo.bech32AddressPrefix)return!0}catch{}return!1}isValidTargetAddress(n){try{const t=(0,L.fromBech32)(n);if(Z.Bt.find(s=>s.bech32_prefix===t.prefix)!=null)return!0}catch{}return!1}parseUri(n,t,r){return U(this,null,function*(){const{pluginId:s}=this.currencyInfo,o={[s]:!0},{parsedUri:c,edgeParsedUri:a}=yield(0,E.x)({currencyInfo:this.currencyInfo,uri:n,networks:o,builtinTokens:this.builtinTokens,currencyCode:t!=null?t:this.currencyInfo.currencyCode,customTokens: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 U(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 h=(0,A.FQ)(c!=null?c:this.currencyInfo.currencyCode,this.currencyInfo,r,this.builtinTokens);if(h==null)throw new Error("InternalErrorInvalidCurrencyCode");i=(0,C.div)(o,h.multiplier,18)}return(0,E.m)(t,s,i)})}connectClient(){return U(this,null,function*(){this.clients==null&&(this.clients=yield ke(this.io.fetchCors,ae(this.networkInfo.rpcNode,this.initOptions))),++this.clientCount})}disconnectClient(){return U(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 U(this,null,function*(){var t;(0,te.k9)(n);const{contractAddress:r}=(t=(0,te.oQ)(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 dt(e){return U(this,null,function*(){return new je(e)})}function ut(e,n){return U(this,null,function*(){const t=lt(n,[]);e.networkInfo=(0,A.wy)(e.networkInfo,t)})}},73776:function(){},77667:function(){},76447:function(){},15340:function(){},79838:function(){}}]);