edge-currency-accountbased 2.5.4 → 2.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (145) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/android/src/main/assets/edge-currency-accountbased/4843.chunk.js +2 -2
  3. package/android/src/main/assets/edge-currency-accountbased/5336.chunk.js +2 -2
  4. package/android/src/main/assets/edge-currency-accountbased/edge-currency-accountbased.js +1 -1
  5. package/android/src/main/assets/edge-currency-accountbased/zcash.chunk.js +2 -2
  6. package/lib/filecoin/filecoinInfo.js +2 -2
  7. package/lib/piratechain/PiratechainEngine.js +102 -102
  8. package/lib/piratechain/PiratechainTools.js +72 -95
  9. package/lib/piratechain/piratechainInfo.js +3 -1
  10. package/lib/piratechain/piratechainTypes.js +7 -11
  11. package/lib/react-native.js +51 -54
  12. package/lib/zcash/ZcashEngine.js +18 -27
  13. package/package.json +3 -1
  14. package/android/src/main/assets/piratesaplingtree/mainnet/2050000.json +0 -7
  15. package/android/src/main/assets/piratesaplingtree/mainnet/2060000.json +0 -7
  16. package/android/src/main/assets/piratesaplingtree/mainnet/2070000.json +0 -7
  17. package/android/src/main/assets/piratesaplingtree/mainnet/2080000.json +0 -7
  18. package/android/src/main/assets/piratesaplingtree/mainnet/2090000.json +0 -7
  19. package/android/src/main/assets/piratesaplingtree/mainnet/2100000.json +0 -7
  20. package/android/src/main/assets/piratesaplingtree/mainnet/2110000.json +0 -7
  21. package/android/src/main/assets/piratesaplingtree/mainnet/2120000.json +0 -7
  22. package/android/src/main/assets/piratesaplingtree/mainnet/2130000.json +0 -7
  23. package/android/src/main/assets/piratesaplingtree/mainnet/2140000.json +0 -7
  24. package/android/src/main/assets/piratesaplingtree/mainnet/2150000.json +0 -7
  25. package/android/src/main/assets/piratesaplingtree/mainnet/2160000.json +0 -7
  26. package/android/src/main/assets/piratesaplingtree/mainnet/2170000.json +0 -7
  27. package/android/src/main/assets/piratesaplingtree/mainnet/2180000.json +0 -7
  28. package/android/src/main/assets/piratesaplingtree/mainnet/2190000.json +0 -7
  29. package/android/src/main/assets/piratesaplingtree/mainnet/2200000.json +0 -7
  30. package/android/src/main/assets/piratesaplingtree/mainnet/2210000.json +0 -7
  31. package/android/src/main/assets/piratesaplingtree/mainnet/2220000.json +0 -7
  32. package/android/src/main/assets/piratesaplingtree/mainnet/2230000.json +0 -7
  33. package/android/src/main/assets/piratesaplingtree/mainnet/2240000.json +0 -7
  34. package/android/src/main/assets/piratesaplingtree/mainnet/2250000.json +0 -7
  35. package/android/src/main/assets/piratesaplingtree/mainnet/2260000.json +0 -7
  36. package/android/src/main/assets/piratesaplingtree/mainnet/2270000.json +0 -7
  37. package/android/src/main/assets/piratesaplingtree/mainnet/2280000.json +0 -7
  38. package/android/src/main/assets/piratesaplingtree/mainnet/2290000.json +0 -7
  39. package/android/src/main/assets/piratesaplingtree/mainnet/2300000.json +0 -7
  40. package/android/src/main/assets/piratesaplingtree/mainnet/2310000.json +0 -7
  41. package/android/src/main/assets/piratesaplingtree/mainnet/2320000.json +0 -7
  42. package/android/src/main/assets/piratesaplingtree/mainnet/2330000.json +0 -7
  43. package/android/src/main/assets/piratesaplingtree/mainnet/2340000.json +0 -7
  44. package/android/src/main/assets/piratesaplingtree/mainnet/2350000.json +0 -7
  45. package/android/src/main/assets/piratesaplingtree/mainnet/2360000.json +0 -7
  46. package/android/src/main/assets/piratesaplingtree/mainnet/2370000.json +0 -7
  47. package/android/src/main/assets/piratesaplingtree/mainnet/2380000.json +0 -7
  48. package/android/src/main/assets/piratesaplingtree/mainnet/2390000.json +0 -7
  49. package/android/src/main/assets/piratesaplingtree/mainnet/2400000.json +0 -7
  50. package/android/src/main/assets/piratesaplingtree/mainnet/2410000.json +0 -7
  51. package/android/src/main/assets/piratesaplingtree/mainnet/2420000.json +0 -7
  52. package/android/src/main/assets/piratesaplingtree/mainnet/2430000.json +0 -7
  53. package/android/src/main/assets/piratesaplingtree/mainnet/2440000.json +0 -7
  54. package/android/src/main/assets/piratesaplingtree/mainnet/2450000.json +0 -7
  55. package/android/src/main/assets/piratesaplingtree/mainnet/2460000.json +0 -7
  56. package/android/src/main/assets/piratesaplingtree/mainnet/2470000.json +0 -7
  57. package/android/src/main/assets/piratesaplingtree/mainnet/2480000.json +0 -7
  58. package/android/src/main/assets/piratesaplingtree/mainnet/2490000.json +0 -7
  59. package/android/src/main/assets/saplingtree/mainnet/1310000.json +0 -7
  60. package/android/src/main/assets/saplingtree/mainnet/1320000.json +0 -7
  61. package/android/src/main/assets/saplingtree/mainnet/1330000.json +0 -7
  62. package/android/src/main/assets/saplingtree/mainnet/1340000.json +0 -7
  63. package/android/src/main/assets/saplingtree/mainnet/1350000.json +0 -7
  64. package/android/src/main/assets/saplingtree/mainnet/1360000.json +0 -7
  65. package/android/src/main/assets/saplingtree/mainnet/1370000.json +0 -7
  66. package/android/src/main/assets/saplingtree/mainnet/1380000.json +0 -7
  67. package/android/src/main/assets/saplingtree/mainnet/1390000.json +0 -7
  68. package/android/src/main/assets/saplingtree/mainnet/1400000.json +0 -7
  69. package/android/src/main/assets/saplingtree/mainnet/1410000.json +0 -7
  70. package/android/src/main/assets/saplingtree/mainnet/1420000.json +0 -7
  71. package/android/src/main/assets/saplingtree/mainnet/1430000.json +0 -7
  72. package/android/src/main/assets/saplingtree/mainnet/1440000.json +0 -7
  73. package/android/src/main/assets/saplingtree/mainnet/1450000.json +0 -7
  74. package/android/src/main/assets/saplingtree/mainnet/1460000.json +0 -7
  75. package/android/src/main/assets/saplingtree/mainnet/1470000.json +0 -7
  76. package/android/src/main/assets/saplingtree/mainnet/1480000.json +0 -7
  77. package/android/src/main/assets/saplingtree/mainnet/1490000.json +0 -7
  78. package/android/src/main/assets/saplingtree/mainnet/1500000.json +0 -7
  79. package/android/src/main/assets/saplingtree/mainnet/1510000.json +0 -7
  80. package/android/src/main/assets/saplingtree/mainnet/1520000.json +0 -7
  81. package/android/src/main/assets/saplingtree/mainnet/1530000.json +0 -7
  82. package/android/src/main/assets/saplingtree/mainnet/1540000.json +0 -7
  83. package/android/src/main/assets/saplingtree/mainnet/1550000.json +0 -7
  84. package/android/src/main/assets/saplingtree/mainnet/1560000.json +0 -7
  85. package/android/src/main/assets/saplingtree/mainnet/1570000.json +0 -7
  86. package/android/src/main/assets/saplingtree/mainnet/1580000.json +0 -7
  87. package/android/src/main/assets/saplingtree/mainnet/1590000.json +0 -7
  88. package/android/src/main/assets/saplingtree/mainnet/1600000.json +0 -7
  89. package/android/src/main/assets/saplingtree/mainnet/1610000.json +0 -7
  90. package/android/src/main/assets/saplingtree/mainnet/1620000.json +0 -7
  91. package/android/src/main/assets/saplingtree/mainnet/1630000.json +0 -7
  92. package/android/src/main/assets/saplingtree/mainnet/1640000.json +0 -7
  93. package/android/src/main/assets/saplingtree/mainnet/1650000.json +0 -7
  94. package/android/src/main/assets/saplingtree/mainnet/1660000.json +0 -7
  95. package/android/src/main/assets/saplingtree/mainnet/1670000.json +0 -7
  96. package/android/src/main/assets/saplingtree/mainnet/1680000.json +0 -7
  97. package/android/src/main/assets/saplingtree/mainnet/1690000.json +0 -7
  98. package/android/src/main/assets/saplingtree/mainnet/1700000.json +0 -7
  99. package/android/src/main/assets/saplingtree/mainnet/1710000.json +0 -7
  100. package/android/src/main/assets/saplingtree/mainnet/1720000.json +0 -7
  101. package/android/src/main/assets/saplingtree/mainnet/1730000.json +0 -7
  102. package/android/src/main/assets/saplingtree/mainnet/1740000.json +0 -7
  103. package/android/src/main/assets/saplingtree/mainnet/1750000.json +0 -7
  104. package/android/src/main/assets/saplingtree/mainnet/1760000.json +0 -7
  105. package/android/src/main/assets/saplingtree/mainnet/1770000.json +0 -7
  106. package/android/src/main/assets/saplingtree/mainnet/1780000.json +0 -7
  107. package/android/src/main/assets/saplingtree/mainnet/1790000.json +0 -7
  108. package/android/src/main/assets/saplingtree/mainnet/1800000.json +0 -7
  109. package/android/src/main/assets/saplingtree/mainnet/1810000.json +0 -7
  110. package/android/src/main/assets/saplingtree/mainnet/1820000.json +0 -7
  111. package/android/src/main/assets/saplingtree/mainnet/1830000.json +0 -7
  112. package/android/src/main/assets/saplingtree/mainnet/1840000.json +0 -7
  113. package/android/src/main/assets/saplingtree/mainnet/1850000.json +0 -7
  114. package/android/src/main/assets/saplingtree/mainnet/1860000.json +0 -7
  115. package/android/src/main/assets/saplingtree/mainnet/1870000.json +0 -7
  116. package/android/src/main/assets/saplingtree/mainnet/1880000.json +0 -7
  117. package/android/src/main/assets/saplingtree/mainnet/1890000.json +0 -7
  118. package/android/src/main/assets/saplingtree/mainnet/1900000.json +0 -7
  119. package/android/src/main/assets/saplingtree/mainnet/1910000.json +0 -7
  120. package/android/src/main/assets/saplingtree/mainnet/1920000.json +0 -7
  121. package/android/src/main/assets/saplingtree/mainnet/1930000.json +0 -7
  122. package/android/src/main/assets/saplingtree/mainnet/1940000.json +0 -7
  123. package/android/src/main/assets/saplingtree/mainnet/1950000.json +0 -7
  124. package/android/src/main/assets/saplingtree/mainnet/1960000.json +0 -7
  125. package/android/src/main/assets/saplingtree/mainnet/1970000.json +0 -7
  126. package/android/src/main/assets/saplingtree/mainnet/1980000.json +0 -7
  127. package/android/src/main/assets/saplingtree/mainnet/1990000.json +0 -7
  128. package/android/src/main/assets/saplingtree/mainnet/2000000.json +0 -7
  129. package/android/src/main/assets/saplingtree/mainnet/2010000.json +0 -7
  130. package/android/src/main/assets/saplingtree/mainnet/2020000.json +0 -7
  131. package/android/src/main/assets/saplingtree/mainnet/2030000.json +0 -7
  132. package/android/src/main/assets/saplingtree/mainnet/2040000.json +0 -7
  133. package/android/src/main/assets/saplingtree/mainnet/2050000.json +0 -7
  134. package/android/src/main/assets/saplingtree/mainnet/2060000.json +0 -7
  135. package/android/src/main/assets/saplingtree/mainnet/2070000.json +0 -7
  136. package/android/src/main/assets/saplingtree/mainnet/2080000.json +0 -7
  137. package/android/src/main/assets/saplingtree/mainnet/2090000.json +0 -7
  138. package/android/src/main/assets/saplingtree/mainnet/2100000.json +0 -7
  139. package/android/src/main/assets/saplingtree/mainnet/2110000.json +0 -7
  140. package/android/src/main/assets/saplingtree/mainnet/2120000.json +0 -7
  141. package/android/src/main/assets/saplingtree/mainnet/2130000.json +0 -7
  142. package/android/src/main/assets/saplingtree/mainnet/2140000.json +0 -7
  143. package/android/src/main/assets/saplingtree/mainnet/2150000.json +0 -7
  144. package/android/src/main/assets/saplingtree/mainnet/2160000.json +0 -7
  145. package/android/src/main/assets/saplingtree/mainnet/2170000.json +0 -7
