polkadot-api 1.19.0 → 1.19.2

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