@polkadot-api/json-rpc-provider-proxy
Advanced tools
Comparing version 0.0.1-5f0fe49a72a058a62aaac5040bea83d67b0f32a5.1.0 to 0.0.1-96a7256a941fdbff1f549302cf9f3b8fcd10dba7.1.0
@@ -217,2 +217,4 @@ "use strict"; | ||
pendingResponses.clear(); | ||
if (!provider) | ||
throw null; | ||
const result = start(); | ||
@@ -264,6 +266,6 @@ subscriptionManager.onAbort().forEach((msg) => { | ||
provider = null; | ||
input2.disconnect(); | ||
input2?.disconnect(); | ||
}; | ||
if (provider instanceof Promise) { | ||
provider.then(finishIt); | ||
provider.then(finishIt, finishIt); | ||
provider = null; | ||
@@ -270,0 +272,0 @@ } else |
@@ -217,2 +217,4 @@ "use strict"; | ||
pendingResponses.clear(); | ||
if (!provider) | ||
throw null; | ||
const result = start(); | ||
@@ -264,6 +266,6 @@ subscriptionManager.onAbort().forEach((msg) => { | ||
provider = null; | ||
input2.disconnect(); | ||
input2?.disconnect(); | ||
}; | ||
if (provider instanceof Promise) { | ||
provider.then(finishIt); | ||
provider.then(finishIt, finishIt); | ||
provider = null; | ||
@@ -270,0 +272,0 @@ } else |
@@ -1,2 +0,2 @@ | ||
"use strict";var d=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var O=(n,t)=>{for(var e in t)d(n,e,{get:t[e],enumerable:!0})},R=(n,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of E(t))!I.call(n,o)&&o!==e&&d(n,o,{get:()=>t[o],enumerable:!(a=_(t,o))||a.enumerable});return n};var M=n=>R(d({},"__esModule",{value:!0}),n);var q={};O(q,{getSyncProvider:()=>D});module.exports=M(q);var N="chainHead_unstable_follow",H="chainHead_unstable_unfollow",m="chainHead_unstable_followEvent",y="stop",w=new Set([y,"operationInaccessible","operationError"]),S={onSent(n){return n.method===N?{type:"subscribe",id:n.id,onRes:t=>t.id===n.id?{id:t.result}:null}:n.method===H?{type:"unsubscribe",id:Object.values(n.params)[0]}:null},onNotification(n){return n.method!==m?null:w.has(n.params.result.event)?{type:"end",id:n.params.subscription}:null},onAbort:n=>({jsonrpc:"2.0",method:m,params:{subscription:n,result:{event:y}}})};var x="transaction_unstable_submitAndWatch",C="transaction_unstable_unwatch",g="transaction_unstable_watchEvent",h="dropped",J=new Set([h,"finalized","error","invalid"]),v={onSent(n){return n.method===x?{type:"subscribe",id:n.id,onRes:t=>t.id===n.id?{id:t.result}:null}:n.method===C?{type:"unsubscribe",id:Object.values(n.params)[0]}:null},onNotification(n){return n.method!==g?null:J.has(n.params.result.event)?{type:"end",id:n.params.subscription}:null},onAbort:n=>({jsonrpc:"2.0",method:g,params:{subscription:n,result:{event:h}}})};var j=({onSent:n,onNotification:t,onAbort:e})=>{let a=new Map,o=new Set;return{onSent(r){let c=n(r);c&&(c.type==="subscribe"?a.set(c.id,c.onRes):o.delete(c.id))},onResponse(r){let c=a.get(r.id)?.(r);c&&(a.delete(r.id),o.add(c.id))},onNotifiaction(r){let c=t(r);c&&o.delete(c.id)},onAbort(){a.clear();let r=[...o].map(e);return o.clear(),r}}},A=()=>{let n=[S,v].map(t=>j(t));return{onSent(t){n.forEach(e=>{e.onSent(t)})},onResponse(t){n.forEach(e=>{e.onResponse(t)})},onNotifiaction(t){n.forEach(e=>{e.onNotifiaction(t)})},onAbort(){return n.map(t=>t.onAbort()).flat()}}};var D=n=>t=>{let e,a=[],o=new Set,r=A(),c=s=>{let i;try{i=JSON.parse(s)}catch{console.error(`Unable to parse incoming message: ${s}`);return}i.id!==void 0?(o.delete(i.id),r.onResponse(i)):r.onNotifiaction(i),t(s)},P=s=>{if(!e)return;let i=JSON.parse(s);r.onSent(i),i.id&&o.add(i.id),e instanceof Promise?a.push(s):e.send(s)},p=()=>{a=[];let s=[...o];o.clear();let i=b();return r.onAbort().forEach(u=>{t(JSON.stringify(u))}),s.forEach(u=>{t(JSON.stringify({jsonrpc:"2.0",error:{code:-32603,message:"Internal error"},id:u}))}),i},b=()=>{let s=i=>{let u=!1,f=i(l=>{u||c(l)},()=>{u||(u=!0,p())});return a.forEach(l=>{f.send(l)}),a=[],e=f};return e=n().then(s,L(p)),e},T=()=>{if(!e)return;let s=i=>{r.onAbort(),o.clear(),e=null,i.disconnect()};e instanceof Promise?(e.then(s),e=null):s(e)};return b(),{send:P,disconnect:T}},L=n=>(...t)=>new Promise(e=>setTimeout(e,0)).then(()=>n(...t)); | ||
"use strict";var d=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var I=Object.prototype.hasOwnProperty;var O=(n,t)=>{for(var e in t)d(n,e,{get:t[e],enumerable:!0})},R=(n,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of E(t))!I.call(n,o)&&o!==e&&d(n,o,{get:()=>t[o],enumerable:!(a=_(t,o))||a.enumerable});return n};var M=n=>R(d({},"__esModule",{value:!0}),n);var q={};O(q,{getSyncProvider:()=>D});module.exports=M(q);var N="chainHead_unstable_follow",w="chainHead_unstable_unfollow",m="chainHead_unstable_followEvent",y="stop",H=new Set([y,"operationInaccessible","operationError"]),S={onSent(n){return n.method===N?{type:"subscribe",id:n.id,onRes:t=>t.id===n.id?{id:t.result}:null}:n.method===w?{type:"unsubscribe",id:Object.values(n.params)[0]}:null},onNotification(n){return n.method!==m?null:H.has(n.params.result.event)?{type:"end",id:n.params.subscription}:null},onAbort:n=>({jsonrpc:"2.0",method:m,params:{subscription:n,result:{event:y}}})};var x="transaction_unstable_submitAndWatch",C="transaction_unstable_unwatch",h="transaction_unstable_watchEvent",g="dropped",J=new Set([g,"finalized","error","invalid"]),v={onSent(n){return n.method===x?{type:"subscribe",id:n.id,onRes:t=>t.id===n.id?{id:t.result}:null}:n.method===C?{type:"unsubscribe",id:Object.values(n.params)[0]}:null},onNotification(n){return n.method!==h?null:J.has(n.params.result.event)?{type:"end",id:n.params.subscription}:null},onAbort:n=>({jsonrpc:"2.0",method:h,params:{subscription:n,result:{event:g}}})};var j=({onSent:n,onNotification:t,onAbort:e})=>{let a=new Map,o=new Set;return{onSent(r){let c=n(r);c&&(c.type==="subscribe"?a.set(c.id,c.onRes):o.delete(c.id))},onResponse(r){let c=a.get(r.id)?.(r);c&&(a.delete(r.id),o.add(c.id))},onNotifiaction(r){let c=t(r);c&&o.delete(c.id)},onAbort(){a.clear();let r=[...o].map(e);return o.clear(),r}}},A=()=>{let n=[S,v].map(t=>j(t));return{onSent(t){n.forEach(e=>{e.onSent(t)})},onResponse(t){n.forEach(e=>{e.onResponse(t)})},onNotifiaction(t){n.forEach(e=>{e.onNotifiaction(t)})},onAbort(){return n.map(t=>t.onAbort()).flat()}}};var D=n=>t=>{let e,a=[],o=new Set,r=A(),c=i=>{let s;try{s=JSON.parse(i)}catch{console.error(`Unable to parse incoming message: ${i}`);return}s.id!==void 0?(o.delete(s.id),r.onResponse(s)):r.onNotifiaction(s),t(i)},P=i=>{if(!e)return;let s=JSON.parse(i);r.onSent(s),s.id&&o.add(s.id),e instanceof Promise?a.push(i):e.send(i)},p=()=>{a=[];let i=[...o];if(o.clear(),!e)throw null;let s=f();return r.onAbort().forEach(u=>{t(JSON.stringify(u))}),i.forEach(u=>{t(JSON.stringify({jsonrpc:"2.0",error:{code:-32603,message:"Internal error"},id:u}))}),s},f=()=>{let i=s=>{let u=!1,b=s(l=>{u||c(l)},()=>{u||(u=!0,p())});return a.forEach(l=>{b.send(l)}),a=[],e=b};return e=n().then(i,L(p)),e},T=()=>{if(!e)return;let i=s=>{r.onAbort(),o.clear(),e=null,s?.disconnect()};e instanceof Promise?(e.then(i,i),e=null):i(e)};return f(),{send:P,disconnect:T}},L=n=>(...t)=>new Promise(e=>setTimeout(e,0)).then(()=>n(...t)); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@polkadot-api/json-rpc-provider-proxy", | ||
"version": "0.0.1-5f0fe49a72a058a62aaac5040bea83d67b0f32a5.1.0", | ||
"version": "0.0.1-96a7256a941fdbff1f549302cf9f3b8fcd10dba7.1.0", | ||
"author": "Josep M Sobrepere (https://github.com/josepot)", | ||
@@ -43,3 +43,3 @@ "repository": { | ||
"devDependencies": { | ||
"@polkadot-api/json-rpc-provider": "0.0.1-5f0fe49a72a058a62aaac5040bea83d67b0f32a5.1.0" | ||
"@polkadot-api/json-rpc-provider": "0.0.1-96a7256a941fdbff1f549302cf9f3b8fcd10dba7.1.0" | ||
}, | ||
@@ -46,0 +46,0 @@ "scripts": { |
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
76180
1074