From ad0110edf0c7e9da202f63d3bef698cc56dbc8b6 Mon Sep 17 00:00:00 2001 From: Rahul Yadav Date: Sat, 4 Nov 2023 06:54:07 +0530 Subject: [PATCH] Create custom field for data type --- .../DashboardSidebar/DashboardSidebar.tsx | 4 +- .../project/NewProject/NewProject.tsx | 5 +- src/components/workspace/ABIUi/ABIUi.tsx | 83 +++-- .../BuildProject/BuildProject.module.scss | 2 +- .../workspace/BuildProject/BuildProject.tsx | 114 +++++- .../workspace/WorkSpace/WorkSpace.tsx | 2 +- .../workspace/abiInputs/Address.tsx | 40 +++ src/components/workspace/abiInputs/Amount.tsx | 37 ++ src/components/workspace/abiInputs/Bool.tsx | 35 ++ src/components/workspace/abiInputs/Buffer.tsx | 42 +++ src/components/workspace/abiInputs/Cell.tsx | 43 +++ src/components/workspace/abiInputs/Null.tsx | 42 +++ src/components/workspace/abiInputs/String.tsx | 34 ++ src/components/workspace/abiInputs/index.ts | 7 + src/hooks/contract.hooks.ts | 333 ++++++++++++++---- src/hooks/project.hooks.ts | 16 +- src/pages/_app.tsx | 2 +- src/utility/utils.ts | 50 +++ tsconfig.json | 2 +- 19 files changed, 774 insertions(+), 119 deletions(-) create mode 100644 src/components/workspace/abiInputs/Address.tsx create mode 100644 src/components/workspace/abiInputs/Amount.tsx create mode 100644 src/components/workspace/abiInputs/Bool.tsx create mode 100644 src/components/workspace/abiInputs/Buffer.tsx create mode 100644 src/components/workspace/abiInputs/Cell.tsx create mode 100644 src/components/workspace/abiInputs/Null.tsx create mode 100644 src/components/workspace/abiInputs/String.tsx create mode 100644 src/components/workspace/abiInputs/index.ts diff --git a/src/components/dashboard/DashboardSidebar/DashboardSidebar.tsx b/src/components/dashboard/DashboardSidebar/DashboardSidebar.tsx index e4c1560..3452451 100644 --- a/src/components/dashboard/DashboardSidebar/DashboardSidebar.tsx +++ b/src/components/dashboard/DashboardSidebar/DashboardSidebar.tsx @@ -19,13 +19,13 @@ const DashboardSidebar: FC = ({ className }) => {
Welcome 👋 - startOnboarding(0)} > Start help wizard - + */} { ]; const templatedList = [ - { label: 'Blank Contract', value: 'tonBlank' }, + // { label: 'Blank Contract', value: 'tonBlank' }, { label: 'Counter Contract', value: 'tonCounter' }, + { label: 'NFT Contract', value: 'nft', lang: 'tact' }, + { label: 'Import Contract', value: 'import' }, + // { label: 'Chat Bot Contract', value: 'chatBot' }, ]; diff --git a/src/components/workspace/ABIUi/ABIUi.tsx b/src/components/workspace/ABIUi/ABIUi.tsx index 28fbadd..e13414a 100644 --- a/src/components/workspace/ABIUi/ABIUi.tsx +++ b/src/components/workspace/ABIUi/ABIUi.tsx @@ -32,7 +32,10 @@ const ABIUi: FC = ({ if (['cell', 'slice'].includes(item.type)) { return [item.type, 'address']; } - return [item.type]; + if (typeof item.type === 'string') { + return [item.type]; + } + return [(item.type as any).type]; }); const [isLoading, setIsLoading] = useState(false); @@ -56,7 +59,7 @@ const ABIUi: FC = ({ const callableFunction = type === 'Getter' ? callGetter : callSetter; - const getterReponse = await callableFunction( + const response = await callableFunction( contractAddress, abi.name, contract as any, @@ -66,8 +69,12 @@ const ABIUi: FC = ({ network ); - if (getterReponse) { - createLog(JSON.stringify(getterReponse)); + if (response?.logs) { + for (const log of response?.logs) { + createLog(log); + } + } else { + createLog(JSON.stringify(response)); } } catch (error: any) { console.log('error', error); @@ -90,30 +97,50 @@ const ABIUi: FC = ({ return (
- {abi.parameters.map((item: ABIParameter, i: number) => ( -
- - - - - - -
- ))} + {abi.parameters.map((item: ABIParameter, i: number) => { + if (item.name === 'queryId') { + return ( + + + + ); + } + return ( +
+ + + + + + +
+ ); + })}