This repository has been archived by the owner on May 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
/
app.js
1 lines (1 loc) · 3.66 KB
/
app.js
1
"use strict";var __awaiter=this&&this.__awaiter||function(a,s,o,l){return new(o||(o=Promise))(function(e,t){function r(e){try{i(l.next(e))}catch(e){t(e)}}function n(e){try{i(l.throw(e))}catch(e){t(e)}}function i(t){t.done?e(t.value):new o(function(e){e(t.value)}).then(r,n)}i((l=l.apply(a,s||[])).next())})},__generator=this&&this.__generator||function(r,n){function e(t){return function(e){return function(t){if(i)throw new TypeError("Generator is already executing.");for(;o;)try{if(i=1,a&&(s=a[2&t[0]?"return":t[0]?"throw":"next"])&&!(s=s.call(a,t[1])).done)return s;switch(a=0,s&&(t=[0,s.value]),t[0]){case 0:case 1:s=t;break;case 4:return o.label++,{value:t[1],done:!1};case 5:o.label++,a=t[1],t=[0];continue;case 7:t=o.ops.pop(),o.trys.pop();continue;default:if(!(s=0<(s=o.trys).length&&s[s.length-1])&&(6===t[0]||2===t[0])){o=0;continue}if(3===t[0]&&(!s||t[1]>s[0]&&t[1]<s[3])){o.label=t[1];break}if(6===t[0]&&o.label<s[1]){o.label=s[1],s=t;break}if(s&&o.label<s[2]){o.label=s[2],o.ops.push(t);break}s[2]&&o.ops.pop(),o.trys.pop();continue}t=n.call(r,o)}catch(e){t=[6,e],a=0}finally{i=s=0}if(5&t[0])throw t[1];return{value:t[0]?t[1]:void 0,done:!0}}([t,e])}}var i,a,s,t,o={label:0,sent:function(){if(1&s[0])throw s[1];return s[1]},trys:[],ops:[]};return t={next:e(0),throw:e(1),return:e(2)},"function"==typeof Symbol&&(t[Symbol.iterator]=function(){return this}),t},_this=this;Object.defineProperty(exports,"__esModule",{value:!0});var ethers_1=require("ethers"),polluterAbi=require("./abi/polluter.json"),daiAbi=require("./abi/dai.json"),web3=window.web3||void 0,utils=ethers_1.ethers.utils,provider=new ethers_1.ethers.providers.Web3Provider(web3.currentProvider),signer=provider.getSigner(),daiToken=new ethers_1.ethers.Contract("0xaFF4481D10270F50f203E0763e2597776068CBc5",daiAbi,signer);jQuery(function(c){return __awaiter(_this,void 0,void 0,function(){var u;return __generator(this,function(e){return c(".js--connect").click(function(t){return __awaiter(this,void 0,void 0,function(){return __generator(this,function(e){switch(e.label){case 0:return t.preventDefault(),u?(alert("already enabled"),[2]):[4,window.ethereum.enable()];case 1:return(u=e.sent())&&c(this).text("Wallet Connected"),[2]}})})}),c(".js--test-dai").click(function(n){return __awaiter(this,void 0,void 0,function(){var t,r=this;return __generator(this,function(e){switch(e.label){case 0:if(n.preventDefault(),!u)return alert("connect wallet"),[2];c(this).text("Getting Test Dai..."),e.label=1;case 1:return e.trys.push([1,4,,5]),[4,daiToken.drip()];case 2:return[4,e.sent().wait(1)];case 3:return e.sent(),c(this).text("Test Dai Received"),setTimeout(function(){c(r).html('Get Test Dai <i class="fas fa-faucet-drip"></i>')},4e3),alert("View test Dai in wallet by adding the token contract - 0xaFF4481D10270F50f203E0763e2597776068CBc5"),[3,5];case 4:return t=e.sent(),alert(t),[3,5];case 5:return[2]}})})}),c(".js--pollute").click(function(l){return __awaiter(this,void 0,void 0,function(){var t,r,n,i,a,s,o;return __generator(this,function(e){switch(e.label){case 0:return l.preventDefault(),u?(c(this).addClass("polluting"),[4,new ethers_1.ethers.Contract("0x57AaFA7eA3D66e2C9540d455BDBe093De9DB6bf4",polluterAbi,signer).iterator()]):(alert("connect wallet"),[2]);case 1:return t=e.sent(),c(this).text("Polluting"),[4,t.wait(1)];case 2:return r=e.sent(),c(this).text("Pollute"),c(this).removeClass("polluting"),n=r.events,i=n[n.length-1],a=i.args.totalGasOffset,s=i.args.methodFootprint,(a||s)&&(o=c(".polluter__spin"),c(o[0]).find("img").attr("src","./images/3.png"),c(o[1]).find("img").attr("src","./images/4.png"),c("body").addClass("clean"),c("pre").append("totalGasOffset: "+a+"<br />\n methodFootprint: "+s),c(this).hide()),[2]}})})}),[2]})})});