polkadot-api 1.23.0 → 1.23.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 +1 @@
|
|
|
1
|
-
(function(_,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(_=typeof globalThis<"u"?globalThis:_||self,E(_.papiPolkadotSdkCompat={}))})(this,(function(_){"use strict";const E=u=>{let c=null;const{send:s,disconnect:n}=u(d=>{c?.(JSON.parse(d))});return d=>(c=d,{send(f){s(JSON.stringify(f))},disconnect(){c=null,n()}})},
|
|
1
|
+
(function(_,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(_=typeof globalThis<"u"?globalThis:_||self,E(_.papiPolkadotSdkCompat={}))})(this,(function(_){"use strict";const E=u=>{let c=null;const{send:s,disconnect:n}=u(d=>{c?.(JSON.parse(d))});return d=>(c=d,{send(f){s(JSON.stringify(f))},disconnect(){c=null,n()}})},g=u=>{let c=null;const{send:s,disconnect:n}=u(d=>{c?.(JSON.stringify(d))});return d=>(c=d,{send(f){s(JSON.parse(f))},disconnect(){c=null,n()}})},z=(...u)=>c=>g(u.reduce((s,n)=>n(s),E(c))),b={body:"",call:"",continue:"",follow:"",header:"",stopOperation:"",storage:"",unfollow:"",unpin:""},y={broadcast:"",stop:""},O={chainName:"",genesisHash:"",properties:""};Object.entries({chainHead:b,chainSpec:O,transaction:y}).forEach(([u,c])=>{Object.keys(c).forEach(s=>{c[s]=`${u}_v1_${s}`})});var L=Object.freeze({__proto__:null,chainHead:b,chainSpec:O,transaction:y});const Q=u=>c=>{const{send:s,disconnect:n}=u(c);return{send:f=>{switch(f.method){case O.chainName:return s({...f,method:"system_chain"});case O.genesisHash:return s({...f,method:"chain_getBlockHash",params:[0]});case O.properties:return s({...f,method:"system_properties"})}s(f)},disconnect:n}},R=u=>c=>{const s=new Set,n=new Map,d=new Map,{send:f,disconnect:r}=u(a=>{if("id"in a){c(a);const{id:o,result:e}=a;if(s.has(o)){s.delete(o),n.set(e,new Set),d.set(e,new Map);return}}else{const{subscription:o}=a.params,e=n.get(o),i=d.get(o);if(e){const t=a.params.result,{event:l}=t;if(l==="initialized"&&t.finalizedBlockHashes.forEach(p=>{e.add(p)}),l==="newBlock"){const{parentBlockHash:p}=t;if(!e.has(p)){const H=i.get(p)??[];H.push(a),i.set(p,H);return}const k=t.blockHash;e.add(t.blockHash),c(a);const w=i.get(k);w&&(i.delete(k),w.forEach(H=>{e.add(H.params.result.blockHash),c(H)}));return}l==="stop"&&(e.delete(o),d.delete(o))}c(a)}});return{send:a=>{const o=a.params[0];switch(a.method){case b.follow:s.add(a.id);break;case b.unpin:const[e,i]=a.params;i.forEach(t=>{n.get(e)?.delete(t),d.get(e)?.delete(t)});break;case b.unfollow:n.delete(o),d.delete(o);break}f(a)},disconnect:r}},M=u=>({jsonrpc:"2.0",...u}),N=(u,c,s,n={})=>M({method:"chainHead_v1_followEvent",params:{subscription:u,result:{event:c,operationId:s,...n}}}),Z="__INNER_RQ_DesV",X=u=>{let c=0;const s=new Map,n=({id:h,error:a,result:o})=>{const e=s.get(h);return e&&(s.delete(h),a?e(!1,a):e(!0,o)),!e};let d=()=>{};return[h=>{const{send:a,disconnect:o}=u(e=>{n(e)&&h(e)});return d=a,{send:d,disconnect:()=>{s.clear(),o()}}},(h,a,o,e)=>{const i=Z+c++;s.set(i,(t,l)=>{(t?o:e)(l)}),d(M({id:i,method:h,params:a}))}]},Y="__INNER_OP_DesV";let ee=0;const V=u=>c=>{const[s,n]=X(u),d=te(n),f=new Map,r=new Map,{send:h,disconnect:a}=s(i=>{if("id"in i){const t=f.get(i.id);t&&(f.delete(i.id),i.result.result==="started"&&t(i.result.operationId))}else if(i.params){const{subscription:t,result:l}=i.params,{operationId:p}=l||{},k=r.get(t);k&&l.event==="stop"&&(k.forEach(H=>{H.cancel()}),r.delete(t));const w=k?.get(p);if(w)switch(l.event){case"operationInaccessible":case"operationError":w.cancel();break;case"operationStorageDone":if(w.isInnerDone)k.delete(p);else{w.isOutterDone=!0;return}}}c(i)}),o=(i,t,l)=>p=>{let k=()=>{};r.has(i)||r.set(i,new Map);const w=r.get(i),H={isOutterDone:!1,isInnerDone:!1,cancel:()=>{k()}};w.set(p,H);let v=0;const B=l.map(S=>d(S,t,I=>{c(N(i,"operationStorageItems",p,{items:I.map(([C,D])=>({key:C,value:D}))}))},I=>{k(),H.isOutterDone||h(M({method:"chainHead_v1_stopOperation",params:[p]})),c(N(i,"operationError",p,{error:typeof I=="string"?I:JSON.stringify(I)}))},()=>{++v===l.length&&(H.isOutterDone?(k(),c(N(i,"operationStorageDone",p))):H.isInnerDone=!0)}));k=()=>{w.delete(p),B.forEach(S=>S())}};return{send:i=>{switch(i.method){case b.storage:{const[t,l,p]=i.params,k=[],w=p.filter(v=>{const B=v.type==="descendantsValues";return B&&k.push(v.key),!B}),H=o(t,l,k);if(w.length)k.length&&f.set(i.id,H);else{const v=Y+ee++;c(M({id:i.id,result:{result:"started",operationId:v}})),H(v),r.get(t).get(v).isOutterDone=!0;return}i.params[2]=w;break}case b.stopOperation:{const[t,l]=i.params,p=r.get(t)?.get(l);if(p&&(p.cancel(),p.isOutterDone))return;break}case b.unfollow:{const[t]=i.params;r.get(t)?.forEach(l=>l.cancel()),r.delete(t);break}}h(i)},disconnect:a}},te=u=>(c,s,n,d,f)=>{let r=!0,h=!1,a=0;const o=t=>{r&&(r=!1,d(t))},e=1e3,i=t=>{u("state_getKeysPaged",[c,e,t||void 0,s],l=>{r&&(l.length>0&&(a++,u("state_queryStorageAt",[l,s],([{changes:p}])=>{r&&(a--,n(p),h&&!a&&f())},o)),l.length<e?(h=!0,a||f()):i(l.at(-1)))},o)};return i(),()=>{r=!1}},$=u=>c=>{const s=new Set,n=new Map,d=new Map,{send:f,disconnect:r}=u(a=>{if("id"in a){c(a);const{id:o,result:e}=a;if(s.has(o)){s.delete(o),n.set(e,new Set),d.set(e,new Map);return}}else{const{subscription:o}=a.params,e=n.get(o),i=d.get(o);if(e){const t=a.params.result,{event:l}=t;if(l==="initialized"&&t.finalizedBlockHashes.forEach(p=>{e.add(p)}),l==="finalized"&&(t.prunedBlockHashes=t.prunedBlockHashes.filter(p=>e.has(p))),l==="newBlock"){e.add(t.blockHash);const p=t.blockHash,k=i.get(p);if(k){i.delete(p),c(a),Promise.resolve().then(()=>{c(k)});return}}if(l==="bestBlockChanged"){const p=t.bestBlockHash;if(!e.has(p)){d.get(o).set(p,a);return}}l==="stop"&&(e.delete(o),d.delete(o))}c(a)}});return{send:a=>{const o=a.params[0];switch(a.method){case b.follow:s.add(a.id);break;case b.unpin:const[e,i]=a.params;i.forEach(t=>{n.get(e)?.delete(t),d.get(e)?.delete(t)});break;case b.unfollow:n.delete(o),d.delete(o);break}f(a)},disconnect:r}},ne=new Set(["BodyDone","CallDone","StorageDone","Inaccessible","Error"].map(u=>"operation"+u)),j=u=>ne.has(u.params?.result?.event),T=u=>c=>{const s=new Set,n=new Map,d=new Map,f=new Map,{send:r,disconnect:h}=u(o=>{if("id"in o){c(o);const{id:e,result:i}=o;if(s.has(e)){s.delete(e),d.set(i,new Set),f.set(i,new Map);return}const t=n.get(e);if(t!==void 0){n.delete(e);const l=o.result?.operationId;if(l!==void 0&&d.has(t)){const p=d.get(t);p.add(l);const k=f.get(t)?.get(l);k&&(k.forEach(c),f.get(t).delete(l),j(k.at(-1))&&p.delete(l))}}}else{const{subscription:e,result:i}=o.params,t=d.get(e);if(t){const{operationId:l}=o.params.result;if(l!==void 0)if(t.has(l))j(o)&&t.delete(l);else{const p=f.get(e),k=p.get(l)??[];k.push(o),p.set(l,k);return}else i?.event==="stop"&&(d.delete(e),f.delete(e))}c(o)}});return{send:o=>{const e=o.params[0];switch(o.method){case b.follow:s.add(o.id);break;case b.body:case b.call:case b.storage:n.set(o.id,e);break;case b.unfollow:d.delete(e),f.delete(e);break;case b.stopOperation:d.get(e)?.delete(o.params[1])}r(o)},disconnect:h}},se=new Set(["newBlock","bestBlockChanged","stop"]),A=u=>c=>{const s=new Set,n=new Map,{send:d,disconnect:f}=u(r=>{if("id"in r){const{id:h,result:a}=r;s.has(h)&&(s.delete(h),n.set(a,()=>{n.delete(a)}))}else{const{subscription:h}=r.params,a=n.get(h);if(a){const o=r.params.result,{event:e}=o;if(e==="initialized"){const i=setTimeout(()=>{n.delete(h),c(N(h,"bestBlockChanged",void 0,{bestBlockHash:o.finalizedBlockHashes.at(-1)}))},500);n.set(h,()=>{n.delete(h),clearTimeout(i)})}else se.has(e)&&a()}}c(r)});return{send(r){switch(r.method){case b.follow:s.add(r.id);break;case b.unfollow:n.get(r.params[0])?.()}d(r)},disconnect:f}},G=u=>c=>u(s=>{const n=s.params?.result;if(!("id"in s)&&n){const{prunedBlockHashes:d,finalizedBlockHash:f,event:r}=n;r==="finalized"&&Array.isArray(d)?n.prunedBlockHashes=[...new Set(n.prunedBlockHashes)]:r==="initialized"&&f&&(n.finalizedBlockHashes=[n.finalizedBlockHash],delete n.finalizedBlockHash)}c(s)}),m=u=>c=>{const{send:s,disconnect:n}=u(c);return{send:f=>{const{method:r,params:h,id:a,...o}=f;r==b.unpin&&h&&Array.isArray(h[1])?h[1].forEach((e,i)=>{s({...o,id:i===0?a:`${a}-patched-${i}`,method:r,params:[h[0],e]})}):s(f)},disconnect:n}},q=u=>({jsonrpc:"2.0",...u}),[P]=y.stop.split("_"),x="unstable",J="rpc_methods",K="__INTERNAL_ID",U=u=>c=>{let s=!0,n=[],d=t=>{n.push(t)};const f=({id:t,result:l,error:p})=>{if(t!==K||!s)return;if(!l){if(console.error(p),e<4){setTimeout(i,200);return}l={methods:[]}}const k=new Set(l.methods),w={};[b,O,y].forEach(B=>{Object.values(B).forEach(S=>{if(k.has(S))w[S]=S;else{const[I,,C]=S.split("_"),D=`${I}_${x}_${C}`;if(k.has(D))w[S]=D,k.delete(D),k.add(S);else if(w[S]=null,I===P){let W;const ie=S==="stop"?"unwatch":"submitAndWatch";[P+"Watch",P].find(ae=>["v1",x].find(ce=>k.has(W=`${ae}_${ce}_${ie}`)))&&(w[S]=W,k.add(S))}}})}),r=c;const H=({method:B,...S})=>{if(B===J){Promise.resolve().then(()=>{c(q({id:S.id,result:{methods:[...k]}}))});return}const I=w[B];I===null?B.split("_")[2]==="follow"?(o(),d({method:B,...S})):Promise.resolve().then(()=>{c({error:{code:-32603,message:`Method not found: ${B}`},id:S.id})}):h({method:I||B,...S})},v=[...n];n=[];for(let B=0;s&&B<v.length;B++)H(v[B]);s&&(d=H)};let r=f;const{send:h,disconnect:a}=u(t=>{r(t)}),o=()=>{s=!0,n=[],d=t=>{n.push(t)},r=f,i()};let e=0;const i=()=>{e++,h(q({id:K,method:J,params:[]}))};return i(),{send:t=>{d(t)},disconnect(){s=!1,d=r=()=>{},n=[],a()}}},F=u=>c=>{let s=0;const n=new Map,{send:d,disconnect:f}=u(r=>{const{id:h}=r;n.has(h)&&(r.id=n.get(h),n.delete(h)),c(r)});return{send:r=>{"id"in r&&(n.set(s,r.id),r.id=s++),d(r)},disconnect:f}},oe=z(F,U,T,m,G,R,$,A,Q,V);_.fixDescendantValues=V,_.fixMissingInitialBest=A,_.fixPrematureBlocks=R,_.fixUnorderedBlocks=$,_.fixUnorderedEvents=T,_.fromParsed=g,_.methods=L,_.parsed=z,_.patchChainHeadEvents=G,_.toParsed=E,_.translate=U,_.unpinHash=m,_.withNumericIds=F,_.withPolkadotSdkCompat=oe}));
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "polkadot-api",
|
|
3
|
-
"version": "1.23.
|
|
3
|
+
"version": "1.23.1",
|
|
4
4
|
"author": "Josep M Sobrepere (https://github.com/josepot)",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -204,24 +204,24 @@
|
|
|
204
204
|
},
|
|
205
205
|
"dependencies": {
|
|
206
206
|
"@rx-state/core": "^0.1.4",
|
|
207
|
-
"@polkadot-api/
|
|
207
|
+
"@polkadot-api/cli": "0.17.1",
|
|
208
208
|
"@polkadot-api/ink-contracts": "0.4.4",
|
|
209
|
-
"@polkadot-api/
|
|
209
|
+
"@polkadot-api/known-chains": "0.9.16",
|
|
210
210
|
"@polkadot-api/json-rpc-provider": "0.0.4",
|
|
211
211
|
"@polkadot-api/logs-provider": "0.0.6",
|
|
212
212
|
"@polkadot-api/metadata-builders": "0.13.7",
|
|
213
|
+
"@polkadot-api/observable-client": "0.17.1",
|
|
213
214
|
"@polkadot-api/pjs-signer": "0.6.17",
|
|
214
215
|
"@polkadot-api/metadata-compatibility": "0.4.2",
|
|
215
|
-
"@polkadot-api/
|
|
216
|
-
"@polkadot-api/polkadot-signer": "0.1.6",
|
|
217
|
-
"@polkadot-api/polkadot-sdk-compat": "2.4.0",
|
|
216
|
+
"@polkadot-api/polkadot-sdk-compat": "2.4.1",
|
|
218
217
|
"@polkadot-api/signer": "0.2.11",
|
|
218
|
+
"@polkadot-api/polkadot-signer": "0.1.6",
|
|
219
219
|
"@polkadot-api/sm-provider": "0.1.15",
|
|
220
220
|
"@polkadot-api/smoldot": "0.3.15",
|
|
221
221
|
"@polkadot-api/substrate-bindings": "0.16.5",
|
|
222
|
-
"@polkadot-api/
|
|
222
|
+
"@polkadot-api/ws-provider": "0.7.4",
|
|
223
223
|
"@polkadot-api/utils": "0.2.0",
|
|
224
|
-
"@polkadot-api/
|
|
224
|
+
"@polkadot-api/substrate-client": "0.5.0"
|
|
225
225
|
},
|
|
226
226
|
"devDependencies": {
|
|
227
227
|
"rxjs": "^7.8.2",
|