Skip to content

Commit

Permalink
Tezos-client in interact (#417)
Browse files Browse the repository at this point in the history
* Tezos-client in interact

* Fix: copy

* Validate burn cap

* Fix: code smells
  • Loading branch information
aopoltorzhicky authored Jun 30, 2022
1 parent 9d7afff commit dc13457
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 15 deletions.
8 changes: 5 additions & 3 deletions src/components/schema/Schema.vue
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,9 @@
:storage-limit="storageLimit"
/>
<SchemaCmdLine
:showCmd="showCmdline"
v-model="showCmdline"
:tezos-client-cmdline="tezosClientCmdline"
:show-clipboard-ok="showClipboardOK"
@cmdLineChange="setCmdline"
/>
<SchemaMichelson
v-model="showMichelson"
Expand Down Expand Up @@ -224,6 +223,9 @@ export default {
setSettings({key, val}) {
Vue.set(this.settings, key, val);
},
setResultOPG(val) {
this.showResultOPG = val;
},
setCmdline(val) {
this.showCmdline = val;
},
Expand Down Expand Up @@ -461,7 +463,7 @@ export default {
const src = this.settings.source || "%YOUR_ADDRESS%";
const entrypoint = this.name;
this.tezosClientCmdline = `transfer ${amount} from ${src} to ${this.address} --entrypoint "${entrypoint}" --arg "${arg}"`;
this.setCmdline(show);
this.showCmdline = show;
}
return resJSON;
})
Expand Down
70 changes: 58 additions & 12 deletions src/components/schema/schemaDialog/SchemaCmdLine.vue
Original file line number Diff line number Diff line change
@@ -1,23 +1,33 @@
<template>
<v-dialog v-model="showCmdline" width="800" scrollable :retain-focus="false">
<v-dialog v-model="show" width="800" scrollable ref="cmdLineDialog" :retain-focus="false">
<v-card flat outlined>
<v-card-title class="sidebar d-flex justify-center py-2">
<span class="body-1 font-weight-medium text-uppercase text--secondary">Tezos-client</span>
<v-spacer></v-spacer>
<v-btn
class="mr-4 text--secondary"
v-clipboard="() => tezosClientCmdline"
v-clipboard="() => cmdLine"
v-clipboard:success="showClipboardOk"
text
>
<v-icon small class="mr-1">mdi-content-copy</v-icon>Copy
</v-btn>
<v-btn icon small @click="showCmdline = false">
<v-btn icon small @click="show = false">
<v-icon>mdi-close</v-icon>
</v-btn>
</v-card-title>
<v-card-text class="pa-6">
<span class="hash">{{ tezosClientCmdline }}</span>
<v-card-text class="pt-4 pb-0">
<v-row>
<v-col cols="12">
<span class="hash">{{ cmdLine }}</span>
</v-col>
<v-col cols="12"><v-divider/></v-col>
<v-col>
<span class="overline">Optional settings</span>
<v-text-field v-model="burnCap" label="Burn cap" class="mt-4" type="numeric" :rules="rules" @keypress="isNumber($event)" dense outlined/>
<v-checkbox v-model="dryRun" color="primary" label="Dry run"></v-checkbox>
</v-col>
</v-row>
</v-card-text>
</v-card>
</v-dialog>
Expand All @@ -27,21 +37,57 @@
export default {
name: "SchemaCmdLine",
props: {
showCmd: Boolean,
value: Boolean,
tezosClientCmdline: String,
showClipboardOk: Function,
},
watch: {
showCmd(val) {
this.showCmdline = val;
computed: {
show: {
get() {
return this.value;
},
set(value) {
this.$emit('input', value);
}
},
showCmdline(val) {
this.$emit('cmdLineChange', val)
cmdLine() {
return `${this.tezosClientCmdline} ${this.options}`
},
options() {
let data = '';
if (this.dryRun) {
data += '--dry-run '
}
if (this.burnCap > 0) {
data += `--burn-cap ${this.burnCap.replace(/^0+(?!\.|$)/, '')}`
}
return data;
}
},
updated() {
if (this.value && !this.once) {
this.once = true;
this.$refs.cmdLineDialog.show();
}
},
data() {
return {
showCmdline: false,
dryRun: false,
burnCap: '0',
once: false,
rules: [
v => /^\d+(\.\d+)?$/.test(v) || "The value must be a float number"
]
}
},
methods: {
isNumber(evt) {
const charCode = (evt.which) ? evt.which : evt.keyCode;
if ((charCode > 31 && (charCode < 48 || charCode > 57)) && charCode !== 46) {
evt.preventDefault();
} else {
return true;
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/components/schema/schemaForm/SchemaForm.vue
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
</template>
<template slot="custom-nat" slot-scope="props">
<v-text-field
:key="props.fullKey"
:ref="props.fullKey"
:label="props.label"
v-on="props.on"
Expand All @@ -41,6 +42,7 @@
</template>
<template slot="custom-contract" slot-scope="props">
<v-text-field
:key="props.fullKey"
:ref="props.fullKey"
:label="props.label"
v-on="props.on"
Expand Down

0 comments on commit dc13457

Please sign in to comment.