|
1 |
| -import { ApiPromise } from "@polkadot/api"; |
2 |
| - |
3 | 1 | import type { Schema } from "avsc";
|
4 | 2 | import { DSNPParquetSchema } from "@dsnp/schemas/types/dsnp-parquet.js";
|
5 | 3 | import {
|
@@ -283,19 +281,14 @@ chainMapping["default"] = {
|
283 | 281 | };
|
284 | 282 |
|
285 | 283 | /**
|
286 |
| - * Gets the schemaId from the Frequency instance configured for |
287 |
| - * apiPromise for the given DSNP type and version. If version is |
288 |
| - * unspecified, the latest version is returned. (You probably only |
289 |
| - * need version if you're migrating.) |
| 284 | + * Gets the schemaId for for given DSNP type and version and genesis hash. |
| 285 | + * If version is unspecified, the latest version is returned. (You probably |
| 286 | + * only need version if you're migrating.) |
| 287 | + * If genesis hash is unspecified, the mainnet genesis hash and schema |
| 288 | + * numbers will be used. |
290 | 289 | */
|
291 |
| -export const getSchemaId = async ( |
292 |
| - apiPromise: Promise<ApiPromise>, |
293 |
| - schemaName: SchemaName, |
294 |
| - dsnpVersion?: DSNPVersion, |
295 |
| -): Promise<number> => { |
296 |
| - const api = await apiPromise; |
297 |
| - const genesisHash = api.genesisHash.toString(); |
298 |
| - let mapping = chainMapping[genesisHash]; |
| 290 | +export const getSchemaId = (schemaName: SchemaName, dsnpVersion?: DSNPVersion, genesisHash?: string): number => { |
| 291 | + let mapping = chainMapping[genesisHash || GENESIS_HASH_MAINNET]; |
299 | 292 | // If we don't recognize this chain, use default mapping
|
300 | 293 | if (!mapping) mapping = chainMapping["default"];
|
301 | 294 | const versions = mapping[schemaName];
|
|
0 commit comments