package/CHANGELOG.md CHANGED
@@ -1,5 +1,15 @@
1
1
  # edge-currency-accountbased
2
2
 
3
+ ## Unreleased
4
+
5
+ ## 2.6.0 (2023-10-09)
6
+
7
+ - changed: Upgrade react-native-piratechain to v0.4.0
8
+
9
+ ## 2.5.5 (2023-10-06)
10
+
11
+ - fixed: Switch Filecoin to a working block explorer (Filfox).
12
+
3
13
  ## 2.5.4 (2023-10-02)
4
14
 
5
15
  - fixed: Max spend for XLM
@@ -1,2 +1,2 @@
1
- (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[4843],{79014:function(_,S,l){"use strict";l.d(S,{Q:function(){return R},k:function(){return I}});var w=l(77591),W=l.n(w),M=l(24350),O=l(84564),B=l.n(O),c=l(76714),U=Object.defineProperty,K=Object.getOwnPropertySymbols,N=Object.prototype.hasOwnProperty,H=Object.prototype.propertyIsEnumerable,x=(s,f,d)=>f in s?U(s,f,{enumerable:!0,configurable:!0,writable:!0,value:d}):s[f]=d,E=(s,f)=>{for(var d in f||(f={}))N.call(f,d)&&x(s,d,f[d]);if(K)for(var d of K(f))H.call(f,d)&&x(s,d,f[d]);return s};function I(s,f,d,g,D=[]){const u=E({},B()(f,{},!0)),T=f.startsWith(`${s.pluginId}://`);if(u.protocol!=null&&(u.protocol=u.protocol.replace(":","")),u.protocol!=null&&u.protocol!==""&&!d[u.protocol])throw new Error(`Uri protocol '${u.protocol}' is not supported for ${s.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]},C=u.query.label,p=u.query.message,b=u.query.category;(C!=null||p!=null||b!=null||T)&&(k.metadata={},k.metadata.name=C,k.metadata.notes=p,k.metadata.category=b,k.metadata.gateway=T!=null?T:!1);const A=u.query.amount;if(A!=null&&typeof A=="string"){g==null&&(g=s.currencyCode);const v=(0,c.Qs)(g!=null?g:"",s,D);if(v==null)throw new Error("InternalErrorInvalidCurrencyCode");let P=(0,w.mul)(A,v.multiplier);P=(0,w.toFixed)(P,0,0),k.nativeAmount=P,k.currencyCode=g}return{edgeParsedUri:k,parsedUri:u}}function R(s,f,d){if(s.publicAddress==null)throw new Error("InvalidPublicAddressError");if(d==null&&s.label==null&&s.message==null)return s.publicAddress;{let g="";d!=null&&(g+="amount="+d+"&"),(s.label!=null||s.message!=null)&&(typeof s.label=="string"&&(g+="label="+s.label+"&"),typeof s.message=="string"&&(g+="message="+s.message+"&")),g=g.substr(0,g.length-1);const D={scheme:f,path:s.publicAddress,query:g};return(0,M.qC)(D)}}},80504:function(_,S,l){"use strict";l.r(S),l.d(S,{PiratechainTools:function(){return P},makeCurrencyEngine:function(){return A},makeCurrencyTools:function(){return F}});var w=l(77591),W=l(2153),M=l(48764),O=l(79014),B=l(76714),c=l(82448),U=l(62177);const K=(0,c.su)({first:c.mH,last:c.mH}),N=(0,c.su)({alias:(0,c.Vk)(c.XC),blockRange:(0,c.Vk)(K,{first:0,last:0})}),H=(0,c.su)({birthdayHeight:c.mH,publicKey:c.XC,unifiedViewingKeys:(0,c.su)({extfvk:c.XC,extpub:c.XC})}),x=(0,U.jd)(H),E=i=>{const t=(0,c.su)({[`${i}Mnemonic`]:c.XC,[`${i}SpendKey`]:c.XC,[`${i}BirthdayHeight`]:c.mH});return(0,c.W1)(e=>{const n=t(e);return{mnemonic:n[`${i}Mnemonic`],spendKey:n[`${i}SpendKey`],birthdayHeight:n[`${i}BirthdayHeight`]}},e=>({[`${i}Mnemonic`]:e.mnemonic,[`${i}SpendKey`]:e.spendKey,[`${i}BirthdayHeight`]:e.birthdayHeight}))};var I=l(94935),R=l(84650),s=l(72681),f=Object.defineProperty,d=Object.getOwnPropertySymbols,g=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty,u=Object.prototype.propertyIsEnumerable,T=Reflect.get,L=(i,t,e)=>t in i?f(i,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):i[t]=e,k=(i,t)=>{for(var e in t||(t={}))D.call(t,e)&&L(i,e,t[e]);if(d)for(var e of d(t))u.call(t,e)&&L(i,e,t[e]);return i},C=(i,t,e)=>T(g(i),e,t),p=(i,t,e)=>new Promise((n,r)=>{var a=o=>{try{m(e.next(o))}catch(h){r(h)}},y=o=>{try{m(e.throw(o))}catch(h){r(h)}},m=o=>o.done?n(o.value):Promise.resolve(o.value).then(a,y);m((e=e.apply(i,t)).next())});class b extends R.P{constructor(t,e,n,r,a){super(t,e,n,r);const{networkInfo:y}=t;this.pluginId=this.currencyInfo.pluginId,this.networkInfo=y,this.makeSynchronizer=a,this.queryMutex=!1}setOtherData(t){this.otherData=N(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 y=n-t;this.initialNumBlocksToDownload<0&&(this.initialNumBlocksToDownload=y),r=y===0||this.initialNumBlocksToDownload===0?1:1-y/this.initialNumBlocksToDownload}this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=r*.8;const a=(this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]+this.tokenCheckBalanceStatus[this.currencyInfo.currencyCode])/2;a!==this.progressRatio&&(Math.abs(a-this.progressRatio)>.1||a===1)&&(this.progressRatio=a,this.updateOnAddressesChecked())}}startEngine(){return p(this,null,function*(){this.initData(),yield C(b.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=[];t.memo!=null&&r.push({type:"text",value:t.memo});const a={txid:t.rawTransactionId,date:t.blockTimeInSeconds,currencyCode:this.currencyInfo.currencyCode,blockHeight:t.minedHeight,nativeAmount:e,isSend:e.startsWith("-"),memos:r,networkFee:this.networkInfo.defaultNetworkFee,ourReceiveAddresses:n,signedTx:"",otherParams:{},walletId:this.walletId};this.addTransaction(this.currencyInfo.currencyCode,a)}killEngine(){return p(this,null,function*(){yield C(b.prototype,this,"killEngine").call(this)})}clearBlockchainCache(){return p(this,null,function*(){yield C(b.prototype,this,"clearBlockchainCache").call(this)})}resyncBlockchain(){return p(this,null,function*(){yield C(b.prototype,this,"killEngine").call(this),yield this.clearBlockchainCache(),yield this.startEngine()})}getMaxSpendable(){return p(this,null,function*(){if(!this.isSynced())throw new Error("Cannot spend until wallet is synced");const t=(0,w.sub)(this.availableZatoshi,this.networkInfo.defaultNetworkFee);if((0,w.lte)(t,"0"))throw new I.C_;return t})}makeSpend(t){return p(this,null,function*(){var e;if(t=(0,s.s)(t,this.currencyInfo),!this.isSynced())throw new Error("Cannot spend until wallet is synced");const{edgeSpendInfo:n,currencyCode:r}=this.makeSpendCheck(t),{memos:a=[]}=n,y=n.spendTargets[0],{publicAddress:m,nativeAmount:o}=y;if(m==null)throw new Error("makeSpend Missing publicAddress");if(o==null)throw new I.$D;if((0,w.eq)(o,"0"))throw new I.$D;const h=(0,w.add)(o,this.networkInfo.defaultNetworkFee);if((0,w.gt)(h,(e=this.walletLocalData.totalBalances[this.currencyInfo.currencyCode])!=null?e:"0"))throw new I.C_;if((0,w.gt)(h,this.availableZatoshi))throw new I.C_("Amount exceeds available balance");const V=n.spendTargets.map($=>{var z;return{uniqueIdentifier:$.uniqueIdentifier,memo:$.memo,nativeAmount:(z=$.nativeAmount)!=null?z:"0",currencyCode:r,publicAddress:m}});return{txid:"",date:0,currencyCode:r,blockHeight:0,nativeAmount:`-${h}`,isSend:o.startsWith("-"),memos:a,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;if(!this.isSynced())throw new Error("Cannot broadcast until wallet is synced");const{memos:r}=t,a=E(this.pluginId)(e==null?void 0:e.privateKeys);if(t.spendTargets==null||t.spendTargets.length!==1)throw new Error("Invalid spend targets");const y=((n=r[0])==null?void 0:n.type)==="text"?r[0].value:"",m=t.spendTargets[0],o={zatoshi:(0,w.sub)((0,w.abs)(t.nativeAmount),t.networkFee),toAddress:m.publicAddress,memo:y,fromAccountIndex:0,spendingKey:a.spendKey};try{const h=yield this.synchronizer.sendToAddress(o);t.txid=h.txId,t.signedTx=h.raw,t.date=Date.now()/1e3,this.warn(`SUCCESS broadcastTx
2
- ${(0,B.oX)(t)}`)}catch(h){throw this.warn("FAILURE broadcastTx failed: ",h),h}return t})}getDisplayPrivateSeed(t){return E(this.pluginId)(t).mnemonic}getDisplayPublicSeed(){var t,e;return(e=(t=this.walletInfo.keys.unifiedViewingKeys)==null?void 0:t.extfvk)!=null?e:""}loadEngine(){return p(this,null,function*(){const{walletInfo:t}=this;yield C(b.prototype,this,"loadEngine").call(this),this.engineOn=!0;const{rpcNode:e}=this.networkInfo;this.initializer=k({fullViewingKey:t.keys.unifiedViewingKeys,birthdayHeight:t.keys.birthdayHeight,alias:t.keys.publicKey},e)})}}function A(i,t,e,n){return p(this,null,function*(){const r=x(e),a=new b(i,t,r,n,()=>{});return yield a.loadEngine(),a})}var v=(i,t,e)=>new Promise((n,r)=>{var a=o=>{try{m(e.next(o))}catch(h){r(h)}},y=o=>{try{m(e.throw(o))}catch(h){r(h)}},m=o=>o.done?n(o.value):Promise.resolve(o.value).then(a,y);m((e=e.apply(i,t)).next())});class P{constructor(t){const{builtinTokens:e,currencyInfo:n,io:r,networkInfo:a}=t;if(this.builtinTokens=e,this.currencyInfo=n,this.io=r,this.networkInfo=a,t.nativeIo["edge-currency-accountbased"]==null)throw new Error("Need opts")}getNewWalletBirthdayBlockheight(){return v(this,null,function*(){throw new Error("getNewWalletBirthdayBlockheight is disabled")})}isValidAddress(t){return v(this,null,function*(){return!1})}importPrivateKey(t){return v(this,arguments,function*(e,n={}){throw new Error("importPrivateKey is disabled")})}createPrivateKey(t){return v(this,null,function*(){if(t!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const e=M.Buffer.from(this.io.random(32)).toString("hex"),n=(0,W.entropyToMnemonic)(e);return yield this.importPrivateKey(n)})}checkPublicKey(t){return v(this,null,function*(){try{return H(t),!0}catch{return!1}})}derivePublicKey(t){return v(this,null,function*(){const{pluginId:e}=this.currencyInfo,n=E(e)(t.keys);if(t.type!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");return{birthdayHeight:n.birthdayHeight,publicKey:"derivePublicKey is disabled",unifiedViewingKeys:{extfvk:"",extpub:""}}})}parseUri(t,e,n){return v(this,null,function*(){const{pluginId:r}=this.currencyInfo,a={[r]:!0},{edgeParsedUri:y}=(0,O.k)(this.currencyInfo,t,a,e!=null?e:this.currencyInfo.currencyCode,n);return y})}encodeUri(t){return v(this,arguments,function*(e,n=[]){const{pluginId:r}=this.currencyInfo,{nativeAmount:a,currencyCode:y}=e;let m;if(a!=null){const h=(0,B.Qs)(y!=null?y:this.currencyInfo.currencyCode,this.currencyInfo,n);if(h==null)throw new Error("InternalErrorInvalidCurrencyCode");m=(0,w.div)(a,h.multiplier,18)}return(0,O.Q)(e,`${r}`,m)})}}function F(i){return v(this,null,function*(){return new P(i)})}},52361:function(){},94616:function(){}}]);
1
+ (self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[4843],{79014:function(W,H,u){"use strict";u.d(H,{Q:function(){return L},k:function(){return b}});var m=u(77591),U=u.n(m),x=u(24350),O=u(84564),B=u.n(O),M=u(76714),g=Object.defineProperty,z=Object.getOwnPropertySymbols,R=Object.prototype.hasOwnProperty,K=Object.prototype.propertyIsEnumerable,A=(o,p,y)=>p in o?g(o,p,{enumerable:!0,configurable:!0,writable:!0,value:y}):o[p]=y,C=(o,p)=>{for(var y in p||(p={}))R.call(p,y)&&A(o,y,p[y]);if(z)for(var y of z(p))K.call(p,y)&&A(o,y,p[y]);return o};function b(o,p,y,w,D=[]){const d=C({},B()(p,{},!0)),T=p.startsWith(`${o.pluginId}://`);if(d.protocol!=null&&(d.protocol=d.protocol.replace(":","")),d.protocol!=null&&d.protocol!==""&&!y[d.protocol])throw new Error(`Uri protocol '${d.protocol}' is not supported for ${o.pluginId}.`);if(d.host===""&&d.pathname==="")throw new Error("Path and host not found in uri.");const k={publicAddress:d.host!==""?d.host:d.pathname.split("/")[0]},P=d.query.label,f=d.query.message,I=d.query.category;(P!=null||f!=null||I!=null||T)&&(k.metadata={},k.metadata.name=P,k.metadata.notes=f,k.metadata.category=I,k.metadata.gateway=T!=null?T:!1);const S=d.query.amount;if(S!=null&&typeof S=="string"){w==null&&(w=o.currencyCode);const v=(0,M.Qs)(w!=null?w:"",o,D);if(v==null)throw new Error("InternalErrorInvalidCurrencyCode");let E=(0,m.mul)(S,v.multiplier);E=(0,m.toFixed)(E,0,0),k.nativeAmount=E,k.currencyCode=w}return{edgeParsedUri:k,parsedUri:d}}function L(o,p,y){if(o.publicAddress==null)throw new Error("InvalidPublicAddressError");if(y==null&&o.label==null&&o.message==null)return o.publicAddress;{let w="";y!=null&&(w+="amount="+y+"&"),(o.label!=null||o.message!=null)&&(typeof o.label=="string"&&(w+="label="+o.label+"&"),typeof o.message=="string"&&(w+="message="+o.message+"&")),w=w.substr(0,w.length-1);const D={scheme:p,path:o.publicAddress,query:w};return(0,x.qC)(D)}}},80504:function(W,H,u){"use strict";u.r(H),u.d(H,{PiratechainTools:function(){return E},makeCurrencyEngine:function(){return S},makeCurrencyTools:function(){return F}});var m=u(77591),U=u(2153),x=u(48764),O=u(62177),B=u(79014),M=u(76714),g=u(82448);const z=(0,g.su)({first:g.mH,last:g.mH}),R=(0,g.su)({alias:(0,g.Vk)(g.XC),blockRange:(0,g.Vk)(z,()=>({first:0,last:0}))}),K=(0,g.su)({birthdayHeight:g.mH,publicKey:g.XC}),A=(0,O.jd)(K),C=a=>{const t=(0,g.su)({[`${a}Mnemonic`]:g.XC,[`${a}BirthdayHeight`]:g.mH});return(0,g.W1)(e=>{const n=t(e);return{mnemonic:n[`${a}Mnemonic`],birthdayHeight:n[`${a}BirthdayHeight`]}},e=>({[`${a}Mnemonic`]:e.mnemonic,[`${a}BirthdayHeight`]:e.birthdayHeight}))};var b=u(94935),L=u(84650),o=u(72681),p=Object.defineProperty,y=Object.getOwnPropertySymbols,w=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty,d=Object.prototype.propertyIsEnumerable,T=Reflect.get,$=(a,t,e)=>t in a?p(a,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):a[t]=e,k=(a,t)=>{for(var e in t||(t={}))D.call(t,e)&&$(a,e,t[e]);if(y)for(var e of y(t))d.call(t,e)&&$(a,e,t[e]);return a},P=(a,t,e)=>T(w(a),e,t),f=(a,t,e)=>new Promise((n,r)=>{var l=s=>{try{c(e.next(s))}catch(h){r(h)}},i=s=>{try{c(e.throw(s))}catch(h){r(h)}},c=s=>s.done?n(s.value):Promise.resolve(s.value).then(l,i);c((e=e.apply(a,t)).next())});class I extends L.P{constructor(t,e,n,r,l){super(t,e,n,r);const{networkInfo:i}=t;this.pluginId=this.currencyInfo.pluginId,this.networkInfo=i,this.makeSynchronizer=l,this.queryMutex=!1,this.started=!1}setOtherData(t){this.otherData=R(t)}initData(){const{birthdayHeight:t}=this.initializer;this.otherData.blockRange.first===0&&(this.otherData.blockRange={first:t,last:t}),this.initialNumBlocksToDownload=-1,this.synchronizerStatus="DISCONNECTED",this.availableZatoshi="0",this.progressRatio=0}initSubscriptions(){this.synchronizer!=null&&(this.synchronizer.on("update",t=>f(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=>f(this,null,function*(){this.synchronizerStatus=t.name,yield this.queryAll()})))}queryAll(){return f(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()){const r=e*.99,l=e*.8;this.tokenCheckBalanceStatus[this.currencyInfo.currencyCode]=r/100,this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=l/100;const i=(r+l)/2;i!==this.progressRatio&&(Math.abs(i-this.progressRatio)>.1||i===1)&&(this.progressRatio=i,this.log.warn(`Scan and download progress: ${Math.floor(i)}%`),this.updateOnAddressesChecked())}}startEngine(){return f(this,null,function*(){this.engineOn=!0,this.started=!0,yield P(I.prototype,this,"startEngine").call(this)})}isSynced(){return this.synchronizerStatus==="SYNCED"}queryBalance(){return f(this,null,function*(){if(!(!this.isSynced()||this.synchronizer==null))try{const t=yield this.synchronizer.getBalance();if(t.totalZatoshi==="-1")return;this.availableZatoshi=t.availableZatoshi,this.updateBalance(this.currencyInfo.currencyCode,t.totalZatoshi)}catch(t){this.warn("Failed to update balances",t),this.updateBalance(this.currencyInfo.currencyCode,"0")}})}queryTransactions(){return f(this,null,function*(){if(this.synchronizer!=null)try{let t=this.otherData.blockRange.first,e=this.otherData.blockRange.last;for(;this.isSynced()&&e<=this.walletLocalData.blockHeight;){if((yield this.synchronizer.getTransactions({first:t,last:e})).forEach(r=>this.processTransaction(r)),e===this.walletLocalData.blockHeight){t=this.walletLocalData.blockHeight,this.walletLocalDataDirty=!0,this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=1,this.updateOnAddressesChecked();break}t=e+1,e=e+this.networkInfo.transactionQueryLimit<this.walletLocalData.blockHeight?e+this.networkInfo.transactionQueryLimit:this.walletLocalData.blockHeight,this.otherData.blockRange={first:t,last:e},this.walletLocalDataDirty=!0}}catch(t){this.error(`Error querying ${this.currencyInfo.currencyCode} transactions `,t)}})}processTransaction(t){let e=t.value;const n=[];t.toAddress!=null?e=`-${(0,m.add)(e,this.networkInfo.defaultNetworkFee)}`:n.push(this.walletInfo.keys.publicKey);const r=t.memos.filter(i=>i!=="").map(i=>({memoName:"memo",type:"text",value:i})),l={blockHeight:t.minedHeight,currencyCode:this.currencyInfo.currencyCode,date:t.blockTimeInSeconds,isSend:e.startsWith("-"),memos:r,nativeAmount:e,networkFee:this.networkInfo.defaultNetworkFee,otherParams:{},ourReceiveAddresses:n,signedTx:"",txid:t.rawTransactionId,walletId:this.walletId};this.addTransaction(this.currencyInfo.currencyCode,l)}syncNetwork(t){return f(this,null,function*(){if(!this.started)return 1e3;const e=C(this.currencyInfo.pluginId)(t==null?void 0:t.privateKeys),{rpcNode:n}=this.networkInfo;return this.initializer=k({mnemonicSeed:e.mnemonic,birthdayHeight:e.birthdayHeight,alias:this.walletInfo.keys.publicKey.slice(0,99)},n),this.synchronizer=yield this.makeSynchronizer(this.initializer),this.initData(),this.initSubscriptions(),yield new Promise(r=>{this.stopSyncing=r})})}killEngine(){return f(this,null,function*(){var t;this.started=!1,this.stopSyncing!=null&&(yield this.stopSyncing(1e3),this.stopSyncing=void 0),yield(t=this.synchronizer)==null?void 0:t.stop(),yield P(I.prototype,this,"killEngine").call(this)})}clearBlockchainCache(){return f(this,null,function*(){yield P(I.prototype,this,"clearBlockchainCache").call(this)})}resyncBlockchain(){return f(this,null,function*(){var t;yield P(I.prototype,this,"killEngine").call(this),yield this.clearBlockchainCache(),yield this.startEngine(),(t=this.synchronizer)==null||t.rescan().catch(e=>this.warn("resyncBlockchain failed: ",e)),this.initData(),this.synchronizerStatus="SYNCING"})}getMaxSpendable(){return f(this,null,function*(){const t=(0,m.sub)(this.availableZatoshi,this.networkInfo.defaultNetworkFee);if((0,m.lte)(t,"0"))throw new b.C_;return t})}makeSpend(t){return f(this,null,function*(){var e;if(t=(0,o.s)(t,this.currencyInfo),!this.isSynced())throw new Error("Cannot spend until wallet is synced");const{edgeSpendInfo:n,currencyCode:r}=this.makeSpendCheck(t),{memos:l=[]}=n,i=n.spendTargets[0],{publicAddress:c,nativeAmount:s}=i;if(c==null)throw new Error("makeSpend Missing publicAddress");if(s==null)throw new b.$D;if((0,m.eq)(s,"0"))throw new b.$D;const h=(0,m.add)(s,this.networkInfo.defaultNetworkFee);if((0,m.gt)(h,(e=this.walletLocalData.totalBalances[this.currencyInfo.currencyCode])!=null?e:"0"))throw new b.C_;if((0,m.gt)(h,this.availableZatoshi))throw new b.C_("Amount exceeds available balance");const N=(0,m.mul)(h,"-1");return{blockHeight:0,currencyCode:r,date:0,isSend:!0,memos:l,nativeAmount:N,networkFee:this.networkInfo.defaultNetworkFee,ourReceiveAddresses:[],signedTx:"",txid:"",walletId:this.walletId}})}signTx(t){return f(this,null,function*(){return t})}broadcastTx(t,e){return f(this,null,function*(){var n;if(this.synchronizer==null)throw new Error("Synchronizer undefined");const{memos:r}=t,l=C(this.pluginId)(e==null?void 0:e.privateKeys);if(t.spendTargets==null||t.spendTargets.length!==1)throw new Error("Invalid spend targets");const i=((n=r[0])==null?void 0:n.type)==="text"?r[0].value:"",c=t.spendTargets[0],s={zatoshi:(0,m.sub)((0,m.abs)(t.nativeAmount),t.networkFee),toAddress:c.publicAddress,memo:i,fromAccountIndex:0,mnemonicSeed:l.mnemonic};try{const h=yield this.synchronizer.sendToAddress(s);t.txid=h.txId,t.signedTx=h.raw,t.date=Date.now()/1e3,this.warn(`SUCCESS broadcastTx
2
+ ${(0,M.oX)(t)}`)}catch(h){throw this.warn("FAILURE broadcastTx failed: ",h),h}return t})}getFreshAddress(){return f(this,null,function*(){if(this.synchronizer==null)throw new Error("Synchronizer undefined");return{publicAddress:(yield this.synchronizer.deriveUnifiedAddress()).saplingAddress}})}}function S(a,t,e,n){return f(this,null,function*(){const r=A(e),{makeSynchronizer:l}=a.nativeIo["edge-currency-accountbased"].piratechain,i=new I(a,t,r,n,l);return yield i.loadEngine(),i})}var v=(a,t,e)=>new Promise((n,r)=>{var l=s=>{try{c(e.next(s))}catch(h){r(h)}},i=s=>{try{c(e.throw(s))}catch(h){r(h)}},c=s=>s.done?n(s.value):Promise.resolve(s.value).then(l,i);c((e=e.apply(a,t)).next())});class E{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 i=t.nativeIo["edge-currency-accountbased"];if(i==null)throw new Error("Need opts");const{Tools:c}=i.piratechain;this.nativeTools=c}getDisplayPrivateKey(t){return v(this,null,function*(){const{pluginId:e}=this.currencyInfo;return C(e)(t.keys).mnemonic})}getDisplayPublicKey(t){return v(this,null,function*(){const{keys:e}=A(t);return e.publicKey})}getNewWalletBirthdayBlockheight(){return v(this,null,function*(){try{return yield this.nativeTools.getBirthdayHeight(this.networkInfo.rpcNode.defaultHost,this.networkInfo.rpcNode.defaultPort)}catch{return this.networkInfo.defaultBirthday}})}isValidAddress(t){return v(this,null,function*(){return yield this.nativeTools.isValidAddress(t)})}importPrivateKey(t){return v(this,arguments,function*(e,n={}){const{pluginId:r}=this.currencyInfo;if(!(0,U.validateMnemonic)(e))throw new Error(`Invalid ${this.currencyInfo.currencyCode} mnemonic`);const i=yield this.getNewWalletBirthdayBlockheight();let c=i;const{birthdayHeight:s}=n;if(s!=null){(0,O.jD)(s);const h=parseInt(s);if(h>i)throw new Error("InvalidBirthdayHeight");c=h}return{[`${r}Mnemonic`]:e,[`${r}BirthdayHeight`]:c}})}createPrivateKey(t){return v(this,null,function*(){if(t!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const e=x.Buffer.from(this.io.random(32)).toString("hex"),n=(0,U.entropyToMnemonic)(e);return yield this.importPrivateKey(n)})}checkPublicKey(t){return v(this,null,function*(){try{return K(t),!0}catch{return!1}})}derivePublicKey(t){return v(this,null,function*(){const{pluginId:e}=this.currencyInfo,n=C(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 l=yield this.nativeTools.deriveViewingKey(r,this.networkInfo.rpcNode.networkName);return{birthdayHeight:n.birthdayHeight,publicKey:l}})}parseUri(t,e,n){return v(this,null,function*(){const{pluginId:r}=this.currencyInfo,l={[r]:!0},{edgeParsedUri:i,edgeParsedUri:{publicAddress:c}}=(0,B.k)(this.currencyInfo,t,l,e!=null?e:this.currencyInfo.currencyCode,n);if(c==null||!(yield this.isValidAddress(c)))throw new Error("InvalidPublicAddressError");return i})}encodeUri(t){return v(this,arguments,function*(e,n=[]){const{pluginId:r}=this.currencyInfo,{nativeAmount:l,currencyCode:i,publicAddress:c}=e;if(!(yield this.isValidAddress(c)))throw new Error("InvalidPublicAddressError");let s;if(l!=null){const N=(0,M.Qs)(i!=null?i:this.currencyInfo.currencyCode,this.currencyInfo,n);if(N==null)throw new Error("InternalErrorInvalidCurrencyCode");s=(0,m.div)(l,N.multiplier,18)}return(0,B.Q)(e,`${r}`,s)})}}function F(a){return v(this,null,function*(){return new E(a)})}},52361:function(){},94616:function(){}}]);