From b1aca8f66ce7c720f1602f83cee40093bdefbd18 Mon Sep 17 00:00:00 2001 From: hmisty Date: Thu, 11 Jan 2024 22:37:51 +0800 Subject: [PATCH] newbie add gas --- scripts/controllers/addressInfoController.js | 34 ++++++++++++++++++-- views/addressInfo.html | 19 ++++++++--- 2 files changed, 45 insertions(+), 8 deletions(-) diff --git a/scripts/controllers/addressInfoController.js b/scripts/controllers/addressInfoController.js index ae6181a..777a970 100644 --- a/scripts/controllers/addressInfoController.js +++ b/scripts/controllers/addressInfoController.js @@ -140,17 +140,44 @@ angular.module('ethExplorer') $('#dialog-unwrap-wjoule-confirm').modal('show'); } + // 新手加油 + $scope.wjUnwrapToNewbie = function () { + $scope.chainId = window.ethereum ? window.ethereum.chainId : ''; + $scope.account = window.ethereum ? window.ethereum.selectedAddress : ''; + + if ($scope.account) { // if having connected account + const from = $scope.account; + const to = $scope.addressId; + const amt = '0.005'; + console.log('wjUnwrapTo', from, amt, to); + + $('#wj-unwrap-amount').val(amt); // set value, instead of innerText + $('#wj-unwrap-to').val(to); + $('#wj-unwrap-save-info').prop('checked', false); + $('#wj-unwrap-check-balance').prop('checked', false); // don't check newbie's WJ balance + + $('#confirm-unwrap-wj-from').text(from); // set innerText for human reading + $('#confirm-unwrap-wj-amount').text(amt ? amt : '0'); + $('#confirm-unwrap-wj-amount2').text(amt ? amt : '0'); + $('#confirm-unwrap-wj-to').text(to); + + $('#dialog-unwrap-wjoule-confirm').modal({keyboard:false, backdrop:'static'}); + $('#dialog-unwrap-wjoule-confirm').modal('show'); + } + } + $scope.wjUnwrapTo = function () { const DIALOG_TITLE = 'Unwrap wJ'; const amt = $('#wj-unwrap-amount')[0].value; const to = $('#wj-unwrap-to')[0].value; const save_info = $('#wj-unwrap-save-info')[0].checked; - console.log('wjUnwrapTo', amt, to, save_info); + const check_balance = $('#wj-unwrap-check-balance')[0].checked; + console.log('wjUnwrapTo', amt, to, save_info, check_balance); if (amt && !isNaN(amt)) { // isNaN works, nice. if (!(amt > 0)) { dialogShowTxt(DIALOG_TITLE, "错误:wJ数量必须大于0"); - } else if (!(parseFloat(amt) < parseFloat($scope.wjBalanceInJoule))) { + } else if (check_balance && !(parseFloat(amt) < parseFloat($scope.wjBalanceInJoule))) { dialogShowTxt(DIALOG_TITLE, "错误:wJ数量 " + amt + " 不能超过持有量 " + $scope.wjBalanceInJoule); } else if (window.ethereum && window.ethereum.isConnected()) { web3.setProvider(window.ethereum); @@ -200,6 +227,7 @@ angular.module('ethExplorer') }; + ////////////////////////////////////////////////////////////////////////////// // read functionalities in page scope // ////////////////////////////////////////////////////////////////////////////// @@ -468,7 +496,7 @@ angular.module('ethExplorer') else tokenInfo.rarity = 'normal'; - console.log(token_id, tokenInfo.rarity); + //console.log(token_id, tokenInfo.rarity); } diff --git a/views/addressInfo.html b/views/addressInfo.html index a7809e4..b7cb2d6 100644 --- a/views/addressInfo.html +++ b/views/addressInfo.html @@ -10,9 +10,9 @@

链地址 查看链地址信息 - +

{{airdrop_hexdata}}

@@ -30,7 +30,7 @@

能量余额: - {{balanceInEther || "-"}} J (焦耳),即 {{balance || "-"}} e (能量单位) + {{balanceInEther || "-"}} Joule (焦耳),即 {{balance || "-"}} energy (能量) 数字资产: @@ -80,7 +80,12 @@

{{i2.tag}} - + + + + + + CryptoJunks @@ -117,7 +122,7 @@

- * 注:J(焦耳)是能量单位。定义 1 J = 1 Ee(E能量)= 10^9 Ge(G能量)= 10^18 e,即 1,000,000,000,000,000,000 e(能量)。 + * 注:J, Joule(焦耳)是能量单位。定义 1 J = 1 Ee(E能量)= 10^9 Ge(G能量)= 10^18 e,即 1,000,000,000,000,000,000 energy(能量)。 @@ -144,6 +149,10 @@

点击确定后不清空输入框
+
+ + +