@zilliqa-js/core
Advanced tools
Comparing version 3.0.0 to 3.1.0
@@ -19,2 +19,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.GET_TX_ATTEMPTS = void 0; | ||
// this constant is used to indicate the number of times to poll the | ||
@@ -21,0 +22,0 @@ // blockchain for a transaction confirmation. this number has been selected by |
@@ -20,3 +20,3 @@ "use strict"; | ||
var sign_1 = require("./sign"); | ||
exports.sign = sign_1.sign; | ||
Object.defineProperty(exports, "sign", { enumerable: true, get: function () { return sign_1.sign; } }); | ||
//# sourceMappingURL=index.js.map |
@@ -19,2 +19,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.sign = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -21,0 +22,0 @@ /** |
@@ -6,3 +6,3 @@ import mitt from 'mitt'; | ||
promise: Promise<T>; | ||
resolve?: (value?: T | PromiseLike<T>) => void; | ||
resolve?: (value: T | PromiseLike<T>) => void; | ||
reject?: (reason?: any) => void; | ||
@@ -9,0 +9,0 @@ then?: any; |
@@ -19,2 +19,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.EventEmitter = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -29,3 +30,2 @@ var mitt_1 = tslib_1.__importDefault(require("mitt")); | ||
this.emit = this.emitter.emit.bind(this); | ||
// tslint:disable-next-line: no-empty | ||
this.promise = new Promise(function (resolve, reject) { | ||
@@ -38,3 +38,2 @@ _this.resolve = resolve; | ||
EventEmitter.prototype.resetHandlers = function () { | ||
// tslint:disable-next-line: forin | ||
for (var i in this.handlers) { | ||
@@ -41,0 +40,0 @@ delete this.handlers[i]; |
@@ -1,2 +0,1 @@ | ||
import fetch from 'cross-fetch'; | ||
import mitt from 'mitt'; | ||
@@ -55,14 +54,14 @@ | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Copyright (c) Microsoft Corporation. | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
@@ -74,3 +73,3 @@ /* global Reflect, Promise */ | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
@@ -80,2 +79,4 @@ }; | ||
function __extends(d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -98,6 +99,7 @@ function __() { this.constructor = d; } | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -136,5 +138,5 @@ }); | ||
function __values(o) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
return { | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
@@ -145,2 +147,3 @@ if (o && i >= o.length) o = void 0; | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
} | ||
@@ -165,2 +168,3 @@ | ||
/** @deprecated */ | ||
function __spread() { | ||
@@ -212,3 +216,468 @@ for (var ar = [], i = 0; i < arguments.length; i++) | ||
// Copyright (C) 2018 Zilliqa | ||
(function(self) { | ||
if (self.fetch) { | ||
return | ||
} | ||
var support = { | ||
searchParams: 'URLSearchParams' in self, | ||
iterable: 'Symbol' in self && 'iterator' in Symbol, | ||
blob: 'FileReader' in self && 'Blob' in self && (function() { | ||
try { | ||
new Blob(); | ||
return true | ||
} catch(e) { | ||
return false | ||
} | ||
})(), | ||
formData: 'FormData' in self, | ||
arrayBuffer: 'ArrayBuffer' in self | ||
}; | ||
if (support.arrayBuffer) { | ||
var viewClasses = [ | ||
'[object Int8Array]', | ||
'[object Uint8Array]', | ||
'[object Uint8ClampedArray]', | ||
'[object Int16Array]', | ||
'[object Uint16Array]', | ||
'[object Int32Array]', | ||
'[object Uint32Array]', | ||
'[object Float32Array]', | ||
'[object Float64Array]' | ||
]; | ||
var isDataView = function(obj) { | ||
return obj && DataView.prototype.isPrototypeOf(obj) | ||
}; | ||
var isArrayBufferView = ArrayBuffer.isView || function(obj) { | ||
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 | ||
}; | ||
} | ||
function normalizeName(name) { | ||
if (typeof name !== 'string') { | ||
name = String(name); | ||
} | ||
if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) { | ||
throw new TypeError('Invalid character in header field name') | ||
} | ||
return name.toLowerCase() | ||
} | ||
function normalizeValue(value) { | ||
if (typeof value !== 'string') { | ||
value = String(value); | ||
} | ||
return value | ||
} | ||
// Build a destructive iterator for the value list | ||
function iteratorFor(items) { | ||
var iterator = { | ||
next: function() { | ||
var value = items.shift(); | ||
return {done: value === undefined, value: value} | ||
} | ||
}; | ||
if (support.iterable) { | ||
iterator[Symbol.iterator] = function() { | ||
return iterator | ||
}; | ||
} | ||
return iterator | ||
} | ||
function Headers(headers) { | ||
this.map = {}; | ||
if (headers instanceof Headers) { | ||
headers.forEach(function(value, name) { | ||
this.append(name, value); | ||
}, this); | ||
} else if (Array.isArray(headers)) { | ||
headers.forEach(function(header) { | ||
this.append(header[0], header[1]); | ||
}, this); | ||
} else if (headers) { | ||
Object.getOwnPropertyNames(headers).forEach(function(name) { | ||
this.append(name, headers[name]); | ||
}, this); | ||
} | ||
} | ||
Headers.prototype.append = function(name, value) { | ||
name = normalizeName(name); | ||
value = normalizeValue(value); | ||
var oldValue = this.map[name]; | ||
this.map[name] = oldValue ? oldValue+','+value : value; | ||
}; | ||
Headers.prototype['delete'] = function(name) { | ||
delete this.map[normalizeName(name)]; | ||
}; | ||
Headers.prototype.get = function(name) { | ||
name = normalizeName(name); | ||
return this.has(name) ? this.map[name] : null | ||
}; | ||
Headers.prototype.has = function(name) { | ||
return this.map.hasOwnProperty(normalizeName(name)) | ||
}; | ||
Headers.prototype.set = function(name, value) { | ||
this.map[normalizeName(name)] = normalizeValue(value); | ||
}; | ||
Headers.prototype.forEach = function(callback, thisArg) { | ||
for (var name in this.map) { | ||
if (this.map.hasOwnProperty(name)) { | ||
callback.call(thisArg, this.map[name], name, this); | ||
} | ||
} | ||
}; | ||
Headers.prototype.keys = function() { | ||
var items = []; | ||
this.forEach(function(value, name) { items.push(name); }); | ||
return iteratorFor(items) | ||
}; | ||
Headers.prototype.values = function() { | ||
var items = []; | ||
this.forEach(function(value) { items.push(value); }); | ||
return iteratorFor(items) | ||
}; | ||
Headers.prototype.entries = function() { | ||
var items = []; | ||
this.forEach(function(value, name) { items.push([name, value]); }); | ||
return iteratorFor(items) | ||
}; | ||
if (support.iterable) { | ||
Headers.prototype[Symbol.iterator] = Headers.prototype.entries; | ||
} | ||
function consumed(body) { | ||
if (body.bodyUsed) { | ||
return Promise.reject(new TypeError('Already read')) | ||
} | ||
body.bodyUsed = true; | ||
} | ||
function fileReaderReady(reader) { | ||
return new Promise(function(resolve, reject) { | ||
reader.onload = function() { | ||
resolve(reader.result); | ||
}; | ||
reader.onerror = function() { | ||
reject(reader.error); | ||
}; | ||
}) | ||
} | ||
function readBlobAsArrayBuffer(blob) { | ||
var reader = new FileReader(); | ||
var promise = fileReaderReady(reader); | ||
reader.readAsArrayBuffer(blob); | ||
return promise | ||
} | ||
function readBlobAsText(blob) { | ||
var reader = new FileReader(); | ||
var promise = fileReaderReady(reader); | ||
reader.readAsText(blob); | ||
return promise | ||
} | ||
function readArrayBufferAsText(buf) { | ||
var view = new Uint8Array(buf); | ||
var chars = new Array(view.length); | ||
for (var i = 0; i < view.length; i++) { | ||
chars[i] = String.fromCharCode(view[i]); | ||
} | ||
return chars.join('') | ||
} | ||
function bufferClone(buf) { | ||
if (buf.slice) { | ||
return buf.slice(0) | ||
} else { | ||
var view = new Uint8Array(buf.byteLength); | ||
view.set(new Uint8Array(buf)); | ||
return view.buffer | ||
} | ||
} | ||
function Body() { | ||
this.bodyUsed = false; | ||
this._initBody = function(body) { | ||
this._bodyInit = body; | ||
if (!body) { | ||
this._bodyText = ''; | ||
} else if (typeof body === 'string') { | ||
this._bodyText = body; | ||
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) { | ||
this._bodyBlob = body; | ||
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) { | ||
this._bodyFormData = body; | ||
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { | ||
this._bodyText = body.toString(); | ||
} else if (support.arrayBuffer && support.blob && isDataView(body)) { | ||
this._bodyArrayBuffer = bufferClone(body.buffer); | ||
// IE 10-11 can't handle a DataView body. | ||
this._bodyInit = new Blob([this._bodyArrayBuffer]); | ||
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { | ||
this._bodyArrayBuffer = bufferClone(body); | ||
} else { | ||
throw new Error('unsupported BodyInit type') | ||
} | ||
if (!this.headers.get('content-type')) { | ||
if (typeof body === 'string') { | ||
this.headers.set('content-type', 'text/plain;charset=UTF-8'); | ||
} else if (this._bodyBlob && this._bodyBlob.type) { | ||
this.headers.set('content-type', this._bodyBlob.type); | ||
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { | ||
this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); | ||
} | ||
} | ||
}; | ||
if (support.blob) { | ||
this.blob = function() { | ||
var rejected = consumed(this); | ||
if (rejected) { | ||
return rejected | ||
} | ||
if (this._bodyBlob) { | ||
return Promise.resolve(this._bodyBlob) | ||
} else if (this._bodyArrayBuffer) { | ||
return Promise.resolve(new Blob([this._bodyArrayBuffer])) | ||
} else if (this._bodyFormData) { | ||
throw new Error('could not read FormData body as blob') | ||
} else { | ||
return Promise.resolve(new Blob([this._bodyText])) | ||
} | ||
}; | ||
this.arrayBuffer = function() { | ||
if (this._bodyArrayBuffer) { | ||
return consumed(this) || Promise.resolve(this._bodyArrayBuffer) | ||
} else { | ||
return this.blob().then(readBlobAsArrayBuffer) | ||
} | ||
}; | ||
} | ||
this.text = function() { | ||
var rejected = consumed(this); | ||
if (rejected) { | ||
return rejected | ||
} | ||
if (this._bodyBlob) { | ||
return readBlobAsText(this._bodyBlob) | ||
} else if (this._bodyArrayBuffer) { | ||
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)) | ||
} else if (this._bodyFormData) { | ||
throw new Error('could not read FormData body as text') | ||
} else { | ||
return Promise.resolve(this._bodyText) | ||
} | ||
}; | ||
if (support.formData) { | ||
this.formData = function() { | ||
return this.text().then(decode) | ||
}; | ||
} | ||
this.json = function() { | ||
return this.text().then(JSON.parse) | ||
}; | ||
return this | ||
} | ||
// HTTP methods whose capitalization should be normalized | ||
var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']; | ||
function normalizeMethod(method) { | ||
var upcased = method.toUpperCase(); | ||
return (methods.indexOf(upcased) > -1) ? upcased : method | ||
} | ||
function Request(input, options) { | ||
options = options || {}; | ||
var body = options.body; | ||
if (input instanceof Request) { | ||
if (input.bodyUsed) { | ||
throw new TypeError('Already read') | ||
} | ||
this.url = input.url; | ||
this.credentials = input.credentials; | ||
if (!options.headers) { | ||
this.headers = new Headers(input.headers); | ||
} | ||
this.method = input.method; | ||
this.mode = input.mode; | ||
if (!body && input._bodyInit != null) { | ||
body = input._bodyInit; | ||
input.bodyUsed = true; | ||
} | ||
} else { | ||
this.url = String(input); | ||
} | ||
this.credentials = options.credentials || this.credentials || 'omit'; | ||
if (options.headers || !this.headers) { | ||
this.headers = new Headers(options.headers); | ||
} | ||
this.method = normalizeMethod(options.method || this.method || 'GET'); | ||
this.mode = options.mode || this.mode || null; | ||
this.referrer = null; | ||
if ((this.method === 'GET' || this.method === 'HEAD') && body) { | ||
throw new TypeError('Body not allowed for GET or HEAD requests') | ||
} | ||
this._initBody(body); | ||
} | ||
Request.prototype.clone = function() { | ||
return new Request(this, { body: this._bodyInit }) | ||
}; | ||
function decode(body) { | ||
var form = new FormData(); | ||
body.trim().split('&').forEach(function(bytes) { | ||
if (bytes) { | ||
var split = bytes.split('='); | ||
var name = split.shift().replace(/\+/g, ' '); | ||
var value = split.join('=').replace(/\+/g, ' '); | ||
form.append(decodeURIComponent(name), decodeURIComponent(value)); | ||
} | ||
}); | ||
return form | ||
} | ||
function parseHeaders(rawHeaders) { | ||
var headers = new Headers(); | ||
// Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space | ||
// https://tools.ietf.org/html/rfc7230#section-3.2 | ||
var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' '); | ||
preProcessedHeaders.split(/\r?\n/).forEach(function(line) { | ||
var parts = line.split(':'); | ||
var key = parts.shift().trim(); | ||
if (key) { | ||
var value = parts.join(':').trim(); | ||
headers.append(key, value); | ||
} | ||
}); | ||
return headers | ||
} | ||
Body.call(Request.prototype); | ||
function Response(bodyInit, options) { | ||
if (!options) { | ||
options = {}; | ||
} | ||
this.type = 'default'; | ||
this.status = options.status === undefined ? 200 : options.status; | ||
this.ok = this.status >= 200 && this.status < 300; | ||
this.statusText = 'statusText' in options ? options.statusText : 'OK'; | ||
this.headers = new Headers(options.headers); | ||
this.url = options.url || ''; | ||
this._initBody(bodyInit); | ||
} | ||
Body.call(Response.prototype); | ||
Response.prototype.clone = function() { | ||
return new Response(this._bodyInit, { | ||
status: this.status, | ||
statusText: this.statusText, | ||
headers: new Headers(this.headers), | ||
url: this.url | ||
}) | ||
}; | ||
Response.error = function() { | ||
var response = new Response(null, {status: 0, statusText: ''}); | ||
response.type = 'error'; | ||
return response | ||
}; | ||
var redirectStatuses = [301, 302, 303, 307, 308]; | ||
Response.redirect = function(url, status) { | ||
if (redirectStatuses.indexOf(status) === -1) { | ||
throw new RangeError('Invalid status code') | ||
} | ||
return new Response(null, {status: status, headers: {location: url}}) | ||
}; | ||
self.Headers = Headers; | ||
self.Request = Request; | ||
self.Response = Response; | ||
self.fetch = function(input, init) { | ||
return new Promise(function(resolve, reject) { | ||
var request = new Request(input, init); | ||
var xhr = new XMLHttpRequest(); | ||
xhr.onload = function() { | ||
var options = { | ||
status: xhr.status, | ||
statusText: xhr.statusText, | ||
headers: parseHeaders(xhr.getAllResponseHeaders() || '') | ||
}; | ||
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL'); | ||
var body = 'response' in xhr ? xhr.response : xhr.responseText; | ||
resolve(new Response(body, options)); | ||
}; | ||
xhr.onerror = function() { | ||
reject(new TypeError('Network request failed')); | ||
}; | ||
xhr.ontimeout = function() { | ||
reject(new TypeError('Network request failed')); | ||
}; | ||
xhr.open(request.method, request.url, true); | ||
if (request.credentials === 'include') { | ||
xhr.withCredentials = true; | ||
} else if (request.credentials === 'omit') { | ||
xhr.withCredentials = false; | ||
} | ||
if ('responseType' in xhr && support.blob) { | ||
xhr.responseType = 'blob'; | ||
} | ||
request.headers.forEach(function(value, name) { | ||
xhr.setRequestHeader(name, value); | ||
}); | ||
xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit); | ||
}) | ||
}; | ||
self.fetch.polyfill = true; | ||
})(typeof self !== 'undefined' ? self : undefined); | ||
/** | ||
@@ -253,2 +722,3 @@ * blockchain-side. | ||
// Contract-related methods | ||
RPCMethod["GetContractAddressFromTransactionID"] = "GetContractAddressFromTransactionID"; | ||
RPCMethod["GetSmartContracts"] = "GetSmartContracts"; | ||
@@ -259,3 +729,3 @@ RPCMethod["GetSmartContractCode"] = "GetSmartContractCode"; | ||
RPCMethod["GetSmartContractSubState"] = "GetSmartContractSubState"; | ||
RPCMethod["GetContractAddressFromTransactionID"] = "GetContractAddressFromTransactionID"; | ||
RPCMethod["GetStateProof"] = "GetStateProof"; | ||
// Account-related methods | ||
@@ -613,3 +1083,2 @@ RPCMethod["GetBalance"] = "GetBalance"; | ||
this.emit = this.emitter.emit.bind(this); | ||
// tslint:disable-next-line: no-empty | ||
this.promise = new Promise(function (resolve, reject) { | ||
@@ -622,3 +1091,2 @@ _this.resolve = resolve; | ||
EventEmitter.prototype.resetHandlers = function () { | ||
// tslint:disable-next-line: forin | ||
for (var i in this.handlers) { | ||
@@ -625,0 +1093,0 @@ delete this.handlers[i]; |
(function (global, factory) { | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('cross-fetch'), require('mitt')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'cross-fetch', 'mitt'], factory) : | ||
(factory((global.zjsCore = {}),global['cross-fetch'],global.mitt)); | ||
}(this, (function (exports,fetch,mitt) { 'use strict'; | ||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('mitt')) : | ||
typeof define === 'function' && define.amd ? define(['exports', 'mitt'], factory) : | ||
(factory((global.zjsCore = {}),global.mitt)); | ||
}(this, (function (exports,mitt) { 'use strict'; | ||
fetch = fetch && fetch.hasOwnProperty('default') ? fetch['default'] : fetch; | ||
mitt = mitt && mitt.hasOwnProperty('default') ? mitt['default'] : mitt; | ||
@@ -60,14 +59,14 @@ | ||
/*! ***************************************************************************** | ||
Copyright (c) Microsoft Corporation. All rights reserved. | ||
Licensed under the Apache License, Version 2.0 (the "License"); you may not use | ||
this file except in compliance with the License. You may obtain a copy of the | ||
License at http://www.apache.org/licenses/LICENSE-2.0 | ||
Copyright (c) Microsoft Corporation. | ||
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED | ||
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE, | ||
MERCHANTABLITY OR NON-INFRINGEMENT. | ||
Permission to use, copy, modify, and/or distribute this software for any | ||
purpose with or without fee is hereby granted. | ||
See the Apache Version 2.0 License for specific language governing permissions | ||
and limitations under the License. | ||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | ||
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY | ||
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | ||
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | ||
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | ||
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | ||
PERFORMANCE OF THIS SOFTWARE. | ||
***************************************************************************** */ | ||
@@ -79,3 +78,3 @@ /* global Reflect, Promise */ | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
@@ -85,2 +84,4 @@ }; | ||
function __extends(d, b) { | ||
if (typeof b !== "function" && b !== null) | ||
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); | ||
extendStatics(d, b); | ||
@@ -103,6 +104,7 @@ function __() { this.constructor = d; } | ||
function __awaiter(thisArg, _arguments, P, generator) { | ||
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
return new (P || (P = Promise))(function (resolve, reject) { | ||
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } | ||
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
@@ -141,5 +143,5 @@ }); | ||
function __values(o) { | ||
var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0; | ||
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; | ||
if (m) return m.call(o); | ||
return { | ||
if (o && typeof o.length === "number") return { | ||
next: function () { | ||
@@ -150,2 +152,3 @@ if (o && i >= o.length) o = void 0; | ||
}; | ||
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); | ||
} | ||
@@ -170,2 +173,3 @@ | ||
/** @deprecated */ | ||
function __spread() { | ||
@@ -217,3 +221,468 @@ for (var ar = [], i = 0; i < arguments.length; i++) | ||
// Copyright (C) 2018 Zilliqa | ||
(function(self) { | ||
if (self.fetch) { | ||
return | ||
} | ||
var support = { | ||
searchParams: 'URLSearchParams' in self, | ||
iterable: 'Symbol' in self && 'iterator' in Symbol, | ||
blob: 'FileReader' in self && 'Blob' in self && (function() { | ||
try { | ||
new Blob(); | ||
return true | ||
} catch(e) { | ||
return false | ||
} | ||
})(), | ||
formData: 'FormData' in self, | ||
arrayBuffer: 'ArrayBuffer' in self | ||
}; | ||
if (support.arrayBuffer) { | ||
var viewClasses = [ | ||
'[object Int8Array]', | ||
'[object Uint8Array]', | ||
'[object Uint8ClampedArray]', | ||
'[object Int16Array]', | ||
'[object Uint16Array]', | ||
'[object Int32Array]', | ||
'[object Uint32Array]', | ||
'[object Float32Array]', | ||
'[object Float64Array]' | ||
]; | ||
var isDataView = function(obj) { | ||
return obj && DataView.prototype.isPrototypeOf(obj) | ||
}; | ||
var isArrayBufferView = ArrayBuffer.isView || function(obj) { | ||
return obj && viewClasses.indexOf(Object.prototype.toString.call(obj)) > -1 | ||
}; | ||
} | ||
function normalizeName(name) { | ||
if (typeof name !== 'string') { | ||
name = String(name); | ||
} | ||
if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) { | ||
throw new TypeError('Invalid character in header field name') | ||
} | ||
return name.toLowerCase() | ||
} | ||
function normalizeValue(value) { | ||
if (typeof value !== 'string') { | ||
value = String(value); | ||
} | ||
return value | ||
} | ||
// Build a destructive iterator for the value list | ||
function iteratorFor(items) { | ||
var iterator = { | ||
next: function() { | ||
var value = items.shift(); | ||
return {done: value === undefined, value: value} | ||
} | ||
}; | ||
if (support.iterable) { | ||
iterator[Symbol.iterator] = function() { | ||
return iterator | ||
}; | ||
} | ||
return iterator | ||
} | ||
function Headers(headers) { | ||
this.map = {}; | ||
if (headers instanceof Headers) { | ||
headers.forEach(function(value, name) { | ||
this.append(name, value); | ||
}, this); | ||
} else if (Array.isArray(headers)) { | ||
headers.forEach(function(header) { | ||
this.append(header[0], header[1]); | ||
}, this); | ||
} else if (headers) { | ||
Object.getOwnPropertyNames(headers).forEach(function(name) { | ||
this.append(name, headers[name]); | ||
}, this); | ||
} | ||
} | ||
Headers.prototype.append = function(name, value) { | ||
name = normalizeName(name); | ||
value = normalizeValue(value); | ||
var oldValue = this.map[name]; | ||
this.map[name] = oldValue ? oldValue+','+value : value; | ||
}; | ||
Headers.prototype['delete'] = function(name) { | ||
delete this.map[normalizeName(name)]; | ||
}; | ||
Headers.prototype.get = function(name) { | ||
name = normalizeName(name); | ||
return this.has(name) ? this.map[name] : null | ||
}; | ||
Headers.prototype.has = function(name) { | ||
return this.map.hasOwnProperty(normalizeName(name)) | ||
}; | ||
Headers.prototype.set = function(name, value) { | ||
this.map[normalizeName(name)] = normalizeValue(value); | ||
}; | ||
Headers.prototype.forEach = function(callback, thisArg) { | ||
for (var name in this.map) { | ||
if (this.map.hasOwnProperty(name)) { | ||
callback.call(thisArg, this.map[name], name, this); | ||
} | ||
} | ||
}; | ||
Headers.prototype.keys = function() { | ||
var items = []; | ||
this.forEach(function(value, name) { items.push(name); }); | ||
return iteratorFor(items) | ||
}; | ||
Headers.prototype.values = function() { | ||
var items = []; | ||
this.forEach(function(value) { items.push(value); }); | ||
return iteratorFor(items) | ||
}; | ||
Headers.prototype.entries = function() { | ||
var items = []; | ||
this.forEach(function(value, name) { items.push([name, value]); }); | ||
return iteratorFor(items) | ||
}; | ||
if (support.iterable) { | ||
Headers.prototype[Symbol.iterator] = Headers.prototype.entries; | ||
} | ||
function consumed(body) { | ||
if (body.bodyUsed) { | ||
return Promise.reject(new TypeError('Already read')) | ||
} | ||
body.bodyUsed = true; | ||
} | ||
function fileReaderReady(reader) { | ||
return new Promise(function(resolve, reject) { | ||
reader.onload = function() { | ||
resolve(reader.result); | ||
}; | ||
reader.onerror = function() { | ||
reject(reader.error); | ||
}; | ||
}) | ||
} | ||
function readBlobAsArrayBuffer(blob) { | ||
var reader = new FileReader(); | ||
var promise = fileReaderReady(reader); | ||
reader.readAsArrayBuffer(blob); | ||
return promise | ||
} | ||
function readBlobAsText(blob) { | ||
var reader = new FileReader(); | ||
var promise = fileReaderReady(reader); | ||
reader.readAsText(blob); | ||
return promise | ||
} | ||
function readArrayBufferAsText(buf) { | ||
var view = new Uint8Array(buf); | ||
var chars = new Array(view.length); | ||
for (var i = 0; i < view.length; i++) { | ||
chars[i] = String.fromCharCode(view[i]); | ||
} | ||
return chars.join('') | ||
} | ||
function bufferClone(buf) { | ||
if (buf.slice) { | ||
return buf.slice(0) | ||
} else { | ||
var view = new Uint8Array(buf.byteLength); | ||
view.set(new Uint8Array(buf)); | ||
return view.buffer | ||
} | ||
} | ||
function Body() { | ||
this.bodyUsed = false; | ||
this._initBody = function(body) { | ||
this._bodyInit = body; | ||
if (!body) { | ||
this._bodyText = ''; | ||
} else if (typeof body === 'string') { | ||
this._bodyText = body; | ||
} else if (support.blob && Blob.prototype.isPrototypeOf(body)) { | ||
this._bodyBlob = body; | ||
} else if (support.formData && FormData.prototype.isPrototypeOf(body)) { | ||
this._bodyFormData = body; | ||
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { | ||
this._bodyText = body.toString(); | ||
} else if (support.arrayBuffer && support.blob && isDataView(body)) { | ||
this._bodyArrayBuffer = bufferClone(body.buffer); | ||
// IE 10-11 can't handle a DataView body. | ||
this._bodyInit = new Blob([this._bodyArrayBuffer]); | ||
} else if (support.arrayBuffer && (ArrayBuffer.prototype.isPrototypeOf(body) || isArrayBufferView(body))) { | ||
this._bodyArrayBuffer = bufferClone(body); | ||
} else { | ||
throw new Error('unsupported BodyInit type') | ||
} | ||
if (!this.headers.get('content-type')) { | ||
if (typeof body === 'string') { | ||
this.headers.set('content-type', 'text/plain;charset=UTF-8'); | ||
} else if (this._bodyBlob && this._bodyBlob.type) { | ||
this.headers.set('content-type', this._bodyBlob.type); | ||
} else if (support.searchParams && URLSearchParams.prototype.isPrototypeOf(body)) { | ||
this.headers.set('content-type', 'application/x-www-form-urlencoded;charset=UTF-8'); | ||
} | ||
} | ||
}; | ||
if (support.blob) { | ||
this.blob = function() { | ||
var rejected = consumed(this); | ||
if (rejected) { | ||
return rejected | ||
} | ||
if (this._bodyBlob) { | ||
return Promise.resolve(this._bodyBlob) | ||
} else if (this._bodyArrayBuffer) { | ||
return Promise.resolve(new Blob([this._bodyArrayBuffer])) | ||
} else if (this._bodyFormData) { | ||
throw new Error('could not read FormData body as blob') | ||
} else { | ||
return Promise.resolve(new Blob([this._bodyText])) | ||
} | ||
}; | ||
this.arrayBuffer = function() { | ||
if (this._bodyArrayBuffer) { | ||
return consumed(this) || Promise.resolve(this._bodyArrayBuffer) | ||
} else { | ||
return this.blob().then(readBlobAsArrayBuffer) | ||
} | ||
}; | ||
} | ||
this.text = function() { | ||
var rejected = consumed(this); | ||
if (rejected) { | ||
return rejected | ||
} | ||
if (this._bodyBlob) { | ||
return readBlobAsText(this._bodyBlob) | ||
} else if (this._bodyArrayBuffer) { | ||
return Promise.resolve(readArrayBufferAsText(this._bodyArrayBuffer)) | ||
} else if (this._bodyFormData) { | ||
throw new Error('could not read FormData body as text') | ||
} else { | ||
return Promise.resolve(this._bodyText) | ||
} | ||
}; | ||
if (support.formData) { | ||
this.formData = function() { | ||
return this.text().then(decode) | ||
}; | ||
} | ||
this.json = function() { | ||
return this.text().then(JSON.parse) | ||
}; | ||
return this | ||
} | ||
// HTTP methods whose capitalization should be normalized | ||
var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT']; | ||
function normalizeMethod(method) { | ||
var upcased = method.toUpperCase(); | ||
return (methods.indexOf(upcased) > -1) ? upcased : method | ||
} | ||
function Request(input, options) { | ||
options = options || {}; | ||
var body = options.body; | ||
if (input instanceof Request) { | ||
if (input.bodyUsed) { | ||
throw new TypeError('Already read') | ||
} | ||
this.url = input.url; | ||
this.credentials = input.credentials; | ||
if (!options.headers) { | ||
this.headers = new Headers(input.headers); | ||
} | ||
this.method = input.method; | ||
this.mode = input.mode; | ||
if (!body && input._bodyInit != null) { | ||
body = input._bodyInit; | ||
input.bodyUsed = true; | ||
} | ||
} else { | ||
this.url = String(input); | ||
} | ||
this.credentials = options.credentials || this.credentials || 'omit'; | ||
if (options.headers || !this.headers) { | ||
this.headers = new Headers(options.headers); | ||
} | ||
this.method = normalizeMethod(options.method || this.method || 'GET'); | ||
this.mode = options.mode || this.mode || null; | ||
this.referrer = null; | ||
if ((this.method === 'GET' || this.method === 'HEAD') && body) { | ||
throw new TypeError('Body not allowed for GET or HEAD requests') | ||
} | ||
this._initBody(body); | ||
} | ||
Request.prototype.clone = function() { | ||
return new Request(this, { body: this._bodyInit }) | ||
}; | ||
function decode(body) { | ||
var form = new FormData(); | ||
body.trim().split('&').forEach(function(bytes) { | ||
if (bytes) { | ||
var split = bytes.split('='); | ||
var name = split.shift().replace(/\+/g, ' '); | ||
var value = split.join('=').replace(/\+/g, ' '); | ||
form.append(decodeURIComponent(name), decodeURIComponent(value)); | ||
} | ||
}); | ||
return form | ||
} | ||
function parseHeaders(rawHeaders) { | ||
var headers = new Headers(); | ||
// Replace instances of \r\n and \n followed by at least one space or horizontal tab with a space | ||
// https://tools.ietf.org/html/rfc7230#section-3.2 | ||
var preProcessedHeaders = rawHeaders.replace(/\r?\n[\t ]+/g, ' '); | ||
preProcessedHeaders.split(/\r?\n/).forEach(function(line) { | ||
var parts = line.split(':'); | ||
var key = parts.shift().trim(); | ||
if (key) { | ||
var value = parts.join(':').trim(); | ||
headers.append(key, value); | ||
} | ||
}); | ||
return headers | ||
} | ||
Body.call(Request.prototype); | ||
function Response(bodyInit, options) { | ||
if (!options) { | ||
options = {}; | ||
} | ||
this.type = 'default'; | ||
this.status = options.status === undefined ? 200 : options.status; | ||
this.ok = this.status >= 200 && this.status < 300; | ||
this.statusText = 'statusText' in options ? options.statusText : 'OK'; | ||
this.headers = new Headers(options.headers); | ||
this.url = options.url || ''; | ||
this._initBody(bodyInit); | ||
} | ||
Body.call(Response.prototype); | ||
Response.prototype.clone = function() { | ||
return new Response(this._bodyInit, { | ||
status: this.status, | ||
statusText: this.statusText, | ||
headers: new Headers(this.headers), | ||
url: this.url | ||
}) | ||
}; | ||
Response.error = function() { | ||
var response = new Response(null, {status: 0, statusText: ''}); | ||
response.type = 'error'; | ||
return response | ||
}; | ||
var redirectStatuses = [301, 302, 303, 307, 308]; | ||
Response.redirect = function(url, status) { | ||
if (redirectStatuses.indexOf(status) === -1) { | ||
throw new RangeError('Invalid status code') | ||
} | ||
return new Response(null, {status: status, headers: {location: url}}) | ||
}; | ||
self.Headers = Headers; | ||
self.Request = Request; | ||
self.Response = Response; | ||
self.fetch = function(input, init) { | ||
return new Promise(function(resolve, reject) { | ||
var request = new Request(input, init); | ||
var xhr = new XMLHttpRequest(); | ||
xhr.onload = function() { | ||
var options = { | ||
status: xhr.status, | ||
statusText: xhr.statusText, | ||
headers: parseHeaders(xhr.getAllResponseHeaders() || '') | ||
}; | ||
options.url = 'responseURL' in xhr ? xhr.responseURL : options.headers.get('X-Request-URL'); | ||
var body = 'response' in xhr ? xhr.response : xhr.responseText; | ||
resolve(new Response(body, options)); | ||
}; | ||
xhr.onerror = function() { | ||
reject(new TypeError('Network request failed')); | ||
}; | ||
xhr.ontimeout = function() { | ||
reject(new TypeError('Network request failed')); | ||
}; | ||
xhr.open(request.method, request.url, true); | ||
if (request.credentials === 'include') { | ||
xhr.withCredentials = true; | ||
} else if (request.credentials === 'omit') { | ||
xhr.withCredentials = false; | ||
} | ||
if ('responseType' in xhr && support.blob) { | ||
xhr.responseType = 'blob'; | ||
} | ||
request.headers.forEach(function(value, name) { | ||
xhr.setRequestHeader(name, value); | ||
}); | ||
xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit); | ||
}) | ||
}; | ||
self.fetch.polyfill = true; | ||
})(typeof self !== 'undefined' ? self : undefined); | ||
(function (RPCMethod) { | ||
@@ -254,2 +723,3 @@ // Network-related methods | ||
// Contract-related methods | ||
RPCMethod["GetContractAddressFromTransactionID"] = "GetContractAddressFromTransactionID"; | ||
RPCMethod["GetSmartContracts"] = "GetSmartContracts"; | ||
@@ -260,3 +730,3 @@ RPCMethod["GetSmartContractCode"] = "GetSmartContractCode"; | ||
RPCMethod["GetSmartContractSubState"] = "GetSmartContractSubState"; | ||
RPCMethod["GetContractAddressFromTransactionID"] = "GetContractAddressFromTransactionID"; | ||
RPCMethod["GetStateProof"] = "GetStateProof"; | ||
// Account-related methods | ||
@@ -613,3 +1083,2 @@ RPCMethod["GetBalance"] = "GetBalance"; | ||
this.emit = this.emitter.emit.bind(this); | ||
// tslint:disable-next-line: no-empty | ||
this.promise = new Promise(function (resolve, reject) { | ||
@@ -622,3 +1091,2 @@ _this.resolve = resolve; | ||
EventEmitter.prototype.resetHandlers = function () { | ||
// tslint:disable-next-line: forin | ||
for (var i in this.handlers) { | ||
@@ -625,0 +1093,0 @@ delete this.handlers[i]; |
@@ -0,1 +1,2 @@ | ||
import 'cross-fetch/polyfill'; | ||
import { WithRequest } from './util'; | ||
@@ -36,2 +37,3 @@ /** | ||
GetMinimumGasPrice = "GetMinimumGasPrice", | ||
GetContractAddressFromTransactionID = "GetContractAddressFromTransactionID", | ||
GetSmartContracts = "GetSmartContracts", | ||
@@ -42,3 +44,3 @@ GetSmartContractCode = "GetSmartContractCode", | ||
GetSmartContractSubState = "GetSmartContractSubState", | ||
GetContractAddressFromTransactionID = "GetContractAddressFromTransactionID", | ||
GetStateProof = "GetStateProof", | ||
GetBalance = "GetBalance" | ||
@@ -45,0 +47,0 @@ } |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.performBatchRPC = exports.performRPC = exports.RPCErrorCode = exports.RPCMethod = void 0; | ||
var tslib_1 = require("tslib"); | ||
// Copyright (C) 2018 Zilliqa | ||
@@ -18,5 +21,3 @@ // | ||
// along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
var tslib_1 = require("tslib"); | ||
var cross_fetch_1 = tslib_1.__importDefault(require("cross-fetch")); | ||
require("cross-fetch/polyfill"); | ||
/** | ||
@@ -61,2 +62,3 @@ * blockchain-side. | ||
// Contract-related methods | ||
RPCMethod["GetContractAddressFromTransactionID"] = "GetContractAddressFromTransactionID"; | ||
RPCMethod["GetSmartContracts"] = "GetSmartContracts"; | ||
@@ -67,3 +69,3 @@ RPCMethod["GetSmartContractCode"] = "GetSmartContractCode"; | ||
RPCMethod["GetSmartContractSubState"] = "GetSmartContractSubState"; | ||
RPCMethod["GetContractAddressFromTransactionID"] = "GetContractAddressFromTransactionID"; | ||
RPCMethod["GetStateProof"] = "GetStateProof"; | ||
// Account-related methods | ||
@@ -105,3 +107,3 @@ RPCMethod["GetBalance"] = "GetBalance"; | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, cross_fetch_1.default(request.url, { | ||
return [4 /*yield*/, fetch(request.url, { | ||
method: 'POST', | ||
@@ -137,3 +139,3 @@ cache: 'no-cache', | ||
_a.trys.push([0, 2, , 3]); | ||
return [4 /*yield*/, cross_fetch_1.default(request.url, { | ||
return [4 /*yield*/, fetch(request.url, { | ||
method: 'POST', | ||
@@ -140,0 +142,0 @@ cache: 'no-cache', |
@@ -19,2 +19,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.BaseProvider = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -21,0 +22,0 @@ var MiddlewareType; |
@@ -19,2 +19,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.HTTPProvider = void 0; | ||
var tslib_1 = require("tslib"); | ||
@@ -21,0 +22,0 @@ var base_1 = require("./base"); |
@@ -169,10 +169,10 @@ /// <reference types="node" /> | ||
export interface TransactionReceiptObj<TGas = string> { | ||
accepted: boolean; | ||
accepted?: boolean; | ||
cumulative_gas: TGas; | ||
epoch_num: string; | ||
event_logs: EventLogEntry[]; | ||
exceptions: ExceptionEntry[]; | ||
event_logs?: EventLogEntry[]; | ||
exceptions?: ExceptionEntry[]; | ||
success: boolean; | ||
transitions: TransitionEntry[]; | ||
errors: any; | ||
transitions?: TransitionEntry[]; | ||
errors?: any; | ||
} | ||
@@ -179,0 +179,0 @@ export interface ExceptionEntry { |
@@ -19,2 +19,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.TransactionError = exports.Signer = void 0; | ||
var Signer = /** @class */ (function () { | ||
@@ -21,0 +22,0 @@ function Signer() { |
@@ -19,2 +19,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.composeMiddleware = exports.isValidResponse = void 0; | ||
function isValidResponse(response) { | ||
@@ -21,0 +22,0 @@ if (response.jsonrpc === '2.0' && |
{ | ||
"name": "@zilliqa-js/core", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Core abstractions that power the zilliqa JS client.", | ||
@@ -28,11 +28,17 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@zilliqa-js/crypto": "3.0.0", | ||
"@zilliqa-js/util": "3.0.0", | ||
"cross-fetch": "^2.2.2", | ||
"cross-fetch": "2.2.5", | ||
"mitt": "^1.1.3" | ||
}, | ||
"files": [ | ||
"dist", | ||
"node_modules", | ||
"package.json", | ||
"LICENSE", | ||
"CHANGELOG.md", | ||
"README.md" | ||
], | ||
"engines": { | ||
"node": ">=12.0.0 <15" | ||
}, | ||
"gitHead": "832bcaf3a930a7257e009481c0c76dc27e39450a" | ||
"gitHead": "5812a8d2199d8f4ff584dfd343b91cac3ee0dbbc" | ||
} |
# @zilliqa-js/core | ||
> Core abstractions required for interacting with the blockchain. | ||
# Interfaces | ||
```typescript | ||
// valid RPC methods | ||
const enum RPCMethod { | ||
GetNetworkId = 'GetNetworkId', | ||
// Blockchain-related methods | ||
GetBlockchainInfo = 'GetBlockchainInfo', | ||
GetShardingStructure = 'GetShardingStructure', | ||
GetDSBlock = 'GetDSBlock', | ||
GetLatestDSBlock = 'GetLatestDsBlock', | ||
GetNumDSBlocks = 'GetNumDSBlocks', | ||
GetDSBlockRate = 'GetDSBlockRate', | ||
DSBlockListing = 'DSBlockListing', | ||
GetTxBlock = 'GetTSBlock', | ||
GetLatestTxBlock = 'GetLatestTxBlock', | ||
GetNumTxBlocks = 'GetNumTxBlocks', | ||
GetTxBlockRate = 'GetTxBlockRate', | ||
TxBlockListing = 'TxBlockListing', | ||
GetNumTransactions = 'GetNumTransactions', | ||
GetTransactionRate = 'GetTransactionRate', | ||
GetCurrentMiniEpoch = 'GetCurrentMiniEpoch', | ||
GetCurrentDSEpoch = 'GetCurrentDSEpoch', | ||
// Transaction-related methods | ||
CreateTransaction = 'CreateTransaction', | ||
GetTransaction = 'GetTransaction', | ||
GetRecentTransactions = 'GetRecentTransactions', | ||
GetNumTxnsTxEpoch = 'GetNumTxnsTxEpoch', | ||
GetNumTxnsDSEpoch = 'GetNumTxnsDSEpoch', | ||
// Contract-related methods | ||
GetSmartContractCode = 'GetSmartContractCode', | ||
GetSmartContractInit = 'GetSmartContractInit', | ||
GetSmartContractState = 'GetSmartContractState', | ||
GetSmartContractSubState = 'GetSmartContractSubState', | ||
GetContractAddressFromTransactionID = 'GetContractAddressFromTransactionID', | ||
// Account-related methods | ||
GetBalance = 'GetBalance', | ||
``` | ||
```typescript | ||
export type Transformer<I, O> = (payload: I) => O; | ||
export type WithRequest<T, I = any> = T & { req: RPCRequest<I> }; | ||
export type ReqMiddlewareFn<I = any, O = any> = Transformer< | ||
RPCRequest<I>, | ||
RPCRequest<O> | ||
>; | ||
export type ResMiddlewareFn<I = any, O = any, E = any> = Transformer< | ||
WithRequest<RPCResponse<I, E>>, | ||
WithRequest<RPCResponse<O, E>> | ||
>; | ||
``` | ||
# Classes | ||
@@ -64,0 +6,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2
6
377512
47
3222
142
+ Addedcross-fetch@2.2.5(transitive)
+ Addednode-fetch@2.6.1(transitive)
- Removed@zilliqa-js/crypto@3.0.0
- Removed@zilliqa-js/util@3.0.0
- Removed@types/bn.js@4.11.6(transitive)
- Removed@types/long@4.0.2(transitive)
- Removed@types/node@22.9.3(transitive)
- Removed@zilliqa-js/crypto@3.0.0(transitive)
- Removed@zilliqa-js/util@3.0.0(transitive)
- Removedaes-js@3.1.2(transitive)
- Removedbn.js@4.12.1(transitive)
- Removedbrorand@1.1.0(transitive)
- Removedbsert@0.0.4(transitive)
- Removedcipher-base@1.0.5(transitive)
- Removedcreate-hash@1.2.0(transitive)
- Removedcreate-hmac@1.1.7(transitive)
- Removedcross-fetch@2.2.6(transitive)
- Removedelliptic@6.6.1(transitive)
- Removedhash-base@3.1.0(transitive)
- Removedhash.js@1.1.7(transitive)
- Removedhmac-drbg@1.0.1(transitive)
- Removedinherits@2.0.4(transitive)
- Removedlong@4.0.0(transitive)
- Removedmd5.js@1.3.5(transitive)
- Removedminimalistic-assert@1.0.1(transitive)
- Removedminimalistic-crypto-utils@1.0.1(transitive)
- Removednode-fetch@2.7.0(transitive)
- Removednode-gyp-build@4.8.4(transitive)
- Removedpbkdf2@3.1.2(transitive)
- Removedrandombytes@2.1.0(transitive)
- Removedreadable-stream@3.6.2(transitive)
- Removedripemd160@2.0.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedscrypt-js@3.0.1(transitive)
- Removedscryptsy@2.1.0(transitive)
- Removedsha.js@2.4.11(transitive)
- Removedsodium-native@3.4.1(transitive)
- Removedstring_decoder@1.3.0(transitive)
- Removedtr46@0.0.3(transitive)
- Removedundici-types@6.19.8(transitive)
- Removedutil-deprecate@1.0.2(transitive)
- Removeduuid@3.4.0(transitive)
- Removedwebidl-conversions@3.0.1(transitive)
- Removedwhatwg-url@5.0.0(transitive)
Updatedcross-fetch@2.2.5