Skip to content

Commit

Permalink
feat(frontend): add sol addresses to derived (#3999)
Browse files Browse the repository at this point in the history
# Motivation

Make a derived for the sol addresses

# Changes

- Add sol address derived per network
- add typing

# Tests

- No unit tests provided

---------

Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
  • Loading branch information
loki344 and github-actions[bot] authored Dec 17, 2024
1 parent 405d36c commit 494658b
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/frontend/src/lib/derived/address.derived.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@ import {
btcAddressMainnetStore,
btcAddressRegtestStore,
btcAddressTestnetStore,
ethAddressStore
ethAddressStore,
solAddressDevnetStore,
solAddressLocalnetStore,
solAddressMainnetStore,
solAddressTestnetStore
} from '$lib/stores/address.store';
import type {
BtcAddress,
EthAddress,
OptionBtcAddress,
OptionEthAddress
OptionEthAddress,
OptionSolAddress,
SolAddress
} from '$lib/types/address';
import { mapAddress } from '$lib/utils/address.utils';
import { isNullish } from '@dfinity/utils';
Expand Down Expand Up @@ -48,3 +54,23 @@ export const ethAddressNotCertified: Readable<boolean> = derived(
[ethAddressCertified],
([$ethAddressCertified]) => !$ethAddressCertified
);

export const solAddressMainnet: Readable<OptionSolAddress> = derived(
[solAddressMainnetStore],
([$solAddressMainnetStore]) => mapAddress<SolAddress>($solAddressMainnetStore)
);

export const solAddressTestnet: Readable<OptionSolAddress> = derived(
[solAddressTestnetStore],
([$solAddressTestnetStore]) => mapAddress<SolAddress>($solAddressTestnetStore)
);

export const solAddressDevnet: Readable<OptionSolAddress> = derived(
[solAddressDevnetStore],
([$solAddressDevnetStore]) => mapAddress<SolAddress>($solAddressDevnetStore)
);

export const solAddressLocal: Readable<OptionSolAddress> = derived(
[solAddressLocalnetStore],
([$solAddressLocalnetStore]) => mapAddress<SolAddress>($solAddressLocalnetStore)
);
2 changes: 2 additions & 0 deletions src/frontend/src/lib/types/address.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,5 @@ export type OptionAddress<T extends Address> = Option<T>;
export type OptionBtcAddress = OptionAddress<BtcAddress>;

export type OptionEthAddress = OptionAddress<EthAddress>;

export type OptionSolAddress = OptionAddress<SolAddress>;

0 comments on commit 494658b

Please sign in to comment.