diff --git a/DevGrants/Simi Grant/back.jpg b/DevGrants/Simi Grant/back.jpg new file mode 100644 index 000000000..735da5fbf Binary files /dev/null and b/DevGrants/Simi Grant/back.jpg differ diff --git a/DevGrants/Simi Grant/index.html b/DevGrants/Simi Grant/index.html new file mode 100644 index 000000000..860d17482 --- /dev/null +++ b/DevGrants/Simi Grant/index.html @@ -0,0 +1,27 @@ + + + + + + Choice Coin + + + +

CHOICE COIN

+
+
+

Choice Coin Voting

+ +
+ +

Statement To be Submitted

+ +
+ + +
+ +
+ + + \ No newline at end of file diff --git a/DevGrants/Simi Grant/script.js b/DevGrants/Simi Grant/script.js new file mode 100644 index 000000000..024b24ded --- /dev/null +++ b/DevGrants/Simi Grant/script.js @@ -0,0 +1,87 @@ +// Retrieve AlgoSigner sdk from the browser +const { AlgoSigner } = window; + +//define the adddresses +const red_address = ""; +const blue_address = ""; + +//Get DOM Elements +const submitBtn = document.querySelector(".submit"); +const connectWallet = document.querySelector(".connect"); +const yes = document.querySelector(".yes-btn"); +const no = document.querySelector(".no-btn"); + +let yesOrNo = ""; +const setValue = (value) => { + yesOrNo = value; +}; +//Function to Connect User's Account +const ConnectAccount = async () => { + //Check if AlgoSigner is installed + if (!AlgoSigner) { + return alert("Kindly install AlgoSigner"); + } + + //Connect Account if AlgoSigner is installed + await AlgoSigner.connect() + .then((d) => {}) + .catch((e) => console.log("error in connection")); +}; + +// Sign the Transaction +const signTransaction = async (receiver = blue_address) => { + const txn = await AlgoSigner.algod({ + ledger: "TestNet", + path: "/v2/transactions/params", + }) + .then((e) => { + return e; + }) + .catch((e) => console.log("error in algorand")); + + //retrieve account details + const account = await AlgoSigner.accounts({ + ledger: "TestNet", + }) + .then((value) => value[0]) + .then((result) => { + const { address } = result; + + return address; + }) + + .catch((e) => console.log("failed to retrieve accounts")); + + //Transaction signature + await AlgoSigner.sign({ + from: account, + to: receiver, + amount: document.querySelector("hello"), + note: "voting", + fee: txn["min-fee"], + }) + .then(() => console.log("complete")) + .catch((e) => console.log("error", e)); +}; + +connectWallet.addEventListener("click", async (e) => { + await ConnectAccount(); + connectWallet.value = "Connected"; +}); + +submitBtn.addEventListener("click", (e) => { + console.log("welcome user"); + + //checks to see if the user click an option + if (!yesOrNo) { + alert("Please click either yes or no"); + return; + } + if (yesOrNo == "Yes") { + signTransaction(blue_address); + } + if (yesOrNo == "No") { + signTransaction(red_address); + } + alert(`Transaction successful in successful in ${yesOrNo}`); +}); \ No newline at end of file diff --git a/DevGrants/Simi Grant/style.css b/DevGrants/Simi Grant/style.css new file mode 100644 index 000000000..ac19d3907 --- /dev/null +++ b/DevGrants/Simi Grant/style.css @@ -0,0 +1,51 @@ +body{ + background: url("back.jpg") no-repeat center center/cover; +} + +/* Connect Form */ +.form{ + margin: auto; + display: flex; + flex-direction: column; + height: 540px; + width: 600px; + align-items: center; + margin-top: 130px; + background-color: rgba(0, 0, 0, 0.5); + box-shadow: -5px -5px rgba(0, 0, 0, 0.5); + border-radius: 25px; +} +.box{ + width: 350px; + padding: 10px; + height: 50px; + color: white; + margin-top: 6px; + background: transparent; + border-bottom: 1px solid; + border-top: none; + border-right: none; + border-left: none; +} +.box::placeholder { + font-size: 1em; + color: rgb(255, 255, 255); + padding: 5px; + } + .pas{ + width: 350px; + padding: 10px; + height: 70px; + margin-top: 6px; + border-radius: 5px; + border-bottom: 1px solid; + border-top: none; + border-right: none; + border-left: none; + } +button{ + background: #000000 + ; + border-radius: 5px; + color: white; +} \ No newline at end of file