Show transaction details in context methods and confirmation modals for redeeming/compounding rewards

This commit is contained in:
Mark Sinclair
2022-06-13 12:27:04 +01:00
parent b48184ba13
commit 6ed28b5a1d
3 changed files with 12 additions and 9 deletions
+2 -1
View File
@@ -28,7 +28,8 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https://
- wallet: new delegation and rewards UI
- wallet: show version in nav bar
- wallet: contract admin route put back
- waller: staking_supply field to StateParams
- wallet: staking_supply field to StateParams
- wallet: show transaction hash for redeeming or compounding rewards
- network-statistics: a new mixnet service that aggregates and exposes anonymized data about mixnet services ([#1328])
### Fixed
+6 -6
View File
@@ -32,8 +32,8 @@ export type TDelegationContext = {
tokenPool: TPoolOption,
) => Promise<TransactionExecuteResult>;
undelegate: (identity: string, proxy: string | null) => Promise<TransactionExecuteResult>;
redeemRewards: (identity: string, proxy: string | null) => Promise<void>;
compoundRewards: (identity: string, proxy: string | null) => Promise<void>;
redeemRewards: (identity: string, proxy: string | null) => Promise<TransactionExecuteResult>;
compoundRewards: (identity: string, proxy: string | null) => Promise<TransactionExecuteResult>;
};
export type TDelegationTransaction = {
@@ -100,10 +100,10 @@ export const DelegationContextProvider: FC<{
try {
if ((proxy || '').trim().length === 0) {
// the owner of the delegation is main account (the owner of the vesting account), so it is delegation with unlocked tokens
await claimDelegatorRewards(identity);
return claimDelegatorRewards(identity);
} else {
// the delegation is with locked tokens, so use the vesting contract
await vestingClaimDelegatorRewards(identity);
return vestingClaimDelegatorRewards(identity);
}
} catch (e) {
throw new Error(e as string);
@@ -114,10 +114,10 @@ export const DelegationContextProvider: FC<{
try {
if ((proxy || '').trim().length === 0) {
// the owner of the delegation is main account (the owner of the vesting account), so it is delegation with unlocked tokens
await compoundDelegatorRewards(identity);
return compoundDelegatorRewards(identity);
} else {
// the delegation is with locked tokens, so use the vesting contract
await vestingCompoundDelegatorRewards(identity);
return vestingCompoundDelegatorRewards(identity);
}
} catch (e) {
throw new Error(e as string);
+4 -2
View File
@@ -196,12 +196,13 @@ export const Delegation: FC = () => {
setCurrentDelegationListActionItem(undefined);
try {
await redeemRewards(identityKey, proxy);
const tx = await redeemRewards(identityKey, proxy);
const bal = await userBalance();
setConfirmationModalProps({
status: 'success',
action: 'redeem',
balance: bal?.printable_balance || '-',
transactionUrl: `${urls(network).blockExplorer}/transaction/${tx.transaction_hash}`,
});
} catch (e) {
setConfirmationModalProps({
@@ -221,12 +222,13 @@ export const Delegation: FC = () => {
setCurrentDelegationListActionItem(undefined);
try {
await compoundRewards(identityKey, proxy);
const tx = await compoundRewards(identityKey, proxy);
const bal = await userBalance();
setConfirmationModalProps({
status: 'success',
action: 'compound',
balance: bal?.printable_balance || '-',
transactionUrl: `${urls(network).blockExplorer}/transaction/${tx.transaction_hash}`,
});
} catch (e) {
setConfirmationModalProps({