11import React from 'react'
2- import { MetadataType , TemplateExplorerWizardAction , TemplateExplorerWizardState , TemplateRepository , WizardStep } from '../types/template-explorer-types'
2+ import { ContractWizardAction , MetadataType , TemplateExplorerWizardAction , TemplateExplorerWizardState , TemplateRepository , WizardStep } from '../types/template-explorer-types'
33import { metadata , templatesRepository } from '../src/utils/helpers'
4+ import * as erc20 from '../src/contractCode/erc20'
5+ import { getErc20ContractCode } from '../src/utils/contractWizardUtils'
46
57export const initialState : TemplateExplorerWizardState = {
68 workspaceTemplateChosen : '' ,
@@ -17,7 +19,22 @@ export const initialState: TemplateExplorerWizardState = {
1719 setSearchTerm : ( term : string ) => { } ,
1820 wizardStep : 'template' ,
1921 setWizardStep : ( step : WizardStep ) => { } ,
20- recentBump : 0
22+ recentBump : 0 ,
23+ contractType : 'erc20' ,
24+ contractOptions : {
25+ mintable : false ,
26+ burnable : false ,
27+ pausable : false
28+ } ,
29+ contractAccessControl : '' ,
30+ contractUpgradability : {
31+ uups : false ,
32+ transparent : false
33+ } ,
34+ contractCode : erc20 . erc20DefaultNoOptions ( 'MyToken' ) ,
35+ contractImport : '' ,
36+ tokenName : 'MyToken' ,
37+ contractName : 'MyToken'
2138}
2239
2340export const templateExplorerReducer = ( state : TemplateExplorerWizardState , action : any ) => {
@@ -61,8 +78,36 @@ export const templateExplorerReducer = (state: TemplateExplorerWizardState, acti
6178 console . log ( 'action.payload wizardStep' , action . payload )
6279 return { ...state , wizardStep : action . payload }
6380 }
64- default :
65- return state
81+ case ContractWizardAction . CONTRACT_TYPE_UPDATED : {
82+ return { ...state , contractType : action . payload }
83+ }
84+ case ContractWizardAction . CONTRACT_UPGRADABILITY_UPDATE : {
85+ return { ...state , contractUpgradability : action . payload }
86+ }
87+ case ContractWizardAction . CONTRACT_ACCESS_CONTROL_UPDATE : {
88+ return { ...state , contractAccessControl : action . payload }
89+ }
90+ case ContractWizardAction . CONTRACT_OPTIONS_UPDATE : {
91+ return { ...state , contractOptions : action . payload }
92+ }
93+ case ContractWizardAction . CONTRACT_CODE_UPDATE : {
94+ return { ...state , contractCode : action . payload }
95+ }
96+ case ContractWizardAction . CONTRACT_IMPORT_UPDATE : {
97+ return { ...state , contractImport : action . payload }
98+ }
99+ case ContractWizardAction . INITIALIZE_AS_GIT_REPO_UPDATE : {
100+ return { ...state , initializeAsGitRepo : action . payload }
101+ }
102+ case ContractWizardAction . TOKEN_NAME_UPDATE : {
103+ return { ...state , tokenName : action . payload }
104+ }
105+ case ContractWizardAction . CONTRACT_NAME_UPDATE : {
106+ return { ...state , contractName : action . payload }
107+ }
108+ default : {
109+ return { ...state , contractCode : getErc20ContractCode ( 'erc20' , state ) }
110+ }
66111 }
67112}
68113
0 commit comments