From 58ae7c05aff6734399e9b05111364769c071e02b Mon Sep 17 00:00:00 2001 From: Serkan Reis Date: Tue, 16 Jan 2024 18:05:31 +0300 Subject: [PATCH] Cover the rest of generic messages for authz grant & revoke --- pages/authz/grant.tsx | 66 +++++++++++++++++++++++++++++++----------- pages/authz/revoke.tsx | 28 ++++++++++++++---- 2 files changed, 71 insertions(+), 23 deletions(-) diff --git a/pages/authz/grant.tsx b/pages/authz/grant.tsx index cb43fd0..261d5f2 100644 --- a/pages/authz/grant.tsx +++ b/pages/authz/grant.tsx @@ -149,6 +149,46 @@ const Grant: NextPage = () => { (expiration?.getTime() as number) / 1000 || 0, ) } + if (genericAuthType === 'MsgBeginRedelegate') { + return AuthzGenericGrantMsg( + wallet.address || '', + granteeAddressState.value, + '/cosmos.staking.v1beta1.MsgBeginRedelegate', + (expiration?.getTime() as number) / 1000 || 0, + ) + } + if (genericAuthType === 'MsgWithdrawDelegatorReward') { + return AuthzGenericGrantMsg( + wallet.address || '', + granteeAddressState.value, + '/cosmos.distribution.v1beta1.MsgWithdrawDelegatorReward', + (expiration?.getTime() as number) / 1000 || 0, + ) + } + if (genericAuthType === 'MsgVote') { + return AuthzGenericGrantMsg( + wallet.address || '', + granteeAddressState.value, + '/cosmos.gov.v1beta1.MsgVote', + (expiration?.getTime() as number) / 1000 || 0, + ) + } + if (genericAuthType === 'MsgExecuteContract') { + return AuthzGenericGrantMsg( + wallet.address || '', + granteeAddressState.value, + '/cosmwasm.wasm.v1.MsgExecuteContract', + (expiration?.getTime() as number) / 1000 || 0, + ) + } + if (genericAuthType === 'MsgMigrateContract') { + return AuthzGenericGrantMsg( + wallet.address || '', + granteeAddressState.value, + '/cosmwasm.wasm.v1.MsgMigrateContract', + (expiration?.getTime() as number) / 1000 || 0, + ) + } } else if (authType === 'Send') { return AuthzSendGrantMsg( wallet.address || '', @@ -227,28 +267,20 @@ const Grant: NextPage = () => { - - - - - + + + + + - - +
+ + +
{/* */}
diff --git a/pages/authz/revoke.tsx b/pages/authz/revoke.tsx index 929edb4..3ed58af 100644 --- a/pages/authz/revoke.tsx +++ b/pages/authz/revoke.tsx @@ -51,7 +51,7 @@ const RevokeAuthorization: NextPage = () => { gasPrice: GasPrice.fromString('0.25ustars'), }) - const result = await stargateClient.signAndBroadcast( + const response = await stargateClient.signAndBroadcast( wallet.address || '', [ { @@ -68,8 +68,9 @@ const RevokeAuthorization: NextPage = () => { gas: '200000', }, ) - setTransactionHash(result.transactionHash) - toast.success(`Revoke authorization success.`, { style: { maxWidth: 'none' } }) + setTransactionHash(response.transactionHash) + if (response.rawLog?.includes('failed')) toast.error(response.rawLog, { style: { maxWidth: 'none' } }) + else toast.success(`Revoke authorization success.`, { style: { maxWidth: 'none' } }) setIsLoading(false) } catch (e: any) { console.log(e) @@ -103,15 +104,30 @@ const RevokeAuthorization: NextPage = () => { - + + + + + - - + {/* */}