Skip to content

feat(wasm-dot): replace AddressFormat enum with numeric union type#203

Merged
lcovar merged 1 commit intomasterfrom
btc-3117/wasm-dot-address-format-union-type
Mar 10, 2026
Merged

feat(wasm-dot): replace AddressFormat enum with numeric union type#203
lcovar merged 1 commit intomasterfrom
btc-3117/wasm-dot-address-format-union-type

Conversation

@bitgo-ai-agent-dev
Copy link

Summary

Replace enum AddressFormat with a type AddressFormat = 0 | 2 | 42 union type + const AddressFormat named constants object, following the same convention used by wasm-utxo's AddressFormat.

Why

DotAddressFormat in @bitgo-beta/sdk-core is also a numeric enum with the same values (polkadot = 0, substrate = 42). With an enum, wallet-platform consumers need an as unknown as AddressFormat cast to bridge between the two. With a union type, the raw number is directly assignable — no cast needed.

What changes

  • types.ts: enum AddressFormattype AddressFormat = 0 | 2 | 42 + const AddressFormat = { Polkadot: 0, Kusama: 2, Substrate: 42 } as const
  • All existing call sites (AddressFormat.Polkadot, .Kusama, .Substrate) work unchanged
  • Default parameter sender(format: AddressFormat = AddressFormat.Polkadot) in transaction.ts works unchanged

Related

Ticket: BTC-3117 — wasm-dot shadow mode address validation for Polkadot in wallet-platform

🤖 Generated with Claude Code

@bitgo-ai-agent-dev bitgo-ai-agent-dev bot requested a review from a team as a code owner March 10, 2026 22:23
@lcovar lcovar force-pushed the btc-3117/wasm-dot-address-format-union-type branch 2 times, most recently from bd2fbac to f0f4ebc Compare March 10, 2026 22:44
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
@lcovar lcovar force-pushed the btc-3117/wasm-dot-address-format-union-type branch from f0f4ebc to 286dd11 Compare March 10, 2026 22:44
@lcovar lcovar merged commit ab8940c into master Mar 10, 2026
13 checks passed
@lcovar lcovar deleted the btc-3117/wasm-dot-address-format-union-type branch March 10, 2026 22:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants