edge-currency-accountbased 2.2.3 → 2.2.5

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 (76) hide show
  1. package/CHANGELOG.md +14 -0
  2. package/android/src/main/assets/edge-currency-accountbased/1944.chunk.js +4 -0
  3. package/android/src/main/assets/edge-currency-accountbased/2153.chunk.js +2 -0
  4. package/android/src/main/assets/edge-currency-accountbased/2821.chunk.js +2 -0
  5. package/android/src/main/assets/edge-currency-accountbased/2896.chunk.js +35 -0
  6. package/android/src/main/assets/edge-currency-accountbased/2945.chunk.js +25 -0
  7. package/android/src/main/assets/edge-currency-accountbased/3491.chunk.js +1 -0
  8. package/android/src/main/assets/edge-currency-accountbased/{620.chunk.js → 3620.chunk.js} +1 -1
  9. package/android/src/main/assets/edge-currency-accountbased/{666.chunk.js → 3666.chunk.js} +1 -1
  10. package/android/src/main/assets/edge-currency-accountbased/3720.chunk.js +1 -0
  11. package/android/src/main/assets/edge-currency-accountbased/{978.chunk.js → 3978.chunk.js} +1 -1
  12. package/android/src/main/assets/edge-currency-accountbased/4251.chunk.js +4 -0
  13. package/android/src/main/assets/edge-currency-accountbased/4431.chunk.js +1 -0
  14. package/android/src/main/assets/edge-currency-accountbased/4618.chunk.js +20 -0
  15. package/android/src/main/assets/edge-currency-accountbased/{627.chunk.js → 4627.chunk.js} +1 -1
  16. package/android/src/main/assets/edge-currency-accountbased/4650.chunk.js +1 -0
  17. package/android/src/main/assets/edge-currency-accountbased/{826.chunk.js → 5179.chunk.js} +1 -1
  18. package/android/src/main/assets/edge-currency-accountbased/{835.chunk.js → 5835.chunk.js} +1 -1
  19. package/android/src/main/assets/edge-currency-accountbased/5836.chunk.js +1 -0
  20. package/android/src/main/assets/edge-currency-accountbased/6266.chunk.js +1 -0
  21. package/android/src/main/assets/edge-currency-accountbased/6291.chunk.js +58 -0
  22. package/android/src/main/assets/edge-currency-accountbased/6341.chunk.js +44 -0
  23. package/android/src/main/assets/edge-currency-accountbased/7221.chunk.js +1 -0
  24. package/android/src/main/assets/edge-currency-accountbased/7428.chunk.js +6 -0
  25. package/android/src/main/assets/edge-currency-accountbased/{481.chunk.js → 7481.chunk.js} +1 -1
  26. package/android/src/main/assets/edge-currency-accountbased/7542.chunk.js +1 -0
  27. package/android/src/main/assets/edge-currency-accountbased/7786.chunk.js +2 -0
  28. package/android/src/main/assets/edge-currency-accountbased/8190.chunk.js +1 -0
  29. package/android/src/main/assets/edge-currency-accountbased/{689.chunk.js → 8689.chunk.js} +1 -1
  30. package/android/src/main/assets/edge-currency-accountbased/{726.chunk.js → 8726.chunk.js} +1 -1
  31. package/android/src/main/assets/edge-currency-accountbased/9068.chunk.js +1 -0
  32. package/android/src/main/assets/edge-currency-accountbased/{223.chunk.js → 9223.chunk.js} +2 -2
  33. package/android/src/main/assets/edge-currency-accountbased/9539.chunk.js +10 -0
  34. package/android/src/main/assets/edge-currency-accountbased/{645.chunk.js → 9645.chunk.js} +6 -6
  35. package/android/src/main/assets/edge-currency-accountbased/9669.chunk.js +7 -0
  36. package/android/src/main/assets/edge-currency-accountbased/algorand.chunk.js +1 -1
  37. package/android/src/main/assets/edge-currency-accountbased/bnb.chunk.js +2 -2
  38. package/android/src/main/assets/edge-currency-accountbased/edge-currency-accountbased.js +2 -18
  39. package/android/src/main/assets/edge-currency-accountbased/eos.chunk.js +5 -5
  40. package/android/src/main/assets/edge-currency-accountbased/ethereum.chunk.js +2 -2
  41. package/android/src/main/assets/edge-currency-accountbased/filecoin.chunk.js +1 -1
  42. package/android/src/main/assets/edge-currency-accountbased/fio.chunk.js +2 -2
  43. package/android/src/main/assets/edge-currency-accountbased/hedera.chunk.js +2 -2
  44. package/android/src/main/assets/edge-currency-accountbased/polkadot.chunk.js +2 -2
  45. package/android/src/main/assets/edge-currency-accountbased/ripple.chunk.js +2 -2
  46. package/android/src/main/assets/edge-currency-accountbased/solana.chunk.js +2 -2
  47. package/android/src/main/assets/edge-currency-accountbased/stellar.chunk.js +2 -2
  48. package/android/src/main/assets/edge-currency-accountbased/tezos.chunk.js +2 -2
  49. package/android/src/main/assets/edge-currency-accountbased/tron.chunk.js +1 -1
  50. package/android/src/main/assets/edge-currency-accountbased/zcash.chunk.js +2 -2
  51. package/lib/ethereum/info/avalancheInfo.js +8 -0
  52. package/lib/ethereum/info/ethereumInfo.js +8 -0
  53. package/lib/filecoin/FilecoinEngine.js +112 -79
  54. package/lib/filecoin/Filfox.js +68 -1
  55. package/lib/filecoin/filecoinInfo.js +8 -3
  56. package/lib/filecoin/filecoinTypes.js +1 -6
  57. package/lib/zcash/ZcashEngine.js +11 -9
  58. package/package.json +1 -1
  59. package/android/src/main/assets/edge-currency-accountbased/124.chunk.js +0 -35
  60. package/android/src/main/assets/edge-currency-accountbased/17.chunk.js +0 -58
  61. package/android/src/main/assets/edge-currency-accountbased/190.chunk.js +0 -1
  62. package/android/src/main/assets/edge-currency-accountbased/221.chunk.js +0 -1
  63. package/android/src/main/assets/edge-currency-accountbased/298.chunk.js +0 -44
  64. package/android/src/main/assets/edge-currency-accountbased/431.chunk.js +0 -1
  65. package/android/src/main/assets/edge-currency-accountbased/491.chunk.js +0 -1
  66. package/android/src/main/assets/edge-currency-accountbased/539.chunk.js +0 -10
  67. package/android/src/main/assets/edge-currency-accountbased/542.chunk.js +0 -1
  68. package/android/src/main/assets/edge-currency-accountbased/618.chunk.js +0 -20
  69. package/android/src/main/assets/edge-currency-accountbased/650.chunk.js +0 -1
  70. package/android/src/main/assets/edge-currency-accountbased/68.chunk.js +0 -1
  71. package/android/src/main/assets/edge-currency-accountbased/720.chunk.js +0 -1
  72. package/android/src/main/assets/edge-currency-accountbased/786.chunk.js +0 -2
  73. package/android/src/main/assets/edge-currency-accountbased/836.chunk.js +0 -1
  74. package/android/src/main/assets/edge-currency-accountbased/935.chunk.js +0 -1
  75. package/android/src/main/assets/edge-currency-accountbased/944.chunk.js +0 -4
  76. package/android/src/main/assets/edge-currency-accountbased/945.chunk.js +0 -25
@@ -1,3 +1,3 @@
1
- (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[92],{19156:function(U,T,f){"use strict";f.r(T),f.d(T,{TezosTools:function(){return L},makeCurrencyEngine:function(){return $},makeCurrencyTools:function(){return F}});var h=f(19971),I=f(39143),l=f(82448),O=f(62177);const D=(0,l.su)({numberTransactions:(0,l.Vk)(l.mH,0)}),P=(0,l.su)({level:l.mH,timestamp:l.XC,hash:l.XC,sender:(0,l.su)({address:l.XC}),bakerFee:l.mH,allocationFee:l.mH,target:(0,l.su)({address:l.XC}),amount:l.mH,status:l.XC}),b=(0,O.jd)((0,l.su)({publicKey:l.XC,publicKeyEd:l.XC})),E=(0,l.su)({mnemonic:l.XC,privateKey:l.XC});var k=f(77591),z=f(94935),K=f(84650),d=f(76714),N=f(81649),B=Object.getPrototypeOf,R=Reflect.get,S=(y,t,e)=>R(B(y),e,t),a=(y,t,e)=>new Promise((r,n)=>{var s=c=>{try{o(e.next(c))}catch(u){n(u)}},i=c=>{try{o(e.throw(c))}catch(u){n(u)}},o=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,i);o((e=e.apply(y,t)).next())});const X=15e3,x=3e4,H=5e3,j=(0,d.jT)(),A=N.j.currencyCode;class w extends K.P{constructor(t,e,r,n){super(t,e,r,n),this.walletInfo=b(r),this.networkInfo=t.networkInfo,this.fetchCors=(0,d.zR)(t.io)}setOtherData(t){this.otherData=D(t)}multicastServers(t,...e){return a(this,null,function*(){let r={result:"",server:"no server"},n;switch(t){case"getHead":{n=this.tools.tezosRpcNodes.map(i=>()=>a(this,null,function*(){const o=yield this.fetchCors(i+"/chains/main/blocks/head/header").then(function(c){return a(this,null,function*(){return yield c.json()})}).then(function(c){return c});return{server:i,result:o}})),r=yield(0,d.QJ)(n);break}case"getBalance":{n=this.tools.tezosRpcNodes.map(i=>()=>a(this,null,function*(){h.eztz.node.setProvider(i);const o=yield h.eztz.rpc.getBalance(e[0]);return{server:i,result:o}})),r=yield(0,d.QJ)(n);break}case"getNumberOfOperations":n=this.tools.tezosApiServers.map(s=>()=>a(this,null,function*(){const i=yield this.fetchCors(`${s}/v1/accounts/${e[0]}`).then(function(o){return a(this,null,function*(){return yield o.json()})}).then(function(o){return o.numTransactions});return{server:s,result:i}})),r=yield(0,d.QJ)(n);break;case"getTransactions":n=this.tools.tezosApiServers.map(s=>()=>a(this,null,function*(){const i=s.includes("tzkt")?"":`&p='${e[1]}&number=50`,o=yield this.fetchCors(`${s}/v1/accounts/${e[0]}/operations?type=transaction`+i).then(function(c){return a(this,null,function*(){return yield c.json()})});return{server:s,result:o}})),r=yield(0,d.QJ)(n);break;case"createTransaction":n=this.tools.tezosRpcNodes.map(s=>()=>a(this,null,function*(){h.eztz.node.setProvider(s);const i=yield h.eztz.rpc.transfer(e[0],e[1],e[2],e[3],e[4],null,this.networkInfo.limit.gas,this.networkInfo.limit.storage,this.networkInfo.fee.reveal).then(function(o){return o});return{server:s,result:i}})),r=yield(0,d.QJ)(n);break;case"injectOperation":{let s="";n=this.tools.tezosRpcNodes.map(i=>()=>a(this,null,function*(){h.eztz.node.setProvider(i);const o=yield h.eztz.rpc.inject(e[0],e[1]).catch(c=>{this.error("Error when injection operation: ",c);const u=this.formatError(c);throw!s&&u!==""&&(s=u),c});return this.multicastServers("silentInjection",i,e[1]),{server:i,result:o}})),r=yield(0,d.QJ)(n).catch(i=>{throw this.error("Error from waterfall: ",i),s!==""?new Error(s):i});break}case"silentInjection":{const s=this.tools.tezosRpcNodes.indexOf(e[0]),i=this.tools.tezosRpcNodes.slice(s+1);r=yield(0,d.Wp)(i.map(o=>a(this,null,function*(){h.eztz.node.setProvider(o);const c=yield h.eztz.rpc.silentInject(e[1]);return this.warn(`Injected silently to: ${o}`),{server:o,result:c}})));break}}return this.log(`XTZ multicastServers ${t} ${r.server} won with result ${r.result}`),r.result})}formatError(t){if(typeof t=="string")return t;try{if(t.error&&t.error==="Operation Failed"&&t.errors&&t.errors[0].id)return"Failed in preapply with an error code ("+t.errors[0].id+")";if(t[0]&&t[0].kind&&t[0].kind==="branch"&&t[0].id)return"Failed in preapply with an error code ("+t[0].id+")"}catch{}return""}processTezosTransaction(t){const e=P(t),r=this.walletLocalData.publicKey,n=[],s=A,i=new Date(e.timestamp).getTime()/1e3,o=e.level;let c=e.amount.toString();const u=(e.bakerFee+e.allocationFee).toString(),C=e.status==="failed";r===e.target.address?(n.push(r),e.sender.address===r&&(c="-"+u)):c="-"+(0,k.add)(c,u);const v={txid:t.hash,date:i,currencyCode:s,blockHeight:o,nativeAmount:c,isSend:c.startsWith("-"),networkFee:u,ourReceiveAddresses:n,signedTx:"",otherParams:{},walletId:this.walletId};C||this.addTransaction(s,v)}checkTransactionsInnerLoop(){return a(this,null,function*(){const t=this.walletLocalData.publicKey;this.otherData.numberTransactions||(this.otherData.numberTransactions=0);const e=yield this.multicastServers("getNumberOfOperations",t);if(e!==this.otherData.numberTransactions){let r=[],n=0,s;this.tokenCheckTransactionsStatus.XTZ=.5;do s=yield this.multicastServers("getTransactions",t,n++),r=r.concat(s);while(s.length>0&&n<10);for(const i of r)this.processTezosTransaction(i);this.transactionsChangedArray.length>0&&(this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[]),this.otherData.numberTransactions=e,this.walletLocalDataDirty=!0}this.tokenCheckTransactionsStatus.XTZ=1,this.updateOnAddressesChecked()})}checkUnconfirmedTransactionsFetch(){return a(this,null,function*(){})}checkAccountInnerLoop(){return a(this,null,function*(){const t=A,e=this.walletLocalData.publicKey;typeof this.walletLocalData.totalBalances[t]>"u"&&(this.walletLocalData.totalBalances[t]="0");const r=yield this.multicastServers("getBalance",e);this.updateBalance(t,r)})}checkBlockchainInnerLoop(){return a(this,null,function*(){const e=(yield this.multicastServers("getHead")).level;this.walletLocalData.blockHeight!==e&&(this.walletLocalData.blockHeight=e,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight))})}clearBlockchainCache(){return a(this,null,function*(){yield S(w.prototype,this,"clearBlockchainCache").call(this)})}isBurn(t){return a(this,null,function*(){return t.kind==="origination"||t.kind==="transaction"&&t.destination.slice(0,2)==="tz"&&(yield this.multicastServers("getBalance",t.destination))==="0"})}startEngine(){return a(this,null,function*(){this.engineOn=!0,this.addToLoop("checkBlockchainInnerLoop",x),this.addToLoop("checkAccountInnerLoop",X),this.addToLoop("checkTransactionsInnerLoop",H),S(w.prototype,this,"startEngine").call(this)})}resyncBlockchain(){return a(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}makeSpend(t){return a(this,null,function*(){return yield j(()=>a(this,null,function*(){return yield this.makeSpendInner(t)}))})}makeSpendInner(t){return a(this,null,function*(){const{edgeSpendInfo:e,currencyCode:r,nativeBalance:n,denom:s}=this.makeSpendCheck(t);if(e.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{publicAddress:i}=e.spendTargets[0];let{nativeAmount:o}=e.spendTargets[0];if(i==null)throw new Error("makeSpend Missing publicAddress");if(o==null)throw new z.$D;if((0,k.eq)(o,"0"))throw new z.$D;const c={pk:this.walletInfo.keys.publicKeyEd,pkh:this.walletInfo.keys.publicKey,sk:!1};let u,C=0,v;do try{u=yield this.multicastServers("createTransaction",c.pkh,c,i,(0,k.div)(o,s.multiplier,6),this.networkInfo.fee.transaction)}catch(g){v=g}while((typeof u>"u"||u.opOb.contents.length>2)&&C++<5);if(typeof u>"u")throw v;let m="0";for(const g of u.opOb.contents)m=(0,k.add)(m,g.fee),(yield this.isBurn(g))&&(m=(0,k.add)(m,this.networkInfo.fee.burn));if(o=(0,k.add)(o,m),(0,k.gt)(o,n))throw new z.C_;return o="-"+o,{txid:"",date:0,currencyCode:r,blockHeight:0,nativeAmount:o,isSend:o.startsWith("-"),networkFee:m,ourReceiveAddresses:[],signedTx:"",otherParams:{idInternal:0,fromAddress:this.walletLocalData.publicKey,toAddress:i,fullOp:u},walletId:this.walletId}})}signTx(t,e){return a(this,null,function*(){const r=E(e),n=(0,d.Xp)(t);if(t.signedTx===""){const s=r.privateKey,i=h.eztz.crypto.sign(n.fullOp.opbytes,s,h.eztz.watermark.generic);n.fullOp.opbytes=i.sbytes,n.fullOp.opOb.signature=i.edsig,t.signedTx=i.sbytes}return this.warn(`signTx
1
+ (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[4092],{19156:function(U,T,f){"use strict";f.r(T),f.d(T,{TezosTools:function(){return L},makeCurrencyEngine:function(){return $},makeCurrencyTools:function(){return F}});var h=f(19971),I=f(39143),l=f(82448),O=f(62177);const D=(0,l.su)({numberTransactions:(0,l.Vk)(l.mH,0)}),P=(0,l.su)({level:l.mH,timestamp:l.XC,hash:l.XC,sender:(0,l.su)({address:l.XC}),bakerFee:l.mH,allocationFee:l.mH,target:(0,l.su)({address:l.XC}),amount:l.mH,status:l.XC}),b=(0,O.jd)((0,l.su)({publicKey:l.XC,publicKeyEd:l.XC})),E=(0,l.su)({mnemonic:l.XC,privateKey:l.XC});var k=f(77591),z=f(94935),K=f(84650),d=f(76714),N=f(81649),B=Object.getPrototypeOf,R=Reflect.get,S=(y,t,e)=>R(B(y),e,t),a=(y,t,e)=>new Promise((r,n)=>{var s=c=>{try{o(e.next(c))}catch(u){n(u)}},i=c=>{try{o(e.throw(c))}catch(u){n(u)}},o=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,i);o((e=e.apply(y,t)).next())});const X=15e3,x=3e4,H=5e3,j=(0,d.jT)(),A=N.j.currencyCode;class w extends K.P{constructor(t,e,r,n){super(t,e,r,n),this.walletInfo=b(r),this.networkInfo=t.networkInfo,this.fetchCors=(0,d.zR)(t.io)}setOtherData(t){this.otherData=D(t)}multicastServers(t,...e){return a(this,null,function*(){let r={result:"",server:"no server"},n;switch(t){case"getHead":{n=this.tools.tezosRpcNodes.map(i=>()=>a(this,null,function*(){const o=yield this.fetchCors(i+"/chains/main/blocks/head/header").then(function(c){return a(this,null,function*(){return yield c.json()})}).then(function(c){return c});return{server:i,result:o}})),r=yield(0,d.QJ)(n);break}case"getBalance":{n=this.tools.tezosRpcNodes.map(i=>()=>a(this,null,function*(){h.eztz.node.setProvider(i);const o=yield h.eztz.rpc.getBalance(e[0]);return{server:i,result:o}})),r=yield(0,d.QJ)(n);break}case"getNumberOfOperations":n=this.tools.tezosApiServers.map(s=>()=>a(this,null,function*(){const i=yield this.fetchCors(`${s}/v1/accounts/${e[0]}`).then(function(o){return a(this,null,function*(){return yield o.json()})}).then(function(o){return o.numTransactions});return{server:s,result:i}})),r=yield(0,d.QJ)(n);break;case"getTransactions":n=this.tools.tezosApiServers.map(s=>()=>a(this,null,function*(){const i=s.includes("tzkt")?"":`&p='${e[1]}&number=50`,o=yield this.fetchCors(`${s}/v1/accounts/${e[0]}/operations?type=transaction`+i).then(function(c){return a(this,null,function*(){return yield c.json()})});return{server:s,result:o}})),r=yield(0,d.QJ)(n);break;case"createTransaction":n=this.tools.tezosRpcNodes.map(s=>()=>a(this,null,function*(){h.eztz.node.setProvider(s);const i=yield h.eztz.rpc.transfer(e[0],e[1],e[2],e[3],e[4],null,this.networkInfo.limit.gas,this.networkInfo.limit.storage,this.networkInfo.fee.reveal).then(function(o){return o});return{server:s,result:i}})),r=yield(0,d.QJ)(n);break;case"injectOperation":{let s="";n=this.tools.tezosRpcNodes.map(i=>()=>a(this,null,function*(){h.eztz.node.setProvider(i);const o=yield h.eztz.rpc.inject(e[0],e[1]).catch(c=>{this.error("Error when injection operation: ",c);const u=this.formatError(c);throw!s&&u!==""&&(s=u),c});return this.multicastServers("silentInjection",i,e[1]),{server:i,result:o}})),r=yield(0,d.QJ)(n).catch(i=>{throw this.error("Error from waterfall: ",i),s!==""?new Error(s):i});break}case"silentInjection":{const s=this.tools.tezosRpcNodes.indexOf(e[0]),i=this.tools.tezosRpcNodes.slice(s+1);r=yield(0,d.Wp)(i.map(o=>a(this,null,function*(){h.eztz.node.setProvider(o);const c=yield h.eztz.rpc.silentInject(e[1]);return this.warn(`Injected silently to: ${o}`),{server:o,result:c}})));break}}return this.log(`XTZ multicastServers ${t} ${r.server} won with result ${r.result}`),r.result})}formatError(t){if(typeof t=="string")return t;try{if(t.error&&t.error==="Operation Failed"&&t.errors&&t.errors[0].id)return"Failed in preapply with an error code ("+t.errors[0].id+")";if(t[0]&&t[0].kind&&t[0].kind==="branch"&&t[0].id)return"Failed in preapply with an error code ("+t[0].id+")"}catch{}return""}processTezosTransaction(t){const e=P(t),r=this.walletLocalData.publicKey,n=[],s=A,i=new Date(e.timestamp).getTime()/1e3,o=e.level;let c=e.amount.toString();const u=(e.bakerFee+e.allocationFee).toString(),C=e.status==="failed";r===e.target.address?(n.push(r),e.sender.address===r&&(c="-"+u)):c="-"+(0,k.add)(c,u);const v={txid:t.hash,date:i,currencyCode:s,blockHeight:o,nativeAmount:c,isSend:c.startsWith("-"),networkFee:u,ourReceiveAddresses:n,signedTx:"",otherParams:{},walletId:this.walletId};C||this.addTransaction(s,v)}checkTransactionsInnerLoop(){return a(this,null,function*(){const t=this.walletLocalData.publicKey;this.otherData.numberTransactions||(this.otherData.numberTransactions=0);const e=yield this.multicastServers("getNumberOfOperations",t);if(e!==this.otherData.numberTransactions){let r=[],n=0,s;this.tokenCheckTransactionsStatus.XTZ=.5;do s=yield this.multicastServers("getTransactions",t,n++),r=r.concat(s);while(s.length>0&&n<10);for(const i of r)this.processTezosTransaction(i);this.transactionsChangedArray.length>0&&(this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[]),this.otherData.numberTransactions=e,this.walletLocalDataDirty=!0}this.tokenCheckTransactionsStatus.XTZ=1,this.updateOnAddressesChecked()})}checkUnconfirmedTransactionsFetch(){return a(this,null,function*(){})}checkAccountInnerLoop(){return a(this,null,function*(){const t=A,e=this.walletLocalData.publicKey;typeof this.walletLocalData.totalBalances[t]>"u"&&(this.walletLocalData.totalBalances[t]="0");const r=yield this.multicastServers("getBalance",e);this.updateBalance(t,r)})}checkBlockchainInnerLoop(){return a(this,null,function*(){const e=(yield this.multicastServers("getHead")).level;this.walletLocalData.blockHeight!==e&&(this.walletLocalData.blockHeight=e,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight))})}clearBlockchainCache(){return a(this,null,function*(){yield S(w.prototype,this,"clearBlockchainCache").call(this)})}isBurn(t){return a(this,null,function*(){return t.kind==="origination"||t.kind==="transaction"&&t.destination.slice(0,2)==="tz"&&(yield this.multicastServers("getBalance",t.destination))==="0"})}startEngine(){return a(this,null,function*(){this.engineOn=!0,this.addToLoop("checkBlockchainInnerLoop",x),this.addToLoop("checkAccountInnerLoop",X),this.addToLoop("checkTransactionsInnerLoop",H),S(w.prototype,this,"startEngine").call(this)})}resyncBlockchain(){return a(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}makeSpend(t){return a(this,null,function*(){return yield j(()=>a(this,null,function*(){return yield this.makeSpendInner(t)}))})}makeSpendInner(t){return a(this,null,function*(){const{edgeSpendInfo:e,currencyCode:r,nativeBalance:n,denom:s}=this.makeSpendCheck(t);if(e.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{publicAddress:i}=e.spendTargets[0];let{nativeAmount:o}=e.spendTargets[0];if(i==null)throw new Error("makeSpend Missing publicAddress");if(o==null)throw new z.$D;if((0,k.eq)(o,"0"))throw new z.$D;const c={pk:this.walletInfo.keys.publicKeyEd,pkh:this.walletInfo.keys.publicKey,sk:!1};let u,C=0,v;do try{u=yield this.multicastServers("createTransaction",c.pkh,c,i,(0,k.div)(o,s.multiplier,6),this.networkInfo.fee.transaction)}catch(g){v=g}while((typeof u>"u"||u.opOb.contents.length>2)&&C++<5);if(typeof u>"u")throw v;let m="0";for(const g of u.opOb.contents)m=(0,k.add)(m,g.fee),(yield this.isBurn(g))&&(m=(0,k.add)(m,this.networkInfo.fee.burn));if(o=(0,k.add)(o,m),(0,k.gt)(o,n))throw new z.C_;return o="-"+o,{txid:"",date:0,currencyCode:r,blockHeight:0,nativeAmount:o,isSend:o.startsWith("-"),networkFee:m,ourReceiveAddresses:[],signedTx:"",otherParams:{idInternal:0,fromAddress:this.walletLocalData.publicKey,toAddress:i,fullOp:u},walletId:this.walletId}})}signTx(t,e){return a(this,null,function*(){const r=E(e),n=(0,d.Xp)(t);if(t.signedTx===""){const s=r.privateKey,i=h.eztz.crypto.sign(n.fullOp.opbytes,s,h.eztz.watermark.generic);n.fullOp.opbytes=i.sbytes,n.fullOp.opOb.signature=i.edsig,t.signedTx=i.sbytes}return this.warn(`signTx
2
2
  ${(0,d.oX)(t)}`),t})}broadcastTx(t){return a(this,null,function*(){const e=(0,d.Xp)(t),r=e.fullOp.opbytes,n=e.fullOp.opOb,s=yield this.multicastServers("injectOperation",n,r);return t.txid=s.hash,t.date=Date.now()/1e3,this.warn(`SUCCESS broadcastTx
3
- ${(0,d.oX)(t)}`),t})}}function $(y,t,e,r){return a(this,null,function*(){const n=b(e),s=new w(y,t,n,r);return yield s.loadEngine(),s})}var M=f(48764).Buffer,p=(y,t,e)=>new Promise((r,n)=>{var s=c=>{try{o(e.next(c))}catch(u){n(u)}},i=c=>{try{o(e.throw(c))}catch(u){n(u)}},o=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,i);o((e=e.apply(y,t)).next())});class L{constructor(t){const{builtinTokens:e,currencyInfo:r,io:n,networkInfo:s}=t;this.builtinTokens=e,this.currencyInfo=r,this.io=n,this.networkInfo=s,this.tezosRpcNodes=[...this.networkInfo.tezosRpcNodes],this.tezosApiServers=[...this.networkInfo.tezosApiServers]}getDisplayPrivateKey(t){return p(this,null,function*(){return E(t.keys).mnemonic})}getDisplayPublicKey(t){return p(this,null,function*(){const{keys:e}=b(t);return e.publicKey})}checkAddress(t){try{return h.eztz.crypto.checkAddress(t)}catch{return!1}}importPrivateKey(t){return p(this,null,function*(){if(/\d/.test(t))throw new Error("Input must be mnemonic phrase");if(t.split(" ").length!==24)throw new Error("Mnemonic phrase must be 24 words long");const n=h.eztz.crypto.generateKeys(t,"");return this.derivePublicKey({type:"wallet:tezos",id:"fake",keys:n}),{mnemonic:n.mnemonic,privateKey:n.sk}})}createPrivateKey(t){return p(this,null,function*(){if(t.replace("wallet:","")==="tezos"){const r=M.from(this.io.random(32)).toString("hex"),n=h.eztz.library.bip39.entropyToMnemonic(r),s=h.eztz.crypto.generateKeys(n,"").sk;return{mnemonic:n,privateKey:s}}else throw new Error("InvalidWalletType")})}derivePublicKey(t){return p(this,null,function*(){if(t.type.replace("wallet:","")==="tezos"){const r=h.eztz.crypto.generateKeys(t.keys.mnemonic,"");return{publicKey:r.pkh,publicKeyEd:r.pk}}else throw new Error("InvalidWalletType")})}parseUri(t){return p(this,null,function*(){let e,r,n;if(this.checkAddress(t))e=t;else if(t.slice(0,10)==="web+tezos:"){if(r=(0,I.decodeMainnet)(t),!r[0]||!r[0].content)throw new Error("InvalidUriError");if(n=r[0].content,e=n.destination,!this.checkAddress(e))throw new Error("InvalidPublicAddressError")}else throw new Error("InvalidUriError");const s={publicAddress:e};return s.nativeAmount=n!=null&&n.amount!=="0"?n.amount:void 0,s.currencyCode="XTZ",s})}encodeUri(t){return p(this,null,function*(){if(!this.checkAddress(t.publicAddress))throw new Error("InvalidPublicAddressError");if(t.currencyCode!=="XTZ")throw new Error("InvalidCurrencyCodeError");const n={kind:"transaction",amount:typeof t.nativeAmount=="string"?t.nativeAmount:"0",destination:t.publicAddress};return(0,I.encodeMainnet)([{content:n}])})}}function F(y){return p(this,null,function*(){return new L(y)})}},75992:function(){}}]);
3
+ ${(0,d.oX)(t)}`),t})}}function $(y,t,e,r){return a(this,null,function*(){const n=b(e),s=new w(y,t,n,r);return yield s.loadEngine(),s})}var M=f(48764).Buffer,p=(y,t,e)=>new Promise((r,n)=>{var s=c=>{try{o(e.next(c))}catch(u){n(u)}},i=c=>{try{o(e.throw(c))}catch(u){n(u)}},o=c=>c.done?r(c.value):Promise.resolve(c.value).then(s,i);o((e=e.apply(y,t)).next())});class L{constructor(t){const{builtinTokens:e,currencyInfo:r,io:n,networkInfo:s}=t;this.builtinTokens=e,this.currencyInfo=r,this.io=n,this.networkInfo=s,this.tezosRpcNodes=[...this.networkInfo.tezosRpcNodes],this.tezosApiServers=[...this.networkInfo.tezosApiServers]}getDisplayPrivateKey(t){return p(this,null,function*(){return E(t.keys).mnemonic})}getDisplayPublicKey(t){return p(this,null,function*(){const{keys:e}=b(t);return e.publicKey})}checkAddress(t){try{return h.eztz.crypto.checkAddress(t)}catch{return!1}}importPrivateKey(t){return p(this,null,function*(){if(/\d/.test(t))throw new Error("Input must be mnemonic phrase");if(t.split(" ").length!==24)throw new Error("Mnemonic phrase must be 24 words long");const n=h.eztz.crypto.generateKeys(t,"");return this.derivePublicKey({type:"wallet:tezos",id:"fake",keys:n}),{mnemonic:n.mnemonic,privateKey:n.sk}})}createPrivateKey(t){return p(this,null,function*(){if(t.replace("wallet:","")==="tezos"){const r=M.from(this.io.random(32)).toString("hex"),n=h.eztz.library.bip39.entropyToMnemonic(r),s=h.eztz.crypto.generateKeys(n,"").sk;return{mnemonic:n,privateKey:s}}else throw new Error("InvalidWalletType")})}derivePublicKey(t){return p(this,null,function*(){if(t.type.replace("wallet:","")==="tezos"){const r=h.eztz.crypto.generateKeys(t.keys.mnemonic,"");return{publicKey:r.pkh,publicKeyEd:r.pk}}else throw new Error("InvalidWalletType")})}parseUri(t){return p(this,null,function*(){let e,r,n;if(this.checkAddress(t))e=t;else if(t.slice(0,10)==="web+tezos:"){if(r=(0,I.decodeMainnet)(t),!r[0]||!r[0].content)throw new Error("InvalidUriError");if(n=r[0].content,e=n.destination,!this.checkAddress(e))throw new Error("InvalidPublicAddressError")}else throw new Error("InvalidUriError");const s={publicAddress:e};return s.nativeAmount=n!=null&&n.amount!=="0"?n.amount:void 0,s.currencyCode="XTZ",s})}encodeUri(t){return p(this,null,function*(){if(!this.checkAddress(t.publicAddress))throw new Error("InvalidPublicAddressError");if(t.currencyCode!=="XTZ")throw new Error("InvalidCurrencyCodeError");const n={kind:"transaction",amount:typeof t.nativeAmount=="string"?t.nativeAmount:"0",destination:t.publicAddress};return(0,I.encodeMainnet)([{content:n}])})}}function F(y){return p(this,null,function*(){return new L(y)})}},89214:function(){},75992:function(){},52361:function(){},94616:function(){}}]);
@@ -1 +1 @@
1
- "use strict";(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[5],{86352:function(mt,Z,h){h.d(Z,{Vn:function(){return tt},lF:function(){return j},sp:function(){return V}});var m=h(76714),F=(t,P,x)=>new Promise((R,H)=>{var L=p=>{try{T(x.next(p))}catch(f){H(f)}},y=p=>{try{T(x.throw(p))}catch(f){H(f)}},T=p=>p.done?R(p.value):Promise.resolve(p.value).then(L,y);T((x=x.apply(t,P)).next())});const G=["https://info1.edge.app","https://info2.edge.app"];function Y(t,P,x){return F(this,arguments,function*(R,H,L,y=5e3,T=fetch){const p=R.map(f=>()=>F(this,null,function*(){const M=yield T(f+"/"+H,L);if(typeof M!="object"){const b=`Invalid return value ${H} in ${f}`;throw console.log(b),new Error(b)}return M}));return yield(0,m.QJ)(p,y)})}function j(t,P,x,R,H=5e3,L){return F(this,null,function*(){const y=yield Y((0,m.Sy)(P),x,R,H,L);if(!y.ok){const f=yield y.text();throw console.error(f),new Error(`Error fetching ${x}: ${f}`)}const T=yield y.json();return t(T)})}function q(t,P,x,R=5e3,H){return F(this,null,function*(){return yield Y((0,m.Sy)(t),P,x,R,H)})}const tt=(t,P,x,R)=>F(void 0,null,function*(){return yield q(G,t,P,x,R)}),V=t=>Object.keys(t).map(P=>{const x=t[P];return x==null?P:`${P}=${encodeURIComponent(x)}`}).join("&")},79014:function(mt,Z,h){h.d(Z,{Q:function(){return L},k:function(){return H}});var m=h(77591),F=h.n(m),G=h(24350),Y=h(84564),j=h.n(Y),q=h(76714),tt=Object.defineProperty,V=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,x=(y,T,p)=>T in y?tt(y,T,{enumerable:!0,configurable:!0,writable:!0,value:p}):y[T]=p,R=(y,T)=>{for(var p in T||(T={}))t.call(T,p)&&x(y,p,T[p]);if(V)for(var p of V(T))P.call(T,p)&&x(y,p,T[p]);return y};function H(y,T,p,f,M=[]){const b=R({},j()(T,{},!0)),et=T.startsWith(`${y.pluginId}://`);if(b.protocol!=null&&(b.protocol=b.protocol.replace(":","")),b.protocol!=null&&b.protocol!==""&&!p[b.protocol])throw new Error(`Uri protocol '${b.protocol}' is not supported for ${y.pluginId}.`);if(b.host===""&&b.pathname==="")throw new Error("Path and host not found in uri.");const U={publicAddress:b.host!==""?b.host:b.pathname.split("/")[0]},nt=b.query.label,rt=b.query.message,it=b.query.category;(nt!=null||rt!=null||it!=null||et)&&(U.metadata={},U.metadata.name=nt,U.metadata.notes=rt,U.metadata.category=it,U.metadata.gateway=et!=null?et:!1);const st=b.query.amount;if(st!=null&&typeof st=="string"){f==null&&(f=y.currencyCode);const ot=(0,q.Qs)(f!=null?f:"",y,M);if(ot==null)throw new Error("InternalErrorInvalidCurrencyCode");let at=(0,m.mul)(st,ot.multiplier);at=(0,m.toFixed)(at,0,0),U.nativeAmount=at,U.currencyCode=f}return{edgeParsedUri:U,parsedUri:b}}function L(y,T,p){if(y.publicAddress==null)throw new Error("InvalidPublicAddressError");if(p==null&&y.label==null&&y.message==null)return y.publicAddress;{let f="";p!=null&&(f+="amount="+p+"&"),(y.label!=null||y.message!=null)&&(typeof y.label=="string"&&(f+="label="+y.label+"&"),typeof y.message=="string"&&(f+="message="+y.message+"&")),f=f.substr(0,f.length-1);const M={scheme:T,path:y.publicAddress,query:f};return(0,G.qC)(M)}}},58780:function(mt,Z,h){h.r(Z),h.d(Z,{TronTools:function(){return _t},makeCurrencyEngine:function(){return Te},makeCurrencyTools:function(){return Ce}});var m=h(77591),F=h(2153),G=h(21964),Y=h.n(G),j=h(48367),q=h.n(j),tt=h(3666),V=h.n(tt),t=h(82448),P=h(86352);const x=s=>{if(s.includes("@"))return R(s)?[!0,s.toLowerCase()]:[!1,"Invalid Email"];if(s.includes("+"))return s="+"+s.replace(/[^\d]+/g,""),s.length!==14?[!1,"Invalid Phone number"]:s.substring(0,3)!=="+55"?[!1,"Not brasilian number"]:[!0,s];if(s.length===36)return[!0,s];if(s.length===18)return/^\d{2}\.\d{3}\.\d{3}\/\d{4}-\d{2}$/.test(s)?L(s)?(s=s.replace(/[^\d]+/g,""),[!0,s]):[!1,"invalid cnpj"]:[!1,"invalid pixkey"];if(s.length===13&&/^\d+$/.test(s))return s.substr(0,2)!=="55"?[!1,"invalid pixkey"]:[!0,"+"+s];if(s.length<11)return[!1,"invalid pixkey"];if(s.length===14){if(/^\d+$/.test(s))return L(s)?[!0,s]:[!1,"invalid pixkey"];if(/^\d{3}\.\d{3}\.\d{3}-\d{2}$/.test(s))return H(s)?[!0,s.replace(/[^\d]+/g,"")]:[!1,"invalid cpf"]}return s.length===11?/^\d+$/.test(s)?H(s)?[!0,s.replace(/[^\d]+/g,"")]:s.charAt(0)==="0"?[!1,"invalid pixkey"]:[!0,"+55"+s]:[!1,"invalid pixkey"]:(s=s.replace(/[^\d]+/g,""),s.length===12?s.charAt(0)!=="0"?[!1,"invalid pixkey"]:[!0,"+55"+s.substr(1)]:s.length===11?H(s)?[!0,s]:[!0,"+55"+s]:[!1,"invalid pixkey"])};function R(s){return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(s).toLowerCase())}function H(s){if(s=s.replace(/[^\d]+/g,""),s===""||s.length!==11||s==="00000000000"||s==="11111111111"||s==="22222222222"||s==="33333333333"||s==="44444444444"||s==="55555555555"||s==="66666666666"||s==="77777777777"||s==="88888888888"||s==="99999999999")return!1;let e,n;e=0;for(let r=1;r<=9;r++)e=e+parseInt(s.substring(r-1,r))*(11-r);if(n=e*10%11,(n===10||n===11)&&(n=0),n!==parseInt(s.substring(9,10)))return!1;e=0;for(let r=1;r<=10;r++)e=e+parseInt(s.substring(r-1,r))*(12-r);return n=e*10%11,(n===10||n===11)&&(n=0),n===parseInt(s.substring(10,11))}function L(s){if(s=s.replace(/[^\d]+/g,""),s===""||s.length!==14||s==="00000000000000"||s==="11111111111111"||s==="22222222222222"||s==="33333333333333"||s==="44444444444444"||s==="55555555555555"||s==="66666666666666"||s==="77777777777777"||s==="88888888888888"||s==="99999999999999")return!1;let e=s.length-2,n=s.substring(0,e);const r=s.substring(e);let a=0,o=e-7;for(let i=e;i>=1;i--)a+=Number(n.charAt(e-i))*o--,o<2&&(o=9);let c=a%11<2?0:11-a%11;if(c!==Number(r.charAt(0)))return!1;e=e+1,n=s.substring(0,e),a=0,o=e-7;for(let i=e;i>=1;i--)a+=Number(n.charAt(e-i))*o--,o<2&&(o=9);return c=a%11<2?0:11-a%11,c===Number(r.charAt(1))}function y(s,e=!1){const n=p(s),r=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];let a=65535;for(let i=0;i<n.length;i++){const u=(n[i]^a>>8)&255;a=r[u]^a<<8}const o=(a^0)&65535,c=T(o,4);return e?c.slice(2)+c.slice(0,2):c}function T(s,e){const n=s.toString(16).toUpperCase();return e>0?("0".repeat(e)+n).slice(-e):n.length%2===0?n:"0"+n}function p(s){let e=0;const n=s.length;let r=0,a=Math.max(32,n+(n>>>1)+7),o=new Uint8Array(a>>>3<<3);for(;e<n;){let c=s.charCodeAt(e++);if(c>=55296&&c<=56319){if(e<n){const i=s.charCodeAt(e);(i&64512)===56320&&(++e,c=((c&1023)<<10)+(i&1023)+65536)}if(c>=55296&&c<=56319)continue}if(r+4>o.length){a+=8,a*=1+e/s.length*2,a=a>>>3<<3;const i=new Uint8Array(a);i.set(o),o=i}if((c&4294967168)===0){o[r++]=c;continue}else if((c&4294965248)===0)o[r++]=c>>>6&31|192;else if((c&4294901760)===0)o[r++]=c>>>12&15|224,o[r++]=c>>>6&63|128;else if((c&4292870144)===0)o[r++]=c>>>18&7|240,o[r++]=c>>>12&63|128,o[r++]=c>>>6&63|128;else continue;o[r++]=c&63|128}return o.slice!=null?o.slice(0,r):o.subarray(0,r)}var f=h(76714),M=(s,e,n)=>new Promise((r,a)=>{var o=l=>{try{i(n.next(l))}catch(u){a(u)}},c=l=>{try{i(n.throw(l))}catch(u){a(u)}},i=l=>l.done?r(l.value):Promise.resolve(l.value).then(o,c);i((n=n.apply(s,e)).next())});const b=60*60*24*7,et=(0,t._C)((0,t.su)({status:(0,t.Wf)("ok"),msg:t.XC,data:(0,t.su)({amount:t.mH,name:t.XC,key:t.XC,timeout:t.mH})}),(0,t.su)({status:(0,t.Wf)("failed"),msg:t.XC})),yt=(0,t.su)({status:(0,t.Wf)("ok"),msg:t.XC,data:(0,t.su)({amount_usd:t.XC,price_brl:t.XC,total_brl:t.XC,fee_brl:t.XC,send_brl:t.XC,timeout:t.mH,amount_txusdt:t.XC,price_txusdt:t.mH,value_usd:t.XC,total_txusdt:t.XC})}),U=(s,e,n,r,a)=>M(void 0,null,function*(){const o=new Date,c=Object.keys(e).find(u=>e[u].currencyCode==="USDT");if(c==null)return;const i=e[c],l=(0,m.mul)("0.5",i.denominations[0].multiplier);if(n.length>36){const u=y(n.slice(0,-4));if(!n.endsWith(u))return;try{const d=(0,f.zR)(s),w=encodeURIComponent(n),k=yield(0,P.lF)(et,["https://connect.smartpay.com.vc"],`api/pix/qrdecode?qrcode=${w}`,void 0,void 0,d);if(k.status!=="ok")throw new Error(k.msg);const{data:_}=k,{amount:A,key:S,name:z,timeout:C}=_;if(C>0&&C<120)throw new Error("ErrorPixExpired");let E,v;if(A!==0){const D={type:"buy",profile:"transfer",currency:"brl",conv:"txusdt",target:"amount",user:a,amount:A===0?100:A},B=(0,P.sp)(D),J=yield(0,P.lF)(yt,["https://connect.smartpay.com.vc"],`api/swapix/swapquote?${B}`,void 0,void 0,d),{data:ct}=J,{amount_txusdt:K,timeout:W}=ct;if(W>0&&W<120)throw new Error("ErrorPixExpired");E=(0,m.mul)(K,i.denominations[0].multiplier);const N=Math.min(C>0?C:b,W>0?W:b);v=new Date(o.getTime()+N*1e3)}return{currencyCode:"USDT",metadata:{name:z,notes:`To PIX: ${S}`},expireDate:v,nativeAmount:E,minNativeAmount:l,publicAddress:r,uniqueIdentifier:n}}catch(d){console.log(`Could not query PIX address ${n}: ${d.message}`)}}else{const[u,d]=x(n);return u?{currencyCode:"USDT",minNativeAmount:l,metadata:{name:`PIX: ${d}`,notes:`To PIX: ${d}`},publicAddress:"TUmgPbM5J6om7Z2PJjzrbSEbXit84ZhVCj",uniqueIdentifier:d}:void 0}});var nt=h(20918),rt=h(79014),it=h(62177);const st=(0,t.su)({smartPayPublicAddress:(0,t.Zz)(t.XC,"TUmgPbM5J6om7Z2PJjzrbSEbXit84ZhVCj"),smartPayUserId:(0,t.Zz)(t.XC,"edge")}),ot=(0,t.su)({txid:t.XC,timestamp:t.mH}),at=(0,t.su)({txQueryCache:(0,t.Vk)((0,t.su)({mainnet:ot,trc20:ot}),()=>({mainnet:{txid:"",timestamp:0},trc20:{txid:"",timestamp:0}}))}),gt=(0,t.Wf)("ENERGY"),It=(0,t.Wf)("BANDWIDTH"),ut=(0,t._C)(gt,It),Pt=(0,t.Wf)("ENERGY_V2"),St=(0,t.Wf)("BANDWIDTH_V2"),pt=(0,t._C)(Pt,St),Dt=(0,t.su)({type:(0,t.Wf)("remove"),params:(0,t.su)({resource:ut})}),Bt=(0,t.su)({type:(0,t.Wf)("addV2"),params:(0,t.su)({nativeAmount:t.XC,resource:pt})}),Ht=(0,t.su)({type:(0,t.Wf)("removeV2"),params:(0,t.su)({nativeAmount:t.XC,resource:pt})}),Nt=(0,t.su)({chainParameter:(0,t._2)((0,t.su)({key:t.XC,value:(0,t.Zz)(t.mH)}))}),Ot=(0,t.su)({blockID:t.XC,block_header:(0,t.su)({raw_data:(0,t.su)({number:t.mH,timestamp:t.mH})})}),vt=(0,t.su)({freeNetUsed:(0,t.Vk)(t.mH,0),freeNetLimit:t.mH,EnergyUsed:(0,t.Vk)(t.mH,0),EnergyLimit:(0,t.Vk)(t.mH,0)}),Rt=(0,t.su)({frozen:(0,t.Zz)((0,t.vq)((0,t.su)({frozen_balance:t.mH,expire_time:t.mH}))),account_resource:(0,t.su)({frozen_balance_for_energy:(0,t.Zz)((0,t.su)({frozen_balance:t.mH,expire_time:t.mH}))}),frozenV2:(0,t.vq)((0,t.su)({amount:(0,t.Zz)(t.mH)}),(0,t.su)({type:gt,amount:(0,t.Zz)(t.mH)}),(0,t.su)({type:(0,t.Wf)("TRON_POWER")})),balance:(0,t.Vk)(t.mH,0)}),zt=(0,t.su)({constant_result:(0,t.vq)(t.XC)}),Ft=(0,t.su)({ret:(0,t._2)((0,t.su)({contractRet:t.XC,fee:t.mH})),txID:t.XC,unfreeze_amount:(0,t.Zz)(t.mH),blockNumber:t.mH,block_timestamp:t.mH,raw_data:(0,t.su)({contract:(0,t._2)(t.JC)})}),Lt=(0,t.su)({transaction_id:t.XC,token_info:(0,t.su)({address:t.XC}),block_timestamp:t.mH,from:t.XC,to:t.XC,type:t.XC,value:t.XC}),Ut=(0,t.su)({fee:(0,t.Zz)(t.mH,0),blockNumber:t.mH}),Xt=(0,t.su)({parameter:(0,t.su)({value:(0,t.su)({amount:t.mH,owner_address:t.XC,to_address:t.XC})}),type:(0,t.Wf)("TransferContract")}),Kt=(0,t.su)({parameter:(0,t.su)({value:(0,t.su)({data:t.XC,owner_address:t.XC,contract_address:t.XC})}),type:(0,t.Wf)("TriggerSmartContract")}),Wt=(0,t.su)({parameter:(0,t.su)({value:(0,t.su)({frozen_balance:t.mH,resource_type:ut,owner_address:t.XC})}),type:(0,t.Wf)("FreezeBalanceContract")}),Vt=(0,t.su)({parameter:(0,t.su)({value:(0,t.su)({resource_type:ut,owner_address:t.XC})}),type:(0,t.Wf)("UnfreezeBalanceContract")}),Mt=(0,t.su)({parameter:(0,t.su)({value:(0,t.su)({frozen_balance:t.mH,owner_address:t.XC})}),type:(0,t.Wf)("FreezeBalanceV2Contract")}),$t=(0,t.su)({parameter:(0,t.su)({value:(0,t.su)({unfreeze_balance:t.mH,owner_address:t.XC})}),type:(0,t.Wf)("UnfreezeBalanceV2Contract")}),Jt=s=>(0,t.su)({data:(0,t._2)(s),success:t.jK,meta:(0,t.su)({links:(0,t.Zz)((0,t.su)({next:t.XC})),page_size:t.mH})}),Zt=(0,t.su)({energy_used:t.mH,transaction:(0,t.su)({ret:(0,t._2)((0,t.su)({ret:(0,t.Zz)(t.XC)}))})}),Yt=(0,t.su)({result:t.jK,txid:t.XC,message:t.XC}),Tt=it.BQ,dt=(0,t.su)({tronMnemonic:(0,t.Zz)(t.XC),tronKey:t.XC,derivationPath:(0,t.Zz)(t.XC)});var wt=h(94935),Q=h(35620),Qt=h(84650),Gt=h(68142),jt=h.n(Gt),qt=h(48764).Buffer;const{utils:{crypto:{decode58Check:te,getBase58CheckAddress:ee}}}=V(),O=s=>{const e=te(s);return Q.YU.stringify(e)},$=s=>{const e=Q.YU.parse(s);return ee(Array.from(e))},Ct="a9059cbb",be=s=>{if(!s.startsWith(Ct))throw new Error("Not a TRC20 data payload");const e=s.replace(Ct,""),n=`41${e.substring(24,64)}`,r=$(n),a=e.substring(64,128),o=hexToDecimal(a);return[r,o]},ne=(s,e)=>{const n=O(s).replace(/^(41)/,"0x"),r=jt().simpleEncode("transfer(address,uint256):(uint256)",n,e);return qt.from(r).toString("hex")};var re=h(48764).Buffer,se=Object.defineProperty,oe=Object.defineProperties,ae=Object.getOwnPropertyDescriptors,bt=Object.getOwnPropertySymbols,ce=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable,ue=Reflect.get,At=(s,e,n)=>e in s?se(s,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[e]=n,ht=(s,e)=>{for(var n in e||(e={}))ie.call(e,n)&&At(s,n,e[n]);if(bt)for(var n of bt(e))le.call(e,n)&&At(s,n,e[n]);return s},de=(s,e)=>oe(s,ae(e)),Et=(s,e,n)=>ue(ce(s),n,e),g=(s,e,n)=>new Promise((r,a)=>{var o=l=>{try{i(n.next(l))}catch(u){a(u)}},c=l=>{try{i(n.throw(l))}catch(u){a(u)}},i=l=>l.done?r(l.value):Promise.resolve(l.value).then(o,c);i((n=n.apply(s,e)).next())});const{utils:{crypto:{signTransaction:he},transaction:{txJsonToPb:fe,txPbToTxID:me}}}=V(),ye=(0,f.jT)(),kt=2e4,ge=2e4,pe=3e3,ve=60*10*1e3;class lt extends Qt.P{constructor(e,n,r,a){super(e,n,r,a);const{networkInfo:o}=e;this.fetchCors=(0,f.zR)(e.io),this.networkInfo=o,this.recentBlock={hash:"0",number:0,timestamp:0},this.accountResources={BANDWIDTH:0,ENERGY:0},this.networkFees={getCreateAccountFee:1e5,getTransactionFee:1e3,getEnergyFee:280,getMemoFee:1e6},this.accountExistsCache={},this.energyEstimateCache={},this.processTRXTransaction=this.processTRXTransaction.bind(this),this.processTRC20Transaction=this.processTRC20Transaction.bind(this),this.stakingStatus={stakedAmounts:[{nativeAmount:"0",otherParams:{type:"BANDWIDTH"}},{nativeAmount:"0",otherParams:{type:"ENERGY"}}]}}setOtherData(e){this.otherData=at(e)}fetch(e,n){return g(this,arguments,function*(r,a,o={}){const c=r+a,i=yield this.fetchCors(c,o);if(!i.ok||i.status!==200)throw this.log(`The server returned error code ${i.status} for ${c}`),new Error(`The server returned error code ${i.status} for ${c}`);const l=yield i.json();if(typeof l!="object"){const u=`Invalid return value ${a} in ${r}`;throw this.log(u),new Error(u)}return{server:r,result:l}})}checkBlockchainInnerLoop(){return g(this,null,function*(){try{const e=yield this.multicastServers("trx_blockNumber","/wallet/getnowblock"),n=Ot(e),r=n.block_header.raw_data.number;Object.assign(this.recentBlock,{hash:n.blockID,number:r,timestamp:n.block_header.raw_data.timestamp}),this.walletLocalData.blockHeight!==r&&(this.checkDroppedTransactionsThrottled(),this.walletLocalData.blockHeight=r,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight))}catch(e){this.log.error("Error fetching height: ",e)}})}checkTokenBalances(){return g(this,null,function*(){const e=O(this.walletLocalData.publicKey);for(const n of this.enabledTokens){const r=this.allTokens.find(c=>c.currencyCode===n);if((r==null?void 0:r.contractAddress)==null)continue;const o={contract_address:O(r.contractAddress),function_selector:"balanceOf(address)",parameter:(0,f.gc)(e,32),owner_address:e};try{const c=yield this.multicastServers("trx_getBalance","/wallet/triggerconstantcontract",o),i=zt(c);r!=null&&this.updateBalance(r.currencyCode,(0,f.Z8)(i.constant_result[0]))}catch(c){this.log.error(`Failed to get balance of ${n}`,c)}}})}checkAccountInnerLoop(){return g(this,null,function*(){const e={address:O(this.walletLocalData.publicKey)};try{const n=yield this.multicastServers("trx_getBalance","/wallet/getaccount",e),r=(0,t.Vk)(Rt)(n);if(r==null){this.updateBalance(this.currencyInfo.currencyCode,"0");return}this.updateBalance(this.currencyInfo.currencyCode,r.balance.toString());const{frozen:a,account_resource:{frozen_balance_for_energy:o}}=r,c=[];if(a!=null){const u=a[0].frozen_balance.toString(),d=new Date(a[0].expire_time);c.push({nativeAmount:u,unlockDate:d,otherParams:{type:"BANDWIDTH"}})}if(o!=null){const u=o.frozen_balance.toString(),d=new Date(o.expire_time);c.push({nativeAmount:u,unlockDate:d,otherParams:{type:"ENERGY"}})}const[i,l]=r.frozenV2;i.amount!=null&&c.push({nativeAmount:i.amount.toFixed(),otherParams:{type:"BANDWIDTH_V2"}}),l.amount!=null&&c.push({nativeAmount:l.amount.toFixed(),otherParams:{type:"ENERGY_V2"}}),this.stakingStatus={stakedAmounts:c},this.currencyEngineCallbacks.onStakingStatusChanged(ht({},this.stakingStatus))}catch(n){this.log.error("Error checking TRX address balance: ",n)}try{const n=yield this.multicastServers("trx_getAccountResource","/wallet/getaccountresource",e),r=vt(n);this.accountResources={BANDWIDTH:r.freeNetLimit-r.freeNetUsed,ENERGY:r.EnergyLimit-r.EnergyUsed}}catch(n){this.log.error("Error checking TRX address resources: ",n)}})}queryTransactions(){return g(this,null,function*(){return yield ye(()=>g(this,null,function*(){return yield this.queryTransactionsInnerLoop()}))})}queryTransactionsInnerLoop(){return g(this,null,function*(){try{yield this.fetchTrxTransactions(),yield this.fetchTrc20Transactions()}catch(e){throw this.log.error("Error checkTransactionsFetch fetchTrxTransactions: ",e),e}this.transactionsChangedArray.length>0&&(this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[]);for(const e of this.enabledTokens)this.tokenCheckTransactionsStatus[e]=1;this.updateOnAddressesChecked()})}fetchTrxTransactions(){return g(this,null,function*(){let e=!1;for(;!e;)e=yield this.fetchTransactions("mainnet",Ft,this.processTRXTransaction)})}fetchTrc20Transactions(){return g(this,null,function*(){let e=!1;for(;!e;)e=yield this.fetchTransactions("trc20",Lt,this.processTRC20Transaction)})}fetchTransactions(e,n,r){return g(this,null,function*(){var a;const o=e==="trc20"?e:"",c=this.otherData.txQueryCache[e].timestamp,i=`/v1/accounts/${this.walletLocalData.publicKey}/transactions/${o}?limit=200&order_by=block_timestamp,asc&min_timestamp=${c}`,l=yield this.multicastServers("trx_getTransactions",i),{data:u,meta:d,success:w}=Jt(n)(l),k=((a=d==null?void 0:d.links)==null?void 0:a.next)==null;if(!w)throw new Error("Failed to query TRX transactions");for(const _ of u){const{timestamp:A,txid:S}=yield r(_);this.otherData.txQueryCache[e].txid=S,this.otherData.txQueryCache[e].timestamp=A,this.walletLocalDataDirty=!0}return k})}processTRXTransaction(e){const{txID:n,block_timestamp:r,blockNumber:a,ret:o,unfreeze_amount:c,raw_data:{contract:i}}=e,l={txid:n,timestamp:r};if(n===this.otherData.txQueryCache.mainnet.txid||o.length<1)return l;const u=[];for(const d of i){const w=(0,t.Vk)(Xt)(d);if(w!=null){const{parameter:{value:{amount:C,owner_address:E,to_address:v}}}=w,{contractRet:I,fee:D}=o[0];let B=D.toString();const J=$(E),ct=$(v);let K=C.toString();if(J===this.walletLocalData.publicKey)J===ct?K=(0,m.mul)(B,"-1"):K=(0,m.mul)((0,m.add)(K,B),"-1"),I!=="SUCCESS"&&(K="0");else{if(I!=="SUCCESS")return l;u.push(this.walletLocalData.publicKey),B="0"}const{currencyCode:W}=this.currencyInfo,N={txid:n,date:Math.floor(r/1e3),currencyCode:W,blockHeight:a,nativeAmount:K,isSend:K.startsWith("-"),networkFee:B,ourReceiveAddresses:u,signedTx:"",walletId:this.walletId};return this.addTransaction(W,N),l}const k=(0,t.Vk)(Kt)(d);if(k!=null){const{parameter:{value:{owner_address:C}}}=k;if($(C)!==this.walletLocalData.publicKey)break;const E=o[0].fee.toString(),{currencyCode:v}=this.currencyInfo,I={txid:n,date:Math.floor(r/1e3),currencyCode:v,blockHeight:a,nativeAmount:(0,m.mul)(E,"-1"),isSend:!0,networkFee:E,ourReceiveAddresses:u,signedTx:"",walletId:this.walletId};return this.addTransaction(v,I),l}const _=(0,t.Vk)(Wt)(d);if(_!=null){const{parameter:{value:{owner_address:C,frozen_balance:E}}}=_;if($(C)!==this.walletLocalData.publicKey)break;const v=o[0].fee.toString(),I=(0,m.add)(E.toString(),v),{currencyCode:D}=this.currencyInfo,B={txid:n,date:Math.floor(r/1e3),currencyCode:D,blockHeight:a,nativeAmount:(0,m.mul)(I,"-1"),isSend:!0,networkFee:v,ourReceiveAddresses:u,signedTx:"",walletId:this.walletId};return this.addTransaction(D,B),l}const A=(0,t.Vk)(Vt)(d);if(A!=null){if(c==null)return l;const{parameter:{value:{owner_address:C}}}=A;if($(C)!==this.walletLocalData.publicKey)break;const E=o[0].fee.toString(),{currencyCode:v}=this.currencyInfo,I=(0,m.sub)(c.toString(),E),D={txid:n,date:Math.floor(r/1e3),currencyCode:v,blockHeight:a,nativeAmount:I,isSend:I.startsWith("-"),networkFee:E,ourReceiveAddresses:u,signedTx:"",walletId:this.walletId};return this.addTransaction(v,D),l}const S=(0,t.Vk)(Mt)(d);if(S!=null){const{parameter:{value:{owner_address:C,frozen_balance:E}}}=S;if($(C)!==this.walletLocalData.publicKey)break;const v=o[0].fee.toString(),I=(0,m.add)(E.toString(),v),{currencyCode:D}=this.currencyInfo,B={txid:n,date:Math.floor(r/1e3),currencyCode:D,blockHeight:a,nativeAmount:(0,m.mul)(I,"-1"),isSend:!0,networkFee:v,ourReceiveAddresses:u,signedTx:"",walletId:this.walletId};return this.addTransaction(D,B),l}const z=(0,t.Vk)($t)(d);if(z!=null){const{parameter:{value:{unfreeze_balance:C,owner_address:E}}}=z;if($(E)!==this.walletLocalData.publicKey)break;const v=o[0].fee.toString(),{currencyCode:I}=this.currencyInfo,D=(0,m.sub)(C.toString(),v),B={txid:n,date:Math.floor(r/1e3),currencyCode:I,blockHeight:a,nativeAmount:D,isSend:D.startsWith("-"),networkFee:v,ourReceiveAddresses:u,signedTx:"",walletId:this.walletId};return this.addTransaction(I,B),l}}return l}processTRC20Transaction(e){return g(this,null,function*(){const{transaction_id:n,token_info:{address:r},block_timestamp:a,from:o,to:c,type:i,value:l}=e,u={txid:n,timestamp:a};if(n===this.otherData.txQueryCache.trc20.txid)return u;const d=yield this.multicastServers("trx_getTransactionInfo","/wallet/gettransactioninfobyid",{value:n}),{blockNumber:w,fee:k}=Ut(d),_=this.allTokens.find(E=>E.contractAddress===r);if(i!=="Transfer"||_==null)return u;const A=[];let S=l;const z=k;if(o===this.walletLocalData.publicKey)S=(0,m.mul)(l,"-1");else if(c===this.walletLocalData.publicKey)A.push(this.walletLocalData.publicKey);else return u;const C={txid:n,date:Math.floor(a/1e3),currencyCode:_.currencyCode,blockHeight:w,nativeAmount:S,isSend:S.startsWith("-"),networkFee:"0",ourReceiveAddresses:A,signedTx:"",walletId:this.walletId};return(0,m.lt)(S,"0")&&(C.parentNetworkFee=z.toString()),this.addTransaction(_.currencyCode,C),u})}checkUpdateNetworkFees(){return g(this,null,function*(){try{const e=yield this.multicastServers("trx_chainParams","/wallet/getchainparameters"),n=Nt(e).chainParameter;for(const r of Object.keys(this.networkFees)){const a=n.find(o=>o.key===r);a!=null&&(this.networkFees=de(ht({},this.networkFees),{[r]:a.value}))}}catch(e){this.log.error("checkUpdateNetworkFees error: ",e)}})}multicastServers(e,n){return g(this,arguments,function*(r,a,o={}){let c={result:"",server:"no server"},i=[];switch(r){case"trx_chainParams":i=this.networkInfo.tronNodeServers.map(l=>()=>g(this,null,function*(){return yield this.fetch(l,a)}));break;case"trx_blockNumber":case"trx_broadcastTx":case"trx_estimateEnergy":case"trx_getAccountResource":case"trx_getBalance":case"trx_getTransactionInfo":i=this.networkInfo.tronNodeServers.map(l=>()=>g(this,null,function*(){const u={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(o)};return yield this.fetch(l,a,u)}));break;case"trx_getTransactions":i=this.networkInfo.tronApiServers.map(l=>()=>g(this,null,function*(){const u={headers:{Accept:"application/json","Content-Type":"application/json"}};return yield this.fetch(l,a,u)}));break}return i=(0,f.Sy)(i),c=yield(0,f.QJ)(i),this.log(`TRX multicastServers ${r} ${c.server} won`),c.result})}calcTxFee(e){return g(this,null,function*(){var n,r;const{note:a,receiverAddress:o,tokenOpts:c,unsignedTxHex:i}=e,l=(0,f.aL)(this.currencyInfo.currencyCode,this.currencyInfo,this.allTokensMap);if(l==null)throw new Error("calcTxFee unknown denom");let u=0;if(c!=null&&o!=null){const{contractAddress:A,data:S}=c;if(this.energyEstimateCache[`${o}:${A}`]==null){const z={owner_address:O(this.walletLocalData.publicKey),contract_address:O(A),function_selector:"transfer(address,uint256)",parameter:S.slice(8)};try{const C=yield this.multicastServers("trx_estimateEnergy","/wallet/triggerconstantcontract",z),E=Zt(C),v=(n=E.transaction.ret[0])==null?void 0:n.ret;if(v!=null&&v!=="SUCCESS")throw new Error("calcTxFee Failed to estimate fee");this.energyEstimateCache[`${o}:${A}`]=E.energy_used}catch(C){this.log.warn("trx_estimateEnergy error. Using a high default.",C)}}u=Math.max(((r=this.energyEstimateCache[`${o}:${A}`])!=null?r:1e5)-this.accountResources.ENERGY,0)}this.log("Account energy: ",this.accountResources.ENERGY),this.log("Energy needed: ",u);let d=i.length/2+65+64+5;if(i.length/2<128&&d--,o!=null&&this.accountExistsCache[o]===void 0)try{const A=yield this.multicastServers("trx_getAccountResource","/wallet/getaccountresource",{address:O(o)});this.accountExistsCache[o]=(0,t.Vk)(vt)(A)!=null}catch(A){this.log.error("calcTxFee error: Failed to call trx_getAccountResource. Allowing the user to proceed assuming high fee.",A)}c==null&&o!=null&&!this.accountExistsCache[o]&&(d=100),d<this.accountResources.BANDWIDTH&&(d=0),this.log("Account bandwidth: ",this.accountResources.BANDWIDTH),this.log("Bandwidth needed: ",d);let w=0;c==null&&o!=null&&!this.accountExistsCache[o]&&(w=this.networkFees.getCreateAccountFee+parseInt(l.multiplier)),this.log("Create account fee: ",w);const k=a!=null?this.networkFees.getMemoFee:0;this.log("Transaction note fee: ",k);const _=u*this.networkFees.getEnergyFee+d*this.networkFees.getTransactionFee+w+k;return this.log("Total fee in SUN: ",_),_.toString()})}txBuilder(e){return g(this,null,function*(){const{contractJson:n,feeLimit:r,note:a}=e,o=this.recentBlock.number.toString(16).padStart(8,"0").slice(4,8),c=this.recentBlock.hash.slice(16,32),i=this.recentBlock.timestamp+60*5*1e3,l=a==null?void 0:Q.YU.stringify(re.from(a,"ascii")),u=fe({raw_data:{contract:[n],ref_block_bytes:o,ref_block_hash:c,expiration:i,timestamp:this.recentBlock.timestamp,data:l,fee_limit:r}}),d=Q.YU.stringify(u.getRawData().serializeBinary());return{transaction:u,transactionHex:d}})}makeTransferJson(e){return g(this,null,function*(){const{currencyCode:n,toAddress:r,nativeAmount:a,data:o,note:c}=e;let i,l;if(n===this.currencyInfo.currencyCode)l={parameter:{value:{to_address:O(r),owner_address:O(this.walletLocalData.publicKey),amount:parseInt(a)}},type:"TransferContract"};else{const u=this.allTokens.find(d=>d.currencyCode===n);if((u==null?void 0:u.contractAddress)==null)throw new Error(`txBuilder unknown currency code ${n}`);l={parameter:{value:{owner_address:O(this.walletLocalData.publicKey),contract_address:O(u.contractAddress),data:o,call_value:0}},type:"TriggerSmartContract"},i=this.networkInfo.defaultFeeLimit}return{contractJson:l,feeLimit:i,note:c}})}makeUnfreezeTransaction(e){return g(this,null,function*(){const{params:{resource:n}}=e,r=this.stakingStatus.stakedAmounts.find(u=>{var d;return((d=u.otherParams)==null?void 0:d.type)===n});if(r==null)throw new Error("Nothing to unfreeze");const o={contractJson:{parameter:{value:{owner_address:O(this.walletLocalData.publicKey),resource:n}},type:"UnfreezeBalanceContract"}},{transactionHex:c}=yield this.txBuilder(o),i=yield this.calcTxFee({unsignedTxHex:c});return{txid:"",date:0,currencyCode:this.currencyInfo.currencyCode,blockHeight:0,nativeAmount:r.nativeAmount,isSend:r.nativeAmount.startsWith("-"),networkFee:i,ourReceiveAddresses:[],signedTx:"",otherParams:o,walletId:this.walletId,metadata:{notes:n}}})}makeFreezeV2Transaction(e){return g(this,null,function*(){const{params:{nativeAmount:n,resource:r}}=e,o={contractJson:{parameter:{value:{owner_address:O(this.walletLocalData.publicKey),frozen_balance:parseInt(n),resource:r==="ENERGY_V2"?"ENERGY":"BANDWIDTH"}},type:"FreezeBalanceV2Contract"}},{transactionHex:c}=yield this.txBuilder(o),i=yield this.calcTxFee({unsignedTxHex:c});return{txid:"",date:0,currencyCode:this.currencyInfo.currencyCode,blockHeight:0,nativeAmount:(0,m.mul)(n,"-1"),isSend:!0,networkFee:i,ourReceiveAddresses:[],signedTx:"",otherParams:o,walletId:this.walletId,metadata:{notes:r}}})}makeUnfreezeV2Transaction(e){return g(this,null,function*(){const{params:{nativeAmount:n,resource:r}}=e,a=this.stakingStatus.stakedAmounts.find(d=>{var w;return((w=d.otherParams)==null?void 0:w.type)===r});if(a==null)throw new Error("Nothing to unfreeze");const c={contractJson:{parameter:{value:{owner_address:O(this.walletLocalData.publicKey),unfreeze_balance:parseInt(n),resource:r==="ENERGY_V2"?"ENERGY":"BANDWIDTH"}},type:"UnfreezeBalanceV2Contract"}},{transactionHex:i}=yield this.txBuilder(c),l=yield this.calcTxFee({unsignedTxHex:i});return{txid:"",date:0,currencyCode:this.currencyInfo.currencyCode,blockHeight:0,nativeAmount:a.nativeAmount,isSend:a.nativeAmount.startsWith("-"),networkFee:l,ourReceiveAddresses:[],signedTx:"",otherParams:c,walletId:this.walletId,metadata:{notes:r}}})}startEngine(){return g(this,null,function*(){this.engineOn=!0,this.addToLoop("checkBlockchainInnerLoop",ge).catch(()=>{}),this.addToLoop("checkAccountInnerLoop",kt).catch(()=>{}),this.addToLoop("checkTokenBalances",kt).catch(()=>{}),this.addToLoop("checkUpdateNetworkFees",ve).catch(()=>{}),this.addToLoop("queryTransactions",pe).catch(()=>{}),yield Et(lt.prototype,this,"startEngine").call(this)})}getStakingStatus(){return g(this,null,function*(){return ht({},this.stakingStatus)})}resyncBlockchain(){return g(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}getMaxSpendable(e){return g(this,null,function*(){const n=this.getBalance({currencyCode:e.currencyCode});if(e.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{publicAddress:r,memo:a}=e.spendTargets[0],o=a===""?void 0:a;if(r==null||e.currencyCode==null)throw new Error("Error: need recipient address and/or currencyCode");if(e.currencyCode===this.currencyInfo.currencyCode){const c=(i,l)=>g(this,null,function*(){const u=(0,m.sub)(l,i);if((0,m.lte)(u,"1"))return i;const d=(0,m.add)(i,(0,m.div)(u,"2")),w={toAddress:r,currencyCode:this.currencyInfo.currencyCode,nativeAmount:d},{contractJson:k,feeLimit:_}=yield this.makeTransferJson(w),{transactionHex:A}=yield this.txBuilder({contractJson:k,feeLimit:_,note:o});e.spendTargets[0].nativeAmount=d;const S=yield this.calcTxFee({receiverAddress:r,unsignedTxHex:A,note:o}),z=(0,m.add)(d,S);return(0,m.gt)(z,n)?yield c(i,d):yield c(d,l)});return yield c("0",(0,m.add)(n,"1"))}else return e.spendTargets[0].nativeAmount=n,yield this.makeSpend(e),n})}makeSpend(e){return g(this,null,function*(){var n,r;if(e.otherParams!=null){let N;if(N=(0,t.Vk)(Dt)(e.otherParams),N!=null)return yield this.makeUnfreezeTransaction(N);if(N=(0,t.Vk)(Bt)(e.otherParams),N!=null)return yield this.makeFreezeV2Transaction(N);if(N=(0,t.Vk)(Ht)(e.otherParams),N!=null)return yield this.makeUnfreezeV2Transaction(N)}const{edgeSpendInfo:a,currencyCode:o}=Et(lt.prototype,this,"makeSpendCheck").call(this,e),c=o!==this.currencyInfo.currencyCode;if(a.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{nativeAmount:i,publicAddress:l,otherParams:u,memo:d}=a.spendTargets[0];if(l==null)throw new Error("makeSpend Missing publicAddress");if(i==null)throw new wt.$D;const w=(n=u==null?void 0:u.data)!=null?n:o!==this.currencyInfo.currencyCode?ne(l,i):void 0,k=c?this.allTokens.find(N=>N.currencyCode===o):void 0,_=d===""?void 0:d,A={currencyCode:o,toAddress:l,nativeAmount:i,contractAddress:k==null?void 0:k.contractAddress,data:w,note:_},{contractJson:S,feeLimit:z}=yield this.makeTransferJson(A),{transactionHex:C}=yield this.txBuilder({contractJson:S,feeLimit:z,note:_}),E=(k==null?void 0:k.contractAddress)!=null&&w!=null?{contractAddress:k==null?void 0:k.contractAddress,data:w}:void 0,v=yield this.calcTxFee({receiverAddress:l,unsignedTxHex:C,tokenOpts:E,note:_});let I,D,B,J;c?(I=i,D="0",B=v,J=B):(I=(0,m.add)(i,v),D=v,J=I);const ct=(r=this.walletLocalData.totalBalances[this.currencyInfo.currencyCode])!=null?r:"0";if((0,m.gt)(J,ct))throw new wt.C_({currencyCode:this.currencyInfo.currencyCode,networkFee:v});const K={contractJson:S,feeLimit:z,note:_},W={txid:"",date:0,currencyCode:o,blockHeight:0,nativeAmount:(0,m.mul)(I,"-1"),isSend:!0,networkFee:D,ourReceiveAddresses:[],signedTx:"",otherParams:K,walletId:this.walletId};return B!=null&&(W.parentNetworkFee=B),W})}signTx(e,n){return g(this,null,function*(){const r=(0,f.Xp)(e),a=yield this.txBuilder(r),{tronKey:o}=dt(n),c=me(a.transaction);a.transaction.txID=c.replace("0x","");const i=yield he(o,a.transaction);i.addSignature(Q.YU.parse(i.signature[0]));const l=Q.YU.stringify(i.serializeBinary());return e.signedTx=l,e})}broadcastTx(e){return g(this,null,function*(){const n={transaction:e.signedTx},r=yield this.multicastServers("trx_broadcastTx","/wallet/broadcasthex",n),a=Yt(r);if(!a.result)throw new Error(a.message);const{toAddress:o,contractAddress:c}=(0,f.Xp)(e);return e.currencyCode===this.currencyInfo.currencyCode&&o!=null&&(this.accountExistsCache[o]=!0),c!=null&&delete this.energyEstimateCache[`${o}:${c}`],e.txid=a.txid,e.date=Date.now()/1e3,e})}}function Te(s,e,n,r){return g(this,null,function*(){const a=Tt(n),o=new lt(s,e,a,r);return yield o.loadEngine(),o})}var xt=h(48764).Buffer,X=(s,e,n)=>new Promise((r,a)=>{var o=l=>{try{i(n.next(l))}catch(u){a(u)}},c=l=>{try{i(n.throw(l))}catch(u){a(u)}},i=l=>l.done?r(l.value):Promise.resolve(l.value).then(o,c);i((n=n.apply(s,e)).next())});const{utils:{crypto:{isAddressValid:ft,pkToAddress:we}}}=V();class _t{constructor(e){const{builtinTokens:n,currencyInfo:r,initOptions:a,io:o,log:c,networkInfo:i}=e;this.builtinTokens=n,this.currencyInfo=r,this.initOptions=st(a),this.io=o,this.log=c,this.networkInfo=i}getDisplayPrivateKey(e){return X(this,null,function*(){var n;const r=dt(e.keys);return(n=r.tronMnemonic)!=null?n:r.tronKey})}getDisplayPublicKey(e){return X(this,null,function*(){const{keys:n}=Tt(e);return n.publicKey})}importPrivateKey(e,n){return X(this,null,function*(){var r;if(/^(0x)?[0-9a-fA-F]{64}$/.test(e)){const a=xt.from(e.replace(/^0x/,""),"hex");if(Y().isValidPrivate(a)===!0)throw new Error("Invalid private key");return{tronKey:a.toString("hex")}}else{if(!(0,F.validateMnemonic)(e))throw new Error("Invalid input");const a=(r=n==null?void 0:n.derivationPath)!=null?r:this.networkInfo.defaultDerivationPath,o=yield this._mnemonicToTronKey(e,a);return{tronMnemonic:e,tronKey:o,derivationPath:a}}})}createPrivateKey(e){return X(this,null,function*(){if(e!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const n=xt.from(this.io.random(32)).toString("hex"),r=(0,F.entropyToMnemonic)(n);return yield this.importPrivateKey(r)})}_mnemonicToTronKey(e,n){return X(this,null,function*(){const r=yield(0,F.mnemonicToSeed)(e);return q().fromMasterSeed(r).derivePath(n).getWallet().getPrivateKeyString().replace("0x","")})}derivePublicKey(e){return X(this,null,function*(){if(e.type!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const{tronKey:n}=dt(e.keys);return{publicKey:we(n)}})}parseUri(e,n,r){return X(this,null,function*(){var a;const o={[this.currencyInfo.pluginId]:!0},{smartPayPublicAddress:c,smartPayUserId:i}=this.initOptions,{parsedUri:l,edgeParsedUri:u}=(0,rt.k)(this.currencyInfo,e,o,n!=null?n:this.currencyInfo.currencyCode,r),d=(a=u.publicAddress)!=null?a:"";if(ft(d))return u.uniqueIdentifier=l.query.memo,u;if(n==null||n==="USDT"){const w=yield U(this.io,this.builtinTokens,e,c,i);if(w!=null)return w}throw new Error("InvalidPublicAddressError")})}encodeUri(e){return X(this,arguments,function*(n,r=[]){const{publicAddress:a,nativeAmount:o,currencyCode:c}=n;if(!ft(a))throw new Error("InvalidPublicAddressError");let i;if(typeof o=="string"){const u=(0,f.Qs)(c!=null?c:this.currencyInfo.currencyCode,this.currencyInfo,r);if(u==null)throw new Error("InternalErrorInvalidCurrencyCode");i=(0,m.div)(o,u.multiplier,18)}return(0,rt.Q)(n,this.currencyInfo.pluginId,i)})}getTokenId(e){return X(this,null,function*(){(0,nt.Rp)(e);const n=(0,nt.Oj)(e.networkLocation);if(n==null||!ft(n.contractAddress))throw new Error("ErrorInvalidContractAddress");return n.contractAddress})}}function Ce(s){return X(this,null,function*(){return new _t(s)})}}}]);
1
+ (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[2005],{86352:function(mt,Z,h){"use strict";h.d(Z,{Vn:function(){return tt},lF:function(){return j},sp:function(){return V}});var m=h(76714),F=(t,P,x)=>new Promise((R,H)=>{var L=p=>{try{T(x.next(p))}catch(f){H(f)}},y=p=>{try{T(x.throw(p))}catch(f){H(f)}},T=p=>p.done?R(p.value):Promise.resolve(p.value).then(L,y);T((x=x.apply(t,P)).next())});const G=["https://info1.edge.app","https://info2.edge.app"];function Y(t,P,x){return F(this,arguments,function*(R,H,L,y=5e3,T=fetch){const p=R.map(f=>()=>F(this,null,function*(){const M=yield T(f+"/"+H,L);if(typeof M!="object"){const b=`Invalid return value ${H} in ${f}`;throw console.log(b),new Error(b)}return M}));return yield(0,m.QJ)(p,y)})}function j(t,P,x,R,H=5e3,L){return F(this,null,function*(){const y=yield Y((0,m.Sy)(P),x,R,H,L);if(!y.ok){const f=yield y.text();throw console.error(f),new Error(`Error fetching ${x}: ${f}`)}const T=yield y.json();return t(T)})}function q(t,P,x,R=5e3,H){return F(this,null,function*(){return yield Y((0,m.Sy)(t),P,x,R,H)})}const tt=(t,P,x,R)=>F(void 0,null,function*(){return yield q(G,t,P,x,R)}),V=t=>Object.keys(t).map(P=>{const x=t[P];return x==null?P:`${P}=${encodeURIComponent(x)}`}).join("&")},79014:function(mt,Z,h){"use strict";h.d(Z,{Q:function(){return L},k:function(){return H}});var m=h(77591),F=h.n(m),G=h(24350),Y=h(84564),j=h.n(Y),q=h(76714),tt=Object.defineProperty,V=Object.getOwnPropertySymbols,t=Object.prototype.hasOwnProperty,P=Object.prototype.propertyIsEnumerable,x=(y,T,p)=>T in y?tt(y,T,{enumerable:!0,configurable:!0,writable:!0,value:p}):y[T]=p,R=(y,T)=>{for(var p in T||(T={}))t.call(T,p)&&x(y,p,T[p]);if(V)for(var p of V(T))P.call(T,p)&&x(y,p,T[p]);return y};function H(y,T,p,f,M=[]){const b=R({},j()(T,{},!0)),et=T.startsWith(`${y.pluginId}://`);if(b.protocol!=null&&(b.protocol=b.protocol.replace(":","")),b.protocol!=null&&b.protocol!==""&&!p[b.protocol])throw new Error(`Uri protocol '${b.protocol}' is not supported for ${y.pluginId}.`);if(b.host===""&&b.pathname==="")throw new Error("Path and host not found in uri.");const U={publicAddress:b.host!==""?b.host:b.pathname.split("/")[0]},nt=b.query.label,rt=b.query.message,it=b.query.category;(nt!=null||rt!=null||it!=null||et)&&(U.metadata={},U.metadata.name=nt,U.metadata.notes=rt,U.metadata.category=it,U.metadata.gateway=et!=null?et:!1);const st=b.query.amount;if(st!=null&&typeof st=="string"){f==null&&(f=y.currencyCode);const ot=(0,q.Qs)(f!=null?f:"",y,M);if(ot==null)throw new Error("InternalErrorInvalidCurrencyCode");let at=(0,m.mul)(st,ot.multiplier);at=(0,m.toFixed)(at,0,0),U.nativeAmount=at,U.currencyCode=f}return{edgeParsedUri:U,parsedUri:b}}function L(y,T,p){if(y.publicAddress==null)throw new Error("InvalidPublicAddressError");if(p==null&&y.label==null&&y.message==null)return y.publicAddress;{let f="";p!=null&&(f+="amount="+p+"&"),(y.label!=null||y.message!=null)&&(typeof y.label=="string"&&(f+="label="+y.label+"&"),typeof y.message=="string"&&(f+="message="+y.message+"&")),f=f.substr(0,f.length-1);const M={scheme:T,path:y.publicAddress,query:f};return(0,G.qC)(M)}}},58780:function(mt,Z,h){"use strict";h.r(Z),h.d(Z,{TronTools:function(){return _t},makeCurrencyEngine:function(){return Te},makeCurrencyTools:function(){return Ce}});var m=h(77591),F=h(2153),G=h(21964),Y=h.n(G),j=h(48367),q=h.n(j),tt=h(3666),V=h.n(tt),t=h(82448),P=h(86352);const x=s=>{if(s.includes("@"))return R(s)?[!0,s.toLowerCase()]:[!1,"Invalid Email"];if(s.includes("+"))return s="+"+s.replace(/[^\d]+/g,""),s.length!==14?[!1,"Invalid Phone number"]:s.substring(0,3)!=="+55"?[!1,"Not brasilian number"]:[!0,s];if(s.length===36)return[!0,s];if(s.length===18)return/^\d{2}\.\d{3}\.\d{3}\/\d{4}-\d{2}$/.test(s)?L(s)?(s=s.replace(/[^\d]+/g,""),[!0,s]):[!1,"invalid cnpj"]:[!1,"invalid pixkey"];if(s.length===13&&/^\d+$/.test(s))return s.substr(0,2)!=="55"?[!1,"invalid pixkey"]:[!0,"+"+s];if(s.length<11)return[!1,"invalid pixkey"];if(s.length===14){if(/^\d+$/.test(s))return L(s)?[!0,s]:[!1,"invalid pixkey"];if(/^\d{3}\.\d{3}\.\d{3}-\d{2}$/.test(s))return H(s)?[!0,s.replace(/[^\d]+/g,"")]:[!1,"invalid cpf"]}return s.length===11?/^\d+$/.test(s)?H(s)?[!0,s.replace(/[^\d]+/g,"")]:s.charAt(0)==="0"?[!1,"invalid pixkey"]:[!0,"+55"+s]:[!1,"invalid pixkey"]:(s=s.replace(/[^\d]+/g,""),s.length===12?s.charAt(0)!=="0"?[!1,"invalid pixkey"]:[!0,"+55"+s.substr(1)]:s.length===11?H(s)?[!0,s]:[!0,"+55"+s]:[!1,"invalid pixkey"])};function R(s){return/^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(String(s).toLowerCase())}function H(s){if(s=s.replace(/[^\d]+/g,""),s===""||s.length!==11||s==="00000000000"||s==="11111111111"||s==="22222222222"||s==="33333333333"||s==="44444444444"||s==="55555555555"||s==="66666666666"||s==="77777777777"||s==="88888888888"||s==="99999999999")return!1;let e,n;e=0;for(let r=1;r<=9;r++)e=e+parseInt(s.substring(r-1,r))*(11-r);if(n=e*10%11,(n===10||n===11)&&(n=0),n!==parseInt(s.substring(9,10)))return!1;e=0;for(let r=1;r<=10;r++)e=e+parseInt(s.substring(r-1,r))*(12-r);return n=e*10%11,(n===10||n===11)&&(n=0),n===parseInt(s.substring(10,11))}function L(s){if(s=s.replace(/[^\d]+/g,""),s===""||s.length!==14||s==="00000000000000"||s==="11111111111111"||s==="22222222222222"||s==="33333333333333"||s==="44444444444444"||s==="55555555555555"||s==="66666666666666"||s==="77777777777777"||s==="88888888888888"||s==="99999999999999")return!1;let e=s.length-2,n=s.substring(0,e);const r=s.substring(e);let a=0,o=e-7;for(let i=e;i>=1;i--)a+=Number(n.charAt(e-i))*o--,o<2&&(o=9);let c=a%11<2?0:11-a%11;if(c!==Number(r.charAt(0)))return!1;e=e+1,n=s.substring(0,e),a=0,o=e-7;for(let i=e;i>=1;i--)a+=Number(n.charAt(e-i))*o--,o<2&&(o=9);return c=a%11<2?0:11-a%11,c===Number(r.charAt(1))}function y(s,e=!1){const n=p(s),r=[0,4129,8258,12387,16516,20645,24774,28903,33032,37161,41290,45419,49548,53677,57806,61935,4657,528,12915,8786,21173,17044,29431,25302,37689,33560,45947,41818,54205,50076,62463,58334,9314,13379,1056,5121,25830,29895,17572,21637,42346,46411,34088,38153,58862,62927,50604,54669,13907,9842,5649,1584,30423,26358,22165,18100,46939,42874,38681,34616,63455,59390,55197,51132,18628,22757,26758,30887,2112,6241,10242,14371,51660,55789,59790,63919,35144,39273,43274,47403,23285,19156,31415,27286,6769,2640,14899,10770,56317,52188,64447,60318,39801,35672,47931,43802,27814,31879,19684,23749,11298,15363,3168,7233,60846,64911,52716,56781,44330,48395,36200,40265,32407,28342,24277,20212,15891,11826,7761,3696,65439,61374,57309,53244,48923,44858,40793,36728,37256,33193,45514,41451,53516,49453,61774,57711,4224,161,12482,8419,20484,16421,28742,24679,33721,37784,41979,46042,49981,54044,58239,62302,689,4752,8947,13010,16949,21012,25207,29270,46570,42443,38312,34185,62830,58703,54572,50445,13538,9411,5280,1153,29798,25671,21540,17413,42971,47098,34713,38840,59231,63358,50973,55100,9939,14066,1681,5808,26199,30326,17941,22068,55628,51565,63758,59695,39368,35305,47498,43435,22596,18533,30726,26663,6336,2273,14466,10403,52093,56156,60223,64286,35833,39896,43963,48026,19061,23124,27191,31254,2801,6864,10931,14994,64814,60687,56684,52557,48554,44427,40424,36297,31782,27655,23652,19525,15522,11395,7392,3265,61215,65342,53085,57212,44955,49082,36825,40952,28183,32310,20053,24180,11923,16050,3793,7920];let a=65535;for(let i=0;i<n.length;i++){const u=(n[i]^a>>8)&255;a=r[u]^a<<8}const o=(a^0)&65535,c=T(o,4);return e?c.slice(2)+c.slice(0,2):c}function T(s,e){const n=s.toString(16).toUpperCase();return e>0?("0".repeat(e)+n).slice(-e):n.length%2===0?n:"0"+n}function p(s){let e=0;const n=s.length;let r=0,a=Math.max(32,n+(n>>>1)+7),o=new Uint8Array(a>>>3<<3);for(;e<n;){let c=s.charCodeAt(e++);if(c>=55296&&c<=56319){if(e<n){const i=s.charCodeAt(e);(i&64512)===56320&&(++e,c=((c&1023)<<10)+(i&1023)+65536)}if(c>=55296&&c<=56319)continue}if(r+4>o.length){a+=8,a*=1+e/s.length*2,a=a>>>3<<3;const i=new Uint8Array(a);i.set(o),o=i}if((c&4294967168)===0){o[r++]=c;continue}else if((c&4294965248)===0)o[r++]=c>>>6&31|192;else if((c&4294901760)===0)o[r++]=c>>>12&15|224,o[r++]=c>>>6&63|128;else if((c&4292870144)===0)o[r++]=c>>>18&7|240,o[r++]=c>>>12&63|128,o[r++]=c>>>6&63|128;else continue;o[r++]=c&63|128}return o.slice!=null?o.slice(0,r):o.subarray(0,r)}var f=h(76714),M=(s,e,n)=>new Promise((r,a)=>{var o=l=>{try{i(n.next(l))}catch(u){a(u)}},c=l=>{try{i(n.throw(l))}catch(u){a(u)}},i=l=>l.done?r(l.value):Promise.resolve(l.value).then(o,c);i((n=n.apply(s,e)).next())});const b=60*60*24*7,et=(0,t._C)((0,t.su)({status:(0,t.Wf)("ok"),msg:t.XC,data:(0,t.su)({amount:t.mH,name:t.XC,key:t.XC,timeout:t.mH})}),(0,t.su)({status:(0,t.Wf)("failed"),msg:t.XC})),yt=(0,t.su)({status:(0,t.Wf)("ok"),msg:t.XC,data:(0,t.su)({amount_usd:t.XC,price_brl:t.XC,total_brl:t.XC,fee_brl:t.XC,send_brl:t.XC,timeout:t.mH,amount_txusdt:t.XC,price_txusdt:t.mH,value_usd:t.XC,total_txusdt:t.XC})}),U=(s,e,n,r,a)=>M(void 0,null,function*(){const o=new Date,c=Object.keys(e).find(u=>e[u].currencyCode==="USDT");if(c==null)return;const i=e[c],l=(0,m.mul)("0.5",i.denominations[0].multiplier);if(n.length>36){const u=y(n.slice(0,-4));if(!n.endsWith(u))return;try{const d=(0,f.zR)(s),w=encodeURIComponent(n),k=yield(0,P.lF)(et,["https://connect.smartpay.com.vc"],`api/pix/qrdecode?qrcode=${w}`,void 0,void 0,d);if(k.status!=="ok")throw new Error(k.msg);const{data:_}=k,{amount:A,key:S,name:z,timeout:C}=_;if(C>0&&C<120)throw new Error("ErrorPixExpired");let E,v;if(A!==0){const D={type:"buy",profile:"transfer",currency:"brl",conv:"txusdt",target:"amount",user:a,amount:A===0?100:A},B=(0,P.sp)(D),J=yield(0,P.lF)(yt,["https://connect.smartpay.com.vc"],`api/swapix/swapquote?${B}`,void 0,void 0,d),{data:ct}=J,{amount_txusdt:K,timeout:W}=ct;if(W>0&&W<120)throw new Error("ErrorPixExpired");E=(0,m.mul)(K,i.denominations[0].multiplier);const N=Math.min(C>0?C:b,W>0?W:b);v=new Date(o.getTime()+N*1e3)}return{currencyCode:"USDT",metadata:{name:z,notes:`To PIX: ${S}`},expireDate:v,nativeAmount:E,minNativeAmount:l,publicAddress:r,uniqueIdentifier:n}}catch(d){console.log(`Could not query PIX address ${n}: ${d.message}`)}}else{const[u,d]=x(n);return u?{currencyCode:"USDT",minNativeAmount:l,metadata:{name:`PIX: ${d}`,notes:`To PIX: ${d}`},publicAddress:"TUmgPbM5J6om7Z2PJjzrbSEbXit84ZhVCj",uniqueIdentifier:d}:void 0}});var nt=h(20918),rt=h(79014),it=h(62177);const st=(0,t.su)({smartPayPublicAddress:(0,t.Zz)(t.XC,"TUmgPbM5J6om7Z2PJjzrbSEbXit84ZhVCj"),smartPayUserId:(0,t.Zz)(t.XC,"edge")}),ot=(0,t.su)({txid:t.XC,timestamp:t.mH}),at=(0,t.su)({txQueryCache:(0,t.Vk)((0,t.su)({mainnet:ot,trc20:ot}),()=>({mainnet:{txid:"",timestamp:0},trc20:{txid:"",timestamp:0}}))}),gt=(0,t.Wf)("ENERGY"),It=(0,t.Wf)("BANDWIDTH"),ut=(0,t._C)(gt,It),Pt=(0,t.Wf)("ENERGY_V2"),St=(0,t.Wf)("BANDWIDTH_V2"),pt=(0,t._C)(Pt,St),Dt=(0,t.su)({type:(0,t.Wf)("remove"),params:(0,t.su)({resource:ut})}),Bt=(0,t.su)({type:(0,t.Wf)("addV2"),params:(0,t.su)({nativeAmount:t.XC,resource:pt})}),Ht=(0,t.su)({type:(0,t.Wf)("removeV2"),params:(0,t.su)({nativeAmount:t.XC,resource:pt})}),Nt=(0,t.su)({chainParameter:(0,t._2)((0,t.su)({key:t.XC,value:(0,t.Zz)(t.mH)}))}),Ot=(0,t.su)({blockID:t.XC,block_header:(0,t.su)({raw_data:(0,t.su)({number:t.mH,timestamp:t.mH})})}),vt=(0,t.su)({freeNetUsed:(0,t.Vk)(t.mH,0),freeNetLimit:t.mH,EnergyUsed:(0,t.Vk)(t.mH,0),EnergyLimit:(0,t.Vk)(t.mH,0)}),Rt=(0,t.su)({frozen:(0,t.Zz)((0,t.vq)((0,t.su)({frozen_balance:t.mH,expire_time:t.mH}))),account_resource:(0,t.su)({frozen_balance_for_energy:(0,t.Zz)((0,t.su)({frozen_balance:t.mH,expire_time:t.mH}))}),frozenV2:(0,t.vq)((0,t.su)({amount:(0,t.Zz)(t.mH)}),(0,t.su)({type:gt,amount:(0,t.Zz)(t.mH)}),(0,t.su)({type:(0,t.Wf)("TRON_POWER")})),balance:(0,t.Vk)(t.mH,0)}),zt=(0,t.su)({constant_result:(0,t.vq)(t.XC)}),Ft=(0,t.su)({ret:(0,t._2)((0,t.su)({contractRet:t.XC,fee:t.mH})),txID:t.XC,unfreeze_amount:(0,t.Zz)(t.mH),blockNumber:t.mH,block_timestamp:t.mH,raw_data:(0,t.su)({contract:(0,t._2)(t.JC)})}),Lt=(0,t.su)({transaction_id:t.XC,token_info:(0,t.su)({address:t.XC}),block_timestamp:t.mH,from:t.XC,to:t.XC,type:t.XC,value:t.XC}),Ut=(0,t.su)({fee:(0,t.Zz)(t.mH,0),blockNumber:t.mH}),Xt=(0,t.su)({parameter:(0,t.su)({value:(0,t.su)({amount:t.mH,owner_address:t.XC,to_address:t.XC})}),type:(0,t.Wf)("TransferContract")}),Kt=(0,t.su)({parameter:(0,t.su)({value:(0,t.su)({data:t.XC,owner_address:t.XC,contract_address:t.XC})}),type:(0,t.Wf)("TriggerSmartContract")}),Wt=(0,t.su)({parameter:(0,t.su)({value:(0,t.su)({frozen_balance:t.mH,resource_type:ut,owner_address:t.XC})}),type:(0,t.Wf)("FreezeBalanceContract")}),Vt=(0,t.su)({parameter:(0,t.su)({value:(0,t.su)({resource_type:ut,owner_address:t.XC})}),type:(0,t.Wf)("UnfreezeBalanceContract")}),Mt=(0,t.su)({parameter:(0,t.su)({value:(0,t.su)({frozen_balance:t.mH,owner_address:t.XC})}),type:(0,t.Wf)("FreezeBalanceV2Contract")}),$t=(0,t.su)({parameter:(0,t.su)({value:(0,t.su)({unfreeze_balance:t.mH,owner_address:t.XC})}),type:(0,t.Wf)("UnfreezeBalanceV2Contract")}),Jt=s=>(0,t.su)({data:(0,t._2)(s),success:t.jK,meta:(0,t.su)({links:(0,t.Zz)((0,t.su)({next:t.XC})),page_size:t.mH})}),Zt=(0,t.su)({energy_used:t.mH,transaction:(0,t.su)({ret:(0,t._2)((0,t.su)({ret:(0,t.Zz)(t.XC)}))})}),Yt=(0,t.su)({result:t.jK,txid:t.XC,message:t.XC}),Tt=it.BQ,dt=(0,t.su)({tronMnemonic:(0,t.Zz)(t.XC),tronKey:t.XC,derivationPath:(0,t.Zz)(t.XC)});var wt=h(94935),Q=h(35620),Qt=h(84650),Gt=h(68142),jt=h.n(Gt),qt=h(48764).Buffer;const{utils:{crypto:{decode58Check:te,getBase58CheckAddress:ee}}}=V(),O=s=>{const e=te(s);return Q.YU.stringify(e)},$=s=>{const e=Q.YU.parse(s);return ee(Array.from(e))},Ct="a9059cbb",be=s=>{if(!s.startsWith(Ct))throw new Error("Not a TRC20 data payload");const e=s.replace(Ct,""),n=`41${e.substring(24,64)}`,r=$(n),a=e.substring(64,128),o=hexToDecimal(a);return[r,o]},ne=(s,e)=>{const n=O(s).replace(/^(41)/,"0x"),r=jt().simpleEncode("transfer(address,uint256):(uint256)",n,e);return qt.from(r).toString("hex")};var re=h(48764).Buffer,se=Object.defineProperty,oe=Object.defineProperties,ae=Object.getOwnPropertyDescriptors,bt=Object.getOwnPropertySymbols,ce=Object.getPrototypeOf,ie=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable,ue=Reflect.get,At=(s,e,n)=>e in s?se(s,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):s[e]=n,ht=(s,e)=>{for(var n in e||(e={}))ie.call(e,n)&&At(s,n,e[n]);if(bt)for(var n of bt(e))le.call(e,n)&&At(s,n,e[n]);return s},de=(s,e)=>oe(s,ae(e)),Et=(s,e,n)=>ue(ce(s),n,e),g=(s,e,n)=>new Promise((r,a)=>{var o=l=>{try{i(n.next(l))}catch(u){a(u)}},c=l=>{try{i(n.throw(l))}catch(u){a(u)}},i=l=>l.done?r(l.value):Promise.resolve(l.value).then(o,c);i((n=n.apply(s,e)).next())});const{utils:{crypto:{signTransaction:he},transaction:{txJsonToPb:fe,txPbToTxID:me}}}=V(),ye=(0,f.jT)(),kt=2e4,ge=2e4,pe=3e3,ve=60*10*1e3;class lt extends Qt.P{constructor(e,n,r,a){super(e,n,r,a);const{networkInfo:o}=e;this.fetchCors=(0,f.zR)(e.io),this.networkInfo=o,this.recentBlock={hash:"0",number:0,timestamp:0},this.accountResources={BANDWIDTH:0,ENERGY:0},this.networkFees={getCreateAccountFee:1e5,getTransactionFee:1e3,getEnergyFee:280,getMemoFee:1e6},this.accountExistsCache={},this.energyEstimateCache={},this.processTRXTransaction=this.processTRXTransaction.bind(this),this.processTRC20Transaction=this.processTRC20Transaction.bind(this),this.stakingStatus={stakedAmounts:[{nativeAmount:"0",otherParams:{type:"BANDWIDTH"}},{nativeAmount:"0",otherParams:{type:"ENERGY"}}]}}setOtherData(e){this.otherData=at(e)}fetch(e,n){return g(this,arguments,function*(r,a,o={}){const c=r+a,i=yield this.fetchCors(c,o);if(!i.ok||i.status!==200)throw this.log(`The server returned error code ${i.status} for ${c}`),new Error(`The server returned error code ${i.status} for ${c}`);const l=yield i.json();if(typeof l!="object"){const u=`Invalid return value ${a} in ${r}`;throw this.log(u),new Error(u)}return{server:r,result:l}})}checkBlockchainInnerLoop(){return g(this,null,function*(){try{const e=yield this.multicastServers("trx_blockNumber","/wallet/getnowblock"),n=Ot(e),r=n.block_header.raw_data.number;Object.assign(this.recentBlock,{hash:n.blockID,number:r,timestamp:n.block_header.raw_data.timestamp}),this.walletLocalData.blockHeight!==r&&(this.checkDroppedTransactionsThrottled(),this.walletLocalData.blockHeight=r,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight))}catch(e){this.log.error("Error fetching height: ",e)}})}checkTokenBalances(){return g(this,null,function*(){const e=O(this.walletLocalData.publicKey);for(const n of this.enabledTokens){const r=this.allTokens.find(c=>c.currencyCode===n);if((r==null?void 0:r.contractAddress)==null)continue;const o={contract_address:O(r.contractAddress),function_selector:"balanceOf(address)",parameter:(0,f.gc)(e,32),owner_address:e};try{const c=yield this.multicastServers("trx_getBalance","/wallet/triggerconstantcontract",o),i=zt(c);r!=null&&this.updateBalance(r.currencyCode,(0,f.Z8)(i.constant_result[0]))}catch(c){this.log.error(`Failed to get balance of ${n}`,c)}}})}checkAccountInnerLoop(){return g(this,null,function*(){const e={address:O(this.walletLocalData.publicKey)};try{const n=yield this.multicastServers("trx_getBalance","/wallet/getaccount",e),r=(0,t.Vk)(Rt)(n);if(r==null){this.updateBalance(this.currencyInfo.currencyCode,"0");return}this.updateBalance(this.currencyInfo.currencyCode,r.balance.toString());const{frozen:a,account_resource:{frozen_balance_for_energy:o}}=r,c=[];if(a!=null){const u=a[0].frozen_balance.toString(),d=new Date(a[0].expire_time);c.push({nativeAmount:u,unlockDate:d,otherParams:{type:"BANDWIDTH"}})}if(o!=null){const u=o.frozen_balance.toString(),d=new Date(o.expire_time);c.push({nativeAmount:u,unlockDate:d,otherParams:{type:"ENERGY"}})}const[i,l]=r.frozenV2;i.amount!=null&&c.push({nativeAmount:i.amount.toFixed(),otherParams:{type:"BANDWIDTH_V2"}}),l.amount!=null&&c.push({nativeAmount:l.amount.toFixed(),otherParams:{type:"ENERGY_V2"}}),this.stakingStatus={stakedAmounts:c},this.currencyEngineCallbacks.onStakingStatusChanged(ht({},this.stakingStatus))}catch(n){this.log.error("Error checking TRX address balance: ",n)}try{const n=yield this.multicastServers("trx_getAccountResource","/wallet/getaccountresource",e),r=vt(n);this.accountResources={BANDWIDTH:r.freeNetLimit-r.freeNetUsed,ENERGY:r.EnergyLimit-r.EnergyUsed}}catch(n){this.log.error("Error checking TRX address resources: ",n)}})}queryTransactions(){return g(this,null,function*(){return yield ye(()=>g(this,null,function*(){return yield this.queryTransactionsInnerLoop()}))})}queryTransactionsInnerLoop(){return g(this,null,function*(){try{yield this.fetchTrxTransactions(),yield this.fetchTrc20Transactions()}catch(e){throw this.log.error("Error checkTransactionsFetch fetchTrxTransactions: ",e),e}this.transactionsChangedArray.length>0&&(this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[]);for(const e of this.enabledTokens)this.tokenCheckTransactionsStatus[e]=1;this.updateOnAddressesChecked()})}fetchTrxTransactions(){return g(this,null,function*(){let e=!1;for(;!e;)e=yield this.fetchTransactions("mainnet",Ft,this.processTRXTransaction)})}fetchTrc20Transactions(){return g(this,null,function*(){let e=!1;for(;!e;)e=yield this.fetchTransactions("trc20",Lt,this.processTRC20Transaction)})}fetchTransactions(e,n,r){return g(this,null,function*(){var a;const o=e==="trc20"?e:"",c=this.otherData.txQueryCache[e].timestamp,i=`/v1/accounts/${this.walletLocalData.publicKey}/transactions/${o}?limit=200&order_by=block_timestamp,asc&min_timestamp=${c}`,l=yield this.multicastServers("trx_getTransactions",i),{data:u,meta:d,success:w}=Jt(n)(l),k=((a=d==null?void 0:d.links)==null?void 0:a.next)==null;if(!w)throw new Error("Failed to query TRX transactions");for(const _ of u){const{timestamp:A,txid:S}=yield r(_);this.otherData.txQueryCache[e].txid=S,this.otherData.txQueryCache[e].timestamp=A,this.walletLocalDataDirty=!0}return k})}processTRXTransaction(e){const{txID:n,block_timestamp:r,blockNumber:a,ret:o,unfreeze_amount:c,raw_data:{contract:i}}=e,l={txid:n,timestamp:r};if(n===this.otherData.txQueryCache.mainnet.txid||o.length<1)return l;const u=[];for(const d of i){const w=(0,t.Vk)(Xt)(d);if(w!=null){const{parameter:{value:{amount:C,owner_address:E,to_address:v}}}=w,{contractRet:I,fee:D}=o[0];let B=D.toString();const J=$(E),ct=$(v);let K=C.toString();if(J===this.walletLocalData.publicKey)J===ct?K=(0,m.mul)(B,"-1"):K=(0,m.mul)((0,m.add)(K,B),"-1"),I!=="SUCCESS"&&(K="0");else{if(I!=="SUCCESS")return l;u.push(this.walletLocalData.publicKey),B="0"}const{currencyCode:W}=this.currencyInfo,N={txid:n,date:Math.floor(r/1e3),currencyCode:W,blockHeight:a,nativeAmount:K,isSend:K.startsWith("-"),networkFee:B,ourReceiveAddresses:u,signedTx:"",walletId:this.walletId};return this.addTransaction(W,N),l}const k=(0,t.Vk)(Kt)(d);if(k!=null){const{parameter:{value:{owner_address:C}}}=k;if($(C)!==this.walletLocalData.publicKey)break;const E=o[0].fee.toString(),{currencyCode:v}=this.currencyInfo,I={txid:n,date:Math.floor(r/1e3),currencyCode:v,blockHeight:a,nativeAmount:(0,m.mul)(E,"-1"),isSend:!0,networkFee:E,ourReceiveAddresses:u,signedTx:"",walletId:this.walletId};return this.addTransaction(v,I),l}const _=(0,t.Vk)(Wt)(d);if(_!=null){const{parameter:{value:{owner_address:C,frozen_balance:E}}}=_;if($(C)!==this.walletLocalData.publicKey)break;const v=o[0].fee.toString(),I=(0,m.add)(E.toString(),v),{currencyCode:D}=this.currencyInfo,B={txid:n,date:Math.floor(r/1e3),currencyCode:D,blockHeight:a,nativeAmount:(0,m.mul)(I,"-1"),isSend:!0,networkFee:v,ourReceiveAddresses:u,signedTx:"",walletId:this.walletId};return this.addTransaction(D,B),l}const A=(0,t.Vk)(Vt)(d);if(A!=null){if(c==null)return l;const{parameter:{value:{owner_address:C}}}=A;if($(C)!==this.walletLocalData.publicKey)break;const E=o[0].fee.toString(),{currencyCode:v}=this.currencyInfo,I=(0,m.sub)(c.toString(),E),D={txid:n,date:Math.floor(r/1e3),currencyCode:v,blockHeight:a,nativeAmount:I,isSend:I.startsWith("-"),networkFee:E,ourReceiveAddresses:u,signedTx:"",walletId:this.walletId};return this.addTransaction(v,D),l}const S=(0,t.Vk)(Mt)(d);if(S!=null){const{parameter:{value:{owner_address:C,frozen_balance:E}}}=S;if($(C)!==this.walletLocalData.publicKey)break;const v=o[0].fee.toString(),I=(0,m.add)(E.toString(),v),{currencyCode:D}=this.currencyInfo,B={txid:n,date:Math.floor(r/1e3),currencyCode:D,blockHeight:a,nativeAmount:(0,m.mul)(I,"-1"),isSend:!0,networkFee:v,ourReceiveAddresses:u,signedTx:"",walletId:this.walletId};return this.addTransaction(D,B),l}const z=(0,t.Vk)($t)(d);if(z!=null){const{parameter:{value:{unfreeze_balance:C,owner_address:E}}}=z;if($(E)!==this.walletLocalData.publicKey)break;const v=o[0].fee.toString(),{currencyCode:I}=this.currencyInfo,D=(0,m.sub)(C.toString(),v),B={txid:n,date:Math.floor(r/1e3),currencyCode:I,blockHeight:a,nativeAmount:D,isSend:D.startsWith("-"),networkFee:v,ourReceiveAddresses:u,signedTx:"",walletId:this.walletId};return this.addTransaction(I,B),l}}return l}processTRC20Transaction(e){return g(this,null,function*(){const{transaction_id:n,token_info:{address:r},block_timestamp:a,from:o,to:c,type:i,value:l}=e,u={txid:n,timestamp:a};if(n===this.otherData.txQueryCache.trc20.txid)return u;const d=yield this.multicastServers("trx_getTransactionInfo","/wallet/gettransactioninfobyid",{value:n}),{blockNumber:w,fee:k}=Ut(d),_=this.allTokens.find(E=>E.contractAddress===r);if(i!=="Transfer"||_==null)return u;const A=[];let S=l;const z=k;if(o===this.walletLocalData.publicKey)S=(0,m.mul)(l,"-1");else if(c===this.walletLocalData.publicKey)A.push(this.walletLocalData.publicKey);else return u;const C={txid:n,date:Math.floor(a/1e3),currencyCode:_.currencyCode,blockHeight:w,nativeAmount:S,isSend:S.startsWith("-"),networkFee:"0",ourReceiveAddresses:A,signedTx:"",walletId:this.walletId};return(0,m.lt)(S,"0")&&(C.parentNetworkFee=z.toString()),this.addTransaction(_.currencyCode,C),u})}checkUpdateNetworkFees(){return g(this,null,function*(){try{const e=yield this.multicastServers("trx_chainParams","/wallet/getchainparameters"),n=Nt(e).chainParameter;for(const r of Object.keys(this.networkFees)){const a=n.find(o=>o.key===r);a!=null&&(this.networkFees=de(ht({},this.networkFees),{[r]:a.value}))}}catch(e){this.log.error("checkUpdateNetworkFees error: ",e)}})}multicastServers(e,n){return g(this,arguments,function*(r,a,o={}){let c={result:"",server:"no server"},i=[];switch(r){case"trx_chainParams":i=this.networkInfo.tronNodeServers.map(l=>()=>g(this,null,function*(){return yield this.fetch(l,a)}));break;case"trx_blockNumber":case"trx_broadcastTx":case"trx_estimateEnergy":case"trx_getAccountResource":case"trx_getBalance":case"trx_getTransactionInfo":i=this.networkInfo.tronNodeServers.map(l=>()=>g(this,null,function*(){const u={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(o)};return yield this.fetch(l,a,u)}));break;case"trx_getTransactions":i=this.networkInfo.tronApiServers.map(l=>()=>g(this,null,function*(){const u={headers:{Accept:"application/json","Content-Type":"application/json"}};return yield this.fetch(l,a,u)}));break}return i=(0,f.Sy)(i),c=yield(0,f.QJ)(i),this.log(`TRX multicastServers ${r} ${c.server} won`),c.result})}calcTxFee(e){return g(this,null,function*(){var n,r;const{note:a,receiverAddress:o,tokenOpts:c,unsignedTxHex:i}=e,l=(0,f.aL)(this.currencyInfo.currencyCode,this.currencyInfo,this.allTokensMap);if(l==null)throw new Error("calcTxFee unknown denom");let u=0;if(c!=null&&o!=null){const{contractAddress:A,data:S}=c;if(this.energyEstimateCache[`${o}:${A}`]==null){const z={owner_address:O(this.walletLocalData.publicKey),contract_address:O(A),function_selector:"transfer(address,uint256)",parameter:S.slice(8)};try{const C=yield this.multicastServers("trx_estimateEnergy","/wallet/triggerconstantcontract",z),E=Zt(C),v=(n=E.transaction.ret[0])==null?void 0:n.ret;if(v!=null&&v!=="SUCCESS")throw new Error("calcTxFee Failed to estimate fee");this.energyEstimateCache[`${o}:${A}`]=E.energy_used}catch(C){this.log.warn("trx_estimateEnergy error. Using a high default.",C)}}u=Math.max(((r=this.energyEstimateCache[`${o}:${A}`])!=null?r:1e5)-this.accountResources.ENERGY,0)}this.log("Account energy: ",this.accountResources.ENERGY),this.log("Energy needed: ",u);let d=i.length/2+65+64+5;if(i.length/2<128&&d--,o!=null&&this.accountExistsCache[o]===void 0)try{const A=yield this.multicastServers("trx_getAccountResource","/wallet/getaccountresource",{address:O(o)});this.accountExistsCache[o]=(0,t.Vk)(vt)(A)!=null}catch(A){this.log.error("calcTxFee error: Failed to call trx_getAccountResource. Allowing the user to proceed assuming high fee.",A)}c==null&&o!=null&&!this.accountExistsCache[o]&&(d=100),d<this.accountResources.BANDWIDTH&&(d=0),this.log("Account bandwidth: ",this.accountResources.BANDWIDTH),this.log("Bandwidth needed: ",d);let w=0;c==null&&o!=null&&!this.accountExistsCache[o]&&(w=this.networkFees.getCreateAccountFee+parseInt(l.multiplier)),this.log("Create account fee: ",w);const k=a!=null?this.networkFees.getMemoFee:0;this.log("Transaction note fee: ",k);const _=u*this.networkFees.getEnergyFee+d*this.networkFees.getTransactionFee+w+k;return this.log("Total fee in SUN: ",_),_.toString()})}txBuilder(e){return g(this,null,function*(){const{contractJson:n,feeLimit:r,note:a}=e,o=this.recentBlock.number.toString(16).padStart(8,"0").slice(4,8),c=this.recentBlock.hash.slice(16,32),i=this.recentBlock.timestamp+60*5*1e3,l=a==null?void 0:Q.YU.stringify(re.from(a,"ascii")),u=fe({raw_data:{contract:[n],ref_block_bytes:o,ref_block_hash:c,expiration:i,timestamp:this.recentBlock.timestamp,data:l,fee_limit:r}}),d=Q.YU.stringify(u.getRawData().serializeBinary());return{transaction:u,transactionHex:d}})}makeTransferJson(e){return g(this,null,function*(){const{currencyCode:n,toAddress:r,nativeAmount:a,data:o,note:c}=e;let i,l;if(n===this.currencyInfo.currencyCode)l={parameter:{value:{to_address:O(r),owner_address:O(this.walletLocalData.publicKey),amount:parseInt(a)}},type:"TransferContract"};else{const u=this.allTokens.find(d=>d.currencyCode===n);if((u==null?void 0:u.contractAddress)==null)throw new Error(`txBuilder unknown currency code ${n}`);l={parameter:{value:{owner_address:O(this.walletLocalData.publicKey),contract_address:O(u.contractAddress),data:o,call_value:0}},type:"TriggerSmartContract"},i=this.networkInfo.defaultFeeLimit}return{contractJson:l,feeLimit:i,note:c}})}makeUnfreezeTransaction(e){return g(this,null,function*(){const{params:{resource:n}}=e,r=this.stakingStatus.stakedAmounts.find(u=>{var d;return((d=u.otherParams)==null?void 0:d.type)===n});if(r==null)throw new Error("Nothing to unfreeze");const o={contractJson:{parameter:{value:{owner_address:O(this.walletLocalData.publicKey),resource:n}},type:"UnfreezeBalanceContract"}},{transactionHex:c}=yield this.txBuilder(o),i=yield this.calcTxFee({unsignedTxHex:c});return{txid:"",date:0,currencyCode:this.currencyInfo.currencyCode,blockHeight:0,nativeAmount:r.nativeAmount,isSend:r.nativeAmount.startsWith("-"),networkFee:i,ourReceiveAddresses:[],signedTx:"",otherParams:o,walletId:this.walletId,metadata:{notes:n}}})}makeFreezeV2Transaction(e){return g(this,null,function*(){const{params:{nativeAmount:n,resource:r}}=e,o={contractJson:{parameter:{value:{owner_address:O(this.walletLocalData.publicKey),frozen_balance:parseInt(n),resource:r==="ENERGY_V2"?"ENERGY":"BANDWIDTH"}},type:"FreezeBalanceV2Contract"}},{transactionHex:c}=yield this.txBuilder(o),i=yield this.calcTxFee({unsignedTxHex:c});return{txid:"",date:0,currencyCode:this.currencyInfo.currencyCode,blockHeight:0,nativeAmount:(0,m.mul)(n,"-1"),isSend:!0,networkFee:i,ourReceiveAddresses:[],signedTx:"",otherParams:o,walletId:this.walletId,metadata:{notes:r}}})}makeUnfreezeV2Transaction(e){return g(this,null,function*(){const{params:{nativeAmount:n,resource:r}}=e,a=this.stakingStatus.stakedAmounts.find(d=>{var w;return((w=d.otherParams)==null?void 0:w.type)===r});if(a==null)throw new Error("Nothing to unfreeze");const c={contractJson:{parameter:{value:{owner_address:O(this.walletLocalData.publicKey),unfreeze_balance:parseInt(n),resource:r==="ENERGY_V2"?"ENERGY":"BANDWIDTH"}},type:"UnfreezeBalanceV2Contract"}},{transactionHex:i}=yield this.txBuilder(c),l=yield this.calcTxFee({unsignedTxHex:i});return{txid:"",date:0,currencyCode:this.currencyInfo.currencyCode,blockHeight:0,nativeAmount:a.nativeAmount,isSend:a.nativeAmount.startsWith("-"),networkFee:l,ourReceiveAddresses:[],signedTx:"",otherParams:c,walletId:this.walletId,metadata:{notes:r}}})}startEngine(){return g(this,null,function*(){this.engineOn=!0,this.addToLoop("checkBlockchainInnerLoop",ge).catch(()=>{}),this.addToLoop("checkAccountInnerLoop",kt).catch(()=>{}),this.addToLoop("checkTokenBalances",kt).catch(()=>{}),this.addToLoop("checkUpdateNetworkFees",ve).catch(()=>{}),this.addToLoop("queryTransactions",pe).catch(()=>{}),yield Et(lt.prototype,this,"startEngine").call(this)})}getStakingStatus(){return g(this,null,function*(){return ht({},this.stakingStatus)})}resyncBlockchain(){return g(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}getMaxSpendable(e){return g(this,null,function*(){const n=this.getBalance({currencyCode:e.currencyCode});if(e.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{publicAddress:r,memo:a}=e.spendTargets[0],o=a===""?void 0:a;if(r==null||e.currencyCode==null)throw new Error("Error: need recipient address and/or currencyCode");if(e.currencyCode===this.currencyInfo.currencyCode){const c=(i,l)=>g(this,null,function*(){const u=(0,m.sub)(l,i);if((0,m.lte)(u,"1"))return i;const d=(0,m.add)(i,(0,m.div)(u,"2")),w={toAddress:r,currencyCode:this.currencyInfo.currencyCode,nativeAmount:d},{contractJson:k,feeLimit:_}=yield this.makeTransferJson(w),{transactionHex:A}=yield this.txBuilder({contractJson:k,feeLimit:_,note:o});e.spendTargets[0].nativeAmount=d;const S=yield this.calcTxFee({receiverAddress:r,unsignedTxHex:A,note:o}),z=(0,m.add)(d,S);return(0,m.gt)(z,n)?yield c(i,d):yield c(d,l)});return yield c("0",(0,m.add)(n,"1"))}else return e.spendTargets[0].nativeAmount=n,yield this.makeSpend(e),n})}makeSpend(e){return g(this,null,function*(){var n,r;if(e.otherParams!=null){let N;if(N=(0,t.Vk)(Dt)(e.otherParams),N!=null)return yield this.makeUnfreezeTransaction(N);if(N=(0,t.Vk)(Bt)(e.otherParams),N!=null)return yield this.makeFreezeV2Transaction(N);if(N=(0,t.Vk)(Ht)(e.otherParams),N!=null)return yield this.makeUnfreezeV2Transaction(N)}const{edgeSpendInfo:a,currencyCode:o}=Et(lt.prototype,this,"makeSpendCheck").call(this,e),c=o!==this.currencyInfo.currencyCode;if(a.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{nativeAmount:i,publicAddress:l,otherParams:u,memo:d}=a.spendTargets[0];if(l==null)throw new Error("makeSpend Missing publicAddress");if(i==null)throw new wt.$D;const w=(n=u==null?void 0:u.data)!=null?n:o!==this.currencyInfo.currencyCode?ne(l,i):void 0,k=c?this.allTokens.find(N=>N.currencyCode===o):void 0,_=d===""?void 0:d,A={currencyCode:o,toAddress:l,nativeAmount:i,contractAddress:k==null?void 0:k.contractAddress,data:w,note:_},{contractJson:S,feeLimit:z}=yield this.makeTransferJson(A),{transactionHex:C}=yield this.txBuilder({contractJson:S,feeLimit:z,note:_}),E=(k==null?void 0:k.contractAddress)!=null&&w!=null?{contractAddress:k==null?void 0:k.contractAddress,data:w}:void 0,v=yield this.calcTxFee({receiverAddress:l,unsignedTxHex:C,tokenOpts:E,note:_});let I,D,B,J;c?(I=i,D="0",B=v,J=B):(I=(0,m.add)(i,v),D=v,J=I);const ct=(r=this.walletLocalData.totalBalances[this.currencyInfo.currencyCode])!=null?r:"0";if((0,m.gt)(J,ct))throw new wt.C_({currencyCode:this.currencyInfo.currencyCode,networkFee:v});const K={contractJson:S,feeLimit:z,note:_},W={txid:"",date:0,currencyCode:o,blockHeight:0,nativeAmount:(0,m.mul)(I,"-1"),isSend:!0,networkFee:D,ourReceiveAddresses:[],signedTx:"",otherParams:K,walletId:this.walletId};return B!=null&&(W.parentNetworkFee=B),W})}signTx(e,n){return g(this,null,function*(){const r=(0,f.Xp)(e),a=yield this.txBuilder(r),{tronKey:o}=dt(n),c=me(a.transaction);a.transaction.txID=c.replace("0x","");const i=yield he(o,a.transaction);i.addSignature(Q.YU.parse(i.signature[0]));const l=Q.YU.stringify(i.serializeBinary());return e.signedTx=l,e})}broadcastTx(e){return g(this,null,function*(){const n={transaction:e.signedTx},r=yield this.multicastServers("trx_broadcastTx","/wallet/broadcasthex",n),a=Yt(r);if(!a.result)throw new Error(a.message);const{toAddress:o,contractAddress:c}=(0,f.Xp)(e);return e.currencyCode===this.currencyInfo.currencyCode&&o!=null&&(this.accountExistsCache[o]=!0),c!=null&&delete this.energyEstimateCache[`${o}:${c}`],e.txid=a.txid,e.date=Date.now()/1e3,e})}}function Te(s,e,n,r){return g(this,null,function*(){const a=Tt(n),o=new lt(s,e,a,r);return yield o.loadEngine(),o})}var xt=h(48764).Buffer,X=(s,e,n)=>new Promise((r,a)=>{var o=l=>{try{i(n.next(l))}catch(u){a(u)}},c=l=>{try{i(n.throw(l))}catch(u){a(u)}},i=l=>l.done?r(l.value):Promise.resolve(l.value).then(o,c);i((n=n.apply(s,e)).next())});const{utils:{crypto:{isAddressValid:ft,pkToAddress:we}}}=V();class _t{constructor(e){const{builtinTokens:n,currencyInfo:r,initOptions:a,io:o,log:c,networkInfo:i}=e;this.builtinTokens=n,this.currencyInfo=r,this.initOptions=st(a),this.io=o,this.log=c,this.networkInfo=i}getDisplayPrivateKey(e){return X(this,null,function*(){var n;const r=dt(e.keys);return(n=r.tronMnemonic)!=null?n:r.tronKey})}getDisplayPublicKey(e){return X(this,null,function*(){const{keys:n}=Tt(e);return n.publicKey})}importPrivateKey(e,n){return X(this,null,function*(){var r;if(/^(0x)?[0-9a-fA-F]{64}$/.test(e)){const a=xt.from(e.replace(/^0x/,""),"hex");if(Y().isValidPrivate(a)===!0)throw new Error("Invalid private key");return{tronKey:a.toString("hex")}}else{if(!(0,F.validateMnemonic)(e))throw new Error("Invalid input");const a=(r=n==null?void 0:n.derivationPath)!=null?r:this.networkInfo.defaultDerivationPath,o=yield this._mnemonicToTronKey(e,a);return{tronMnemonic:e,tronKey:o,derivationPath:a}}})}createPrivateKey(e){return X(this,null,function*(){if(e!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const n=xt.from(this.io.random(32)).toString("hex"),r=(0,F.entropyToMnemonic)(n);return yield this.importPrivateKey(r)})}_mnemonicToTronKey(e,n){return X(this,null,function*(){const r=yield(0,F.mnemonicToSeed)(e);return q().fromMasterSeed(r).derivePath(n).getWallet().getPrivateKeyString().replace("0x","")})}derivePublicKey(e){return X(this,null,function*(){if(e.type!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const{tronKey:n}=dt(e.keys);return{publicKey:we(n)}})}parseUri(e,n,r){return X(this,null,function*(){var a;const o={[this.currencyInfo.pluginId]:!0},{smartPayPublicAddress:c,smartPayUserId:i}=this.initOptions,{parsedUri:l,edgeParsedUri:u}=(0,rt.k)(this.currencyInfo,e,o,n!=null?n:this.currencyInfo.currencyCode,r),d=(a=u.publicAddress)!=null?a:"";if(ft(d))return u.uniqueIdentifier=l.query.memo,u;if(n==null||n==="USDT"){const w=yield U(this.io,this.builtinTokens,e,c,i);if(w!=null)return w}throw new Error("InvalidPublicAddressError")})}encodeUri(e){return X(this,arguments,function*(n,r=[]){const{publicAddress:a,nativeAmount:o,currencyCode:c}=n;if(!ft(a))throw new Error("InvalidPublicAddressError");let i;if(typeof o=="string"){const u=(0,f.Qs)(c!=null?c:this.currencyInfo.currencyCode,this.currencyInfo,r);if(u==null)throw new Error("InternalErrorInvalidCurrencyCode");i=(0,m.div)(o,u.multiplier,18)}return(0,rt.Q)(n,this.currencyInfo.pluginId,i)})}getTokenId(e){return X(this,null,function*(){(0,nt.Rp)(e);const n=(0,nt.Oj)(e.networkLocation);if(n==null||!ft(n.contractAddress))throw new Error("ErrorInvalidContractAddress");return n.contractAddress})}}function Ce(s){return X(this,null,function*(){return new _t(s)})}},89214:function(){},52361:function(){},94616:function(){}}]);
@@ -1,2 +1,2 @@
1
- "use strict";(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[159],{79014:function(_,O,d){d.d(O,{Q:function(){return V},k:function(){return b}});var w=d(77591),A=d.n(w),R=d(24350),x=d(84564),N=d.n(x),M=d(76714),h=Object.defineProperty,U=Object.getOwnPropertySymbols,L=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,P=(a,y,f)=>y in a?h(a,y,{enumerable:!0,configurable:!0,writable:!0,value:f}):a[y]=f,S=(a,y)=>{for(var f in y||(y={}))L.call(y,f)&&P(a,f,y[f]);if(U)for(var f of U(y))$.call(y,f)&&P(a,f,y[f]);return a};function b(a,y,f,g,D=[]){const u=S({},N()(y,{},!0)),T=y.startsWith(`${a.pluginId}://`);if(u.protocol!=null&&(u.protocol=u.protocol.replace(":","")),u.protocol!=null&&u.protocol!==""&&!f[u.protocol])throw new Error(`Uri protocol '${u.protocol}' is not supported for ${a.pluginId}.`);if(u.host===""&&u.pathname==="")throw new Error("Path and host not found in uri.");const k={publicAddress:u.host!==""?u.host:u.pathname.split("/")[0]},p=u.query.label,I=u.query.message,z=u.query.category;(p!=null||I!=null||z!=null||T)&&(k.metadata={},k.metadata.name=p,k.metadata.notes=I,k.metadata.category=z,k.metadata.gateway=T!=null?T:!1);const m=u.query.amount;if(m!=null&&typeof m=="string"){g==null&&(g=a.currencyCode);const B=(0,M.Qs)(g!=null?g:"",a,D);if(B==null)throw new Error("InternalErrorInvalidCurrencyCode");let K=(0,w.mul)(m,B.multiplier);K=(0,w.toFixed)(K,0,0),k.nativeAmount=K,k.currencyCode=g}return{edgeParsedUri:k,parsedUri:u}}function V(a,y,f){if(a.publicAddress==null)throw new Error("InvalidPublicAddressError");if(f==null&&a.label==null&&a.message==null)return a.publicAddress;{let g="";f!=null&&(g+="amount="+f+"&"),(a.label!=null||a.message!=null)&&(typeof a.label=="string"&&(g+="label="+a.label+"&"),typeof a.message=="string"&&(g+="message="+a.message+"&")),g=g.substr(0,g.length-1);const D={scheme:y,path:a.publicAddress,query:g};return(0,R.qC)(D)}}},62560:function(_,O,d){d.r(O),d.d(O,{ZcashTools:function(){return B},makeCurrencyEngine:function(){return z},makeCurrencyTools:function(){return K}});var w=d(77591),A=d(2153),R=d(48764),x=d(62177),N=d(79014),M=d(76714),h=d(82448);const U=(0,h.su)({first:h.mH,last:h.mH}),L=(0,h.su)({alias:(0,h.Vk)(h.XC),blockRange:(0,h.Vk)(U,()=>({first:0,last:0}))}),$=(0,h.su)({birthdayHeight:h.mH,publicKey:h.XC,unifiedViewingKeys:(0,h.su)({extfvk:h.XC,extpub:h.XC})}),P=(0,x.jd)($),S=s=>{const t=(0,h.su)({[`${s}Mnemonic`]:h.XC,[`${s}SpendKey`]:h.XC,[`${s}BirthdayHeight`]:h.mH});return(0,h.W1)(e=>{const n=t(e);return{mnemonic:n[`${s}Mnemonic`],spendKey:n[`${s}SpendKey`],birthdayHeight:n[`${s}BirthdayHeight`]}},e=>({[`${s}Mnemonic`]:e.mnemonic,[`${s}SpendKey`]:e.spendKey,[`${s}BirthdayHeight`]:e.birthdayHeight}))};var b=d(94935),V=d(84650),a=Object.defineProperty,y=Object.getOwnPropertySymbols,f=Object.getPrototypeOf,g=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable,u=Reflect.get,T=(s,t,e)=>t in s?a(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,W=(s,t)=>{for(var e in t||(t={}))g.call(t,e)&&T(s,e,t[e]);if(y)for(var e of y(t))D.call(t,e)&&T(s,e,t[e]);return s},k=(s,t,e)=>u(f(s),e,t),p=(s,t,e)=>new Promise((n,r)=>{var c=i=>{try{l(e.next(i))}catch(v){r(v)}},o=i=>{try{l(e.throw(i))}catch(v){r(v)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(c,o);l((e=e.apply(s,t)).next())});class I extends V.P{constructor(t,e,n,r,c){super(t,e,n,r);const{networkInfo:o}=t;this.pluginId=this.currencyInfo.pluginId,this.networkInfo=o,this.makeSynchronizer=c,this.queryMutex=!1}setOtherData(t){this.otherData=L(t)}initData(){const{birthdayHeight:t,alias:e}=this.initializer;this.otherData.blockRange.first===0&&(this.otherData.blockRange={first:t,last:t}),this.alias=e,this.initialNumBlocksToDownload=-1,this.synchronizerStatus="DISCONNECTED",this.availableZatoshi="0",this.progressRatio=0}initSubscriptions(){this.synchronizer.on("update",t=>p(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=>p(this,null,function*(){this.synchronizerStatus=t.name,yield this.queryAll()}))}queryAll(){return p(this,null,function*(){if(!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()){this.tokenCheckBalanceStatus[this.currencyInfo.currencyCode]=e*.99/100;let r=0;if(t>0){const o=n-t;this.initialNumBlocksToDownload<0&&(this.initialNumBlocksToDownload=o),r=o===0||this.initialNumBlocksToDownload===0?1:1-o/this.initialNumBlocksToDownload}this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=r*.8;const c=(this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]+this.tokenCheckBalanceStatus[this.currencyInfo.currencyCode])/2;c!==this.progressRatio&&(Math.abs(c-this.progressRatio)>.1||c===1)&&(this.progressRatio=c,this.updateOnAddressesChecked())}}startEngine(){return p(this,null,function*(){this.initData(),this.synchronizer=yield this.makeSynchronizer(this.initializer),yield this.synchronizer.start(),this.initSubscriptions(),yield k(I.prototype,this,"startEngine").call(this)})}isSynced(){return this.synchronizerStatus==="SYNCED"}queryBalance(){return p(this,null,function*(){if(!!this.isSynced())try{const t=yield this.synchronizer.getShieldedBalance();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 p(this,null,function*(){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,w.add)(e,this.networkInfo.defaultNetworkFee)}`:n.push(this.walletInfo.keys.publicKey);const r={txid:t.rawTransactionId,date:t.blockTimeInSeconds,currencyCode:this.currencyInfo.currencyCode,blockHeight:t.minedHeight,nativeAmount:e,isSend:e.startsWith("-"),networkFee:this.networkInfo.defaultNetworkFee,ourReceiveAddresses:n,signedTx:"",otherParams:{},walletId:this.walletId};this.addTransaction(this.currencyInfo.currencyCode,r)}killEngine(){return p(this,null,function*(){yield this.synchronizer.stop(),yield k(I.prototype,this,"killEngine").call(this)})}clearBlockchainCache(){return p(this,null,function*(){yield k(I.prototype,this,"clearBlockchainCache").call(this)})}resyncBlockchain(){return p(this,null,function*(){yield k(I.prototype,this,"killEngine").call(this),yield this.clearBlockchainCache(),yield this.startEngine(),this.synchronizer.rescan(this.walletInfo.keys.birthdayHeight).catch(t=>this.warn("resyncBlockchain failed: ",t))})}getMaxSpendable(){return p(this,null,function*(){const t=(0,w.sub)(this.availableZatoshi,this.networkInfo.defaultNetworkFee);if((0,w.lte)(t,"0"))throw new b.C_;return t})}makeSpend(t){return p(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),c=n.spendTargets[0],{publicAddress:o,nativeAmount:l}=c;if(o==null)throw new Error("makeSpend Missing publicAddress");if(l==null)throw new b.$D;if((0,w.eq)(l,"0"))throw new b.$D;const i=(0,w.add)(l,this.networkInfo.defaultNetworkFee);if((0,w.gt)(i,(e=this.walletLocalData.totalBalances[this.currencyInfo.currencyCode])!=null?e:"0"))throw new b.C_;if((0,w.gt)(i,this.availableZatoshi))throw new b.C_("Amount exceeds available balance");const v=n.spendTargets.map(C=>{var H;return{uniqueIdentifier:C.uniqueIdentifier,memo:C.memo,nativeAmount:(H=C.nativeAmount)!=null?H:"0",currencyCode:r,publicAddress:o}});return{txid:"",date:0,currencyCode:r,blockHeight:0,nativeAmount:`-${i}`,isSend:l.startsWith("-"),networkFee:this.networkInfo.defaultNetworkFee,ourReceiveAddresses:[],signedTx:"",spendTargets:v,walletId:this.walletId}})}signTx(t){return p(this,null,function*(){return t})}broadcastTx(t,e){return p(this,null,function*(){var n,r;const c=S(this.pluginId)(e==null?void 0:e.privateKeys);if(t.spendTargets==null||t.spendTargets.length!==1)throw new Error("Invalid spend targets");const o=t.spendTargets[0],l={zatoshi:(0,w.sub)((0,w.abs)(t.nativeAmount),t.networkFee),toAddress:o.publicAddress,memo:(r=(n=o.memo)!=null?n:o.uniqueIdentifier)!=null?r:"",fromAccountIndex:0,spendingKey:c.spendKey};try{const i=yield this.synchronizer.sendToAddress(l);t.txid=i.txId,t.signedTx=i.raw,t.date=Date.now()/1e3,this.warn(`SUCCESS broadcastTx
2
- ${(0,M.oX)(t)}`)}catch(i){throw this.warn("FAILURE broadcastTx failed: ",i),i}return t})}loadEngine(){return p(this,null,function*(){const{walletInfo:t}=this;yield k(I.prototype,this,"loadEngine").call(this),this.engineOn=!0;const{rpcNode:e}=this.networkInfo;this.initializer=W({fullViewingKey:t.keys.unifiedViewingKeys,birthdayHeight:t.keys.birthdayHeight,alias:t.keys.publicKey},e)})}}function z(s,t,e,n){return p(this,null,function*(){const r=P(e),{makeSynchronizer:c}=s.nativeIo["edge-currency-accountbased"][s.networkInfo.nativeSdk],o=new I(s,t,r,n,c);return yield o.loadEngine(),o})}var m=(s,t,e)=>new Promise((n,r)=>{var c=i=>{try{l(e.next(i))}catch(v){r(v)}},o=i=>{try{l(e.throw(i))}catch(v){r(v)}},l=i=>i.done?n(i.value):Promise.resolve(i.value).then(c,o);l((e=e.apply(s,t)).next())});class B{constructor(t){const{builtinTokens:e,currencyInfo:n,io:r,networkInfo:c}=t;this.builtinTokens=e,this.currencyInfo=n,this.io=r,this.networkInfo=c;const o=t.nativeIo["edge-currency-accountbased"];if(o==null)throw new Error("Need opts");const{KeyTool:l,AddressTool:i}=o[this.networkInfo.nativeSdk];this.KeyTool=l,this.AddressTool=i}getDisplayPrivateKey(t){return m(this,null,function*(){const{pluginId:e}=this.currencyInfo;return S(e)(t.keys).mnemonic})}getDisplayPublicKey(t){return m(this,null,function*(){var e;const{keys:n}=P(t);return(e=n.unifiedViewingKeys)==null?void 0:e.extfvk})}getNewWalletBirthdayBlockheight(){return m(this,null,function*(){try{return yield this.KeyTool.getBirthdayHeight(this.networkInfo.rpcNode.defaultHost,this.networkInfo.rpcNode.defaultPort)}catch{return this.networkInfo.defaultBirthday}})}isValidAddress(t){return m(this,null,function*(){return(yield this.AddressTool.isValidShieldedAddress(t))||(yield this.AddressTool.isValidTransparentAddress(t))})}importPrivateKey(t){return m(this,arguments,function*(e,n={}){const{pluginId:r}=this.currencyInfo;if(!(0,A.validateMnemonic)(e))throw new Error(`Invalid ${this.currencyInfo.currencyCode} mnemonic`);const l=(yield(0,A.mnemonicToSeed)(e)).toString("hex"),i=yield this.KeyTool.deriveSpendingKey(l,this.networkInfo.rpcNode.networkName);if(typeof i!="string")throw new Error("Invalid spendKey type");const v=yield this.getNewWalletBirthdayBlockheight();let E=v;const{birthdayHeight:C}=n;if(C!=null){(0,x.jD)(C);const H=parseInt(C);if(H>v)throw new Error("InvalidBirthdayHeight");E=H}return{[`${r}Mnemonic`]:e,[`${r}SpendKey`]:i,[`${r}BirthdayHeight`]:E}})}createPrivateKey(t){return m(this,null,function*(){if(t!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const e=R.Buffer.from(this.io.random(32)).toString("hex"),n=(0,A.entropyToMnemonic)(e);return yield this.importPrivateKey(n)})}checkPublicKey(t){return m(this,null,function*(){try{return $(t),!0}catch{return!1}})}derivePublicKey(t){return m(this,null,function*(){const{pluginId:e}=this.currencyInfo,n=S(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(0,A.mnemonicToSeed)(r)).toString("hex"),l=yield this.KeyTool.deriveViewingKey(o,this.networkInfo.rpcNode.networkName),i=yield this.AddressTool.deriveShieldedAddress(l.extfvk,this.networkInfo.rpcNode.networkName);return{birthdayHeight:n.birthdayHeight,publicKey:i,unifiedViewingKeys:l}})}parseUri(t,e,n){return m(this,null,function*(){const{pluginId:r}=this.currencyInfo,c={[r]:!0},{edgeParsedUri:o,edgeParsedUri:{publicAddress:l}}=(0,N.k)(this.currencyInfo,t,c,e!=null?e:this.currencyInfo.currencyCode,n);if(l==null||!(yield this.isValidAddress(l)))throw new Error("InvalidPublicAddressError");return o})}encodeUri(t){return m(this,arguments,function*(e,n=[]){const{pluginId:r}=this.currencyInfo,{nativeAmount:c,currencyCode:o,publicAddress:l}=e;if(!(yield this.isValidAddress(l)))throw new Error("InvalidPublicAddressError");let i;if(c!=null){const E=(0,M.Qs)(o!=null?o:this.currencyInfo.currencyCode,this.currencyInfo,n);if(E==null)throw new Error("InternalErrorInvalidCurrencyCode");i=(0,w.div)(c,E.multiplier,18)}return(0,N.Q)(e,`${r}`,i)})}}function K(s){return m(this,null,function*(){return new B(s)})}}}]);
1
+ (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[2159],{79014:function(F,H,d){"use strict";d.d(H,{Q:function(){return V},k:function(){return b}});var g=d(77591),A=d.n(g),$=d(24350),O=d(84564),x=d.n(O),N=d(76714),h=Object.defineProperty,M=Object.getOwnPropertySymbols,L=Object.prototype.hasOwnProperty,U=Object.prototype.propertyIsEnumerable,P=(a,y,f)=>y in a?h(a,y,{enumerable:!0,configurable:!0,writable:!0,value:f}):a[y]=f,S=(a,y)=>{for(var f in y||(y={}))L.call(y,f)&&P(a,f,y[f]);if(M)for(var f of M(y))U.call(y,f)&&P(a,f,y[f]);return a};function b(a,y,f,m,D=[]){const u=S({},x()(y,{},!0)),T=y.startsWith(`${a.pluginId}://`);if(u.protocol!=null&&(u.protocol=u.protocol.replace(":","")),u.protocol!=null&&u.protocol!==""&&!f[u.protocol])throw new Error(`Uri protocol '${u.protocol}' is not supported for ${a.pluginId}.`);if(u.host===""&&u.pathname==="")throw new Error("Path and host not found in uri.");const k={publicAddress:u.host!==""?u.host:u.pathname.split("/")[0]},p=u.query.label,I=u.query.message,z=u.query.category;(p!=null||I!=null||z!=null||T)&&(k.metadata={},k.metadata.name=p,k.metadata.notes=I,k.metadata.category=z,k.metadata.gateway=T!=null?T:!1);const w=u.query.amount;if(w!=null&&typeof w=="string"){m==null&&(m=a.currencyCode);const B=(0,N.Qs)(m!=null?m:"",a,D);if(B==null)throw new Error("InternalErrorInvalidCurrencyCode");let K=(0,g.mul)(w,B.multiplier);K=(0,g.toFixed)(K,0,0),k.nativeAmount=K,k.currencyCode=m}return{edgeParsedUri:k,parsedUri:u}}function V(a,y,f){if(a.publicAddress==null)throw new Error("InvalidPublicAddressError");if(f==null&&a.label==null&&a.message==null)return a.publicAddress;{let m="";f!=null&&(m+="amount="+f+"&"),(a.label!=null||a.message!=null)&&(typeof a.label=="string"&&(m+="label="+a.label+"&"),typeof a.message=="string"&&(m+="message="+a.message+"&")),m=m.substr(0,m.length-1);const D={scheme:y,path:a.publicAddress,query:m};return(0,$.qC)(D)}}},62560:function(F,H,d){"use strict";d.r(H),d.d(H,{ZcashTools:function(){return B},makeCurrencyEngine:function(){return z},makeCurrencyTools:function(){return K}});var g=d(77591),A=d(2153),$=d(48764),O=d(62177),x=d(79014),N=d(76714),h=d(82448);const M=(0,h.su)({first:h.mH,last:h.mH}),L=(0,h.su)({alias:(0,h.Vk)(h.XC),blockRange:(0,h.Vk)(M,()=>({first:0,last:0}))}),U=(0,h.su)({birthdayHeight:h.mH,publicKey:h.XC,unifiedViewingKeys:(0,h.su)({extfvk:h.XC,extpub:h.XC})}),P=(0,O.jd)(U),S=s=>{const t=(0,h.su)({[`${s}Mnemonic`]:h.XC,[`${s}SpendKey`]:h.XC,[`${s}BirthdayHeight`]:h.mH});return(0,h.W1)(e=>{const n=t(e);return{mnemonic:n[`${s}Mnemonic`],spendKey:n[`${s}SpendKey`],birthdayHeight:n[`${s}BirthdayHeight`]}},e=>({[`${s}Mnemonic`]:e.mnemonic,[`${s}SpendKey`]:e.spendKey,[`${s}BirthdayHeight`]:e.birthdayHeight}))};var b=d(94935),V=d(84650),a=Object.defineProperty,y=Object.getOwnPropertySymbols,f=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty,D=Object.prototype.propertyIsEnumerable,u=Reflect.get,T=(s,t,e)=>t in s?a(s,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):s[t]=e,_=(s,t)=>{for(var e in t||(t={}))m.call(t,e)&&T(s,e,t[e]);if(y)for(var e of y(t))D.call(t,e)&&T(s,e,t[e]);return s},k=(s,t,e)=>u(f(s),e,t),p=(s,t,e)=>new Promise((n,r)=>{var l=i=>{try{c(e.next(i))}catch(v){r(v)}},o=i=>{try{c(e.throw(i))}catch(v){r(v)}},c=i=>i.done?n(i.value):Promise.resolve(i.value).then(l,o);c((e=e.apply(s,t)).next())});class I extends V.P{constructor(t,e,n,r,l){super(t,e,n,r);const{networkInfo:o}=t;this.pluginId=this.currencyInfo.pluginId,this.networkInfo=o,this.makeSynchronizer=l,this.queryMutex=!1}setOtherData(t){this.otherData=L(t)}initData(){const{birthdayHeight:t,alias:e}=this.initializer;this.otherData.blockRange.first===0&&(this.otherData.blockRange={first:t,last:t}),this.alias=e,this.initialNumBlocksToDownload=-1,this.synchronizerStatus="DISCONNECTED",this.availableZatoshi="0",this.progressRatio=0}initSubscriptions(){this.synchronizer.on("update",t=>p(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=>p(this,null,function*(){this.synchronizerStatus=t.name,yield this.queryAll()}))}queryAll(){return p(this,null,function*(){if(!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()){this.tokenCheckBalanceStatus[this.currencyInfo.currencyCode]=e*.99/100;let r=0;if(t>0){const o=n-t;this.initialNumBlocksToDownload<0&&(this.initialNumBlocksToDownload=o),r=o===0||this.initialNumBlocksToDownload===0?1:1-o/this.initialNumBlocksToDownload}this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=r*.8;const l=(this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]+this.tokenCheckBalanceStatus[this.currencyInfo.currencyCode])/2;l!==this.progressRatio&&(Math.abs(l-this.progressRatio)>.1||l===1)&&(this.progressRatio=l,this.updateOnAddressesChecked())}}startEngine(){return p(this,null,function*(){this.initData(),this.synchronizer=yield this.makeSynchronizer(this.initializer),yield this.synchronizer.start(),this.initSubscriptions(),yield k(I.prototype,this,"startEngine").call(this)})}isSynced(){return this.synchronizerStatus==="SYNCED"}queryBalance(){return p(this,null,function*(){if(!!this.isSynced())try{const t=yield this.synchronizer.getShieldedBalance();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 p(this,null,function*(){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,g.add)(e,this.networkInfo.defaultNetworkFee)}`:n.push(this.walletInfo.keys.publicKey);const r={txid:t.rawTransactionId,date:t.blockTimeInSeconds,currencyCode:this.currencyInfo.currencyCode,blockHeight:t.minedHeight,nativeAmount:e,isSend:e.startsWith("-"),networkFee:this.networkInfo.defaultNetworkFee,ourReceiveAddresses:n,signedTx:"",otherParams:{},walletId:this.walletId};this.addTransaction(this.currencyInfo.currencyCode,r)}killEngine(){return p(this,null,function*(){yield this.synchronizer.stop(),yield k(I.prototype,this,"killEngine").call(this)})}clearBlockchainCache(){return p(this,null,function*(){yield k(I.prototype,this,"clearBlockchainCache").call(this)})}resyncBlockchain(){return p(this,null,function*(){yield k(I.prototype,this,"killEngine").call(this),yield this.clearBlockchainCache(),yield this.startEngine(),this.synchronizer.rescan(this.walletInfo.keys.birthdayHeight).catch(t=>this.warn("resyncBlockchain failed: ",t))})}getMaxSpendable(){return p(this,null,function*(){const t=(0,g.sub)(this.availableZatoshi,this.networkInfo.defaultNetworkFee);if((0,g.lte)(t,"0"))throw new b.C_;return t})}makeSpend(t){return p(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),l=n.spendTargets[0],{publicAddress:o,nativeAmount:c}=l;if(o==null)throw new Error("makeSpend Missing publicAddress");if(c==null)throw new b.$D;if((0,g.eq)(c,"0"))throw new b.$D;const i=(0,g.add)(c,this.networkInfo.defaultNetworkFee);if((0,g.gt)(i,(e=this.walletLocalData.totalBalances[this.currencyInfo.currencyCode])!=null?e:"0"))throw new b.C_;if((0,g.gt)(i,this.availableZatoshi))throw new b.C_("Amount exceeds available balance");const v=n.spendTargets.map(E=>{var W;return{uniqueIdentifier:E.uniqueIdentifier,memo:E.memo,nativeAmount:(W=E.nativeAmount)!=null?W:"0",currencyCode:r,publicAddress:o}}),C=(0,g.mul)(i,"-1");return{txid:"",date:0,currencyCode:r,blockHeight:0,nativeAmount:C,isSend:!0,networkFee:this.networkInfo.defaultNetworkFee,ourReceiveAddresses:[],signedTx:"",spendTargets:v,walletId:this.walletId}})}signTx(t){return p(this,null,function*(){return t})}broadcastTx(t,e){return p(this,null,function*(){var n,r;const l=S(this.pluginId)(e==null?void 0:e.privateKeys);if(t.spendTargets==null||t.spendTargets.length!==1)throw new Error("Invalid spend targets");const o=t.spendTargets[0],c={zatoshi:(0,g.sub)((0,g.abs)(t.nativeAmount),t.networkFee),toAddress:o.publicAddress,memo:(r=(n=o.memo)!=null?n:o.uniqueIdentifier)!=null?r:"",fromAccountIndex:0,spendingKey:l.spendKey};try{const i=yield this.synchronizer.sendToAddress(c);t.txid=i.txId,t.signedTx=i.raw,t.date=Date.now()/1e3,this.warn(`SUCCESS broadcastTx
2
+ ${(0,N.oX)(t)}`)}catch(i){throw this.warn("FAILURE broadcastTx failed: ",i),i}return t})}loadEngine(){return p(this,null,function*(){const{walletInfo:t}=this;yield k(I.prototype,this,"loadEngine").call(this),this.engineOn=!0;const{rpcNode:e}=this.networkInfo;this.initializer=_({fullViewingKey:t.keys.unifiedViewingKeys,birthdayHeight:t.keys.birthdayHeight,alias:t.keys.publicKey},e)})}}function z(s,t,e,n){return p(this,null,function*(){const r=P(e),{makeSynchronizer:l}=s.nativeIo["edge-currency-accountbased"][s.networkInfo.nativeSdk],o=new I(s,t,r,n,l);return yield o.loadEngine(),o})}var w=(s,t,e)=>new Promise((n,r)=>{var l=i=>{try{c(e.next(i))}catch(v){r(v)}},o=i=>{try{c(e.throw(i))}catch(v){r(v)}},c=i=>i.done?n(i.value):Promise.resolve(i.value).then(l,o);c((e=e.apply(s,t)).next())});class B{constructor(t){const{builtinTokens:e,currencyInfo:n,io:r,networkInfo:l}=t;this.builtinTokens=e,this.currencyInfo=n,this.io=r,this.networkInfo=l;const o=t.nativeIo["edge-currency-accountbased"];if(o==null)throw new Error("Need opts");const{KeyTool:c,AddressTool:i}=o[this.networkInfo.nativeSdk];this.KeyTool=c,this.AddressTool=i}getDisplayPrivateKey(t){return w(this,null,function*(){const{pluginId:e}=this.currencyInfo;return S(e)(t.keys).mnemonic})}getDisplayPublicKey(t){return w(this,null,function*(){var e;const{keys:n}=P(t);return(e=n.unifiedViewingKeys)==null?void 0:e.extfvk})}getNewWalletBirthdayBlockheight(){return w(this,null,function*(){try{return yield this.KeyTool.getBirthdayHeight(this.networkInfo.rpcNode.defaultHost,this.networkInfo.rpcNode.defaultPort)}catch{return this.networkInfo.defaultBirthday}})}isValidAddress(t){return w(this,null,function*(){return(yield this.AddressTool.isValidShieldedAddress(t))||(yield this.AddressTool.isValidTransparentAddress(t))})}importPrivateKey(t){return w(this,arguments,function*(e,n={}){const{pluginId:r}=this.currencyInfo;if(!(0,A.validateMnemonic)(e))throw new Error(`Invalid ${this.currencyInfo.currencyCode} mnemonic`);const c=(yield(0,A.mnemonicToSeed)(e)).toString("hex"),i=yield this.KeyTool.deriveSpendingKey(c,this.networkInfo.rpcNode.networkName);if(typeof i!="string")throw new Error("Invalid spendKey type");const v=yield this.getNewWalletBirthdayBlockheight();let C=v;const{birthdayHeight:R}=n;if(R!=null){(0,O.jD)(R);const E=parseInt(R);if(E>v)throw new Error("InvalidBirthdayHeight");C=E}return{[`${r}Mnemonic`]:e,[`${r}SpendKey`]:i,[`${r}BirthdayHeight`]:C}})}createPrivateKey(t){return w(this,null,function*(){if(t!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const e=$.Buffer.from(this.io.random(32)).toString("hex"),n=(0,A.entropyToMnemonic)(e);return yield this.importPrivateKey(n)})}checkPublicKey(t){return w(this,null,function*(){try{return U(t),!0}catch{return!1}})}derivePublicKey(t){return w(this,null,function*(){const{pluginId:e}=this.currencyInfo,n=S(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(0,A.mnemonicToSeed)(r)).toString("hex"),c=yield this.KeyTool.deriveViewingKey(o,this.networkInfo.rpcNode.networkName),i=yield this.AddressTool.deriveShieldedAddress(c.extfvk,this.networkInfo.rpcNode.networkName);return{birthdayHeight:n.birthdayHeight,publicKey:i,unifiedViewingKeys:c}})}parseUri(t,e,n){return w(this,null,function*(){const{pluginId:r}=this.currencyInfo,l={[r]:!0},{edgeParsedUri:o,edgeParsedUri:{publicAddress:c}}=(0,x.k)(this.currencyInfo,t,l,e!=null?e:this.currencyInfo.currencyCode,n);if(c==null||!(yield this.isValidAddress(c)))throw new Error("InvalidPublicAddressError");return o})}encodeUri(t){return w(this,arguments,function*(e,n=[]){const{pluginId:r}=this.currencyInfo,{nativeAmount:l,currencyCode:o,publicAddress:c}=e;if(!(yield this.isValidAddress(c)))throw new Error("InvalidPublicAddressError");let i;if(l!=null){const C=(0,N.Qs)(o!=null?o:this.currencyInfo.currencyCode,this.currencyInfo,n);if(C==null)throw new Error("InternalErrorInvalidCurrencyCode");i=(0,g.div)(l,C.multiplier,18)}return(0,x.Q)(e,`${r}`,i)})}}function K(s){return w(this,null,function*(){return new B(s)})}},52361:function(){},94616:function(){}}]);
@@ -118,6 +118,14 @@ const builtinTokens = {
118
118
  contractAddress: '0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664'
119
119
  }
120
120
  },
121
+ '9702230a8ea53601f5cd2dc00fdbc13d4df4a8c7': {
122
+ currencyCode: 'USDT',
123
+ displayName: 'Tether USD',
124
+ denominations: [{ name: 'USDT', multiplier: '1000000' }],
125
+ networkLocation: {
126
+ contractAddress: '0x9702230A8Ea53601f5cD2dc00fDBc13d4dF4A8c7'
127
+ }
128
+ },
121
129
  c7198437980c041c805a1edcba50c1ce5db95118: {
122
130
  currencyCode: 'USDT.e',
123
131
  displayName: 'Tether USD',
@@ -934,6 +934,14 @@ const builtinTokens = {
934
934
  contractAddress: '0x3a4f40631a4f906c2BaD353Ed06De7A5D3fCb430'
935
935
  }
936
936
  },
937
+ e17b8adf8e46b15f3f9ab4bb9e3b6e31db09126e: {
938
+ currencyCode: 'PYUSD',
939
+ displayName: 'PayPal USD',
940
+ denominations: [{ name: 'PYUSD', multiplier: '1000000' }],
941
+ networkLocation: {
942
+ contractAddress: '0xe17b8aDF8E46b15f3F9aB4Bb9E3b6e31Db09126E'
943
+ }
944
+ },
937
945
  '4a220e6096b25eadb88358cb44068a3248254675': {
938
946
  currencyCode: 'QNT',
939
947
  displayName: 'Quant',