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