polkadot-api 0.8.0 → 0.9.0
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 +112 -0
- package/dist/index.d.ts +112 -0
- package/dist/index.js +29 -51
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -51
- package/dist/index.mjs.map +1 -1
- package/dist/min/index.d.ts +112 -0
- package/dist/min/index.js +1 -1
- package/dist/min/index.js.map +1 -1
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -345,10 +345,23 @@ type TxInBestBlocksFound = {
|
|
|
345
345
|
found: true;
|
|
346
346
|
} & TxEventsPayload;
|
|
347
347
|
type TxEventsPayload = {
|
|
348
|
+
/**
|
|
349
|
+
* Verify if extrinsic was successful, i.e. check if `System.ExtrinsicSuccess`
|
|
350
|
+
* is found.
|
|
351
|
+
*/
|
|
348
352
|
ok: boolean;
|
|
353
|
+
/**
|
|
354
|
+
* Array of all events emitted by the tx. Ordered as they are emitted
|
|
355
|
+
* on-chain.
|
|
356
|
+
*/
|
|
349
357
|
events: Array<SystemEvent$1["event"]>;
|
|
358
|
+
/**
|
|
359
|
+
* Block information where the tx is found. `hash` of the block, `number` of
|
|
360
|
+
* the block, `index` of the tx in the block.
|
|
361
|
+
*/
|
|
350
362
|
block: {
|
|
351
363
|
hash: string;
|
|
364
|
+
number: number;
|
|
352
365
|
index: number;
|
|
353
366
|
};
|
|
354
367
|
};
|
|
@@ -357,41 +370,125 @@ type TxFinalized = {
|
|
|
357
370
|
txHash: HexString;
|
|
358
371
|
} & TxEventsPayload;
|
|
359
372
|
type TxOptions<Asset> = Partial<void extends Asset ? {
|
|
373
|
+
/**
|
|
374
|
+
* Block to target the transaction against. Default: `"finalized"`
|
|
375
|
+
*/
|
|
360
376
|
at: HexString | "best" | "finalized";
|
|
377
|
+
/**
|
|
378
|
+
* Tip in fundamental units. Default: `0`
|
|
379
|
+
*/
|
|
361
380
|
tip: bigint;
|
|
381
|
+
/**
|
|
382
|
+
* Mortality of the transaction. Default: `{ mortal: true, period: 64 }`
|
|
383
|
+
*/
|
|
362
384
|
mortality: {
|
|
363
385
|
mortal: false;
|
|
364
386
|
} | {
|
|
365
387
|
mortal: true;
|
|
366
388
|
period: number;
|
|
367
389
|
};
|
|
390
|
+
/**
|
|
391
|
+
* Custom nonce for the transaction. Default: retrieve from latest known
|
|
392
|
+
* finalized block.
|
|
393
|
+
*/
|
|
368
394
|
nonce: number;
|
|
369
395
|
} : {
|
|
396
|
+
/**
|
|
397
|
+
* Block to target the transaction against. Default: `"finalized"`
|
|
398
|
+
*/
|
|
370
399
|
at: HexString | "best" | "finalized";
|
|
400
|
+
/**
|
|
401
|
+
* Tip in fundamental units. Default: `0`
|
|
402
|
+
*/
|
|
371
403
|
tip: bigint;
|
|
404
|
+
/**
|
|
405
|
+
* Mortality of the transaction. Default: `{ mortal: true, period: 64 }`
|
|
406
|
+
*/
|
|
372
407
|
mortality: {
|
|
373
408
|
mortal: false;
|
|
374
409
|
} | {
|
|
375
410
|
mortal: true;
|
|
376
411
|
period: number;
|
|
377
412
|
};
|
|
413
|
+
/**
|
|
414
|
+
* Asset information to pay fees, tip, etc. By default it'll use the
|
|
415
|
+
* native token of the chain.
|
|
416
|
+
*/
|
|
378
417
|
asset: Asset;
|
|
418
|
+
/**
|
|
419
|
+
* Custom nonce for the transaction. Default: retrieve from latest known
|
|
420
|
+
* finalized block.
|
|
421
|
+
*/
|
|
379
422
|
nonce: number;
|
|
380
423
|
}>;
|
|
381
424
|
type TxFinalizedPayload = Omit<TxFinalized, "type">;
|
|
382
425
|
type TxPromise<Asset> = (from: PolkadotSigner, txOptions?: TxOptions<Asset>) => Promise<TxFinalizedPayload>;
|
|
383
426
|
type TxObservable<Asset> = (from: PolkadotSigner, txOptions?: TxOptions<Asset>) => Observable<TxEvent>;
|
|
384
427
|
interface TxCall {
|
|
428
|
+
/**
|
|
429
|
+
* SCALE-encoded callData of the transaction.
|
|
430
|
+
*
|
|
431
|
+
* @returns Promise resolving in the encoded data.
|
|
432
|
+
*/
|
|
385
433
|
(): Promise<Binary>;
|
|
434
|
+
/**
|
|
435
|
+
* SCALE-encoded callData of the transaction.
|
|
436
|
+
*
|
|
437
|
+
* @param runtime Runtime from got with `typedApi.runtime`
|
|
438
|
+
* @returns Synchronously returns encoded data.
|
|
439
|
+
*/
|
|
386
440
|
(runtime: Runtime): Binary;
|
|
387
441
|
}
|
|
388
442
|
type TxSignFn<Asset> = (from: PolkadotSigner, txOptions?: TxOptions<Asset>) => Promise<HexString>;
|
|
389
443
|
type Transaction<Arg extends {} | undefined, Pallet extends string, Name extends string, Asset> = {
|
|
444
|
+
/**
|
|
445
|
+
* Pack the transaction, sends it to the signer, and return the signature
|
|
446
|
+
* asynchronously. If the signer fails (or the user cancels the signature)
|
|
447
|
+
* it'll throw an error.
|
|
448
|
+
*
|
|
449
|
+
* @param from `PolkadotSigner`-compliant signer.
|
|
450
|
+
* @param txOptions Optionally pass any number of txOptions.
|
|
451
|
+
* @returns Encoded `SignedExtrinsic` ready for broadcasting.
|
|
452
|
+
*/
|
|
390
453
|
sign: TxSignFn<Asset>;
|
|
454
|
+
/**
|
|
455
|
+
* Observable-based all-in-one transaction submitting. It will sign,
|
|
456
|
+
* broadcast, and track the transaction. The observable is singlecast, i.e.
|
|
457
|
+
* it will sign, broadcast, etc at every subscription. It will complete once
|
|
458
|
+
* the transaction is found in a `finalizedBlock`.
|
|
459
|
+
*
|
|
460
|
+
* @param from `PolkadotSigner`-compliant signer.
|
|
461
|
+
* @param txOptions Optionally pass any number of txOptions.
|
|
462
|
+
* @returns Observable to the transaction.
|
|
463
|
+
*/
|
|
391
464
|
signSubmitAndWatch: TxObservable<Asset>;
|
|
465
|
+
/**
|
|
466
|
+
* Pack the transaction, sends it to the signer, broadcast, and track the
|
|
467
|
+
* transaction. The promise will resolve as soon as the transaction in found
|
|
468
|
+
* in a `finalizedBlock`. If the signer fails (or the user cancels the
|
|
469
|
+
* signature), or the transaction becomes invalid it'll throw an error.
|
|
470
|
+
*
|
|
471
|
+
* @param from `PolkadotSigner`-compliant signer.
|
|
472
|
+
* @param txOptions Optionally pass any number of txOptions.
|
|
473
|
+
* @returns Finalized transaction information.
|
|
474
|
+
*/
|
|
392
475
|
signAndSubmit: TxPromise<Asset>;
|
|
476
|
+
/**
|
|
477
|
+
* SCALE-encoded callData of the transaction.
|
|
478
|
+
*/
|
|
393
479
|
getEncodedData: TxCall;
|
|
480
|
+
/**
|
|
481
|
+
* Estimate fees against the latest known `finalizedBlock`
|
|
482
|
+
*
|
|
483
|
+
* @param from Public key or address from the potencial sender.
|
|
484
|
+
* @param txOptions Optionally pass any number of txOptions.
|
|
485
|
+
* @returns Fees in fundamental units.
|
|
486
|
+
*/
|
|
394
487
|
getEstimatedFees: (from: Uint8Array | SS58String, txOptions?: TxOptions<Asset>) => Promise<bigint>;
|
|
488
|
+
/**
|
|
489
|
+
* PAPI way of expressing an extrinsic with arguments.
|
|
490
|
+
* It's useful to pass as a parameter to extrinsics that accept calls.
|
|
491
|
+
*/
|
|
395
492
|
decodedCall: Enum<{
|
|
396
493
|
[P in Pallet]: Enum<{
|
|
397
494
|
[N in Name]: Arg;
|
|
@@ -399,7 +496,18 @@ type Transaction<Arg extends {} | undefined, Pallet extends string, Name extends
|
|
|
399
496
|
}>;
|
|
400
497
|
};
|
|
401
498
|
interface TxEntry<Arg extends {} | undefined, Pallet extends string, Name extends string, Asset> {
|
|
499
|
+
/**
|
|
500
|
+
* Synchronously create the transaction object ready to sign, submit, estimate
|
|
501
|
+
* fees, etc.
|
|
502
|
+
*
|
|
503
|
+
* @param args All parameters required by the transaction.
|
|
504
|
+
* @returns Transaction object.
|
|
505
|
+
*/
|
|
402
506
|
(...args: Arg extends undefined ? [] : [data: Arg]): Transaction<Arg, Pallet, Name, Asset>;
|
|
507
|
+
/**
|
|
508
|
+
* `isCompatible` enables you to check whether or not the call you're trying
|
|
509
|
+
* to make is compatible with the descriptors you generated on dev time.
|
|
510
|
+
*/
|
|
403
511
|
isCompatible: IsCompatible;
|
|
404
512
|
}
|
|
405
513
|
|
|
@@ -537,6 +645,10 @@ interface PolkadotClient {
|
|
|
537
645
|
* generated by `papi` CLI.
|
|
538
646
|
*/
|
|
539
647
|
getTypedApi: <D extends ChainDefinition>(descriptors: D) => TypedApi<D>;
|
|
648
|
+
/**
|
|
649
|
+
* This will `unfollow` the provider, disconnect and error every subscription.
|
|
650
|
+
* After calling it nothing can be done with the client.
|
|
651
|
+
*/
|
|
540
652
|
destroy: () => void;
|
|
541
653
|
/**
|
|
542
654
|
* This API is meant as an "escape hatch" to allow access to debug endpoints
|
package/dist/index.d.ts
CHANGED
|
@@ -345,10 +345,23 @@ type TxInBestBlocksFound = {
|
|
|
345
345
|
found: true;
|
|
346
346
|
} & TxEventsPayload;
|
|
347
347
|
type TxEventsPayload = {
|
|
348
|
+
/**
|
|
349
|
+
* Verify if extrinsic was successful, i.e. check if `System.ExtrinsicSuccess`
|
|
350
|
+
* is found.
|
|
351
|
+
*/
|
|
348
352
|
ok: boolean;
|
|
353
|
+
/**
|
|
354
|
+
* Array of all events emitted by the tx. Ordered as they are emitted
|
|
355
|
+
* on-chain.
|
|
356
|
+
*/
|
|
349
357
|
events: Array<SystemEvent$1["event"]>;
|
|
358
|
+
/**
|
|
359
|
+
* Block information where the tx is found. `hash` of the block, `number` of
|
|
360
|
+
* the block, `index` of the tx in the block.
|
|
361
|
+
*/
|
|
350
362
|
block: {
|
|
351
363
|
hash: string;
|
|
364
|
+
number: number;
|
|
352
365
|
index: number;
|
|
353
366
|
};
|
|
354
367
|
};
|
|
@@ -357,41 +370,125 @@ type TxFinalized = {
|
|
|
357
370
|
txHash: HexString;
|
|
358
371
|
} & TxEventsPayload;
|
|
359
372
|
type TxOptions<Asset> = Partial<void extends Asset ? {
|
|
373
|
+
/**
|
|
374
|
+
* Block to target the transaction against. Default: `"finalized"`
|
|
375
|
+
*/
|
|
360
376
|
at: HexString | "best" | "finalized";
|
|
377
|
+
/**
|
|
378
|
+
* Tip in fundamental units. Default: `0`
|
|
379
|
+
*/
|
|
361
380
|
tip: bigint;
|
|
381
|
+
/**
|
|
382
|
+
* Mortality of the transaction. Default: `{ mortal: true, period: 64 }`
|
|
383
|
+
*/
|
|
362
384
|
mortality: {
|
|
363
385
|
mortal: false;
|
|
364
386
|
} | {
|
|
365
387
|
mortal: true;
|
|
366
388
|
period: number;
|
|
367
389
|
};
|
|
390
|
+
/**
|
|
391
|
+
* Custom nonce for the transaction. Default: retrieve from latest known
|
|
392
|
+
* finalized block.
|
|
393
|
+
*/
|
|
368
394
|
nonce: number;
|
|
369
395
|
} : {
|
|
396
|
+
/**
|
|
397
|
+
* Block to target the transaction against. Default: `"finalized"`
|
|
398
|
+
*/
|
|
370
399
|
at: HexString | "best" | "finalized";
|
|
400
|
+
/**
|
|
401
|
+
* Tip in fundamental units. Default: `0`
|
|
402
|
+
*/
|
|
371
403
|
tip: bigint;
|
|
404
|
+
/**
|
|
405
|
+
* Mortality of the transaction. Default: `{ mortal: true, period: 64 }`
|
|
406
|
+
*/
|
|
372
407
|
mortality: {
|
|
373
408
|
mortal: false;
|
|
374
409
|
} | {
|
|
375
410
|
mortal: true;
|
|
376
411
|
period: number;
|
|
377
412
|
};
|
|
413
|
+
/**
|
|
414
|
+
* Asset information to pay fees, tip, etc. By default it'll use the
|
|
415
|
+
* native token of the chain.
|
|
416
|
+
*/
|
|
378
417
|
asset: Asset;
|
|
418
|
+
/**
|
|
419
|
+
* Custom nonce for the transaction. Default: retrieve from latest known
|
|
420
|
+
* finalized block.
|
|
421
|
+
*/
|
|
379
422
|
nonce: number;
|
|
380
423
|
}>;
|
|
381
424
|
type TxFinalizedPayload = Omit<TxFinalized, "type">;
|
|
382
425
|
type TxPromise<Asset> = (from: PolkadotSigner, txOptions?: TxOptions<Asset>) => Promise<TxFinalizedPayload>;
|
|
383
426
|
type TxObservable<Asset> = (from: PolkadotSigner, txOptions?: TxOptions<Asset>) => Observable<TxEvent>;
|
|
384
427
|
interface TxCall {
|
|
428
|
+
/**
|
|
429
|
+
* SCALE-encoded callData of the transaction.
|
|
430
|
+
*
|
|
431
|
+
* @returns Promise resolving in the encoded data.
|
|
432
|
+
*/
|
|
385
433
|
(): Promise<Binary>;
|
|
434
|
+
/**
|
|
435
|
+
* SCALE-encoded callData of the transaction.
|
|
436
|
+
*
|
|
437
|
+
* @param runtime Runtime from got with `typedApi.runtime`
|
|
438
|
+
* @returns Synchronously returns encoded data.
|
|
439
|
+
*/
|
|
386
440
|
(runtime: Runtime): Binary;
|
|
387
441
|
}
|
|
388
442
|
type TxSignFn<Asset> = (from: PolkadotSigner, txOptions?: TxOptions<Asset>) => Promise<HexString>;
|
|
389
443
|
type Transaction<Arg extends {} | undefined, Pallet extends string, Name extends string, Asset> = {
|
|
444
|
+
/**
|
|
445
|
+
* Pack the transaction, sends it to the signer, and return the signature
|
|
446
|
+
* asynchronously. If the signer fails (or the user cancels the signature)
|
|
447
|
+
* it'll throw an error.
|
|
448
|
+
*
|
|
449
|
+
* @param from `PolkadotSigner`-compliant signer.
|
|
450
|
+
* @param txOptions Optionally pass any number of txOptions.
|
|
451
|
+
* @returns Encoded `SignedExtrinsic` ready for broadcasting.
|
|
452
|
+
*/
|
|
390
453
|
sign: TxSignFn<Asset>;
|
|
454
|
+
/**
|
|
455
|
+
* Observable-based all-in-one transaction submitting. It will sign,
|
|
456
|
+
* broadcast, and track the transaction. The observable is singlecast, i.e.
|
|
457
|
+
* it will sign, broadcast, etc at every subscription. It will complete once
|
|
458
|
+
* the transaction is found in a `finalizedBlock`.
|
|
459
|
+
*
|
|
460
|
+
* @param from `PolkadotSigner`-compliant signer.
|
|
461
|
+
* @param txOptions Optionally pass any number of txOptions.
|
|
462
|
+
* @returns Observable to the transaction.
|
|
463
|
+
*/
|
|
391
464
|
signSubmitAndWatch: TxObservable<Asset>;
|
|
465
|
+
/**
|
|
466
|
+
* Pack the transaction, sends it to the signer, broadcast, and track the
|
|
467
|
+
* transaction. The promise will resolve as soon as the transaction in found
|
|
468
|
+
* in a `finalizedBlock`. If the signer fails (or the user cancels the
|
|
469
|
+
* signature), or the transaction becomes invalid it'll throw an error.
|
|
470
|
+
*
|
|
471
|
+
* @param from `PolkadotSigner`-compliant signer.
|
|
472
|
+
* @param txOptions Optionally pass any number of txOptions.
|
|
473
|
+
* @returns Finalized transaction information.
|
|
474
|
+
*/
|
|
392
475
|
signAndSubmit: TxPromise<Asset>;
|
|
476
|
+
/**
|
|
477
|
+
* SCALE-encoded callData of the transaction.
|
|
478
|
+
*/
|
|
393
479
|
getEncodedData: TxCall;
|
|
480
|
+
/**
|
|
481
|
+
* Estimate fees against the latest known `finalizedBlock`
|
|
482
|
+
*
|
|
483
|
+
* @param from Public key or address from the potencial sender.
|
|
484
|
+
* @param txOptions Optionally pass any number of txOptions.
|
|
485
|
+
* @returns Fees in fundamental units.
|
|
486
|
+
*/
|
|
394
487
|
getEstimatedFees: (from: Uint8Array | SS58String, txOptions?: TxOptions<Asset>) => Promise<bigint>;
|
|
488
|
+
/**
|
|
489
|
+
* PAPI way of expressing an extrinsic with arguments.
|
|
490
|
+
* It's useful to pass as a parameter to extrinsics that accept calls.
|
|
491
|
+
*/
|
|
395
492
|
decodedCall: Enum<{
|
|
396
493
|
[P in Pallet]: Enum<{
|
|
397
494
|
[N in Name]: Arg;
|
|
@@ -399,7 +496,18 @@ type Transaction<Arg extends {} | undefined, Pallet extends string, Name extends
|
|
|
399
496
|
}>;
|
|
400
497
|
};
|
|
401
498
|
interface TxEntry<Arg extends {} | undefined, Pallet extends string, Name extends string, Asset> {
|
|
499
|
+
/**
|
|
500
|
+
* Synchronously create the transaction object ready to sign, submit, estimate
|
|
501
|
+
* fees, etc.
|
|
502
|
+
*
|
|
503
|
+
* @param args All parameters required by the transaction.
|
|
504
|
+
* @returns Transaction object.
|
|
505
|
+
*/
|
|
402
506
|
(...args: Arg extends undefined ? [] : [data: Arg]): Transaction<Arg, Pallet, Name, Asset>;
|
|
507
|
+
/**
|
|
508
|
+
* `isCompatible` enables you to check whether or not the call you're trying
|
|
509
|
+
* to make is compatible with the descriptors you generated on dev time.
|
|
510
|
+
*/
|
|
403
511
|
isCompatible: IsCompatible;
|
|
404
512
|
}
|
|
405
513
|
|
|
@@ -537,6 +645,10 @@ interface PolkadotClient {
|
|
|
537
645
|
* generated by `papi` CLI.
|
|
538
646
|
*/
|
|
539
647
|
getTypedApi: <D extends ChainDefinition>(descriptors: D) => TypedApi<D>;
|
|
648
|
+
/**
|
|
649
|
+
* This will `unfollow` the provider, disconnect and error every subscription.
|
|
650
|
+
* After calling it nothing can be done with the client.
|
|
651
|
+
*/
|
|
540
652
|
destroy: () => void;
|
|
541
653
|
/**
|
|
542
654
|
* 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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
778
|
-
const isFinalized =
|
|
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
|
-
|
|
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
|
});
|