edge-currency-accountbased 2.9.0 → 2.9.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +8 -0
- package/android/src/main/assets/edge-currency-accountbased/4843.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/5336.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/ripple.chunk.js +5 -5
- package/lib/piratechain/PiratechainEngine.js +1 -1
- package/lib/ripple/RippleEngine.js +42 -18
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
|
|
3
3
|
## Unreleased
|
|
4
4
|
|
|
5
|
+
## 2.9.2 (2023-11-02)
|
|
6
|
+
|
|
7
|
+
- changed: (Piratechain) Use walletId as synchronizer alias
|
|
8
|
+
|
|
9
|
+
## 2.9.1 (2023-11-01)
|
|
10
|
+
|
|
11
|
+
- fixed: EdgeTxActionSwap direction parsing for XRP transactions
|
|
12
|
+
|
|
5
13
|
## 2.9.0 (2023-10-25)
|
|
6
14
|
|
|
7
15
|
- added: Parse XRP DEX orders into EdgeTxActions
|
|
@@ -1,2 +1,2 @@
|
|
|
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
|
|
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.walletId},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
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(){}}]);
|