MCPcopy Create free account
hub / github.com/dfinity/orbit / detectAddressFormat

Function detectAddressFormat

apps/wallet/src/utils/asset.utils.ts:14–30  ·  view source on GitHub ↗
(blockchain: string, address: string)

Source from the content-addressed store, hash-verified

12}
13
14export function detectAddressFormat(blockchain: string, address: string): string | undefined {
15 switch (blockchain) {
16 case BlockchainType.InternetComputer:
17 if (ICNativeApi.isValidAddress(address)) {
18 return AddressFormat.ICPNative;
19 } else if (ICRC1Api.isValidAddress(address)) {
20 return AddressFormat.ICRC1;
21 } else {
22 return;
23 }
24 case BlockchainType.Bitcoin:
25 case BlockchainType.Ethereum:
26 return;
27 default:
28 throw new Error(`Blockchain not supported ${blockchain}`);
29 }
30}
31
32export function detectAddressStandard(
33 asset: Asset,

Callers 3

validAddressFunction · 0.90
detectAddressStandardFunction · 0.85

Calls 1

isValidAddressMethod · 0.65

Tested by

no test coverage detected