-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(devx): Add filter flag to Iota CLI
Signed-off-by: salaheldinsoliman <[email protected]>
- Loading branch information
1 parent
f7a61eb
commit f5986b6
Showing
129 changed files
with
2,389 additions
and
1,305 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
// Copyright (c) Mysten Labs, Inc. | ||
// Modifications Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { useFeatureIsOn } from '@growthbook/growthbook-react'; | ||
import { useIotaClient } from '@iota/dapp-kit'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
|
||
const IOTA_NS_FEATURE_FLAG = 'iotans'; | ||
|
||
// This should align with whatever names we want to be able to resolve. | ||
const IOTA_NS_DOMAINS = ['.iota']; | ||
export function isIotaNSName(name: string) { | ||
return IOTA_NS_DOMAINS.some((domain) => name.endsWith(domain)); | ||
} | ||
|
||
export function useIotaNSEnabled() { | ||
return useFeatureIsOn(IOTA_NS_FEATURE_FLAG); | ||
} | ||
|
||
export function useResolveIotaNSAddress(name?: string | null, enabled?: boolean) { | ||
const client = useIotaClient(); | ||
const enabledIotaNs = useIotaNSEnabled(); | ||
|
||
return useQuery({ | ||
queryKey: ['resolve-iotans-address', name], | ||
queryFn: async () => { | ||
return await client.resolveNameServiceAddress({ | ||
name: name!, | ||
}); | ||
}, | ||
enabled: !!name && enabled && enabledIotaNs, | ||
refetchOnWindowFocus: false, | ||
retry: false, | ||
}); | ||
} | ||
|
||
export function useResolveIotaNSName(address?: string | null) { | ||
const client = useIotaClient(); | ||
const enabled = useIotaNSEnabled(); | ||
|
||
return useQuery({ | ||
queryKey: ['resolve-iotans-name', address], | ||
queryFn: async () => { | ||
// NOTE: We only fetch 1 here because it's the default name. | ||
const { data } = await client.resolveNameServiceNames({ | ||
address: address!, | ||
limit: 1, | ||
}); | ||
|
||
return data[0] || null; | ||
}, | ||
enabled: !!address && enabled, | ||
refetchOnWindowFocus: false, | ||
retry: false, | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,16 @@ | ||
// Copyright (c) 2024 IOTA Stiftung | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
import { useIotaNSEnabled } from '.'; | ||
import { useIotaClient } from '@iota/dapp-kit'; | ||
import { useMemo } from 'react'; | ||
import { createIotaAddressValidation } from '../utils'; | ||
|
||
export function useIotaAddressValidation() { | ||
const client = useIotaClient(); | ||
const iotaNSEnabled = useIotaNSEnabled(); | ||
|
||
return useMemo(() => { | ||
return createIotaAddressValidation(); | ||
}, []); | ||
return createIotaAddressValidation(client, iotaNSEnabled); | ||
}, [client, iotaNSEnabled]); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.