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

Add NFT minting forged tool #77

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
61 changes: 60 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,14 @@
<v-list-item-title>ENS</v-list-item-title>
</v-list-item-content>
</v-list-item>
<v-list-item link @click="$router.push(`/nft/${minionAddr}`)">
<v-list-item-action>
<v-icon>mdi-settings</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>NFT</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
</v-navigation-drawer>

Expand All @@ -54,6 +62,7 @@
@registered="onRegisteredChild"
@executed="onExecutedChild"
@actionDetails="onGetMinionDetails"
@mintedNFT="onMintedNFT"
:minions="minions"
:domains="domains"
:subdomains="subdomains"
Expand Down Expand Up @@ -114,6 +123,7 @@ import gql from "graphql-tag";
import minionAbi from "./abi/minion.json";
import molochAbi from "./abi/moloch_v2.json";
import subdomainRegistrarAbi from "./abi/minion_subdomain_registrar.json";
import nftAbi from "./abi/minion_nft.json";

// dao address is gotten from minion contract
const addresses = {
Expand All @@ -132,6 +142,10 @@ const addresses = {
resolver: {
kovan: "0xbe3f1473231C9DbC62603F4964406f9D3c4E40f2",
mainnet: "0xDaaF96c344f63131acadD0Ea35170E7892d3dfBA"
},
nft: {
kovan: "0x29B237Bb6D56d2710F68638C7400727f0E29fb27",
mainnet: "0x0"
}
};

Expand Down Expand Up @@ -200,7 +214,11 @@ export default {
resolverAddr:
process.env.VUE_APP_CHAIN === "kovan"
? addresses.resolver.kovan
: addresses.resolver.mainnet
: addresses.resolver.mainnet,
nftAddr:
process.env.VUE_APP_CHAIN === "kovan"
? addresses.nft.kovan
: addresses.nft.mainnet
}),
computed: {
minions: function() {
Expand Down Expand Up @@ -452,6 +470,47 @@ export default {
this.overlay = false;
// console.log("rejected", e);
}
},
async onMintedNFT(request) {
const molochContract = new this.web3.eth.Contract(
molochAbi,
this.molochAddr
);
const member = await molochContract.methods.members(request.to).call();
// If token receiver is not a member, decision is handled by Minion via Moloch vote
if (member.shares > 0) {
// force user to sign in before submitting new proposal
if (!this.user) {
return this.signIn();
}
this.overlay = true;

const contract = new this.web3.eth.Contract(nftAbi, this.nftAddr);
try {
const txReceipt = await contract.methods
.mint(request.to)
.send({ from: this.user });

// timeout to let things sync?
setTimeout(() => {
this.overlay = false;
this.$router.push("/");
}, 1000);
} catch (e) {
this.overlay = false;
// console.log("rejected", e);
}
} else {
const minion = {};
minion.target = this.nftAddr;
minion.description = `Mint welcome token to ${request.to} (requested by ${this.user}).`;
minion.id = this.minions.length + 1;
const mintFunc = nftAbi.find(func => func.name && func.name === "mint");
minion.hexData = this.web3.eth.abi.encodeFunctionCall(mintFunc, [
request.to
]);
this.onSubmittedChild(minion);
}
}
},
async created() {
Expand Down
Loading