From 44658fcccd9120836f693b9b721376d86cf09848 Mon Sep 17 00:00:00 2001 From: Logan Nguyen Date: Fri, 22 Sep 2023 23:54:52 -0500 Subject: [PATCH] dapp-refactor: reorganized shared items (#420) (#422) * dapp-refactor: moved /hooks folder to /src folder Signed-off-by: Logan Nguyen * dapp-refactor: moved handleRetrievingTransactionResultsFromLocalStorage and handleSanitizeFormInputs to main common shared method folder Signed-off-by: Logan Nguyen * dapp-refactor: moved erc/hooks to main hooks folder and erc/methods to main methods folder Signed-off-by: Logan Nguyen * dapp-refactor: moved prepareInfoValuesToShow() and TransactionResultTable() to its main shared folder Signed-off-by: Logan Nguyen * dapp-refactor: reorganized token-create-custom Signed-off-by: Logan Nguyen * dapp-update: reused copyContentToClipboard where needed Signed-off-by: Logan Nguyen * dapp-update: renamed handleRemoveRecord to handleRemoveMapRecord Signed-off-by: Logan Nguyen * dapp-update: renamed navsidebar Signed-off-by: Logan Nguyen * dapp-update: renamed interfaces and types Signed-off-by: Logan Nguyen * dapp-refactor: moved ITransactionResult && ISmartContractExecutionResult to a shared type folder Signed-off-by: Logan Nguyen * dapp-update: replaced IExchangeRateContractResult & IPRNGContractResult with ISmartContractExecutionResult Signed-off-by: Logan Nguyen --------- Signed-off-by: Logan Nguyen --- .../__tests__/hedera/helper/index.test.ts | 4 - .../token-create-custom/index.test.ts | 9 +- .../token-management-contract/index.test.ts | 11 +-- .../token-transfer-contract/index.test.ts | 4 - .../__tests__/hedera/index.test.ts | 4 +- .../__tests__/mirror-node/index.test.ts | 14 ++-- .../src/api/ethers/index.ts | 16 ++-- .../api/hedera/erc20-interactions/index.ts | 20 ++--- .../api/hedera/erc721-interactions/index.ts | 32 ++++---- .../exchange-rate-interactions/index.ts | 5 +- .../tokenCreateCustom-interactions/index.ts | 81 +++++++----------- .../tokenManagement-interactions/index.ts | 82 ++++++++----------- .../tokenQuery-interactions/index.ts | 47 ++++------- .../tokenTransfer-interactions/index.ts | 32 +++----- .../src/api/hedera/ihrc-interactions/index.ts | 6 +- .../src/api/hedera/index.ts | 14 ++-- .../src/api/hedera/prng-interactions/index.ts | 9 +- .../src/api/mirror-node/index.ts | 10 +-- .../src/api/wallet/index.ts | 22 ++--- .../src/app/activity/layout.tsx | 6 +- .../src/app/hedera/layout.tsx | 6 +- .../common/{ => components}/AlertDialog.tsx | 0 .../common/{ => components}/ConfirmModal.tsx | 0 .../HederaCommonTextField.tsx | 0 .../{ => components}/MultiLineMethod.tsx | 0 .../common/{ => components}/OneLineMethod.tsx | 0 .../components/TransactionResultTable.tsx | 29 +++---- .../erc/shared => common}/methods/common.tsx | 2 +- .../methods/handleAPIErrors.tsx | 4 +- ...vingTransactionResultsFromLocalStorage.tsx | 8 +- .../methods/handleSanitizeFormInputs.tsx | 3 +- .../methods/prepareInfoValuesToShow.tsx | 0 .../erc/deployment/ERCDeployField.tsx | 2 +- .../erc/erc-20/methods/balance-of/index.tsx | 6 +- .../erc/erc-20/methods/mint/index.tsx | 10 +-- .../methods/token-information/index.tsx | 2 +- .../erc-20/methods/token-permission/index.tsx | 14 ++-- .../erc-20/methods/token-transfer/index.tsx | 12 +-- .../erc/erc-721/methods/approve/index.tsx | 18 ++-- .../erc/erc-721/methods/balance-of/index.tsx | 6 +- .../erc/erc-721/methods/mint/index.tsx | 12 +-- .../methods/operator-approve/index.tsx | 14 ++-- .../erc/erc-721/methods/owner-of/index.tsx | 6 +- .../methods/token-information/index.tsx | 2 +- .../erc-721/methods/token-transfer/index.tsx | 12 +-- .../erc/erc-721/methods/token-uri/index.tsx | 6 +- .../deployment/ExchangeRateDeployField.tsx | 8 +- .../exchange-rate/methods/index.tsx | 20 ++--- .../hts/shared/components/SigningKeysForm.tsx | 22 ++--- .../components/TokenGeneralInfoModal.tsx | 2 +- .../components/TokenSpecificInfoModal.tsx | 3 +- .../hts/shared/methods/signingKeys.tsx | 20 ++--- .../hts/shared/states/commonStates.ts | 5 -- .../index.tsx} | 26 +++--- .../index.tsx} | 32 ++++---- .../index.tsx} | 24 +++--- .../index.tsx} | 26 +++--- .../index.tsx} | 32 ++++---- .../hts/token-create-custom/methods/index.tsx | 4 +- .../methods/manageTokenDelete/index.tsx | 20 ++--- .../methods/manageTokenInfo/TokenKeysForm.tsx | 17 +--- .../methods/manageTokenInfo/index.tsx | 33 +++----- .../methods/manageTokenPermission/index.tsx | 20 ++--- .../methods/manageTokenRelation/index.tsx | 20 ++--- .../methods/manageTokenStatus/index.tsx | 18 ++-- .../manageTokenSupplyReduction/index.tsx | 20 ++--- .../methods/querySpecificToken/index.tsx | 16 ++-- .../methods/queryTokenGeneralInfo/index.tsx | 18 ++-- .../methods/queryTokenPermission/index.tsx | 18 ++-- .../methods/queryTokenStatus/index.tsx | 20 ++--- .../methods/queryTokenValidity/index.tsx | 18 ++-- .../helpers/prepareCryptoTransferValues.ts | 5 -- .../method/transferCrypto/index.tsx | 22 ++--- .../method/transferMultipleTokens/index.tsx | 22 ++--- .../method/transferSingleToken/index.tsx | 20 ++--- .../ihrc/methods/index.tsx | 16 ++-- .../components/contract-interaction/index.tsx | 19 +++-- .../prng/methods/index.tsx | 18 ++-- .../src/components/navbar/index.tsx | 6 +- .../{leftSideBar => sidebar}/index.tsx | 8 +- .../src/components/wallet-popup/index.tsx | 11 +-- ...useFilterTransactionsByContractAddress.tsx | 4 +- .../hooks/usePaginatedTxResults.tsx | 6 +- .../useRetrieveMapValueFromLocalStorage.tsx | 0 .../shared => }/hooks/useToastSuccessful.tsx | 19 ++--- .../hooks/useUpdateLocalStorage.tsx | 4 +- .../hooks/useUpdateMapStateUILocalStorage.tsx | 10 +-- .../src/sections/activity/index.tsx | 13 +-- .../src/sections/overview/index.tsx | 4 +- .../src/types/common/index.d.ts | 26 +++--- .../ExchangeRate/index.d.ts | 26 ------ .../contract-interactions/HTS/index.d.ts | 51 +----------- .../contract-interactions/PRNG/index.d.ts | 26 ------ .../contract-interactions/erc/index.d.ts | 2 +- .../contract-interactions/shared/index.d.ts | 70 ++++++++++++++++ .../src/utils/common/constants.ts | 28 +++---- .../src/utils/common/helpers.ts | 10 +-- .../contract-interactions/HTS/helpers.ts | 29 ++----- .../HTS/token-create-custom/constant.ts | 27 +++--- .../HTS/token-management/constant.ts | 7 +- 100 files changed, 683 insertions(+), 890 deletions(-) rename system-contract-dapp-playground/src/components/common/{ => components}/AlertDialog.tsx (100%) rename system-contract-dapp-playground/src/components/common/{ => components}/ConfirmModal.tsx (100%) rename system-contract-dapp-playground/src/components/common/{ => components}/HederaCommonTextField.tsx (100%) rename system-contract-dapp-playground/src/components/common/{ => components}/MultiLineMethod.tsx (100%) rename system-contract-dapp-playground/src/components/common/{ => components}/OneLineMethod.tsx (100%) rename system-contract-dapp-playground/src/components/{contract-interaction/hts/shared => common}/components/TransactionResultTable.tsx (96%) rename system-contract-dapp-playground/src/components/{contract-interaction/erc/shared => common}/methods/common.tsx (90%) rename system-contract-dapp-playground/src/components/{contract-interaction/hts/shared => common}/methods/handleAPIErrors.tsx (95%) rename system-contract-dapp-playground/src/components/{contract-interaction/hts/shared => common}/methods/handleRetrievingTransactionResultsFromLocalStorage.tsx (85%) rename system-contract-dapp-playground/src/components/{contract-interaction/hts/shared => common}/methods/handleSanitizeFormInputs.tsx (99%) rename system-contract-dapp-playground/src/components/{contract-interaction/hts/shared => common}/methods/prepareInfoValuesToShow.tsx (100%) rename system-contract-dapp-playground/src/components/contract-interaction/hts/token-create-custom/methods/{AssociateHederaToken.tsx => AssociateHederaToken/index.tsx} (89%) rename system-contract-dapp-playground/src/components/contract-interaction/hts/token-create-custom/methods/{FungibleTokenCreate.tsx => FungibleTokenCreate/index.tsx} (92%) rename system-contract-dapp-playground/src/components/contract-interaction/hts/token-create-custom/methods/{GrantTokenKYC.tsx => GrantTokenKYC/index.tsx} (88%) rename system-contract-dapp-playground/src/components/contract-interaction/hts/token-create-custom/methods/{MintHederaToken.tsx => MintHederaToken/index.tsx} (90%) rename system-contract-dapp-playground/src/components/contract-interaction/hts/token-create-custom/methods/{NonFungibleTokenCreate.tsx => NonFungibleTokenCreate/index.tsx} (90%) rename system-contract-dapp-playground/src/components/{leftSideBar => sidebar}/index.tsx (90%) rename system-contract-dapp-playground/src/{components/contract-interaction/hts/shared => }/hooks/useFilterTransactionsByContractAddress.tsx (89%) rename system-contract-dapp-playground/src/{components/contract-interaction/hts/shared => }/hooks/usePaginatedTxResults.tsx (87%) rename system-contract-dapp-playground/src/{components/contract-interaction/erc/shared => }/hooks/useRetrieveMapValueFromLocalStorage.tsx (100%) rename system-contract-dapp-playground/src/{components/contract-interaction/hts/shared => }/hooks/useToastSuccessful.tsx (89%) rename system-contract-dapp-playground/src/{components/contract-interaction/hts/shared => }/hooks/useUpdateLocalStorage.tsx (90%) rename system-contract-dapp-playground/src/{components/contract-interaction/erc/shared => }/hooks/useUpdateMapStateUILocalStorage.tsx (96%) delete mode 100644 system-contract-dapp-playground/src/types/contract-interactions/ExchangeRate/index.d.ts delete mode 100644 system-contract-dapp-playground/src/types/contract-interactions/PRNG/index.d.ts create mode 100644 system-contract-dapp-playground/src/types/contract-interactions/shared/index.d.ts diff --git a/system-contract-dapp-playground/__tests__/hedera/helper/index.test.ts b/system-contract-dapp-playground/__tests__/hedera/helper/index.test.ts index 617ab24ea..30e9029ac 100644 --- a/system-contract-dapp-playground/__tests__/hedera/helper/index.test.ts +++ b/system-contract-dapp-playground/__tests__/hedera/helper/index.test.ts @@ -23,10 +23,6 @@ import { DEFAULT_IHTS_KEY_VALUE, KEY_TYPE_MAP, } from '@/utils/contract-interactions/HTS/token-create-custom/constant'; -import { - IHederaTokenServiceKeyType, - IHederaTokenServiceKeyValueType, -} from '@/types/contract-interactions/HTS'; describe('constructIHederaTokenKey test suite', () => { // mock contractId & compressedPubKey diff --git a/system-contract-dapp-playground/__tests__/hedera/hts-interactions/token-create-custom/index.test.ts b/system-contract-dapp-playground/__tests__/hedera/hts-interactions/token-create-custom/index.test.ts index e1dcfcb24..ae51dd01d 100644 --- a/system-contract-dapp-playground/__tests__/hedera/hts-interactions/token-create-custom/index.test.ts +++ b/system-contract-dapp-playground/__tests__/hedera/hts-interactions/token-create-custom/index.test.ts @@ -27,7 +27,6 @@ import { createHederaNonFungibleToken, associateHederaTokensToAccounts, } from '@/api/hedera/hts-interactions/tokenCreateCustom-interactions'; -import { CommonKeyObject } from '@/types/contract-interactions/HTS'; import { MOCK_TOKEN_ADDRESS, MOCK_TX_HASH } from '../../../utils/common/constants'; describe('createHederaFungibleToken test suite', () => { @@ -83,8 +82,8 @@ describe('createHederaFungibleToken test suite', () => { createNonFungibleTokenWithCustomFeesPublic: jest.fn().mockResolvedValue(mockResolvedValue), }; - // mock inputKeys with CommonKeyObject[] type - const inputKeys: CommonKeyObject[] = [ + // mock inputKeys with ICommonKeyObject[] type + const inputKeys: ICommonKeyObject[] = [ { keyType: 'ADMIN', keyValueType: 'contractId', @@ -261,7 +260,7 @@ describe('createHederaFungibleToken test suite', () => { }); it('should execute createHederaFungibleToken and return error if inputKeys is invalid ', async () => { - const failedKeys: CommonKeyObject[] = [ + const failedKeys: ICommonKeyObject[] = [ { keyType: 'ADMIN', keyValueType: 'contractId', @@ -395,7 +394,7 @@ describe('createHederaFungibleToken test suite', () => { }); it('should execute createHederaNonFungibleToken and return error if inputKeys is invalid ', async () => { - const failedKeys: CommonKeyObject[] = [ + const failedKeys: ICommonKeyObject[] = [ { keyType: 'ADMIN', keyValueType: 'contractId', diff --git a/system-contract-dapp-playground/__tests__/hedera/hts-interactions/token-management-contract/index.test.ts b/system-contract-dapp-playground/__tests__/hedera/hts-interactions/token-management-contract/index.test.ts index 7dc94ea10..426cc53f9 100644 --- a/system-contract-dapp-playground/__tests__/hedera/hts-interactions/token-management-contract/index.test.ts +++ b/system-contract-dapp-playground/__tests__/hedera/hts-interactions/token-management-contract/index.test.ts @@ -18,6 +18,7 @@ * */ +import { Contract } from 'ethers'; import { manageTokenStatus, manageTokenRelation, @@ -25,12 +26,6 @@ import { manageTokenInfomation, manageTokenPermission, } from '@/api/hedera/hts-interactions/tokenManagement-interactions'; -import { - CommonKeyObject, - IHederaTokenServiceExpiry, - IHederaTokenServiceHederaToken, -} from '@/types/contract-interactions/HTS'; -import { Contract } from 'ethers'; import { MOCK_CONTRACT_ID, MOCK_GAS_LIMIT, @@ -68,8 +63,8 @@ describe('TokenManagementContract test suite', () => { expiry: tokenExpiry, }; - // mock inputKeys with CommonKeyObject[] type - const tokenKeys: CommonKeyObject[] = [ + // mock inputKeys with ICommonKeyObject[] type + const tokenKeys: ICommonKeyObject[] = [ { keyType: 'ADMIN', keyValueType: 'contractId', diff --git a/system-contract-dapp-playground/__tests__/hedera/hts-interactions/token-transfer-contract/index.test.ts b/system-contract-dapp-playground/__tests__/hedera/hts-interactions/token-transfer-contract/index.test.ts index 149cf337a..f2d6755e1 100644 --- a/system-contract-dapp-playground/__tests__/hedera/hts-interactions/token-transfer-contract/index.test.ts +++ b/system-contract-dapp-playground/__tests__/hedera/hts-interactions/token-transfer-contract/index.test.ts @@ -19,10 +19,6 @@ */ import { Contract } from 'ethers'; -import { - IHederaTokenServiceTokenTransferList, - IHederaTokenServiceTransferList, -} from '@/types/contract-interactions/HTS'; import { MOCK_RESPONSE_CODE, MOCK_TX_HASH, diff --git a/system-contract-dapp-playground/__tests__/hedera/index.test.ts b/system-contract-dapp-playground/__tests__/hedera/index.test.ts index 0e0f7cf62..ecc5ec165 100644 --- a/system-contract-dapp-playground/__tests__/hedera/index.test.ts +++ b/system-contract-dapp-playground/__tests__/hedera/index.test.ts @@ -20,7 +20,7 @@ import { ContractFactory } from 'ethers'; import { deploySmartContract } from '@/api/hedera'; -import { HederaSmartContractResult } from '@/types/common'; +import { IHederaSmartContractResult } from '@/types/common'; import { HEDERA_SMART_CONTRACTS_ASSETS } from '@/utils/common/constants'; import { MOCK_CONTRACT_ID, MOCK_TX_HASH } from '../utils/common/constants'; @@ -74,7 +74,7 @@ describe('deploySmartContract', () => { (ContractFactory as unknown as jest.Mock).mockImplementation(() => mockContract); // execute deploySmartContract API - const result: HederaSmartContractResult = await deploySmartContract( + const result: IHederaSmartContractResult = await deploySmartContract( contractABI, contractBytecode, deployParams diff --git a/system-contract-dapp-playground/__tests__/mirror-node/index.test.ts b/system-contract-dapp-playground/__tests__/mirror-node/index.test.ts index 6a1ee89b6..6e4000572 100644 --- a/system-contract-dapp-playground/__tests__/mirror-node/index.test.ts +++ b/system-contract-dapp-playground/__tests__/mirror-node/index.test.ts @@ -19,7 +19,7 @@ */ import { getHederaNativeIDFromEvmAddress } from '@/api/mirror-node'; -import { NetworkName } from '@/types/common'; +import { TNetworkName } from '@/types/common'; import { HEDERA_NETWORKS } from '@/utils/common/constants'; import axios from 'axios'; import MockAdapter from 'axios-mock-adapter'; @@ -30,7 +30,7 @@ const RestMock = new MockAdapter(axios); describe('getHederaNativeIDFromEvmAddress calls the correct mirror URL', () => { it('should match mirror-node url dynamically based on different networks', async () => { const evmAddress = '0xCC07a8243578590d55c5708D7fB453245350Cc2A'; - const networks: NetworkName[] = ['mainnet', 'testnet', 'previewnet', 'localnet']; + const networks: TNetworkName[] = ['mainnet', 'testnet', 'previewnet', 'localnet']; networks.forEach((network) => { const experimentUrl = `${HEDERA_NETWORKS[network].mirrorNodeUrl}/accounts/${evmAddress}`; @@ -47,7 +47,7 @@ describe('getHederaNativeIDFromEvmAddress calls the correct mirror URL', () => { it('should match mirror-node url dynamically based on different params', async () => { const evmAddress = '0xCC07a8243578590d55c5708D7fB453245350Cc2A'; - const network: NetworkName = 'mainnet'; + const network: TNetworkName = 'mainnet'; const params = ['accounts', 'contracts']; params.forEach((param) => { @@ -61,7 +61,7 @@ describe('getHederaNativeIDFromEvmAddress calls the correct mirror URL', () => { it('should call the correct mirror node URL when a network environment is set', async () => { const accountParam = 'accounts'; const contractParam = 'contracts'; - const network: NetworkName = 'testnet'; + const network: TNetworkName = 'testnet'; const expectedHederaNativeId = '0.0.445445'; const evmAddress = '0xCC07a8243578590d55c5708D7fB453245350Cc2A'; @@ -75,11 +75,7 @@ describe('getHederaNativeIDFromEvmAddress calls the correct mirror URL', () => { RestMock.onGet(expectedContractUrl).reply(200, mockContractResponse); const accountResult = await getHederaNativeIDFromEvmAddress(evmAddress, network, accountParam); - const contractResult = await getHederaNativeIDFromEvmAddress( - evmAddress, - network, - contractParam - ); + const contractResult = await getHederaNativeIDFromEvmAddress(evmAddress, network, contractParam); expect(accountResult.accountId).toBe(expectedHederaNativeId); expect(contractResult.contractId).toBe(expectedHederaNativeId); diff --git a/system-contract-dapp-playground/src/api/ethers/index.ts b/system-contract-dapp-playground/src/api/ethers/index.ts index ed21ba70f..3898b22d8 100644 --- a/system-contract-dapp-playground/src/api/ethers/index.ts +++ b/system-contract-dapp-playground/src/api/ethers/index.ts @@ -20,21 +20,21 @@ import { ethers } from 'ethers'; import { getWalletProvider } from '../wallet'; -import { ContractABI, EthersResult } from '@/types/common'; +import { IContractABI, IEthersResult } from '@/types/common'; /** * @dev generate a new ethers.Contract instance at contractAddress * * @param contractAddress: string * - * @param contractABI: ContractABI[] + * @param contractABI: IContractABI[] * - * @return Promise + * @return Promise */ export const generateBaseContractInstance = async ( contractAddress: string, - contractABI: ContractABI[] -): Promise => { + contractABI: IContractABI[] +): Promise => { // get wallet provider const walletProvider = getWalletProvider(); if (walletProvider.err || !walletProvider.walletProvider) { @@ -46,11 +46,7 @@ export const generateBaseContractInstance = async ( const walletSigner = await walletProvider.walletProvider.getSigner(); // generate a new ethers.Contract instance - const baseContract = new ethers.Contract( - contractAddress, - JSON.stringify(contractABI), - walletSigner - ); + const baseContract = new ethers.Contract(contractAddress, JSON.stringify(contractABI), walletSigner); return { baseContract }; } catch (err) { diff --git a/system-contract-dapp-playground/src/api/hedera/erc20-interactions/index.ts b/system-contract-dapp-playground/src/api/hedera/erc20-interactions/index.ts index a08922bce..712bbf4fb 100644 --- a/system-contract-dapp-playground/src/api/hedera/erc20-interactions/index.ts +++ b/system-contract-dapp-playground/src/api/hedera/erc20-interactions/index.ts @@ -29,12 +29,12 @@ import { Contract, isAddress } from 'ethers'; * * @param method: 'name' | 'symbol' | 'totalSupply' | 'decimals' * - * @return Promise + * @return Promise */ export const getERC20TokenInformation = async ( baseContract: Contract, method: 'name' | 'symbol' | 'totalSupply' | 'decimals' -): Promise => { +): Promise => { try { switch (method) { case 'name': @@ -61,13 +61,13 @@ export const getERC20TokenInformation = async ( * * @param tokenAmount: number * - * @return Promise + * @return Promise */ export const erc20Mint = async ( baseContract: Contract, recipientAddress: string, tokenAmount: number -): Promise => { +): Promise => { if (!isAddress(recipientAddress)) { return { err: 'Invalid recipient address' }; } else if (tokenAmount <= 0) { @@ -90,12 +90,12 @@ export const erc20Mint = async ( * * @param accountAddress: address * - * @return Promise + * @return Promise */ export const balanceOf = async ( baseContract: Contract, accountAddress: string -): Promise => { +): Promise => { if (!isAddress(accountAddress)) { return { err: 'Invalid account address' }; } @@ -129,7 +129,7 @@ export const balanceOf = async ( * * @param amount?: number * - * @return Promise + * @return Promise */ export const handleErc20TokenPermissions = async ( baseContract: Contract, @@ -137,7 +137,7 @@ export const handleErc20TokenPermissions = async ( spenderAddress: string, ownerAddress?: string, amount?: number -): Promise => { +): Promise => { // sanitize params if (ownerAddress && !isAddress(ownerAddress)) { return { err: 'Invalid owner address' }; @@ -188,7 +188,7 @@ export const handleErc20TokenPermissions = async ( * * @param tokenOwnerAddress?: address * - * @return Promise + * @return Promise */ export const erc20Transfers = async ( baseContract: Contract, @@ -196,7 +196,7 @@ export const erc20Transfers = async ( recipientAddress: string, amount: number, tokenOwnerAddress?: string -): Promise => { +): Promise => { if (method === 'transferFrom' && !isAddress(tokenOwnerAddress)) { return { err: 'Invalid token owner address' }; } else if (!isAddress(recipientAddress)) { diff --git a/system-contract-dapp-playground/src/api/hedera/erc721-interactions/index.ts b/system-contract-dapp-playground/src/api/hedera/erc721-interactions/index.ts index e33bb619a..d3ff95435 100644 --- a/system-contract-dapp-playground/src/api/hedera/erc721-interactions/index.ts +++ b/system-contract-dapp-playground/src/api/hedera/erc721-interactions/index.ts @@ -29,12 +29,12 @@ import { Contract, ethers, isAddress } from 'ethers'; * * @param method: 'name' | 'symbol' * - * @return Promise + * @return Promise */ export const getERC721TokenInformation = async ( baseContract: Contract, method: 'name' | 'symbol' -): Promise => { +): Promise => { try { switch (method) { case 'name': @@ -55,12 +55,12 @@ export const getERC721TokenInformation = async ( * * @param tokenId: number * - * @return Promise + * @return Promise */ export const erc721TokenURI = async ( baseContract: Contract, tokenId: number -): Promise => { +): Promise => { if (tokenId < 0) { return { err: 'Invalid token amount' }; } @@ -82,13 +82,13 @@ export const erc721TokenURI = async ( * * @param tokenId: number * - * @return Promise + * @return Promise */ export const erc721Mint = async ( baseContract: Contract, recipientAddress: string, tokenId: number -): Promise => { +): Promise => { if (!isAddress(recipientAddress)) { return { err: 'Invalid recipient address' }; } else if (tokenId < 0) { @@ -111,12 +111,12 @@ export const erc721Mint = async ( * * @param accountAddress: address * - * @return Promise + * @return Promise */ export const erc721BalanceOf = async ( baseContract: Contract, accountAddress: string -): Promise => { +): Promise => { if (!isAddress(accountAddress)) { return { err: 'Invalid account address' }; } @@ -136,12 +136,12 @@ export const erc721BalanceOf = async ( * * @param tokenId: number * - * @return Promise + * @return Promise */ export const erc721OwnerOf = async ( baseContract: Contract, tokenId: number -): Promise => { +): Promise => { try { return { ownerOfRes: (await baseContract.ownerOf(tokenId)).toString() }; } catch (err) { @@ -163,14 +163,14 @@ export const erc721OwnerOf = async ( * * @param tokenId: number * - * @return Promise + * @return Promise */ export const erc721TokenApprove = async ( baseContract: Contract, method: 'APPROVE' | 'GET_APPROVE', spenderAddress: string, tokenId: number -): Promise => { +): Promise => { if (method === 'APPROVE' && !isAddress(spenderAddress)) { return { err: 'Invalid account address' }; } @@ -204,7 +204,7 @@ export const erc721TokenApprove = async ( * * @param approvalStatus: boolean * - * @return Promise + * @return Promise */ export const erc721TokenApproval = async ( baseContract: Contract, @@ -212,7 +212,7 @@ export const erc721TokenApproval = async ( ownerAddress: string, operatorAddress: string, approvalStatus: boolean -): Promise => { +): Promise => { if (method === 'IS_APPROVAL' && !isAddress(ownerAddress)) { return { err: 'Invalid owner address' }; } else if (!isAddress(operatorAddress)) { @@ -256,7 +256,7 @@ export const erc721TokenApproval = async ( * * @param data: string * - * @return Promise + * @return Promise */ export const erc721Transfers = async ( baseContract: Contract, @@ -265,7 +265,7 @@ export const erc721Transfers = async ( recipientAddress: string, tokenId: number, data: string -): Promise => { +): Promise => { if (!isAddress(senderAddress)) { return { err: 'Invalid sender address' }; } else if (!isAddress(recipientAddress)) { diff --git a/system-contract-dapp-playground/src/api/hedera/exchange-rate-interactions/index.ts b/system-contract-dapp-playground/src/api/hedera/exchange-rate-interactions/index.ts index e9338d0e1..6734a8efa 100644 --- a/system-contract-dapp-playground/src/api/hedera/exchange-rate-interactions/index.ts +++ b/system-contract-dapp-playground/src/api/hedera/exchange-rate-interactions/index.ts @@ -19,6 +19,7 @@ */ import { Contract } from 'ethers'; +import { ISmartContractExecutionResult } from '@/types/contract-interactions/shared'; /** * @dev handle converting tinycents to tinybars and vice versa @@ -35,14 +36,14 @@ import { Contract } from 'ethers'; * * @param gasLimit: number * - * @return Promise + * @return Promise */ export const handleExchangeRate = async ( baseContract: Contract, API: 'CENT_TO_BAR' | 'BAR_TO_CENT', amount: number, gasLimit: number -): Promise => { +): Promise => { // sanitize param if (amount < 0) { console.error('Amount to convert cannot be negative'); diff --git a/system-contract-dapp-playground/src/api/hedera/hts-interactions/tokenCreateCustom-interactions/index.ts b/system-contract-dapp-playground/src/api/hedera/hts-interactions/tokenCreateCustom-interactions/index.ts index 74ada729a..9f07d2ee9 100644 --- a/system-contract-dapp-playground/src/api/hedera/hts-interactions/tokenCreateCustom-interactions/index.ts +++ b/system-contract-dapp-playground/src/api/hedera/hts-interactions/tokenCreateCustom-interactions/index.ts @@ -23,7 +23,7 @@ import { prepareHederaTokenKeyArray, } from '@/utils/contract-interactions/HTS/helpers'; import { Contract, ethers, isAddress } from 'ethers'; -import { CommonKeyObject, SmartContractExecutionResult } from '@/types/contract-interactions/HTS'; +import { ISmartContractExecutionResult } from '@/types/contract-interactions/shared'; /** * @dev creates a Hedera fungible token @@ -48,13 +48,13 @@ import { CommonKeyObject, SmartContractExecutionResult } from '@/types/contract- * * @param treasury: string * - * @param inputKeys: CommonKeyObject[], + * @param inputKeys: ICommonKeyObject[], * * @param msgValue: string * * @param feeTokenAddress?: string * - * @return Promise + * @return Promise * * @see https://github.com/hashgraph/hedera-smart-contracts/blob/main/contracts/hts-precompile/IHederaTokenService.sol#L136 * for more information on the purposes of the params @@ -69,10 +69,10 @@ export const createHederaFungibleToken = async ( decimals: number, freezeDefaultStatus: boolean, treasury: string, - inputKeys: CommonKeyObject[], + inputKeys: ICommonKeyObject[], msgValue: string, feeTokenAddress?: string -): Promise => { +): Promise => { // sanitize params let sanitizeErr; if (initialTotalSupply < 0) { @@ -138,9 +138,7 @@ export const createHederaFungibleToken = async ( const txReceipt = await tokenCreateTx.wait(); - const { data } = txReceipt.logs.filter( - (event: any) => event.fragment.name === 'CreatedToken' - )[0]; + const { data } = txReceipt.logs.filter((event: any) => event.fragment.name === 'CreatedToken')[0]; // @notice since the returned `data` is 32 byte, convert it to the public 20-byte address standard const tokenAddress = `0x${data.slice(-40)}`; @@ -169,13 +167,13 @@ export const createHederaFungibleToken = async ( * * @param treasury: string * - * @param inputKeys: CommonKeyObject[], + * @param inputKeys: ICommonKeyObject[], * * @param msgValue: string * * @param feeTokenAddress?: string * - * @return Promise + * @return Promise * * @see https://github.com/hashgraph/hedera-smart-contracts/blob/main/contracts/hts-precompile/IHederaTokenService.sol#L136 * for more information on the purposes of the params @@ -187,10 +185,10 @@ export const createHederaNonFungibleToken = async ( memo: string, maxSupply: number, treasury: string, - inputKeys: CommonKeyObject[], + inputKeys: ICommonKeyObject[], msgValue: string, feeTokenAddress?: string -): Promise => { +): Promise => { // sanitize params let sanitizeErr; if (maxSupply < 0) { @@ -247,9 +245,7 @@ export const createHederaNonFungibleToken = async ( const txReceipt = await tokenCreateTx.wait(); - const { data } = txReceipt.logs.filter( - (event: any) => event.fragment.name === 'CreatedToken' - )[0]; + const { data } = txReceipt.logs.filter((event: any) => event.fragment.name === 'CreatedToken')[0]; // @notice since the returned `data` is 32 byte, convert it to the public 20-byte address standard const tokenAddress = `0x${data.slice(-40)}`; @@ -276,7 +272,7 @@ export const createHederaNonFungibleToken = async ( * * @param metadata: string[] * - * @return Promise + * @return Promise */ export const mintHederaToken = async ( baseContract: Contract, @@ -284,7 +280,7 @@ export const mintHederaToken = async ( hederaTokenAddress: string, amountToMint: number, metadata: string[] -): Promise => { +): Promise => { // sanitize params let sanitizeErr; if (!isAddress(hederaTokenAddress)) { @@ -305,14 +301,9 @@ export const mintHederaToken = async ( // execute .mintTokenPublic() method try { - const tx = await baseContract.mintTokenPublic( - hederaTokenAddress, - amountToMint, - bufferedMetadata, - { - gasLimit: 1_000_000, - } - ); + const tx = await baseContract.mintTokenPublic(hederaTokenAddress, amountToMint, bufferedMetadata, { + gasLimit: 1_000_000, + }); // handle contract responses return await handleContractResponse(tx); @@ -339,7 +330,7 @@ export const mintHederaToken = async ( * * @param metadata: string[] * - * @return Promise + * @return Promise */ export const mintHederaTokenToAddress = async ( baseContract: Contract, @@ -348,7 +339,7 @@ export const mintHederaTokenToAddress = async ( recipientAddress: string, amountToMint: number, metadata: string[] -): Promise => { +): Promise => { // sanitize params let sanitizeErr; if (!isAddress(hederaTokenAddress)) { @@ -412,13 +403,13 @@ export const mintHederaTokenToAddress = async ( * * @param associtingAccountAddress: string * - * @return Promise + * @return Promise */ export const associateHederaTokensToAccounts = async ( baseContract: Contract, hederaTokenAddresses: string[], associtingAccountAddress: string -): Promise => { +): Promise => { // sanitize params let sanitizeErr; if (hederaTokenAddresses.length === 0) { @@ -445,21 +436,13 @@ export const associateHederaTokensToAccounts = async ( try { let tx; if (hederaTokenAddresses.length === 1) { - tx = await baseContract.associateTokenPublic( - associtingAccountAddress, - hederaTokenAddresses[0], - { - gasLimit: 1_000_000, - } - ); + tx = await baseContract.associateTokenPublic(associtingAccountAddress, hederaTokenAddresses[0], { + gasLimit: 1_000_000, + }); } else { - tx = await baseContract.associateTokensPublic( - associtingAccountAddress, - hederaTokenAddresses, - { - gasLimit: 1_000_000, - } - ); + tx = await baseContract.associateTokensPublic(associtingAccountAddress, hederaTokenAddresses, { + gasLimit: 1_000_000, + }); } // handle contract responses @@ -481,13 +464,13 @@ export const associateHederaTokensToAccounts = async ( * * @param grantingKYCAccountAddress: string * - * @return Promise + * @return Promise */ export const grantTokenKYCToAccount = async ( baseContract: Contract, hederaTokenAddress: string, grantingKYCAccountAddress: string -): Promise => { +): Promise => { // sanitize params let sanitizeErr; if (!isAddress(hederaTokenAddress)) { @@ -502,11 +485,9 @@ export const grantTokenKYCToAccount = async ( } try { - const tx = await baseContract.grantTokenKycPublic( - hederaTokenAddress, - grantingKYCAccountAddress, - { gasLimit: 1_000_000 } - ); + const tx = await baseContract.grantTokenKycPublic(hederaTokenAddress, grantingKYCAccountAddress, { + gasLimit: 1_000_000, + }); // handle contract responses return await handleContractResponse(tx); diff --git a/system-contract-dapp-playground/src/api/hedera/hts-interactions/tokenManagement-interactions/index.ts b/system-contract-dapp-playground/src/api/hedera/hts-interactions/tokenManagement-interactions/index.ts index 0b116641e..4e7e9b818 100644 --- a/system-contract-dapp-playground/src/api/hedera/hts-interactions/tokenManagement-interactions/index.ts +++ b/system-contract-dapp-playground/src/api/hedera/hts-interactions/tokenManagement-interactions/index.ts @@ -18,17 +18,12 @@ * */ -import { - CommonKeyObject, - IHederaTokenServiceExpiry, - IHederaTokenServiceHederaToken, - SmartContractExecutionResult, -} from '@/types/contract-interactions/HTS'; +import { Contract, isAddress } from 'ethers'; +import { ISmartContractExecutionResult } from '@/types/contract-interactions/shared'; import { handleContractResponse, prepareHederaTokenKeyArray, } from '@/utils/contract-interactions/HTS/helpers'; -import { Contract, isAddress } from 'ethers'; /** * @dev manages and updates token information @@ -51,9 +46,9 @@ import { Contract, isAddress } from 'ethers'; * * @param expiryInfo?: IHederaTokenServiceExpiry * - * @param keysInfo?: CommonKeyObject[], + * @param keysInfo?: ICommonKeyObject[], * - * @return Promise + * @return Promise */ export const manageTokenInfomation = async ( baseContract: Contract, @@ -62,8 +57,8 @@ export const manageTokenInfomation = async ( gasLimit: number, tokenInfo?: IHederaTokenServiceHederaToken, expiryInfo?: IHederaTokenServiceExpiry, - keysInfo?: CommonKeyObject[] -): Promise => { + keysInfo?: ICommonKeyObject[] +): Promise => { // sanitize param if (!isAddress(hederaTokenAddress)) { console.error('Invalid token address'); @@ -79,22 +74,18 @@ export const manageTokenInfomation = async ( if (!tokenInfo) { errMsg = 'Token information object is needed for UPDATE_INFO API'; } else { - transactionResult = await baseContract.updateTokenInfoPublic( - hederaTokenAddress, - tokenInfo, - { gasLimit } - ); + transactionResult = await baseContract.updateTokenInfoPublic(hederaTokenAddress, tokenInfo, { + gasLimit, + }); } break; case 'UPDATE_EXPIRY': if (!expiryInfo) { errMsg = 'Expiry information object is needed for UPDATE_EXPIRY API'; } else { - transactionResult = await baseContract.updateTokenExpiryInfoPublic( - hederaTokenAddress, - expiryInfo, - { gasLimit } - ); + transactionResult = await baseContract.updateTokenExpiryInfoPublic(hederaTokenAddress, expiryInfo, { + gasLimit, + }); } break; case 'UPDATE_KEYS': @@ -152,7 +143,7 @@ export const manageTokenInfomation = async ( * * @param approvedStatus?: boolean (SET_APPROVAL) * - * @return Promise + * @return Promise */ export const manageTokenPermission = async ( baseContract: Contract, @@ -163,7 +154,7 @@ export const manageTokenPermission = async ( amountToApprove?: number, serialNumber?: number, approvedStatus?: boolean -): Promise => { +): Promise => { // sanitize params let sanitizeErr; if (!isAddress(hederaTokenAddress)) { @@ -241,13 +232,13 @@ export const manageTokenPermission = async ( * * @param hederaTokenAddress: string * - * @return Promise + * @return Promise */ export const manageTokenStatus = async ( baseContract: Contract, API: 'PAUSE' | 'UNPAUSE', hederaTokenAddress: string -): Promise => { +): Promise => { // sanitize param if (!isAddress(hederaTokenAddress)) { console.error('Invalid token address'); @@ -299,7 +290,7 @@ export const manageTokenStatus = async ( * * @param hederaTokenAddresses?: string[] * - * @return Promise + * @return Promise */ export const manageTokenRelation = async ( baseContract: Contract, @@ -308,7 +299,7 @@ export const manageTokenRelation = async ( gasLimit: number, hederaTokenAddress?: string, hederaTokenAddresses?: string[] -): Promise => { +): Promise => { // sanitize params let sanitizeErr; if (!isAddress(accountAddress)) { @@ -335,25 +326,19 @@ export const manageTokenRelation = async ( let transactionResult; switch (API) { case 'REVOKE_KYC': - transactionResult = await baseContract.revokeTokenKycPublic( - hederaTokenAddress, - accountAddress, - { gasLimit } - ); + transactionResult = await baseContract.revokeTokenKycPublic(hederaTokenAddress, accountAddress, { + gasLimit, + }); break; case 'FREEZE': - transactionResult = await baseContract.freezeTokenPublic( - hederaTokenAddress, - accountAddress, - { gasLimit } - ); + transactionResult = await baseContract.freezeTokenPublic(hederaTokenAddress, accountAddress, { + gasLimit, + }); break; case 'UNFREEZE': - transactionResult = await baseContract.unfreezeTokenPublic( - hederaTokenAddress, - accountAddress, - { gasLimit } - ); + transactionResult = await baseContract.unfreezeTokenPublic(hederaTokenAddress, accountAddress, { + gasLimit, + }); break; case 'DISSOCIATE_TOKEN': if (hederaTokenAddresses!.length === 1) { @@ -404,7 +389,7 @@ export const manageTokenRelation = async ( * * @param serialNumbers?: number[] * - * @return Promise + * @return Promise */ export const manageTokenDeduction = async ( baseContract: Contract, @@ -414,7 +399,7 @@ export const manageTokenDeduction = async ( accountAddress?: string, amount?: number, serialNumbers?: number[] -): Promise => { +): Promise => { // sanitize params let sanitizeErr; if (!isAddress(hederaTokenAddress)) { @@ -476,12 +461,9 @@ export const manageTokenDeduction = async ( if (!amount && (!serialNumbers || serialNumbers.length === 0)) { errMsg = 'Amount/serial number is needed for BURN API'; } else { - transactionResult = await baseContract.burnTokenPublic( - hederaTokenAddress, - amount, - serialNumbers, - { gasLimit } - ); + transactionResult = await baseContract.burnTokenPublic(hederaTokenAddress, amount, serialNumbers, { + gasLimit, + }); } break; diff --git a/system-contract-dapp-playground/src/api/hedera/hts-interactions/tokenQuery-interactions/index.ts b/system-contract-dapp-playground/src/api/hedera/hts-interactions/tokenQuery-interactions/index.ts index cd1ccb3bc..3f4ad8e4d 100644 --- a/system-contract-dapp-playground/src/api/hedera/hts-interactions/tokenQuery-interactions/index.ts +++ b/system-contract-dapp-playground/src/api/hedera/hts-interactions/tokenQuery-interactions/index.ts @@ -18,11 +18,8 @@ * */ -import { - IHederaTokenServiceKeyType, - SmartContractExecutionResult, -} from '@/types/contract-interactions/HTS'; import { Contract, isAddress } from 'ethers'; +import { ISmartContractExecutionResult } from '@/types/contract-interactions/shared'; import { KEY_TYPE_MAP } from '@/utils/contract-interactions/HTS/token-create-custom/constant'; import { convertsArgsProxyToHTSSpecificInfo, @@ -39,12 +36,12 @@ import { * * @param hederaTokenAddress: string * - * @return Promise + * @return Promise */ export const queryTokenValidity = async ( baseContract: Contract, hederaTokenAddress: string -): Promise => { +): Promise => { // sanitize param if (!isAddress(hederaTokenAddress)) { console.error('Invalid token address'); @@ -82,14 +79,14 @@ export const queryTokenValidity = async ( * * @param serialNumber?: number * - * @return Promise + * @return Promise */ export const queryTokenGeneralInfomation = async ( baseContract: Contract, API: 'TOKEN' | 'FUNGIBLE' | 'NON_FUNFIBLE', hederaTokenAddress: string, serialNumber?: number -): Promise => { +): Promise => { // sanitize param if (!isAddress(hederaTokenAddress)) { console.error('Invalid token address'); @@ -136,9 +133,7 @@ export const queryTokenGeneralInfomation = async ( const txReceipt = await transactionResult.wait(); // retrieve information from event - const { args } = txReceipt.logs.filter( - (event: any) => event.fragment.name === eventMaps[API] - )[0]; + const { args } = txReceipt.logs.filter((event: any) => event.fragment.name === eventMaps[API])[0]; return { [eventMaps[API]]: convertsArgsProxyToHTSTokenInfo(args.tokenInfo, API), @@ -173,7 +168,7 @@ export const queryTokenGeneralInfomation = async ( * * @param keyType?: IHederaTokenServiceKeyType * - * @return Promise + * @return Promise */ export const queryTokenSpecificInfomation = async ( baseContract: Contract, @@ -186,7 +181,7 @@ export const queryTokenSpecificInfomation = async ( | 'DEFAULT_FREEZE_STATUS', hederaTokenAddress: string, keyType?: IHederaTokenServiceKeyType -): Promise => { +): Promise => { // sanitize param if (!isAddress(hederaTokenAddress)) { console.error('Invalid token address'); @@ -208,9 +203,7 @@ export const queryTokenSpecificInfomation = async ( let transactionResult; switch (API) { case 'DEFAULT_FREEZE_STATUS': - transactionResult = await baseContract.getTokenDefaultFreezeStatusPublic( - hederaTokenAddress - ); + transactionResult = await baseContract.getTokenDefaultFreezeStatusPublic(hederaTokenAddress); break; case 'DEFAULT_KYC_STATUS': @@ -232,10 +225,7 @@ export const queryTokenSpecificInfomation = async ( console.error('Key Type is needed for querying NON_FUNGIBLE'); return { err: 'Key Type is needed for querying NON_FUNGIBLE' }; } else { - transactionResult = await baseContract.getTokenKeyPublic( - hederaTokenAddress, - KEY_TYPE_MAP[keyType] - ); + transactionResult = await baseContract.getTokenKeyPublic(hederaTokenAddress, KEY_TYPE_MAP[keyType]); } break; } @@ -244,9 +234,7 @@ export const queryTokenSpecificInfomation = async ( const txReceipt = await transactionResult.wait(); // retrieve information from event - const tokenInfoResult = txReceipt.logs.filter( - (event: any) => event.fragment.name === eventMaps[API] - )[0]; + const tokenInfoResult = txReceipt.logs.filter((event: any) => event.fragment.name === eventMaps[API])[0]; if (API === 'DEFAULT_FREEZE_STATUS' || API === 'DEFAULT_KYC_STATUS' || API === 'TOKEN_TYPE') { return { [eventMaps[API]]: tokenInfoResult.data, transactionHash: txReceipt.hash }; @@ -281,7 +269,7 @@ export const queryTokenSpecificInfomation = async ( * * @param serialNumber?: number * - * @return Promise + * @return Promise */ export const queryTokenPermissionInformation = async ( baseContract: Contract, @@ -290,7 +278,7 @@ export const queryTokenPermissionInformation = async ( ownerAddress?: string, spenderAddress?: string, serialNumber?: number -): Promise => { +): Promise => { // sanitize param if (!isAddress(hederaTokenAddress)) { console.error('Invalid token address'); @@ -334,10 +322,7 @@ export const queryTokenPermissionInformation = async ( if (!serialNumber) { errMsg = 'Serial number is needed for GET_APPROVED API'; } else { - transactionResult = await baseContract.getApprovedPublic( - hederaTokenAddress, - serialNumber - ); + transactionResult = await baseContract.getApprovedPublic(hederaTokenAddress, serialNumber); } break; case 'IS_APPROVAL': @@ -390,14 +375,14 @@ export const queryTokenPermissionInformation = async ( * * @param serialNumber?: number * - * @return Promise + * @return Promise */ export const queryTokenStatusInformation = async ( baseContract: Contract, API: 'IS_KYC' | 'IS_FROZEN', hederaTokenAddress: string, accountAddress: string -): Promise => { +): Promise => { // sanitize param if (!isAddress(hederaTokenAddress)) { console.error('Invalid token address'); diff --git a/system-contract-dapp-playground/src/api/hedera/hts-interactions/tokenTransfer-interactions/index.ts b/system-contract-dapp-playground/src/api/hedera/hts-interactions/tokenTransfer-interactions/index.ts index 6827643a7..6b94b2b1e 100644 --- a/system-contract-dapp-playground/src/api/hedera/hts-interactions/tokenTransfer-interactions/index.ts +++ b/system-contract-dapp-playground/src/api/hedera/hts-interactions/tokenTransfer-interactions/index.ts @@ -19,12 +19,8 @@ */ import { Contract, isAddress } from 'ethers'; -import { - IHederaTokenServiceTransferList, - IHederaTokenServiceTokenTransferList, - SmartContractExecutionResult, -} from '@/types/contract-interactions/HTS'; import { handleContractResponse } from '@/utils/contract-interactions/HTS/helpers'; +import { ISmartContractExecutionResult } from '@/types/contract-interactions/shared'; /** * @dev transfers Hedera Cryptos @@ -39,14 +35,14 @@ import { handleContractResponse } from '@/utils/contract-interactions/HTS/helper * * @param gasLimit: number * - * @return Promise + * @return Promise */ export const transferCrypto = async ( baseContract: Contract, transferList: IHederaTokenServiceTransferList, tokenTransferList: IHederaTokenServiceTokenTransferList[], gasLimit: number -): Promise => { +): Promise => { // invoking contract methods try { const tx = await baseContract.cryptoTransferPublic(transferList, tokenTransferList, { @@ -75,7 +71,7 @@ export const transferCrypto = async ( * * @param gasLimit: number * - * @return Promise Promise + * @return Promise Promise */ export const transferFungibleTokens = async ( baseContract: Contract, @@ -83,7 +79,7 @@ export const transferFungibleTokens = async ( accountIDs: string[], amounts: number[], gasLimit: number -): Promise => { +): Promise => { // sanitize params let sanitizeErr; if (!isAddress(hederaTokenAddress)) { @@ -141,7 +137,7 @@ export const transferFungibleTokens = async ( * * @param gasLimit: number * - * @return Promise + * @return Promise */ export const transferNonFungibleTokens = async ( baseContract: Contract, @@ -150,7 +146,7 @@ export const transferNonFungibleTokens = async ( receivers: string[], serialNumbers: number[], gasLimit: number -): Promise => { +): Promise => { // sanitize params let sanitizeErr; if (!isAddress(hederaTokenAddress)) { @@ -187,13 +183,9 @@ export const transferNonFungibleTokens = async ( // invoking contract methods try { - const tx = await baseContract.transferNFTsPublic( - hederaTokenAddress, - senders, - receivers, - serialNumbers, - { gasLimit } - ); + const tx = await baseContract.transferNFTsPublic(hederaTokenAddress, senders, receivers, serialNumbers, { + gasLimit, + }); return await handleContractResponse(tx); } catch (err: any) { @@ -225,7 +217,7 @@ export const transferNonFungibleTokens = async ( * * @param quantity: number (amount/serialNumber) * - * @return Promise + * @return Promise */ export const transferSingleToken = async ( baseContract: Contract, @@ -235,7 +227,7 @@ export const transferSingleToken = async ( receiver: string, quantity: number, gasLimit: number -): Promise => { +): Promise => { // sanitize params let sanitizeErr; if (!isAddress(hederaTokenAddress)) { diff --git a/system-contract-dapp-playground/src/api/hedera/ihrc-interactions/index.ts b/system-contract-dapp-playground/src/api/hedera/ihrc-interactions/index.ts index ed1fcd614..653b8965f 100644 --- a/system-contract-dapp-playground/src/api/hedera/ihrc-interactions/index.ts +++ b/system-contract-dapp-playground/src/api/hedera/ihrc-interactions/index.ts @@ -20,7 +20,7 @@ import { Contract, ethers, isAddress } from 'ethers'; import { HEDERA_SMART_CONTRACTS_ASSETS } from '@/utils/common/constants'; -import { SmartContractExecutionResult } from '@/types/contract-interactions/HTS'; +import { ISmartContractExecutionResult } from '@/types/contract-interactions/shared'; /** * @dev handle associating and/or dissociating token from an EOA @@ -35,14 +35,14 @@ import { SmartContractExecutionResult } from '@/types/contract-interactions/HTS' * * @param signer: ethers.JsonRpcSigner * - * @return Promise + * @return Promise */ export const handleIHRC719APIs = async ( API: 'ASSOCIATE' | 'DISSOCIATE', hederaTokenAddress: string, signer: ethers.JsonRpcSigner, gasLimit: number -): Promise => { +): Promise => { // sanitize params if (!isAddress(hederaTokenAddress)) { console.error('Invalid token address'); diff --git a/system-contract-dapp-playground/src/api/hedera/index.ts b/system-contract-dapp-playground/src/api/hedera/index.ts index 3e17dc8cc..e4202ef79 100644 --- a/system-contract-dapp-playground/src/api/hedera/index.ts +++ b/system-contract-dapp-playground/src/api/hedera/index.ts @@ -20,26 +20,26 @@ import { ContractFactory } from 'ethers'; import { getWalletProvider } from '../wallet'; -import { TransactionResult } from '@/types/contract-interactions/HTS'; -import { ContractABI, HederaSmartContractResult } from '@/types/common'; +import { ITransactionResult } from '@/types/contract-interactions/shared'; +import { IContractABI, IHederaSmartContractResult } from '@/types/common'; import { HEDERA_TRANSACTION_RESULT_STORAGE_KEYS } from '@/utils/common/constants'; /** * @dev deploys smart contract to Hedera network * - * @params contractABI: ContractABI + * @params contractABI: IContractABI * * @params contractBytecode: string * - * @return Promise + * @return Promise * * @resource https://github.com/ed-marquez/hedera-example-metamask-counter-dapp/blob/master/src/components/hedera/contractDeploy.js */ export const deploySmartContract = async ( - contractABI: ContractABI[], + contractABI: IContractABI[], contractBytecode: string, params: any[] -): Promise => { +): Promise => { // states const transactionResultStorageKey = HEDERA_TRANSACTION_RESULT_STORAGE_KEYS['CONTRACT-CREATE']; @@ -75,7 +75,7 @@ export const deploySmartContract = async ( // prepare create transaction result if (txReceipt) { - const createTransactionResult: TransactionResult = { + const createTransactionResult: ITransactionResult = { status: 'success', transactionResultStorageKey, transactionTimeStamp: Date.now(), diff --git a/system-contract-dapp-playground/src/api/hedera/prng-interactions/index.ts b/system-contract-dapp-playground/src/api/hedera/prng-interactions/index.ts index 23bff04f3..6e58e18d1 100644 --- a/system-contract-dapp-playground/src/api/hedera/prng-interactions/index.ts +++ b/system-contract-dapp-playground/src/api/hedera/prng-interactions/index.ts @@ -19,6 +19,7 @@ */ import { Contract } from 'ethers'; +import { ISmartContractExecutionResult } from '@/types/contract-interactions/shared'; /** * @dev handle retrieving a pseudo-random seed @@ -29,12 +30,12 @@ import { Contract } from 'ethers'; * * @param gasLimit: Number * - * @return Promise + * @return Promise */ export const handlePRGNAPI = async ( baseContract: Contract, gasLimit: Number -): Promise => { +): Promise => { try { // invoke contract method const tx = await baseContract.getPseudorandomSeed({ gasLimit }); @@ -42,9 +43,7 @@ export const handlePRGNAPI = async ( // retrieve txReceipt const txReceipt = await tx.wait(); - const { data } = txReceipt.logs.filter( - (event: any) => event.fragment.name === 'PseudoRandomSeed' - )[0]; + const { data } = txReceipt.logs.filter((event: any) => event.fragment.name === 'PseudoRandomSeed')[0]; return { transactionHash: txReceipt.hash, pseudoRandomSeed: data }; } catch (err: any) { diff --git a/system-contract-dapp-playground/src/api/mirror-node/index.ts b/system-contract-dapp-playground/src/api/mirror-node/index.ts index 8c726e4de..6e6d9edeb 100644 --- a/system-contract-dapp-playground/src/api/mirror-node/index.ts +++ b/system-contract-dapp-playground/src/api/mirror-node/index.ts @@ -20,7 +20,7 @@ import axios from 'axios'; import { HEDERA_NETWORKS } from '@/utils/common/constants'; -import { MirrorNodeResult, NetworkName } from '@/types/common'; +import { IMirrorNodeResult, TNetworkName } from '@/types/common'; /** * @dev get Hedera native account ID from EVM address @@ -33,13 +33,11 @@ import { MirrorNodeResult, NetworkName } from '@/types/common'; */ export const getHederaNativeIDFromEvmAddress = async ( evmAddress: string, - network: NetworkName, + network: TNetworkName, params: 'accounts' | 'contracts' -): Promise => { +): Promise => { try { - const accountInfo = await axios.get( - `${HEDERA_NETWORKS[network].mirrorNodeUrl}/${params}/${evmAddress}` - ); + const accountInfo = await axios.get(`${HEDERA_NETWORKS[network].mirrorNodeUrl}/${params}/${evmAddress}`); if (params === 'accounts') { return { accountId: accountInfo.data.account }; diff --git a/system-contract-dapp-playground/src/api/wallet/index.ts b/system-contract-dapp-playground/src/api/wallet/index.ts index 125a522c5..f0aad00cc 100644 --- a/system-contract-dapp-playground/src/api/wallet/index.ts +++ b/system-contract-dapp-playground/src/api/wallet/index.ts @@ -18,7 +18,7 @@ * */ -import { WalletResult } from '@/types/common'; +import { IWalletResult } from '@/types/common'; import { ethers, BrowserProvider } from 'ethers'; /** @@ -36,9 +36,9 @@ export const getWalletObject = () => { /** * @dev get ethersjs wallet provider (i.e. Metamask provider) * - * @return WalletResult + * @return IWalletResult */ -export const getWalletProvider = (): WalletResult => { +export const getWalletProvider = (): IWalletResult => { // prepare walletObject const walletObject = getWalletObject(); if (!walletObject) { @@ -57,12 +57,12 @@ export const getWalletProvider = (): WalletResult => { * * @params account: string * - * @returns Promise + * @returns Promise */ export const getBalance = async ( walletProvider: ethers.BrowserProvider, account: string -): Promise => { +): Promise => { try { const balance = await walletProvider.send('eth_getBalance', [account]); return { @@ -79,11 +79,9 @@ export const getBalance = async ( * * @params walletProvider: ethers.BrowserProvider * - * @returns Promise + * @returns Promise */ -export const getCurrentChainId = async ( - walletProvider: ethers.BrowserProvider -): Promise => { +export const getCurrentChainId = async (walletProvider: ethers.BrowserProvider): Promise => { try { const currentChainId = await walletProvider.send('eth_chainId', []); return { @@ -99,11 +97,9 @@ export const getCurrentChainId = async ( * * @params walletProvider: ethers.BrowserProvider * - * @returns Promise + * @returns Promise */ -export const requestAccount = async ( - walletProvider: ethers.BrowserProvider -): Promise => { +export const requestAccount = async (walletProvider: ethers.BrowserProvider): Promise => { try { const accounts: [string] = await walletProvider.send('eth_requestAccounts', []); return { diff --git a/system-contract-dapp-playground/src/app/activity/layout.tsx b/system-contract-dapp-playground/src/app/activity/layout.tsx index ce552ac07..1b5abdec0 100644 --- a/system-contract-dapp-playground/src/app/activity/layout.tsx +++ b/system-contract-dapp-playground/src/app/activity/layout.tsx @@ -20,16 +20,16 @@ import Footer from '@/components/footer'; import Navbar from '@/components/navbar'; -import LeftSideBar from '@/components/leftSideBar'; +import NavSideBar from '@/components/sidebar'; export default function RootLayout({ children }: { children: React.ReactNode }) { return (
- {/* */} + {/* */}
- +
{/*
*/}
{children}
diff --git a/system-contract-dapp-playground/src/app/hedera/layout.tsx b/system-contract-dapp-playground/src/app/hedera/layout.tsx index 032e415d4..0b46536c3 100644 --- a/system-contract-dapp-playground/src/app/hedera/layout.tsx +++ b/system-contract-dapp-playground/src/app/hedera/layout.tsx @@ -20,16 +20,16 @@ import Navbar from '@/components/navbar'; import Footer from '@/components/footer'; -import LeftSideBar from '@/components/leftSideBar'; +import NavSideBar from '@/components/sidebar'; export default function RootLayout({ children }: { children: React.ReactNode }) { return (
- {/* */} + {/* */}
- +
{/*
*/}
{children}
diff --git a/system-contract-dapp-playground/src/components/common/AlertDialog.tsx b/system-contract-dapp-playground/src/components/common/components/AlertDialog.tsx similarity index 100% rename from system-contract-dapp-playground/src/components/common/AlertDialog.tsx rename to system-contract-dapp-playground/src/components/common/components/AlertDialog.tsx diff --git a/system-contract-dapp-playground/src/components/common/ConfirmModal.tsx b/system-contract-dapp-playground/src/components/common/components/ConfirmModal.tsx similarity index 100% rename from system-contract-dapp-playground/src/components/common/ConfirmModal.tsx rename to system-contract-dapp-playground/src/components/common/components/ConfirmModal.tsx diff --git a/system-contract-dapp-playground/src/components/common/HederaCommonTextField.tsx b/system-contract-dapp-playground/src/components/common/components/HederaCommonTextField.tsx similarity index 100% rename from system-contract-dapp-playground/src/components/common/HederaCommonTextField.tsx rename to system-contract-dapp-playground/src/components/common/components/HederaCommonTextField.tsx diff --git a/system-contract-dapp-playground/src/components/common/MultiLineMethod.tsx b/system-contract-dapp-playground/src/components/common/components/MultiLineMethod.tsx similarity index 100% rename from system-contract-dapp-playground/src/components/common/MultiLineMethod.tsx rename to system-contract-dapp-playground/src/components/common/components/MultiLineMethod.tsx diff --git a/system-contract-dapp-playground/src/components/common/OneLineMethod.tsx b/system-contract-dapp-playground/src/components/common/components/OneLineMethod.tsx similarity index 100% rename from system-contract-dapp-playground/src/components/common/OneLineMethod.tsx rename to system-contract-dapp-playground/src/components/common/components/OneLineMethod.tsx diff --git a/system-contract-dapp-playground/src/components/contract-interaction/hts/shared/components/TransactionResultTable.tsx b/system-contract-dapp-playground/src/components/common/components/TransactionResultTable.tsx similarity index 96% rename from system-contract-dapp-playground/src/components/contract-interaction/hts/shared/components/TransactionResultTable.tsx rename to system-contract-dapp-playground/src/components/common/components/TransactionResultTable.tsx index 925adcb98..4864a2f2c 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/hts/shared/components/TransactionResultTable.tsx +++ b/system-contract-dapp-playground/src/components/common/components/TransactionResultTable.tsx @@ -23,8 +23,9 @@ import { ethers } from 'ethers'; import { FiExternalLink } from 'react-icons/fi'; import { AiOutlineMinus } from 'react-icons/ai'; import { Dispatch, SetStateAction } from 'react'; +import { copyContentToClipboard } from '../methods/common'; import { MdNavigateBefore, MdNavigateNext } from 'react-icons/md'; -import { IHederaTokenServiceKeyType, TransactionResult } from '@/types/contract-interactions/HTS'; +import { ITransactionResult } from '@/types/contract-interactions/shared'; import { HEDERA_BRANDING_COLORS, HEDERA_CHAKRA_TABLE_VARIANTS, @@ -51,14 +52,14 @@ interface TransactionResultTablePageProps { TRANSACTION_PAGE_SIZE: number; currentTransactionPage: number; transactionResultStorageKey: string; - transactionResults: TransactionResult[]; + transactionResults: ITransactionResult[]; setTokenInfoFromTxResult?: Dispatch; - paginatedTransactionResults: TransactionResult[]; + paginatedTransactionResults: ITransactionResult[]; setShowTokenInfo?: Dispatch>; setAPIMethodsFromTxResult?: Dispatch>; setCurrentTransactionPage: Dispatch>; setTokenAddressFromTxResult?: Dispatch>; - setTransactionResults: Dispatch>; + setTransactionResults: Dispatch>; setKeyTypeFromTxResult?: Dispatch>; API: | 'PRNG' @@ -163,7 +164,7 @@ export const TransactionResultTable = ({ {paginatedTransactionResults.map((transactionResult, index) => { /** @dev handle removing record */ - const handleRemoveRecord = (targetTransactionResult: TransactionResult) => { + const handleRemoveRecord = (targetTransactionResult: ITransactionResult) => { const filteredItems = transactionResults.filter( (transactionResult) => targetTransactionResult.txHash !== transactionResult.txHash ); @@ -197,7 +198,7 @@ export const TransactionResultTable = ({ {/* transaction hash */}
-
navigator.clipboard.writeText(transactionResult.txHash)}> +
copyContentToClipboard(transactionResult.txHash)}>
@@ -246,7 +247,7 @@ export const TransactionResultTable = ({ {transactionResult.tokenAddress ? (
-
navigator.clipboard.writeText(transactionResult.tokenAddress!)}> +
copyContentToClipboard(transactionResult.tokenAddress!)}>
@@ -291,9 +292,7 @@ export const TransactionResultTable = ({ {transactionResult.tokenAddresses && transactionResult.tokenAddresses.length === 1 ? (
-
navigator.clipboard.writeText(transactionResult.tokenAddresses![0])} - > +
copyContentToClipboard(transactionResult.tokenAddresses![0])}>
@@ -341,7 +340,7 @@ export const TransactionResultTable = ({ > {transactionResult.tokenAddresses?.map((token) => (
-
navigator.clipboard.writeText(token)}> +
copyContentToClipboard(token)}>
@@ -391,7 +390,7 @@ export const TransactionResultTable = ({ {transactionResult.accountAddress ? (
-
navigator.clipboard.writeText(transactionResult.accountAddress!)}> +
copyContentToClipboard(transactionResult.accountAddress!)}>
@@ -437,7 +436,7 @@ export const TransactionResultTable = ({ {API === 'TransferSingle' && (
-
navigator.clipboard.writeText(transactionResult.receiverAddress!)}> +
copyContentToClipboard(transactionResult.receiverAddress!)}>
@@ -554,9 +553,7 @@ export const TransactionResultTable = ({ {transactionResult.pseudoRandomSeed ? (
-
navigator.clipboard.writeText(transactionResult.pseudoRandomSeed!)} - > +
copyContentToClipboard(transactionResult.pseudoRandomSeed!)}>
diff --git a/system-contract-dapp-playground/src/components/contract-interaction/erc/shared/methods/common.tsx b/system-contract-dapp-playground/src/components/common/methods/common.tsx similarity index 90% rename from system-contract-dapp-playground/src/components/contract-interaction/erc/shared/methods/common.tsx rename to system-contract-dapp-playground/src/components/common/methods/common.tsx index 1d9f904c7..1affb0c46 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/erc/shared/methods/common.tsx +++ b/system-contract-dapp-playground/src/components/common/methods/common.tsx @@ -24,7 +24,7 @@ export const copyContentToClipboard = (content: string) => { }; /** @dev handle remove record */ -export const handleRemoveRecord = (targetKey: any, setMap: any, transactionResultStorageKey: string) => { +export const handleRemoveMapRecord = (targetKey: any, setMap: any, transactionResultStorageKey: string) => { setMap((prev: any) => { prev.delete(targetKey); if (prev.size === 0) { diff --git a/system-contract-dapp-playground/src/components/contract-interaction/hts/shared/methods/handleAPIErrors.tsx b/system-contract-dapp-playground/src/components/common/methods/handleAPIErrors.tsx similarity index 95% rename from system-contract-dapp-playground/src/components/contract-interaction/hts/shared/methods/handleAPIErrors.tsx rename to system-contract-dapp-playground/src/components/common/methods/handleAPIErrors.tsx index 0bc89930b..bbb756710 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/hts/shared/methods/handleAPIErrors.tsx +++ b/system-contract-dapp-playground/src/components/common/methods/handleAPIErrors.tsx @@ -20,8 +20,8 @@ import { Dispatch, SetStateAction } from 'react'; import { CommonErrorToast } from '@/components/toast/CommonToast'; +import { ITransactionResult } from '@/types/contract-interactions/shared'; import { HEDERA_COMMON_WALLET_REVERT_REASONS } from '@/utils/common/constants'; -import { IHederaTokenServiceKeyType, TransactionResult } from '@/types/contract-interactions/HTS'; /** @dev handle error returned back from invoking method APIs*/ export const handleAPIErrors = ({ @@ -53,7 +53,7 @@ export const handleAPIErrors = ({ transactionResultStorageKey: string; transactionHash: string | undefined; keyTypeCalled?: IHederaTokenServiceKeyType; - setTransactionResults: Dispatch>; + setTransactionResults: Dispatch>; }) => { const errorMessage = JSON.stringify(err); diff --git a/system-contract-dapp-playground/src/components/contract-interaction/hts/shared/methods/handleRetrievingTransactionResultsFromLocalStorage.tsx b/system-contract-dapp-playground/src/components/common/methods/handleRetrievingTransactionResultsFromLocalStorage.tsx similarity index 85% rename from system-contract-dapp-playground/src/components/contract-interaction/hts/shared/methods/handleRetrievingTransactionResultsFromLocalStorage.tsx rename to system-contract-dapp-playground/src/components/common/methods/handleRetrievingTransactionResultsFromLocalStorage.tsx index e0c0184e2..7e87155fd 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/hts/shared/methods/handleRetrievingTransactionResultsFromLocalStorage.tsx +++ b/system-contract-dapp-playground/src/components/common/methods/handleRetrievingTransactionResultsFromLocalStorage.tsx @@ -19,17 +19,17 @@ */ import { Dispatch, SetStateAction } from 'react'; -import { TRANSACTION_PAGE_SIZE } from '../states/commonStates'; import { CommonErrorToast } from '@/components/toast/CommonToast'; -import { TransactionResult } from '@/types/contract-interactions/HTS'; import { getArrayTypedValuesFromLocalStorage } from '@/api/localStorage'; +import { ITransactionResult } from '@/types/contract-interactions/shared'; import { HEDERA_COMMON_WALLET_REVERT_REASONS } from '@/utils/common/constants'; +import { TRANSACTION_PAGE_SIZE } from '../../contract-interaction/hts/shared/states/commonStates'; export const handleRetrievingTransactionResultsFromLocalStorage = ( toaster: any, transactionResultStorageKey: string, setCurrentTransactionPage: any, - setTransactionResults: Dispatch> + setTransactionResults: Dispatch> ) => { const { storageResult, err: storagedErr } = getArrayTypedValuesFromLocalStorage(transactionResultStorageKey); @@ -45,7 +45,7 @@ export const handleRetrievingTransactionResultsFromLocalStorage = ( // update states if storageResult is found if (storageResult) { - setTransactionResults(storageResult as TransactionResult[]); + setTransactionResults(storageResult as ITransactionResult[]); // set the current page to the last page so it can show the latest transactions const maxPageNum = Math.ceil(storageResult.length / TRANSACTION_PAGE_SIZE); diff --git a/system-contract-dapp-playground/src/components/contract-interaction/hts/shared/methods/handleSanitizeFormInputs.tsx b/system-contract-dapp-playground/src/components/common/methods/handleSanitizeFormInputs.tsx similarity index 99% rename from system-contract-dapp-playground/src/components/contract-interaction/hts/shared/methods/handleSanitizeFormInputs.tsx rename to system-contract-dapp-playground/src/components/common/methods/handleSanitizeFormInputs.tsx index e9fecd784..6a5ecc61e 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/hts/shared/methods/handleSanitizeFormInputs.tsx +++ b/system-contract-dapp-playground/src/components/common/methods/handleSanitizeFormInputs.tsx @@ -19,7 +19,6 @@ */ import { isAddress } from 'ethers'; -import { CommonKeyObject } from '@/types/contract-interactions/HTS'; import { isCompressedPublicKey } from '@/utils/contract-interactions/HTS/helpers'; interface ParamsProps { @@ -43,7 +42,7 @@ interface ParamsProps { serialNumbers?: number[]; receiverAddress?: string; feeTokenAddress?: string; - keys?: CommonKeyObject[]; + keys?: ICommonKeyObject[]; autoRenewPeriod?: string; autoRenewAccount?: string; tokenAddresses?: string[]; diff --git a/system-contract-dapp-playground/src/components/contract-interaction/hts/shared/methods/prepareInfoValuesToShow.tsx b/system-contract-dapp-playground/src/components/common/methods/prepareInfoValuesToShow.tsx similarity index 100% rename from system-contract-dapp-playground/src/components/contract-interaction/hts/shared/methods/prepareInfoValuesToShow.tsx rename to system-contract-dapp-playground/src/components/common/methods/prepareInfoValuesToShow.tsx diff --git a/system-contract-dapp-playground/src/components/contract-interaction/erc/deployment/ERCDeployField.tsx b/system-contract-dapp-playground/src/components/contract-interaction/erc/deployment/ERCDeployField.tsx index 448934adf..e4e8df7b8 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/erc/deployment/ERCDeployField.tsx +++ b/system-contract-dapp-playground/src/components/contract-interaction/erc/deployment/ERCDeployField.tsx @@ -22,7 +22,7 @@ import Image from 'next/image'; import { useToast } from '@chakra-ui/react'; import { Dispatch, SetStateAction, useState } from 'react'; import { CommonErrorToast } from '../../../toast/CommonToast'; -import HederaCommonTextField from '../../../common/HederaCommonTextField'; +import HederaCommonTextField from '../../../common/components/HederaCommonTextField'; interface PageProps { isDeploying: boolean; diff --git a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/balance-of/index.tsx b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/balance-of/index.tsx index 71a4fe08a..c09b0ff57 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/balance-of/index.tsx +++ b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/balance-of/index.tsx @@ -23,10 +23,10 @@ import { Contract, isAddress } from 'ethers'; import { useState, ReactNode, useCallback } from 'react'; import { balanceOf } from '@/api/hedera/erc20-interactions'; import { CommonErrorToast } from '@/components/toast/CommonToast'; -import HederaCommonTextField from '@/components/common/HederaCommonTextField'; +import HederaCommonTextField from '@/components/common/components/HederaCommonTextField'; import { useToast, TableContainer, Table, Thead, Tr, Th, Tbody } from '@chakra-ui/react'; -import useUpdateMapStateUILocalStorage from '../../../shared/hooks/useUpdateMapStateUILocalStorage'; -import useRetrieveMapValueFromLocalStorage from '../../../shared/hooks/useRetrieveMapValueFromLocalStorage'; +import useUpdateMapStateUILocalStorage from '../../../../../../hooks/useUpdateMapStateUILocalStorage'; +import useRetrieveMapValueFromLocalStorage from '../../../../../../hooks/useRetrieveMapValueFromLocalStorage'; import { HEDERA_BRANDING_COLORS, HEDERA_CHAKRA_TABLE_VARIANTS, diff --git a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/mint/index.tsx b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/mint/index.tsx index 18b5679d1..45b2ece0b 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/mint/index.tsx +++ b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/mint/index.tsx @@ -24,12 +24,12 @@ import { useEffect, useState } from 'react'; import { Contract, isAddress } from 'ethers'; import { erc20Mint } from '@/api/hedera/erc20-interactions'; import { CommonErrorToast } from '@/components/toast/CommonToast'; -import MultiLineMethod from '@/components/common/MultiLineMethod'; -import { TransactionResult } from '@/types/contract-interactions/HTS'; +import { ITransactionResult } from '@/types/contract-interactions/shared'; +import MultiLineMethod from '@/components/common/components/MultiLineMethod'; +import { handleAPIErrors } from '@/components/common/methods/handleAPIErrors'; import { mintParamFields } from '@/utils/contract-interactions/erc/erc20/constant'; +import { useUpdateTransactionResultsToLocalStorage } from '@/hooks/useUpdateLocalStorage'; import { CONTRACT_NAMES, HEDERA_TRANSACTION_RESULT_STORAGE_KEYS } from '@/utils/common/constants'; -import { handleAPIErrors } from '@/components/contract-interaction/hts/shared/methods/handleAPIErrors'; -import { useUpdateTransactionResultsToLocalStorage } from '@/components/contract-interaction/hts/shared/hooks/useUpdateLocalStorage'; interface PageProps { baseContract: Contract; @@ -40,7 +40,7 @@ const Mint = ({ baseContract }: PageProps) => { const [isLoading, setIsLoading] = useState(false); const [isSuccessful, setIsSuccessful] = useState(false); const currentContractAddress = Cookies.get(CONTRACT_NAMES.ERC20) as string; - const [transactionResults, setTransactionResults] = useState([]); + const [transactionResults, setTransactionResults] = useState([]); const transactionResultStorageKey = HEDERA_TRANSACTION_RESULT_STORAGE_KEYS['ERC20-RESULT']['TOKEN-MINT']; const [mintParams, setMintParams] = useState({ recipient: '', diff --git a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/token-information/index.tsx b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/token-information/index.tsx index 9174ec8ba..824ba3fce 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/token-information/index.tsx +++ b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/token-information/index.tsx @@ -21,8 +21,8 @@ import { useState } from 'react'; import { Contract } from 'ethers'; import { useToast } from '@chakra-ui/react'; -import OneLineMethod from '@/components/common/OneLineMethod'; import { CommonErrorToast } from '@/components/toast/CommonToast'; +import OneLineMethod from '@/components/common/components/OneLineMethod'; import { getERC20TokenInformation } from '@/api/hedera/erc20-interactions'; import { HEDERA_COMMON_WALLET_REVERT_REASONS } from '@/utils/common/constants'; diff --git a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/token-permission/index.tsx b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/token-permission/index.tsx index c195ccc9a..b807f9515 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/token-permission/index.tsx +++ b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/token-permission/index.tsx @@ -25,15 +25,15 @@ import { BiCopy } from 'react-icons/bi'; import { AiOutlineMinus } from 'react-icons/ai'; import { IoRefreshOutline } from 'react-icons/io5'; import { CommonErrorToast } from '@/components/toast/CommonToast'; -import MultiLineMethod from '@/components/common/MultiLineMethod'; import { Dispatch, SetStateAction, useEffect, useState } from 'react'; -import { TransactionResult } from '@/types/contract-interactions/HTS'; -import { copyContentToClipboard } from '../../../shared/methods/common'; import { getArrayTypedValuesFromLocalStorage } from '@/api/localStorage'; +import { ITransactionResult } from '@/types/contract-interactions/shared'; +import MultiLineMethod from '@/components/common/components/MultiLineMethod'; +import { copyContentToClipboard } from '../../../../../common/methods/common'; import { handleErc20TokenPermissions } from '@/api/hedera/erc20-interactions'; -import { handleAPIErrors } from '@/components/contract-interaction/hts/shared/methods/handleAPIErrors'; -import { useUpdateTransactionResultsToLocalStorage } from '@/components/contract-interaction/hts/shared/hooks/useUpdateLocalStorage'; -import { handleRetrievingTransactionResultsFromLocalStorage } from '@/components/contract-interaction/hts/shared/methods/handleRetrievingTransactionResultsFromLocalStorage'; +import { handleAPIErrors } from '@/components/common/methods/handleAPIErrors'; +import { useUpdateTransactionResultsToLocalStorage } from '@/hooks/useUpdateLocalStorage'; +import { handleRetrievingTransactionResultsFromLocalStorage } from '@/components/common/methods/handleRetrievingTransactionResultsFromLocalStorage'; import { HEDERA_BRANDING_COLORS, HEDERA_CHAKRA_TABLE_VARIANTS, @@ -77,7 +77,7 @@ const TokenPermission = ({ baseContract }: PageProps) => { const toaster = useToast(); const [allowances, setAllowances] = useState([]); const currentContractAddress = Cookies.get(CONTRACT_NAMES.ERC20) as string; - const [transactionResults, setTransactionResults] = useState([]); + const [transactionResults, setTransactionResults] = useState([]); const transactionResultStorageKey = HEDERA_TRANSACTION_RESULT_STORAGE_KEYS['ERC20-RESULT']['TOKEN-PERMISSION']; const allowanceStorageKey = HEDERA_TRANSACTION_RESULT_STORAGE_KEYS['ERC20-RESULT']['ALLOWANCES-RESULT']; diff --git a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/token-transfer/index.tsx b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/token-transfer/index.tsx index 987284875..d18eda674 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/token-transfer/index.tsx +++ b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-20/methods/token-transfer/index.tsx @@ -24,14 +24,14 @@ import { isAddress } from 'ethers'; import { useToast } from '@chakra-ui/react'; import { erc20Transfers } from '@/api/hedera/erc20-interactions'; import { CommonErrorToast } from '@/components/toast/CommonToast'; -import MultiLineMethod from '@/components/common/MultiLineMethod'; import { Dispatch, SetStateAction, useEffect, useState } from 'react'; -import { TransactionResult } from '@/types/contract-interactions/HTS'; import { convertCalmelCaseFunctionName } from '@/utils/common/helpers'; +import { ITransactionResult } from '@/types/contract-interactions/shared'; +import MultiLineMethod from '@/components/common/components/MultiLineMethod'; +import { handleAPIErrors } from '@/components/common/methods/handleAPIErrors'; +import { useUpdateTransactionResultsToLocalStorage } from '@/hooks/useUpdateLocalStorage'; import { CONTRACT_NAMES, HEDERA_TRANSACTION_RESULT_STORAGE_KEYS } from '@/utils/common/constants'; -import { handleAPIErrors } from '@/components/contract-interaction/hts/shared/methods/handleAPIErrors'; -import { useUpdateTransactionResultsToLocalStorage } from '@/components/contract-interaction/hts/shared/hooks/useUpdateLocalStorage'; -import { handleRetrievingTransactionResultsFromLocalStorage } from '@/components/contract-interaction/hts/shared/methods/handleRetrievingTransactionResultsFromLocalStorage'; +import { handleRetrievingTransactionResultsFromLocalStorage } from '@/components/common/methods/handleRetrievingTransactionResultsFromLocalStorage'; import { transferParamFields, transferFromParamFields, @@ -46,7 +46,7 @@ const Transfer = ({ baseContract }: PageProps) => { const transactionResultStorageKey = HEDERA_TRANSACTION_RESULT_STORAGE_KEYS['ERC20-RESULT']['TOKEN-TRANSFER']; const currentContractAddress = Cookies.get(CONTRACT_NAMES.ERC20) as string; - const [transactionResults, setTransactionResults] = useState([]); + const [transactionResults, setTransactionResults] = useState([]); const [transferParams, setTransferParams] = useState({ owner: '', diff --git a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/approve/index.tsx b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/approve/index.tsx index 124281c8c..006d328ae 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/approve/index.tsx +++ b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/approve/index.tsx @@ -22,19 +22,19 @@ import Image from 'next/image'; import Cookies from 'js-cookie'; import { Contract } from 'ethers'; import { isAddress } from 'ethers'; -import MultiLineMethod from '@/components/common/MultiLineMethod'; import { CommonErrorToast } from '@/components/toast/CommonToast'; import { ReactNode, useCallback, useEffect, useState } from 'react'; -import { TransactionResult } from '@/types/contract-interactions/HTS'; import { erc721TokenApprove } from '@/api/hedera/erc721-interactions'; -import HederaCommonTextField from '@/components/common/HederaCommonTextField'; +import { ITransactionResult } from '@/types/contract-interactions/shared'; +import MultiLineMethod from '@/components/common/components/MultiLineMethod'; +import { handleAPIErrors } from '@/components/common/methods/handleAPIErrors'; +import HederaCommonTextField from '@/components/common/components/HederaCommonTextField'; import { Th, Tr, Table, Tbody, Thead, useToast, TableContainer } from '@chakra-ui/react'; +import { useUpdateTransactionResultsToLocalStorage } from '@/hooks/useUpdateLocalStorage'; import { approveERC721ParamFields } from '@/utils/contract-interactions/erc/erc721/constant'; -import useUpdateMapStateUILocalStorage from '../../../shared/hooks/useUpdateMapStateUILocalStorage'; -import { handleAPIErrors } from '@/components/contract-interaction/hts/shared/methods/handleAPIErrors'; -import useRetrieveMapValueFromLocalStorage from '../../../shared/hooks/useRetrieveMapValueFromLocalStorage'; -import { useUpdateTransactionResultsToLocalStorage } from '@/components/contract-interaction/hts/shared/hooks/useUpdateLocalStorage'; -import { handleRetrievingTransactionResultsFromLocalStorage } from '@/components/contract-interaction/hts/shared/methods/handleRetrievingTransactionResultsFromLocalStorage'; +import useUpdateMapStateUILocalStorage from '../../../../../../hooks/useUpdateMapStateUILocalStorage'; +import useRetrieveMapValueFromLocalStorage from '../../../../../../hooks/useRetrieveMapValueFromLocalStorage'; +import { handleRetrievingTransactionResultsFromLocalStorage } from '@/components/common/methods/handleRetrievingTransactionResultsFromLocalStorage'; import { CONTRACT_NAMES, HEDERA_BRANDING_COLORS, @@ -54,7 +54,7 @@ const ERC721Approve = ({ baseContract }: PageProps) => { const [getApproveTokenId, setGetApproveTokenId] = useState(''); const currentContractAddress = Cookies.get(CONTRACT_NAMES.ERC721) as string; const [tokenSpenders, setTokenSpenders] = useState(new Map()); - const [transactionResults, setTransactionResults] = useState([]); + const [transactionResults, setTransactionResults] = useState([]); const tokenSpenderResultsStorageKey = HEDERA_TRANSACTION_RESULT_STORAGE_KEYS['ERC721-RESULT']['GET-APPROVE']; const transactionResultStorageKey = diff --git a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/balance-of/index.tsx b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/balance-of/index.tsx index 79627fe8b..0b91cf4fb 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/balance-of/index.tsx +++ b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/balance-of/index.tsx @@ -23,10 +23,10 @@ import { Contract, isAddress } from 'ethers'; import { ReactNode, useCallback, useState } from 'react'; import { CommonErrorToast } from '@/components/toast/CommonToast'; import { erc721BalanceOf } from '@/api/hedera/erc721-interactions'; -import HederaCommonTextField from '@/components/common/HederaCommonTextField'; +import HederaCommonTextField from '@/components/common/components/HederaCommonTextField'; import { Table, TableContainer, Tbody, Th, Thead, Tr, useToast } from '@chakra-ui/react'; -import useUpdateMapStateUILocalStorage from '../../../shared/hooks/useUpdateMapStateUILocalStorage'; -import useRetrieveMapValueFromLocalStorage from '../../../shared/hooks/useRetrieveMapValueFromLocalStorage'; +import useUpdateMapStateUILocalStorage from '../../../../../../hooks/useUpdateMapStateUILocalStorage'; +import useRetrieveMapValueFromLocalStorage from '../../../../../../hooks/useRetrieveMapValueFromLocalStorage'; import { HEDERA_BRANDING_COLORS, HEDERA_CHAKRA_TABLE_VARIANTS, diff --git a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/mint/index.tsx b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/mint/index.tsx index 3105ef8b4..8496cbc65 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/mint/index.tsx +++ b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/mint/index.tsx @@ -24,12 +24,12 @@ import { useEffect, useState } from 'react'; import { Contract, isAddress } from 'ethers'; import { erc721Mint } from '@/api/hedera/erc721-interactions'; import { CommonErrorToast } from '@/components/toast/CommonToast'; -import MultiLineMethod from '@/components/common/MultiLineMethod'; -import { TransactionResult } from '@/types/contract-interactions/HTS'; -import { CONTRACT_NAMES, HEDERA_TRANSACTION_RESULT_STORAGE_KEYS } from '@/utils/common/constants'; +import { ITransactionResult } from '@/types/contract-interactions/shared'; +import MultiLineMethod from '@/components/common/components/MultiLineMethod'; +import { handleAPIErrors } from '@/components/common/methods/handleAPIErrors'; import { mintParamFields } from '@/utils/contract-interactions/erc/erc721/constant'; -import { handleAPIErrors } from '@/components/contract-interaction/hts/shared/methods/handleAPIErrors'; -import { useUpdateTransactionResultsToLocalStorage } from '@/components/contract-interaction/hts/shared/hooks/useUpdateLocalStorage'; +import { CONTRACT_NAMES, HEDERA_TRANSACTION_RESULT_STORAGE_KEYS } from '@/utils/common/constants'; +import { useUpdateTransactionResultsToLocalStorage } from '@/hooks/useUpdateLocalStorage'; interface PageProps { baseContract: Contract; @@ -40,7 +40,7 @@ const Mint = ({ baseContract }: PageProps) => { const [isLoading, setIsLoading] = useState(false); const [isSuccessful, setIsSuccessful] = useState(false); const currentContractAddress = Cookies.get(CONTRACT_NAMES.ERC721) as string; - const [transactionResults, setTransactionResults] = useState([]); + const [transactionResults, setTransactionResults] = useState([]); const transactionResultStorageKey = HEDERA_TRANSACTION_RESULT_STORAGE_KEYS['ERC721-RESULT']['TOKEN-MINT']; const [mintParams, setMintParams] = useState({ recipient: '', diff --git a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/operator-approve/index.tsx b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/operator-approve/index.tsx index 770577446..78831bfc1 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/operator-approve/index.tsx +++ b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/operator-approve/index.tsx @@ -26,15 +26,15 @@ import { useEffect, useState } from 'react'; import { AiOutlineMinus } from 'react-icons/ai'; import { IoRefreshOutline } from 'react-icons/io5'; import { CommonErrorToast } from '@/components/toast/CommonToast'; -import MultiLineMethod from '@/components/common/MultiLineMethod'; -import { TransactionResult } from '@/types/contract-interactions/HTS'; +import { ITransactionResult } from '@/types/contract-interactions/shared'; import { erc721TokenApproval } from '@/api/hedera/erc721-interactions'; -import { copyContentToClipboard } from '../../../shared/methods/common'; +import { copyContentToClipboard } from '../../../../../common/methods/common'; import { getArrayTypedValuesFromLocalStorage } from '@/api/localStorage'; +import MultiLineMethod from '@/components/common/components/MultiLineMethod'; +import { handleAPIErrors } from '@/components/common/methods/handleAPIErrors'; +import { useUpdateTransactionResultsToLocalStorage } from '@/hooks/useUpdateLocalStorage'; import { isApprovalERC721ParamFields } from '@/utils/contract-interactions/erc/erc721/constant'; -import { handleAPIErrors } from '@/components/contract-interaction/hts/shared/methods/handleAPIErrors'; -import { useUpdateTransactionResultsToLocalStorage } from '@/components/contract-interaction/hts/shared/hooks/useUpdateLocalStorage'; -import { handleRetrievingTransactionResultsFromLocalStorage } from '@/components/contract-interaction/hts/shared/methods/handleRetrievingTransactionResultsFromLocalStorage'; +import { handleRetrievingTransactionResultsFromLocalStorage } from '@/components/common/methods/handleRetrievingTransactionResultsFromLocalStorage'; import { Td, Th, @@ -79,7 +79,7 @@ const ERC721OperatorApproval = ({ baseContract }: PageProps) => { const [successStatus, setSuccessStatus] = useState(false); const currentContractAddress = Cookies.get(CONTRACT_NAMES.ERC721) as string; const [approvalRecords, setApprovalRecords] = useState([]); - const [transactionResults, setTransactionResults] = useState([]); + const [transactionResults, setTransactionResults] = useState([]); const approvalStatusStorageKey = HEDERA_TRANSACTION_RESULT_STORAGE_KEYS['ERC721-RESULT']['GET-APPROVAL']; const transactionResultStorageKey = HEDERA_TRANSACTION_RESULT_STORAGE_KEYS['ERC721-RESULT']['SET-APPROVAL']; const [isLoading, setIsLoading] = useState({ diff --git a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/owner-of/index.tsx b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/owner-of/index.tsx index f62016a59..4dbe651aa 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/owner-of/index.tsx +++ b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/owner-of/index.tsx @@ -23,10 +23,10 @@ import { Contract } from 'ethers'; import { ReactNode, useCallback, useState } from 'react'; import { erc721OwnerOf } from '@/api/hedera/erc721-interactions'; import { CommonErrorToast } from '@/components/toast/CommonToast'; -import HederaCommonTextField from '@/components/common/HederaCommonTextField'; +import HederaCommonTextField from '@/components/common/components/HederaCommonTextField'; import { Table, TableContainer, Tbody, Th, Thead, Tr, useToast } from '@chakra-ui/react'; -import useUpdateMapStateUILocalStorage from '../../../shared/hooks/useUpdateMapStateUILocalStorage'; -import useRetrieveMapValueFromLocalStorage from '../../../shared/hooks/useRetrieveMapValueFromLocalStorage'; +import useUpdateMapStateUILocalStorage from '../../../../../../hooks/useUpdateMapStateUILocalStorage'; +import useRetrieveMapValueFromLocalStorage from '../../../../../../hooks/useRetrieveMapValueFromLocalStorage'; import { HEDERA_BRANDING_COLORS, HEDERA_CHAKRA_TABLE_VARIANTS, diff --git a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/token-information/index.tsx b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/token-information/index.tsx index 6697caa48..c482add07 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/token-information/index.tsx +++ b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/token-information/index.tsx @@ -21,8 +21,8 @@ import { useState } from 'react'; import { Contract } from 'ethers'; import { useToast } from '@chakra-ui/react'; -import OneLineMethod from '@/components/common/OneLineMethod'; import { CommonErrorToast } from '@/components/toast/CommonToast'; +import OneLineMethod from '@/components/common/components/OneLineMethod'; import { getERC721TokenInformation } from '@/api/hedera/erc721-interactions'; import { HEDERA_COMMON_WALLET_REVERT_REASONS } from '@/utils/common/constants'; diff --git a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/token-transfer/index.tsx b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/token-transfer/index.tsx index e7b63a950..94fac5423 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/token-transfer/index.tsx +++ b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/token-transfer/index.tsx @@ -24,14 +24,14 @@ import { isAddress } from 'ethers'; import { useToast } from '@chakra-ui/react'; import { useEffect, useState } from 'react'; import { CommonErrorToast } from '@/components/toast/CommonToast'; -import MultiLineMethod from '@/components/common/MultiLineMethod'; import { erc721Transfers } from '@/api/hedera/erc721-interactions'; -import { TransactionResult } from '@/types/contract-interactions/HTS'; +import { ITransactionResult } from '@/types/contract-interactions/shared'; import { convertCalmelCaseFunctionName } from '@/utils/common/helpers'; +import MultiLineMethod from '@/components/common/components/MultiLineMethod'; +import { handleAPIErrors } from '@/components/common/methods/handleAPIErrors'; +import { useUpdateTransactionResultsToLocalStorage } from '@/hooks/useUpdateLocalStorage'; import { CONTRACT_NAMES, HEDERA_TRANSACTION_RESULT_STORAGE_KEYS } from '@/utils/common/constants'; -import { handleAPIErrors } from '@/components/contract-interaction/hts/shared/methods/handleAPIErrors'; -import { useUpdateTransactionResultsToLocalStorage } from '@/components/contract-interaction/hts/shared/hooks/useUpdateLocalStorage'; -import { handleRetrievingTransactionResultsFromLocalStorage } from '@/components/contract-interaction/hts/shared/methods/handleRetrievingTransactionResultsFromLocalStorage'; +import { handleRetrievingTransactionResultsFromLocalStorage } from '@/components/common/methods/handleRetrievingTransactionResultsFromLocalStorage'; import { transferFromERC721ParamFields, safeTransferFromERC721ParamFields, @@ -46,7 +46,7 @@ const ERC721Transfer = ({ baseContract }: PageProps) => { const transactionResultStorageKey = HEDERA_TRANSACTION_RESULT_STORAGE_KEYS['ERC721-RESULT']['TOKEN-TRANSFER']; const currentContractAddress = Cookies.get(CONTRACT_NAMES.ERC721) as string; - const [transactionResults, setTransactionResults] = useState([]); + const [transactionResults, setTransactionResults] = useState([]); const [transferFromParams, setTransferFromParams] = useState({ sender: '', diff --git a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/token-uri/index.tsx b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/token-uri/index.tsx index 668f00d76..06bb08d4b 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/token-uri/index.tsx +++ b/system-contract-dapp-playground/src/components/contract-interaction/erc/erc-721/methods/token-uri/index.tsx @@ -23,10 +23,10 @@ import { Contract } from 'ethers'; import { ReactNode, useCallback, useState } from 'react'; import { CommonErrorToast } from '@/components/toast/CommonToast'; import { erc721TokenURI } from '@/api/hedera/erc721-interactions'; -import HederaCommonTextField from '@/components/common/HederaCommonTextField'; +import HederaCommonTextField from '@/components/common/components/HederaCommonTextField'; import { Table, TableContainer, Tbody, Th, Thead, Tr, useToast } from '@chakra-ui/react'; -import useUpdateMapStateUILocalStorage from '../../../shared/hooks/useUpdateMapStateUILocalStorage'; -import useRetrieveMapValueFromLocalStorage from '../../../shared/hooks/useRetrieveMapValueFromLocalStorage'; +import useUpdateMapStateUILocalStorage from '../../../../../../hooks/useUpdateMapStateUILocalStorage'; +import useRetrieveMapValueFromLocalStorage from '../../../../../../hooks/useRetrieveMapValueFromLocalStorage'; import { HEDERA_BRANDING_COLORS, HEDERA_CHAKRA_TABLE_VARIANTS, diff --git a/system-contract-dapp-playground/src/components/contract-interaction/exchange-rate/deployment/ExchangeRateDeployField.tsx b/system-contract-dapp-playground/src/components/contract-interaction/exchange-rate/deployment/ExchangeRateDeployField.tsx index 6a5759175..3c3e70ed0 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/exchange-rate/deployment/ExchangeRateDeployField.tsx +++ b/system-contract-dapp-playground/src/components/contract-interaction/exchange-rate/deployment/ExchangeRateDeployField.tsx @@ -22,7 +22,7 @@ import Image from 'next/image'; import { useToast } from '@chakra-ui/react'; import { Dispatch, SetStateAction, useState } from 'react'; import { CommonErrorToast } from '../../../toast/CommonToast'; -import HederaCommonTextField from '../../../common/HederaCommonTextField'; +import HederaCommonTextField from '../../../common/components/HederaCommonTextField'; interface PageProps { isDeploying: boolean; @@ -30,11 +30,7 @@ interface PageProps { setDidDeployStart: Dispatch>; } -const ExchangeRateDeployField = ({ - isDeploying, - setDidDeployStart, - setDeployedParams, -}: PageProps) => { +const ExchangeRateDeployField = ({ isDeploying, setDidDeployStart, setDeployedParams }: PageProps) => { const toaster = useToast(); const [value, setValue] = useState(''); diff --git a/system-contract-dapp-playground/src/components/contract-interaction/exchange-rate/methods/index.tsx b/system-contract-dapp-playground/src/components/contract-interaction/exchange-rate/methods/index.tsx index 7e1bae6f7..be3fdb4ca 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/exchange-rate/methods/index.tsx +++ b/system-contract-dapp-playground/src/components/contract-interaction/exchange-rate/methods/index.tsx @@ -23,18 +23,18 @@ import { Contract } from 'ethers'; import { useToast } from '@chakra-ui/react'; import { useEffect, useState } from 'react'; import { CommonErrorToast } from '@/components/toast/CommonToast'; -import { TransactionResult } from '@/types/contract-interactions/HTS'; -import { handleAPIErrors } from '../../hts/shared/methods/handleAPIErrors'; +import { ITransactionResult } from '@/types/contract-interactions/shared'; +import { handleAPIErrors } from '../../../common/methods/handleAPIErrors'; +import { useToastSuccessful } from '../../../../hooks/useToastSuccessful'; import { handleExchangeRate } from '@/api/hedera/exchange-rate-interactions'; import { TRANSACTION_PAGE_SIZE } from '../../hts/shared/states/commonStates'; -import { useToastSuccessful } from '../../hts/shared/hooks/useToastSuccessful'; -import { usePaginatedTxResults } from '../../hts/shared/hooks/usePaginatedTxResults'; -import { TransactionResultTable } from '../../hts/shared/components/TransactionResultTable'; -import { handleSanitizeHederaFormInputs } from '../../hts/shared/methods/handleSanitizeFormInputs'; +import { usePaginatedTxResults } from '../../../../hooks/usePaginatedTxResults'; +import { TransactionResultTable } from '../../../common/components/TransactionResultTable'; +import { handleSanitizeHederaFormInputs } from '../../../common/methods/handleSanitizeFormInputs'; +import { useUpdateTransactionResultsToLocalStorage } from '../../../../hooks/useUpdateLocalStorage'; import { SharedExecuteButton, SharedFormInputField } from '../../hts/shared/components/ParamInputForm'; -import { useUpdateTransactionResultsToLocalStorage } from '../../hts/shared/hooks/useUpdateLocalStorage'; -import useFilterTransactionsByContractAddress from '../../hts/shared/hooks/useFilterTransactionsByContractAddress'; -import { handleRetrievingTransactionResultsFromLocalStorage } from '../../hts/shared/methods/handleRetrievingTransactionResultsFromLocalStorage'; +import useFilterTransactionsByContractAddress from '../../../../hooks/useFilterTransactionsByContractAddress'; +import { handleRetrievingTransactionResultsFromLocalStorage } from '../../../common/methods/handleRetrievingTransactionResultsFromLocalStorage'; import { CONTRACT_NAMES, HEDERA_BRANDING_COLORS, @@ -58,7 +58,7 @@ const HederaExchangeRateMethods = ({ baseContract }: PageProps) => { const hederaNetwork = JSON.parse(Cookies.get('_network') as string); const [currentTransactionPage, setCurrentTransactionPage] = useState(1); const currentContractAddress = Cookies.get(CONTRACT_NAMES.EXCHANGE_RATE) as string; - const [transactionResults, setTransactionResults] = useState([]); + const [transactionResults, setTransactionResults] = useState([]); const transactionResultStorageKey = HEDERA_TRANSACTION_RESULT_STORAGE_KEYS['EXCHANGE-RATE-RESULT']['EXCHANGE-RATE']; const [isLoading, setIsLoading] = useState({ diff --git a/system-contract-dapp-playground/src/components/contract-interaction/hts/shared/components/SigningKeysForm.tsx b/system-contract-dapp-playground/src/components/contract-interaction/hts/shared/components/SigningKeysForm.tsx index b538da94c..fb200a2ad 100644 --- a/system-contract-dapp-playground/src/components/contract-interaction/hts/shared/components/SigningKeysForm.tsx +++ b/system-contract-dapp-playground/src/components/contract-interaction/hts/shared/components/SigningKeysForm.tsx @@ -28,11 +28,6 @@ import { HEDERA_CHAKRA_INPUT_BOX_SIZES, HEDERA_CHAKRA_INPUT_BOX_SHARED_CLASSNAME, } from '@/utils/common/constants'; -import { - CommonKeyObject, - IHederaTokenServiceKeyType, - IHederaTokenServiceKeyValueType, -} from '@/types/contract-interactions/HTS'; import { handleUpdateKeyValue, handleKeyTypeOnChange, @@ -43,11 +38,11 @@ import { /** @dev shared component presenting signing keys*/ interface SigningKeyPageProps { buttonTitle: string; - keys: CommonKeyObject[]; + keys: ICommonKeyObject[]; chosenKeys: Set; keyTypesToShow: Set; HederaTokenKeyTypes: IHederaTokenServiceKeyType[]; - setKeys: Dispatch>; + setKeys: Dispatch>; HederaTokenKeyValueType: IHederaTokenServiceKeyValueType[]; setChosenKeys: Dispatch>>; setKeyTypesToShow: Dispatch>>; @@ -70,11 +65,7 @@ export const SharedSigningKeysComponent = ({ {/* Add more key */}
{keys.length < 7 && ( - +