Skip to content
This repository has been archived by the owner on Sep 14, 2023. It is now read-only.

chore: generate simpler lookups from ss58 registry #256

Closed
wants to merge 4 commits into from

Conversation

harrysolovay
Copy link
Contributor

@harrysolovay harrysolovay commented Oct 2, 2022

Should be useful for codegen purposes.

See lookups here.

@harrysolovay harrysolovay requested a review from tjjfvi October 2, 2022 08:34
@tjjfvi
Copy link
Contributor

tjjfvi commented Oct 2, 2022

I don't understand why this needs to be codegenned at all. Couldn't lookups.ts just be

import ss58Registry from "../deps/ss58_registry.ts";

export interface ChainInfo {
  prefix: number;
  network: string;
  displayName: string;
  symbols: string[];
  decimals: number[];
  standardAccount: string | null;
  website: string | null;
}

export const lookup: Record<string, ChainInfo> = Object.fromEntries(
  ss58Registry.map((obj) => [obj.network, obj]),
);

@harrysolovay
Copy link
Contributor Author

Would be a tiny bit slower. Couldn't help but micro-optimize... in retrospect, the complexity of the build step might make this less worthwhile. Thoughts?

@tjjfvi
Copy link
Contributor

tjjfvi commented Oct 2, 2022

Very tiny, and it's only ever run once. If anything, I would say optimize it by including the specific object in the codegen output (which would be as simple as JSON.stringify(lookup[network]))

@harrysolovay
Copy link
Contributor Author

Closing in light of #260

@harrysolovay harrysolovay deleted the gen-registry-util branch October 2, 2022 19:03
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants