Merge branch 'webide/generate-deploy-script' into 'dev'

Webide/generate deploy script

See merge request ligolang/ligo!637
This commit is contained in:
Jev Björsell 2020-05-25 18:47:51 +00:00
commit 413dc7cc1b
25 changed files with 2696 additions and 2281 deletions

View File

@ -15,6 +15,9 @@
evaluateFunction:
entrypoint: add
parameters: 5, 6
generateDeployScript:
entrypoint: main
storage: 0
*_*)
type storage = int

View File

@ -15,6 +15,9 @@
evaluateFunction:
entrypoint: add
parameters: (5, 6)
generateDeployScript:
entrypoint: main
storage: 0
*_*)
// variant defining pseudo multi-entrypoint actions
type action is

View File

@ -15,6 +15,9 @@
evaluateFunction:
entrypoint: add
parameters: (5, 6)
generateDeployScript:
entrypoint: main
storage: 0
*_*)
type storage = int;

View File

@ -16168,6 +16168,11 @@
}
}
},
"slugify": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/slugify/-/slugify-1.4.0.tgz",
"integrity": "sha512-FtLNsMGBSRB/0JOE2A0fxlqjI6fJsgHGS13iTuVT28kViI4JjUiNqp/vyis0ZXYcMnpR3fzGNkv+6vRlI2GwdQ=="
},
"snapdragon": {
"version": "0.8.2",
"resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz",

View File

@ -7,7 +7,7 @@ import { DeployAction } from '../../redux/actions/deploy';
import { DryRunAction } from '../../redux/actions/dry-run';
import { EvaluateFunctionAction } from '../../redux/actions/evaluate-function';
import { EvaluateValueAction } from '../../redux/actions/evaluate-value';
import { GenerateCommandAction } from '../../redux/actions/generate-command';
import { GenerateDeployScriptAction } from '../../redux/actions/generate-deploy-script';
import { AppState } from '../../redux/app';
import { ChangeDispatchedAction, ChangeSelectedAction, CommandState } from '../../redux/command';
import { Command } from '../../redux/types';
@ -17,7 +17,7 @@ import { DeployPaneComponent } from './deploy-pane';
import { DryRunPaneComponent } from './dry-run-pane';
import { EvaluateFunctionPaneComponent } from './evaluate-function-pane';
import { EvaluateValuePaneComponent } from './evaluate-value-pane';
import { GenerateCommandPaneComponent } from './generate-command-pane';
import { GenerateDeployScriptPane } from './generate-deploy-script-pane';
const Container = styled.div<{ visible?: boolean }>`
position: absolute;
@ -76,8 +76,8 @@ function createAction(command: Command) {
return new EvaluateValueAction();
case Command.EvaluateFunction:
return new EvaluateFunctionAction();
case Command.GenerateCommand:
return new GenerateCommandAction();
case Command.GenerateDeployScript:
return new GenerateDeployScriptAction();
default:
throw new Error('Unsupported command');
}
@ -113,7 +113,7 @@ export const ConfigureTabComponent = (props: {
<Option value={Command.DryRun}>Dry Run</Option>
<Option value={Command.EvaluateFunction}>Evaluate Function</Option>
<Option value={Command.EvaluateValue}>Evaluate Value</Option>
<Option value={Command.GenerateCommand}>Generate Command</Option>
<Option value={Command.GenerateDeployScript}>Generate Deploy Script</Option>
</SelectCommand>
<RunButton
id="run"
@ -147,8 +147,8 @@ export const ConfigureTabComponent = (props: {
(command === Command.EvaluateValue && (
<EvaluateValuePaneComponent></EvaluateValuePaneComponent>
)) ||
(command === Command.GenerateCommand && (
<GenerateCommandPaneComponent></GenerateCommandPaneComponent>
(command === Command.GenerateDeployScript && (
<GenerateDeployScriptPane></GenerateDeployScriptPane>
))}
</Container>
);

View File

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

View File

@ -24,7 +24,7 @@ const Pre = styled.pre`
margin: 0;
`;
export const GenerateCommandOutputPane = () => {
export const GenerateDeployScriptOutputPane = () => {
const output = useSelector<AppState, ResultState['output']>(
state => state.result.output
);

View File

@ -8,7 +8,7 @@ import { ResultState } from '../../redux/result';
import { Command } from '../../redux/types';
import { CompileOutputPane } from './compile-output-pane';
import { DeployOutputPane } from './deploy-output-pane';
import { GenerateCommandOutputPane } from './generate-command-output-pane';
import { GenerateDeployScriptOutputPane } from './generate-deploy-script-output-pane';
import { Loading } from './loading';
import { OutputPane } from './output-pane';
@ -55,8 +55,8 @@ export const OutputTab = (props: {
return <CompileOutputPane></CompileOutputPane>;
} else if (command === Command.Deploy) {
return <DeployOutputPane></DeployOutputPane>;
} else if (command === Command.GenerateCommand) {
return <GenerateCommandOutputPane></GenerateCommandOutputPane>;
} else if (command === Command.GenerateDeployScript) {
return <GenerateDeployScriptOutputPane></GenerateDeployScriptOutputPane>;
}
return <OutputPane></OutputPane>;

View File

@ -22,25 +22,25 @@ export async function fetchRandomPrivateKey(): Promise<string> {
return response.text();
}
export class GenerateCommandAction extends CancellableAction {
export class GenerateDeployScriptAction extends CancellableAction {
getAction() {
return async (dispatch: Dispatch, getState: () => AppState) => {
dispatch({ ...new UpdateLoadingAction('Compiling contract...') });
try {
const { editor, generateCommand } = getState();
const { editor, generateDeployScript } = getState();
const michelsonCodeJson = await compileContract(
editor.language,
editor.code,
generateCommand.entrypoint,
generateDeployScript.entrypoint,
MichelsonFormat.Json
);
const michelsonCode = await compileContract(
editor.language,
editor.code,
generateCommand.entrypoint
generateDeployScript.entrypoint
);
if (this.isCancelled()) {
@ -51,16 +51,16 @@ export class GenerateCommandAction extends CancellableAction {
const michelsonStorageJson = await compileStorage(
editor.language,
editor.code,
generateCommand.entrypoint,
generateCommand.storage,
generateDeployScript.entrypoint,
generateDeployScript.storage,
MichelsonFormat.Json
);
const michelsonStorage = await compileStorage(
editor.language,
editor.code,
generateCommand.entrypoint,
generateCommand.storage
generateDeployScript.entrypoint,
generateDeployScript.storage
);
if (this.isCancelled()) {
@ -82,7 +82,7 @@ export class GenerateCommandAction extends CancellableAction {
const title = slugify(editor.title).toLowerCase() || 'untitled';
const output = `tezos-client \\
${generateCommand.command} \\
${generateDeployScript.command} \\
contract \\
${title} \\
transferring 0 \\
@ -92,7 +92,7 @@ export class GenerateCommandAction extends CancellableAction {
--burn-cap ${estimate.burnFeeMutez / 1000000}`;
dispatch({
...new ChangeOutputAction(output, Command.GenerateCommand)
...new ChangeOutputAction(output, Command.GenerateDeployScript)
});
} catch (ex) {
if (this.isCancelled()) {
@ -101,7 +101,7 @@ export class GenerateCommandAction extends CancellableAction {
dispatch({
...new ChangeOutputAction(
`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 evaluateValue, { EvaluateValueState } from './evaluate-value';
import examples, { ExamplesState } from './examples';
import generateCommand, { GenerateCommandState } from './generate-command';
import generateDeployScript, { GenerateDeployScriptState } from './generate-deploy-script';
import loading, { LoadingState } from './loading';
import result, { ResultState } from './result';
import share, { ShareState } from './share';
@ -23,7 +23,7 @@ export interface AppState {
deploy: DeployState;
evaluateFunction: EvaluateFunctionState;
evaluateValue: EvaluateValueState;
generateCommand: GenerateCommandState;
generateDeployScript: GenerateDeployScriptState;
result: ResultState;
command: CommandState;
examples: ExamplesState;
@ -38,7 +38,7 @@ export default combineReducers({
deploy,
evaluateFunction,
evaluateValue,
generateCommand,
generateDeployScript,
result,
command,
examples,

View File

@ -4,6 +4,8 @@ import { DryRunState } from './dry-run';
import { EditorState } from './editor';
import { EvaluateFunctionState } from './evaluate-function';
import { EvaluateValueState } from './evaluate-value';
import { GenerateDeployScriptState } from './generate-deploy-script';
export interface ExampleState {
id: string;
@ -14,4 +16,5 @@ export interface ExampleState {
deploy: DeployState;
evaluateFunction: EvaluateFunctionState;
evaluateValue: EvaluateValueState;
generateDeployScript: GenerateDeployScriptState;
}

View File

@ -1,13 +1,14 @@
import { ActionType as ExamplesActionType, ChangeSelectedAction as ChangeSelectedExampleAction } from './examples';
import { Tool, ToolCommand } from './types';
export enum ActionType {
ChangeTool = 'generate-command-change-tool',
ChangeCommand = 'generate-command-change-command',
ChangeEntrypoint = 'generate-command-change-entrypoint',
ChangeStorage = 'generate-command-change-storage'
ChangeTool = 'generate-deploy-script-change-tool',
ChangeCommand = 'generate-deploy-script-change-command',
ChangeEntrypoint = 'generate-deploy-script-change-entrypoint',
ChangeStorage = 'generate-deploy-script-change-storage'
}
export interface GenerateCommandState {
export interface GenerateDeployScriptState {
tool: Tool;
command: ToolCommand;
entrypoint: string;
@ -18,31 +19,32 @@ export interface GenerateCommandState {
export class ChangeToolAction {
public readonly type = ActionType.ChangeTool;
constructor(public payload: GenerateCommandState['tool']) {}
constructor(public payload: GenerateDeployScriptState['tool']) {}
}
export class ChangeCommandAction {
public readonly type = ActionType.ChangeCommand;
constructor(public payload: GenerateCommandState['command']) {}
constructor(public payload: GenerateDeployScriptState['command']) {}
}
export class ChangeEntrypointAction {
public readonly type = ActionType.ChangeEntrypoint;
constructor(public payload: GenerateCommandState['entrypoint']) {}
constructor(public payload: GenerateDeployScriptState['entrypoint']) {}
}
export class ChangeStorageAction {
public readonly type = ActionType.ChangeStorage;
constructor(public payload: GenerateCommandState['storage']) {}
constructor(public payload: GenerateDeployScriptState['storage']) {}
}
type Action =
| ChangeToolAction
| ChangeCommandAction
| ChangeEntrypointAction
| ChangeStorageAction;
| ChangeStorageAction
| ChangeSelectedExampleAction;
const DEFAULT_STATE: GenerateCommandState = {
const DEFAULT_STATE: GenerateDeployScriptState = {
tool: Tool.TezosClient,
command: ToolCommand.Originate,
entrypoint: '',
@ -54,8 +56,13 @@ const DEFAULT_STATE: GenerateCommandState = {
export default (
state = DEFAULT_STATE,
action: Action
): GenerateCommandState => {
): GenerateDeployScriptState => {
switch (action.type) {
case ExamplesActionType.ChangeSelected:
return {
...state,
...(!action.payload ? DEFAULT_STATE : action.payload.generateDeployScript)
};
case ActionType.ChangeTool:
return {
...state,

View File

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

View File

@ -3317,8 +3317,7 @@
"gensync": {
"version": "1.0.0-beta.1",
"resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.1.tgz",
"integrity": "sha512-r8EC6NO1sngH/zdD9fiRDLdcgnbayXah+mLgManTaIZJqEC1MZstmnox8KpnI2/fxQwrp5OpCOYWLp4rBl4Jcg==",
"dev": true
"integrity": "sha512-r8EC6NO1sngH/zdD9fiRDLdcgnbayXah+mLgManTaIZJqEC1MZstmnox8KpnI2/fxQwrp5OpCOYWLp4rBl4Jcg=="
},
"get-caller-file": {
"version": "2.0.5",

View File

@ -11,16 +11,16 @@
},
"devDependencies": {
"@ts-tools/node": "^1.0.0",
"@types/cors": "^2.8.6",
"@types/express": "^4.17.1",
"@types/express-winston": "^3.0.4",
"@types/hapi__joi": "^16.0.1",
"@types/jest": "^24.0.23",
"@types/joi": "^14.3.3",
"@types/node": "10",
"@types/node-fetch": "^2.5.4",
"@types/tmp": "^0.1.0",
"@types/winston": "^2.4.4",
"@types/cors": "^2.8.6",
"@types/node-fetch": "^2.5.4",
"jest": "^24.9.0",
"nodemon": "^1.19.3",
"ts-jest": "^24.1.0",
@ -40,6 +40,7 @@
"express": "^4.17.1",
"express-prometheus-middleware": "^0.8.5",
"express-winston": "^4.0.1",
"gensync": "^1.0.0-beta.1",
"node-fetch": "^2.6.0",
"sanitize-html": "^1.20.1",
"tmp": "^0.1.0",

View File

@ -11,7 +11,7 @@ interface CompileBody {
format?: string;
}
const validateRequest = (body: any): { value: CompileBody; error: any } => {
const validateRequest = (body: any): { value: CompileBody; error?: any } => {
return joi
.object({
syntax: joi.string().required(),

View File

@ -10,7 +10,7 @@ interface CompileBody {
format?: string;
}
const validateRequest = (body: any): { value: CompileBody; error: any } => {
const validateRequest = (body: any): { value: CompileBody; error?: any } => {
return joi
.object({
syntax: joi.string().required(),

View File

@ -12,7 +12,7 @@ interface CompileBody {
format?: string;
}
const validateRequest = (body: any): { value: CompileBody; error: any } => {
const validateRequest = (body: any): { value: CompileBody; error?: any } => {
return joi
.object({
syntax: joi.string().required(),

View File

@ -15,7 +15,7 @@ interface DeployBody {
Tezos.setProvider({ rpc: 'https://api.tez.ie/rpc/carthagenet' });
const validateRequest = (body: any): { value: DeployBody; error: any } => {
const validateRequest = (body: any): { value: DeployBody; error?: any } => {
return joi
.object({
syntax: joi.string().required(),

View File

@ -12,7 +12,7 @@ interface DryRunBody {
storage: string;
}
const validateRequest = (body: any): { value: DryRunBody; error: any } => {
const validateRequest = (body: any): { value: DryRunBody; error?: any } => {
return joi
.object({
syntax: joi.string().required(),

View File

@ -12,7 +12,7 @@ interface EvaluateValueBody {
const validateRequest = (
body: any
): { value: EvaluateValueBody; error: any } => {
): { value: EvaluateValueBody; error?: any } => {
return joi
.object({
syntax: joi.string().required(),

View File

@ -11,7 +11,7 @@ interface RunFunctionBody {
parameters: string;
}
const validateRequest = (body: any): { value: RunFunctionBody; error: any } => {
const validateRequest = (body: any): { value: RunFunctionBody; error?: any } => {
return joi
.object({
syntax: joi.string().required(),

View File

@ -35,7 +35,7 @@ interface ShareBody {
};
}
const validateRequest = (body: any): { value: ShareBody; error: any } => {
const validateRequest = (body: any): { value: ShareBody; error?: any } => {
return joi
.object({
editor: joi

View File

@ -28,6 +28,7 @@ export async function loadDefaultState(appBundleDirectory: string) {
deploy: {},
evaluateValue: {},
evaluateFunction: {},
generateDeployScript: {},
editor: {
title: ''
},
@ -63,6 +64,10 @@ export async function loadDefaultState(appBundleDirectory: string) {
...defaultState.evaluateFunction,
...defaultExample.evaluateFunction
};
defaultState.generateDeployScript = {
...defaultState.generateDeployScript,
...defaultExample.generateDeployScript
};
defaultState.editor = {
...defaultState.editor,
...defaultExample.editor,

File diff suppressed because it is too large Load Diff