@stacks/network 4.2.0-beta.2 → 4.2.0-beta.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/package.json +29 -31
- package/dist/polyfill/index.js +0 -1
package/package.json
CHANGED
|
@@ -1,43 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacks/network",
|
|
3
|
-
"version": "4.2.0-beta.
|
|
3
|
+
"version": "4.2.0-beta.5",
|
|
4
4
|
"description": "Library for Stacks network operations",
|
|
5
|
-
"
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
"network"
|
|
9
|
-
],
|
|
10
|
-
"author": "yknl <yukanliao@gmail.com>",
|
|
11
|
-
"homepage": "https://blockstack.org",
|
|
12
|
-
"license": "GPL-3.0-or-later",
|
|
13
|
-
"files": [
|
|
14
|
-
"dist",
|
|
15
|
-
"src"
|
|
16
|
-
],
|
|
17
|
-
"publishConfig": {
|
|
18
|
-
"access": "public"
|
|
19
|
-
},
|
|
20
|
-
"repository": {
|
|
21
|
-
"type": "git",
|
|
22
|
-
"url": "git+https://github.com/blockstack/blockstack.js.git"
|
|
23
|
-
},
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": "Hiro Systems PBC (https://hiro.so)",
|
|
7
|
+
"homepage": "https://www.hiro.so/stacks-js",
|
|
24
8
|
"scripts": {
|
|
25
|
-
"
|
|
26
|
-
"build": "npm run clean && npm run build:cjs && npm run build:esm && npm run build:umd && npm run build:polyfill",
|
|
9
|
+
"build": "npm run clean && npm run build:cjs && npm run build:esm && npm run build:umd",
|
|
27
10
|
"build:cjs": "tsc -b tsconfig.build.json",
|
|
28
11
|
"build:esm": "tsc -p tsconfig.build.json --module ES6 --outDir ./dist/esm",
|
|
29
12
|
"build:umd": "NODE_OPTIONS=--max-old-space-size=8192 webpack --config webpack.config.js",
|
|
30
|
-
"build:polyfill": "NODE_OPTIONS=--max-old-space-size=8192 rollup -c ../../configs/rollup.config.js && rimraf dist/polyfill/dist",
|
|
31
13
|
"clean": "rimraf dist && tsc -b tsconfig.build.json --clean",
|
|
32
|
-
"typecheck": "tsc --noEmit",
|
|
33
|
-
"typecheck:watch": "npm run typecheck -- --watch",
|
|
34
14
|
"pack": "npm pack",
|
|
35
15
|
"prepublishOnly": "npm run test && NODE_ENV=production npm run build",
|
|
16
|
+
"start": "tsc -b tsconfig.build.json --watch --verbose",
|
|
36
17
|
"test": "jest",
|
|
37
|
-
"test:watch": "jest --watch --coverage=false"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"url": "https://github.com/blockstack/blockstack.js/issues"
|
|
18
|
+
"test:watch": "jest --watch --coverage=false",
|
|
19
|
+
"typecheck": "tsc --noEmit",
|
|
20
|
+
"typecheck:watch": "npm run typecheck -- --watch"
|
|
41
21
|
},
|
|
42
22
|
"dependencies": {
|
|
43
23
|
"@stacks/common": "^4.1.0",
|
|
@@ -58,11 +38,29 @@
|
|
|
58
38
|
"webpack-cli": "^4.6.0"
|
|
59
39
|
},
|
|
60
40
|
"sideEffects": false,
|
|
41
|
+
"publishConfig": {
|
|
42
|
+
"access": "public"
|
|
43
|
+
},
|
|
61
44
|
"typings": "dist/index.d.ts",
|
|
62
45
|
"main": "dist/index.js",
|
|
63
46
|
"module": "dist/esm/index.js",
|
|
64
|
-
"browser": "dist/polyfill/index.js",
|
|
65
47
|
"umd:main": "dist/umd/index.js",
|
|
66
48
|
"unpkg": "dist/umd/index.js",
|
|
67
|
-
"
|
|
49
|
+
"files": [
|
|
50
|
+
"dist",
|
|
51
|
+
"src"
|
|
52
|
+
],
|
|
53
|
+
"keywords": [
|
|
54
|
+
"blockstack",
|
|
55
|
+
"network",
|
|
56
|
+
"stacks"
|
|
57
|
+
],
|
|
58
|
+
"repository": {
|
|
59
|
+
"type": "git",
|
|
60
|
+
"url": "git+https://github.com/hirosystems/stacks.js.git"
|
|
61
|
+
},
|
|
62
|
+
"bugs": {
|
|
63
|
+
"url": "https://github.com/blockstack/blockstack.js/issues"
|
|
64
|
+
},
|
|
65
|
+
"gitHead": "b05e8a908bf48ff58f49765559d6b36cc87ef38f"
|
|
68
66
|
}
|
package/dist/polyfill/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
window.global=window;import{TransactionVersion as t,ChainID as e}from"@stacks/common/dist/polyfill";var r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};!function(t){!function(e){var r="URLSearchParams"in t,n="Symbol"in t&&"iterator"in Symbol,o="FileReader"in t&&"Blob"in t&&function(){try{return new Blob,!0}catch(t){return!1}}(),i="FormData"in t,s="ArrayBuffer"in t;if(s)var a=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],h=ArrayBuffer.isView||function(t){return t&&a.indexOf(Object.prototype.toString.call(t))>-1};function c(t){if("string"!=typeof t&&(t=String(t)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(t))throw new TypeError("Invalid character in header field name");return t.toLowerCase()}function l(t){return"string"!=typeof t&&(t=String(t)),t}function d(t){var e={next:function(){var e=t.shift();return{done:void 0===e,value:e}}};return n&&(e[Symbol.iterator]=function(){return e}),e}function u(t){this.map={},t instanceof u?t.forEach((function(t,e){this.append(e,t)}),this):Array.isArray(t)?t.forEach((function(t){this.append(t[0],t[1])}),this):t&&Object.getOwnPropertyNames(t).forEach((function(e){this.append(e,t[e])}),this)}function f(t){if(t.bodyUsed)return Promise.reject(new TypeError("Already read"));t.bodyUsed=!0}function p(t){return new Promise((function(e,r){t.onload=function(){e(t.result)},t.onerror=function(){r(t.error)}}))}function y(t){var e=new FileReader,r=p(e);return e.readAsArrayBuffer(t),r}function b(t){if(t.slice)return t.slice(0);var e=new Uint8Array(t.byteLength);return e.set(new Uint8Array(t)),e.buffer}function m(){return this.bodyUsed=!1,this._initBody=function(t){var e;this._bodyInit=t,t?"string"==typeof t?this._bodyText=t:o&&Blob.prototype.isPrototypeOf(t)?this._bodyBlob=t:i&&FormData.prototype.isPrototypeOf(t)?this._bodyFormData=t:r&&URLSearchParams.prototype.isPrototypeOf(t)?this._bodyText=t.toString():s&&o&&(e=t)&&DataView.prototype.isPrototypeOf(e)?(this._bodyArrayBuffer=b(t.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):s&&(ArrayBuffer.prototype.isPrototypeOf(t)||h(t))?this._bodyArrayBuffer=b(t):this._bodyText=t=Object.prototype.toString.call(t):this._bodyText="",this.headers.get("content-type")||("string"==typeof t?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):r&&URLSearchParams.prototype.isPrototypeOf(t)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},o&&(this.blob=function(){var t=f(this);if(t)return t;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?f(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(y)}),this.text=function(){var t,e,r,n=f(this);if(n)return n;if(this._bodyBlob)return t=this._bodyBlob,e=new FileReader,r=p(e),e.readAsText(t),r;if(this._bodyArrayBuffer)return Promise.resolve(function(t){for(var e=new Uint8Array(t),r=new Array(e.length),n=0;n<e.length;n++)r[n]=String.fromCharCode(e[n]);return r.join("")}(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},i&&(this.formData=function(){return this.text().then(g)}),this.json=function(){return this.text().then(JSON.parse)},this}u.prototype.append=function(t,e){t=c(t),e=l(e);var r=this.map[t];this.map[t]=r?r+", "+e:e},u.prototype.delete=function(t){delete this.map[c(t)]},u.prototype.get=function(t){return t=c(t),this.has(t)?this.map[t]:null},u.prototype.has=function(t){return this.map.hasOwnProperty(c(t))},u.prototype.set=function(t,e){this.map[c(t)]=l(e)},u.prototype.forEach=function(t,e){for(var r in this.map)this.map.hasOwnProperty(r)&&t.call(e,this.map[r],r,this)},u.prototype.keys=function(){var t=[];return this.forEach((function(e,r){t.push(r)})),d(t)},u.prototype.values=function(){var t=[];return this.forEach((function(e){t.push(e)})),d(t)},u.prototype.entries=function(){var t=[];return this.forEach((function(e,r){t.push([r,e])})),d(t)},n&&(u.prototype[Symbol.iterator]=u.prototype.entries);var w=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function v(t,e){var r,n,o=(e=e||{}).body;if(t instanceof v){if(t.bodyUsed)throw new TypeError("Already read");this.url=t.url,this.credentials=t.credentials,e.headers||(this.headers=new u(t.headers)),this.method=t.method,this.mode=t.mode,this.signal=t.signal,o||null==t._bodyInit||(o=t._bodyInit,t.bodyUsed=!0)}else this.url=String(t);if(this.credentials=e.credentials||this.credentials||"same-origin",!e.headers&&this.headers||(this.headers=new u(e.headers)),this.method=(r=e.method||this.method||"GET",n=r.toUpperCase(),w.indexOf(n)>-1?n:r),this.mode=e.mode||this.mode||null,this.signal=e.signal||this.signal,this.referrer=null,("GET"===this.method||"HEAD"===this.method)&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}function g(t){var e=new FormData;return t.trim().split("&").forEach((function(t){if(t){var r=t.split("="),n=r.shift().replace(/\+/g," "),o=r.join("=").replace(/\+/g," ");e.append(decodeURIComponent(n),decodeURIComponent(o))}})),e}function E(t,e){e||(e={}),this.type="default",this.status=void 0===e.status?200:e.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in e?e.statusText:"OK",this.headers=new u(e.headers),this.url=e.url||"",this._initBody(t)}v.prototype.clone=function(){return new v(this,{body:this._bodyInit})},m.call(v.prototype),m.call(E.prototype),E.prototype.clone=function(){return new E(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new u(this.headers),url:this.url})},E.error=function(){var t=new E(null,{status:0,statusText:""});return t.type="error",t};var A=[301,302,303,307,308];E.redirect=function(t,e){if(-1===A.indexOf(e))throw new RangeError("Invalid status code");return new E(null,{status:e,headers:{location:t}})},e.DOMException=t.DOMException;try{new e.DOMException}catch(t){e.DOMException=function(t,e){this.message=t,this.name=e;var r=Error(t);this.stack=r.stack},e.DOMException.prototype=Object.create(Error.prototype),e.DOMException.prototype.constructor=e.DOMException}function U(t,r){return new Promise((function(n,i){var s=new v(t,r);if(s.signal&&s.signal.aborted)return i(new e.DOMException("Aborted","AbortError"));var a=new XMLHttpRequest;function h(){a.abort()}a.onload=function(){var t,e,r={status:a.status,statusText:a.statusText,headers:(t=a.getAllResponseHeaders()||"",e=new u,t.replace(/\r?\n[\t ]+/g," ").split(/\r?\n/).forEach((function(t){var r=t.split(":"),n=r.shift().trim();if(n){var o=r.join(":").trim();e.append(n,o)}})),e)};r.url="responseURL"in a?a.responseURL:r.headers.get("X-Request-URL");var o="response"in a?a.response:a.responseText;n(new E(o,r))},a.onerror=function(){i(new TypeError("Network request failed"))},a.ontimeout=function(){i(new TypeError("Network request failed"))},a.onabort=function(){i(new e.DOMException("Aborted","AbortError"))},a.open(s.method,s.url,!0),"include"===s.credentials?a.withCredentials=!0:"omit"===s.credentials&&(a.withCredentials=!1),"responseType"in a&&o&&(a.responseType="blob"),s.headers.forEach((function(t,e){a.setRequestHeader(e,t)})),s.signal&&(s.signal.addEventListener("abort",h),a.onreadystatechange=function(){4===a.readyState&&s.signal.removeEventListener("abort",h)}),a.send(void 0===s._bodyInit?null:s._bodyInit)}))}U.polyfill=!0,t.fetch||(t.fetch=U,t.Headers=u,t.Request=v,t.Response=E),e.Headers=u,e.Request=v,e.Response=E,e.fetch=U,Object.defineProperty(e,"__esModule",{value:!0})}({})}("undefined"!=typeof self?self:r);const n={referrerPolicy:"origin"},o=()=>n,i=t=>Object.assign(n,t);async function s(t,e){const r={};Object.assign(r,e,n);return await fetch(t,r)}function a(t,e){return"string"==typeof e?e===t:e.exec(t)}function h({apiKey:t,host:e=/(.*)api(.*)\.stacks\.co$/i,httpHeader:r="x-api-key"}){return{pre:n=>{if(!a(new URL(n.url).host,e))return;const o=new Headers(n.init.headers);o.set(r,t),n.init.headers=o}}}function c(...t){const{fetchLib:e,middlewares:r}=function(t){let e=s,r=[];return t.length>0&&"function"==typeof t[0]&&(e=t.shift()),t.length>0&&(r=t),{fetchLib:e,middlewares:r}}(t);return async(t,n)=>{var o;let i={url:t,init:null!=n?n:{}};for(const t of r)if("function"==typeof t.pre){const r=await Promise.resolve(t.pre(Object.assign({fetch:e},i)));i=null!=r?r:i}let s=await e(i.url,i.init);for(const t of r)if("function"==typeof t.post){const r=await Promise.resolve(t.post({fetch:e,url:i.url,init:i.init,response:null!==(o=null==s?void 0:s.clone())&&void 0!==o?o:s}));s=null!=r?r:s}return s}}const l="https://stacks-node-api.mainnet.stacks.co",d="https://stacks-node-api.testnet.stacks.co",u="http://localhost:3999",f=["mainnet","testnet"];class p{constructor(r){var n;this.version=t.Mainnet,this.chainId=e.Mainnet,this.bnsLookupUrl="https://stacks-node-api.mainnet.stacks.co",this.broadcastEndpoint="/v2/transactions",this.transferFeeEstimateEndpoint="/v2/fees/transfer",this.transactionFeeEstimateEndpoint="/v2/fees/transaction",this.accountEndpoint="/v2/accounts",this.contractAbiEndpoint="/v2/contracts/interface",this.readOnlyFunctionCallEndpoint="/v2/contracts/call-read",this.isMainnet=()=>this.version===t.Mainnet,this.getBroadcastApiUrl=()=>`${this.coreApiUrl}${this.broadcastEndpoint}`,this.getTransferFeeEstimateApiUrl=()=>`${this.coreApiUrl}${this.transferFeeEstimateEndpoint}`,this.getTransactionFeeEstimateApiUrl=()=>`${this.coreApiUrl}${this.transactionFeeEstimateEndpoint}`,this.getAccountApiUrl=t=>`${this.coreApiUrl}${this.accountEndpoint}/${t}?proof=0`,this.getAbiApiUrl=(t,e)=>`${this.coreApiUrl}${this.contractAbiEndpoint}/${t}/${e}`,this.getReadOnlyFunctionCallApiUrl=(t,e,r)=>`${this.coreApiUrl}${this.readOnlyFunctionCallEndpoint}/${t}/${e}/${encodeURIComponent(r)}`,this.getInfoUrl=()=>`${this.coreApiUrl}/v2/info`,this.getBlockTimeInfoUrl=()=>`${this.coreApiUrl}/extended/v1/info/network_block_times`,this.getPoxInfoUrl=()=>`${this.coreApiUrl}/v2/pox`,this.getRewardsUrl=(t,e)=>{let r=`${this.coreApiUrl}/extended/v1/burnchain/rewards/${t}`;return e&&(r=`${r}?limit=${e.limit}&offset=${e.offset}`),r},this.getRewardsTotalUrl=t=>`${this.coreApiUrl}/extended/v1/burnchain/rewards/${t}/total`,this.getRewardHoldersUrl=(t,e)=>{let r=`${this.coreApiUrl}/extended/v1/burnchain/reward_slot_holders/${t}`;return e&&(r=`${r}?limit=${e.limit}&offset=${e.offset}`),r},this.getStackerInfoUrl=(t,e)=>`${this.coreApiUrl}${this.readOnlyFunctionCallEndpoint}\n ${t}/${e}/get-stacker-info`,this.coreApiUrl=r.url,this.fetchFn=null!==(n=r.fetchFn)&&void 0!==n?n:c()}getNameInfo(t){const e=`${this.bnsLookupUrl}/v1/names/${t}`;return this.fetchFn(e).then((t=>{if(404===t.status)throw new Error("Name not found");if(200!==t.status)throw new Error(`Bad response status: ${t.status}`);return t.json()})).then((t=>t.address?Object.assign({},t,{address:t.address}):t))}}p.fromName=t=>{switch(t){case"mainnet":return new y;case"testnet":return new b;default:throw new Error(`Invalid network name provided. Must be one of the following: ${f.join(", ")}`)}},p.fromNameOrNetwork=t=>"string"!=typeof t&&"version"in t?t:p.fromName(t);class y extends p{constructor(r){var n;super({url:null!==(n=null==r?void 0:r.url)&&void 0!==n?n:"https://stacks-node-api.mainnet.stacks.co",fetchFn:null==r?void 0:r.fetchFn}),this.version=t.Mainnet,this.chainId=e.Mainnet}}class b extends p{constructor(r){var n;super({url:null!==(n=null==r?void 0:r.url)&&void 0!==n?n:"https://stacks-node-api.testnet.stacks.co",fetchFn:null==r?void 0:r.fetchFn}),this.version=t.Testnet,this.chainId=e.Testnet}}class m extends p{constructor(r){var n;super({url:null!==(n=null==r?void 0:r.url)&&void 0!==n?n:"http://localhost:3999",fetchFn:null==r?void 0:r.fetchFn}),this.version=t.Testnet,this.chainId=e.Testnet}}export{l as HIRO_MAINNET_DEFAULT,u as HIRO_MOCKNET_DEFAULT,d as HIRO_TESTNET_DEFAULT,y as StacksMainnet,m as StacksMocknet,p as StacksNetwork,f as StacksNetworks,b as StacksTestnet,h as createApiKeyMiddleware,c as createFetchFn,s as fetchWrapper,o as getFetchOptions,a as hostMatches,i as setFetchOptions};
|