polkadot-api 1.19.0 → 1.19.1

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.
package/bin/cli.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { getCli, ink, update, remove, generate, add } from '@polkadot-api/cli';
3
3
 
4
- var version = "1.19.0";
4
+ var version = "1.19.1";
5
5
 
6
6
  getCli({
7
7
  add,
@@ -1 +1 @@
1
- (function(C,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(C=typeof globalThis<"u"?globalThis:C||self,i(C.papiWsProvider={}))})(this,(function(C){"use strict";var i=(t=>(t[t.CONNECTING=0]="CONNECTING",t[t.CONNECTED=1]="CONNECTED",t[t.ERROR=2]="ERROR",t[t.CLOSE=3]="CLOSE",t))(i||{});const _=t=>JSON.stringify({jsonrpc:"2.0",...t}),M=new Set(["v1","unstable"].map(t=>`chainHead_${t}_unfollow`)),$=t=>{let e={type:1,pending:[]};const s=n=>{if(e.type===0){const o=JSON.parse(n);if("id"in o)"result"in o&&e.onGoingRequests.get(o.id)?.type===0&&e.activeChainHeads.add(o.result),e.onGoingRequests.delete(o.id);else if("params"in o){const{subscription:l,result:u}=o.params;u?.event==="stop"&&e.activeChainHeads.delete(l)}}e.type!==2&&t(n)},r=n=>{if(e.type===2)return;if(e.type===1){e.pending.push(n);return}const o=JSON.parse(n);if(M.has(o.method)&&e.activeChainHeads.delete(o.params[0]),"id"in o){const{method:l,id:u}=o,d=l.startsWith("chainHead")?l.endsWith("follow")?{type:0,msg:n}:{type:1,id:u}:{type:2,msg:n};e.onGoingRequests.set(u,d)}e.connection.send(n)};return{send:r,disconnect:()=>{e.type!==2&&(e.type===0&&e.connection.disconnect(),e={type:2})},connect:n=>{if(e.type!==1)throw new Error("Nonesense");const{pending:o}=e,l=new Map,u=new Set;e={type:0,connection:n(s,()=>{e={type:1,pending:[]},u.forEach(h=>{s(_({params:{subscription:h,result:{event:"stop",internal:!0}}}))}),u.clear();for(const h of l.values())h.type===1?s(_({id:h.id,error:{code:-32603,message:"Internal error"},internal:!0})):r(h.msg);l.clear()}),onGoingRequests:l,activeChainHeads:u},o.forEach(r)}}},k=t=>e=>{let s=$(e);const r=()=>{t().then(n=>{if(s)s.connect((o,l)=>n(o,()=>{l(),r()}));else try{n(()=>{},()=>{}).disconnect()}catch{}},()=>{s&&setTimeout(r,0)})};return r(),{send:n=>{s?.send(n)},disconnect:()=>{s?.disconnect(),s=null}}},H={};["v1","unstable"].forEach(t=>{H[`chainHead_${t}_follow`]="follow",H[`chainHead_${t}_unfollow`]="unfollow"});const q=(t,e)=>{const s=new Set,r=new Map,n=new Set;let o;return Object.assign(u=>{const{send:d,disconnect:h}=t(p=>{const f=JSON.parse(p);if("id"in f){const{id:c,result:E}=f;if(c===o&&(o=void 0,E&&!E.methods.some(m=>{const[a,,N]=m.split("_");return a==="chainHead"&&N==="follow"}))){u(p),e();return}const y=r.get(c);if(y){if(r.delete(c),s.has(E)){s.delete(E);return}n.add(E);const m=n.size+r.size;if(m>2)console.warn(`Too many chainHead follow subscriptions (${m})`);else if(f.error){console.warn(`chainHead follow failed on the ${m} sub`),e(),r.set(c,y),d(y);return}}}else{const{subscription:c,result:E}=f.params;E?.event==="stop"&&(n.has(c)?n.delete(c):s.add(c))}u(p)});return{send(p){const f=JSON.parse(p);f.method==="rpc_methods"&&(o=f.id);const c=H[f.method];c==="follow"?r.set(f.id,p):c==="unfollow"&&n.delete(f.params[0]),d(p)},disconnect:h}},{cleanup:()=>{s.clear(),r.clear(),n.clear()}})},G={type:i.ERROR,event:{type:"timeout"}},S=()=>{},J={onStatusChanged:S,innerEnhancer:t=>t,timeout:5e3},j=t=>t.map(e=>typeof e=="string"?[e]:[e.uri,e.protocol]),x=(t,e)=>{const{onStatusChanged:s,innerEnhancer:r,timeout:n}={...J,...e},o=j(Array.isArray(t)?t:[t]),l=e?.websocketClass??globalThis.WebSocket;if(!l)throw new Error("Missing WebSocket class");let u=0,d,h=null,p=S,f=S;const c=q(k(async()=>{const[y,m]=h||o[u++%t.length];h=null;const a=new l(y,m),N=()=>{try{a.addEventListener("error",S,{once:!0}),a.close()}catch{}};s(d={type:i.CONNECTING,uri:y,protocols:m}),await new Promise((L,v)=>{const T=()=>{R(),L()},O=g=>{R(),g==null&&N(),console.error(`Unable to connect to ${y}${m?", protocols: "+m:""}`),s(d={type:g?i.ERROR:i.CLOSE,event:g}),setTimeout(v,g?300:0,g)},b=n!==1/0?setTimeout(()=>{R(),N(),s(d=G),v(G.event)},n):void 0,R=()=>{clearTimeout(b),a.removeEventListener("error",O),a.removeEventListener("open",T)};a.addEventListener("open",T),a.addEventListener("error",O),p=()=>{O(null)}}),s(d={type:i.CONNECTED,uri:y,protocols:m});let I;const z=r(L=>(I=L,{send:v=>{a.send(v)},disconnect:()=>{p()}}));return(L,v)=>{const T=z(L),O=w=>{typeof w.data=="string"&&I(w.data)},b=w=>P=>{console.warn(`WS halt (${w})`),s(d={type:w,event:P}),v()},R=b(i.ERROR),g=b(i.CLOSE);return a.addEventListener("message",O),a.addEventListener("error",R),a.addEventListener("close",g),p=w=>{f(),p=S,a.removeEventListener("message",O),a.removeEventListener("error",R),a.removeEventListener("close",g),N(),w&&g({})},T}}),()=>{E()});f=c.cleanup,delete c.cleanup;const E=(...y)=>{d.type!==i.CLOSE&&(y.length&&(h=y),d.type!==i.ERROR&&p(!0))};return Object.assign(c,{switch:E,getStatus:()=>d})};C.WsEvent=i,C.getWsProvider=x}));
1
+ (function(C,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(C=typeof globalThis<"u"?globalThis:C||self,c(C.papiWsProvider={}))})(this,(function(C){"use strict";var c=(t=>(t[t.CONNECTING=0]="CONNECTING",t[t.CONNECTED=1]="CONNECTED",t[t.ERROR=2]="ERROR",t[t.CLOSE=3]="CLOSE",t))(c||{});const G=t=>JSON.stringify({jsonrpc:"2.0",...t}),M=new Set(["v1","unstable"].map(t=>`chainHead_${t}_unfollow`)),$=t=>{let e={type:1,pending:[]};const s=n=>{if(e.type===0){const o=JSON.parse(n);if("id"in o)"result"in o&&e.onGoingRequests.get(o.id)?.type===0&&e.activeChainHeads.add(o.result),e.onGoingRequests.delete(o.id);else if("params"in o){const{subscription:l,result:p}=o.params;p?.event==="stop"&&e.activeChainHeads.delete(l)}}e.type!==2&&t(n)},i=n=>{if(e.type===2)return;if(e.type===1){e.pending.push(n);return}const o=JSON.parse(n);if(M.has(o.method)&&e.activeChainHeads.delete(o.params[0]),"id"in o){const{method:l,id:p}=o,d=l.startsWith("chainHead")?l.endsWith("follow")?{type:0,msg:n}:{type:1,id:p}:{type:2,msg:n};e.onGoingRequests.set(p,d)}e.connection.send(n)};return{send:i,disconnect:()=>{e.type!==2&&(e.type===0&&e.connection.disconnect(),e={type:2})},connect:n=>{if(e.type!==1)throw new Error("Nonesense");const{pending:o}=e,l=new Map,p=new Set;e={type:0,connection:n(s,()=>{e={type:1,pending:[]},p.forEach(y=>{s(G({params:{subscription:y,result:{event:"stop",internal:!0}}}))}),p.clear();for(const y of l.values())y.type===1?s(G({id:y.id,error:{code:-32603,message:"Internal error"},internal:!0})):i(y.msg);l.clear()}),onGoingRequests:l,activeChainHeads:p},o.forEach(i)}}},k=t=>e=>{let s=$(e);const i=()=>{t().then(n=>{if(s)s.connect((o,l)=>n(o,()=>{l(),i()}));else try{n(()=>{},()=>{}).disconnect()}catch{}},()=>{s&&setTimeout(i,0)})};return i(),{send:n=>{s?.send(n)},disconnect:()=>{s?.disconnect(),s=null}}},_={};["v1","unstable"].forEach(t=>{_[`chainHead_${t}_follow`]="follow",_[`chainHead_${t}_unfollow`]="unfollow"});const q=(t,e)=>{const s=new Set,i=new Map,n=new Set;let o;return Object.assign(p=>{const{send:d,disconnect:y}=t(f=>{let u={latest:Date.now(),count:0};const m=JSON.parse(f);if("id"in m){const{id:E,result:a}=m;if(E===o&&(o=void 0,a&&!a.methods.some(r=>{const[N,,T]=r.split("_");return N==="chainHead"&&T==="follow"}))){p(f),e();return}const h=i.get(E);if(h){if(i.delete(E),s.has(a)){s.delete(a);return}n.add(a);const r=n.size+i.size;if(r>2)console.warn(`Too many chainHead follow subscriptions (${r})`);else if(m.error){console.warn(`chainHead follow failed on the ${r} sub`),e(),i.set(E,h),d(h);return}}}else{const{subscription:E,result:a}=m.params;if(a?.event==="stop"){const h=Date.now()-u.latest;u.latest+=h,u.count=h<1e3?u.count+1:1,n.has(E)?n.delete(E):s.add(E)}}p(f),u.count>2&&e()});return{send(f){const u=JSON.parse(f);u.method==="rpc_methods"&&(o=u.id);const m=_[u.method];m==="follow"?i.set(u.id,f):m==="unfollow"&&n.delete(u.params[0]),d(f)},disconnect:y}},{cleanup:()=>{s.clear(),i.clear(),n.clear()}})},I={type:c.ERROR,event:{type:"timeout"}},R=()=>{},J={onStatusChanged:R,innerEnhancer:t=>t,timeout:5e3},j=t=>t.map(e=>typeof e=="string"?[e]:[e.uri,e.protocol]),x=(t,e)=>{const{onStatusChanged:s,innerEnhancer:i,timeout:n}={...J,...e},o=j(Array.isArray(t)?t:[t]),l=e?.websocketClass??globalThis.WebSocket;if(!l)throw new Error("Missing WebSocket class");let p=0,d,y=null,f=R,u=R;const m=q(k(async()=>{const[a,h]=y||o[p++%t.length];y=null;const r=new l(a,h),N=()=>{try{r.addEventListener("error",R,{once:!0}),r.close()}catch{}};s(d={type:c.CONNECTING,uri:a,protocols:h}),await new Promise((L,v)=>{const b=()=>{S(),L()},O=w=>{S(),w==null&&N(),console.error(`Unable to connect to ${a}${h?", protocols: "+h:""}`),s(d={type:w?c.ERROR:c.CLOSE,event:w}),setTimeout(v,w?300:0,w)},H=n!==1/0?setTimeout(()=>{S(),N(),s(d=I),v(I.event)},n):void 0,S=()=>{clearTimeout(H),r.removeEventListener("error",O),r.removeEventListener("open",b)};r.addEventListener("open",b),r.addEventListener("error",O),f=()=>{O(null)}}),s(d={type:c.CONNECTED,uri:a,protocols:h});let T;const z=i(L=>(T=L,{send:v=>{r.send(v)},disconnect:()=>{f()}}));return(L,v)=>{const b=z(L),O=g=>{typeof g.data=="string"&&T(g.data)},H=g=>D=>{console.warn(`WS halt (${g})`),s(d={type:g,event:D}),v()},S=H(c.ERROR),w=H(c.CLOSE);return r.addEventListener("message",O),r.addEventListener("error",S),r.addEventListener("close",w),f=g=>{u(),f=R,r.removeEventListener("message",O),r.removeEventListener("error",S),r.removeEventListener("close",w),N(),g&&w({})},b}}),()=>{E()});u=m.cleanup,delete m.cleanup;const E=(...a)=>{d.type!==c.CLOSE&&(a.length&&(y=a),d.type!==c.ERROR&&f(!0))};return Object.assign(m,{switch:E,getStatus:()=>d})};C.WsEvent=c,C.getWsProvider=x}));
@@ -1 +1 @@
1
- (function(C,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(C=typeof globalThis<"u"?globalThis:C||self,v(C.papiWsProviderWeb={}))})(this,(function(C){"use strict";const v=t=>JSON.stringify({jsonrpc:"2.0",...t}),M=new Set(["v1","unstable"].map(t=>`chainHead_${t}_unfollow`)),W=t=>{let e={type:1,pending:[]};const s=o=>{if(e.type===0){const n=JSON.parse(o);if("id"in n)"result"in n&&e.onGoingRequests.get(n.id)?.type===0&&e.activeChainHeads.add(n.result),e.onGoingRequests.delete(n.id);else if("params"in n){const{subscription:r,result:c}=n.params;c?.event==="stop"&&e.activeChainHeads.delete(r)}}e.type!==2&&t(o)},i=o=>{if(e.type===2)return;if(e.type===1){e.pending.push(o);return}const n=JSON.parse(o);if(M.has(n.method)&&e.activeChainHeads.delete(n.params[0]),"id"in n){const{method:r,id:c}=n,d=r.startsWith("chainHead")?r.endsWith("follow")?{type:0,msg:o}:{type:1,id:c}:{type:2,msg:o};e.onGoingRequests.set(c,d)}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:n}=e,r=new Map,c=new Set;e={type:0,connection:o(s,()=>{e={type:1,pending:[]},c.forEach(h=>{s(v({params:{subscription:h,result:{event:"stop",internal:!0}}}))}),c.clear();for(const h of r.values())h.type===1?s(v({id:h.id,error:{code:-32603,message:"Internal error"},internal:!0})):i(h.msg);r.clear()}),onGoingRequests:r,activeChainHeads:c},n.forEach(i)}}},A=t=>e=>{let s=W(e);const i=()=>{t().then(o=>{if(s)s.connect((n,r)=>o(n,()=>{r(),i()}));else try{o(()=>{},()=>{}).disconnect()}catch{}},()=>{s&&setTimeout(i,0)})};return i(),{send:o=>{s?.send(o)},disconnect:()=>{s?.disconnect(),s=null}}};var f=(t=>(t[t.CONNECTING=0]="CONNECTING",t[t.CONNECTED=1]="CONNECTED",t[t.ERROR=2]="ERROR",t[t.CLOSE=3]="CLOSE",t))(f||{});const _={};["v1","unstable"].forEach(t=>{_[`chainHead_${t}_follow`]="follow",_[`chainHead_${t}_unfollow`]="unfollow"});const P=(t,e)=>{const s=new Set,i=new Map,o=new Set;let n;return Object.assign(c=>{const{send:d,disconnect:h}=t(u=>{const p=JSON.parse(u);if("id"in p){const{id:a,result:E}=p;if(a===n&&(n=void 0,E&&!E.methods.some(m=>{const[l,,L]=m.split("_");return l==="chainHead"&&L==="follow"}))){c(u),e();return}const y=i.get(a);if(y){if(i.delete(a),s.has(E)){s.delete(E);return}o.add(E);const m=o.size+i.size;if(m>2)console.warn(`Too many chainHead follow subscriptions (${m})`);else if(p.error){console.warn(`chainHead follow failed on the ${m} sub`),e(),i.set(a,y),d(y);return}}}else{const{subscription:a,result:E}=p.params;E?.event==="stop"&&(o.has(a)?o.delete(a):s.add(a))}c(u)});return{send(u){const p=JSON.parse(u);p.method==="rpc_methods"&&(n=p.id);const a=_[p.method];a==="follow"?i.set(p.id,u):a==="unfollow"&&o.delete(p.params[0]),d(u)},disconnect:h}},{cleanup:()=>{s.clear(),i.clear(),o.clear()}})},k={type:f.ERROR,event:{type:"timeout"}},S=()=>{},G={onStatusChanged:S,innerEnhancer:t=>t,timeout:5e3},$=t=>t.map(e=>typeof e=="string"?[e]:[e.uri,e.protocol]),j=(t,e)=>{const{onStatusChanged:s,innerEnhancer:i,timeout:o}={...G,...e},n=$(Array.isArray(t)?t:[t]),r=e?.websocketClass??globalThis.WebSocket;if(!r)throw new Error("Missing WebSocket class");let c=0,d,h=null,u=S,p=S;const a=P(A(async()=>{const[y,m]=h||n[c++%t.length];h=null;const l=new r(y,m),L=()=>{try{l.addEventListener("error",S,{once:!0}),l.close()}catch{}};s(d={type:f.CONNECTING,uri:y,protocols:m}),await new Promise((b,O)=>{const T=()=>{N(),b()},R=g=>{N(),g==null&&L(),console.error(`Unable to connect to ${y}${m?", protocols: "+m:""}`),s(d={type:g?f.ERROR:f.CLOSE,event:g}),setTimeout(O,g?300:0,g)},H=o!==1/0?setTimeout(()=>{N(),L(),s(d=k),O(k.event)},o):void 0,N=()=>{clearTimeout(H),l.removeEventListener("error",R),l.removeEventListener("open",T)};l.addEventListener("open",T),l.addEventListener("error",R),u=()=>{R(null)}}),s(d={type:f.CONNECTED,uri:y,protocols:m});let I;const J=i(b=>(I=b,{send:O=>{l.send(O)},disconnect:()=>{u()}}));return(b,O)=>{const T=J(b),R=w=>{typeof w.data=="string"&&I(w.data)},H=w=>z=>{console.warn(`WS halt (${w})`),s(d={type:w,event:z}),O()},N=H(f.ERROR),g=H(f.CLOSE);return l.addEventListener("message",R),l.addEventListener("error",N),l.addEventListener("close",g),u=w=>{p(),u=S,l.removeEventListener("message",R),l.removeEventListener("error",N),l.removeEventListener("close",g),L(),w&&g({})},T}}),()=>{E()});p=a.cleanup,delete a.cleanup;const E=(...y)=>{d.type!==f.CLOSE&&(y.length&&(h=y),d.type!==f.ERROR&&u(!0))};return Object.assign(a,{switch:E,getStatus:()=>d})},q=(t=>(...e)=>{let s=[],{timeout:i,innerEnhancer:o,onStatusChanged:n}=G;const[r]=e;return e.length===1&&typeof r=="object"&&!Array.isArray(r)?(s=$(r.endpoints),n=r.onStatusChanged??S,i=r.timeout??i,o=r.innerEnhancer??(c=>c)):(typeof e[1]=="function"&&(n=e[1]),Array.isArray(r)?s=$(r):(s=[[r]],e[1]&&e[1]!==n&&(s[0][1]=e[1]),e[2]&&(n=e[2]))),j(s.map(c=>c.length===1?c[0]:{uri:c[0],protocol:c[1]}),{websocketClass:t,onStatusChanged:n,timeout:i,innerEnhancer:o})})(WebSocket);C.WsEvent=f,C.getWsProvider=q}));
1
+ (function(C,v){typeof exports=="object"&&typeof module<"u"?v(exports):typeof define=="function"&&define.amd?define(["exports"],v):(C=typeof globalThis<"u"?globalThis:C||self,v(C.papiWsProviderWeb={}))})(this,(function(C){"use strict";const v=t=>JSON.stringify({jsonrpc:"2.0",...t}),M=new Set(["v1","unstable"].map(t=>`chainHead_${t}_unfollow`)),W=t=>{let e={type:1,pending:[]};const s=o=>{if(e.type===0){const n=JSON.parse(o);if("id"in n)"result"in n&&e.onGoingRequests.get(n.id)?.type===0&&e.activeChainHeads.add(n.result),e.onGoingRequests.delete(n.id);else if("params"in n){const{subscription:r,result:c}=n.params;c?.event==="stop"&&e.activeChainHeads.delete(r)}}e.type!==2&&t(o)},i=o=>{if(e.type===2)return;if(e.type===1){e.pending.push(o);return}const n=JSON.parse(o);if(M.has(n.method)&&e.activeChainHeads.delete(n.params[0]),"id"in n){const{method:r,id:c}=n,d=r.startsWith("chainHead")?r.endsWith("follow")?{type:0,msg:o}:{type:1,id:c}:{type:2,msg:o};e.onGoingRequests.set(c,d)}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:n}=e,r=new Map,c=new Set;e={type:0,connection:o(s,()=>{e={type:1,pending:[]},c.forEach(y=>{s(v({params:{subscription:y,result:{event:"stop",internal:!0}}}))}),c.clear();for(const y of r.values())y.type===1?s(v({id:y.id,error:{code:-32603,message:"Internal error"},internal:!0})):i(y.msg);r.clear()}),onGoingRequests:r,activeChainHeads:c},n.forEach(i)}}},A=t=>e=>{let s=W(e);const i=()=>{t().then(o=>{if(s)s.connect((n,r)=>o(n,()=>{r(),i()}));else try{o(()=>{},()=>{}).disconnect()}catch{}},()=>{s&&setTimeout(i,0)})};return i(),{send:o=>{s?.send(o)},disconnect:()=>{s?.disconnect(),s=null}}};var h=(t=>(t[t.CONNECTING=0]="CONNECTING",t[t.CONNECTED=1]="CONNECTED",t[t.ERROR=2]="ERROR",t[t.CLOSE=3]="CLOSE",t))(h||{});const $={};["v1","unstable"].forEach(t=>{$[`chainHead_${t}_follow`]="follow",$[`chainHead_${t}_unfollow`]="unfollow"});const P=(t,e)=>{const s=new Set,i=new Map,o=new Set;let n;return Object.assign(c=>{const{send:d,disconnect:y}=t(p=>{let u={latest:Date.now(),count:0};const m=JSON.parse(p);if("id"in m){const{id:E,result:l}=m;if(E===n&&(n=void 0,l&&!l.methods.some(a=>{const[L,,T]=a.split("_");return L==="chainHead"&&T==="follow"}))){c(p),e();return}const f=i.get(E);if(f){if(i.delete(E),s.has(l)){s.delete(l);return}o.add(l);const a=o.size+i.size;if(a>2)console.warn(`Too many chainHead follow subscriptions (${a})`);else if(m.error){console.warn(`chainHead follow failed on the ${a} sub`),e(),i.set(E,f),d(f);return}}}else{const{subscription:E,result:l}=m.params;if(l?.event==="stop"){const f=Date.now()-u.latest;u.latest+=f,u.count=f<1e3?u.count+1:1,o.has(E)?o.delete(E):s.add(E)}}c(p),u.count>2&&e()});return{send(p){const u=JSON.parse(p);u.method==="rpc_methods"&&(n=u.id);const m=$[u.method];m==="follow"?i.set(u.id,p):m==="unfollow"&&o.delete(u.params[0]),d(p)},disconnect:y}},{cleanup:()=>{s.clear(),i.clear(),o.clear()}})},G={type:h.ERROR,event:{type:"timeout"}},S=()=>{},I={onStatusChanged:S,innerEnhancer:t=>t,timeout:5e3},k=t=>t.map(e=>typeof e=="string"?[e]:[e.uri,e.protocol]),j=(t,e)=>{const{onStatusChanged:s,innerEnhancer:i,timeout:o}={...I,...e},n=k(Array.isArray(t)?t:[t]),r=e?.websocketClass??globalThis.WebSocket;if(!r)throw new Error("Missing WebSocket class");let c=0,d,y=null,p=S,u=S;const m=P(A(async()=>{const[l,f]=y||n[c++%t.length];y=null;const a=new r(l,f),L=()=>{try{a.addEventListener("error",S,{once:!0}),a.close()}catch{}};s(d={type:h.CONNECTING,uri:l,protocols:f}),await new Promise((b,O)=>{const H=()=>{N(),b()},R=g=>{N(),g==null&&L(),console.error(`Unable to connect to ${l}${f?", protocols: "+f:""}`),s(d={type:g?h.ERROR:h.CLOSE,event:g}),setTimeout(O,g?300:0,g)},_=o!==1/0?setTimeout(()=>{N(),L(),s(d=G),O(G.event)},o):void 0,N=()=>{clearTimeout(_),a.removeEventListener("error",R),a.removeEventListener("open",H)};a.addEventListener("open",H),a.addEventListener("error",R),p=()=>{R(null)}}),s(d={type:h.CONNECTED,uri:l,protocols:f});let T;const J=i(b=>(T=b,{send:O=>{a.send(O)},disconnect:()=>{p()}}));return(b,O)=>{const H=J(b),R=w=>{typeof w.data=="string"&&T(w.data)},_=w=>z=>{console.warn(`WS halt (${w})`),s(d={type:w,event:z}),O()},N=_(h.ERROR),g=_(h.CLOSE);return a.addEventListener("message",R),a.addEventListener("error",N),a.addEventListener("close",g),p=w=>{u(),p=S,a.removeEventListener("message",R),a.removeEventListener("error",N),a.removeEventListener("close",g),L(),w&&g({})},H}}),()=>{E()});u=m.cleanup,delete m.cleanup;const E=(...l)=>{d.type!==h.CLOSE&&(l.length&&(y=l),d.type!==h.ERROR&&p(!0))};return Object.assign(m,{switch:E,getStatus:()=>d})},q=(t=>(...e)=>{let s=[],{timeout:i,innerEnhancer:o,onStatusChanged:n}=I;const[r]=e;return e.length===1&&typeof r=="object"&&!Array.isArray(r)?(s=k(r.endpoints),n=r.onStatusChanged??S,i=r.timeout??i,o=r.innerEnhancer??(c=>c)):(typeof e[1]=="function"&&(n=e[1]),Array.isArray(r)?s=k(r):(s=[[r]],e[1]&&e[1]!==n&&(s[0][1]=e[1]),e[2]&&(n=e[2]))),j(s.map(c=>c.length===1?c[0]:{uri:c[0],protocol:c[1]}),{websocketClass:t,onStatusChanged:n,timeout:i,innerEnhancer:o})})(WebSocket);C.WsEvent=h,C.getWsProvider=q}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "polkadot-api",
3
- "version": "1.19.0",
3
+ "version": "1.19.1",
4
4
  "author": "Josep M Sobrepere (https://github.com/josepot)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -204,28 +204,28 @@
204
204
  },
205
205
  "dependencies": {
206
206
  "@rx-state/core": "^0.1.4",
207
- "@polkadot-api/cli": "0.15.0",
208
- "@polkadot-api/known-chains": "0.9.11",
207
+ "@polkadot-api/cli": "0.15.1",
208
+ "@polkadot-api/json-rpc-provider": "0.0.4",
209
209
  "@polkadot-api/ink-contracts": "0.4.0",
210
+ "@polkadot-api/known-chains": "0.9.11",
210
211
  "@polkadot-api/logs-provider": "0.0.6",
211
- "@polkadot-api/json-rpc-provider": "0.0.4",
212
212
  "@polkadot-api/metadata-builders": "0.13.5",
213
- "@polkadot-api/observable-client": "0.15.1",
214
213
  "@polkadot-api/metadata-compatibility": "0.3.6",
215
214
  "@polkadot-api/pjs-signer": "0.6.15",
216
- "@polkadot-api/polkadot-sdk-compat": "2.3.3",
215
+ "@polkadot-api/observable-client": "0.15.1",
217
216
  "@polkadot-api/polkadot-signer": "0.1.6",
218
217
  "@polkadot-api/signer": "0.2.9",
219
218
  "@polkadot-api/sm-provider": "0.1.11",
220
- "@polkadot-api/substrate-client": "0.4.7",
219
+ "@polkadot-api/polkadot-sdk-compat": "2.3.3",
221
220
  "@polkadot-api/substrate-bindings": "0.16.3",
222
- "@polkadot-api/smoldot": "0.3.14",
221
+ "@polkadot-api/substrate-client": "0.4.7",
223
222
  "@polkadot-api/utils": "0.2.0",
224
- "@polkadot-api/ws-provider": "0.6.0"
223
+ "@polkadot-api/ws-provider": "0.6.1",
224
+ "@polkadot-api/smoldot": "0.3.14"
225
225
  },
226
226
  "devDependencies": {
227
227
  "rxjs": "^7.8.2",
228
- "@polkadot-api/codegen": "0.19.0"
228
+ "@polkadot-api/codegen": "0.19.1"
229
229
  },
230
230
  "scripts": {
231
231
  "build-core": "tsc --noEmit && rollup -c",