Skip to content

Commit

Permalink
feat: added TokenManagementContract to the main layout (#363)
Browse files Browse the repository at this point in the history
* dapp-feat: added TokenManagementContract to the main layout

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

* dapp-update: added gasLimit to ManageTokenInfo API methods

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

* dapp-feat: added SharedExecuteButtonWithFeePageProps button

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

---------

Signed-off-by: Logan Nguyen <[email protected]>
  • Loading branch information
quiet-node authored Sep 1, 2023
1 parent 62fbe99 commit b6fc10f
Show file tree
Hide file tree
Showing 11 changed files with 238 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ import { Contract } from 'ethers';
describe('TokenManagementContract test suite', () => {
// mock states
const responseCode = 22;
const gasLimnit = 1000000;
const AUTO_RENEW_SECOND = 0;
const AUTO_RENEW_PERIOD = 8000000;
const NEW_AUTO_RENEW_PERIOD = 7999900;
const accountAddress = '0x34810E139b451e0a4c67d5743E956Ac8990842A8';
const contractId = '0xDd7fCb7c2ee96A79B1e201d25F5E43d6a0cED5e6';
Expand Down Expand Up @@ -146,6 +146,7 @@ describe('TokenManagementContract test suite', () => {
baseContract as unknown as Contract,
'UPDATE_INFO',
hederaTokenAddress,
gasLimnit,
tokenInfo
);

Expand All @@ -159,6 +160,7 @@ describe('TokenManagementContract test suite', () => {
baseContract as unknown as Contract,
'UPDATE_INFO',
hederaTokenAddress,
gasLimnit,
undefined
);

Expand All @@ -172,6 +174,7 @@ describe('TokenManagementContract test suite', () => {
baseContract as unknown as Contract,
'UPDATE_EXPIRY',
hederaTokenAddress,
gasLimnit,
undefined,
tokenExpiry
);
Expand All @@ -186,6 +189,7 @@ describe('TokenManagementContract test suite', () => {
baseContract as unknown as Contract,
'UPDATE_EXPIRY',
hederaTokenAddress,
gasLimnit,
undefined,
undefined
);
Expand All @@ -200,6 +204,7 @@ describe('TokenManagementContract test suite', () => {
baseContract as unknown as Contract,
'UPDATE_KEYS',
hederaTokenAddress,
gasLimnit,
undefined,
undefined,
tokenKeys
Expand All @@ -215,6 +220,7 @@ describe('TokenManagementContract test suite', () => {
baseContract as unknown as Contract,
'UPDATE_KEYS',
hederaTokenAddress,
gasLimnit,
undefined,
undefined,
undefined
Expand All @@ -230,6 +236,7 @@ describe('TokenManagementContract test suite', () => {
baseContract as unknown as Contract,
'UPDATE_KEYS',
'0xabc',
gasLimnit,
undefined,
undefined,
tokenKeys
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export const manageTokenInfomation = async (
baseContract: Contract,
API: 'UPDATE_INFO' | 'UPDATE_EXPIRY' | 'UPDATE_KEYS',
hederaTokenAddress: string,
gasLimit: number,
tokenInfo?: IHederaTokenServiceHederaToken,
expiryInfo?: IHederaTokenServiceExpiry,
keysInfo?: CommonKeyObject[]
Expand All @@ -78,7 +79,8 @@ export const manageTokenInfomation = async (
} else {
transactionResult = await baseContract.updateTokenInfoPublic(
hederaTokenAddress,
tokenInfo
tokenInfo,
{ gasLimit }
);
}
break;
Expand All @@ -88,7 +90,8 @@ export const manageTokenInfomation = async (
} else {
transactionResult = await baseContract.updateTokenExpiryInfoPublic(
hederaTokenAddress,
expiryInfo
expiryInfo,
{ gasLimit }
);
}
break;
Expand All @@ -107,7 +110,8 @@ export const manageTokenInfomation = async (

transactionResult = await baseContract.updateTokenKeysPublic(
hederaTokenAddress,
hederaTokenKeys
hederaTokenKeys,
{ gasLimit }
);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -139,39 +139,64 @@ export const SharedExecuteButton = ({
);
};

/** @dev shared execute button with service fee component */
interface SharedExecuteButtonWithServiceFeePageProps {
/** @dev shared remove fields button */
interface SharedRemoveFieldButtonPageProps {
fieldKey: string;
handleModifyTokenAddresses: any;
}
export const SharedRemoveFieldsButton = ({
fieldKey,
handleModifyTokenAddresses,
}: SharedRemoveFieldButtonPageProps) => {
return (
<Tooltip label="delete this record" placement="top">
<button
onClick={() => handleModifyTokenAddresses('REMOVE', fieldKey)}
className={`border h-fit border-white/30 text-base px-1 py-1 rounded-lg flex items-center justify-center cursor-pointer hover:bg-red-400 transition duration-300`}
>
<AiOutlineMinus />
</button>
</Tooltip>
);
};

/** @dev shared execute button with fee component */
interface SharedExecuteButtonWithFeePageProps {
isLoading: boolean;
paramValues: string;
explanation: string;
placeHolder: string;
executeBtnTitle: string;
handleCreatingFungibleToken: () => Promise<void>;
feeType: 'SERVICE' | 'GAS';
handleInvokingAPIMethod: () => Promise<void>;
handleInputOnChange: (e: any, param: string) => void;
}

export const SharedExecuteButtonWithServiceFee = ({
export const SharedExecuteButtonWithFee = ({
feeType,
isLoading,
paramValues,
explanation,
placeHolder,
executeBtnTitle,
handleInputOnChange,
handleCreatingFungibleToken,
}: SharedExecuteButtonWithServiceFeePageProps) => {
handleInvokingAPIMethod,
}: SharedExecuteButtonWithFeePageProps) => {
return (
<div className="flex flex-col gap-1">
<div className="flex items-center gap-6">
{/* Service Fee */}
<div className="w-3/12">
<SharedFormInputField
param={'msgValue'}
param={'feeValue'}
paramValue={paramValues}
handleInputOnChange={handleInputOnChange}
paramSize={'lg'}
paramType={'number'}
paramKey={'msgValue'}
explanation={
'Represents the fee in HBAR directly paid to the contract system of the Hedera Token Service'
}
paramKey={'feeValue'}
explanation={explanation}
paramClassName={'border-white/30 rounded-xl'}
paramPlaceholder={'Service fee...'}
paramPlaceholder={placeHolder}
paramFocusColor={'#A98DF4'}
/>
</div>
Expand All @@ -180,43 +205,24 @@ export const SharedExecuteButtonWithServiceFee = ({
<SharedExecuteButton
isLoading={isLoading}
buttonTitle={executeBtnTitle}
handleCreatingFungibleToken={handleCreatingFungibleToken}
handleCreatingFungibleToken={handleInvokingAPIMethod}
/>
</div>
</div>
<p className="text-sm whitespace-normal">
<span className="italic font-medium text-sm">*Important:</span> Varying configurations
applied to the token will result in varying service fees. Be sure to utilize the{' '}
<Link
className="underline text-hedera-green font-medium whitespace-nowrap"
href={'https://hedera.com/fees'}
target="_blank"
>
Hedera service fee calculator
</Link>{' '}
for precise estimation of the applicable fee, as this fee is non-refundable.
</p>
{feeType === 'SERVICE' && (
<p className="text-sm whitespace-normal">
<span className="italic font-medium text-sm">*Important:</span> Varying configurations
applied to the token will result in varying service fees. Be sure to utilize the{' '}
<Link
className="underline text-hedera-green font-medium whitespace-nowrap"
href={'https://hedera.com/fees'}
target="_blank"
>
Hedera service fee calculator
</Link>{' '}
for precise estimation of the applicable fee, as this fee is non-refundable.
</p>
)}
</div>
);
};

/** @dev shared remove fields button */
interface SharedRemoveFieldButtonPageProps {
fieldKey: string;
handleModifyTokenAddresses: any;
}
export const SharedRemoveFieldsButton = ({
fieldKey,
handleModifyTokenAddresses,
}: SharedRemoveFieldButtonPageProps) => {
return (
<Tooltip label="delete this record" placement="top">
<button
onClick={() => handleModifyTokenAddresses('REMOVE', fieldKey)}
className={`border h-fit border-white/30 text-base px-1 py-1 rounded-lg flex items-center justify-center cursor-pointer hover:bg-red-400 transition duration-300`}
>
<AiOutlineMinus />
</button>
</Tooltip>
);
};
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import {

/** @dev shared component presenting signing keys*/
interface SigningKeyPageProps {
buttonTitle: string;
keys: CommonKeyObject[];
chosenKeys: Set<IHederaTokenServiceKeyType>;
keyTypesToShow: Set<IHederaTokenServiceKeyType>;
Expand All @@ -51,6 +52,7 @@ export const SharedSigningKeysComponent = ({
keys,
setKeys,
chosenKeys,
buttonTitle,
setChosenKeys,
keyTypesToShow,
setKeyTypesToShow,
Expand Down Expand Up @@ -81,7 +83,7 @@ export const SharedSigningKeysComponent = ({
}
className="w-full rounded border border-white/30 text-center text-sm hover:border-hedera-purple hover:text-hedera-purple transition duration-300 hover:cursor-pointer "
>
{keys.length === 0 ? `Add signing keys to the token` : '+'}
{keys.length === 0 ? buttonTitle : '+'}
</button>
</Tooltip>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import { handleRetrievingTransactionResultsFromLocalStorage } from '../../shared
import {
SharedFormInputField,
SharedFormButton,
SharedExecuteButtonWithServiceFee,
SharedExecuteButtonWithFee,
} from '../../shared/components/ParamInputForm';
import {
CommonKeyObject,
Expand Down Expand Up @@ -74,7 +74,7 @@ const FungibleTokenCreate = ({ baseContract }: PageProps) => {
memo: '',
name: '',
symbol: '',
msgValue: '',
feeValue: '',
treasury: '',
decimals: '',
maxSupply: '',
Expand Down Expand Up @@ -117,7 +117,7 @@ const FungibleTokenCreate = ({ baseContract }: PageProps) => {
name,
symbol,
treasury,
msgValue,
feeValue,
decimals,
maxSupply,
initSupply,
Expand All @@ -131,7 +131,7 @@ const FungibleTokenCreate = ({ baseContract }: PageProps) => {
name,
keys,
symbol,
msgValue,
feeValue,
decimals,
treasury,
maxSupply,
Expand Down Expand Up @@ -161,7 +161,7 @@ const FungibleTokenCreate = ({ baseContract }: PageProps) => {
freezeStatus,
treasury,
keys,
msgValue,
feeValue,
withCustomFee ? feeTokenAddress : undefined
);

Expand Down Expand Up @@ -341,16 +341,22 @@ const FungibleTokenCreate = ({ baseContract }: PageProps) => {
keyTypesToShow={keyTypesToShow}
setKeyTypesToShow={setKeyTypesToShow}
HederaTokenKeyTypes={HederaTokenKeyTypes}
buttonTitle="Add signing keys to the token"
HederaTokenKeyValueType={HederaTokenKeyValueType}
/>

{/* Service Fee & Execute button */}
<SharedExecuteButtonWithServiceFee
<SharedExecuteButtonWithFee
isLoading={isLoading}
paramValues={paramValues['msgValue']}
feeType={'SERVICE'}
paramValues={paramValues.feeValue}
placeHolder={'Service fee...'}
executeBtnTitle={'Create Fungible Token'}
handleInputOnChange={handleInputOnChange}
handleCreatingFungibleToken={handleCreatingFungibleToken}
explanation={
'Represents the fee in HBAR directly paid to the contract system of the Hedera Token Service'
}
handleInvokingAPIMethod={handleCreatingFungibleToken}
/>
</div>

Expand Down
Loading

0 comments on commit b6fc10f

Please sign in to comment.