polkadot-api 1.6.5 → 1.6.6
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(
|
|
1
|
+
(function(y,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(y=typeof globalThis<"u"?globalThis:y||self,E(y.papiWsProviderWeb={}))})(this,function(y){"use strict";const E=n=>JSON.stringify({jsonrpc:"2.0",...n}),H=new Set(["v1","unstable"].map(n=>`chainHead_${n}_unfollow`)),P=n=>{let e={type:1,pending:[]};const s=o=>{if(e.type===0){const t=JSON.parse(o);if("id"in t)e.onGoingRequests.get(t.id)?.type===0&&e.activeChainHeads.add(t.result),e.onGoingRequests.delete(t.id);else{const{subscription:d,result:r}=t.params;r?.event==="stop"&&e.activeChainHeads.delete(d)}}e.type!==2&&n(o)},i=o=>{if(e.type===2)return;if(e.type===1){e.pending.push(o);return}const t=JSON.parse(o);if(H.has(t.method)&&e.activeChainHeads.delete(t.params[0]),"id"in t){const{method:d,id:r}=t,h=d.startsWith("chainHead")?d.endsWith("follow")?{type:0,msg:o}:{type:1,id:r}:{type:2,msg:o};e.onGoingRequests.set(r,h)}e.connection.send(o)};return{send:i,disconnect:()=>{e.type!==2&&(e.type===0&&e.connection.disconnect(),e={type:2})},connect:o=>{if(e.type!==1)throw new Error("Nonesense");const{pending:t}=e,d=new Map,r=new Set;e={type:0,connection:o(s,()=>{e={type:1,pending:[]},r.forEach(p=>{s(E({params:{subscription:p,result:{event:"stop",internal:!0}}}))}),r.clear();for(const p of d.values())p.type===1?s(E({id:p.id,error:{code:-32603,message:"Internal error"},internal:!0})):i(p.msg);d.clear()}),onGoingRequests:d,activeChainHeads:r},t.forEach(i)}}},G=n=>e=>{let s=P(e);const i=()=>{n().then(o=>{if(s)s.connect((t,d)=>o(t,()=>{d(),i()}));else try{o(()=>{},()=>{}).disconnect()}catch{}},()=>{s&&setTimeout(i,0)})};return i(),{send:o=>{s?.send(o)},disconnect:()=>{s?.disconnect(),s=null}}};var l=(n=>(n[n.CONNECTING=0]="CONNECTING",n[n.CONNECTED=1]="CONNECTED",n[n.ERROR=2]="ERROR",n[n.CLOSE=3]="CLOSE",n))(l||{});const w={type:l.ERROR,event:{type:"timeout"}},R=()=>{},T=n=>n.map(e=>typeof e=="string"?[e]:[e.uri,e.protocol]),I=(n=>(...e)=>{let s=[],i=R,o=3500;const[t]=e;e.length===1&&typeof t=="object"&&!Array.isArray(t)?(s=T(t.endpoints),i=t.onStatusChanged??R,o=t.timeout??o):(typeof e[1]=="function"&&(i=e[1]),Array.isArray(t)?s=T(t):(s=[[t]],e[1]&&e[1]!==i&&(s[0][1]=e[1]),e[2]&&(i=e[2])));let d=0,r,h=null,p=R;const N=G(async()=>{const[u,C]=h||s[d++%s.length];h=null;const a=new n(u,C),S=()=>{try{a.close()}catch{}};return i(r={type:l.CONNECTING,uri:u,protocols:C}),await new Promise((L,g)=>{const m=()=>{f(),L()},v=c=>{f(),c==null&&S(),console.error(`Unable to connect to ${u}${C?", protocols: "+C:""}`),i(r={type:c?l.ERROR:l.CLOSE,event:c}),setTimeout(g,c?300:0,c)},O=o!==1/0?setTimeout(()=>{f(),S(),i(r=w),g(w.event)},o):void 0,f=()=>{clearTimeout(O),a.removeEventListener("error",v),a.removeEventListener("open",m)};a.addEventListener("open",m),a.addEventListener("error",v),p=()=>{v(null)}}),i(r={type:l.CONNECTED,uri:u,protocols:C}),(L,g)=>{const m=c=>{typeof c.data=="string"&&L(c.data)},v=c=>b=>{console.warn(`WS halt (${c})`),i(r={type:c,event:b}),g()},O=v(l.ERROR),f=v(l.CLOSE);return a.addEventListener("message",m),a.addEventListener("error",O),a.addEventListener("close",f),p=c=>{p=R,a.removeEventListener("message",m),a.removeEventListener("error",O),a.removeEventListener("close",f),S(),c&&f({})},{send:c=>{a.send(c)},disconnect:p}}});return N.getStatus=()=>r,N.switch=(...u)=>{r.type!==l.CLOSE&&(u.length&&(h=u),r.type!==l.ERROR&&p(!0))},N})(WebSocket);y.WsEvent=l,y.getWsProvider=I});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polkadot-api",
|
|
3
|
-
"version": "1.6.
|
|
3
|
+
"version": "1.6.6",
|
|
4
4
|
"author": "Josep M Sobrepere (https://github.com/josepot)",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -194,21 +194,21 @@
|
|
|
194
194
|
"@polkadot-api/cli": "0.9.13",
|
|
195
195
|
"@polkadot-api/ink-contracts": "0.1.2",
|
|
196
196
|
"@polkadot-api/json-rpc-provider": "0.0.4",
|
|
197
|
+
"@polkadot-api/logs-provider": "0.0.6",
|
|
197
198
|
"@polkadot-api/metadata-builders": "0.9.1",
|
|
198
199
|
"@polkadot-api/polkadot-sdk-compat": "2.3.1",
|
|
199
200
|
"@polkadot-api/metadata-compatibility": "0.1.11",
|
|
200
|
-
"@polkadot-api/logs-provider": "0.0.6",
|
|
201
|
-
"@polkadot-api/observable-client": "0.5.14",
|
|
202
201
|
"@polkadot-api/pjs-signer": "0.5.2",
|
|
203
202
|
"@polkadot-api/polkadot-signer": "0.1.6",
|
|
204
|
-
"@polkadot-api/
|
|
205
|
-
"@polkadot-api/sm-provider": "0.1.3",
|
|
203
|
+
"@polkadot-api/observable-client": "0.5.14",
|
|
206
204
|
"@polkadot-api/substrate-bindings": "0.9.3",
|
|
205
|
+
"@polkadot-api/signer": "0.1.10",
|
|
207
206
|
"@polkadot-api/substrate-client": "0.2.2",
|
|
207
|
+
"@polkadot-api/sm-provider": "0.1.3",
|
|
208
208
|
"@polkadot-api/utils": "0.1.2",
|
|
209
|
-
"@polkadot-api/
|
|
209
|
+
"@polkadot-api/known-chains": "0.5.5",
|
|
210
210
|
"@polkadot-api/smoldot": "0.3.3",
|
|
211
|
-
"@polkadot-api/
|
|
211
|
+
"@polkadot-api/ws-provider": "0.3.3"
|
|
212
212
|
},
|
|
213
213
|
"devDependencies": {
|
|
214
214
|
"rxjs": "^7.8.1",
|