From 286dd11807b0046edfd97584940d6f197bca32f6 Mon Sep 17 00:00:00 2001 From: Ongo Date: Tue, 10 Mar 2026 22:23:27 +0000 Subject: [PATCH] feat(wasm-dot): replace AddressFormat enum with numeric union type Replace the numeric enum with a `type AddressFormat = 0 | 2 | 42` union and a matching `const AddressFormat` object. This follows the wasm-utxo convention and lets callers pass a raw SS58 prefix number directly (e.g. from DotAddressFormat in sdk-core) without a type cast. All existing call sites using AddressFormat.Polkadot / .Kusama / .Substrate continue to work unchanged. Co-Authored-By: Claude Opus 4.6 Ticket: BTC-3127 --- packages/wasm-dot/js/types.ts | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/packages/wasm-dot/js/types.ts b/packages/wasm-dot/js/types.ts index 83738b1..149b093 100644 --- a/packages/wasm-dot/js/types.ts +++ b/packages/wasm-dot/js/types.ts @@ -221,13 +221,22 @@ export interface ParsedTransaction { } /** - * SS58 address format prefixes + * SS58 address format prefixes. + * Using a numeric union type rather than an enum so that callers can pass + * the raw SS58 prefix number directly without a cast. */ -export enum AddressFormat { +export type AddressFormat = 0 | 2 | 42; + +/** + * Named constants for common SS58 address formats. + * All existing call sites using AddressFormat.Polkadot / .Kusama / .Substrate + * continue to work unchanged. + */ +export const AddressFormat = { /** Polkadot mainnet (prefix 0, addresses start with '1') */ - Polkadot = 0, + Polkadot: 0, /** Kusama (prefix 2) */ - Kusama = 2, + Kusama: 2, /** Substrate generic (prefix 42, addresses start with '5') */ - Substrate = 42, -} + Substrate: 42, +} as const satisfies Record;