-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #140 from AbstractSDK/adair/useClaimNamespace
Add useClaimNamespace and re-export useSendFunds
- Loading branch information
Showing
8 changed files
with
143 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
"@abstract-money/core": minor | ||
"@abstract-money/react": minor | ||
--- | ||
|
||
Add useClaimnamespace and re-export send funds |
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
55 changes: 55 additions & 0 deletions
55
packages/react/src/hooks/account/wallet/use-claim-namespace.ts
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,55 @@ | ||
import { AccountWalletClient } from '@abstract-money/core/clients' | ||
import { AccountId } from '@abstract-money/core/utils' | ||
import { ExecuteResult } from '@cosmjs/cosmwasm-stargate' | ||
import { DeliverTxResponse } from '@cosmjs/stargate' | ||
import { useMutation } from '@tanstack/react-query' | ||
import { useConfig } from '../../../contexts' | ||
import { ExtractArgsFromParameters } from '../../../types/args' | ||
import { | ||
UseMutationParameters, | ||
UseMutationReturnType, | ||
} from '../../../types/queries' | ||
|
||
type ClaimNamespaceMutation = ExtractArgsFromParameters< | ||
Parameters<AccountWalletClient['claimNamespace']>[0] | ||
> | ||
|
||
export type UseClaimNamespaceParameters = { | ||
accountId: AccountId | undefined | ||
chainName: string | undefined | ||
mutation?: UseMutationParameters< | ||
ExecuteResult, | ||
unknown, | ||
ClaimNamespaceMutation | ||
> | ||
} | ||
|
||
/** | ||
* Claim a namespace from version control on the account. | ||
* @param accountId | ||
* @param chainName | ||
* @param mutation | ||
*/ | ||
export function useClaimNamespace({ | ||
accountId, | ||
chainName, | ||
mutation, | ||
}: UseClaimNamespaceParameters): UseMutationReturnType< | ||
ExecuteResult, | ||
unknown, | ||
ClaimNamespaceMutation | ||
> { | ||
const config = useConfig() | ||
const accountClient = config.useAccountWalletClient({ | ||
chainName, | ||
accountId, | ||
}) | ||
return useMutation( | ||
['claimNamespace', chainName, accountId], | ||
({ args, ...cosmWasmSignOptions }) => { | ||
if (!accountClient) throw new Error('client is not defined') | ||
return accountClient.claimNamespace({ ...cosmWasmSignOptions, ...args }) | ||
}, | ||
mutation, | ||
) | ||
} |
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