polkadot-api 0.8.0 → 0.9.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/dist/index.d.mts CHANGED
@@ -247,7 +247,10 @@ type WithCallOptions<Args extends Array<any>> = [
247
247
  ...args: Args,
248
248
  options?: CallOptions
249
249
  ];
250
- type PossibleParents<A extends Array<any>> = A extends [...infer Left, any] ? Left | PossibleParents<Left> : [];
250
+ type PossibleParents<A extends Array<any>> = A extends [...infer Left, any] ? Left | PossibleParents<Left> : ArrayPossibleParents<A>;
251
+ type ArrayPossibleParents<A extends Array<any>, Count extends Array<any> = [], R = []> = A extends Array<infer T> & {
252
+ length: infer L;
253
+ } ? number extends L ? Array<T> : L extends Count["length"] ? R : ArrayPossibleParents<A, [...Count, T], R | Count> : never;
251
254
  type StorageEntryWithoutKeys<Payload> = {
252
255
  /**
253
256
  * `isCompatible` enables you to check whether or not the call you're trying
@@ -345,10 +348,23 @@ type TxInBestBlocksFound = {
345
348
  found: true;
346
349
  } & TxEventsPayload;
347
350
  type TxEventsPayload = {
351
+ /**
352
+ * Verify if extrinsic was successful, i.e. check if `System.ExtrinsicSuccess`
353
+ * is found.
354
+ */
348
355
  ok: boolean;
356
+ /**
357
+ * Array of all events emitted by the tx. Ordered as they are emitted
358
+ * on-chain.
359
+ */
349
360
  events: Array<SystemEvent$1["event"]>;
361
+ /**
362
+ * Block information where the tx is found. `hash` of the block, `number` of
363
+ * the block, `index` of the tx in the block.
364
+ */
350
365
  block: {
351
366
  hash: string;
367
+ number: number;
352
368
  index: number;
353
369
  };
354
370
  };
@@ -357,41 +373,125 @@ type TxFinalized = {
357
373
  txHash: HexString;
358
374
  } & TxEventsPayload;
359
375
  type TxOptions<Asset> = Partial<void extends Asset ? {
376
+ /**
377
+ * Block to target the transaction against. Default: `"finalized"`
378
+ */
360
379
  at: HexString | "best" | "finalized";
380
+ /**
381
+ * Tip in fundamental units. Default: `0`
382
+ */
361
383
  tip: bigint;
384
+ /**
385
+ * Mortality of the transaction. Default: `{ mortal: true, period: 64 }`
386
+ */
362
387
  mortality: {
363
388
  mortal: false;
364
389
  } | {
365
390
  mortal: true;
366
391
  period: number;
367
392
  };
393
+ /**
394
+ * Custom nonce for the transaction. Default: retrieve from latest known
395
+ * finalized block.
396
+ */
368
397
  nonce: number;
369
398
  } : {
399
+ /**
400
+ * Block to target the transaction against. Default: `"finalized"`
401
+ */
370
402
  at: HexString | "best" | "finalized";
403
+ /**
404
+ * Tip in fundamental units. Default: `0`
405
+ */
371
406
  tip: bigint;
407
+ /**
408
+ * Mortality of the transaction. Default: `{ mortal: true, period: 64 }`
409
+ */
372
410
  mortality: {
373
411
  mortal: false;
374
412
  } | {
375
413
  mortal: true;
376
414
  period: number;
377
415
  };
416
+ /**
417
+ * Asset information to pay fees, tip, etc. By default it'll use the
418
+ * native token of the chain.
419
+ */
378
420
  asset: Asset;
421
+ /**
422
+ * Custom nonce for the transaction. Default: retrieve from latest known
423
+ * finalized block.
424
+ */
379
425
  nonce: number;
380
426
  }>;
381
427
  type TxFinalizedPayload = Omit<TxFinalized, "type">;
382
428
  type TxPromise<Asset> = (from: PolkadotSigner, txOptions?: TxOptions<Asset>) => Promise<TxFinalizedPayload>;
383
429
  type TxObservable<Asset> = (from: PolkadotSigner, txOptions?: TxOptions<Asset>) => Observable<TxEvent>;
