-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* dapp-feat: added TokenTransferContract to the main layout Signed-off-by: Logan Nguyen <[email protected]> * dapp-update: added gasLimist to to transferCrypto API method Signed-off-by: Logan Nguyen <[email protected]> * dapp-feat: added helper functions and form components for CryptoTransfer master component Signed-off-by: Logan Nguyen <[email protected]> * dapp-update: updated util component for new CryptoTransfer API Signed-off-by: Logan Nguyen <[email protected]> * dapp-feat: CryptoTransfer feature complete (#319) Signed-off-by: Logan Nguyen <[email protected]> * dapp-update: added guard condition to hide `cryptoTransfer` method if the network !== "localnet" Signed-off-by: Logan Nguyen <[email protected]> * dapp-update: added guard condition to hide `cryptoTransfer` method if the network !== "localnet" Signed-off-by: Logan Nguyen <[email protected]> * dapp-update: updated TokenTransferContract's method tabs' names Signed-off-by: Logan Nguyen <[email protected]> --------- Signed-off-by: Logan Nguyen <[email protected]>
- Loading branch information
1 parent
28ffb5e
commit 3457154
Showing
16 changed files
with
1,414 additions
and
151 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
...d/src/components/contract-interaction/hts/shared/components/CryptoTransferInputFields.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/*- | ||
* | ||
* Hedera Smart Contracts | ||
* | ||
* Copyright (C) 2023 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
import { Tooltip, Select } from '@chakra-ui/react'; | ||
import { SharedFormInputField, SharedRemoveFieldsButton } from './ParamInputForm'; | ||
import { htsCryptoTransferParamFields } from '@/utils/contract-interactions/HTS/token-transfer/paramFieldConstant'; | ||
|
||
interface PageProps { | ||
mode: 'CRYPTO' | 'TOKEN'; | ||
paramValue: any; | ||
masterTokenParam?: any; | ||
handleModifyRecords: any; | ||
setCryptoTransferParamValues?: any; | ||
handleTokenTransferInputOnChange?: any; | ||
handleCryptoTransferInputOnChange?: any; | ||
} | ||
|
||
const CryptoTransferInputFields = ({ | ||
mode, | ||
paramValue, | ||
masterTokenParam, | ||
handleModifyRecords, | ||
setCryptoTransferParamValues, | ||
handleTokenTransferInputOnChange, | ||
handleCryptoTransferInputOnChange, | ||
}: PageProps) => { | ||
return ( | ||
<div key={paramValue.fieldKey} className="flex gap-6 items-center w-full"> | ||
{/* account ID & amount */} | ||
{(['accountID', 'amount'] as ('accountID' | 'amount')[]).map((paramKey) => ( | ||
<SharedFormInputField | ||
key={paramKey} | ||
param={htsCryptoTransferParamFields[paramKey].paramKey} | ||
paramValue={paramValue.fieldValue[paramKey]} | ||
paramKey={htsCryptoTransferParamFields[paramKey].paramKey} | ||
paramType={htsCryptoTransferParamFields[paramKey].inputType} | ||
paramSize={htsCryptoTransferParamFields[paramKey].inputSize} | ||
explanation={htsCryptoTransferParamFields[paramKey].explanation} | ||
paramClassName={htsCryptoTransferParamFields[paramKey].inputClassname} | ||
paramPlaceholder={htsCryptoTransferParamFields[paramKey].inputPlaceholder} | ||
paramFocusColor={htsCryptoTransferParamFields[paramKey].inputFocusBorderColor} | ||
handleInputOnChange={(e) => { | ||
if (mode === 'TOKEN') { | ||
handleTokenTransferInputOnChange( | ||
e, | ||
masterTokenParam.fieldKey, | ||
paramValue.fieldKey, | ||
'transfers', | ||
paramKey | ||
); | ||
} else { | ||
handleCryptoTransferInputOnChange( | ||
e, | ||
paramKey, | ||
paramValue.fieldKey, | ||
setCryptoTransferParamValues | ||
); | ||
} | ||
}} | ||
/> | ||
))} | ||
|
||
{/* isApproval A*/} | ||
<div> | ||
<Tooltip | ||
label={htsCryptoTransferParamFields.isApprovalA.explanation} | ||
placement="top" | ||
fontWeight={'medium'} | ||
> | ||
<Select | ||
_focus={{ borderColor: '#A98DF4' }} | ||
className="w-[200px] hover:cursor-pointer rounded-md border-white/30" | ||
placeholder="Approval Status" | ||
onChange={(e) => { | ||
if (mode === 'TOKEN') { | ||
handleTokenTransferInputOnChange( | ||
e, | ||
masterTokenParam.fieldKey, | ||
paramValue.fieldKey, | ||
'transfers', | ||
'isApprovalA' | ||
); | ||
} else { | ||
handleCryptoTransferInputOnChange( | ||
e, | ||
'isApprovalA', | ||
paramValue.fieldKey, | ||
setCryptoTransferParamValues | ||
); | ||
} | ||
}} | ||
> | ||
<option value={'false'}>FALSE</option> | ||
<option value={'true'}>TRUE</option> | ||
</Select> | ||
</Tooltip> | ||
</div> | ||
|
||
{/* delete key button */} | ||
<div className="w-fit flex items-center"> | ||
<SharedRemoveFieldsButton | ||
fieldKey={paramValue.fieldKey} | ||
handleModifyTokenAddresses={handleModifyRecords} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CryptoTransferInputFields; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
...ayground/src/components/contract-interaction/hts/token-transfer-contract/method/index.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/*- | ||
* | ||
* Hedera Smart Contracts | ||
* | ||
* Copyright (C) 2023 Hedera Hashgraph, LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* | ||
*/ | ||
|
||
import { Contract } from 'ethers'; | ||
import CryptoTransfer from './transferCrypto'; | ||
import { NetworkName } from '@/types/common'; | ||
|
||
interface PageProps { | ||
method: string; | ||
baseContract: Contract; | ||
} | ||
|
||
const HederaTokenTransferMethods = ({ baseContract, method }: PageProps) => { | ||
return ( | ||
<> | ||
{method === 'transferFrom' && <>{method}</>} | ||
{method === 'transferToken' && <>{method}</>} | ||
{method === 'transferTokens' && <>{method}</>} | ||
{method === 'crypto' && <CryptoTransfer baseContract={baseContract} />} | ||
</> | ||
); | ||
}; | ||
|
||
export default HederaTokenTransferMethods; |
Oops, something went wrong.