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 #833

Merged
merged 3 commits into from
Jan 28, 2022
Merged
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
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,20 @@ https://app.fyre.hypersign.id

## Installing & Building

node version = 14.17.1
npm version=8.3.1


```bash
npm i # to install packages
npm run dev # to run in development
npm run build # to build for production
```



Step 1:Create a braunch with version number(make sure all the code is save in stage develop and version brunch)
Step 2: check node and version
Step 3:remove node modules and packge-lock.json check for appropiate node version given in readme
Step 4:then run npm i and finally run npm run build to build for s3
Step 5; login into AWS console (before deploying makesure backend is deployed for production)
Binary file added src/assets/reef.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
114 changes: 66 additions & 48 deletions src/components/participant/ActionInputs/ReefErc20.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,17 @@
<b-row v-if="!showerror">
<b-col cols="12" sm="12" md="12">
<div class="metamask">
<b-form-input
<b-form-select
type="text"
:placeholder="data.placeHolder"
:options="options"
v-model="value.userWalletAddress"
:disabled="true"
:disabled="false"
:required="data.isManadatory"
></b-form-input>
<button class="btn text-black" @click="invokeMetamask()" v-if="!done">
></b-form-select>
<button class="btn text-black" @click="signMessage()" v-if="!done">
<img
src="../../../assets/metamask.svg"
src="../../../assets/reef.png"
height="25px"
width="25px"
/>
Expand All @@ -53,7 +54,7 @@
</b-row>
<b-row v-else>
<b-col cols="12" sm="12" md="12">
<ErrorMessage errorMessage="Install Metamask browser extension" />
<ErrorMessage errorMessage="Install Reef browser extension" />
</b-col>
</b-row>
<b-row v-if="!done">
Expand Down Expand Up @@ -83,7 +84,7 @@ import {
import notificationMixins from "../../../mixins/notificationMixins";
import Messages from "../../../utils/messages/participants/en";
import ErrorMessage from "../ErrorMessage.vue";
import Web3 from "web3";

export default {
name: "ReefErc20",
props: {
Expand All @@ -104,62 +105,74 @@ export default {
authToken: localStorage.getItem("authToken"),
showerror: false,
signature: "",
message_sign: "",
message_sign: "You are Signing this Message to confirm your Paricipation",

options:[{value: '', text: 'Please select an option'}],
value: {
contractAddress: "",
userWalletAddress: "",
userWalletAddress: '',
thresholdBalance: 0
}
},
wallet:[],
walletSignObj:""

};
},
mounted() {

async mounted() {

if(this.data.value){
Object.assign(this.value, {...JSON.parse(this.data.value) })
}
eventBus.$on(`disableInput${this.data._id}`, this.disableInput);
this.checkWeb3Injection();
await this.checkWeb3Injection();
await this.invokeReef()
await this.fetchAccounts()
},
methods: {
checkWeb3Injection() {
async checkWeb3Injection() {
try {
if (ethereum && ethereum.isMetaMask) {
this.web3 = new Web3(window.ethereum);
if (window.injectedWeb3) {
this.web3 = window.injectedWeb3

}
} catch (error) {
console.log(error);
this.showerror = true;
}




},
async signMessage() {
const message =
"You are Signing this message to ensure your participation in this event";
this.message_sign = message;
return await this.web3.eth.personal.sign(
message,
ethereum.selectedAddress
);
async fetchAccounts() {

for (let i in this.wallet) {

this.options.push({value:this.wallet[i],text: 'Address: '+ this.wallet[i].address.slice(0,12)+'...'+this.wallet[i].address.slice(38,48)+' Name: '+this.wallet[i].name})
}
},
async invokeMetamask() {
async invokeReef() {
try {
if (ethereum.isMetaMask) {
const wallet = await ethereum.request({
method: "eth_requestAccounts",
});
this.signature = await this.signMessage();

if (this.web3.reef) {

let sign;
await window.injectedWeb3.reef.enable()
.then(async walletObj=>{
this.wallet = await walletObj.accounts.get();
this.walletSignObj=walletObj

})





// const walletAddr= await wallet.get


const generatedWalletAddr = await this.web3.eth.personal.ecRecover(this.message_sign, this.signature)

let isSigVerified = false;
if(generatedWalletAddr === wallet[0]){
isSigVerified = true;
}

if (isSigVerified) {
this.value.userWalletAddress = wallet[0];
} else{
return this.notifyErr(Messages.EVENT_ACTIONS.ETH.INVALID_SIG)
}
}
} catch (error) {
return this.notifyErr(error.message)
Expand All @@ -173,6 +186,9 @@ export default {
let balance = await this.fetchBalance();
if (balance !== undefined) {
if (balance >= Number.parseFloat(this.value.thresholdBalance)) {
this.value.contractAddress=this.value.contractAddress.address
console.log(JSON.stringify({...this.value}));
this.value.userBalance=balance
this.$emit("input", JSON.stringify({
...this.value,
}));
Expand All @@ -187,26 +203,28 @@ export default {
}
},
isFieldValid() {
if (isEmpty(this.value.userWalletAddress)) {
if (isEmpty(this.value.userWalletAddress.address)) {
return false;
}
if (isValidURL(this.value.userWalletAddress)) {
if (isValidURL(this.value.userWalletAddress.address)) {
return false;
}
if (!isValidText(this.value.userWalletAddress)) {
if (!isValidText(this.value.userWalletAddress.address)) {
return false;
}
return true;
},
async fetchBalance() {
console.log(this.value.userWalletAddress);
this.signature=await this.walletSignObj.signer.signRaw(this.value.userWalletAddress)
const body = {
actionType: this.data.type,
data: this.value.userWalletAddress,
data: this.value.userWalletAddress.address,
contractAddress: this.value.contractAddress,
signature: this.signature,
message: this.message_sign,
};
let url = `${this.$config.studioServer.BASE_URL}api/v1/action/contract/call`;
let url = `${this.$config.studioServer.BASE_URL}api/v1/action/contract/reef`;

let headers = {
"Content-Type": "application/json",
Expand All @@ -220,9 +238,9 @@ export default {
header: headers,
});

const result = res.data;

return result;
const result = res.data.balance.hex;
return Number(result);
},
disableInput(data) {
this.done = data;
Expand Down