Skip to content

Commit

Permalink
dapp-feat: added remove transaction records feature to main activity …
Browse files Browse the repository at this point in the history
…page (#419)

* dapp-update: added transactionResultStorageKey to the TransactionResult type

Signed-off-by: Logan Nguyen <[email protected]>

* dapp-feat: added delete individual transaction feature in /activity

Signed-off-by: Logan Nguyen <[email protected]>

* dapp-feat: remove all cached transactions feature complete

Signed-off-by: Logan Nguyen <[email protected]>

---------

Signed-off-by: Logan Nguyen <[email protected]>
  • Loading branch information
quiet-node authored Sep 23, 2023
1 parent 182bd23 commit 7968621
Show file tree
Hide file tree
Showing 33 changed files with 190 additions and 21 deletions.
1 change: 1 addition & 0 deletions system-contract-dapp-playground/src/api/hedera/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ export const deploySmartContract = async (
if (txReceipt) {
const createTransactionResult: TransactionResult = {
status: 'success',
transactionResultStorageKey,
transactionTimeStamp: Date.now(),
txHash: txReceipt.hash as string,
transactionType: 'CONTRACT-CREATE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,11 @@ const Mint = ({ baseContract }: PageProps) => {

if (mintErr || !mintRes) {
handleAPIErrors({
err: mintErr,
toaster,
err: mintErr,
setTransactionResults,
transactionHash: txHash,
transactionResultStorageKey,
transactionType: 'ERC20-MINT',
sessionedContractAddress: currentContractAddress,
});
Expand All @@ -86,6 +87,7 @@ const Mint = ({ baseContract }: PageProps) => {
{
status: 'success',
txHash: txHash as string,
transactionResultStorageKey,
transactionType: 'ERC20-MINT',
transactionTimeStamp: Date.now(),
sessionedContractAddress: currentContractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ const TokenPermission = ({ baseContract }: PageProps) => {
handleAPIErrors({
toaster,
setTransactionResults,
transactionResultStorageKey,
err: tokenPermissionRes.err,
transactionHash: tokenPermissionRes.txHash,
sessionedContractAddress: currentContractAddress,
Expand Down Expand Up @@ -265,6 +266,7 @@ const TokenPermission = ({ baseContract }: PageProps) => {
...prev,
{
status: 'success',
transactionResultStorageKey,
transactionTimeStamp: Date.now(),
txHash: tokenPermissionRes.txHash as string,
sessionedContractAddress: currentContractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const Transfer = ({ baseContract }: PageProps) => {
toaster,
setTransactionResults,
err: tokenTransferRes.err,
transactionResultStorageKey,
transactionHash: tokenTransferRes.txHash,
sessionedContractAddress: currentContractAddress,
transactionType: `ERC20-${convertCalmelCaseFunctionName(method).replace(' ', '-')}`,
Expand All @@ -143,6 +144,7 @@ const Transfer = ({ baseContract }: PageProps) => {
...prev,
{
status: 'success',
transactionResultStorageKey,
transactionTimeStamp: Date.now(),
txHash: tokenTransferRes.txHash as string,
sessionedContractAddress: currentContractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ const ERC721Approve = ({ baseContract }: PageProps) => {
handleAPIErrors({
toaster,
setTransactionResults,
transactionResultStorageKey,
err: erc721ApproveResult.err,
transactionType: 'ERC721-APPROVE',
transactionHash: erc721ApproveResult.txHash,
Expand All @@ -136,6 +137,7 @@ const ERC721Approve = ({ baseContract }: PageProps) => {
...prev,
{
status: 'success',
transactionResultStorageKey,
transactionTimeStamp: Date.now(),
transactionType: 'ERC721-APPROVE',
txHash: erc721ApproveResult.txHash as string,
Expand All @@ -162,6 +164,7 @@ const ERC721Approve = ({ baseContract }: PageProps) => {
getApproveTokenId,
approveParams.tokenId,
currentContractAddress,
transactionResultStorageKey,
approveParams.spenderAddress,
]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ const Mint = ({ baseContract }: PageProps) => {
toaster,
setTransactionResults,
transactionHash: txHash,
transactionResultStorageKey,
transactionType: 'ERC721-MINT',
sessionedContractAddress: currentContractAddress,
});
Expand All @@ -86,6 +87,7 @@ const Mint = ({ baseContract }: PageProps) => {
{
status: 'success',
txHash: txHash as string,
transactionResultStorageKey,
transactionType: 'ERC721-MINT',
transactionTimeStamp: Date.now(),
sessionedContractAddress: currentContractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ const ERC721OperatorApproval = ({ baseContract }: PageProps) => {
toaster,
setTransactionResults,
err: tokenApprovalRes.err,
transactionResultStorageKey,
transactionType: 'ERC721-SET-APPROVAL',
transactionHash: tokenApprovalRes.txHash,
sessionedContractAddress: currentContractAddress,
Expand All @@ -182,6 +183,7 @@ const ERC721OperatorApproval = ({ baseContract }: PageProps) => {
...prev,
{
status: 'success',
transactionResultStorageKey,
transactionTimeStamp: Date.now(),
transactionType: 'ERC721-SET-APPROVAL',
txHash: tokenApprovalRes.txHash as string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ const ERC721Transfer = ({ baseContract }: PageProps) => {
toaster,
setTransactionResults,
err: tokenTransferRes.err,
transactionResultStorageKey,
transactionHash: tokenTransferRes.txHash,
sessionedContractAddress: currentContractAddress,
transactionType: `ERC721-${convertCalmelCaseFunctionName(method).replace(' ', '-')}`,
Expand All @@ -134,6 +135,7 @@ const ERC721Transfer = ({ baseContract }: PageProps) => {
...prev,
{
status: 'success',
transactionResultStorageKey,
transactionTimeStamp: Date.now(),
txHash: tokenTransferRes.txHash as string,
sessionedContractAddress: currentContractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ const HederaExchangeRateMethods = ({ baseContract }: PageProps) => {
transactionHash,
transactionType: API,
setTransactionResults,
transactionResultStorageKey,
initialAmount: paramValues.amountToConvert,
sessionedContractAddress: currentContractAddress,
});
Expand All @@ -136,6 +137,7 @@ const HederaExchangeRateMethods = ({ baseContract }: PageProps) => {
status: 'success',
APICalled: API,
transactionType: API,
transactionResultStorageKey,
transactionTimeStamp: Date.now(),
txHash: transactionHash as string,
initialAmount: paramValues.amountToConvert,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export const handleAPIErrors = ({
receiverAddress,
setTransactionResults,
sessionedContractAddress,
transactionResultStorageKey,
}: {
err: any;
toaster: any;
Expand All @@ -49,6 +50,7 @@ export const handleAPIErrors = ({
receiverAddress?: string;
tokenAddresses?: string[];
sessionedContractAddress: string;
transactionResultStorageKey: string;
transactionHash: string | undefined;
keyTypeCalled?: IHederaTokenServiceKeyType;
setTransactionResults: Dispatch<SetStateAction<TransactionResult[]>>;
Expand Down Expand Up @@ -87,12 +89,13 @@ export const handleAPIErrors = ({
transactionType,
txHash: transactionHash,
sessionedContractAddress,
transactionResultStorageKey,
transactionTimeStamp: Date.now(),
tokenAddress: tokenAddress ? tokenAddress : '',
initialAmount: initialAmount ? initialAmount : '',
accountAddress: accountAddress ? accountAddress : '',
tokenAddresses: tokenAddresses ? tokenAddresses : [''],
receiverAddress: receiverAddress ? receiverAddress : '',
transactionTimeStamp: Date.now(),
},
]);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ const AssociateHederaToken = ({ baseContract }: PageProps) => {
tokenAddresses,
transactionHash,
setTransactionResults,
transactionResultStorageKey,
accountAddress: associatingAddress,
transactionType: 'HTS-TOKEN-ASSOCIATE',
sessionedContractAddress: currentContractAddress,
Expand All @@ -164,6 +165,7 @@ const AssociateHederaToken = ({ baseContract }: PageProps) => {
{
tokenAddresses,
status: 'success',
transactionResultStorageKey,
transactionTimeStamp: Date.now(),
txHash: transactionHash as string,
accountAddress: associatingAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ const FungibleTokenCreate = ({ baseContract }: PageProps) => {
toaster,
transactionHash,
setTransactionResults,
transactionResultStorageKey,
transactionType: 'HTS-TOKEN-CREATE',
sessionedContractAddress: currentContractAddress,
});
Expand All @@ -192,6 +193,7 @@ const FungibleTokenCreate = ({ baseContract }: PageProps) => {
{
tokenAddress,
status: 'success',
transactionResultStorageKey,
transactionTimeStamp: Date.now(),
txHash: transactionHash as string,
transactionType: 'HTS-TOKEN-CREATE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const GrantTokenKYC = ({ baseContract }: PageProps) => {
toaster,
transactionHash,
setTransactionResults,
transactionResultStorageKey,
tokenAddress: hederaTokenAddress,
transactionType: 'HTS-GRANT-KYC',
accountAddress: grantingKYCAccountAddress,
Expand All @@ -131,6 +132,7 @@ const GrantTokenKYC = ({ baseContract }: PageProps) => {
...prev,
{
status: 'success',
transactionResultStorageKey,
transactionType: 'HTS-GRANT-KYC',
transactionTimeStamp: Date.now(),
tokenAddress: hederaTokenAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ const MintHederaToken = ({ baseContract }: PageProps) => {
toaster,
err: txRes.err,
setTransactionResults,
transactionResultStorageKey,
tokenAddress: tokenAddressToMint,
transactionHash: txRes.transactionHash,
sessionedContractAddress: currentContractAddress,
Expand All @@ -202,6 +203,7 @@ const MintHederaToken = ({ baseContract }: PageProps) => {
...prev,
{
status: 'success',
transactionResultStorageKey,
accountAddress: recipientAddress,
transactionTimeStamp: Date.now(),
txHash: txRes.transactionHash as string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,7 @@ const NonFungibleTokenCreate = ({ baseContract }: PageProps) => {
toaster,
transactionHash,
setTransactionResults,
transactionResultStorageKey,
transactionType: 'HTS-NFT-CREATE',
sessionedContractAddress: currentContractAddress,
});
Expand All @@ -170,6 +171,7 @@ const NonFungibleTokenCreate = ({ baseContract }: PageProps) => {
{
tokenAddress,
status: 'success',
transactionResultStorageKey,
transactionTimeStamp: Date.now(),
transactionType: 'HTS-NFT-CREATE',
txHash: transactionHash as string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ const ManageTokenDelete = ({ baseContract }: PageProps) => {
toaster,
transactionHash,
setTransactionResults,
transactionResultStorageKey,
tokenAddress: hederaTokenAddress,
transactionType: 'HTS-TOKEN-DELETE',
sessionedContractAddress: currentContractAddress,
Expand All @@ -131,6 +132,7 @@ const ManageTokenDelete = ({ baseContract }: PageProps) => {
...prev,
{
status: 'success',
transactionResultStorageKey,
tokenAddress: hederaTokenAddress,
transactionTimeStamp: Date.now(),
txHash: transactionHash as string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ const ManageTokenInfo = ({ baseContract }: PageProps) => {
toaster,
transactionHash,
setTransactionResults,
transactionResultStorageKey,
tokenAddress: hederaTokenAddress,
sessionedContractAddress: currentContractAddress,
transactionType: `HTS-${APIMethods.replace('_', '-')}`,
Expand All @@ -273,6 +274,7 @@ const ManageTokenInfo = ({ baseContract }: PageProps) => {
...prev,
{
status: 'success',
transactionResultStorageKey,
tokenAddress: hederaTokenAddress,
transactionTimeStamp: Date.now(),
txHash: transactionHash as string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ const ManageTokenPermission = ({ baseContract }: PageProps) => {
toaster,
transactionHash,
setTransactionResults,
transactionResultStorageKey,
tokenAddress: hederaTokenAddress,
transactionType: transactionTypeMap[API],
sessionedContractAddress: currentContractAddress,
Expand All @@ -178,6 +179,7 @@ const ManageTokenPermission = ({ baseContract }: PageProps) => {
...prev,
{
status: 'success',
transactionResultStorageKey,
tokenAddress: hederaTokenAddress,
transactionTimeStamp: Date.now(),
txHash: transactionHash as string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ const ManageTokenRelation = ({ baseContract }: PageProps) => {
toaster,
transactionHash,
setTransactionResults,
transactionResultStorageKey,
tokenAddress: paramValues.hederaTokenAddress,
transactionType: `HTS-${API.replace('_', '-')}`,
sessionedContractAddress: currentContractAddress,
Expand All @@ -229,6 +230,7 @@ const ManageTokenRelation = ({ baseContract }: PageProps) => {
...prev,
{
status: 'success',
transactionResultStorageKey,
transactionTimeStamp: Date.now(),
txHash: transactionHash as string,
tokenAddress: paramValues.hederaTokenAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ const ManageTokenStatus = ({ baseContract }: PageProps) => {
toaster,
transactionHash,
setTransactionResults,
transactionResultStorageKey,
transactionType: `HTS-TOKEN-${API}`,
tokenAddress: paramValues.hederaTokenAddress,
sessionedContractAddress: currentContractAddress,
Expand All @@ -141,6 +142,7 @@ const ManageTokenStatus = ({ baseContract }: PageProps) => {
...prev,
{
status: 'success',
transactionResultStorageKey,
transactionTimeStamp: Date.now(),
txHash: transactionHash as string,
transactionType: `HTS-TOKEN-${API}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,7 @@ const ManageTokenDeduction = ({ baseContract }: PageProps) => {
toaster,
transactionHash,
setTransactionResults,
transactionResultStorageKey,
tokenAddress: hederaTokenAddress,
transactionType: transactionTypeMap[API],
sessionedContractAddress: currentContractAddress,
Expand All @@ -176,6 +177,7 @@ const ManageTokenDeduction = ({ baseContract }: PageProps) => {
...prev,
{
status: 'success',
transactionResultStorageKey,
transactionTimeStamp: Date.now(),
tokenAddress: hederaTokenAddress,
txHash: transactionHash as string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ const QueryTokenSpecificInfomation = ({ baseContract }: PageProps) => {
setTransactionResults,
keyTypeCalled: keyType,
err: tokenInfoResult.err,
transactionResultStorageKey,
tokenAddress: paramValues.hederaTokenAddress,
sessionedContractAddress: currentContractAddress,
transactionHash: tokenInfoResult.transactionHash,
Expand Down Expand Up @@ -233,6 +234,7 @@ const QueryTokenSpecificInfomation = ({ baseContract }: PageProps) => {
status: 'success',
keyTypeCalled: keyType,
tokenInfo: cachedTokenInfo,
transactionResultStorageKey,
transactionTimeStamp: Date.now(),
tokenAddress: paramValues.hederaTokenAddress,
sessionedContractAddress: currentContractAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ const QueryTokenGeneralInfomation = ({ baseContract }: PageProps) => {
toaster,
err: err,
setTransactionResults,
transactionResultStorageKey,
transactionHash: transactionHash,
transactionType: transactionTypeMap[API],
tokenAddress: paramValues.hederaTokenAddress,
Expand All @@ -187,6 +188,7 @@ const QueryTokenGeneralInfomation = ({ baseContract }: PageProps) => {
{
APICalled: API,
status: 'success',
transactionResultStorageKey,
transactionTimeStamp: Date.now(),
txHash: transactionHash as string,
transactionType: transactionTypeMap[API],
Expand Down
Loading

0 comments on commit 7968621

Please sign in to comment.