384
430
  interface TxCall {
431
+ /**
432
+ * SCALE-encoded callData of the transaction.
433
+ *
434
+ * @returns Promise resolving in the encoded data.
435
+ */
385
436
  (): Promise<Binary>;
437
+ /**
438
+ * SCALE-encoded callData of the transaction.
439
+ *
440
+ * @param runtime Runtime from got with `typedApi.runtime`
441
+ * @returns Synchronously returns encoded data.
442
+ */
386
443
  (runtime: Runtime): Binary;
387
444
  }
388
445
  type TxSignFn<Asset> = (from: PolkadotSigner, txOptions?: TxOptions<Asset>) => Promise<HexString>;
389
446
  type Transaction<Arg extends {} | undefined, Pallet extends string, Name extends string, Asset> = {
447
+ /**
448
+ * Pack the transaction, sends it to the signer, and return the signature
449
+ * asynchronously. If the signer fails (or the user cancels the signature)
450
+ * it'll throw an error.
451
+ *
452
+ * @param from `PolkadotSigner`-compliant signer.
453
+ * @param txOptions Optionally pass any number of txOptions.
454
+ * @returns Encoded `SignedExtrinsic` ready for broadcasting.
455
+ */
390
456
  sign: TxSignFn<Asset>;
457
+ /**
458
+ * Observable-based all-in-one transaction submitting. It will sign,
459
+ * broadcast, and track the transaction. The observable is singlecast, i.e.
460
+ * it will sign, broadcast, etc at every subscription. It will complete once
461
+ * the transaction is found in a `finalizedBlock`.
462
+ *
463
+ * @param from `PolkadotSigner`-compliant signer.
464
+ * @param txOptions Optionally pass any number of txOptions.
465
+ * @returns Observable to the transaction.
466
+ */
391
467
  signSubmitAndWatch: TxObservable<Asset>;
468
+ /**
469
+ * Pack the transaction, sends it to the signer, broadcast, and track the
470
+ * transaction. The promise will resolve as soon as the transaction in found
471
+ * in a `finalizedBlock`. If the signer fails (or the user cancels the
472
+ * signature), or the transaction becomes invalid it'll throw an error.
473
+ *
474
+ * @param from `PolkadotSigner`-compliant signer.
475
+ * @param txOptions Optionally pass any number of txOptions.
476
+ * @returns Finalized transaction information.
477
+ */
392
478
  signAndSubmit: TxPromise<Asset>;
479
+ /**
480
+ * SCALE-encoded callData of the transaction.
481
+ */
393
482
  getEncodedData: TxCall;
483
+ /**
484
+ * Estimate fees against the latest known `finalizedBlock`
485
+ *
486
+ * @param from Public key or address from the potencial sender.
487
+ * @param txOptions Optionally pass any number of txOptions.
488
+ * @returns Fees in fundamental units.
489
+ */
394
490
  getEstimatedFees: (from: Uint8Array | SS58String, txOptions?: TxOptions<Asset>) => Promise<bigint>;
491
+ /**
492
+ * PAPI way of expressing an extrinsic with arguments.
493
+ * It's useful to pass as a parameter to extrinsics that accept calls.
494
+ */
395
495
  decodedCall: Enum<{
396
496
  [P in Pallet]: Enum<{
397
497
  [N in Name]: Arg;
@@ -399,7 +499,18 @@ type Transaction<Arg extends {} | undefined, Pallet extends string, Name extends
399
499
  }>;
400
500
  };
401
501
  interface TxEntry<Arg extends {} | undefined, Pallet extends string, Name extends string, Asset> {
502
+ /**
503
+ * Synchronously create the transaction object ready to sign, submit, estimate
504
+ * fees, etc.
505
+ *
506
+ * @param args All parameters required by the transaction.
507
+ * @returns Transaction object.
508
+ */
402
509
  (...args: Arg extends undefined ? [] : [data: Arg]): Transaction<Arg, Pallet, Name, Asset>;
510
+ /**
511
+ * `isCompatible` enables you to check whether or not the call you're trying
512
+ * to make is compatible with the descriptors you generated on dev time.
513
+ */
403
514
  isCompatible: IsCompatible;
404
515
  }
405
516
 
@@ -537,6 +648,10 @@ interface PolkadotClient {
537
648
  * generated by `papi` CLI.
538
649
  */
539
650
  getTypedApi: <D extends ChainDefinition>(descriptors: D) => TypedApi<D>;
651
+ /**
652
+ * This will `unfollow` the provider, disconnect and error every subscription.
653
+ * After calling it nothing can be done with the client.
654
+ */
540
655
  destroy: () => void;
541
656
  /**
542
657
  * This API is meant as an "escape hatch" to allow access to debug endpoints
package/dist/index.d.ts CHANGED
@@ -247,7 +247,10 @@ type WithCallOptions<Args extends Array<any>> = [
247
247
  ...args: Args,
248
248
  options?: CallOptions
249
249
  ];
250
- type PossibleParents<A extends Array<any>> = A extends [...infer Left, any] ? Left | PossibleParents<Left> : [];
250
+ type PossibleParents<A extends Array<any>> = A extends [...infer Left, any] ? Left | PossibleParents<Left> : ArrayPossibleParents<A>;
251
+ type ArrayPossibleParents<A extends Array<any>, Count extends Array<any> = [], R = []> = A extends Array<infer T> & {
252
+ length: infer L;
253
+ } ? number extends L ? Array<T> : L extends Count["length"] ? R : ArrayPossibleParents<A, [...Count, T], R | Count> : never;
251
254
  type StorageEntryWithoutKeys<Payload> = {
252
255
  /**
253
256
  * `isCompatible` enables you to check whether or not the call you're trying
@@ -345,10 +348,23 @@ type TxInBestBlocksFound = {
345
348
  found: true;
346
349
  } & TxEventsPayload;
347
350
  type TxEventsPayload = {
351
+ /**
352
+ * Verify if extrinsic was successful, i.e. check if `System.ExtrinsicSuccess`
353
+ * is found.
354
+ */
348
355
  ok: boolean;
356
+ /**
357
+ * Array of all events emitted by the tx. Ordered as they are emitted
358
+ * on-chain.
359
+ */
349
360
  events: Array<SystemEvent$1["event"]>;
361
+ /**
362
+ * Block information where the tx is found. `hash` of the block, `number` of
363
+ * the block, `index` of the tx in the block.
364
+ */
350
365
  block: {
351
366
  hash: string;
367
+ number: number;
352
368
  index: number;
353
369
  };
354
370
  };
@@ -357,41 +373,125 @@ type TxFinalized = {
357
373
  txHash: HexString;
358
374
  } & TxEventsPayload;
359
375
  type TxOptions<Asset> = Partial<void extends Asset ? {
376
+ /**
377
+ * Block to target the transaction against. Default: `"finalized"`
378
+ */
360
379
  at: HexString | "best" | "finalized";
380
+ /**
381
+ * Tip in fundamental units. Default: `0`
382
+ */
361
383
  tip: bigint;
384
+ /**
385
+ * Mortality of the transaction. Default: `{ mortal: true, period: 64 }`
386
+ */
362
387
  mortality: {
363
388
  mortal: false;
364
389
  } | {
365
390
  mortal: true;
366
391
  period: number;
367
392
  };
393
+ /**
394
+ * Custom nonce for the transaction. Default: retrieve from latest known
395
+ * finalized block.
396
+ */
368
397
  nonce: number;
369
398
  } : {
399
+ /**
400
+ * Block to target the transaction against. Default: `"finalized"`
401
+ */
370
402
  at: HexString | "best" | "finalized";
403
+ /**
404
+ * Tip in fundamental units. Default: `0`
405
+ */
371
406
  tip: bigint;
407
+ /**
408
+ * Mortality of the transaction. Default: `{ mortal: true, period: 64 }`
409
+ */
372
410
  mortality: {
373
411
  mortal: false;
374
412
  } | {
375
413
  mortal: true;
376
414
  period: number;
377
415
  };
416
+ /**
417
+ * Asset information to pay fees, tip, etc. By default it'll use the
418
+ * native token of the chain.
419
+ */
378
420
  asset: Asset;
421
+ /**
422
+ * Custom nonce for the transaction. Default: retrieve from latest known
423
+ * finalized block.
424
+ */
379
425
  nonce: number;
380
426
  }>;
381
427
  type TxFinalizedPayload = Omit<TxFinalized, "type">;
382
428
  type TxPromise<Asset> = (from: PolkadotSigner, txOptions?: TxOptions<Asset>) => Promise<TxFinalizedPayload>;
383
429
  type TxObservable<Asset> = (from: PolkadotSigner, txOptions?: TxOptions<Asset>) => Observable<TxEvent>;
384
430
  interface TxCall {
431
+ /**
432
+ * SCALE-encoded callData of the transaction.
433
+ *
434
+ * @returns Promise resolving in the encoded data.
435
+ */
385
436
  (): Promise<Binary>;
437
+ /**
438
+ * SCALE-encoded callData of the transaction.
439
+ *
440
+ * @param runtime Runtime from got with `typedApi.runtime`
441
+ * @returns Synchronously returns encoded data.
442
+ */
386
443
  (runtime: Runtime): Binary;
387
444
  }
388
445
  type TxSignFn<Asset> = (from: PolkadotSigner, txOptions?: TxOptions<Asset>) => Promise<HexString>;
389
446
  type Transaction<Arg extends {} | undefined, Pallet extends string, Name extends string, Asset> = {
447
+ /**
448
+ * Pack the transaction, sends it to the signer, and return the signature
449
+ * asynchronously. If the signer fails (or the user cancels the signature)
450
+ * it'll throw an error.
451
+ *
452
+ * @param from `PolkadotSigner`-compliant signer.
453
+ * @param txOptions Optionally pass any number of txOptions.
454
+ * @returns Encoded `SignedExtrinsic` ready for broadcasting.
455
+ */
390
456
  sign: TxSignFn<Asset>;
457
+ /**
458
+ * Observable-based all-in-one transaction submitting. It will sign,
459
+ * broadcast, and track the transaction. The observable is singlecast, i.e.
460
+ * it will sign, broadcast, etc at every subscription. It will complete once
461
+ * the transaction is found in a `finalizedBlock`.
462
+ *
463
+ * @param from `PolkadotSigner`-compliant signer.
464
+ * @param txOptions Optionally pass any number of txOptions.
465
+ * @returns Observable to the transaction.
466
+ */
391
467
  signSubmitAndWatch: TxObservable<Asset>;
468
+ /**
469
+ * Pack the transaction, sends it to the signer, broadcast, and track the
470
+ * transaction. The promise will resolve as soon as the transaction in found
471
+ * in a `finalizedBlock`. If the signer fails (or the user cancels the
472
+ * signature), or the transaction becomes invalid it'll throw an error.
473
+ *
474
+ * @param from `PolkadotSigner`-compliant signer.
475
+ * @param txOptions Optionally pass any number of txOptions.
476
+ * @returns Finalized transaction information.
477
+ */
392
478
  signAndSubmit: TxPromise<Asset>;
479
+ /**
480
+ * SCALE-encoded callData of the transaction.
481
+ */
393
482
  getEncodedData: TxCall;
483
+ /**
484
+ * Estimate fees against the latest known `finalizedBlock`
485
+ *
486
+ * @param from Public key or address from the potencial sender.
487
+ * @param txOptions Optionally pass any number of txOptions.
488
+ * @returns Fees in fundamental units.
489
+ */
394
490
  getEstimatedFees: (from: Uint8Array | SS58String, txOptions?: TxOptions<Asset>) => Promise<bigint>;
491
+ /**
492
+ * PAPI way of expressing an extrinsic with arguments.
493
+ * It's useful to pass as a parameter to extrinsics that accept calls.
494
+ */
395
495
  decodedCall: Enum<{
396
496
  [P in Pallet]: Enum<{
397
497
  [N in Name]: Arg;
@@ -399,7 +499,18 @@ type Transaction<Arg extends {} | undefined, Pallet extends string, Name extends
399
499
  }>;
400
500
  };
401
501
  interface TxEntry<Arg extends {} | undefined, Pallet extends string, Name extends string, Asset> {
502
+ /**
503
+ * Synchronously create the transaction object ready to sign, submit, estimate
504
+ * fees, etc.
505
+ *
506
+ * @param args All parameters required by the transaction.
507
+ * @returns Transaction object.
508
+ */
402
509
  (...args: Arg extends undefined ? [] : [data: Arg]): Transaction<Arg, Pallet, Name, Asset>;
510
+ /**
511
+ * `isCompatible` enables you to check whether or not the call you're trying
512
+ * to make is compatible with the descriptors you generated on dev time.
513
+ */
403
514
  isCompatible: IsCompatible;
404
515
  }
405
516
 
@@ -537,6 +648,10 @@ interface PolkadotClient {
537
648
  * generated by `papi` CLI.
538
649
  */
539
650
  getTypedApi: <D extends ChainDefinition>(descriptors: D) => TypedApi<D>;
651
+ /**
652
+ * This will `unfollow` the provider, disconnect and error every subscription.
653
+ * After calling it nothing can be done with the client.
654
+ */
540
655
  destroy: () => void;
541
656
  /**
542
657
  * This API is meant as an "escape hatch" to allow access to debug endpoints
package/dist/index.js CHANGED
@@ -54,8 +54,7 @@ var createConstantEntry = (palletName, name, chainHead, compatibilityHelper2) =>
54
54
  };
55
55
  const fn = (runtime) => {
56
56
  if (runtime) {
57
- if (!isCompatible(runtime))
58
- throw checksumError();
57
+ if (!isCompatible(runtime)) throw checksumError();
59
58
  return getValueWithContext(runtime._getCtx());
60
59
  }
61
60
  return (0, import_rxjs.firstValueFrom)(
@@ -105,8 +104,7 @@ function firstValueFromWithSignal(source, signal) {
105
104
  reject(new Error("Observable completed without emitting"));
106
105
  }
107
106
  });
108
- if (!isDone)
109
- signal?.addEventListener("abort", onAbort);
107
+ if (!isDone) signal?.addEventListener("abort", onAbort);
110
108
  });
111
109
  }
112
110
 
@@ -231,8 +229,7 @@ var raceMap = (mapper, concurrent) => (source$) => new import_rxjs5.Observable((
231
229
  observer.error(err);
232
230
  },
233
231
  complete() {
234
- if (innerSubscriptions.length === 0)
235
- observer.complete();
232
+ if (innerSubscriptions.length === 0) observer.complete();
236
233
  isOuterDone = true;
237
234
  }
238
235
  });
@@ -255,10 +252,8 @@ var continueWith = (mapper) => (source) => new import_rxjs6.Observable((observer
255
252
  observer.error(e);
256
253
  },
257
254
  complete() {
258
- if (latestValue === NOTIN)
259
- observer.complete();
260
- else
261
- subscription = mapper(latestValue).subscribe(observer);
255
+ if (latestValue === NOTIN) observer.complete();
256
+ else subscription = mapper(latestValue).subscribe(observer);
262
257
  }
263
258
  });
264
259
  return () => {
@@ -396,8 +391,7 @@ var compatibilityHelper = (runtimeApi, getDescriptorChecksum) => (getChecksum) =
396
391
  var import_utils4 = require("@polkadot-api/utils");
397
392
  var import_rxjs9 = require("rxjs");
398
393
  var isOptionalArg = (lastArg) => {
399
- if (typeof lastArg !== "object")
400
- return false;
394
+ if (typeof lastArg !== "object") return false;
401
395
  return Object.keys(lastArg).every(
402
396
  (k) => k === "at" && typeof lastArg.at === "string" || k === "signal" && lastArg.signal instanceof AbortSignal
403
397
  );
@@ -428,8 +422,7 @@ var createRuntimeCallEntry = (api, method, chainHead, compatibilityHelper2) => {
428
422
  var import_rxjs10 = require("rxjs");
429
423
  var import_observable_client = require("@polkadot-api/observable-client");
430
424
  var isOptionalArg2 = (lastArg) => {
431
- if (typeof lastArg !== "object")
432
- return false;
425
+ if (typeof lastArg !== "object") return false;
433
426
  return Object.keys(lastArg).every(
434
427
  (k) => k === "at" && typeof lastArg.at === "string" || k === "signal" && lastArg.signal instanceof AbortSignal
435
428
  );
@@ -469,15 +462,12 @@ var createStorageEntry = (pallet, name, chainHead, compatibilityHelper2) => {
469
462
  if (isSystemNumber) {
470
463
  result$ = chainHead.bestBlocks$.pipe(
471
464
  (0, import_rxjs10.map)((blocks) => {
472
- if (at === "finalized" || !at)
473
- return blocks.at(-1);
474
- if (at === "best")
475
- return blocks.at(0);
465
+ if (at === "finalized" || !at) return blocks.at(-1);
466
+ if (at === "best") return blocks.at(0);
476
467
  return blocks.find((block) => block.hash === at);
477
468
  }),
478
469
  (0, import_rxjs10.map)((block) => {
479
- if (!block)
480
- throw new import_observable_client.NotBestBlockError();
470
+ if (!block) throw new import_observable_client.NotBestBlockError();
481
471
  return block.number;
482
472
  }),
483
473
  (0, import_rxjs10.distinctUntilChanged)()
@@ -488,12 +478,10 @@ var createStorageEntry = (pallet, name, chainHead, compatibilityHelper2) => {
488
478
  at,
489
479
  "value",
490
480
  (ctx) => {
491
- if (!isCompatible2(ctx))
492
- throw checksumError();
481
+ if (!isCompatible2(ctx)) throw checksumError();
493
482
  const codecs = ctx.dynamicBuilder.buildStorage(pallet, name);
494
483
  const actualArgs = args.length === codecs.len ? args : args.slice(0, -1);
495
- if (args !== actualArgs && !isLastArgOptional)
496
- throw invalidArgs(args);
484
+ if (args !== actualArgs && !isLastArgOptional) throw invalidArgs(args);
497
485
  return codecs.enc(...actualArgs);
498
486
  },
499
487
  null,
@@ -515,11 +503,9 @@ var createStorageEntry = (pallet, name, chainHead, compatibilityHelper2) => {
515
503
  at,
516
504
  "descendantsValues",
517
505
  (ctx) => {
518
- if (!isCompatible2(ctx))
519
- throw checksumError();
506
+ if (!isCompatible2(ctx)) throw checksumError();
520
507
  const codecs = ctx.dynamicBuilder.buildStorage(pallet, name);
521
- if (args.length > codecs.len)
522
- throw invalidArgs(args);
508
+ if (args.length > codecs.len) throw invalidArgs(args);
523
509
  const actualArgs = args.length > 0 && isLastArgOptional ? args.slice(0, -1) : args;
524
510
  if (args.length === codecs.len && actualArgs === args)
525
511
  throw invalidArgs(args);
@@ -572,8 +558,7 @@ var systemVersionProp$ = (propName, metadata) => {
572
558
  const constant = metadata.pallets.find((x) => x.name === "System").constants.find((s) => s.name === "Version");
573
559
  const systemVersion = lookupFn(constant.type);
574
560
  const systemVersionDec = dynamicBuilder.buildDefinition(constant.type).dec;
575
- if (systemVersion.type !== "struct")
576
- throw new Error("not a struct");
561
+ if (systemVersion.type !== "struct") throw new Error("not a struct");
577
562
  const valueEnc = dynamicBuilder.buildDefinition(
578
563
  systemVersion.value[propName].id
579
564
  ).enc;
@@ -769,30 +754,27 @@ var computeState = (analized$, blocks$) => new import_rxjs21.Observable((observe
769
754
  let analyzed = analyzedBlocks.get(current);
770
755
  while (!analyzed) {
771
756
  const block = pinnedBlocks.blocks.get(current);
772
- if (!block)
773
- break;
757
+ if (!block) break;
774
758
  analyzed = analyzedBlocks.get(current = block.parent);
775
759
  }
776
- if (!analyzed)
777
- return;
778
- const isFinalized = pinnedBlocks.blocks.get(analyzed.hash).number <= pinnedBlocks.blocks.get(pinnedBlocks.finalized).number;
760
+ if (!analyzed) return;
761
+ const analyzedNumber = pinnedBlocks.blocks.get(analyzed.hash).number;
762
+ const isFinalized = analyzedNumber <= pinnedBlocks.blocks.get(pinnedBlocks.finalized).number;
779
763
  const found = analyzed.found.type;
780
764
  if (found && typeof latestState === "object" && latestState.hash === analyzed.hash) {
781
- if (isFinalized)
782
- observer.complete();
765
+ if (isFinalized) observer.complete();
783
766
  return;
784
767
  }
785
768
  observer.next(
786
769
  latestState = found ? {
787
770
  hash: analyzed.hash,
771
+ number: analyzedNumber,
788
772
  ...analyzed.found
789
773
  } : analyzed.found.isValid
790
774
  );
791
775
  if (isFinalized) {
792
- if (found)
793
- observer.complete();
794
- else if (!analyzed.found.isValid)
795
- observer.error(new Error("Invalid"));
776
+ if (found) observer.complete();
777
+ else if (!analyzed.found.isValid) observer.error(new Error("Invalid"));
796
778
  }
797
779
  };
798
780
  const subscription = blocks$.pipe(
@@ -802,8 +784,7 @@ var computeState = (analized$, blocks$) => new import_rxjs21.Observable((observe
802
784
  ).subscribe({
803
785
  next: (pinned) => {
804
786
  pinnedBlocks = pinned;
805
- if (analyzedBlocks.size === 0)
806
- return;
787
+ if (analyzedBlocks.size === 0) return;
807
788
  computeNextState();
808
789
  },
809
790
  error(e) {
@@ -872,6 +853,7 @@ var submit$ = (chainHead, broadcastTx$, tx, at, emitSign = false) => {
872
853
  found: true,
873
854
  block: {
874
855
  index: x.index,
856
+ number: x.number,
875
857
  hash: x.hash
876
858
  },
877
859
  ...getTxSuccessFromSystemEvents(x.events, x.index)
@@ -890,8 +872,7 @@ var submit$ = (chainHead, broadcastTx$, tx, at, emitSign = false) => {
890
872
  );
891
873
  };
892
874
  var submit = async (chainHead, broadcastTx$, transaction, at) => (0, import_rxjs21.lastValueFrom)(submit$(chainHead, broadcastTx$, transaction, at)).then((x) => {
893
- if (x.type !== "finalized")
894
- throw null;
875
+ if (x.type !== "finalized") throw null;
895
876
  const result = { ...x };
896
877
  delete result.type;
897
878
  return result;
@@ -930,8 +911,7 @@ var createTxEntry = (pallet, name, assetChecksum, chainHead, broadcast, compatib
930
911
  const getEncodedData = (runtime) => {
931
912
  if (!runtime)
932
913
  return (0, import_rxjs22.firstValueFrom)(getCallData$(arg).pipe((0, import_rxjs22.map)((x) => x.callData)));
933
- if (!isCompatible(runtime))
934
- throw checksumError();
914
+ if (!isCompatible(runtime)) throw checksumError();
935
915
  return getCallDataWithContext(runtime._getCtx(), arg).callData;
936
916
  };
937
917
  const sign$ = (from, { ..._options }, atBlock) => getCallData$(arg, _options).pipe(
@@ -1006,11 +986,9 @@ var createTypedApi = (chainDefinition, chainHead, broadcast$) => {
1006
986
  const createProxyPath = (pathCall) => {
1007
987
  const cache = {};
1008
988
  return createProxy((a) => {
1009
- if (!cache[a])
1010
- cache[a] = {};
989
+ if (!cache[a]) cache[a] = {};
1011
990
  return createProxy((b) => {
1012
- if (!cache[a][b])
1013
- cache[a][b] = pathCall(a, b);
991
+ if (!cache[a][b]) cache[a][b] = pathCall(a, b);
1014
992
  return cache[a][b];
1015
993
  });
1016
994
  });