near-api-js 0.44.1 → 0.44.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/near-api-js.js +1 -1
- package/dist/near-api-js.min.js +1 -1
- package/lib/utils/web.js +1 -1
- package/package.json +1 -1
package/dist/near-api-js.js
CHANGED
|
@@ -3821,7 +3821,7 @@ async function fetchJson(connectionInfoOrUrl, json) {
|
|
|
3821
3821
|
const response = await fetch(connectionInfo.url, {
|
|
3822
3822
|
method: json ? 'POST' : 'GET',
|
|
3823
3823
|
body: json ? json : undefined,
|
|
3824
|
-
headers: { ...connectionInfo.headers, 'Content-Type': 'application/json
|
|
3824
|
+
headers: { ...connectionInfo.headers, 'Content-Type': 'application/json' }
|
|
3825
3825
|
});
|
|
3826
3826
|
if (!response.ok) {
|
|
3827
3827
|
if (response.status === 503) {
|
package/dist/near-api-js.min.js
CHANGED
|
@@ -1039,7 +1039,7 @@ module.exports={
|
|
|
1039
1039
|
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var borsh_1=require("borsh");Object.defineProperty(exports,"base_encode",{enumerable:!0,get:function(){return borsh_1.baseEncode}}),Object.defineProperty(exports,"base_decode",{enumerable:!0,get:function(){return borsh_1.baseDecode}}),Object.defineProperty(exports,"serialize",{enumerable:!0,get:function(){return borsh_1.serialize}}),Object.defineProperty(exports,"deserialize",{enumerable:!0,get:function(){return borsh_1.deserialize}}),Object.defineProperty(exports,"BorshError",{enumerable:!0,get:function(){return borsh_1.BorshError}}),Object.defineProperty(exports,"BinaryWriter",{enumerable:!0,get:function(){return borsh_1.BinaryWriter}}),Object.defineProperty(exports,"BinaryReader",{enumerable:!0,get:function(){return borsh_1.BinaryReader}});
|
|
1040
1040
|
|
|
1041
1041
|
},{"borsh":38}],32:[function(require,module,exports){
|
|
1042
|
-
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.fetchJson=void 0;const http_errors_1=__importDefault(require("http-errors")),exponential_backoff_1=__importDefault(require("./exponential-backoff")),providers_1=require("../providers"),errors_1=require("./errors"),START_WAIT_TIME_MS=1e3,BACKOFF_MULTIPLIER=1.5,RETRY_NUMBER=10;async function fetchJson(e,r){let t={url:null};"string"==typeof e?t.url=e:t=e;const o=await exponential_backoff_1.default(START_WAIT_TIME_MS,RETRY_NUMBER,BACKOFF_MULTIPLIER,async()=>{try{const e=await fetch(t.url,{method:r?"POST":"GET",body:r||void 0,headers:{...t.headers,"Content-Type":"application/json
|
|
1042
|
+
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.fetchJson=void 0;const http_errors_1=__importDefault(require("http-errors")),exponential_backoff_1=__importDefault(require("./exponential-backoff")),providers_1=require("../providers"),errors_1=require("./errors"),START_WAIT_TIME_MS=1e3,BACKOFF_MULTIPLIER=1.5,RETRY_NUMBER=10;async function fetchJson(e,r){let t={url:null};"string"==typeof e?t.url=e:t=e;const o=await exponential_backoff_1.default(START_WAIT_TIME_MS,RETRY_NUMBER,BACKOFF_MULTIPLIER,async()=>{try{const e=await fetch(t.url,{method:r?"POST":"GET",body:r||void 0,headers:{...t.headers,"Content-Type":"application/json"}});if(!e.ok){if(503===e.status)return errors_1.logWarning(`Retrying HTTP request for ${t.url} as it's not available now`),null;throw http_errors_1.default(e.status,await e.text())}return e}catch(e){if(e.toString().includes("FetchError")||e.toString().includes("Failed to fetch"))return errors_1.logWarning(`Retrying HTTP request for ${t.url} because of error: ${e}`),null;throw e}});if(!o)throw new providers_1.TypedError(`Exceeded ${RETRY_NUMBER} attempts for ${t.url}.`,"RetriesExceeded");return await o.json()}exports.fetchJson=fetchJson;
|
|
1043
1043
|
|
|
1044
1044
|
},{"../providers":18,"./errors":25,"./exponential-backoff":26,"http-errors":57}],33:[function(require,module,exports){
|
|
1045
1045
|
"use strict";var __importDefault=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(exports,"__esModule",{value:!0}),exports.diffEpochValidators=exports.findSeatPrice=void 0;const bn_js_1=__importDefault(require("bn.js")),depd_1=__importDefault(require("depd"));function findSeatPrice(e,t,a,r){if(r&&r<49)return findSeatPriceForProtocolBefore49(e,t);if(!a){depd_1.default("findSeatPrice(validators, maxNumberOfSeats)")("`use `findSeatPrice(validators, maxNumberOfSeats, minimumStakeRatio)` instead"),a=[1,6250]}return findSeatPriceForProtocolAfter49(e,t,a)}function findSeatPriceForProtocolBefore49(e,t){const a=e.map(e=>new bn_js_1.default(e.stake,10)).sort((e,t)=>e.cmp(t)),r=new bn_js_1.default(t),n=a.reduce((e,t)=>e.add(t));if(n.lt(r))throw new Error("Stakes are below seats");let o=new bn_js_1.default(1),d=n.add(new bn_js_1.default(1));for(;!o.eq(d.sub(new bn_js_1.default(1)));){const e=o.add(d).div(new bn_js_1.default(2));let t=!1,n=new bn_js_1.default(0);for(let d=0;d<a.length;++d)if((n=n.add(a[d].div(e))).gte(r)){o=e,t=!0;break}t||(d=e)}return o}function findSeatPriceForProtocolAfter49(e,t,a){if(2!=a.length)throw Error("minimumStakeRatio should have 2 elements");const r=e.map(e=>new bn_js_1.default(e.stake,10)).sort((e,t)=>e.cmp(t)),n=r.reduce((e,t)=>e.add(t));return e.length<t?n.mul(new bn_js_1.default(a[0])).div(new bn_js_1.default(a[1])):r[0].add(new bn_js_1.default(1))}function diffEpochValidators(e,t){const a=new Map;e.forEach(e=>a.set(e.account_id,e));const r=new Set(t.map(e=>e.account_id));return{newValidators:t.filter(e=>!a.has(e.account_id)),removedValidators:e.filter(e=>!r.has(e.account_id)),changedValidators:t.filter(e=>a.has(e.account_id)&&a.get(e.account_id).stake!=e.stake).map(e=>({current:a.get(e.account_id),next:e}))}}exports.findSeatPrice=findSeatPrice,exports.diffEpochValidators=diffEpochValidators;
|
package/lib/utils/web.js
CHANGED
|
@@ -24,7 +24,7 @@ async function fetchJson(connectionInfoOrUrl, json) {
|
|
|
24
24
|
const response = await fetch(connectionInfo.url, {
|
|
25
25
|
method: json ? 'POST' : 'GET',
|
|
26
26
|
body: json ? json : undefined,
|
|
27
|
-
headers: { ...connectionInfo.headers, 'Content-Type': 'application/json
|
|
27
|
+
headers: { ...connectionInfo.headers, 'Content-Type': 'application/json' }
|
|
28
28
|
});
|
|
29
29
|
if (!response.ok) {
|
|
30
30
|
if (response.status === 503) {
|
package/package.json
CHANGED