polkadot-api 1.6.5 → 1.6.7

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