@talismn/sapi 0.0.11 → 0.0.12
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.
|
@@ -340,16 +340,18 @@ const getPayloadWithMetadataHash = (chain, chainInfo, payload) => {
|
|
|
340
340
|
specName,
|
|
341
341
|
specVersion
|
|
342
342
|
} = chainInfo;
|
|
343
|
-
|
|
344
|
-
// since ultimately this needs a V15 object, would be nice if this accepted one directly as input
|
|
345
|
-
const merkleizedMetadata = merkleizeMetadata.merkleizeMetadata(chain.hexMetadata, {
|
|
343
|
+
const metadataHashInputs = {
|
|
346
344
|
tokenSymbol,
|
|
347
345
|
decimals,
|
|
348
346
|
base58Prefix,
|
|
349
347
|
specName,
|
|
350
348
|
specVersion
|
|
351
|
-
}
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
// since ultimately this needs a V15 object, would be nice if this accepted one directly as input
|
|
352
|
+
const merkleizedMetadata = merkleizeMetadata.merkleizeMetadata(chain.hexMetadata, metadataHashInputs);
|
|
352
353
|
const metadataHash = utils.toHex(merkleizedMetadata.digest());
|
|
354
|
+
log.log("metadataHash", metadataHash, metadataHashInputs);
|
|
353
355
|
const payloadWithMetadataHash = {
|
|
354
356
|
...payload,
|
|
355
357
|
mode: 1,
|
|
@@ -531,7 +533,8 @@ const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signed
|
|
|
531
533
|
const MAGIC_NUMBER = 1635018093;
|
|
532
534
|
|
|
533
535
|
// it's important to set a max because some chains also return high invalid version numbers in the metadata_versions list (ex on Polkadot, related to JAM?)
|
|
534
|
-
const MAX_SUPPORTED_METADATA_VERSION =
|
|
536
|
+
const MAX_SUPPORTED_METADATA_VERSION = 15; // v16 sometimes outputs different metadata hashes, ignore v16 until that is fixed in PAPI
|
|
537
|
+
|
|
535
538
|
/**
|
|
536
539
|
* Fetches the highest supported version of metadata from the chain.
|
|
537
540
|
*
|
|
@@ -578,5 +581,6 @@ const normalizeMetadata = metadata => {
|
|
|
578
581
|
return `0x${metadata.slice(magicNumberIndex)}`;
|
|
579
582
|
};
|
|
580
583
|
|
|
584
|
+
exports.MAX_SUPPORTED_METADATA_VERSION = MAX_SUPPORTED_METADATA_VERSION;
|
|
581
585
|
exports.fetchBestMetadata = fetchBestMetadata;
|
|
582
586
|
exports.getScaleApi = getScaleApi;
|
|
@@ -340,16 +340,18 @@ const getPayloadWithMetadataHash = (chain, chainInfo, payload) => {
|
|
|
340
340
|
specName,
|
|
341
341
|
specVersion
|
|
342
342
|
} = chainInfo;
|
|
343
|
-
|
|
344
|
-
// since ultimately this needs a V15 object, would be nice if this accepted one directly as input
|
|
345
|
-
const merkleizedMetadata = merkleizeMetadata.merkleizeMetadata(chain.hexMetadata, {
|
|
343
|
+
const metadataHashInputs = {
|
|
346
344
|
tokenSymbol,
|
|
347
345
|
decimals,
|
|
348
346
|
base58Prefix,
|
|
349
347
|
specName,
|
|
350
348
|
specVersion
|
|
351
|
-
}
|
|
349
|
+
};
|
|
350
|
+
|
|
351
|
+
// since ultimately this needs a V15 object, would be nice if this accepted one directly as input
|
|
352
|
+
const merkleizedMetadata = merkleizeMetadata.merkleizeMetadata(chain.hexMetadata, metadataHashInputs);
|
|
352
353
|
const metadataHash = utils.toHex(merkleizedMetadata.digest());
|
|
354
|
+
log.log("metadataHash", metadataHash, metadataHashInputs);
|
|
353
355
|
const payloadWithMetadataHash = {
|
|
354
356
|
...payload,
|
|
355
357
|
mode: 1,
|
|
@@ -531,7 +533,8 @@ const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signed
|
|
|
531
533
|
const MAGIC_NUMBER = 1635018093;
|
|
532
534
|
|
|
533
535
|
// it's important to set a max because some chains also return high invalid version numbers in the metadata_versions list (ex on Polkadot, related to JAM?)
|
|
534
|
-
const MAX_SUPPORTED_METADATA_VERSION =
|
|
536
|
+
const MAX_SUPPORTED_METADATA_VERSION = 15; // v16 sometimes outputs different metadata hashes, ignore v16 until that is fixed in PAPI
|
|
537
|
+
|
|
535
538
|
/**
|
|
536
539
|
* Fetches the highest supported version of metadata from the chain.
|
|
537
540
|
*
|
|
@@ -578,5 +581,6 @@ const normalizeMetadata = metadata => {
|
|
|
578
581
|
return `0x${metadata.slice(magicNumberIndex)}`;
|
|
579
582
|
};
|
|
580
583
|
|
|
584
|
+
exports.MAX_SUPPORTED_METADATA_VERSION = MAX_SUPPORTED_METADATA_VERSION;
|
|
581
585
|
exports.fetchBestMetadata = fetchBestMetadata;
|
|
582
586
|
exports.getScaleApi = getScaleApi;
|
package/dist/talismn-sapi.esm.js
CHANGED
|
@@ -334,16 +334,18 @@ const getPayloadWithMetadataHash = (chain, chainInfo, payload) => {
|
|
|
334
334
|
specName,
|
|
335
335
|
specVersion
|
|
336
336
|
} = chainInfo;
|
|
337
|
-
|
|
338
|
-
// since ultimately this needs a V15 object, would be nice if this accepted one directly as input
|
|
339
|
-
const merkleizedMetadata = merkleizeMetadata(chain.hexMetadata, {
|
|
337
|
+
const metadataHashInputs = {
|
|
340
338
|
tokenSymbol,
|
|
341
339
|
decimals,
|
|
342
340
|
base58Prefix,
|
|
343
341
|
specName,
|
|
344
342
|
specVersion
|
|
345
|
-
}
|
|
343
|
+
};
|
|
344
|
+
|
|
345
|
+
// since ultimately this needs a V15 object, would be nice if this accepted one directly as input
|
|
346
|
+
const merkleizedMetadata = merkleizeMetadata(chain.hexMetadata, metadataHashInputs);
|
|
346
347
|
const metadataHash = toHex(merkleizedMetadata.digest());
|
|
348
|
+
log.log("metadataHash", metadataHash, metadataHashInputs);
|
|
347
349
|
const payloadWithMetadataHash = {
|
|
348
350
|
...payload,
|
|
349
351
|
mode: 1,
|
|
@@ -525,7 +527,8 @@ const getScaleApi = (connector, hexMetadata, token, hasCheckMetadataHash, signed
|
|
|
525
527
|
const MAGIC_NUMBER = 1635018093;
|
|
526
528
|
|
|
527
529
|
// it's important to set a max because some chains also return high invalid version numbers in the metadata_versions list (ex on Polkadot, related to JAM?)
|
|
528
|
-
const MAX_SUPPORTED_METADATA_VERSION =
|
|
530
|
+
const MAX_SUPPORTED_METADATA_VERSION = 15; // v16 sometimes outputs different metadata hashes, ignore v16 until that is fixed in PAPI
|
|
531
|
+
|
|
529
532
|
/**
|
|
530
533
|
* Fetches the highest supported version of metadata from the chain.
|
|
531
534
|
*
|
|
@@ -572,4 +575,4 @@ const normalizeMetadata = metadata => {
|
|
|
572
575
|
return `0x${metadata.slice(magicNumberIndex)}`;
|
|
573
576
|
};
|
|
574
577
|
|
|
575
|
-
export { fetchBestMetadata, getScaleApi };
|
|
578
|
+
export { MAX_SUPPORTED_METADATA_VERSION, fetchBestMetadata, getScaleApi };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@talismn/sapi",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.12",
|
|
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.2.
|
|
34
|
+
"@talismn/scale": "0.2.2"
|
|
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/
|
|
43
|
-
"@talismn/
|
|
42
|
+
"@talismn/tsconfig": "0.0.3",
|
|
43
|
+
"@talismn/eslint-config": "0.0.3"
|
|
44
44
|
},
|
|
45
45
|
"eslintConfig": {
|
|
46
46
|
"root": true,
|