updating generate command to generate deploy script

This commit is contained in:
Edmond Lee 2020-05-21 15:50:10 -07:00 committed by Jev Björsell
parent 417bd0f5f8
commit 2bf34e9ff5
No known key found for this signature in database
GPG Key ID: 03F50CB91981EC9E
7 changed files with 38 additions and 38 deletions

View File

@ -76,7 +76,7 @@ function createAction(command: Command) {
return new EvaluateValueAction(); return new EvaluateValueAction();
case Command.EvaluateFunction: case Command.EvaluateFunction:
return new EvaluateFunctionAction(); return new EvaluateFunctionAction();
case Command.GenerateCommand: case Command.GenerateDeployScript:
return new GenerateDeployScript(); return new GenerateDeployScript();
default: default:
throw new Error('Unsupported command'); throw new Error('Unsupported command');
@ -113,7 +113,7 @@ export const ConfigureTabComponent = (props: {
<Option value={Command.DryRun}>Dry Run</Option> <Option value={Command.DryRun}>Dry Run</Option>
<Option value={Command.EvaluateFunction}>Evaluate Function</Option> <Option value={Command.EvaluateFunction}>Evaluate Function</Option>
<Option value={Command.EvaluateValue}>Evaluate Value</Option> <Option value={Command.EvaluateValue}>Evaluate Value</Option>
<Option value={Command.GenerateCommand}>Generate Command</Option> <Option value={Command.GenerateDeployScript}>Generate Deploy Script</Option>
</SelectCommand> </SelectCommand>
<RunButton <RunButton
id="run" id="run"
@ -147,7 +147,7 @@ export const ConfigureTabComponent = (props: {
(command === Command.EvaluateValue && ( (command === Command.EvaluateValue && (
<EvaluateValuePaneComponent></EvaluateValuePaneComponent> <EvaluateValuePaneComponent></EvaluateValuePaneComponent>
)) || )) ||
(command === Command.GenerateCommand && ( (command === Command.GenerateDeployScript && (
<GenerateDeployScriptPane></GenerateDeployScriptPane> <GenerateDeployScriptPane></GenerateDeployScriptPane>
))} ))}
</Container> </Container>

View File

@ -8,7 +8,7 @@ import {
ChangeEntrypointAction, ChangeEntrypointAction,
ChangeStorageAction, ChangeStorageAction,
ChangeToolAction, ChangeToolAction,
GenerateCommandState, GenerateDeployScriptState,
} from '../../redux/generate-command'; } from '../../redux/generate-command';
import { Tool, ToolCommand } from '../../redux/types'; import { Tool, ToolCommand } from '../../redux/types';
import { AccessFunctionLabel, Group, Input, Label, Textarea } from '../form/inputs'; import { AccessFunctionLabel, Group, Input, Label, Textarea } from '../form/inputs';
@ -21,20 +21,20 @@ const Container = styled.div`
export const GenerateDeployScriptPane = () => { export const GenerateDeployScriptPane = () => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const tool = useSelector<AppState, GenerateCommandState['tool']>( const tool = useSelector<AppState, GenerateDeployScriptState['tool']>(
state => state.generateCommand.tool state => state.generateDeployScript.tool
); );
const command = useSelector<AppState, GenerateCommandState['command']>( const command = useSelector<AppState, GenerateDeployScriptState['command']>(
state => state.generateCommand.command state => state.generateDeployScript.command
); );
const entrypoint = useSelector<AppState, GenerateCommandState['entrypoint']>( const entrypoint = useSelector<AppState, GenerateDeployScriptState['entrypoint']>(
state => state.generateCommand.entrypoint state => state.generateDeployScript.entrypoint
); );
const storage = useSelector<AppState, GenerateCommandState['storage']>( const storage = useSelector<AppState, GenerateDeployScriptState['storage']>(
state => state.generateCommand.storage state => state.generateDeployScript.storage
); );
return ( return (

View File

@ -55,7 +55,7 @@ export const OutputTab = (props: {
return <CompileOutputPane></CompileOutputPane>; return <CompileOutputPane></CompileOutputPane>;
} else if (command === Command.Deploy) { } else if (command === Command.Deploy) {
return <DeployOutputPane></DeployOutputPane>; return <DeployOutputPane></DeployOutputPane>;
} else if (command === Command.GenerateCommand) { } else if (command === Command.GenerateDeployScript) {
return <GenerateDeployScriptOutputPane></GenerateDeployScriptOutputPane>; return <GenerateDeployScriptOutputPane></GenerateDeployScriptOutputPane>;
} }

View File

@ -28,19 +28,19 @@ export class GenerateDeployScript extends CancellableAction {
dispatch({ ...new UpdateLoadingAction('Compiling contract...') }); dispatch({ ...new UpdateLoadingAction('Compiling contract...') });
try { try {
const { editor, generateCommand } = getState(); const { editor, generateDeployScript } = getState();
const michelsonCodeJson = await compileContract( const michelsonCodeJson = await compileContract(
editor.language, editor.language,
editor.code, editor.code,
generateCommand.entrypoint, generateDeployScript.entrypoint,
MichelsonFormat.Json MichelsonFormat.Json
); );
const michelsonCode = await compileContract( const michelsonCode = await compileContract(
editor.language, editor.language,
editor.code, editor.code,
generateCommand.entrypoint generateDeployScript.entrypoint
); );
if (this.isCancelled()) { if (this.isCancelled()) {
@ -51,16 +51,16 @@ export class GenerateDeployScript extends CancellableAction {
const michelsonStorageJson = await compileStorage( const michelsonStorageJson = await compileStorage(
editor.language, editor.language,
editor.code, editor.code,
generateCommand.entrypoint, generateDeployScript.entrypoint,
generateCommand.storage, generateDeployScript.storage,
MichelsonFormat.Json MichelsonFormat.Json
); );
const michelsonStorage = await compileStorage( const michelsonStorage = await compileStorage(
editor.language, editor.language,
editor.code, editor.code,
generateCommand.entrypoint, generateDeployScript.entrypoint,
generateCommand.storage generateDeployScript.storage
); );
if (this.isCancelled()) { if (this.isCancelled()) {
@ -82,7 +82,7 @@ export class GenerateDeployScript extends CancellableAction {
const title = slugify(editor.title).toLowerCase() || 'untitled'; const title = slugify(editor.title).toLowerCase() || 'untitled';
const output = `tezos-client \\ const output = `tezos-client \\
${generateCommand.command} \\ ${generateDeployScript.command} \\
contract \\ contract \\
${title} \\ ${title} \\
transferring 0 \\ transferring 0 \\
@ -92,7 +92,7 @@ export class GenerateDeployScript extends CancellableAction {
--burn-cap ${estimate.burnFeeMutez / 1000000}`; --burn-cap ${estimate.burnFeeMutez / 1000000}`;
dispatch({ dispatch({
...new ChangeOutputAction(output, Command.GenerateCommand) ...new ChangeOutputAction(output, Command.GenerateDeployScript)
}); });
} catch (ex) { } catch (ex) {
if (this.isCancelled()) { if (this.isCancelled()) {
@ -101,7 +101,7 @@ export class GenerateDeployScript extends CancellableAction {
dispatch({ dispatch({
...new ChangeOutputAction( ...new ChangeOutputAction(
`Error: ${getErrorMessage(ex)}`, `Error: ${getErrorMessage(ex)}`,
Command.GenerateCommand Command.GenerateDeployScript
) )
}); });
} }

View File

@ -8,7 +8,7 @@ import editor, { EditorState } from './editor';
import evaluateFunction, { EvaluateFunctionState } from './evaluate-function'; import evaluateFunction, { EvaluateFunctionState } from './evaluate-function';
import evaluateValue, { EvaluateValueState } from './evaluate-value'; import evaluateValue, { EvaluateValueState } from './evaluate-value';
import examples, { ExamplesState } from './examples'; import examples, { ExamplesState } from './examples';
import generateCommand, { GenerateCommandState } from './generate-command'; import generateDeployScript, { GenerateDeployScriptState } from './generate-command';
import loading, { LoadingState } from './loading'; import loading, { LoadingState } from './loading';
import result, { ResultState } from './result'; import result, { ResultState } from './result';
import share, { ShareState } from './share'; import share, { ShareState } from './share';
@ -23,7 +23,7 @@ export interface AppState {
deploy: DeployState; deploy: DeployState;
evaluateFunction: EvaluateFunctionState; evaluateFunction: EvaluateFunctionState;
evaluateValue: EvaluateValueState; evaluateValue: EvaluateValueState;
generateCommand: GenerateCommandState; generateDeployScript: GenerateDeployScriptState;
result: ResultState; result: ResultState;
command: CommandState; command: CommandState;
examples: ExamplesState; examples: ExamplesState;
@ -38,7 +38,7 @@ export default combineReducers({
deploy, deploy,
evaluateFunction, evaluateFunction,
evaluateValue, evaluateValue,
generateCommand, generateDeployScript,
result, result,
command, command,
examples, examples,

View File

@ -1,13 +1,13 @@
import { Tool, ToolCommand } from './types'; import { Tool, ToolCommand } from './types';
export enum ActionType { export enum ActionType {
ChangeTool = 'generate-command-change-tool', ChangeTool = 'generate-deploy-script-change-tool',
ChangeCommand = 'generate-command-change-command', ChangeCommand = 'generate-deploy-script-change-command',
ChangeEntrypoint = 'generate-command-change-entrypoint', ChangeEntrypoint = 'generate-deploy-script-change-entrypoint',
ChangeStorage = 'generate-command-change-storage' ChangeStorage = 'generate-deploy-script-change-storage'
} }
export interface GenerateCommandState { export interface GenerateDeployScriptState {
tool: Tool; tool: Tool;
command: ToolCommand; command: ToolCommand;
entrypoint: string; entrypoint: string;
@ -18,22 +18,22 @@ export interface GenerateCommandState {
export class ChangeToolAction { export class ChangeToolAction {
public readonly type = ActionType.ChangeTool; public readonly type = ActionType.ChangeTool;
constructor(public payload: GenerateCommandState['tool']) {} constructor(public payload: GenerateDeployScriptState['tool']) {}
} }
export class ChangeCommandAction { export class ChangeCommandAction {
public readonly type = ActionType.ChangeCommand; public readonly type = ActionType.ChangeCommand;
constructor(public payload: GenerateCommandState['command']) {} constructor(public payload: GenerateDeployScriptState['command']) {}
} }
export class ChangeEntrypointAction { export class ChangeEntrypointAction {
public readonly type = ActionType.ChangeEntrypoint; public readonly type = ActionType.ChangeEntrypoint;
constructor(public payload: GenerateCommandState['entrypoint']) {} constructor(public payload: GenerateDeployScriptState['entrypoint']) {}
} }
export class ChangeStorageAction { export class ChangeStorageAction {
public readonly type = ActionType.ChangeStorage; public readonly type = ActionType.ChangeStorage;
constructor(public payload: GenerateCommandState['storage']) {} constructor(public payload: GenerateDeployScriptState['storage']) {}
} }
type Action = type Action =
@ -42,7 +42,7 @@ type Action =
| ChangeEntrypointAction | ChangeEntrypointAction
| ChangeStorageAction; | ChangeStorageAction;
const DEFAULT_STATE: GenerateCommandState = { const DEFAULT_STATE: GenerateDeployScriptState = {
tool: Tool.TezosClient, tool: Tool.TezosClient,
command: ToolCommand.Originate, command: ToolCommand.Originate,
entrypoint: '', entrypoint: '',
@ -54,7 +54,7 @@ const DEFAULT_STATE: GenerateCommandState = {
export default ( export default (
state = DEFAULT_STATE, state = DEFAULT_STATE,
action: Action action: Action
): GenerateCommandState => { ): GenerateDeployScriptState => {
switch (action.type) { switch (action.type) {
case ActionType.ChangeTool: case ActionType.ChangeTool:
return { return {

View File

@ -10,7 +10,7 @@ export enum Command {
EvaluateValue = 'evaluate-value', EvaluateValue = 'evaluate-value',
EvaluateFunction = 'evaluate-function', EvaluateFunction = 'evaluate-function',
Deploy = 'deploy', Deploy = 'deploy',
GenerateCommand = 'generate-command' GenerateDeployScript = 'generate-deploy-script'
} }
export enum Tool { export enum Tool {