edge-currency-accountbased 2.2.0 → 2.2.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 +14 -1
- package/android/src/main/assets/edge-currency-accountbased/223.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/edge-currency-accountbased.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/polkadot.chunk.js +2 -2
- package/lib/filecoin/filecoinInfo.js +2 -3
- package/lib/polkadot/PolkadotEngine.js +133 -95
- package/lib/polkadot/info/liberlandInfo.js +2 -1
- package/lib/polkadot/info/liberlandTestnetInfo.js +2 -1
- package/lib/polkadot/info/polkadotInfo.js +1 -0
- package/lib/polkadot/polkadotTypes.js +0 -8
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[591],{79014:function(Z,D,h){h.d(D,{Q:function(){return Q},k:function(){return V}});var E=h(77591),_=h.n(E),N=h(24350),W=h(84564),p=h.n(W),M=h(76714),L=Object.defineProperty,T=Object.getOwnPropertySymbols,U=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable,o=(c,f,m)=>f in c?L(c,f,{enumerable:!0,configurable:!0,writable:!0,value:m}):c[f]=m,X=(c,f)=>{for(var m in f||(f={}))U.call(f,m)&&o(c,m,f[m]);if(T)for(var m of T(f))I.call(f,m)&&o(c,m,f[m]);return c};function V(c,f,m,g,S=[]){const y=X({},p()(f,{},!0)),O=f.startsWith(`${c.pluginId}://`);if(y.protocol!=null&&(y.protocol=y.protocol.replace(":","")),y.protocol!=null&&y.protocol!==""&&!m[y.protocol])throw new Error(`Uri protocol '${y.protocol}' is not supported for ${c.pluginId}.`);if(y.host===""&&y.pathname==="")throw new Error("Path and host not found in uri.");const C={publicAddress:y.host!==""?y.host:y.pathname.split("/")[0]},H=y.query.label,$=y.query.message,K=y.query.category;(H!=null||$!=null||K!=null||O)&&(C.metadata={},C.metadata.name=H,C.metadata.notes=$,C.metadata.category=K,C.metadata.gateway=O!=null?O:!1);const x=y.query.amount;if(x!=null&&typeof x=="string"){g==null&&(g=c.currencyCode);const R=(0,M.Qs)(g!=null?g:"",c,S);if(R==null)throw new Error("InternalErrorInvalidCurrencyCode");let B=(0,E.mul)(x,R.multiplier);B=(0,E.toFixed)(B,0,0),C.nativeAmount=B,C.currencyCode=g}return{edgeParsedUri:C,parsedUri:y}}function Q(c,f,m){if(c.publicAddress==null)throw new Error("InvalidPublicAddressError");if(m==null&&c.label==null&&c.message==null)return c.publicAddress;{let g="";m!=null&&(g+="amount="+m+"&"),(c.label!=null||c.message!=null)&&(typeof c.label=="string"&&(g+="label="+c.label+"&"),typeof c.message=="string"&&(g+="message="+c.message+"&")),g=g.substr(0,g.length-1);const S={scheme:f,path:c.publicAddress,query:g};return(0,N.qC)(S)}}},34765:function(Z,D,h){h.r(D),h.d(D,{PolkadotTools:function(){return J},makeCurrencyEngine:function(){return at},makeCurrencyTools:function(){return ut}});var E=h(58170),_=h(21293),N=h(18534),W=h(23670),p=h(77591),M=h(2153),L=h(48764),T=h(20918),U=h(79014),I=h(76714),o=h(82448),X=h(62177);const V=(0,o.Vk)((0,o.su)({balance:o.mH})),Q=(0,o.su)({txCount:(0,o.Vk)(o.mH,0)}),c=(0,o.su)({code:o.mH,message:o.XC,data:(0,o.Zz)((0,o.su)(o.JC))}),f=(0,o.su)({from:o.XC,to:o.XC,success:o.jK,hash:o.XC,block_num:o.mH,block_timestamp:o.mH,module:o.XC,amount:o.XC,fee:o.XC}),m=(0,o.su)({count:o.mH,transfers:(0,o.Vk)((0,o._2)(f),()=>[])}),g=X.BQ,S=l=>{const t=(0,o.su)({[`${l}Mnemonic`]:(0,o.Zz)(o.XC),[`${l}Key`]:o.XC});return(0,o.W1)(e=>{const s=t(e);return{mnemonic:s[`${l}Mnemonic`],privateKey:s[`${l}Key`]}},e=>({[`${l}Mnemonic`]:e.mnemonic,[`${l}Key`]:e.privateKey}))};var y=h(94935),O=h(35620),z=h(84650),C=Object.defineProperty,H=Object.defineProperties,$=Object.getOwnPropertyDescriptors,K=Object.getOwnPropertySymbols,x=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable,tt=Reflect.get,G=(l,t,e)=>t in l?C(l,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):l[t]=e,et=(l,t)=>{for(var e in t||(t={}))R.call(t,e)&&G(l,e,t[e]);if(K)for(var e of K(t))B.call(t,e)&&G(l,e,t[e]);return l},nt=(l,t)=>H(l,$(t)),q=(l,t,e)=>tt(x(l),e,t),v=(l,t,e)=>new Promise((s,n)=>{var r=i=>{try{u(e.next(i))}catch(d){n(d)}},a=i=>{try{u(e.throw(i))}catch(d){n(d)}},u=i=>i.done?s(i.value):Promise.resolve(i.value).then(r,a);u((e=e.apply(l,t)).next())});const rt=5e3,st=2e4,ot=3e3,it=(0,I.jT)();class F extends z.P{constructor(t,e,s,n){super(t,e,s,n),this.getRecipientBalance=r=>v(this,null,function*(){try{return(yield this.api.query.system.account(r)).data.free.toString()}catch{return this.minimumAddressBalance}}),this.fetchCors=(0,I.zR)(t.io),this.networkInfo=t.networkInfo,this.nonce=0}setOtherData(t){this.otherData=Q(t)}fetchSubscan(t,e){return v(this,null,function*(){if(this.networkInfo.subscanBaseUrl==null)throw new Error("Missing subscan url");const s={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)},n=yield this.fetchCors(this.networkInfo.subscanBaseUrl+t,s);if(!n.ok||n.status===429)throw new Error(`Subscan ${t} failed with ${n.status}`);const r=yield n.json();return c(r)})}queryBalance(){return v(this,null,function*(){const t=[[this.api.query.system.account,this.walletInfo.keys.publicKey]],e=[];for(const n of this.enabledTokenIds){const r=this.allTokensMap[n];if(r==null)continue;const a=(0,T.Oj)(r.networkLocation);a!=null&&(t.push([this.api.query.assets.account,[a.contractAddress,this.walletInfo.keys.publicKey]]),e.push(r))}(yield this.api.queryMulti(t,n=>{if(n.length===0)throw new Error("No balances returned");const r=n.shift();this.nonce=r.nonce.toNumber(),this.updateBalance(this.currencyInfo.currencyCode,r.data.free.toString());for(const[a,u]of n.entries()){const i=e[a],d=V(u.toPrimitive());if(d==null){this.updateBalance(i.currencyCode,"0");return}this.updateBalance(i.currencyCode,d.balance.toString())}}))()})}queryBlockheight(){return v(this,null,function*(){try{const e=(yield this.api.rpc.chain.getBlock()).block.header.number.toNumber();e>this.walletLocalData.blockHeight&&(this.walletLocalData.blockHeight=e,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight))}catch(t){this.warn("queryBlockheight failed with error: ",t)}})}processPolkadotTransaction(t){const{from:e,to:s,success:n,hash:r,block_num:a,block_timestamp:u,module:i,amount:d,fee:k}=t;if(!n||i!=="balances")return;const w=(0,I.aL)(this.currencyInfo.currencyCode,this.currencyInfo,this.allTokensMap);if(w==null)return;const A=[];let P=(0,p.mul)(d,w.multiplier);e===this.walletInfo.keys.publicKey?P=`-${(0,p.add)(P,k)}`:A.push(s);const j={txid:r,date:u,currencyCode:this.currencyInfo.currencyCode,blockHeight:a,nativeAmount:P,isSend:P.startsWith("-"),networkFee:k,ourReceiveAddresses:A,signedTx:"",walletId:this.walletId};this.addTransaction(this.currencyInfo.currencyCode,j)}queryTransactions(){return v(this,null,function*(){if(this.networkInfo.subscanBaseUrl==null){for(const t of this.enabledTokens)this.tokenCheckTransactionsStatus[t]=1;this.updateOnAddressesChecked();return}return yield it(()=>v(this,null,function*(){return yield this.queryTransactionsInner()}))})}queryTransactionsInner(){return v(this,null,function*(){let t=Math.floor(this.otherData.txCount/this.networkInfo.subscanQueryLimit);for(;;){const e={row:this.networkInfo.subscanQueryLimit,page:t,address:this.walletInfo.keys.publicKey};let s=0,n=[];try{const r=yield this.fetchSubscan("/scan/transfers",e),a=m(r.data);s=a.count,n=a.transfers}catch(r){if(r instanceof Error&&r.message.includes("Subscan /scan/transfers failed with 429")){this.log(r.message);continue}else throw r}if(n.forEach(r=>{try{this.processPolkadotTransaction(f(r))}catch{const u=r!=null&&typeof r.hash=="string"?r.hash:"";this.warn(`Ignoring invalid transfer ${u}`)}}),this.otherData.txCount=t*this.networkInfo.subscanQueryLimit+n.length,this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=Math.min(1,s===0?1:this.otherData.txCount/s),this.updateOnAddressesChecked(),s===this.otherData.txCount)break;t++}this.transactionsChangedArray.length>0&&(this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[])})}startEngine(){return v(this,null,function*(){this.engineOn=!0,yield this.tools.connectApi(this.walletId),this.api=this.tools.polkadotApi,this.minimumAddressBalance=this.api.consts.balances.existentialDeposit.toString(),this.addToLoop("queryBlockheight",st).catch(()=>{}),this.addToLoop("queryBalance",rt).catch(()=>{}),this.addToLoop("queryTransactions",ot).catch(()=>{}),yield q(F.prototype,this,"startEngine").call(this)})}killEngine(){return v(this,null,function*(){yield q(F.prototype,this,"killEngine").call(this),yield this.tools.disconnectApi(this.walletId)})}resyncBlockchain(){return v(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}getMaxSpendable(t){return v(this,null,function*(){if(t.spendTargets.length===0||t.spendTargets[0].publicAddress==null)throw new Error("Missing public address");const e=this.getBalance({currencyCode:t.currencyCode}),s=(0,p.sub)(e,this.api.consts.balances.existentialDeposit.toString()),n=[{publicAddress:t.spendTargets[0].publicAddress,nativeAmount:"0"}],r=nt(et({},t),{spendTargets:n}),u=(yield this.makeSpend(r)).networkFee,i=(d,k)=>{const w=(0,p.sub)(k,d);if((0,p.lte)(w,"1"))return d;const A=(0,p.add)(d,(0,p.div)(w,"2")),P=(0,I.X0)(A).replace("0x",""),j=P.length%2===1?`0${P}`:P,dt=(0,p.mul)((0,p.div)(j.length.toString(),"2"),this.networkInfo.lengthFeePerByte),ht=(0,p.add)((0,p.add)(dt,u),A);return(0,p.gt)(ht,s)?i(d,A):i(A,k)};return i("0",(0,p.add)(s,"1"))})}makeSpend(t){return v(this,null,function*(){const{edgeSpendInfo:e,currencyCode:s}=this.makeSpendCheck(t);if(e.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{nativeAmount:n,publicAddress:r}=e.spendTargets[0];if(r==null)throw new Error("makeSpend Missing publicAddress");if(n==null)throw new y.$D;const a=this.getBalance({currencyCode:this.currencyInfo.currencyCode}),u=(0,p.sub)(a,this.api.consts.balances.existentialDeposit.toString());if((0,p.gt)(n,u))throw new y.C_;const d=yield(e.tokenId!=null?yield this.api.tx.assets.transferKeepAlive(parseInt(e.tokenId),r,n):yield this.api.tx.balances.transferKeepAlive(r,n)).paymentInfo(this.walletInfo.keys.publicKey),k=(0,p.sub)(d.partialFee.toString(),this.networkInfo.lengthFeePerByte),w=(0,p.add)(n,k);if((0,p.gt)(w,u))throw new y.C_;const A={publicAddress:r};return{txid:"",date:0,currencyCode:s,blockHeight:0,nativeAmount:(0,p.mul)(w,"-1"),isSend:!0,networkFee:k,ourReceiveAddresses:[],signedTx:"",otherParams:A,walletId:this.walletId}})}signTx(t,e){return v(this,null,function*(){const s=S(this.currencyInfo.pluginId)(e),{publicAddress:n}=(0,I.Xp)(t);if(n==null)throw new Error("Missing publicAddress from makeSpend");const r=(0,p.abs)((0,p.add)(t.nativeAmount,t.networkFee));yield this.checkRecipientMinimumBalance(this.getRecipientBalance,r,n);const a=this.allTokens.find(w=>w.currencyCode===t.currencyCode),u=(a==null?void 0:a.contractAddress)!=null?yield this.api.tx.assets.transferKeepAlive(parseInt(a.contractAddress),n,r):yield this.api.tx.balances.transferKeepAlive(n,r),i=this.api.createType("SignerPayload",{method:u,nonce:this.nonce,genesisHash:this.api.genesisHash,blockHash:this.api.genesisHash,runtimeVersion:this.api.runtimeVersion,version:this.api.extrinsicVersion}),d=this.api.createType("ExtrinsicPayload",i.toPayload(),{version:this.api.extrinsicVersion});if(this.keypair==null)if(this.keypair=new E.Y({ss58Format:0}),s.mnemonic!=null)this.keypair.addFromUri(s.mnemonic);else{const w=O.YU.parse(s.privateKey);this.keypair.addFromSeed(w)}const k=d.sign(this.keypair.getPair(this.walletInfo.keys.publicKey));return u.addSignature(this.walletInfo.keys.publicKey,k.signature,i.toPayload()),t.signedTx=u.toHex(),t})}broadcastTx(t){return v(this,null,function*(){try{const e=yield this.api.rpc.author.submitExtrinsic(t.signedTx);t.txid=e.toHex(),t.date=Date.now()/1e3,this.warn(`SUCCESS broadcastTx
|
|
2
|
-
${(0,I.oX)(t)}`)}catch(e){throw this.warn("FAILURE broadcastTx failed: ",e),e}return t})}}function
|
|
1
|
+
"use strict";(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[591],{79014:function(et,M,d){d.d(M,{Q:function(){return _},k:function(){return V}});var S=d(77591),j=d.n(S),W=d(24350),X=d(84564),i=d.n(X),L=d(76714),U=Object.defineProperty,T=Object.getOwnPropertySymbols,F=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable,a=(c,g,m)=>g in c?U(c,g,{enumerable:!0,configurable:!0,writable:!0,value:m}):c[g]=m,Q=(c,g)=>{for(var m in g||(g={}))F.call(g,m)&&a(c,m,g[m]);if(T)for(var m of T(g))I.call(g,m)&&a(c,m,g[m]);return c};function V(c,g,m,k,P=[]){const y=Q({},i()(g,{},!0)),O=g.startsWith(`${c.pluginId}://`);if(y.protocol!=null&&(y.protocol=y.protocol.replace(":","")),y.protocol!=null&&y.protocol!==""&&!m[y.protocol])throw new Error(`Uri protocol '${y.protocol}' is not supported for ${c.pluginId}.`);if(y.host===""&&y.pathname==="")throw new Error("Path and host not found in uri.");const C={publicAddress:y.host!==""?y.host:y.pathname.split("/")[0]},H=y.query.label,x=y.query.message,R=y.query.category;(H!=null||x!=null||R!=null||O)&&(C.metadata={},C.metadata.name=H,C.metadata.notes=x,C.metadata.category=R,C.metadata.gateway=O!=null?O:!1);const B=y.query.amount;if(B!=null&&typeof B=="string"){k==null&&(k=c.currencyCode);const $=(0,L.Qs)(k!=null?k:"",c,P);if($==null)throw new Error("InternalErrorInvalidCurrencyCode");let D=(0,S.mul)(B,$.multiplier);D=(0,S.toFixed)(D,0,0),C.nativeAmount=D,C.currencyCode=k}return{edgeParsedUri:C,parsedUri:y}}function _(c,g,m){if(c.publicAddress==null)throw new Error("InvalidPublicAddressError");if(m==null&&c.label==null&&c.message==null)return c.publicAddress;{let k="";m!=null&&(k+="amount="+m+"&"),(c.label!=null||c.message!=null)&&(typeof c.label=="string"&&(k+="label="+c.label+"&"),typeof c.message=="string"&&(k+="message="+c.message+"&")),k=k.substr(0,k.length-1);const P={scheme:g,path:c.publicAddress,query:k};return(0,W.qC)(P)}}},34765:function(et,M,d){d.r(M),d.d(M,{PolkadotTools:function(){return tt},makeCurrencyEngine:function(){return it},makeCurrencyTools:function(){return ct}});var S=d(58170),j=d(21293),W=d(18534),X=d(23670),i=d(77591),L=d(2153),U=d(48764),T=d(20918),F=d(79014),I=d(76714),a=d(82448),Q=d(62177);const V=(0,a.su)({txCount:(0,a.Vk)(a.mH,0)}),_=(0,a.su)({code:a.mH,message:a.XC,data:(0,a.Zz)((0,a.su)(a.JC))}),c=(0,a.su)({from:a.XC,to:a.XC,success:a.jK,hash:a.XC,block_num:a.mH,block_timestamp:a.mH,module:a.XC,amount:a.XC,fee:a.XC}),g=(0,a.su)({count:a.mH,transfers:(0,a.Vk)((0,a._2)(c),()=>[])}),m=Q.BQ,k=u=>{const t=(0,a.su)({[`${u}Mnemonic`]:(0,a.Zz)(a.XC),[`${u}Key`]:a.XC});return(0,a.W1)(e=>{const r=t(e);return{mnemonic:r[`${u}Mnemonic`],privateKey:r[`${u}Key`]}},e=>({[`${u}Mnemonic`]:e.mnemonic,[`${u}Key`]:e.privateKey}))};var P=d(94935),y=d(35620),O=d(84650),z=Object.defineProperty,C=Object.defineProperties,H=Object.getOwnPropertyDescriptors,x=Object.getOwnPropertySymbols,R=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty,$=Object.prototype.propertyIsEnumerable,D=Reflect.get,G=(u,t,e)=>t in u?z(u,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):u[t]=e,Y=(u,t)=>{for(var e in t||(t={}))B.call(t,e)&&G(u,e,t[e]);if(x)for(var e of x(t))$.call(t,e)&&G(u,e,t[e]);return u},J=(u,t)=>C(u,H(t)),Z=(u,t,e)=>D(R(u),e,t),w=(u,t,e)=>new Promise((r,n)=>{var s=o=>{try{h(e.next(o))}catch(f){n(f)}},l=o=>{try{h(e.throw(o))}catch(f){n(f)}},h=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,l);h((e=e.apply(u,t)).next())});const nt=5e3,rt=2e4,st=3e3,ot=(0,I.jT)();class N extends O.P{constructor(t,e,r,n){super(t,e,r,n),this.getRecipientBalance=s=>w(this,null,function*(){try{return(yield this.api.query.system.account(s)).data.free.toString()}catch{return this.minimumAddressBalance}}),this.fetchCors=(0,I.zR)(t.io),this.networkInfo=t.networkInfo,this.nonce=0}setOtherData(t){this.otherData=V(t)}fetchSubscan(t,e){return w(this,null,function*(){if(this.networkInfo.subscanBaseUrl==null)throw new Error("Missing subscan url");const r={method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:JSON.stringify(e)},n=yield this.fetchCors(this.networkInfo.subscanBaseUrl+t,r);if(!n.ok||n.status===429)throw new Error(`Subscan ${t} failed with ${n.status}`);const s=yield n.json();return _(s)})}queryBalance(){return w(this,null,function*(){const t=yield this.api.query.system.account(this.walletInfo.keys.publicKey);this.nonce=t.nonce.toNumber(),this.updateBalance(this.currencyInfo.currencyCode,t.data.free.toString());for(const e of this.enabledTokenIds){const r=this.allTokensMap[e];if(r==null)continue;const n=(0,T.Oj)(r.networkLocation);if(n==null)continue;const s=yield this.api.query.assets.account(n.contractAddress,this.walletInfo.keys.publicKey);let l="0";s.isSome&&(l=s.unwrap().balance.toString()),this.updateBalance(r.currencyCode,l)}})}queryBlockheight(){return w(this,null,function*(){try{const e=(yield this.api.rpc.chain.getBlock()).block.header.number.toNumber();e>this.walletLocalData.blockHeight&&(this.walletLocalData.blockHeight=e,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight))}catch(t){this.warn("queryBlockheight failed with error: ",t)}})}processPolkadotTransaction(t){const{from:e,to:r,success:n,hash:s,block_num:l,block_timestamp:h,module:o,amount:f,fee:p}=t;if(!n||o!=="balances")return;const E=(0,I.aL)(this.currencyInfo.currencyCode,this.currencyInfo,this.allTokensMap);if(E==null)return;const A=[];let v=(0,i.mul)(f,E.multiplier);e===this.walletInfo.keys.publicKey?v=`-${(0,i.add)(v,p)}`:A.push(r);const K={txid:s,date:h,currencyCode:this.currencyInfo.currencyCode,blockHeight:l,nativeAmount:v,isSend:v.startsWith("-"),networkFee:p,ourReceiveAddresses:A,signedTx:"",walletId:this.walletId};this.addTransaction(this.currencyInfo.currencyCode,K)}queryTransactions(){return w(this,null,function*(){if(this.networkInfo.subscanBaseUrl==null){for(const t of this.enabledTokens)this.tokenCheckTransactionsStatus[t]=1;this.updateOnAddressesChecked();return}return yield ot(()=>w(this,null,function*(){return yield this.queryTransactionsInner()}))})}queryTransactionsInner(){return w(this,null,function*(){let t=Math.floor(this.otherData.txCount/this.networkInfo.subscanQueryLimit);for(;;){const e={row:this.networkInfo.subscanQueryLimit,page:t,address:this.walletInfo.keys.publicKey};let r=0,n=[];try{const s=yield this.fetchSubscan("/scan/transfers",e),l=g(s.data);r=l.count,n=l.transfers}catch(s){if(s instanceof Error&&s.message.includes("Subscan /scan/transfers failed with 429")){this.log(s.message);continue}else throw s}if(r===this.otherData.txCount||(n.forEach(s=>{try{this.processPolkadotTransaction(c(s))}catch{const h=s!=null&&typeof s.hash=="string"?s.hash:"";this.warn(`Ignoring invalid transfer ${h}`)}}),this.otherData.txCount=t*this.networkInfo.subscanQueryLimit+n.length,this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=Math.min(1,r===0?1:this.otherData.txCount/r),this.updateOnAddressesChecked(),r===this.otherData.txCount))break;t++}this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=1,this.updateOnAddressesChecked(),this.transactionsChangedArray.length>0&&(this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[])})}startEngine(){return w(this,null,function*(){this.engineOn=!0,yield this.tools.connectApi(this.walletId),this.api=this.tools.polkadotApi,this.minimumAddressBalance=this.api.consts.balances.existentialDeposit.toString(),this.addToLoop("queryBlockheight",rt).catch(()=>{}),this.addToLoop("queryBalance",nt).catch(()=>{}),this.addToLoop("queryTransactions",st).catch(()=>{}),yield Z(N.prototype,this,"startEngine").call(this)})}killEngine(){return w(this,null,function*(){yield Z(N.prototype,this,"killEngine").call(this),yield this.tools.disconnectApi(this.walletId)})}resyncBlockchain(){return w(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}getMaxSpendable(t){return w(this,null,function*(){if(t.spendTargets.length===0||t.spendTargets[0].publicAddress==null)throw new Error("Missing public address");const e=this.getBalance({currencyCode:t.currencyCode});if(t.currencyCode!==this.currencyInfo.currencyCode){const f=[{publicAddress:t.spendTargets[0].publicAddress,nativeAmount:e}],p=J(Y({},t),{spendTargets:f});return yield this.makeSpend(p),e}const r=(0,i.sub)(e,this.api.consts.balances.existentialDeposit.toString()),n=[{publicAddress:t.spendTargets[0].publicAddress,nativeAmount:"0"}],s=J(Y({},t),{spendTargets:n}),h=(yield this.makeSpend(s)).networkFee,o=(f,p)=>{const E=(0,i.sub)(p,f);if((0,i.lte)(E,"1"))return f;const A=(0,i.add)(f,(0,i.div)(E,"2")),v=(0,I.X0)(A).replace("0x",""),K=v.length%2===1?`0${v}`:v,ut=(0,i.mul)((0,i.div)(K.length.toString(),"2"),this.networkInfo.lengthFeePerByte),dt=(0,i.add)((0,i.add)(ut,h),A);return(0,i.gt)(dt,r)?o(f,A):o(A,p)};return o("0",(0,i.add)(r,"1"))})}makeSpend(t){return w(this,null,function*(){const{edgeSpendInfo:e,currencyCode:r}=this.makeSpendCheck(t);if(e.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{nativeAmount:n,publicAddress:s}=e.spendTargets[0];if(s==null)throw new Error("makeSpend Missing publicAddress");if(n==null)throw new P.$D;const l=this.getBalance({currencyCode:r});let h,o;if(e.tokenId==null){const E=(0,i.sub)(l,this.api.consts.balances.existentialDeposit.toString());if((0,i.gt)(n,E))throw new P.C_;const v=yield(yield this.api.tx.balances.transferKeepAlive(s,n)).paymentInfo(this.walletInfo.keys.publicKey);if(o=(0,i.sub)(v.partialFee.toString(),(0,i.mul)(this.networkInfo.lengthFeePerByte,this.networkInfo.partialFeeOffsetMultiplier)),h=(0,i.add)(n,o),(0,i.gt)(h,E))throw new P.C_}else{if((0,i.gt)(n,l))throw new P.C_;h=n;const A=yield(yield this.api.tx.assets.transfer(parseInt(e.tokenId),s,n)).paymentInfo(this.walletInfo.keys.publicKey);o=(0,i.sub)(A.partialFee.toString(),(0,i.mul)(this.networkInfo.lengthFeePerByte,this.networkInfo.partialFeeOffsetMultiplier));const v=this.getBalance({currencyCode:this.currencyInfo.currencyCode}),K=(0,i.sub)(v,this.api.consts.balances.existentialDeposit.toString());if((0,i.gt)(o,K))throw new P.C_({currencyCode:this.currencyInfo.currencyCode,networkFee:o})}const f={publicAddress:s};return{txid:"",date:0,currencyCode:r,blockHeight:0,nativeAmount:(0,i.mul)(h,"-1"),isSend:!0,networkFee:o,ourReceiveAddresses:[],signedTx:"",otherParams:f,walletId:this.walletId}})}signTx(t,e){return w(this,null,function*(){const r=k(this.currencyInfo.pluginId)(e),{publicAddress:n}=(0,I.Xp)(t);if(n==null)throw new Error("Missing publicAddress from makeSpend");const s=this.allTokens.find(p=>p.currencyCode===t.currencyCode);let l;if(s==null){const p=(0,i.abs)((0,i.add)(t.nativeAmount,t.networkFee));yield this.checkRecipientMinimumBalance(this.getRecipientBalance,p,n),l=yield this.api.tx.balances.transferKeepAlive(n,p)}else if(s.contractAddress!=null){const p=(0,i.abs)(t.nativeAmount);l=yield this.api.tx.assets.transfer(parseInt(s.contractAddress),n,p)}else throw new Error("Unrecognized asset");const h=this.api.createType("SignerPayload",{method:l,nonce:this.nonce,genesisHash:this.api.genesisHash,blockHash:this.api.genesisHash,runtimeVersion:this.api.runtimeVersion,version:this.api.extrinsicVersion}),o=this.api.createType("ExtrinsicPayload",h.toPayload(),{version:this.api.extrinsicVersion});if(this.keypair==null)if(this.keypair=new S.Y({ss58Format:0}),r.mnemonic!=null)this.keypair.addFromUri(r.mnemonic);else{const p=y.YU.parse(r.privateKey);this.keypair.addFromSeed(p)}const f=o.sign(this.keypair.getPair(this.walletInfo.keys.publicKey));return l.addSignature(this.walletInfo.keys.publicKey,f.signature,h.toPayload()),t.signedTx=l.toHex(),t})}broadcastTx(t){return w(this,null,function*(){try{const e=yield this.api.rpc.author.submitExtrinsic(t.signedTx);t.txid=e.toHex(),t.date=Date.now()/1e3,this.warn(`SUCCESS broadcastTx
|
|
2
|
+
${(0,I.oX)(t)}`)}catch(e){throw this.warn("FAILURE broadcastTx failed: ",e),e}return t})}}function it(u,t,e,r){return w(this,null,function*(){const n=m(e),s=new N(u,t,n,r);return yield s.loadEngine(),s})}var b=(u,t,e)=>new Promise((r,n)=>{var s=o=>{try{h(e.next(o))}catch(f){n(f)}},l=o=>{try{h(e.throw(o))}catch(f){n(f)}},h=o=>o.done?r(o.value):Promise.resolve(o.value).then(s,l);h((e=e.apply(u,t)).next())});const{ed25519PairFromSeed:at,isAddress:q,mnemonicToMiniSecret:lt}=X;class tt{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.polkadotApiSubscribers=new Set}getDisplayPrivateKey(t){return b(this,null,function*(){var e;const{pluginId:r}=this.currencyInfo,n=k(r)(t.keys);return(e=n.mnemonic)!=null?e:n.privateKey})}getDisplayPublicKey(t){return b(this,null,function*(){const{keys:e}=m(t);return e.publicKey})}importPrivateKey(t){return b(this,null,function*(){const{pluginId:e}=this.currencyInfo;if((0,L.validateMnemonic)(t)){const r=lt(t),{secretKey:n}=at(r);return{[`${e}Mnemonic`]:t,[`${e}Key`]:U.Buffer.from(n).toString("hex")}}else{if((0,I.vq)(t))return{[`${e}Key`]:t};throw new Error("InvalidPrivateKey")}})}createPrivateKey(t){return b(this,null,function*(){if(t!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const e=U.Buffer.from(this.io.random(32)),r=(0,L.entropyToMnemonic)(e);return yield this.importPrivateKey(r)})}derivePublicKey(t){return b(this,null,function*(){const{pluginId:e}=this.currencyInfo;return{publicKey:new S.Y({ss58Format:0}).addFromUri(t.keys[`${e}Mnemonic`]).address}})}parseUri(t,e,r){return b(this,null,function*(){var n,s;const{pluginId:l}=this.currencyInfo,h={[l]:!0},{parsedUri:o,edgeParsedUri:f}=(0,F.k)(this.currencyInfo,t,h,e!=null?e:this.currencyInfo.currencyCode,r),p=(n=f.publicAddress)!=null?n:"";if(!q(p))throw new Error("InvalidPublicAddressError");return f.uniqueIdentifier=(s=o.query.memo)!=null?s:void 0,f})}encodeUri(t){return b(this,arguments,function*(e,r=[]){const{pluginId:n}=this.currencyInfo,{nativeAmount:s,currencyCode:l,publicAddress:h}=e;if(!q(h))throw new Error("InvalidPublicAddressError");let o;if(typeof s=="string"){const p=(0,I.Qs)(l!=null?l:this.currencyInfo.currencyCode,this.currencyInfo,r);if(p==null)throw new Error("InternalErrorInvalidCurrencyCode");o=(0,i.div)(s,p.multiplier,10)}return(0,F.Q)(e,n,o)})}connectApi(t){return b(this,null,function*(){return this.polkadotApi==null&&(this.polkadotApi=yield j.G.create({initWasm:!1,provider:new W.U(this.networkInfo.rpcNodes[0])})),this.polkadotApiSubscribers.add(t),this.polkadotApi})}disconnectApi(t){return b(this,null,function*(){this.polkadotApiSubscribers.delete(t),this.polkadotApiSubscribers.size===0&&(yield this.polkadotApi.disconnect(),this.polkadotApi=void 0)})}getTokenId(t){return b(this,null,function*(){(0,T.Rp)(t);const e=(0,T.Oj)(t.networkLocation);if(e==null)throw new Error("ErrorInvalidContractAddress");return e.contractAddress})}}function ct(u){return b(this,null,function*(){return new tt(u)})}}}]);
|
|
@@ -24,9 +24,8 @@ const networkInfo = {
|
|
|
24
24
|
|
|
25
25
|
defaultSettings: {},
|
|
26
26
|
|
|
27
|
-
addressExplorer: 'https://
|
|
28
|
-
transactionExplorer:
|
|
29
|
-
'https://blockchair.com/filecoin/transaction/%s?from=edgeapp',
|
|
27
|
+
addressExplorer: 'https://filscan.io/en/address/%s',
|
|
28
|
+
transactionExplorer: 'https://filscan.io/en/message/%s',
|
|
30
29
|
|
|
31
30
|
denominations: [
|
|
32
31
|
// An array of Objects of the possible denominations for this currency
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});require('@polkadot/api-augment/polkadot');
|
|
2
2
|
|
|
3
3
|
var _api = require('@polkadot/api');
|
|
4
4
|
|
|
@@ -14,8 +14,7 @@ var _biggystring = require('biggystring');
|
|
|
14
14
|
|
|
15
15
|
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
var _types3 = require('edge-core-js/types');
|
|
17
|
+
var _types = require('edge-core-js/types');
|
|
19
18
|
var _rfc4648 = require('rfc4648');
|
|
20
19
|
|
|
21
20
|
var _CurrencyEngine = require('../common/CurrencyEngine');
|
|
@@ -42,7 +41,6 @@ var _utils = require('../common/utils');
|
|
|
42
41
|
|
|
43
42
|
|
|
44
43
|
|
|
45
|
-
|
|
46
44
|
var _polkadotTypes = require('./polkadotTypes');
|
|
47
45
|
|
|
48
46
|
const ACCOUNT_POLL_MILLISECONDS = 5000
|
|
@@ -115,10 +113,14 @@ const queryTxMutex = _utils.makeMutex.call(void 0, )
|
|
|
115
113
|
}
|
|
116
114
|
|
|
117
115
|
async queryBalance() {
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
116
|
+
const accountBalanceRes = await this.api.query.system.account(
|
|
117
|
+
this.walletInfo.keys.publicKey
|
|
118
|
+
)
|
|
119
|
+
this.nonce = accountBalanceRes.nonce.toNumber()
|
|
120
|
+
this.updateBalance(
|
|
121
|
+
this.currencyInfo.currencyCode,
|
|
122
|
+
accountBalanceRes.data.free.toString()
|
|
123
|
+
)
|
|
122
124
|
|
|
123
125
|
for (const tokenId of this.enabledTokenIds) {
|
|
124
126
|
const token = this.allTokensMap[tokenId]
|
|
@@ -126,41 +128,16 @@ const queryTxMutex = _utils.makeMutex.call(void 0, )
|
|
|
126
128
|
const networkLocation = _tokenHelpers.asMaybeContractLocation.call(void 0, token.networkLocation)
|
|
127
129
|
if (networkLocation == null) continue
|
|
128
130
|
|
|
129
|
-
|
|
130
|
-
this.api.query.assets.account,
|
|
131
|
-
[networkLocation.contractAddress, this.walletInfo.keys.publicKey]
|
|
132
|
-
]) // returns Option<PalletAssetsAssetAccount>
|
|
133
|
-
edgeTokenArray.push(token)
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
const unsubscribe = await this.api.queryMulti(queryArray, balances => {
|
|
137
|
-
if (balances.length === 0) {
|
|
138
|
-
throw new Error('No balances returned')
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
// Mainnet
|
|
142
|
-
const accountBalance = balances.shift()
|
|
143
|
-
this.nonce = accountBalance.nonce.toNumber()
|
|
144
|
-
this.updateBalance(
|
|
145
|
-
this.currencyInfo.currencyCode,
|
|
146
|
-
accountBalance.data.free.toString()
|
|
147
|
-
)
|
|
131
|
+
const tokenBalanceRes = await this.api.query.assets.account
|
|
148
132
|
|
|
149
|
-
|
|
150
|
-
for (const [i, assetBalanceRaw] of balances.entries()) {
|
|
151
|
-
const token = edgeTokenArray[i]
|
|
152
|
-
const assetBalance = _polkadotTypes.asMaybeAssetsPalletBalance.call(void 0,
|
|
153
|
-
assetBalanceRaw.toPrimitive()
|
|
154
|
-
)
|
|
155
|
-
if (assetBalance == null) {
|
|
156
|
-
this.updateBalance(token.currencyCode, '0')
|
|
157
|
-
return
|
|
158
|
-
}
|
|
133
|
+
(networkLocation.contractAddress, this.walletInfo.keys.publicKey)
|
|
159
134
|
|
|
160
|
-
|
|
135
|
+
let tokenBalance = '0'
|
|
136
|
+
if (tokenBalanceRes.isSome) {
|
|
137
|
+
tokenBalance = tokenBalanceRes.unwrap().balance.toString()
|
|
161
138
|
}
|
|
162
|
-
|
|
163
|
-
|
|
139
|
+
this.updateBalance(token.currencyCode, tokenBalance)
|
|
140
|
+
}
|
|
164
141
|
}
|
|
165
142
|
|
|
166
143
|
async queryBlockheight() {
|
|
@@ -272,6 +249,10 @@ const queryTxMutex = _utils.makeMutex.call(void 0, )
|
|
|
272
249
|
}
|
|
273
250
|
}
|
|
274
251
|
|
|
252
|
+
// count is the total number of transactions ever for an account
|
|
253
|
+
// If we've already seen all the transfers we don't need to bother processing or page through older ones
|
|
254
|
+
if (count === this.otherData.txCount) break
|
|
255
|
+
|
|
275
256
|
// Process txs (newest first)
|
|
276
257
|
transfers.forEach(tx => {
|
|
277
258
|
try {
|
|
@@ -290,13 +271,14 @@ const queryTxMutex = _utils.makeMutex.call(void 0, )
|
|
|
290
271
|
Math.min(1, count === 0 ? 1 : this.otherData.txCount / count)
|
|
291
272
|
this.updateOnAddressesChecked()
|
|
292
273
|
|
|
293
|
-
// count is the total number of transactions ever for an account
|
|
294
|
-
// If we've already seen all the transfers we don't need to bother processing or page through older ones
|
|
295
274
|
if (count === this.otherData.txCount) break
|
|
296
275
|
|
|
297
276
|
page++
|
|
298
277
|
}
|
|
299
278
|
|
|
279
|
+
this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode] = 1
|
|
280
|
+
this.updateOnAddressesChecked()
|
|
281
|
+
|
|
300
282
|
if (this.transactionsChangedArray.length > 0) {
|
|
301
283
|
this.walletLocalDataDirty = true
|
|
302
284
|
this.currencyEngineCallbacks.onTransactionsChanged(
|
|
@@ -347,6 +329,19 @@ const queryTxMutex = _utils.makeMutex.call(void 0, )
|
|
|
347
329
|
const balance = this.getBalance({
|
|
348
330
|
currencyCode: spendInfo.currencyCode
|
|
349
331
|
})
|
|
332
|
+
|
|
333
|
+
if (spendInfo.currencyCode !== this.currencyInfo.currencyCode) {
|
|
334
|
+
const tempSpendTarget = [
|
|
335
|
+
{
|
|
336
|
+
publicAddress: spendInfo.spendTargets[0].publicAddress,
|
|
337
|
+
nativeAmount: balance
|
|
338
|
+
}
|
|
339
|
+
]
|
|
340
|
+
const maxSpendInfo = { ...spendInfo, spendTargets: tempSpendTarget }
|
|
341
|
+
await this.makeSpend(maxSpendInfo)
|
|
342
|
+
return balance
|
|
343
|
+
}
|
|
344
|
+
|
|
350
345
|
const spendableBalance = _biggystring.sub.call(void 0,
|
|
351
346
|
balance,
|
|
352
347
|
this.api.consts.balances.existentialDeposit.toString()
|
|
@@ -399,45 +394,85 @@ const queryTxMutex = _utils.makeMutex.call(void 0, )
|
|
|
399
394
|
|
|
400
395
|
if (publicAddress == null)
|
|
401
396
|
throw new Error('makeSpend Missing publicAddress')
|
|
402
|
-
if (nativeAmount == null) throw new (0,
|
|
397
|
+
if (nativeAmount == null) throw new (0, _types.NoAmountSpecifiedError)()
|
|
403
398
|
|
|
404
399
|
const balance = this.getBalance({
|
|
405
|
-
currencyCode
|
|
400
|
+
currencyCode
|
|
406
401
|
})
|
|
407
|
-
const spendableBalance = _biggystring.sub.call(void 0,
|
|
408
|
-
balance,
|
|
409
|
-
this.api.consts.balances.existentialDeposit.toString()
|
|
410
|
-
)
|
|
411
402
|
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
}
|
|
403
|
+
let totalTxAmount
|
|
404
|
+
let nativeNetworkFee
|
|
415
405
|
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
nativeAmount
|
|
422
|
-
)
|
|
423
|
-
: await this.api.tx.balances.transferKeepAlive(
|
|
424
|
-
publicAddress,
|
|
425
|
-
nativeAmount
|
|
426
|
-
)
|
|
427
|
-
|
|
428
|
-
const paymentInfo = await transfer.paymentInfo(
|
|
429
|
-
this.walletInfo.keys.publicKey
|
|
430
|
-
)
|
|
406
|
+
if (edgeSpendInfo.tokenId == null) {
|
|
407
|
+
const spendableBalance = _biggystring.sub.call(void 0,
|
|
408
|
+
balance,
|
|
409
|
+
this.api.consts.balances.existentialDeposit.toString()
|
|
410
|
+
)
|
|
431
411
|
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
412
|
+
if (_biggystring.gt.call(void 0, nativeAmount, spendableBalance)) {
|
|
413
|
+
throw new (0, _types.InsufficientFundsError)()
|
|
414
|
+
}
|
|
415
|
+
|
|
416
|
+
const transfer = await this.api.tx.balances.transferKeepAlive(
|
|
417
|
+
publicAddress,
|
|
418
|
+
nativeAmount
|
|
419
|
+
)
|
|
420
|
+
|
|
421
|
+
const paymentInfo = await transfer.paymentInfo(
|
|
422
|
+
this.walletInfo.keys.publicKey
|
|
423
|
+
)
|
|
424
|
+
|
|
425
|
+
// The fee returned from partial fee is always off by some length fee, because reasons
|
|
426
|
+
nativeNetworkFee = _biggystring.sub.call(void 0,
|
|
427
|
+
paymentInfo.partialFee.toString(),
|
|
428
|
+
_biggystring.mul.call(void 0,
|
|
429
|
+
this.networkInfo.lengthFeePerByte,
|
|
430
|
+
this.networkInfo.partialFeeOffsetMultiplier
|
|
431
|
+
)
|
|
432
|
+
)
|
|
437
433
|
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
434
|
+
totalTxAmount = _biggystring.add.call(void 0, nativeAmount, nativeNetworkFee)
|
|
435
|
+
|
|
436
|
+
if (_biggystring.gt.call(void 0, totalTxAmount, spendableBalance)) {
|
|
437
|
+
throw new (0, _types.InsufficientFundsError)()
|
|
438
|
+
}
|
|
439
|
+
} else {
|
|
440
|
+
if (_biggystring.gt.call(void 0, nativeAmount, balance)) {
|
|
441
|
+
throw new (0, _types.InsufficientFundsError)()
|
|
442
|
+
}
|
|
443
|
+
totalTxAmount = nativeAmount
|
|
444
|
+
const transfer = await this.api.tx.assets.transfer(
|
|
445
|
+
parseInt(edgeSpendInfo.tokenId),
|
|
446
|
+
publicAddress,
|
|
447
|
+
nativeAmount
|
|
448
|
+
)
|
|
449
|
+
|
|
450
|
+
const paymentInfo = await transfer.paymentInfo(
|
|
451
|
+
this.walletInfo.keys.publicKey
|
|
452
|
+
)
|
|
453
|
+
|
|
454
|
+
// The fee returned from partial fee is always off by some length fee, because reasons
|
|
455
|
+
nativeNetworkFee = _biggystring.sub.call(void 0,
|
|
456
|
+
paymentInfo.partialFee.toString(),
|
|
457
|
+
_biggystring.mul.call(void 0,
|
|
458
|
+
this.networkInfo.lengthFeePerByte,
|
|
459
|
+
this.networkInfo.partialFeeOffsetMultiplier
|
|
460
|
+
)
|
|
461
|
+
)
|
|
462
|
+
|
|
463
|
+
const feeBalance = this.getBalance({
|
|
464
|
+
currencyCode: this.currencyInfo.currencyCode
|
|
465
|
+
})
|
|
466
|
+
const spendableFeeBalance = _biggystring.sub.call(void 0,
|
|
467
|
+
feeBalance,
|
|
468
|
+
this.api.consts.balances.existentialDeposit.toString()
|
|
469
|
+
)
|
|
470
|
+
if (_biggystring.gt.call(void 0, nativeNetworkFee, spendableFeeBalance)) {
|
|
471
|
+
throw new (0, _types.InsufficientFundsError)({
|
|
472
|
+
currencyCode: this.currencyInfo.currencyCode,
|
|
473
|
+
networkFee: nativeNetworkFee
|
|
474
|
+
})
|
|
475
|
+
}
|
|
441
476
|
}
|
|
442
477
|
|
|
443
478
|
const otherParams = {
|
|
@@ -474,31 +509,34 @@ const queryTxMutex = _utils.makeMutex.call(void 0, )
|
|
|
474
509
|
if (publicAddress == null)
|
|
475
510
|
throw new Error('Missing publicAddress from makeSpend')
|
|
476
511
|
|
|
477
|
-
const nativeAmount = _biggystring.abs.call(void 0,
|
|
478
|
-
_biggystring.add.call(void 0, edgeTransaction.nativeAmount, edgeTransaction.networkFee)
|
|
479
|
-
)
|
|
480
|
-
|
|
481
|
-
await this.checkRecipientMinimumBalance(
|
|
482
|
-
this.getRecipientBalance,
|
|
483
|
-
nativeAmount,
|
|
484
|
-
publicAddress
|
|
485
|
-
)
|
|
486
|
-
|
|
487
512
|
const edgeToken = this.allTokens.find(
|
|
488
513
|
token => token.currencyCode === edgeTransaction.currencyCode
|
|
489
514
|
)
|
|
490
515
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
516
|
+
let transfer
|
|
517
|
+
if (edgeToken == null) {
|
|
518
|
+
const nativeAmount = _biggystring.abs.call(void 0,
|
|
519
|
+
_biggystring.add.call(void 0, edgeTransaction.nativeAmount, edgeTransaction.networkFee)
|
|
520
|
+
)
|
|
521
|
+
await this.checkRecipientMinimumBalance(
|
|
522
|
+
this.getRecipientBalance,
|
|
523
|
+
nativeAmount,
|
|
524
|
+
publicAddress
|
|
525
|
+
)
|
|
526
|
+
transfer = await this.api.tx.balances.transferKeepAlive(
|
|
527
|
+
publicAddress,
|
|
528
|
+
nativeAmount
|
|
529
|
+
)
|
|
530
|
+
} else if (edgeToken.contractAddress != null) {
|
|
531
|
+
const nativeAmount = _biggystring.abs.call(void 0, edgeTransaction.nativeAmount)
|
|
532
|
+
transfer = await this.api.tx.assets.transfer(
|
|
533
|
+
parseInt(edgeToken.contractAddress),
|
|
534
|
+
publicAddress,
|
|
535
|
+
nativeAmount
|
|
536
|
+
)
|
|
537
|
+
} else {
|
|
538
|
+
throw new Error('Unrecognized asset')
|
|
539
|
+
}
|
|
502
540
|
|
|
503
541
|
const signer = this.api.createType('SignerPayload', {
|
|
504
542
|
method: transfer,
|
|
@@ -20,7 +20,8 @@ const networkInfo = {
|
|
|
20
20
|
rpcNodes: ['wss://mainnet.liberland.org/'],
|
|
21
21
|
subscanBaseUrl: undefined,
|
|
22
22
|
subscanQueryLimit: 100,
|
|
23
|
-
|
|
23
|
+
partialFeeOffsetMultiplier: '2',
|
|
24
|
+
lengthFeePerByte: '76800000'
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
const currencyInfo = {
|
|
@@ -20,7 +20,8 @@ const networkInfo = {
|
|
|
20
20
|
rpcNodes: ['wss://testchain.liberland.org/'],
|
|
21
21
|
subscanBaseUrl: undefined,
|
|
22
22
|
subscanQueryLimit: 100,
|
|
23
|
-
|
|
23
|
+
partialFeeOffsetMultiplier: '2',
|
|
24
|
+
lengthFeePerByte: '76800000'
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
const currencyInfo = {
|
|
@@ -13,14 +13,6 @@ var _cleaners = require('cleaners');
|
|
|
13
13
|
|
|
14
14
|
var _types = require('../common/types');
|
|
15
15
|
|
|
16
|
-
const asMaybeAssetsPalletBalance = _cleaners.asMaybe.call(void 0,
|
|
17
|
-
_cleaners.asObject.call(void 0, {
|
|
18
|
-
balance: _cleaners.asNumber
|
|
19
|
-
// status: 'Liquid',
|
|
20
|
-
// reason: { sufficient: null },
|
|
21
|
-
// extra: null
|
|
22
|
-
})
|
|
23
|
-
); exports.asMaybeAssetsPalletBalance = asMaybeAssetsPalletBalance
|
|
24
16
|
|
|
25
17
|
|
|
26
18
|
|