forked from ecency/ecency-vision
-
Notifications
You must be signed in to change notification settings - Fork 5
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 #15 from spknetwork/feat/rc-delegation
initiate rc feature
- Loading branch information
Showing
22 changed files
with
1,759 additions
and
23 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 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,39 @@ | ||
import { useMutation } from "@tanstack/react-query"; | ||
import { usrActivity } from "./private-api"; | ||
import { claimAccount, claimAccountByKeychain } from "./operations"; | ||
import { FullAccount } from "../store/accounts/types"; | ||
import { PrivateKey } from "@hiveio/dhive"; | ||
|
||
interface Params { | ||
bl?: string | number; | ||
tx?: string | number; | ||
} | ||
|
||
export function useUserActivity(username: string | undefined, ty: number) { | ||
return useMutation(["user-activity", username, ty], async (params: Params | undefined) => { | ||
if (username) { | ||
await usrActivity(username, ty, params?.bl, params?.tx); | ||
} | ||
}); | ||
} | ||
|
||
export function useAccountClaiming(account: FullAccount) { | ||
return useMutation( | ||
["account-claiming", account.name], | ||
async ({ isKeychain, key }: { key?: PrivateKey; isKeychain?: boolean }) => { | ||
try { | ||
if (isKeychain) { | ||
return await claimAccountByKeychain(account); | ||
} | ||
|
||
if (key) { | ||
return await claimAccount(account, key); | ||
} | ||
|
||
throw new Error(); | ||
} catch (error) { | ||
throw new Error("Failed RC claiming. Please, try again or contact with support."); | ||
} | ||
} | ||
); | ||
} |
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.