Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #1416

Merged
merged 3 commits into from
Jul 7, 2022
Merged

Develop #1416

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
207 changes: 48 additions & 159 deletions src/components/participant/ActionInputs/BinanceNetwork.vue
Original file line number Diff line number Diff line change
Expand Up @@ -31,108 +31,36 @@
</b-card-header>
<b-collapse :id="`collapse-${idValue}`" v-model="visible">
<b-card-body class="user-details">
<b-row v-if="!showerror">
<b-row>
<b-col cols="12" sm="12" md="12">
<!-- <div class="metamask">
<b-form-input
type="text"
:placeholder="data.placeHolder"
v-model="value.userWalletAddress"
:disabled="true"
:required="data.isManadatory"
></b-form-input>
<button
class="btn text-black"
@click="invokeMetamask()"
v-if="!done"
>
<img
src="../../../assets/metamask.svg"
height="25px"
width="25px"
/>
</button>
</div> -->
<div class="row g-3 align-items-center w-100 mt-4">
<div class="text-left col-lg-3 col-md-3 text-left">
<label for="title" class="col-form-label font-weight-bold"
>Method Name<span style="color: red">*</span>:
</label>
</div>

<div class="col-lg-8 col-md-8 px-0">
<input
v-model="value.methods"
type=""
id="title"
:required="true"
class="form-control w-100 font-weight-bold"
:disabled="true"
/>
</div>
</div>
<div class="row g-3 align-items-center" v-for="(param, index) in value.paramsList" v-bind:key="index">
<div class="col-lg-12 col-md-12" v-if="param.name === 'address'">
<div v-if="!showerror">
<input v-model="param.value" type="" id="title" :required="true" class="form-control w-100"
:disabled="true" :placeholder="param.name" />

<div
class="row g-3 align-items-center w-100 mt-4"
v-for="(param, index) in value.paramsList"
v-bind:key="index"
>
<div class="text-left col-lg-3 col-md-3 text-left">
<label for="title" class="col-form-label"
>{{ param.name }}<span style="color: red">*</span>:
</label>
</div>
<div v-if="!done" class="btn-group w-100">
<button class="btn btn-link" @click="invokeMetamask(index)">Connect Metamask</button>
<button class="btn btn-link" @click="update()">Continue</button>
</div>
</div>
<div v-else>
<ErrorMessage errorMessage="Install Metamask browser extension" v-if="!done" />
<input v-model="param.value" type="" id="title" :required="true" class="form-control w-100"
:disabled="true" v-else />
</div>
</div>
<div class="col-lg-12 col-md-12" v-else>
<input v-model="param.value" type="" id="title" :required="true" class="form-control w-100"
:disabled="done" />

<div
class="col-lg-9 col-md-9 px-0 metamask"
v-if="param.name === 'address'"
>
<input
v-model="param.value"
type=""
id="title"
:required="true"
class="form-control w-100"
:disabled="true"
/>
<button
class="btn text-black"
@click="invokeMetamask(index)"
v-if="!done"
>
<img
src="../../../assets/metamask.svg"
height="25px"
width="25px"
/>
</button>
</div>
<div class="col-lg-8 col-md-8 px-0" v-else>
<input
v-model="param.value"
type=""
id="title"
:required="true"
class="form-control w-100"
:disabled="done"
/>
<div v-if="!done" class="btn-group w-100" cols="12" sm="12" md="12">
<button class="btn btn-link center" @click="update()">Continue</button>
</div>
</div>
</div>
</b-col>
</b-row>
<b-row v-else>
<b-col cols="12" sm="12" md="12">
<ErrorMessage errorMessage="Install Metamask browser extension" />
</b-col>
</b-row>
<b-row v-if="!done">
<b-col cols="12" sm="12" md="12">
<button class="btn btn-link center" @click="update()">
<!-- <button class="btn btn-link center" @click="getData()"> -->
Continue / Execute
</button>
</b-col>
</b-row>
</b-card-body>
</b-collapse>
</b-card>
Expand Down Expand Up @@ -220,6 +148,8 @@ export default {
try {
if (window.ethereum && window.ethereum.isMetaMask) {
this.web3 = new Web3(window.ethereum);
}else {
this.showerror = true;
}
} catch (error) {
console.log(error);
Expand Down Expand Up @@ -265,6 +195,21 @@ export default {
return this.notifyErr(error.message);
}
},
emitToUpdate() {
//this.notifySuccess("Success");
const { contractAddress, paramsList } = this.value;
const valueToStore = {
contractAddress, paramsList
}
this.value.condition = "Condition True";

this.$emit(
"input",
JSON.stringify({
...valueToStore,
})
);
},
async update() {
try {
let result = await this.execute();
Expand All @@ -289,15 +234,7 @@ export default {
result = Number.parseFloat(result);
this.value.operand = Number.parseFloat(this.value.operand);
if (this.value.operand === result) {
this.notifySuccess("Success");
this.value.condition = "Condition True";

this.$emit(
"input",
JSON.stringify({
...this.value,
})
);
this.emitToUpdate()
} else {
throw new Error("Condition Mismatch");
}
Expand All @@ -306,31 +243,15 @@ export default {
case "string":
case "address":{
if (this.value.operand === result) {
this.notifySuccess("Success");
this.value.condition = "Condition True";

this.$emit(
"input",
JSON.stringify({
...this.value,
})
);
this.emitToUpdate()
} else {
this.notifyErr("Condition Mismatch");
}
break;
}
case "bool": {
if (!!this.value.operand === !!result) {
this.value.condition = "Condition True";

this.$emit(
"input",
JSON.stringify({
...this.value,
})
);
this.notifySuccess("Success");
this.emitToUpdate()
} else {
this.notifyErr("Condition Mismatch");
}
Expand All @@ -349,15 +270,7 @@ export default {
result = Number.parseFloat(result);
this.value.operand = Number.parseFloat(this.value.operand);
if (result < this.value.operand) {
this.notifySuccess("Success");
this.value.condition = "Condition True";

this.$emit(
"input",
JSON.stringify({
...this.value,
})
);
this.emitToUpdate()
} else {
throw new Error("Condition Mismatch");
}
Expand All @@ -372,15 +285,7 @@ export default {
result = Number.parseFloat(result);
this.value.operand = Number.parseFloat(this.value.operand);
if (result > this.value.operand) {
this.notifySuccess("Success");
this.value.condition = "Condition True";

this.$emit(
"input",
JSON.stringify({
...this.value,
})
);
this.emitToUpdate()
} else {
throw new Error("Condition Mismatch");
}
Expand All @@ -396,15 +301,7 @@ export default {
result = Number.parseFloat(result);
this.value.operand = Number.parseFloat(this.value.operand);
if (result <= this.value.operand) {
this.notifySuccess("Success");
this.value.condition = "Condition True";

this.$emit(
"input",
JSON.stringify({
...this.value,
})
);
this.emitToUpdate()
} else {
throw new Error("Condition Mismatch");
}
Expand All @@ -419,15 +316,7 @@ export default {
result = Number.parseFloat(result);
this.value.operand = Number.parseFloat(this.value.operand);
if (result >= this.value.operand) {
this.notifySuccess("Success");
this.value.condition = "Condition True";

this.$emit(
"input",
JSON.stringify({
...this.value,
})
);
this.emitToUpdate()
} else {
throw new Error("Condition Mismatch");
}
Expand Down Expand Up @@ -484,7 +373,7 @@ export default {
return result;
},
disableInput(data) {
this.done = data;
this.data.isDone = data;
},
},
mixins: [notificationMixins],
Expand Down
Loading