@talismn/sapi 0.0.5 → 0.0.7

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.
@@ -8,4 +8,6 @@ export declare const getDecodedCall: (palletName: string, methodName: string, ar
8
8
  value: unknown;
9
9
  };
10
10
  };
11
- export declare const getDecodedCallFromPayload: <Res extends DecodedCall>(chain: Chain, payload: SignerPayloadJSON) => Res;
11
+ export declare const getDecodedCallFromPayload: <Res extends DecodedCall>(chain: Chain, payload: {
12
+ method: SignerPayloadJSON["method"];
13
+ }) => Res;
@@ -1,8 +1,6 @@
1
1
  import { ExtDef } from "@polkadot/types/extrinsic/signedExtensions/types";
2
- import { getDynamicBuilder, getLookupFn, UnifiedMetadata } from "@talismn/scale";
2
+ import { MetadataBuilder, MetadataLookup, UnifiedMetadata } from "@talismn/scale";
3
3
  import { SapiConnector } from "./getSapiConnector";
4
- export type ScaleBuilder = ReturnType<typeof getDynamicBuilder>;
5
- export type ScaleLookup = ReturnType<typeof getLookupFn>;
6
4
  export type Chain = {
7
5
  connector: SapiConnector;
8
6
  hexMetadata: `0x${string}`;
@@ -14,8 +12,9 @@ export type Chain = {
14
12
  signedExtensions?: ExtDef;
15
13
  registryTypes?: unknown;
16
14
  metadata: UnifiedMetadata;
17
- lookup: ScaleLookup;
18
- builder: ScaleBuilder;
15
+ lookup: MetadataLookup;
16
+ builder: MetadataBuilder;
17
+ metadataRpc: `0x${string}`;
19
18
  };
20
19
  export type ChainInfo = {
21
20
  specName: string;
@@ -1,5 +1,6 @@
1
1
  import { ExtDef } from "@polkadot/types/extrinsic/signedExtensions/types";
2
2
  import { SignerPayloadJSON } from "@polkadot/types/types";
3
+ import { Chain } from "./helpers/types";
3
4
  import { DecodedCall, PayloadSignerConfig, SapiConnectorProps } from "./types";
4
5
  export type ScaleApi = NonNullable<ReturnType<typeof getScaleApi>>;
5
6
  export declare const getScaleApi: (connector: SapiConnectorProps, hexMetadata: `0x${string}`, token: {
@@ -16,6 +17,7 @@ export declare const getScaleApi: (connector: SapiConnectorProps, hexMetadata: `
16
17
  symbol: string;
17
18
  decimals: number;
18
19
  };
20
+ chain: Chain;
19
21
  getConstant: <T>(pallet: string, constant: string) => T;
20
22
  getStorage: <T>(pallet: string, entry: string, keys: unknown[], at?: string) => Promise<T>;
21
23
  getDecodedCall: (pallet: string, method: string, args: unknown) => {
@@ -25,7 +27,9 @@ export declare const getScaleApi: (connector: SapiConnectorProps, hexMetadata: `
25
27
  value: unknown;
26
28
  };
27
29
  };
28
- getDecodedCallFromPayload: <Res extends DecodedCall>(payload: SignerPayloadJSON) => Res;
30
+ getDecodedCallFromPayload: <Res extends DecodedCall>(payload: {
31
+ method: SignerPayloadJSON["method"];
32
+ }) => Res;
29
33
  getExtrinsicPayload: (pallet: string, method: string, args: unknown, config: PayloadSignerConfig) => Promise<{
30
34
  payload: SignerPayloadJSON;
31
35
  txMetadata?: Uint8Array;
@@ -33,7 +37,7 @@ export declare const getScaleApi: (connector: SapiConnectorProps, hexMetadata: `
33
37
  getFeeEstimate: (payload: SignerPayloadJSON) => Promise<bigint>;
34
38
  getRuntimeCallValue: <T>(apiName: string, method: string, args: unknown[]) => Promise<T>;
35
39
  getTypeRegistry: (payload: SignerPayloadJSON) => import("@polkadot/types").TypeRegistry;
36
- submit: (payload: SignerPayloadJSON, signature?: `0x${string}`, txInfo?: any) => Promise<{
40
+ submit: (payload: SignerPayloadJSON, signature?: `0x${string}`, txInfo?: unknown) => Promise<{
37
41
  hash: `0x${string}`;
38
42
  }>;
39
43
  getCallDocs: (pallet: string, method: string) => string | null;
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var util = require('@polkadot/util');
4
3
  var scale = require('@talismn/scale');
5
4
  var anylogger = require('anylogger');
6
5
  var polkadotApi = require('polkadot-api');
7
6
  var metadataBuilders = require('@polkadot-api/metadata-builders');
8
7
  var utils = require('@polkadot-api/utils');
8
+ var util = require('@polkadot/util');
9
9
  var types = require('@polkadot/types');
10
10
  var merkleizeMetadata = require('@polkadot-api/merkleize-metadata');
11
11
  var substrateBindings = require('@polkadot-api/substrate-bindings');
@@ -431,27 +431,36 @@ function trailingZeroes(n) {
431
431
  return i;
432
432
  }
433
433
 
434
+ const ERA_PERIOD = 64; // validity period in blocks, used for mortal era
435
+
434
436
  const getSignerPayloadJSON = async (chain, palletName, methodName, args, signerConfig, chainInfo) => {
435
437
  const {
436
438
  codec,
437
439
  location
438
440
  } = chain.builder.buildCall(palletName, methodName);
439
441
  const method = polkadotApi.Binary.fromBytes(utils.mergeUint8([new Uint8Array(location), codec.enc(args)]));
440
- const blockNumber = await getStorageValue(chain, "System", "Number", []);
441
- if (blockNumber === null) throw new Error("Block number not found");
442
- const [account, genesisHash, blockHash] = await Promise.all([
443
- // TODO if V15 available, use a runtime call instead : AccountNonceApi/account_nonce
444
- // about nonce https://github.com/paritytech/json-rpc-interface-spec/issues/156
445
- getStorageValue(chain, "System", "Account", [signerConfig.address]), getStorageValue(chain, "System", "BlockHash", [0]), getSendRequestResult(chain, "chain_getBlockHash", [blockNumber], false) // TODO find the right way to fetch this with new RPC api, this is not available in storage yet
446
- ]);
442
+
443
+ // on unstable networks with lots of forks (ex: westend asset hub as of june 2025),
444
+ // using a finalized block as reference for mortality is necessary for txs to get through
445
+ let blockHash = await getSendRequestResult(chain, "chain_getFinalizedHead", [], false);
446
+ const [nonce, genesisHash, blockNumberFinalized, blockNumberCurrent] = await Promise.all([getSendRequestResult(chain, "system_accountNextIndex", [signerConfig.address], false), getStorageValue(chain, "System", "BlockHash", [0]), getStorageValue(chain, "System", "Number", [], blockHash), getStorageValue(chain, "System", "Number", [])]);
447
447
  if (!genesisHash) throw new Error("Genesis hash not found");
448
448
  if (!blockHash) throw new Error("Block hash not found");
449
- const nonce = account ? account.nonce : 0;
449
+ let blockNumber = blockNumberFinalized;
450
+
451
+ // on Autonomys the finalized block hash is wrong (7000 blocks behind),
452
+ // if we use it to craft a tx it will be invalid
453
+ // => if finalized block number is more than 32 blocks behind, use current - 16
454
+ if (blockNumberCurrent - blockNumberFinalized > 32) {
455
+ blockNumber = blockNumberCurrent - 16;
456
+ const binBlockHash = await getStorageValue(chain, "System", "BlockHash", [blockNumber]);
457
+ blockHash = binBlockHash.asHex();
458
+ }
450
459
  const era = mortal({
451
- period: 16,
452
- phase: blockNumber % 16
460
+ period: ERA_PERIOD,
461
+ phase: blockNumber % ERA_PERIOD
453
462
  });
454
- const signedExtensions = chain.metadata.extrinsic.signedExtensions.map(ext => ext.identifier.toString());
463
+ const signedExtensions = chain.metadata.extrinsic.signedExtensions.map(ext => ext.identifier);
455
464
  const basePayload = {
456
465
  address: signerConfig.address,
457
466
  genesisHash: genesisHash.asHex(),
@@ -486,10 +495,11 @@ const getSignerPayloadJSON = async (chain, palletName, methodName, args, signerC
486
495
  };
487
496
 
488
497
  const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signedExtensions, registryTypes) => {
489
- const metadata = scale.unifyMetadata(scale.decAnyMetadata(hexMetadata));
490
- util.assert(metadata, `Missing Metadata V14+ for chain ${connector.chainId}`);
491
- const lookup = scale.getLookupFn(metadata);
492
- const builder = scale.getDynamicBuilder(lookup);
498
+ const {
499
+ unifiedMetadata: metadata,
500
+ lookupFn: lookup,
501
+ builder
502
+ } = scale.parseMetadataRpc(hexMetadata);
493
503
  const chain = {
494
504
  connector: getSapiConnector(connector),
495
505
  hexMetadata,
@@ -499,7 +509,8 @@ const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signed
499
509
  registryTypes,
500
510
  metadata,
501
511
  lookup,
502
- builder
512
+ builder,
513
+ metadataRpc: hexMetadata
503
514
  };
504
515
  const chainInfo = getChainInfo(chain);
505
516
  const {
@@ -515,6 +526,7 @@ const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signed
515
526
  hasCheckMetadataHash,
516
527
  base58Prefix,
517
528
  token: chain.token,
529
+ chain,
518
530
  getConstant: (pallet, constant) => getConstantValue(chain, pallet, constant),
519
531
  getStorage: (pallet, entry, keys, at) => getStorageValue(chain, pallet, entry, keys, at),
520
532
  getDecodedCall: (pallet, method, args) => getDecodedCall(pallet, method, args),
@@ -523,8 +535,7 @@ const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signed
523
535
  getFeeEstimate: payload => getFeeEstimate(chain, payload, chainInfo),
524
536
  getRuntimeCallValue: (apiName, method, args) => getRuntimeCallResult(chain, apiName, method, args),
525
537
  getTypeRegistry: payload => getTypeRegistry(chain, payload),
526
- submit: (payload, signature, txInfo // eslint-disable-line @typescript-eslint/no-explicit-any
527
- ) => chain.connector.submit(payload, signature, txInfo),
538
+ submit: (payload, signature, txInfo) => chain.connector.submit(payload, signature, txInfo),
528
539
  getCallDocs: (pallet, method) => getCallDocs(chain, pallet, method),
529
540
  getDryRunCall: (from, decodedCall) => getDryRunCall(chain, from, decodedCall),
530
541
  isApiAvailable: (name, method) => isApiAvailable(chain, name, method)
@@ -554,7 +565,9 @@ const fetchBestMetadata = async (rpcSend, allowLegacyFallback) => {
554
565
  const message = cause?.message;
555
566
  if (allowLegacyFallback || message?.includes("is not found") ||
556
567
  // ex: crust standalone
557
- message?.includes("Module doesn't have export Metadata_metadata_versions") // ex: 3DPass
568
+ message?.includes("Module doesn't have export Metadata_metadata_versions") ||
569
+ // ex: 3DPass
570
+ message?.includes("Exported method Metadata_metadata_versions is not found") // ex: sora-polkadot & sora-standalone
558
571
  ) {
559
572
  return await rpcSend("state_getMetadata", [], true);
560
573
  }
@@ -1,11 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var util = require('@polkadot/util');
4
3
  var scale = require('@talismn/scale');
5
4
  var anylogger = require('anylogger');
6
5
  var polkadotApi = require('polkadot-api');
7
6
  var metadataBuilders = require('@polkadot-api/metadata-builders');
8
7
  var utils = require('@polkadot-api/utils');
8
+ var util = require('@polkadot/util');
9
9
  var types = require('@polkadot/types');
10
10
  var merkleizeMetadata = require('@polkadot-api/merkleize-metadata');
11
11
  var substrateBindings = require('@polkadot-api/substrate-bindings');
@@ -431,27 +431,36 @@ function trailingZeroes(n) {
431
431
  return i;
432
432
  }
433
433
 
434
+ const ERA_PERIOD = 64; // validity period in blocks, used for mortal era
435
+
434
436
  const getSignerPayloadJSON = async (chain, palletName, methodName, args, signerConfig, chainInfo) => {
435
437
  const {
436
438
  codec,
437
439
  location
438
440
  } = chain.builder.buildCall(palletName, methodName);
439
441
  const method = polkadotApi.Binary.fromBytes(utils.mergeUint8([new Uint8Array(location), codec.enc(args)]));
440
- const blockNumber = await getStorageValue(chain, "System", "Number", []);
441
- if (blockNumber === null) throw new Error("Block number not found");
442
- const [account, genesisHash, blockHash] = await Promise.all([
443
- // TODO if V15 available, use a runtime call instead : AccountNonceApi/account_nonce
444
- // about nonce https://github.com/paritytech/json-rpc-interface-spec/issues/156
445
- getStorageValue(chain, "System", "Account", [signerConfig.address]), getStorageValue(chain, "System", "BlockHash", [0]), getSendRequestResult(chain, "chain_getBlockHash", [blockNumber], false) // TODO find the right way to fetch this with new RPC api, this is not available in storage yet
446
- ]);
442
+
443
+ // on unstable networks with lots of forks (ex: westend asset hub as of june 2025),
444
+ // using a finalized block as reference for mortality is necessary for txs to get through
445
+ let blockHash = await getSendRequestResult(chain, "chain_getFinalizedHead", [], false);
446
+ const [nonce, genesisHash, blockNumberFinalized, blockNumberCurrent] = await Promise.all([getSendRequestResult(chain, "system_accountNextIndex", [signerConfig.address], false), getStorageValue(chain, "System", "BlockHash", [0]), getStorageValue(chain, "System", "Number", [], blockHash), getStorageValue(chain, "System", "Number", [])]);
447
447
  if (!genesisHash) throw new Error("Genesis hash not found");
448
448
  if (!blockHash) throw new Error("Block hash not found");
449
- const nonce = account ? account.nonce : 0;
449
+ let blockNumber = blockNumberFinalized;
450
+
451
+ // on Autonomys the finalized block hash is wrong (7000 blocks behind),
452
+ // if we use it to craft a tx it will be invalid
453
+ // => if finalized block number is more than 32 blocks behind, use current - 16
454
+ if (blockNumberCurrent - blockNumberFinalized > 32) {
455
+ blockNumber = blockNumberCurrent - 16;
456
+ const binBlockHash = await getStorageValue(chain, "System", "BlockHash", [blockNumber]);
457
+ blockHash = binBlockHash.asHex();
458
+ }
450
459
  const era = mortal({
451
- period: 16,
452
- phase: blockNumber % 16
460
+ period: ERA_PERIOD,
461
+ phase: blockNumber % ERA_PERIOD
453
462
  });
454
- const signedExtensions = chain.metadata.extrinsic.signedExtensions.map(ext => ext.identifier.toString());
463
+ const signedExtensions = chain.metadata.extrinsic.signedExtensions.map(ext => ext.identifier);
455
464
  const basePayload = {
456
465
  address: signerConfig.address,
457
466
  genesisHash: genesisHash.asHex(),
@@ -486,10 +495,11 @@ const getSignerPayloadJSON = async (chain, palletName, methodName, args, signerC
486
495
  };
487
496
 
488
497
  const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signedExtensions, registryTypes) => {
489
- const metadata = scale.unifyMetadata(scale.decAnyMetadata(hexMetadata));
490
- util.assert(metadata, `Missing Metadata V14+ for chain ${connector.chainId}`);
491
- const lookup = scale.getLookupFn(metadata);
492
- const builder = scale.getDynamicBuilder(lookup);
498
+ const {
499
+ unifiedMetadata: metadata,
500
+ lookupFn: lookup,
501
+ builder
502
+ } = scale.parseMetadataRpc(hexMetadata);
493
503
  const chain = {
494
504
  connector: getSapiConnector(connector),
495
505
  hexMetadata,
@@ -499,7 +509,8 @@ const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signed
499
509
  registryTypes,
500
510
  metadata,
501
511
  lookup,
502
- builder
512
+ builder,
513
+ metadataRpc: hexMetadata
503
514
  };
504
515
  const chainInfo = getChainInfo(chain);
505
516
  const {
@@ -515,6 +526,7 @@ const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signed
515
526
  hasCheckMetadataHash,
516
527
  base58Prefix,
517
528
  token: chain.token,
529
+ chain,
518
530
  getConstant: (pallet, constant) => getConstantValue(chain, pallet, constant),
519
531
  getStorage: (pallet, entry, keys, at) => getStorageValue(chain, pallet, entry, keys, at),
520
532
  getDecodedCall: (pallet, method, args) => getDecodedCall(pallet, method, args),
@@ -523,8 +535,7 @@ const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signed
523
535
  getFeeEstimate: payload => getFeeEstimate(chain, payload, chainInfo),
524
536
  getRuntimeCallValue: (apiName, method, args) => getRuntimeCallResult(chain, apiName, method, args),
525
537
  getTypeRegistry: payload => getTypeRegistry(chain, payload),
526
- submit: (payload, signature, txInfo // eslint-disable-line @typescript-eslint/no-explicit-any
527
- ) => chain.connector.submit(payload, signature, txInfo),
538
+ submit: (payload, signature, txInfo) => chain.connector.submit(payload, signature, txInfo),
528
539
  getCallDocs: (pallet, method) => getCallDocs(chain, pallet, method),
529
540
  getDryRunCall: (from, decodedCall) => getDryRunCall(chain, from, decodedCall),
530
541
  isApiAvailable: (name, method) => isApiAvailable(chain, name, method)
@@ -554,7 +565,9 @@ const fetchBestMetadata = async (rpcSend, allowLegacyFallback) => {
554
565
  const message = cause?.message;
555
566
  if (allowLegacyFallback || message?.includes("is not found") ||
556
567
  // ex: crust standalone
557
- message?.includes("Module doesn't have export Metadata_metadata_versions") // ex: 3DPass
568
+ message?.includes("Module doesn't have export Metadata_metadata_versions") ||
569
+ // ex: 3DPass
570
+ message?.includes("Exported method Metadata_metadata_versions is not found") // ex: sora-polkadot & sora-standalone
558
571
  ) {
559
572
  return await rpcSend("state_getMetadata", [], true);
560
573
  }
@@ -1,9 +1,9 @@
1
- import { assert, u8aConcatStrict } from '@polkadot/util';
2
- import { unifyMetadata, decAnyMetadata, getLookupFn as getLookupFn$1, getDynamicBuilder } from '@talismn/scale';
1
+ import { parseMetadataRpc } from '@talismn/scale';
3
2
  import anylogger from 'anylogger';
4
3
  import { Enum, Binary } from 'polkadot-api';
5
4
  import { getLookupFn } from '@polkadot-api/metadata-builders';
6
5
  import { toHex, mergeUint8 } from '@polkadot-api/utils';
6
+ import { assert, u8aConcatStrict } from '@polkadot/util';
7
7
  import { TypeRegistry, Metadata } from '@polkadot/types';
8
8
  import { merkleizeMetadata } from '@polkadot-api/merkleize-metadata';
9
9
  import { enhanceEncoder, Bytes, u16 } from '@polkadot-api/substrate-bindings';
@@ -425,27 +425,36 @@ function trailingZeroes(n) {
425
425
  return i;
426
426
  }
427
427
 
428
+ const ERA_PERIOD = 64; // validity period in blocks, used for mortal era
429
+
428
430
  const getSignerPayloadJSON = async (chain, palletName, methodName, args, signerConfig, chainInfo) => {
429
431
  const {
430
432
  codec,
431
433
  location
432
434
  } = chain.builder.buildCall(palletName, methodName);
433
435
  const method = Binary.fromBytes(mergeUint8([new Uint8Array(location), codec.enc(args)]));
434
- const blockNumber = await getStorageValue(chain, "System", "Number", []);
435
- if (blockNumber === null) throw new Error("Block number not found");
436
- const [account, genesisHash, blockHash] = await Promise.all([
437
- // TODO if V15 available, use a runtime call instead : AccountNonceApi/account_nonce
438
- // about nonce https://github.com/paritytech/json-rpc-interface-spec/issues/156
439
- getStorageValue(chain, "System", "Account", [signerConfig.address]), getStorageValue(chain, "System", "BlockHash", [0]), getSendRequestResult(chain, "chain_getBlockHash", [blockNumber], false) // TODO find the right way to fetch this with new RPC api, this is not available in storage yet
440
- ]);
436
+
437
+ // on unstable networks with lots of forks (ex: westend asset hub as of june 2025),
438
+ // using a finalized block as reference for mortality is necessary for txs to get through
439
+ let blockHash = await getSendRequestResult(chain, "chain_getFinalizedHead", [], false);
440
+ const [nonce, genesisHash, blockNumberFinalized, blockNumberCurrent] = await Promise.all([getSendRequestResult(chain, "system_accountNextIndex", [signerConfig.address], false), getStorageValue(chain, "System", "BlockHash", [0]), getStorageValue(chain, "System", "Number", [], blockHash), getStorageValue(chain, "System", "Number", [])]);
441
441
  if (!genesisHash) throw new Error("Genesis hash not found");
442
442
  if (!blockHash) throw new Error("Block hash not found");
443
- const nonce = account ? account.nonce : 0;
443
+ let blockNumber = blockNumberFinalized;
444
+
445
+ // on Autonomys the finalized block hash is wrong (7000 blocks behind),
446
+ // if we use it to craft a tx it will be invalid
447
+ // => if finalized block number is more than 32 blocks behind, use current - 16
448
+ if (blockNumberCurrent - blockNumberFinalized > 32) {
449
+ blockNumber = blockNumberCurrent - 16;
450
+ const binBlockHash = await getStorageValue(chain, "System", "BlockHash", [blockNumber]);
451
+ blockHash = binBlockHash.asHex();
452
+ }
444
453
  const era = mortal({
445
- period: 16,
446
- phase: blockNumber % 16
454
+ period: ERA_PERIOD,
455
+ phase: blockNumber % ERA_PERIOD
447
456
  });
448
- const signedExtensions = chain.metadata.extrinsic.signedExtensions.map(ext => ext.identifier.toString());
457
+ const signedExtensions = chain.metadata.extrinsic.signedExtensions.map(ext => ext.identifier);
449
458
  const basePayload = {
450
459
  address: signerConfig.address,
451
460
  genesisHash: genesisHash.asHex(),
@@ -480,10 +489,11 @@ const getSignerPayloadJSON = async (chain, palletName, methodName, args, signerC
480
489
  };
481
490
 
482
491
  const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signedExtensions, registryTypes) => {
483
- const metadata = unifyMetadata(decAnyMetadata(hexMetadata));
484
- assert(metadata, `Missing Metadata V14+ for chain ${connector.chainId}`);
485
- const lookup = getLookupFn$1(metadata);
486
- const builder = getDynamicBuilder(lookup);
492
+ const {
493
+ unifiedMetadata: metadata,
494
+ lookupFn: lookup,
495
+ builder
496
+ } = parseMetadataRpc(hexMetadata);
487
497
  const chain = {
488
498
  connector: getSapiConnector(connector),
489
499
  hexMetadata,
@@ -493,7 +503,8 @@ const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signed
493
503
  registryTypes,
494
504
  metadata,
495
505
  lookup,
496
- builder
506
+ builder,
507
+ metadataRpc: hexMetadata
497
508
  };
498
509
  const chainInfo = getChainInfo(chain);
499
510
  const {
@@ -509,6 +520,7 @@ const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signed
509
520
  hasCheckMetadataHash,
510
521
  base58Prefix,
511
522
  token: chain.token,
523
+ chain,
512
524
  getConstant: (pallet, constant) => getConstantValue(chain, pallet, constant),
513
525
  getStorage: (pallet, entry, keys, at) => getStorageValue(chain, pallet, entry, keys, at),
514
526
  getDecodedCall: (pallet, method, args) => getDecodedCall(pallet, method, args),
@@ -517,8 +529,7 @@ const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signed
517
529
  getFeeEstimate: payload => getFeeEstimate(chain, payload, chainInfo),
518
530
  getRuntimeCallValue: (apiName, method, args) => getRuntimeCallResult(chain, apiName, method, args),
519
531
  getTypeRegistry: payload => getTypeRegistry(chain, payload),
520
- submit: (payload, signature, txInfo // eslint-disable-line @typescript-eslint/no-explicit-any
521
- ) => chain.connector.submit(payload, signature, txInfo),
532
+ submit: (payload, signature, txInfo) => chain.connector.submit(payload, signature, txInfo),
522
533
  getCallDocs: (pallet, method) => getCallDocs(chain, pallet, method),
523
534
  getDryRunCall: (from, decodedCall) => getDryRunCall(chain, from, decodedCall),
524
535
  isApiAvailable: (name, method) => isApiAvailable(chain, name, method)
@@ -548,7 +559,9 @@ const fetchBestMetadata = async (rpcSend, allowLegacyFallback) => {
548
559
  const message = cause?.message;
549
560
  if (allowLegacyFallback || message?.includes("is not found") ||
550
561
  // ex: crust standalone
551
- message?.includes("Module doesn't have export Metadata_metadata_versions") // ex: 3DPass
562
+ message?.includes("Module doesn't have export Metadata_metadata_versions") ||
563
+ // ex: 3DPass
564
+ message?.includes("Exported method Metadata_metadata_versions is not found") // ex: sora-polkadot & sora-standalone
552
565
  ) {
553
566
  return await rpcSend("state_getMetadata", [], true);
554
567
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@talismn/sapi",
3
- "version": "0.0.5",
3
+ "version": "0.0.7",
4
4
  "author": "Talisman",
5
5
  "homepage": "https://talisman.xyz",
6
6
  "license": "GPL-3.0-or-later",
@@ -31,7 +31,7 @@
31
31
  "anylogger": "^1.0.11",
32
32
  "polkadot-api": "1.13.1",
33
33
  "scale-ts": "^1.6.1",
34
- "@talismn/scale": "0.1.2"
34
+ "@talismn/scale": "0.2.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/jest": "^29.5.14",
@@ -39,8 +39,8 @@
39
39
  "jest": "^29.7",
40
40
  "ts-jest": "^29.2.5",
41
41
  "typescript": "^5.6.3",
42
- "@talismn/tsconfig": "0.0.2",
43
- "@talismn/eslint-config": "0.0.3"
42
+ "@talismn/eslint-config": "0.0.3",
43
+ "@talismn/tsconfig": "0.0.2"
44
44
  },
45
45
  "eslintConfig": {
46
46
  "root": true,