Skip to content

Commit 286dd11

Browse files
Ongolcovar
authored andcommitted
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 <noreply@anthropic.com> Ticket: BTC-3127
1 parent 19ee5a9 commit 286dd11

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

packages/wasm-dot/js/types.ts

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -221,13 +221,22 @@ export interface ParsedTransaction {
221221
}
222222

223223
/**
224-
* SS58 address format prefixes
224+
* SS58 address format prefixes.
225+
* Using a numeric union type rather than an enum so that callers can pass
226+
* the raw SS58 prefix number directly without a cast.
225227
*/
226-
export enum AddressFormat {
228+
export type AddressFormat = 0 | 2 | 42;
229+
230+
/**
231+
* Named constants for common SS58 address formats.
232+
* All existing call sites using AddressFormat.Polkadot / .Kusama / .Substrate
233+
* continue to work unchanged.
234+
*/
235+
export const AddressFormat = {
227236
/** Polkadot mainnet (prefix 0, addresses start with '1') */
228-
Polkadot = 0,
237+
Polkadot: 0,
229238
/** Kusama (prefix 2) */
230-
Kusama = 2,
239+
Kusama: 2,
231240
/** Substrate generic (prefix 42, addresses start with '5') */
232-
Substrate = 42,
233-
}
241+
Substrate: 42,
242+
} as const satisfies Record<string, AddressFormat>;

0 commit comments

Comments
 (0)