UNPKG

libra-sdk-mol

Version:

Javascript SDK for Libra Network and Move Smart Contract powered by MoveOnLibra OpenAPI

8 lines 26.3 kB
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.LibraClient=t():e.LibraClient=t()}(window,(function(){return function(e){var t={};function r(n){if(t[n])return t[n].exports;var a=t[n]={i:n,l:!1,exports:{}};return e[n].call(a.exports,a,a.exports,r),a.l=!0,a.exports}return r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var a in e)r.d(n,a,function(t){return e[t]}.bind(null,a));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=10)}([function(e,t,r){"use strict";var n=r(2),a=r(14),s=Object.prototype.toString;function i(e){return"[object Array]"===s.call(e)}function o(e){return null!==e&&"object"==typeof e}function c(e){return"[object Function]"===s.call(e)}function u(e,t){if(null!=e)if("object"!=typeof e&&(e=[e]),i(e))for(var r=0,n=e.length;r<n;r++)t.call(null,e[r],r,e);else for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.call(null,e[a],a,e)}e.exports={isArray:i,isArrayBuffer:function(e){return"[object ArrayBuffer]"===s.call(e)},isBuffer:a,isFormData:function(e){return"undefined"!=typeof FormData&&e instanceof FormData},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&e.buffer instanceof ArrayBuffer},isString:function(e){return"string"==typeof e},isNumber:function(e){return"number"==typeof e},isObject:o,isUndefined:function(e){return void 0===e},isDate:function(e){return"[object Date]"===s.call(e)},isFile:function(e){return"[object File]"===s.call(e)},isBlob:function(e){return"[object Blob]"===s.call(e)},isFunction:c,isStream:function(e){return o(e)&&c(e.pipe)},isURLSearchParams:function(e){return"undefined"!=typeof URLSearchParams&&e instanceof URLSearchParams},isStandardBrowserEnv:function(){return("undefined"==typeof navigator||"ReactNative"!==navigator.product&&"NativeScript"!==navigator.product&&"NS"!==navigator.product)&&("undefined"!=typeof window&&"undefined"!=typeof document)},forEach:u,merge:function e(){var t={};function r(r,n){"object"==typeof t[n]&&"object"==typeof r?t[n]=e(t[n],r):t[n]=r}for(var n=0,a=arguments.length;n<a;n++)u(arguments[n],r);return t},deepMerge:function e(){var t={};function r(r,n){"object"==typeof t[n]&&"object"==typeof r?t[n]=e(t[n],r):t[n]="object"==typeof r?e({},r):r}for(var n=0,a=arguments.length;n<a;n++)u(arguments[n],r);return t},extend:function(e,t,r){return u(t,(function(t,a){e[a]=r&&"function"==typeof t?n(t,r):t})),e},trim:function(e){return e.replace(/^\s*/,"").replace(/\s*$/,"")}}},function(e,t){e.exports=class{constructor(e){this.client=e,this.checkParam=function(e,t,r,n){if(null==e){if(n)throw new Error("Missing the required parameter: "+t);return e}if(("string"===r||"integer"===r)&&"object"==typeof e)if(void 0!==e[t])e=e[t];else if(n)throw new Error(JSON.stringify(e)+" does not have requried param: "+t);return this.checkParamType(e,t,r),"string"===r&&(e=e.trim(),t.endsWith("address")),e},this.checkParamType=function(e,t,r){if("string"===r){if("string"!=typeof e)throw new Error(t+"'s type should be string, but real type is "+typeof e)}else if("number"===r){if(!Number.isInteger(e))throw new Error(t+"'s type should be integer, but real type is "+typeof e)}else if("array"===r){if(!Array.isArray(e))throw new Error(t+"'s type should be array, but real type is "+typeof e)}else{if("file"!==r)throw new Error("Unsupport type:"+r);if(!e instanceof File)throw new Error(t+"'s type should be file, but real type is "+typeof e)}}}}},function(e,t,r){"use strict";e.exports=function(e,t){return function(){for(var r=new Array(arguments.length),n=0;n<r.length;n++)r[n]=arguments[n];return e.apply(t,r)}}},function(e,t,r){"use strict";var n=r(0);function a(e){return encodeURIComponent(e).replace(/%40/gi,"@").replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}e.exports=function(e,t,r){if(!t)return e;var s;if(r)s=r(t);else if(n.isURLSearchParams(t))s=t.toString();else{var i=[];n.forEach(t,(function(e,t){null!=e&&(n.isArray(e)?t+="[]":e=[e],n.forEach(e,(function(e){n.isDate(e)?e=e.toISOString():n.isObject(e)&&(e=JSON.stringify(e)),i.push(a(t)+"="+a(e))})))})),s=i.join("&")}if(s){var o=e.indexOf("#");-1!==o&&(e=e.slice(0,o)),e+=(-1===e.indexOf("?")?"?":"&")+s}return e}},function(e,t,r){"use strict";e.exports=function(e){return!(!e||!e.__CANCEL__)}},function(e,t,r){"use strict";(function(t){var n=r(0),a=r(20),s={"Content-Type":"application/x-www-form-urlencoded"};function i(e,t){!n.isUndefined(e)&&n.isUndefined(e["Content-Type"])&&(e["Content-Type"]=t)}var o,c={adapter:(void 0!==t&&"[object process]"===Object.prototype.toString.call(t)?o=r(6):"undefined"!=typeof XMLHttpRequest&&(o=r(6)),o),transformRequest:[function(e,t){return a(t,"Accept"),a(t,"Content-Type"),n.isFormData(e)||n.isArrayBuffer(e)||n.isBuffer(e)||n.isStream(e)||n.isFile(e)||n.isBlob(e)?e:n.isArrayBufferView(e)?e.buffer:n.isURLSearchParams(e)?(i(t,"application/x-www-form-urlencoded;charset=utf-8"),e.toString()):n.isObject(e)?(i(t,"application/json;charset=utf-8"),JSON.stringify(e)):e}],transformResponse:[function(e){if("string"==typeof e)try{e=JSON.parse(e)}catch(e){}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,validateStatus:function(e){return e>=200&&e<300}};c.headers={common:{Accept:"application/json, text/plain, */*"}},n.forEach(["delete","get","head"],(function(e){c.headers[e]={}})),n.forEach(["post","put","patch"],(function(e){c.headers[e]=n.merge(s)})),e.exports=c}).call(this,r(19))},function(e,t,r){"use strict";var n=r(0),a=r(21),s=r(3),i=r(23),o=r(24),c=r(7);e.exports=function(e){return new Promise((function(t,u){var l=e.data,f=e.headers;n.isFormData(l)&&delete f["Content-Type"];var h=new XMLHttpRequest;if(e.auth){var d=e.auth.username||"",p=e.auth.password||"";f.Authorization="Basic "+btoa(d+":"+p)}if(h.open(e.method.toUpperCase(),s(e.url,e.params,e.paramsSerializer),!0),h.timeout=e.timeout,h.onreadystatechange=function(){if(h&&4===h.readyState&&(0!==h.status||h.responseURL&&0===h.responseURL.indexOf("file:"))){var r="getAllResponseHeaders"in h?i(h.getAllResponseHeaders()):null,n={data:e.responseType&&"text"!==e.responseType?h.response:h.responseText,status:h.status,statusText:h.statusText,headers:r,config:e,request:h};a(t,u,n),h=null}},h.onabort=function(){h&&(u(c("Request aborted",e,"ECONNABORTED",h)),h=null)},h.onerror=function(){u(c("Network Error",e,null,h)),h=null},h.ontimeout=function(){u(c("timeout of "+e.timeout+"ms exceeded",e,"ECONNABORTED",h)),h=null},n.isStandardBrowserEnv()){var m=r(25),v=(e.withCredentials||o(e.url))&&e.xsrfCookieName?m.read(e.xsrfCookieName):void 0;v&&(f[e.xsrfHeaderName]=v)}if("setRequestHeader"in h&&n.forEach(f,(function(e,t){void 0===l&&"content-type"===t.toLowerCase()?delete f[t]:h.setRequestHeader(t,e)})),e.withCredentials&&(h.withCredentials=!0),e.responseType)try{h.responseType=e.responseType}catch(t){if("json"!==e.responseType)throw t}"function"==typeof e.onDownloadProgress&&h.addEventListener("progress",e.onDownloadProgress),"function"==typeof e.onUploadProgress&&h.upload&&h.upload.addEventListener("progress",e.onUploadProgress),e.cancelToken&&e.cancelToken.promise.then((function(e){h&&(h.abort(),u(e),h=null)})),void 0===l&&(l=null),h.send(l)}))}},function(e,t,r){"use strict";var n=r(22);e.exports=function(e,t,r,a,s){var i=new Error(e);return n(i,t,r,a,s)}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e,t){t=t||{};var r={};return n.forEach(["url","method","params","data"],(function(e){void 0!==t[e]&&(r[e]=t[e])})),n.forEach(["headers","auth","proxy"],(function(a){n.isObject(t[a])?r[a]=n.deepMerge(e[a],t[a]):void 0!==t[a]?r[a]=t[a]:n.isObject(e[a])?r[a]=n.deepMerge(e[a]):void 0!==e[a]&&(r[a]=e[a])})),n.forEach(["baseURL","transformRequest","transformResponse","paramsSerializer","timeout","withCredentials","adapter","responseType","xsrfCookieName","xsrfHeaderName","onUploadProgress","onDownloadProgress","maxContentLength","validateStatus","maxRedirects","httpAgent","httpsAgent","cancelToken","socketPath"],(function(n){void 0!==t[n]?r[n]=t[n]:void 0!==e[n]&&(r[n]=e[n])})),r}},function(e,t,r){"use strict";function n(e){this.message=e}n.prototype.toString=function(){return"Cancel"+(this.message?": "+this.message:"")},n.prototype.__CANCEL__=!0,e.exports=n},function(e,t,r){const n=r(11),a=r(30),s=r(31),i=r(32),o=r(33),c=r(34),u=r(35),l=r(36);function f(e){return e.response?e.response.status+": "+e.response.data.error:e.request?e.request:e.message}function h(e){throw e.response?(console.log(e.response.data),console.log(e.response.status),console.log(e.response.headers)):e.request?console.log(e.request):console.log("Error",e.message),e}e.exports=class{constructor(e,t=null,r=h){if(null==e)throw new Error("Missing the required parameter 'network'.");this.apiClient=new n(e,t,r),this.parseError=f,this.addressAPI=new a(this.apiClient),this.authkeyAPI=new s(this.apiClient),this.eventAPI=new i(this.apiClient),this.libraAPI=new o(this.apiClient),this.moveAPI=new c(this.apiClient),this.transactionAPI=new u(this.apiClient),this.walletAPI=new l(this.apiClient)}}},function(e,t,r){const n=r(12);e.exports=class{constructor(e,t,r,n={}){this.network=e,this.appkey=t,this.errorHandler=r,this.config=n}async call_api(e,t,r="GET"){let a={url:e,method:r};if(this.config.baseURL)a.baseURL=this.config.baseURL;else if("testnet"===this.network||"devnet"===this.network)a.baseURL="https://apitest.moveonLibra.com";else{if("mainnet"!==this.network)throw new Error("Unknown network: "+this.network);a.baseURL="https://api.moveonLibra.com"}this.appkey&&(a.headers={Authorization:this.appkey}),"POST"===r?a.data=t:a.params=t;let s=this;return(await n(a).catch((function(e){if(!s.errorHandler)throw e;s.errorHandler(e)}))).data}}},function(e,t,r){e.exports=r(13)},function(e,t,r){"use strict";var n=r(0),a=r(2),s=r(15),i=r(8);function o(e){var t=new s(e),r=a(s.prototype.request,t);return n.extend(r,s.prototype,t),n.extend(r,t),r}var c=o(r(5));c.Axios=s,c.create=function(e){return o(i(c.defaults,e))},c.Cancel=r(9),c.CancelToken=r(28),c.isCancel=r(4),c.all=function(e){return Promise.all(e)},c.spread=r(29),e.exports=c,e.exports.default=c},function(e,t){ /*! * Determine if an object is a Buffer * * @author Feross Aboukhadijeh <https://feross.org> * @license MIT */ e.exports=function(e){return null!=e&&null!=e.constructor&&"function"==typeof e.constructor.isBuffer&&e.constructor.isBuffer(e)}},function(e,t,r){"use strict";var n=r(0),a=r(3),s=r(16),i=r(17),o=r(8);function c(e){this.defaults=e,this.interceptors={request:new s,response:new s}}c.prototype.request=function(e){"string"==typeof e?(e=arguments[1]||{}).url=arguments[0]:e=e||{},(e=o(this.defaults,e)).method=e.method?e.method.toLowerCase():"get";var t=[i,void 0],r=Promise.resolve(e);for(this.interceptors.request.forEach((function(e){t.unshift(e.fulfilled,e.rejected)})),this.interceptors.response.forEach((function(e){t.push(e.fulfilled,e.rejected)}));t.length;)r=r.then(t.shift(),t.shift());return r},c.prototype.getUri=function(e){return e=o(this.defaults,e),a(e.url,e.params,e.paramsSerializer).replace(/^\?/,"")},n.forEach(["delete","get","head","options"],(function(e){c.prototype[e]=function(t,r){return this.request(n.merge(r||{},{method:e,url:t}))}})),n.forEach(["post","put","patch"],(function(e){c.prototype[e]=function(t,r,a){return this.request(n.merge(a||{},{method:e,url:t,data:r}))}})),e.exports=c},function(e,t,r){"use strict";var n=r(0);function a(){this.handlers=[]}a.prototype.use=function(e,t){return this.handlers.push({fulfilled:e,rejected:t}),this.handlers.length-1},a.prototype.eject=function(e){this.handlers[e]&&(this.handlers[e]=null)},a.prototype.forEach=function(e){n.forEach(this.handlers,(function(t){null!==t&&e(t)}))},e.exports=a},function(e,t,r){"use strict";var n=r(0),a=r(18),s=r(4),i=r(5),o=r(26),c=r(27);function u(e){e.cancelToken&&e.cancelToken.throwIfRequested()}e.exports=function(e){return u(e),e.baseURL&&!o(e.url)&&(e.url=c(e.baseURL,e.url)),e.headers=e.headers||{},e.data=a(e.data,e.headers,e.transformRequest),e.headers=n.merge(e.headers.common||{},e.headers[e.method]||{},e.headers||{}),n.forEach(["delete","get","head","post","put","patch","common"],(function(t){delete e.headers[t]})),(e.adapter||i.adapter)(e).then((function(t){return u(e),t.data=a(t.data,t.headers,e.transformResponse),t}),(function(t){return s(t)||(u(e),t&&t.response&&(t.response.data=a(t.response.data,t.response.headers,e.transformResponse))),Promise.reject(t)}))}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e,t,r){return n.forEach(r,(function(r){e=r(e,t)})),e}},function(e,t){var r,n,a=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function o(e){if(r===setTimeout)return setTimeout(e,0);if((r===s||!r)&&setTimeout)return r=setTimeout,setTimeout(e,0);try{return r(e,0)}catch(t){try{return r.call(null,e,0)}catch(t){return r.call(this,e,0)}}}!function(){try{r="function"==typeof setTimeout?setTimeout:s}catch(e){r=s}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var c,u=[],l=!1,f=-1;function h(){l&&c&&(l=!1,c.length?u=c.concat(u):f=-1,u.length&&d())}function d(){if(!l){var e=o(h);l=!0;for(var t=u.length;t;){for(c=u,u=[];++f<t;)c&&c[f].run();f=-1,t=u.length}c=null,l=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===i||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(t){try{return n.call(null,e)}catch(t){return n.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function m(){}a.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)t[r-1]=arguments[r];u.push(new p(e,t)),1!==u.length||l||o(d)},p.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=m,a.addListener=m,a.once=m,a.off=m,a.removeListener=m,a.removeAllListeners=m,a.emit=m,a.prependListener=m,a.prependOnceListener=m,a.listeners=function(e){return[]},a.binding=function(e){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(e){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},function(e,t,r){"use strict";var n=r(0);e.exports=function(e,t){n.forEach(e,(function(r,n){n!==t&&n.toUpperCase()===t.toUpperCase()&&(e[t]=r,delete e[n])}))}},function(e,t,r){"use strict";var n=r(7);e.exports=function(e,t,r){var a=r.config.validateStatus;!a||a(r.status)?e(r):t(n("Request failed with status code "+r.status,r.config,null,r.request,r))}},function(e,t,r){"use strict";e.exports=function(e,t,r,n,a){return e.config=t,r&&(e.code=r),e.request=n,e.response=a,e.isAxiosError=!0,e.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}},e}},function(e,t,r){"use strict";var n=r(0),a=["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"];e.exports=function(e){var t,r,s,i={};return e?(n.forEach(e.split("\n"),(function(e){if(s=e.indexOf(":"),t=n.trim(e.substr(0,s)).toLowerCase(),r=n.trim(e.substr(s+1)),t){if(i[t]&&a.indexOf(t)>=0)return;i[t]="set-cookie"===t?(i[t]?i[t]:[]).concat([r]):i[t]?i[t]+", "+r:r}})),i):i}},function(e,t,r){"use strict";var n=r(0);e.exports=n.isStandardBrowserEnv()?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),r=document.createElement("a");function a(e){var n=e;return t&&(r.setAttribute("href",n),n=r.href),r.setAttribute("href",n),{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 e=a(window.location.href),function(t){var r=n.isString(t)?a(t):t;return r.protocol===e.protocol&&r.host===e.host}}():function(){return!0}},function(e,t,r){"use strict";var n=r(0);e.exports=n.isStandardBrowserEnv()?{write:function(e,t,r,a,s,i){var o=[];o.push(e+"="+encodeURIComponent(t)),n.isNumber(r)&&o.push("expires="+new Date(r).toGMTString()),n.isString(a)&&o.push("path="+a),n.isString(s)&&o.push("domain="+s),!0===i&&o.push("secure"),document.cookie=o.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}}},function(e,t,r){"use strict";e.exports=function(e){return/^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(e)}},function(e,t,r){"use strict";e.exports=function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}},function(e,t,r){"use strict";var n=r(9);function a(e){if("function"!=typeof e)throw new TypeError("executor must be a function.");var t;this.promise=new Promise((function(e){t=e}));var r=this;e((function(e){r.reason||(r.reason=new n(e),t(r.reason))}))}a.prototype.throwIfRequested=function(){if(this.reason)throw this.reason},a.source=function(){var e;return{token:new a((function(t){e=t})),cancel:e}},e.exports=a},function(e,t,r){"use strict";e.exports=function(e){return function(t){return e.apply(null,t)}}},function(e,t,r){const n=r(1);e.exports=class extends n{async getAccountState(e){e=this.checkParam(e,"address","string",!0);let t="/v1/address/{address}";t=t.replace("{address}",e);return await this.client.call_api(t,{})}async getAccountResource(e){e=this.checkParam(e,"address","string",!0);let t="/v1/address/account_resource/{address}";t=t.replace("{address}",e);return await this.client.call_api(t,{})}async getAccountBalance(e){e=this.checkParam(e,"address","string",!0);let t="/v1/address/balance/{address}";t=t.replace("{address}",e);return await this.client.call_api(t,{})}async getAccountSequence(e){e=this.checkParam(e,"address","string",!0);let t="/v1/address/sequence_number/{address}";t=t.replace("{address}",e);return await this.client.call_api(t,{})}}},function(e,t,r){const n=r(1);e.exports=class extends n{async postClientKey(e){e=this.checkParam(e,"valid_hours","number",!0);let t={};return t.valid_hours=e,await this.client.call_api("/v1/authkey/clients",t,"POST")}async getClientKeys(){return await this.client.call_api("/v1/authkey/clients",{})}async debugKey(){return await this.client.call_api("/v1/authkey/debug",{})}}},function(e,t,r){const n=r(1);e.exports=class extends n{async getAccountEventsSent(e,t,r){e=this.checkParam(e,"address","string",!0),t=this.checkParam(t,"start_event_seq_number","number",!0),r=this.checkParam(r,"limit","number",!1);let n="/v1/events/sent/{address}";n=n.replace("{address}",e);let a={};return a.start_event_seq_number=t,a.limit=r,await this.client.call_api(n,a)}async getAccountEventsReceived(e,t,r){e=this.checkParam(e,"address","string",!0),t=this.checkParam(t,"start_event_seq_number","number",!0),r=this.checkParam(r,"limit","number",!1);let n="/v1/events/received/{address}";n=n.replace("{address}",e);let a={};return a.start_event_seq_number=t,a.limit=r,await this.client.call_api(n,a)}async getAccountEventsLatestSent(e,t){e=this.checkParam(e,"address","string",!0),t=this.checkParam(t,"limit","number",!1);let r="/v1/events/latest/sent/{address}";r=r.replace("{address}",e);let n={};return n.limit=t,await this.client.call_api(r,n)}async getAccountEventsLatestReceived(e,t){e=this.checkParam(e,"address","string",!0),t=this.checkParam(t,"limit","number",!1);let r="/v1/events/latest/received/{address}";r=r.replace("{address}",e);let n={};return n.limit=t,await this.client.call_api(r,n)}async getAccountEvents(e,t,r){e=this.checkParam(e,"address","string",!0),t=this.checkParam(t,"start_event_seq_number","number",!0),r=this.checkParam(r,"limit","number",!1);let n="/v1/events/{address}";n=n.replace("{address}",e);let a={};return a.start_event_seq_number=t,a.limit=r,await this.client.call_api(n,a)}async getAccountEventsLatest(e,t){e=this.checkParam(e,"address","string",!0),t=this.checkParam(t,"limit","number",!1);let r="/v1/events/latest/{address}";r=r.replace("{address}",e);let n={};return n.limit=t,await this.client.call_api(r,n)}}},function(e,t,r){const n=r(1);e.exports=class extends n{async getVmErrorCodes(){return await this.client.call_api("/v1/libra/vm_errors",{})}async getVmErrorCode(e){e=this.checkParam(e,"code","number",!0);let t="/v1/libra/vm_errors/{code}";t=t.replace("{code}",e);return await this.client.call_api(t,{})}}},function(e,t,r){const n=r(1);e.exports=class extends n{async compileModule(e,t){e=this.checkParam(e,"publish_account_address","string",!0),t=this.checkParam(t,"source_file","file",!0);let r={};return r.publish_account_address=e,r.source_file=t,await this.client.call_api("/v1/move/compile/module",r,"POST")}async compileScript(e,t){e=this.checkParam(e,"sender_address","string",!1),t=this.checkParam(t,"source_file","file",!0);let r={};return r.sender_address=e,r.source_file=t,await this.client.call_api("/v1/move/compile/script",r,"POST")}async getCode(e){e=this.checkParam(e,"code_id","string",!0);let t="/v1/move/download/{code_id}";t=t.replace("{code_id}",e);return await this.client.call_api(t,{})}async publish(e,t){e=this.checkParam(e,"code_id","string",!0),t=this.checkParam(t,"publish_account_address","string",!0);let r={};return r.code_id=e,r.publish_account_address=t,await this.client.call_api("/v1/move/publish",r,"POST")}async execute(e,t,r){e=this.checkParam(e,"code_id","string",!0),t=this.checkParam(t,"sender_account_address","string",!0),r=this.checkParam(r,"script_args","array",!0);let n={};return n.code_id=e,n.sender_account_address=t,n.script_args=r,await this.client.call_api("/v1/move/execute",n,"POST")}}},function(e,t,r){const n=r(1);e.exports=class extends n{async getTransaction(e){e=this.checkParam(e,"version","number",!0);let t="/v1/transactions/{version}";t=t.replace("{version}",e);return await this.client.call_api(t,{})}async getTransactions(e,t){e=this.checkParam(e,"start_version","number",!0),t=this.checkParam(t,"limit","number",!1);let r={};return r.start_version=e,r.limit=t,await this.client.call_api("/v1/transactions",r)}async getLatestVersion(){return await this.client.call_api("/v1/transactions/latest_version",{})}async getTransactionLatest(e){e=this.checkParam(e,"limit","number",!1);let t={};return t.limit=e,await this.client.call_api("/v1/transactions/latest",t)}async getByAccountSeq(e,t){e=this.checkParam(e,"account_address","string",!0),t=this.checkParam(t,"sequence_number","number",!0);let r={};return r.account_address=e,r.sequence_number=t,await this.client.call_api("/v1/transactions/acc_seq",r)}async waitTransaction(e,t){e=this.checkParam(e,"account_address","string",!0),t=this.checkParam(t,"sequence_number","number",!0);let r={};return r.account_address=e,r.sequence_number=t,await this.client.call_api("/v1/transactions/wait_for_transaction",r)}async mint(e,t,r,n){e=this.checkParam(e,"receiver_account_address","string",!0),t=this.checkParam(t,"auth_key_prefix","string",!0),r=this.checkParam(r,"number_of_micro_libra","number",!0),n=this.checkParam(n,"force_offical","number",!1);let a={};return a.receiver_account_address=e,a.auth_key_prefix=t,a.number_of_micro_libra=r,a.force_offical=n,await this.client.call_api("/v1/transactions/mint",a,"POST")}async mintMol(e,t,r){e=this.checkParam(e,"receiver_account_address","string",!0),t=this.checkParam(t,"auth_key_prefix","string",!0),r=this.checkParam(r,"number_of_micro_libra","number",!0);let n={};return n.receiver_account_address=e,n.auth_key_prefix=t,n.number_of_micro_libra=r,await this.client.call_api("/v1/transactions/mint_mol",n,"POST")}async createAccount(e,t){e=this.checkParam(e,"account_address","string",!0),t=this.checkParam(t,"auth_key_prefix","string",!0);let r={};return r.account_address=e,r.auth_key_prefix=t,await this.client.call_api("/v1/transactions/create_account",r,"POST")}async p2pTransfer(e,t,r,n){e=this.checkParam(e,"wallet_id","number",!0),t=this.checkParam(t,"sender_account_address","string",!0),r=this.checkParam(r,"receiver_account_address","string",!0),n=this.checkParam(n,"number_of_micro_libra","number",!0);let a={};return a.wallet_id=e,a.sender_account_address=t,a.receiver_account_address=r,a.number_of_micro_libra=n,await this.client.call_api("/v1/transactions/transfer",a,"POST")}}},function(e,t,r){const n=r(1);e.exports=class extends n{async createWallet(e){e=this.checkParam(e,"name","string",!0);let t={};return t.name=e,await this.client.call_api("/v1/wallets",t,"POST")}async getWallets(){return await this.client.call_api("/v1/wallets",{})}async getWallet(e){e=this.checkParam(e,"wallet_id","number",!0);let t="/v1/wallets/{wallet_id}";t=t.replace("{wallet_id}",e);return await this.client.call_api(t,{})}async backupWallet(e){e=this.checkParam(e,"wallet_id","number",!0);let t="/v1/wallets/backup/{wallet_id}";t=t.replace("{wallet_id}",e);return await this.client.call_api(t,{})}async createWalletAccount(e){e=this.checkParam(e,"wallet_id","number",!0);let t="/v1/wallets/{wallet_id}/accounts";t=t.replace("{wallet_id}",e);return await this.client.call_api(t,{},"POST")}async getWalletAccounts(e){e=this.checkParam(e,"wallet_id","number",!0);let t="/v1/wallets/{wallet_id}/accounts";t=t.replace("{wallet_id}",e);return await this.client.call_api(t,{})}}}])}));