Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Commit

Permalink
release 0.3.8-beta3
Browse files Browse the repository at this point in the history
Signed-off-by: lerencao <[email protected]>
  • Loading branch information
nanne007 committed Jul 3, 2020
1 parent 742c08b commit ac722c0
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 17 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 15 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "move-ide",
"version": "0.3.8-beta2",
"version": "0.3.8-beta3",
"description": "Move/mvir IDE for VSCode",
"publisher": "starcoinorg",
"displayName": "Move IDE",
Expand Down Expand Up @@ -71,6 +71,10 @@
"command": "move.run",
"title": "Move: Run Script"
},
{
"command": "move.dry-run",
"title": "Move: Dry-Run Script"
},
{
"command": "move.deploy",
"title": "Move: Deploy Module"
Expand All @@ -86,6 +90,10 @@
"command": "move.run",
"when": "editorLangId == move"
},
{
"command": "move.dry-run",
"when": "editorLangId == move"
},
{
"command": "move.deploy",
"when": "editorLangId == move"
Expand Down Expand Up @@ -144,6 +152,11 @@
"type": "string",
"markdownDescription": "Url of Starcoin node rpc address",
"default": "ws://127.0.0.1:56818"
},
"starcoin.maxGasAmount": {
"type": "integer",
"markdownDescription": "Max gas amount used to run txn",
"default": "1000000"
}
}
}
Expand Down Expand Up @@ -203,4 +216,4 @@
"darwin": "move-build-darwin"
}
}
}
}
50 changes: 36 additions & 14 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ interface MlsConfig {
export async function activate(context: vscode.ExtensionContext) {

context.subscriptions.push(vscode.commands.registerCommand('move.compile', () => compileCommand().catch(console.error)));
context.subscriptions.push(vscode.commands.registerTextEditorCommand('move.run', (textEditor, edit) => executeMoveFileCommand(textEditor, edit).catch(console.error)));
context.subscriptions.push(vscode.commands.registerTextEditorCommand('move.deploy', (textEditor, edit) => executeMoveFileCommand(textEditor, edit).catch(console.error)));
context.subscriptions.push(vscode.commands.registerTextEditorCommand('move.dry-run', (textEditor, edit) => executeMoveFileCommand(textEditor, edit, true).catch(console.error)));
context.subscriptions.push(vscode.commands.registerTextEditorCommand('move.run', (textEditor, edit) => executeMoveFileCommand(textEditor, edit, false).catch(console.error)));
context.subscriptions.push(vscode.commands.registerTextEditorCommand('move.deploy', (textEditor, edit) => executeMoveFileCommand(textEditor, edit, false).catch(console.error)));

extensionPath = context.extensionPath;
const outputChannel = vscode.window.createOutputChannel('move-language-server');
Expand Down Expand Up @@ -160,7 +161,7 @@ function checkDocumentLanguage(document: vscode.TextDocument, languageId: string
return true;
}

async function executeMoveFileCommand(textEditor: vscode.TextEditor, _edit: vscode.TextEditorEdit) {
async function executeMoveFileCommand(textEditor: vscode.TextEditor, _edit: vscode.TextEditorEdit, dryRun: boolean) {
let doc = textEditor.document;
if (!checkDocumentLanguage(doc, 'move')) {
return vscode.window.showWarningMessage('Can only run *.move file');
Expand All @@ -173,6 +174,8 @@ async function executeMoveFileCommand(textEditor: vscode.TextEditor, _edit: vsco
let starcoinConfig = vscode.workspace.getConfiguration('starcoin', workdir);
let nodePath = starcoinConfig.get<string>('nodePath');
let nodeRpcUrl = starcoinConfig.get<string>('nodeRpcUrl');
let maxGasAmount = starcoinConfig.get('maxGasAmount', 1000000) || 1000000;

if (!nodePath) {
vscode.window.showErrorMessage("starcoin nodePath is not configured");
return;
Expand All @@ -193,13 +196,22 @@ async function executeMoveFileCommand(textEditor: vscode.TextEditor, _edit: vsco
.then((value) => (value) && (sender = value));
}

if (!sender) {
return;
}

const args = [
'--connect', nodeRpcUrl,
'dev', 'execute',
'--blocking',
'--sender', sender,
'-o', 'json',
'dev', 'execute', '--blocking',
];

if (dryRun) {
args.push('--dry-run');
}
args.push('--sender', sender);
args.push('--max-gas', maxGasAmount.toString());

let deps = [];
if (!!config.modulesPath && fs.existsSync(config.modulesPath)) {
let dirEntries = fs.readdirSync(config.modulesPath);
Expand Down Expand Up @@ -282,22 +294,32 @@ function compileLibra(account: string, document: vscode.TextDocument, outdir: st
const executable = (process.platform === 'win32') ? 'move-build.exe' : 'move-build';
const bin = cfgBinPath || path.join(extensionPath, 'bin', executable);

const mods: string[] = [config.stdlibPath, config.modulesPath]
.filter((a) => !!a)
.filter((a) => fs.existsSync(a!))
.map((a) => a!);
const args = [
,
'--out-dir', outdir,
'--sender', account
];

if (mods.length) {
const moveFilePath = document.fileName;
const deps: string[] = [config.stdlibPath, config.modulesPath]
.filter((a) => !!a)
.map((a) => a!)
.filter((a) => fs.existsSync(a))
.map(depPath => {
let dirEntries = fs.readdirSync(depPath);
// exclude move file to run as dependencies
let modulePaths = dirEntries
.map(e => path.join(depPath!, e))
.filter((d) => d !== moveFilePath);
modulePaths.forEach(e => console.log(e));
return modulePaths;
}).flat();

if (deps.length) {
args.push('--dependency');
args.push(...mods);
args.push(...deps);
}

args.push('--', document.uri.fsPath);
args.push('--', moveFilePath);

const workdir = workspace.getWorkspaceFolder(document.uri);

Expand Down

0 comments on commit ac722c0

Please sign in to comment.