edge-currency-accountbased 2.2.3 → 2.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/android/src/main/assets/edge-currency-accountbased/1944.chunk.js +4 -0
- package/android/src/main/assets/edge-currency-accountbased/2153.chunk.js +2 -0
- package/android/src/main/assets/edge-currency-accountbased/2821.chunk.js +2 -0
- package/android/src/main/assets/edge-currency-accountbased/2896.chunk.js +35 -0
- package/android/src/main/assets/edge-currency-accountbased/2945.chunk.js +25 -0
- package/android/src/main/assets/edge-currency-accountbased/3491.chunk.js +1 -0
- package/android/src/main/assets/edge-currency-accountbased/{620.chunk.js → 3620.chunk.js} +1 -1
- package/android/src/main/assets/edge-currency-accountbased/{666.chunk.js → 3666.chunk.js} +1 -1
- package/android/src/main/assets/edge-currency-accountbased/3720.chunk.js +1 -0
- package/android/src/main/assets/edge-currency-accountbased/{978.chunk.js → 3978.chunk.js} +1 -1
- package/android/src/main/assets/edge-currency-accountbased/4251.chunk.js +4 -0
- package/android/src/main/assets/edge-currency-accountbased/4431.chunk.js +1 -0
- package/android/src/main/assets/edge-currency-accountbased/4618.chunk.js +20 -0
- package/android/src/main/assets/edge-currency-accountbased/{627.chunk.js → 4627.chunk.js} +1 -1
- package/android/src/main/assets/edge-currency-accountbased/4650.chunk.js +1 -0
- package/android/src/main/assets/edge-currency-accountbased/{826.chunk.js → 5179.chunk.js} +1 -1
- package/android/src/main/assets/edge-currency-accountbased/{835.chunk.js → 5835.chunk.js} +1 -1
- package/android/src/main/assets/edge-currency-accountbased/5836.chunk.js +1 -0
- package/android/src/main/assets/edge-currency-accountbased/6266.chunk.js +1 -0
- package/android/src/main/assets/edge-currency-accountbased/6291.chunk.js +58 -0
- package/android/src/main/assets/edge-currency-accountbased/6341.chunk.js +44 -0
- package/android/src/main/assets/edge-currency-accountbased/7221.chunk.js +1 -0
- package/android/src/main/assets/edge-currency-accountbased/7428.chunk.js +6 -0
- package/android/src/main/assets/edge-currency-accountbased/{481.chunk.js → 7481.chunk.js} +1 -1
- package/android/src/main/assets/edge-currency-accountbased/7542.chunk.js +1 -0
- package/android/src/main/assets/edge-currency-accountbased/7786.chunk.js +2 -0
- package/android/src/main/assets/edge-currency-accountbased/8190.chunk.js +1 -0
- package/android/src/main/assets/edge-currency-accountbased/{689.chunk.js → 8689.chunk.js} +1 -1
- package/android/src/main/assets/edge-currency-accountbased/{726.chunk.js → 8726.chunk.js} +1 -1
- package/android/src/main/assets/edge-currency-accountbased/9068.chunk.js +1 -0
- package/android/src/main/assets/edge-currency-accountbased/{223.chunk.js → 9223.chunk.js} +2 -2
- package/android/src/main/assets/edge-currency-accountbased/9539.chunk.js +10 -0
- package/android/src/main/assets/edge-currency-accountbased/{645.chunk.js → 9645.chunk.js} +6 -6
- package/android/src/main/assets/edge-currency-accountbased/9669.chunk.js +7 -0
- package/android/src/main/assets/edge-currency-accountbased/algorand.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/bnb.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/edge-currency-accountbased.js +2 -18
- package/android/src/main/assets/edge-currency-accountbased/eos.chunk.js +5 -5
- package/android/src/main/assets/edge-currency-accountbased/ethereum.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/filecoin.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/fio.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/hedera.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/polkadot.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/ripple.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/solana.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/stellar.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/tezos.chunk.js +2 -2
- package/android/src/main/assets/edge-currency-accountbased/tron.chunk.js +1 -1
- package/android/src/main/assets/edge-currency-accountbased/zcash.chunk.js +2 -2
- package/lib/ethereum/info/avalancheInfo.js +8 -0
- package/lib/ethereum/info/ethereumInfo.js +8 -0
- package/lib/filecoin/FilecoinEngine.js +112 -79
- package/lib/filecoin/Filfox.js +68 -1
- package/lib/filecoin/filecoinInfo.js +8 -3
- package/lib/filecoin/filecoinTypes.js +1 -6
- package/lib/zcash/ZcashEngine.js +11 -9
- package/package.json +1 -1
- package/android/src/main/assets/edge-currency-accountbased/124.chunk.js +0 -35
- package/android/src/main/assets/edge-currency-accountbased/17.chunk.js +0 -58
- package/android/src/main/assets/edge-currency-accountbased/190.chunk.js +0 -1
- package/android/src/main/assets/edge-currency-accountbased/221.chunk.js +0 -1
- package/android/src/main/assets/edge-currency-accountbased/298.chunk.js +0 -44
- package/android/src/main/assets/edge-currency-accountbased/431.chunk.js +0 -1
- package/android/src/main/assets/edge-currency-accountbased/491.chunk.js +0 -1
- package/android/src/main/assets/edge-currency-accountbased/539.chunk.js +0 -10
- package/android/src/main/assets/edge-currency-accountbased/542.chunk.js +0 -1
- package/android/src/main/assets/edge-currency-accountbased/618.chunk.js +0 -20
- package/android/src/main/assets/edge-currency-accountbased/650.chunk.js +0 -1
- package/android/src/main/assets/edge-currency-accountbased/68.chunk.js +0 -1
- package/android/src/main/assets/edge-currency-accountbased/720.chunk.js +0 -1
- package/android/src/main/assets/edge-currency-accountbased/786.chunk.js +0 -2
- package/android/src/main/assets/edge-currency-accountbased/836.chunk.js +0 -1
- package/android/src/main/assets/edge-currency-accountbased/935.chunk.js +0 -1
- package/android/src/main/assets/edge-currency-accountbased/944.chunk.js +0 -4
- package/android/src/main/assets/edge-currency-accountbased/945.chunk.js +0 -25
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[9669],{9669:function(d,m,t){d.exports=t(51609)},55448:function(d,m,t){"use strict";var u=t(64867),f=t(36026),a=t(15327),r=t(84109),o=t(67985),c=t(85061);d.exports=function(e){return new Promise(function(p,v){var h=e.data,S=e.headers;u.isFormData(h)&&delete S["Content-Type"];var l=new XMLHttpRequest;if(e.auth){var U=e.auth.username||"",T=e.auth.password||"";S.Authorization="Basic "+btoa(U+":"+T)}if(l.open(e.method.toUpperCase(),a(e.url,e.params,e.paramsSerializer),!0),l.timeout=e.timeout,l.onreadystatechange=function(){if(!(!l||l.readyState!==4)&&!(l.status===0&&!(l.responseURL&&l.responseURL.indexOf("file:")===0))){var R="getAllResponseHeaders"in l?r(l.getAllResponseHeaders()):null,A=!e.responseType||e.responseType==="text"?l.responseText:l.response,N={data:A,status:l.status,statusText:l.statusText,headers:R,config:e,request:l};f(p,v,N),l=null}},l.onabort=function(){!l||(v(c("Request aborted",e,"ECONNABORTED",l)),l=null)},l.onerror=function(){v(c("Network Error",e,null,l)),l=null},l.ontimeout=function(){v(c("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",l)),l=null},u.isStandardBrowserEnv()){var B=t(4372),g=(e.withCredentials||o(e.url))&&e.xsrfCookieName?B.read(e.xsrfCookieName):void 0;g&&(S[e.xsrfHeaderName]=g)}if("setRequestHeader"in l&&u.forEach(S,function(R,A){typeof h>"u"&&A.toLowerCase()==="content-type"?delete S[A]:l.setRequestHeader(A,R)}),e.withCredentials&&(l.withCredentials=!0),e.responseType)try{l.responseType=e.responseType}catch(C){if(e.responseType!=="json")throw C}typeof e.onDownloadProgress=="function"&&l.addEventListener("progress",e.onDownloadProgress),typeof e.onUploadProgress=="function"&&l.upload&&l.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then(function(R){!l||(l.abort(),v(R),l=null)}),h===void 0&&(h=null),l.send(h)})}},51609:function(d,m,t){"use strict";var u=t(64867),f=t(91849),a=t(30321),r=t(47185),o=t(45655);function c(e){var s=new a(e),p=f(a.prototype.request,s);return u.extend(p,a.prototype,s),u.extend(p,s),p}var n=c(o);n.Axios=a,n.create=function(s){return c(r(n.defaults,s))},n.Cancel=t(65263),n.CancelToken=t(14972),n.isCancel=t(26502),n.all=function(s){return Promise.all(s)},n.spread=t(8713),d.exports=n,d.exports.default=n},65263:function(d){"use strict";function m(t){this.message=t}m.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},m.prototype.__CANCEL__=!0,d.exports=m},14972:function(d,m,t){"use strict";var u=t(65263);function f(a){if(typeof a!="function")throw new TypeError("executor must be a function.");var r;this.promise=new Promise(function(n){r=n});var o=this;a(function(n){o.reason||(o.reason=new u(n),r(o.reason))})}f.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},f.source=function(){var r,o=new f(function(n){r=n});return{token:o,cancel:r}},d.exports=f},26502:function(d){"use strict";d.exports=function(t){return!!(t&&t.__CANCEL__)}},30321:function(d,m,t){"use strict";var u=t(64867),f=t(15327),a=t(80782),r=t(13572),o=t(47185);function c(n){this.defaults=n,this.interceptors={request:new a,response:new a}}c.prototype.request=function(e){typeof e=="string"?(e=arguments[1]||{},e.url=arguments[0]):e=e||{},e=o(this.defaults,e),e.method=e.method?e.method.toLowerCase():"get";var s=[r,void 0],p=Promise.resolve(e);for(this.interceptors.request.forEach(function(h){s.unshift(h.fulfilled,h.rejected)}),this.interceptors.response.forEach(function(h){s.push(h.fulfilled,h.rejected)});s.length;)p=p.then(s.shift(),s.shift());return p},c.prototype.getUri=function(e){return e=o(this.defaults,e),f(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},u.forEach(["delete","get","head","options"],function(e){c.prototype[e]=function(s,p){return this.request(u.merge(p||{},{method:e,url:s}))}}),u.forEach(["post","put","patch"],function(e){c.prototype[e]=function(s,p,v){return this.request(u.merge(v||{},{method:e,url:s,data:p}))}}),d.exports=c},80782:function(d,m,t){"use strict";var u=t(64867);function f(){this.handlers=[]}f.prototype.use=function(r,o){return this.handlers.push({fulfilled:r,rejected:o}),this.handlers.length-1},f.prototype.eject=function(r){this.handlers[r]&&(this.handlers[r]=null)},f.prototype.forEach=function(r){u.forEach(this.handlers,function(c){c!==null&&r(c)})},d.exports=f},85061:function(d,m,t){"use strict";var u=t(80481);d.exports=function(a,r,o,c,n){var e=new Error(a);return u(e,r,o,c,n)}},13572:function(d,m,t){"use strict";var u=t(64867),f=t(18527),a=t(26502),r=t(45655),o=t(91793),c=t(7303);function n(e){e.cancelToken&&e.cancelToken.throwIfRequested()}d.exports=function(s){n(s),s.baseURL&&!o(s.url)&&(s.url=c(s.baseURL,s.url)),s.headers=s.headers||{},s.data=f(s.data,s.headers,s.transformRequest),s.headers=u.merge(s.headers.common||{},s.headers[s.method]||{},s.headers||{}),u.forEach(["delete","get","head","post","put","patch","common"],function(h){delete s.headers[h]});var p=s.adapter||r.adapter;return p(s).then(function(h){return n(s),h.data=f(h.data,h.headers,s.transformResponse),h},function(h){return a(h)||(n(s),h&&h.response&&(h.response.data=f(h.response.data,h.response.headers,s.transformResponse))),Promise.reject(h)})}},80481:function(d){"use strict";d.exports=function(t,u,f,a,r){return t.config=u,f&&(t.code=f),t.request=a,t.response=r,t.isAxiosError=!0,t.toJSON=function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:this.config,code:this.code}},t}},47185:function(d,m,t){"use strict";var u=t(64867);d.exports=function(a,r){r=r||{};var o={};return u.forEach(["url","method","params","data"],function(n){typeof r[n]<"u"&&(o[n]=r[n])}),u.forEach(["headers","auth","proxy"],function(n){u.isObject(r[n])?o[n]=u.deepMerge(a[n],r[n]):typeof r[n]<"u"?o[n]=r[n]:u.isObject(a[n])?o[n]=u.deepMerge(a[n]):typeof a[n]<"u"&&(o[n]=a[n])}),u.forEach(["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"],function(n){typeof r[n]<"u"?o[n]=r[n]:typeof a[n]<"u"&&(o[n]=a[n])}),o}},36026:function(d,m,t){"use strict";var u=t(85061);d.exports=function(a,r,o){var c=o.config.validateStatus;!c||c(o.status)?a(o):r(u("Request failed with status code "+o.status,o.config,null,o.request,o))}},18527:function(d,m,t){"use strict";var u=t(64867);d.exports=function(a,r,o){return u.forEach(o,function(n){a=n(a,r)}),a}},45655:function(d,m,t){"use strict";var u=t(34155),f=t(64867),a=t(16016),r={"Content-Type":"application/x-www-form-urlencoded"};function o(e,s){!f.isUndefined(e)&&f.isUndefined(e["Content-Type"])&&(e["Content-Type"]=s)}function c(){var e;return(typeof u<"u"&&Object.prototype.toString.call(u)==="[object process]"||typeof XMLHttpRequest<"u")&&(e=t(55448)),e}var n={adapter:c(),transformRequest:[function(s,p){return a(p,"Accept"),a(p,"Content-Type"),f.isFormData(s)||f.isArrayBuffer(s)||f.isBuffer(s)||f.isStream(s)||f.isFile(s)||f.isBlob(s)?s:f.isArrayBufferView(s)?s.buffer:f.isURLSearchParams(s)?(o(p,"application/x-www-form-urlencoded;charset=utf-8"),s.toString()):f.isObject(s)?(o(p,"application/json;charset=utf-8"),JSON.stringify(s)):s}],transformResponse:[function(s){if(typeof s=="string")try{s=JSON.parse(s)}catch{}return s}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(s){return s>=200&&s<300}};n.headers={common:{Accept:"application/json, text/plain, */*"}},f.forEach(["delete","get","head"],function(s){n.headers[s]={}}),f.forEach(["post","put","patch"],function(s){n.headers[s]=f.merge(r)}),d.exports=n},91849:function(d){"use strict";d.exports=function(t,u){return function(){for(var a=new Array(arguments.length),r=0;r<a.length;r++)a[r]=arguments[r];return t.apply(u,a)}}},15327:function(d,m,t){"use strict";var u=t(64867);function f(a){return encodeURIComponent(a).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}d.exports=function(r,o,c){if(!o)return r;var n;if(c)n=c(o);else if(u.isURLSearchParams(o))n=o.toString();else{var e=[];u.forEach(o,function(v,h){v===null||typeof v>"u"||(u.isArray(v)?h=h+"[]":v=[v],u.forEach(v,function(l){u.isDate(l)?l=l.toISOString():u.isObject(l)&&(l=JSON.stringify(l)),e.push(f(h)+"="+f(l))}))}),n=e.join("&")}if(n){var s=r.indexOf("#");s!==-1&&(r=r.slice(0,s)),r+=(r.indexOf("?")===-1?"?":"&")+n}return r}},7303:function(d){"use strict";d.exports=function(t,u){return u?t.replace(/\/+$/,"")+"/"+u.replace(/^\/+/,""):t}},4372:function(d,m,t){"use strict";var u=t(64867);d.exports=u.isStandardBrowserEnv()?function(){return{write:function(r,o,c,n,e,s){var p=[];p.push(r+"="+encodeURIComponent(o)),u.isNumber(c)&&p.push("expires="+new Date(c).toGMTString()),u.isString(n)&&p.push("path="+n),u.isString(e)&&p.push("domain="+e),s===!0&&p.push("secure"),document.cookie=p.join("; ")},read:function(r){var o=document.cookie.match(new RegExp("(^|;\\s*)("+r+")=([^;]*)"));return o?decodeURIComponent(o[3]):null},remove:function(r){this.write(r,"",Date.now()-864e5)}}}():function(){return{write:function(){},read:function(){return null},remove:function(){}}}()},91793:function(d){"use strict";d.exports=function(t){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(t)}},67985:function(d,m,t){"use strict";var u=t(64867);d.exports=u.isStandardBrowserEnv()?function(){var a=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a"),o;function c(n){var e=n;return a&&(r.setAttribute("href",e),e=r.href),r.setAttribute("href",e),{href:r.href,protocol:r.protocol?r.protocol.replace(/:$/,""):"",host:r.host,search:r.search?r.search.replace(/^\?/,""):"",hash:r.hash?r.hash.replace(/^#/,""):"",hostname:r.hostname,port:r.port,pathname:r.pathname.charAt(0)==="/"?r.pathname:"/"+r.pathname}}return o=c(window.location.href),function(e){var s=u.isString(e)?c(e):e;return s.protocol===o.protocol&&s.host===o.host}}():function(){return function(){return!0}}()},16016:function(d,m,t){"use strict";var u=t(64867);d.exports=function(a,r){u.forEach(a,function(c,n){n!==r&&n.toUpperCase()===r.toUpperCase()&&(a[r]=c,delete a[n])})}},84109:function(d,m,t){"use strict";var u=t(64867),f=["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"];d.exports=function(r){var o={},c,n,e;return r&&u.forEach(r.split(`
|
|
2
|
+
`),function(p){if(e=p.indexOf(":"),c=u.trim(p.substr(0,e)).toLowerCase(),n=u.trim(p.substr(e+1)),c){if(o[c]&&f.indexOf(c)>=0)return;c==="set-cookie"?o[c]=(o[c]?o[c]:[]).concat([n]):o[c]=o[c]?o[c]+", "+n:n}}),o}},8713:function(d){"use strict";d.exports=function(t){return function(f){return t.apply(null,f)}}},64867:function(d,m,t){"use strict";var u=t(91849),f=t(48738),a=Object.prototype.toString;function r(i){return a.call(i)==="[object Array]"}function o(i){return a.call(i)==="[object ArrayBuffer]"}function c(i){return typeof FormData<"u"&&i instanceof FormData}function n(i){var w;return typeof ArrayBuffer<"u"&&ArrayBuffer.isView?w=ArrayBuffer.isView(i):w=i&&i.buffer&&i.buffer instanceof ArrayBuffer,w}function e(i){return typeof i=="string"}function s(i){return typeof i=="number"}function p(i){return typeof i>"u"}function v(i){return i!==null&&typeof i=="object"}function h(i){return a.call(i)==="[object Date]"}function S(i){return a.call(i)==="[object File]"}function l(i){return a.call(i)==="[object Blob]"}function U(i){return a.call(i)==="[object Function]"}function T(i){return v(i)&&U(i.pipe)}function B(i){return typeof URLSearchParams<"u"&&i instanceof URLSearchParams}function g(i){return i.replace(/^\s*/,"").replace(/\s*$/,"")}function C(){return typeof navigator<"u"&&(navigator.product==="ReactNative"||navigator.product==="NativeScript"||navigator.product==="NS")?!1:typeof window<"u"&&typeof document<"u"}function R(i,w){if(!(i===null||typeof i>"u"))if(typeof i!="object"&&(i=[i]),r(i))for(var y=0,b=i.length;y<b;y++)w.call(null,i[y],y,i);else for(var x in i)Object.prototype.hasOwnProperty.call(i,x)&&w.call(null,i[x],x,i)}function A(){var i={};function w(x,E){typeof i[E]=="object"&&typeof x=="object"?i[E]=A(i[E],x):i[E]=x}for(var y=0,b=arguments.length;y<b;y++)R(arguments[y],w);return i}function N(){var i={};function w(x,E){typeof i[E]=="object"&&typeof x=="object"?i[E]=N(i[E],x):typeof x=="object"?i[E]=N({},x):i[E]=x}for(var y=0,b=arguments.length;y<b;y++)R(arguments[y],w);return i}function L(i,w,y){return R(w,function(x,E){y&&typeof x=="function"?i[E]=u(x,y):i[E]=x}),i}d.exports={isArray:r,isArrayBuffer:o,isBuffer:f,isFormData:c,isArrayBufferView:n,isString:e,isNumber:s,isObject:v,isUndefined:p,isDate:h,isFile:S,isBlob:l,isFunction:U,isStream:T,isURLSearchParams:B,isStandardBrowserEnv:C,forEach:R,merge:A,deepMerge:N,extend:L,trim:g}},48738:function(d){/*!
|
|
3
|
+
* Determine if an object is a Buffer
|
|
4
|
+
*
|
|
5
|
+
* @author Feross Aboukhadijeh <https://feross.org>
|
|
6
|
+
* @license MIT
|
|
7
|
+
*/d.exports=function(t){return t!=null&&t.constructor!=null&&typeof t.constructor.isBuffer=="function"&&t.constructor.isBuffer(t)}}}]);
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[741],{37011:function(de,_,m){"use strict";m.r(_),m.d(_,{AlgorandTools:function(){return ie},makeCurrencyEngine:function(){return Pe},makeCurrencyTools:function(){return Se}});var k=m(88814),p=m(77591),V=m(20918),$=m(79014),P=m(76714),e=m(82448),Z=m(62177);const z=(0,e.su)({latestRound:(0,e.Vk)(e.mH,0),latestTxid:(0,e.Vk)(e.XC,"")}),q=(0,e.su)({amount:e.mH,assets:(0,e._2)((0,e.su)({amount:e.mH,"asset-id":e.mH})),"min-balance":e.mH,round:e.mH}),J=(0,e.su)({"confirmed-round":e.mH,fee:e.mH,"first-valid":e.mH,id:e.XC,note:(0,e.Zz)(e.XC),"round-time":e.mH,sender:e.XC,"tx-type":e.XC}).withRest,K=(0,e.Wf)("pay"),G=(0,e.su)({"payment-transaction":(0,e.su)({amount:e.mH,"close-amount":e.mH,receiver:e.XC}),"tx-type":K}),Y=(0,e.Wf)("axfer"),ee=(0,e.su)({"asset-transfer-transaction":(0,e.su)({amount:e.mH,"asset-id":e.mH,receiver:e.XC}),"tx-type":Y}),h=(0,e.su)({"confirmed-round":e.mH,fee:e.mH,"first-valid":e.mH,note:(0,e.Zz)(e.XC),"round-time":e.mH,sender:e.XC,"tx-type":e.XC}).withRest,w=(0,e.Wf)("appl"),T=(0,e.su)({"inner-txns":(0,e.Zz)((0,e._2)(h)),"tx-type":w}).withRest,C=(0,e.su)({"current-round":e.mH,"next-token":(0,e.Zz)(e.XC),transactions:(0,e._2)(J)}),L=(0,e.su)({flatFee:e.jK,fee:e.mH,firstRound:e.mH,lastRound:e.mH,genesisID:e.XC,genesisHash:e.XC}),g=(0,e.su)({type:e.XC}).withRest,F=(0,e.su)({encodedTx:e.XC,recipient:(0,e.Zz)(e.XC)}),he=(0,e.su)({type:K,to:e.XC,amount:e.mH}).withRest,b=(0,e.Vk)((0,e.su)({fee:(0,e.Zz)(e.XC)}),{fee:void 0}),X=(0,e.Vk)((0,e.su)({contractAddress:Z.jD})),W=Z.BQ,R=y=>{const t=(0,e.su)({[`${y}Mnemonic`]:e.XC});return(0,e.W1)(n=>({mnemonic:t(n)[`${y}Mnemonic`]}),n=>({[`${y}Mnemonic`]:n.mnemonic}))},N=(0,e.su)({id:(0,e._C)(e.XC,e.mH),method:(0,e.Wf)("algo_signTxn"),params:(0,e.vq)((0,e.vq)((0,e.su)({txn:e.XC,message:(0,e.Zz)(e.XC)})))}),Q=(0,e.su)({id:e.mH,jsonrpc:(0,e.Wf)("2.0"),method:(0,e.Wf)("algo_signTxn"),params:(0,e.vq)((0,e._2)((0,e.su)({txn:e.XC,message:(0,e.Zz)(e.XC)})))}).withRest;var M=m(94935),H=m(35620),fe=m(84650),ye=m(48764).Buffer,me=Object.defineProperty,pe=Object.defineProperties,ge=Object.getOwnPropertyDescriptors,re=Object.getOwnPropertySymbols,we=Object.getPrototypeOf,Te=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable,ve=Reflect.get,se=(y,t,n)=>t in y?me(y,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):y[t]=n,j=(y,t)=>{for(var n in t||(t={}))Te.call(t,n)&&se(y,n,t[n]);if(re)for(var n of re(t))Ie.call(t,n)&&se(y,n,t[n]);return y},ke=(y,t)=>pe(y,ge(t)),Ce=(y,t,n)=>ve(we(y),n,t),f=(y,t,n)=>new Promise((s,i)=>{var o=r=>{try{l(n.next(r))}catch(c){i(c)}},a=r=>{try{l(n.throw(r))}catch(c){i(c)}},l=r=>r.done?s(r.value):Promise.resolve(r.value).then(o,a);l((n=n.apply(y,t)).next())});const{Algodv2:te,Indexer:xe}=k.ZP,oe=5e3,Ae=3e3;class ne extends fe.P{constructor(t,n,s,i){super(t,n,s,i),this.getRecipientBalance=o=>f(this,null,function*(){try{return(yield this.fetchAccountInfo(o)).amount.toString()}catch{return this.minimumAddressBalance}}),this.engineGetActivationAssets=o=>f(this,null,function*(){return{assetOptions:[{paymentWalletId:this.walletId,currencyPluginId:this.currencyInfo.pluginId}]}}),this.engineActivateWallet=o=>f(this,[o],function*({activateTokenIds:a,paymentTokenId:l,paymentWallet:r}){var c;if(a==null)throw new Error(`Must specify activateTokenIds for ${this.currencyInfo.currencyCode}`);if(l!=null)throw new Error(`Must activate with ${this.currencyInfo.currencyCode}`);if((r==null?void 0:r.id)!==this.walletId)throw new Error("Must pay with same wallet you are activating token with");const d=this.networkInfo.minimumTxFee.toFixed();let u="0";const v=[];for(const O of a){if(this.allTokensMap[O]==null)throw new Error(`Invalid tokenId to activate ${O}`);const x={currencyCode:this.allTokensMap[O].currencyCode,skipChecks:!0,spendTargets:[{publicAddress:this.walletInfo.keys.publicKey,nativeAmount:"0"}]};try{const I=yield this.makeSpend(x);u=(0,p.add)(u,(c=I.parentNetworkFee)!=null?c:d)}catch{u=(0,p.add)(u,d)}v.push(x)}return{paymentWalletId:this.walletId,fromNativeAmount:"0",networkFee:{nativeAmount:u,currencyPluginId:this.currencyInfo.pluginId},approve:(...O)=>f(this,[...O],function*(x={}){const{metadata:I}=x,A=[];for(const B of v){const U=yield this.makeSpend(B);U.metadata=j({},I);let S=yield r.signTx(U);S=yield r.broadcastTx(S),A.push(S),yield r.saveTx(S)}return{transactions:A}}),close:()=>f(this,null,function*(){})}}),this.networkInfo=t.networkInfo,this.queryTxMutex=(0,P.jT)(),this.suggestedTransactionParams={flatFee:!1,fee:0,firstRound:0,lastRound:0,genesisID:this.networkInfo.genesisID,genesisHash:this.networkInfo.genesisHash},this.minimumAddressBalance=this.networkInfo.minimumAddressBalance,this.totalReserve=this.minimumAddressBalance,this.otherMethods={parseWalletConnectV2Payload:o=>f(this,null,function*(){try{const l=Q(o).params[0][0],r=(0,k.wj)(H.US.parse(l.txn)),c=r.amount!=null?r.amount.toString():"0",d=r.fee.toFixed();let u;if(r.type==="axfer"){const v=r.assetIndex.toString();if(this.allTokensMap[v]==null)throw new Error("Unrecognized token");u=v}return{nativeAmount:c,networkFee:d,tokenId:u}}catch(a){throw this.warn("Wallet connect call_request ",a),a}})}}setOtherData(t){this.otherData=z(t)}fetchAccountInfo(t){return f(this,null,function*(){return yield(0,P.QJ)(this.networkInfo.algodServers.map(n=>()=>f(this,null,function*(){const i=yield new te("",n,"").accountInformation(t).do();return q(i)})))})}queryBalance(){return f(this,null,function*(){try{const t=yield this.fetchAccountInfo(this.walletLocalData.publicKey),{assets:n,amount:s,"min-balance":i,round:o}=t;this.totalReserve=i.toString();const a=[];for(const l of this.enabledTokens)if(l===this.currencyInfo.currencyCode)this.updateBalance(this.currencyInfo.currencyCode,s.toString());else{const r=Object.keys(this.allTokensMap).find(d=>this.allTokensMap[d].currencyCode===l);if(r==null){this.updateBalance(l,"0");continue}const c=n.find(d=>d["asset-id"].toFixed()===r);if(c==null){a.push(r),this.updateBalance(l,"0");continue}this.updateBalance(l,c.amount.toString())}o>this.walletLocalData.blockHeight&&(this.walletLocalData.blockHeight=o,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight)),(0,P.dQ)(a,this.walletLocalData.unactivatedTokenIds)||(this.walletLocalData.unactivatedTokenIds=a,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onUnactivatedTokenIdsChanged(this.walletLocalData.unactivatedTokenIds))}catch(t){this.log.warn("queryBalance Error ",t)}})}queryTransactionParams(){return f(this,null,function*(){try{const t=yield(0,P.QJ)(this.networkInfo.algodServers.map(n=>()=>f(this,null,function*(){const i=yield new te("",n,"").getTransactionParams().do(),o=L(i);if(o.genesisHash!==this.networkInfo.genesisHash)throw new Error("Server genesisHash mismatch");return o})));this.suggestedTransactionParams=t}catch(t){this.log.warn("queryTransactionParams error:",t)}})}processAlgorandTransaction(t){const{fee:n,"confirmed-round":s,id:i,"round-time":o,sender:a,"tx-type":l}=t;let r,c,d,u,v=!1;const E=[];switch(l){case"pay":{const{amount:x,receiver:I}=G(t)["payment-transaction"];if(c=x.toString(),d=n.toString(),a===this.walletInfo.keys.publicKey)c=`-${(0,p.add)(c,d)}`,v=!0;else if(I===this.walletInfo.keys.publicKey)d="0",E.push(this.walletInfo.keys.publicKey);else return;r=this.currencyInfo.currencyCode;break}case"axfer":{const{amount:x,"asset-id":I,receiver:A}=ee(t)["asset-transfer-transaction"];if(c=x.toString(),d="0",a===this.walletInfo.keys.publicKey)c=`-${c}`,u=n.toString(),v=!0;else if(A===this.walletInfo.keys.publicKey)E.push(this.walletInfo.keys.publicKey);else return;const B=this.allTokensMap[I];if(B==null)return;r=B.currencyCode;break}case"appl":{const{"inner-txns":x=[]}=T(t);if(x.forEach(I=>this.processAlgorandTransaction(ke(j({},I),{id:i}))),c="0",d=n.toString(),a===this.walletInfo.keys.publicKey)c=`-${(0,p.add)(c,d)}`,v=!0;else return;r=this.currencyInfo.currencyCode;break}default:return}const O={txid:i,date:o,currencyCode:r,blockHeight:s,nativeAmount:c,isSend:v,networkFee:d,ourReceiveAddresses:E,parentNetworkFee:u,signedTx:"",walletId:this.walletId};this.addTransaction(this.currencyInfo.currencyCode,O)}queryTransactions(){return f(this,null,function*(){return yield this.queryTxMutex(()=>f(this,null,function*(){return yield this.queryTransactionsInner()}))})}queryTransactionsInner(){return f(this,null,function*(){const t=this.otherData.latestRound;let n,s=this.otherData.latestRound,i=0,o,a=!0;do{const l=yield(0,P.QJ)(this.networkInfo.indexerServers.map(u=>()=>f(this,null,function*(){const E=yield new xe({},u,"").lookupAccountTransactions(this.walletLocalData.publicKey).minRound(t).nextToken(o!=null?o:"").do();return C(E)}))),{"next-token":r,transactions:c}=l;if(c.length===0)break;for(const u of c){if(n==null&&(n=u.id,s=u["confirmed-round"]),i=u["confirmed-round"],u.id===this.otherData.latestTxid){a=!1;break}try{this.processAlgorandTransaction(u)}catch(v){this.log.warn("processAlgorandTransaction error:",v)}}s=s!=null?s:this.walletLocalData.blockHeight;const d=(s-i)/(s-t);this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=d,this.updateOnAddressesChecked(),o=r}while(o!=null&&a);n!=null&&this.otherData.latestTxid!==n&&(this.otherData.latestTxid=n,this.otherData.latestRound=s,this.walletLocalDataDirty=!0);for(const l of this.enabledTokens)this.tokenCheckTransactionsStatus[l]=1;this.updateOnAddressesChecked(),this.transactionsChangedArray.length>0&&(this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[])})}startEngine(){return f(this,null,function*(){this.engineOn=!0,this.addToLoop("queryBalance",oe).catch(()=>{}),this.addToLoop("queryTransactionParams",oe).catch(()=>{}),this.addToLoop("queryTransactions",Ae).catch(()=>{}),yield Ce(ne.prototype,this,"startEngine").call(this)})}resyncBlockchain(){return f(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}calcFee(t){const n=t.estimateSize();return Math.max(this.suggestedTransactionParams.fee*n,this.networkInfo.minimumTxFee).toString()}getMaxSpendable(t){return f(this,null,function*(){let n=this.getBalance({currencyCode:t.currencyCode});if(t.currencyCode===this.currencyInfo.currencyCode&&(n=(0,p.sub)(n,this.totalReserve)),t.spendTargets[0].publicAddress==null)throw new Error("makeSpend Missing publicAddress");const{customNetworkFee:i}=t;let a=b(i).fee;a==null&&(t.spendTargets[0].nativeAmount="1",a=(yield this.makeSpend(t)).networkFee);const l=(r,c)=>f(this,null,function*(){const d=(0,p.sub)(c,r);if((0,p.lte)(d,"1"))return r;const u=(0,p.add)(r,(0,p.div)(d,"2"));t.spendTargets[0].nativeAmount=u;const v=(0,p.add)(u,a!=null?a:this.networkInfo.minimumTxFee.toString());return(0,p.gt)(v,n)?yield l(r,u):yield l(u,c)});return yield l("0",(0,p.add)(n,"1"))})}makeSpend(t){return f(this,null,function*(){var n,s,i;const{edgeSpendInfo:o,currencyCode:a,nativeBalance:l}=this.makeSpendCheck(t),r=(0,p.sub)(this.getBalance({currencyCode:this.currencyInfo.currencyCode}),this.totalReserve);if(o.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{nativeAmount:c,memo:d,publicAddress:u}=o.spendTargets[0];if(u==null)throw new Error("makeSpend Missing publicAddress");if(c==null)throw new M.$D;const{type:v}=(n=(0,e.Vk)(g)(o.otherParams))!=null?n:{type:a===this.currencyInfo.currencyCode?"pay":"axfer"};let E;d!=null&&(E=Uint8Array.from(ye.from(d,"ascii")));const{customNetworkFee:O}=o,x=b(O).fee;let I,A=c,B="0",U,S,ce;switch(v){case"pay":{if(I=k.ZP.makePaymentTxnWithSuggestedParamsFromObject({to:u,from:this.walletInfo.keys.publicKey,amount:BigInt(c),note:E,suggestedParams:j({},this.suggestedTransactionParams)}),S=x!=null?x:this.calcFee(I),B=S,A=`-${(0,p.add)(A,B)}`,ce=u,(0,p.gt)((0,p.abs)(A),r))throw new M.C_;break}case"axfer":{const le=Object.keys(this.allTokensMap).find(De=>this.allTokensMap[De].currencyCode===a);if(le==null)throw new Error("Unrecognized asset");const ue=X((i=(s=this.allTokensMap)==null?void 0:s[le])==null?void 0:i.networkLocation);if(ue==null)throw new Error("Unrecognized asset");if(I=k.ZP.makeAssetTransferTxnWithSuggestedParamsFromObject({assetIndex:parseInt(ue.contractAddress),to:u,from:this.walletInfo.keys.publicKey,amount:BigInt(c),note:E,suggestedParams:j({},this.suggestedTransactionParams)}),S=x!=null?x:this.calcFee(I),A=`-${A}`,U=S,(0,p.gt)(U,r))throw new M.C_({currencyCode:this.currencyInfo.currencyCode,networkFee:S});if((0,p.gt)((0,p.abs)(A),l))throw new M.C_;break}default:throw new Error("Unrecognized transaction type")}I.flatFee=!0,I.fee=parseInt(S);const Oe={encodedTx:H.YU.stringify((0,k.nJ)(I)),recipient:ce};return{txid:"",date:0,currencyCode:a,blockHeight:0,nativeAmount:A,isSend:!0,networkFee:B,ourReceiveAddresses:[],parentNetworkFee:U,signedTx:"",otherParams:Oe,walletId:this.walletId}})}signMessage(t,n){return f(this,null,function*(){const s=R(this.currencyInfo.pluginId)(n),i=(0,k.wj)(H.US.parse(t)),o=k.ZP.mnemonicToSecretKey(s.mnemonic),a=i.signTxn(o.sk);return H.US.stringify(a)})}signTx(t,n){return f(this,null,function*(){const{encodedTx:s,recipient:i}=F((0,P.Xp)(t)),o=(0,k.wj)(Uint8Array.from(H.YU.parse(s)));i!=null&&(yield this.checkRecipientMinimumBalance(this.getRecipientBalance,o.amount.toString(),i));const a=R(this.currencyInfo.pluginId)(n),l=k.ZP.mnemonicToSecretKey(a.mnemonic),r=o.signTxn(l.sk),c=H.YU.stringify(r);return t.signedTx=c,t})}broadcastTx(t){return f(this,null,function*(){const n=Uint8Array.from(H.YU.parse(t.signedTx));try{const{txId:s}=yield(0,P.QJ)(this.networkInfo.algodServers.map(i=>()=>f(this,null,function*(){return yield new te("",i,"").sendRawTransaction(n).do()})));t.txid=s,t.date=Date.now()/1e3}catch(s){throw this.warn("FAILURE broadcastTx failed: ",s),s}return this.warn(`SUCCESS broadcastTx
|
|
1
|
+
(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[7741],{37011:function(de,_,m){"use strict";m.r(_),m.d(_,{AlgorandTools:function(){return ie},makeCurrencyEngine:function(){return Pe},makeCurrencyTools:function(){return Se}});var k=m(88814),p=m(77591),V=m(20918),$=m(79014),P=m(76714),e=m(82448),Z=m(62177);const z=(0,e.su)({latestRound:(0,e.Vk)(e.mH,0),latestTxid:(0,e.Vk)(e.XC,"")}),q=(0,e.su)({amount:e.mH,assets:(0,e._2)((0,e.su)({amount:e.mH,"asset-id":e.mH})),"min-balance":e.mH,round:e.mH}),J=(0,e.su)({"confirmed-round":e.mH,fee:e.mH,"first-valid":e.mH,id:e.XC,note:(0,e.Zz)(e.XC),"round-time":e.mH,sender:e.XC,"tx-type":e.XC}).withRest,K=(0,e.Wf)("pay"),G=(0,e.su)({"payment-transaction":(0,e.su)({amount:e.mH,"close-amount":e.mH,receiver:e.XC}),"tx-type":K}),Y=(0,e.Wf)("axfer"),ee=(0,e.su)({"asset-transfer-transaction":(0,e.su)({amount:e.mH,"asset-id":e.mH,receiver:e.XC}),"tx-type":Y}),h=(0,e.su)({"confirmed-round":e.mH,fee:e.mH,"first-valid":e.mH,note:(0,e.Zz)(e.XC),"round-time":e.mH,sender:e.XC,"tx-type":e.XC}).withRest,w=(0,e.Wf)("appl"),T=(0,e.su)({"inner-txns":(0,e.Zz)((0,e._2)(h)),"tx-type":w}).withRest,C=(0,e.su)({"current-round":e.mH,"next-token":(0,e.Zz)(e.XC),transactions:(0,e._2)(J)}),L=(0,e.su)({flatFee:e.jK,fee:e.mH,firstRound:e.mH,lastRound:e.mH,genesisID:e.XC,genesisHash:e.XC}),g=(0,e.su)({type:e.XC}).withRest,F=(0,e.su)({encodedTx:e.XC,recipient:(0,e.Zz)(e.XC)}),he=(0,e.su)({type:K,to:e.XC,amount:e.mH}).withRest,b=(0,e.Vk)((0,e.su)({fee:(0,e.Zz)(e.XC)}),{fee:void 0}),X=(0,e.Vk)((0,e.su)({contractAddress:Z.jD})),W=Z.BQ,R=y=>{const t=(0,e.su)({[`${y}Mnemonic`]:e.XC});return(0,e.W1)(n=>({mnemonic:t(n)[`${y}Mnemonic`]}),n=>({[`${y}Mnemonic`]:n.mnemonic}))},N=(0,e.su)({id:(0,e._C)(e.XC,e.mH),method:(0,e.Wf)("algo_signTxn"),params:(0,e.vq)((0,e.vq)((0,e.su)({txn:e.XC,message:(0,e.Zz)(e.XC)})))}),Q=(0,e.su)({id:e.mH,jsonrpc:(0,e.Wf)("2.0"),method:(0,e.Wf)("algo_signTxn"),params:(0,e.vq)((0,e._2)((0,e.su)({txn:e.XC,message:(0,e.Zz)(e.XC)})))}).withRest;var M=m(94935),H=m(35620),fe=m(84650),ye=m(48764).Buffer,me=Object.defineProperty,pe=Object.defineProperties,ge=Object.getOwnPropertyDescriptors,re=Object.getOwnPropertySymbols,we=Object.getPrototypeOf,Te=Object.prototype.hasOwnProperty,Ie=Object.prototype.propertyIsEnumerable,ve=Reflect.get,se=(y,t,n)=>t in y?me(y,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):y[t]=n,j=(y,t)=>{for(var n in t||(t={}))Te.call(t,n)&&se(y,n,t[n]);if(re)for(var n of re(t))Ie.call(t,n)&&se(y,n,t[n]);return y},ke=(y,t)=>pe(y,ge(t)),Ce=(y,t,n)=>ve(we(y),n,t),f=(y,t,n)=>new Promise((s,i)=>{var o=r=>{try{l(n.next(r))}catch(c){i(c)}},a=r=>{try{l(n.throw(r))}catch(c){i(c)}},l=r=>r.done?s(r.value):Promise.resolve(r.value).then(o,a);l((n=n.apply(y,t)).next())});const{Algodv2:te,Indexer:xe}=k.ZP,oe=5e3,Ae=3e3;class ne extends fe.P{constructor(t,n,s,i){super(t,n,s,i),this.getRecipientBalance=o=>f(this,null,function*(){try{return(yield this.fetchAccountInfo(o)).amount.toString()}catch{return this.minimumAddressBalance}}),this.engineGetActivationAssets=o=>f(this,null,function*(){return{assetOptions:[{paymentWalletId:this.walletId,currencyPluginId:this.currencyInfo.pluginId}]}}),this.engineActivateWallet=o=>f(this,[o],function*({activateTokenIds:a,paymentTokenId:l,paymentWallet:r}){var c;if(a==null)throw new Error(`Must specify activateTokenIds for ${this.currencyInfo.currencyCode}`);if(l!=null)throw new Error(`Must activate with ${this.currencyInfo.currencyCode}`);if((r==null?void 0:r.id)!==this.walletId)throw new Error("Must pay with same wallet you are activating token with");const d=this.networkInfo.minimumTxFee.toFixed();let u="0";const v=[];for(const O of a){if(this.allTokensMap[O]==null)throw new Error(`Invalid tokenId to activate ${O}`);const x={currencyCode:this.allTokensMap[O].currencyCode,skipChecks:!0,spendTargets:[{publicAddress:this.walletInfo.keys.publicKey,nativeAmount:"0"}]};try{const I=yield this.makeSpend(x);u=(0,p.add)(u,(c=I.parentNetworkFee)!=null?c:d)}catch{u=(0,p.add)(u,d)}v.push(x)}return{paymentWalletId:this.walletId,fromNativeAmount:"0",networkFee:{nativeAmount:u,currencyPluginId:this.currencyInfo.pluginId},approve:(...O)=>f(this,[...O],function*(x={}){const{metadata:I}=x,A=[];for(const B of v){const U=yield this.makeSpend(B);U.metadata=j({},I);let S=yield r.signTx(U);S=yield r.broadcastTx(S),A.push(S),yield r.saveTx(S)}return{transactions:A}}),close:()=>f(this,null,function*(){})}}),this.networkInfo=t.networkInfo,this.queryTxMutex=(0,P.jT)(),this.suggestedTransactionParams={flatFee:!1,fee:0,firstRound:0,lastRound:0,genesisID:this.networkInfo.genesisID,genesisHash:this.networkInfo.genesisHash},this.minimumAddressBalance=this.networkInfo.minimumAddressBalance,this.totalReserve=this.minimumAddressBalance,this.otherMethods={parseWalletConnectV2Payload:o=>f(this,null,function*(){try{const l=Q(o).params[0][0],r=(0,k.wj)(H.US.parse(l.txn)),c=r.amount!=null?r.amount.toString():"0",d=r.fee.toFixed();let u;if(r.type==="axfer"){const v=r.assetIndex.toString();if(this.allTokensMap[v]==null)throw new Error("Unrecognized token");u=v}return{nativeAmount:c,networkFee:d,tokenId:u}}catch(a){throw this.warn("Wallet connect call_request ",a),a}})}}setOtherData(t){this.otherData=z(t)}fetchAccountInfo(t){return f(this,null,function*(){return yield(0,P.QJ)(this.networkInfo.algodServers.map(n=>()=>f(this,null,function*(){const i=yield new te("",n,"").accountInformation(t).do();return q(i)})))})}queryBalance(){return f(this,null,function*(){try{const t=yield this.fetchAccountInfo(this.walletLocalData.publicKey),{assets:n,amount:s,"min-balance":i,round:o}=t;this.totalReserve=i.toString();const a=[];for(const l of this.enabledTokens)if(l===this.currencyInfo.currencyCode)this.updateBalance(this.currencyInfo.currencyCode,s.toString());else{const r=Object.keys(this.allTokensMap).find(d=>this.allTokensMap[d].currencyCode===l);if(r==null){this.updateBalance(l,"0");continue}const c=n.find(d=>d["asset-id"].toFixed()===r);if(c==null){a.push(r),this.updateBalance(l,"0");continue}this.updateBalance(l,c.amount.toString())}o>this.walletLocalData.blockHeight&&(this.walletLocalData.blockHeight=o,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight)),(0,P.dQ)(a,this.walletLocalData.unactivatedTokenIds)||(this.walletLocalData.unactivatedTokenIds=a,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onUnactivatedTokenIdsChanged(this.walletLocalData.unactivatedTokenIds))}catch(t){this.log.warn("queryBalance Error ",t)}})}queryTransactionParams(){return f(this,null,function*(){try{const t=yield(0,P.QJ)(this.networkInfo.algodServers.map(n=>()=>f(this,null,function*(){const i=yield new te("",n,"").getTransactionParams().do(),o=L(i);if(o.genesisHash!==this.networkInfo.genesisHash)throw new Error("Server genesisHash mismatch");return o})));this.suggestedTransactionParams=t}catch(t){this.log.warn("queryTransactionParams error:",t)}})}processAlgorandTransaction(t){const{fee:n,"confirmed-round":s,id:i,"round-time":o,sender:a,"tx-type":l}=t;let r,c,d,u,v=!1;const E=[];switch(l){case"pay":{const{amount:x,receiver:I}=G(t)["payment-transaction"];if(c=x.toString(),d=n.toString(),a===this.walletInfo.keys.publicKey)c=`-${(0,p.add)(c,d)}`,v=!0;else if(I===this.walletInfo.keys.publicKey)d="0",E.push(this.walletInfo.keys.publicKey);else return;r=this.currencyInfo.currencyCode;break}case"axfer":{const{amount:x,"asset-id":I,receiver:A}=ee(t)["asset-transfer-transaction"];if(c=x.toString(),d="0",a===this.walletInfo.keys.publicKey)c=`-${c}`,u=n.toString(),v=!0;else if(A===this.walletInfo.keys.publicKey)E.push(this.walletInfo.keys.publicKey);else return;const B=this.allTokensMap[I];if(B==null)return;r=B.currencyCode;break}case"appl":{const{"inner-txns":x=[]}=T(t);if(x.forEach(I=>this.processAlgorandTransaction(ke(j({},I),{id:i}))),c="0",d=n.toString(),a===this.walletInfo.keys.publicKey)c=`-${(0,p.add)(c,d)}`,v=!0;else return;r=this.currencyInfo.currencyCode;break}default:return}const O={txid:i,date:o,currencyCode:r,blockHeight:s,nativeAmount:c,isSend:v,networkFee:d,ourReceiveAddresses:E,parentNetworkFee:u,signedTx:"",walletId:this.walletId};this.addTransaction(this.currencyInfo.currencyCode,O)}queryTransactions(){return f(this,null,function*(){return yield this.queryTxMutex(()=>f(this,null,function*(){return yield this.queryTransactionsInner()}))})}queryTransactionsInner(){return f(this,null,function*(){const t=this.otherData.latestRound;let n,s=this.otherData.latestRound,i=0,o,a=!0;do{const l=yield(0,P.QJ)(this.networkInfo.indexerServers.map(u=>()=>f(this,null,function*(){const E=yield new xe({},u,"").lookupAccountTransactions(this.walletLocalData.publicKey).minRound(t).nextToken(o!=null?o:"").do();return C(E)}))),{"next-token":r,transactions:c}=l;if(c.length===0)break;for(const u of c){if(n==null&&(n=u.id,s=u["confirmed-round"]),i=u["confirmed-round"],u.id===this.otherData.latestTxid){a=!1;break}try{this.processAlgorandTransaction(u)}catch(v){this.log.warn("processAlgorandTransaction error:",v)}}s=s!=null?s:this.walletLocalData.blockHeight;const d=(s-i)/(s-t);this.tokenCheckTransactionsStatus[this.currencyInfo.currencyCode]=d,this.updateOnAddressesChecked(),o=r}while(o!=null&&a);n!=null&&this.otherData.latestTxid!==n&&(this.otherData.latestTxid=n,this.otherData.latestRound=s,this.walletLocalDataDirty=!0);for(const l of this.enabledTokens)this.tokenCheckTransactionsStatus[l]=1;this.updateOnAddressesChecked(),this.transactionsChangedArray.length>0&&(this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[])})}startEngine(){return f(this,null,function*(){this.engineOn=!0,this.addToLoop("queryBalance",oe).catch(()=>{}),this.addToLoop("queryTransactionParams",oe).catch(()=>{}),this.addToLoop("queryTransactions",Ae).catch(()=>{}),yield Ce(ne.prototype,this,"startEngine").call(this)})}resyncBlockchain(){return f(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}calcFee(t){const n=t.estimateSize();return Math.max(this.suggestedTransactionParams.fee*n,this.networkInfo.minimumTxFee).toString()}getMaxSpendable(t){return f(this,null,function*(){let n=this.getBalance({currencyCode:t.currencyCode});if(t.currencyCode===this.currencyInfo.currencyCode&&(n=(0,p.sub)(n,this.totalReserve)),t.spendTargets[0].publicAddress==null)throw new Error("makeSpend Missing publicAddress");const{customNetworkFee:i}=t;let a=b(i).fee;a==null&&(t.spendTargets[0].nativeAmount="1",a=(yield this.makeSpend(t)).networkFee);const l=(r,c)=>f(this,null,function*(){const d=(0,p.sub)(c,r);if((0,p.lte)(d,"1"))return r;const u=(0,p.add)(r,(0,p.div)(d,"2"));t.spendTargets[0].nativeAmount=u;const v=(0,p.add)(u,a!=null?a:this.networkInfo.minimumTxFee.toString());return(0,p.gt)(v,n)?yield l(r,u):yield l(u,c)});return yield l("0",(0,p.add)(n,"1"))})}makeSpend(t){return f(this,null,function*(){var n,s,i;const{edgeSpendInfo:o,currencyCode:a,nativeBalance:l}=this.makeSpendCheck(t),r=(0,p.sub)(this.getBalance({currencyCode:this.currencyInfo.currencyCode}),this.totalReserve);if(o.spendTargets.length!==1)throw new Error("Error: only one output allowed");const{nativeAmount:c,memo:d,publicAddress:u}=o.spendTargets[0];if(u==null)throw new Error("makeSpend Missing publicAddress");if(c==null)throw new M.$D;const{type:v}=(n=(0,e.Vk)(g)(o.otherParams))!=null?n:{type:a===this.currencyInfo.currencyCode?"pay":"axfer"};let E;d!=null&&(E=Uint8Array.from(ye.from(d,"ascii")));const{customNetworkFee:O}=o,x=b(O).fee;let I,A=c,B="0",U,S,ce;switch(v){case"pay":{if(I=k.ZP.makePaymentTxnWithSuggestedParamsFromObject({to:u,from:this.walletInfo.keys.publicKey,amount:BigInt(c),note:E,suggestedParams:j({},this.suggestedTransactionParams)}),S=x!=null?x:this.calcFee(I),B=S,A=`-${(0,p.add)(A,B)}`,ce=u,(0,p.gt)((0,p.abs)(A),r))throw new M.C_;break}case"axfer":{const le=Object.keys(this.allTokensMap).find(De=>this.allTokensMap[De].currencyCode===a);if(le==null)throw new Error("Unrecognized asset");const ue=X((i=(s=this.allTokensMap)==null?void 0:s[le])==null?void 0:i.networkLocation);if(ue==null)throw new Error("Unrecognized asset");if(I=k.ZP.makeAssetTransferTxnWithSuggestedParamsFromObject({assetIndex:parseInt(ue.contractAddress),to:u,from:this.walletInfo.keys.publicKey,amount:BigInt(c),note:E,suggestedParams:j({},this.suggestedTransactionParams)}),S=x!=null?x:this.calcFee(I),A=`-${A}`,U=S,(0,p.gt)(U,r))throw new M.C_({currencyCode:this.currencyInfo.currencyCode,networkFee:S});if((0,p.gt)((0,p.abs)(A),l))throw new M.C_;break}default:throw new Error("Unrecognized transaction type")}I.flatFee=!0,I.fee=parseInt(S);const Oe={encodedTx:H.YU.stringify((0,k.nJ)(I)),recipient:ce};return{txid:"",date:0,currencyCode:a,blockHeight:0,nativeAmount:A,isSend:!0,networkFee:B,ourReceiveAddresses:[],parentNetworkFee:U,signedTx:"",otherParams:Oe,walletId:this.walletId}})}signMessage(t,n){return f(this,null,function*(){const s=R(this.currencyInfo.pluginId)(n),i=(0,k.wj)(H.US.parse(t)),o=k.ZP.mnemonicToSecretKey(s.mnemonic),a=i.signTxn(o.sk);return H.US.stringify(a)})}signTx(t,n){return f(this,null,function*(){const{encodedTx:s,recipient:i}=F((0,P.Xp)(t)),o=(0,k.wj)(Uint8Array.from(H.YU.parse(s)));i!=null&&(yield this.checkRecipientMinimumBalance(this.getRecipientBalance,o.amount.toString(),i));const a=R(this.currencyInfo.pluginId)(n),l=k.ZP.mnemonicToSecretKey(a.mnemonic),r=o.signTxn(l.sk),c=H.YU.stringify(r);return t.signedTx=c,t})}broadcastTx(t){return f(this,null,function*(){const n=Uint8Array.from(H.YU.parse(t.signedTx));try{const{txId:s}=yield(0,P.QJ)(this.networkInfo.algodServers.map(i=>()=>f(this,null,function*(){return yield new te("",i,"").sendRawTransaction(n).do()})));t.txid=s,t.date=Date.now()/1e3}catch(s){throw this.warn("FAILURE broadcastTx failed: ",s),s}return this.warn(`SUCCESS broadcastTx
|
|
2
2
|
${(0,P.oX)(t)}`),t})}}function Pe(y,t,n,s){return f(this,null,function*(){const i=W(n),o=new ne(y,t,i,s);return yield o.loadEngine(),o})}var be=m(48764).Buffer,D=(y,t,n)=>new Promise((s,i)=>{var o=r=>{try{l(n.next(r))}catch(c){i(c)}},a=r=>{try{l(n.throw(r))}catch(c){i(c)}},l=r=>r.done?s(r.value):Promise.resolve(r.value).then(o,a);l((n=n.apply(y,t)).next())});const{isValidAddress:ae,mnemonicFromSeed:Ee}=k.ZP;class ie{constructor(t){const{builtinTokens:n,currencyInfo:s,io:i}=t;this.io=i,this.currencyInfo=s,this.builtinTokens=n}getDisplayPrivateKey(t){return D(this,null,function*(){const{pluginId:n}=this.currencyInfo;return R(n)(t.keys).mnemonic})}getDisplayPublicKey(t){return D(this,null,function*(){const{keys:n}=W(t);return n.publicKey})}importPrivateKey(t){return D(this,null,function*(){const{pluginId:n}=this.currencyInfo;return k.ZP.mnemonicToSecretKey(t),{[`${n}Mnemonic`]:t}})}createPrivateKey(t){return D(this,null,function*(){if(t!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const n=be.from(this.io.random(32)),s=Ee(n);return yield this.importPrivateKey(s)})}derivePublicKey(t){return D(this,null,function*(){const{pluginId:n}=this.currencyInfo;if(t.type!==this.currencyInfo.walletType)throw new Error("InvalidWalletType");const s=R(n)(t.keys);return{publicKey:k.ZP.mnemonicToSecretKey(s.mnemonic).addr}})}parseUri(t,n,s){return D(this,null,function*(){const{pluginId:i}=this.currencyInfo,o={[i]:!0},{parsedUri:a,edgeParsedUri:l}=(0,$.k)(this.currencyInfo,t,o,n!=null?n:this.currencyInfo.currencyCode,s);let r="";if(l.publicAddress!=null&&(r=l.publicAddress),!ae(r))throw new Error("InvalidPublicAddressError");return l.uniqueIdentifier=a.query.memo,l})}encodeUri(t){return D(this,arguments,function*(n,s=[]){const{pluginId:i}=this.currencyInfo,{nativeAmount:o,currencyCode:a,publicAddress:l}=n;if(!ae(l))throw new Error("InvalidPublicAddressError");let r;if(typeof o=="string"){const d=(0,P.Qs)(a!=null?a:this.currencyInfo.currencyCode,this.currencyInfo,s);if(d==null)throw new Error("InternalErrorInvalidCurrencyCode");r=(0,p.div)(o,d.multiplier,18)}return(0,$.Q)(n,i,r)})}getTokenId(t){return D(this,null,function*(){(0,V.Rp)(t);const n=X(t.networkLocation);if(n==null)throw new Error("ErrorInvalidContractAddress");return n.contractAddress})}}function Se(y){return D(this,null,function*(){return new ie(y)})}},79014:function(de,_,m){"use strict";m.d(_,{Q:function(){return ee},k:function(){return Y}});var k=m(77591),p=m.n(k),V=m(24350),$=m(84564),P=m.n($),e=m(76714),Z=Object.defineProperty,z=Object.getOwnPropertySymbols,q=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable,K=(h,w,T)=>w in h?Z(h,w,{enumerable:!0,configurable:!0,writable:!0,value:T}):h[w]=T,G=(h,w)=>{for(var T in w||(w={}))q.call(w,T)&&K(h,T,w[T]);if(z)for(var T of z(w))J.call(w,T)&&K(h,T,w[T]);return h};function Y(h,w,T,C,L=[]){const g=G({},P()(w,{},!0)),F=w.startsWith(`${h.pluginId}://`);if(g.protocol!=null&&(g.protocol=g.protocol.replace(":","")),g.protocol!=null&&g.protocol!==""&&!T[g.protocol])throw new Error(`Uri protocol '${g.protocol}' is not supported for ${h.pluginId}.`);if(g.host===""&&g.pathname==="")throw new Error("Path and host not found in uri.");const b={publicAddress:g.host!==""?g.host:g.pathname.split("/")[0]},X=g.query.label,W=g.query.message,R=g.query.category;(X!=null||W!=null||R!=null||F)&&(b.metadata={},b.metadata.name=X,b.metadata.notes=W,b.metadata.category=R,b.metadata.gateway=F!=null?F:!1);const N=g.query.amount;if(N!=null&&typeof N=="string"){C==null&&(C=h.currencyCode);const Q=(0,e.Qs)(C!=null?C:"",h,L);if(Q==null)throw new Error("InternalErrorInvalidCurrencyCode");let M=(0,k.mul)(N,Q.multiplier);M=(0,k.toFixed)(M,0,0),b.nativeAmount=M,b.currencyCode=C}return{edgeParsedUri:b,parsedUri:g}}function ee(h,w,T){if(h.publicAddress==null)throw new Error("InvalidPublicAddressError");if(T==null&&h.label==null&&h.message==null)return h.publicAddress;{let C="";T!=null&&(C+="amount="+T+"&"),(h.label!=null||h.message!=null)&&(typeof h.label=="string"&&(C+="label="+h.label+"&"),typeof h.message=="string"&&(C+="message="+h.message+"&")),C=C.substr(0,C.length-1);const L={scheme:w,path:h.publicAddress,query:C};return(0,V.qC)(L)}}},55024:function(){}}]);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[
|
|
1
|
+
(self.webpackChunkedge_currency_accountbased=self.webpackChunkedge_currency_accountbased||[]).push([[4026],{36048:function($){function E(u){var A=new Error("Cannot find module '"+u+"'");throw A.code="MODULE_NOT_FOUND",A}E.keys=function(){return[]},E.resolve=E,E.id=36048,$.exports=E},89662:function($,E,u){"use strict";u.r(E),u.d(E,{BinanceTools:function(){return Z},makeCurrencyEngine:function(){return Y},makeCurrencyTools:function(){return te}});var A=u(58298),g=u(77591),U=u(2153),R=u(48764),D=u(79014),y=u(76714),a=u(82448),B=u(62177);const H=(0,a.su)({sync_info:(0,a.su)({latest_block_height:a.mH})}),X=(0,a.su)({balances:(0,a._2)((0,a.su)({free:a.XC,frozen:a.XC,locked:a.XC,symbol:a.XC}))}),_=(0,a.su)({hash:a.XC,blockHeight:a.mH,blockTime:a.mH,type:a.XC,fee:a.mH,memo:a.XC,asset:a.XC,amount:a.mH,fromAddr:a.XC,toAddr:a.XC}),F=(0,a.su)({txs:(0,a._2)(_)}),V=(0,a.su)({binanceMnemonic:(0,a.Zz)(a.XC),publicKey:(0,a.Zz)(a.XC)}),x=(0,a.su)({result:(0,a._2)((0,a.su)({ok:a.jK,hash:(0,a.Zz)(a.XC)}))}),l=B.BQ,h=(0,a.su)({binanceKey:a.XC,binanceMnemonic:a.XC});var f=u(94935),m=u(84650),L=Object.getPrototypeOf,d=Reflect.get,O=(w,e,t)=>d(L(w),t,e),b=(w,e,t)=>new Promise((s,n)=>{var r=o=>{try{c(t.next(o))}catch(p){n(p)}},i=o=>{try{c(t.throw(o))}catch(p){n(p)}},c=o=>o.done?s(o.value):Promise.resolve(o.value).then(r,i);c((t=t.apply(w,e)).next())});const C=2e4,K=2e4,N=3e3,P=1e3*60*60*24,S=15555e8,M=1e3*60*60*24*5,k="7500";class W extends m.P{constructor(e,t,s,n,r){super(e,t,s,r),this.fetchCors=(0,y.zR)(e.io),this.networkInfo=e.networkInfo}setOtherData(e){this.otherData={}}fetchGet(e){return b(this,null,function*(){const t=yield this.fetchCors(e,{method:"GET"});if(!t.ok)throw new Error(`The server returned error code ${t.status} for ${e}`);return yield t.json()})}checkBlockchainInnerLoop(){return b(this,null,function*(){try{const e=yield this.multicastServers("bnb_blockNumber","/api/v1/node-info"),s=H(e).sync_info.latest_block_height;this.log(`Got block height ${s}`),this.walletLocalData.blockHeight!==s&&(this.checkDroppedTransactionsThrottled(),this.walletLocalData.blockHeight=s,this.walletLocalDataDirty=!0,this.currencyEngineCallbacks.onBlockHeightChanged(this.walletLocalData.blockHeight))}catch(e){this.error("Error fetching height: ",e.message)}})}checkAccountInnerLoop(){return b(this,null,function*(){const e=this.walletLocalData.publicKey;try{const t=yield this.multicastServers("bnb_getBalance",`/api/v1/account/${e}`),s=X(t);s.balances.length===0&&this.updateBalance("BNB","0");for(const n of this.enabledTokens)for(const r of s.balances)if(r.symbol===n){const i=(0,y.aL)(n,this.currencyInfo,this.allTokensMap);if(i==null){this.error(`checkAccountInnerLoop Received unsupported currencyCode: ${n}`);break}const c=(0,g.mul)(r.free,i.multiplier);this.updateBalance(n,c)}}catch(t){/error code 404/.test(t==null?void 0:t.message)?this.updateBalance("BNB","0"):this.error(`Error checking BNB address balance ${String(t)}`)}})}processBinanceApiTransaction(e,t){if(t!==e.asset||e.type!=="TRANSFER")return;let s;const n=[],r=String(e.fee),i=String(e.amount);e.fromAddr.toLowerCase()===this.walletLocalData.publicKey.toLowerCase()?e.fromAddr.toLowerCase()===e.toAddr.toLowerCase()?s=(0,g.mul)(r,"-1"):(s=(0,g.sub)("0",i),s=(0,g.sub)(s,r)):(s=(0,g.add)("0",i),n.push(this.walletLocalData.publicKey.toLowerCase()));let c=e.blockHeight;c<0&&(c=0);const o=new Date(e.blockTime).getTime()/1e3,p={txid:e.hash,date:o,currencyCode:t,blockHeight:c,nativeAmount:s,isSend:s.startsWith("-"),networkFee:r,ourReceiveAddresses:n,signedTx:"",metadata:{notes:e.memo},walletId:this.walletId};this.addTransaction(t,p)}checkTransactionsFetch(e,t){return b(this,null,function*(){const s=this.walletLocalData.publicKey;let n=e,r=0;const i=Date.now();try{for(;r!==i;){r=n+M,r>i&&(r=i);const o=`/bc/api/v1/txs?address=${s}`+`&startTime=${n}&endTime=${r}`,p=yield this.multicastServers("bnb_getTransactions",o),v=F(p);for(const I of v.txs)this.processBinanceApiTransaction(I,t);n=r}}catch(c){if(!(0,B.Tt)(c).message.includes("404"))return this.error(`Error checkTransactionsFetch ${t}: ${this.walletLocalData.publicKey}`,c),!1}return this.tokenCheckTransactionsStatus[t]=1,this.updateOnAddressesChecked(),!0})}checkTransactionsInnerLoop(){return b(this,null,function*(){const e=Date.now();let t=S;const s=[];this.walletLocalData.lastAddressQueryHeight>P&&(t=this.walletLocalData.lastAddressQueryHeight-P);for(const i of this.enabledTokens)s.push(this.checkTransactionsFetch(t,i));let n=[];try{n=yield Promise.all(s)}catch(i){this.error("Failed to query transactions ",i)}let r=0;for(const i of n)i&&r++;r===s.length&&(this.walletLocalData.lastAddressQueryHeight=e),this.transactionsChangedArray.length>0&&(this.currencyEngineCallbacks.onTransactionsChanged(this.transactionsChangedArray),this.transactionsChangedArray=[])})}multicastServers(e,...t){return b(this,null,function*(){let s={result:"",server:"no server"},n;switch(e){case"bnb_broadcastTx":{const r=[],i=this.networkInfo.binanceApiServers;for(const p of i){const v=`${p}/api/v1/broadcast?sync=true`;r.push(this.fetchCors(v,{method:"POST",body:t[0],headers:{"content-type":"text/plain"}}))}const o=yield(yield(0,y.Wp)(r)).json();if(o[0]&&o[0].ok&&o[0].code===0)return this.log(`multicastServers ${e} ${JSON.stringify(s)} won`),{result:o,server:"irrelevant"};throw new Error(`send fail with error: ${o.message}`)}case"bnb_blockNumber":case"bnb_getBalance":n=this.networkInfo.binanceApiServers.map(r=>()=>b(this,null,function*(){const i=t[0],c=yield this.fetchGet(r+i);if(typeof c!="object"){const o=`Invalid return value ${e} in ${r}`;throw this.error(o),new Error(o)}return{server:r,result:c}})),n=(0,y.Sy)(n),s=yield(0,y.QJ)(n);break;case"bnb_getTransactions":n=this.networkInfo.beaconChainApiServers.map(r=>()=>b(this,null,function*(){const i=t[0],c=yield this.fetchGet(r+i);if(typeof c!="object"){const o=`Invalid return value ${e} in ${r}`;throw this.error(o),new Error(o)}return{server:r,result:c}})),n=(0,y.Sy)(n),s=yield(0,y.QJ)(n);break}return this.log(`multicastServers ${e} ${s.server} won`),s.result})}startEngine(){return b(this,null,function*(){this.engineOn=!0,this.addToLoop("checkBlockchainInnerLoop",K).catch(()=>{}),this.addToLoop("checkAccountInnerLoop",C).catch(()=>{}),this.addToLoop("checkTransactionsInnerLoop",N).catch(()=>{}),yield O(W.prototype,this,"startEngine").call(this)})}resyncBlockchain(){return b(this,null,function*(){yield this.killEngine(),yield this.clearBlockchainCache(),yield this.startEngine()})}makeSpend(e){return b(this,null,function*(){var t,s;const{edgeSpendInfo:n,currencyCode:r}=this.makeSpendCheck(e),i=n.spendTargets[0],{publicAddress:c}=i;let{nativeAmount:o}=i;if(c==null)throw new Error("makeSpend Missing publicAddress");if(o==null)throw new f.$D;const p=i.otherParams!=null?i.otherParams.data:void 0,v={from:[this.walletLocalData.publicKey],to:[c],errorVal:0,tokenRecipientAddress:null,data:p};if(r!==this.currencyInfo.currencyCode)throw new Error("Binance Beacon Chain token transfers not supported");((t=n.spendTargets[0].otherParams)==null?void 0:t.uniqueIdentifier)!=null&&(v.memo=n.spendTargets[0].otherParams.uniqueIdentifier);const I=k,G=new Error("Insufficient BNB for transaction fee");G.name="ErrorInsufficientFundsMoreBnb";const z=(s=this.walletLocalData.totalBalances[this.currencyInfo.currencyCode])!=null?s:"0";let j="0";if(j=(0,g.add)(o,I),(0,g.gt)(j,z))throw new f.C_;return o=(0,g.mul)(j,"-1"),{txid:"",date:0,currencyCode:r,blockHeight:0,nativeAmount:o,isSend:o.startsWith("-"),networkFee:I,ourReceiveAddresses:[],signedTx:"",otherParams:v,walletId:this.walletId}})}signTx(e,t){return b(this,null,function*(){const s=h(t),n=(0,y.Xp)(e),r=new A.TR(this.networkInfo.binanceApiServers[0]);r.chooseNetwork("mainnet");const{binanceKey:i}=s;yield r.setPrivateKey(i),yield r.initChain();const c=e.currencyCode,p=(0,g.add)(e.nativeAmount,k).replace("-",""),v=(0,y.aL)(c,this.currencyInfo,this.allTokensMap);if(v==null)throw this.error(`signTx Received unsupported currencyCode: ${c}`),new Error(`Received unsupported currencyCode: ${c}`);const I=parseInt(p)/parseInt(v.multiplier);r._broadcastDelegate=z=>z;const G=yield r.transfer(n.from[0],n.to[0],I,c,n.memo);return e.signedTx=G.serialize(),this.warn(`signTx
|
|
2
2
|
${(0,y.oX)(e)}`),e})}broadcastTx(e){return b(this,null,function*(){var t,s;try{const n=yield this.multicastServers("bnb_broadcastTx",e.signedTx),r=x(n);if((t=r.result[0])!=null&&t.ok)return this.warn(`SUCCESS broadcastTx
|
|
3
3
|
${(0,y.oX)(e)}`),e.txid=(s=r.result[0].hash)!=null?s:"",e.date=Date.now()/1e3,e;throw new Error(`Broadcast failed ${JSON.stringify(r)}`)}catch(n){throw this.log.warn(`FAILURE broadcastTx
|
|
4
|
-
${JSON.stringify((0,y.oX)(e))} `,n),new Error(`Broadcast failed: ${n.message}`)}})}}function Y(w,e,t,s){return b(this,null,function*(){const{initOptions:n}=w,r=l(t),i=new W(w,e,r,n,s);return yield i.loadEngine(),i})}var T=(w,e,t)=>new Promise((s,n)=>{var r=o=>{try{c(t.next(o))}catch(p){n(p)}},i=o=>{try{c(t.throw(o))}catch(p){n(p)}},c=o=>o.done?s(o.value):Promise.resolve(o.value).then(r,i);c((t=t.apply(w,e)).next())});const{checkAddress:J,getAddressFromPrivateKey:q,getPrivateKeyFromMnemonic:Q,validateMnemonic:ee}=A.eL;class Z{constructor(e){const{builtinTokens:t,currencyInfo:s,io:n,networkInfo:r}=e;this.builtinTokens=t,this.currencyInfo=s,this.io=n,this.networkInfo=r}getDisplayPrivateKey(e){return T(this,null,function*(){return h(e.keys).binanceMnemonic})}getDisplayPublicKey(e){return T(this,null,function*(){const{keys:t}=l(e);return t.publicKey})}importPrivateKey(e){return T(this,null,function*(){if(!ee(e))throw new Error("Invalid BNB mnemonic");const s=Q(e);return{binanceMnemonic:e,binanceKey:s}})}createPrivateKey(e){return T(this,null,function*(){if(e.replace("wallet:","")==="binance"){const s=R.Buffer.from(this.io.random(32)).toString("hex"),n=(0,U.entropyToMnemonic)(s),r=Q(n);return{binanceMnemonic:n,binanceKey:r}}else throw new Error("InvalidWalletType")})}derivePublicKey(e){return T(this,null,function*(){if(e.type.replace("wallet:","")==="binance"){let s="",n=e.keys.binanceKey;return typeof n!="string"&&(n=Q(e.keys.binanceMnemonic)),s=q(n,"bnb"),{publicKey:s}}else throw new Error("InvalidWalletType")})}parseUri(e,t,s){return T(this,null,function*(){var n;const r={binance:!0},{parsedUri:i,edgeParsedUri:c}=(0,D.k)(this.currencyInfo,e,r,t!=null?t:"BNB",s),o=(n=c.publicAddress)!=null?n:"";if(!J(o,"bnb"))throw new Error("InvalidPublicAddressError");return c.uniqueIdentifier=i.query.memo,c})}encodeUri(e){return T(this,arguments,function*(t,s=[]){const{publicAddress:n,nativeAmount:r,currencyCode:i}=t;if(!J(n,"bnb"))throw new Error("InvalidPublicAddressError");let o;if(typeof r=="string"){const v=(0,y.Qs)(i!=null?i:"BNB",this.currencyInfo,s);if(v==null)throw new Error("InternalErrorInvalidCurrencyCode");o=(0,g.div)(r,v.multiplier,18)}return(0,D.Q)(t,"binance",o)})}}function te(w){return T(this,null,function*(){return new Z(w)})}},79014:function($,E,u){"use strict";u.d(E,{Q:function(){return x},k:function(){return V}});var A=u(77591),g=u.n(A),U=u(24350),R=u(84564),D=u.n(R),y=u(76714),a=Object.defineProperty,B=Object.getOwnPropertySymbols,H=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,_=(l,h,f)=>h in l?a(l,h,{enumerable:!0,configurable:!0,writable:!0,value:f}):l[h]=f,F=(l,h)=>{for(var f in h||(h={}))H.call(h,f)&&_(l,f,h[f]);if(B)for(var f of B(h))X.call(h,f)&&_(l,f,h[f]);return l};function V(l,h,f,m,L=[]){const d=F({},D()(h,{},!0)),O=h.startsWith(`${l.pluginId}://`);if(d.protocol!=null&&(d.protocol=d.protocol.replace(":","")),d.protocol!=null&&d.protocol!==""&&!f[d.protocol])throw new Error(`Uri protocol '${d.protocol}' is not supported for ${l.pluginId}.`);if(d.host===""&&d.pathname==="")throw new Error("Path and host not found in uri.");const C={publicAddress:d.host!==""?d.host:d.pathname.split("/")[0]},K=d.query.label,N=d.query.message,P=d.query.category;(K!=null||N!=null||P!=null||O)&&(C.metadata={},C.metadata.name=K,C.metadata.notes=N,C.metadata.category=P,C.metadata.gateway=O!=null?O:!1);const S=d.query.amount;if(S!=null&&typeof S=="string"){m==null&&(m=l.currencyCode);const M=(0,y.Qs)(m!=null?m:"",l,L);if(M==null)throw new Error("InternalErrorInvalidCurrencyCode");let k=(0,A.mul)(S,M.multiplier);k=(0,A.toFixed)(k,0,0),C.nativeAmount=k,C.currencyCode=m}return{edgeParsedUri:C,parsedUri:d}}function x(l,h,f){if(l.publicAddress==null)throw new Error("InvalidPublicAddressError");if(f==null&&l.label==null&&l.message==null)return l.publicAddress;{let m="";f!=null&&(m+="amount="+f+"&"),(l.label!=null||l.message!=null)&&(typeof l.label=="string"&&(m+="label="+l.label+"&"),typeof l.message=="string"&&(m+="message="+l.message+"&")),m=m.substr(0,m.length-1);const L={scheme:h,path:l.publicAddress,query:m};return(0,U.qC)(L)}}},71156:function(){},83954:function(){}}]);
|
|
4
|
+
${JSON.stringify((0,y.oX)(e))} `,n),new Error(`Broadcast failed: ${n.message}`)}})}}function Y(w,e,t,s){return b(this,null,function*(){const{initOptions:n}=w,r=l(t),i=new W(w,e,r,n,s);return yield i.loadEngine(),i})}var T=(w,e,t)=>new Promise((s,n)=>{var r=o=>{try{c(t.next(o))}catch(p){n(p)}},i=o=>{try{c(t.throw(o))}catch(p){n(p)}},c=o=>o.done?s(o.value):Promise.resolve(o.value).then(r,i);c((t=t.apply(w,e)).next())});const{checkAddress:J,getAddressFromPrivateKey:q,getPrivateKeyFromMnemonic:Q,validateMnemonic:ee}=A.eL;class Z{constructor(e){const{builtinTokens:t,currencyInfo:s,io:n,networkInfo:r}=e;this.builtinTokens=t,this.currencyInfo=s,this.io=n,this.networkInfo=r}getDisplayPrivateKey(e){return T(this,null,function*(){return h(e.keys).binanceMnemonic})}getDisplayPublicKey(e){return T(this,null,function*(){const{keys:t}=l(e);return t.publicKey})}importPrivateKey(e){return T(this,null,function*(){if(!ee(e))throw new Error("Invalid BNB mnemonic");const s=Q(e);return{binanceMnemonic:e,binanceKey:s}})}createPrivateKey(e){return T(this,null,function*(){if(e.replace("wallet:","")==="binance"){const s=R.Buffer.from(this.io.random(32)).toString("hex"),n=(0,U.entropyToMnemonic)(s),r=Q(n);return{binanceMnemonic:n,binanceKey:r}}else throw new Error("InvalidWalletType")})}derivePublicKey(e){return T(this,null,function*(){if(e.type.replace("wallet:","")==="binance"){let s="",n=e.keys.binanceKey;return typeof n!="string"&&(n=Q(e.keys.binanceMnemonic)),s=q(n,"bnb"),{publicKey:s}}else throw new Error("InvalidWalletType")})}parseUri(e,t,s){return T(this,null,function*(){var n;const r={binance:!0},{parsedUri:i,edgeParsedUri:c}=(0,D.k)(this.currencyInfo,e,r,t!=null?t:"BNB",s),o=(n=c.publicAddress)!=null?n:"";if(!J(o,"bnb"))throw new Error("InvalidPublicAddressError");return c.uniqueIdentifier=i.query.memo,c})}encodeUri(e){return T(this,arguments,function*(t,s=[]){const{publicAddress:n,nativeAmount:r,currencyCode:i}=t;if(!J(n,"bnb"))throw new Error("InvalidPublicAddressError");let o;if(typeof r=="string"){const v=(0,y.Qs)(i!=null?i:"BNB",this.currencyInfo,s);if(v==null)throw new Error("InternalErrorInvalidCurrencyCode");o=(0,g.div)(r,v.multiplier,18)}return(0,D.Q)(t,"binance",o)})}}function te(w){return T(this,null,function*(){return new Z(w)})}},79014:function($,E,u){"use strict";u.d(E,{Q:function(){return x},k:function(){return V}});var A=u(77591),g=u.n(A),U=u(24350),R=u(84564),D=u.n(R),y=u(76714),a=Object.defineProperty,B=Object.getOwnPropertySymbols,H=Object.prototype.hasOwnProperty,X=Object.prototype.propertyIsEnumerable,_=(l,h,f)=>h in l?a(l,h,{enumerable:!0,configurable:!0,writable:!0,value:f}):l[h]=f,F=(l,h)=>{for(var f in h||(h={}))H.call(h,f)&&_(l,f,h[f]);if(B)for(var f of B(h))X.call(h,f)&&_(l,f,h[f]);return l};function V(l,h,f,m,L=[]){const d=F({},D()(h,{},!0)),O=h.startsWith(`${l.pluginId}://`);if(d.protocol!=null&&(d.protocol=d.protocol.replace(":","")),d.protocol!=null&&d.protocol!==""&&!f[d.protocol])throw new Error(`Uri protocol '${d.protocol}' is not supported for ${l.pluginId}.`);if(d.host===""&&d.pathname==="")throw new Error("Path and host not found in uri.");const C={publicAddress:d.host!==""?d.host:d.pathname.split("/")[0]},K=d.query.label,N=d.query.message,P=d.query.category;(K!=null||N!=null||P!=null||O)&&(C.metadata={},C.metadata.name=K,C.metadata.notes=N,C.metadata.category=P,C.metadata.gateway=O!=null?O:!1);const S=d.query.amount;if(S!=null&&typeof S=="string"){m==null&&(m=l.currencyCode);const M=(0,y.Qs)(m!=null?m:"",l,L);if(M==null)throw new Error("InternalErrorInvalidCurrencyCode");let k=(0,A.mul)(S,M.multiplier);k=(0,A.toFixed)(k,0,0),C.nativeAmount=k,C.currencyCode=m}return{edgeParsedUri:C,parsedUri:d}}function x(l,h,f){if(l.publicAddress==null)throw new Error("InvalidPublicAddressError");if(f==null&&l.label==null&&l.message==null)return l.publicAddress;{let m="";f!=null&&(m+="amount="+f+"&"),(l.label!=null||l.message!=null)&&(typeof l.label=="string"&&(m+="label="+l.label+"&"),typeof l.message=="string"&&(m+="message="+l.message+"&")),m=m.substr(0,m.length-1);const L={scheme:h,path:l.publicAddress,query:m};return(0,U.qC)(L)}}},89214:function(){},71156:function(){},52361:function(){},94616:function(){},83954:function(){}}]);
|