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