diff --git a/blockchains/minter/apps/wallet/content.php b/blockchains/minter/apps/wallet/content.php
index 06237ec9..b62aebcb 100644
--- a/blockchains/minter/apps/wallet/content.php
+++ b/blockchains/minter/apps/wallet/content.php
@@ -7,7 +7,8 @@
-
Конвертация
+
Делегирование
+
+
+
Адрес:
+
+
+
+
Делегированные монеты
+
+Статус валидатора, ключ
+Название |
+Стек
+В BIP |
+В списке ожидания? |
+Действия... |
+
+
+
+
+
+
Конвертация
+
+
+
+
+
+
+
+
+
+'; ?>
\ No newline at end of file
diff --git a/blockchains/minter/apps/wallet/index.php b/blockchains/minter/apps/wallet/index.php
index 207e8122..1a93b008 100644
--- a/blockchains/minter/apps/wallet/index.php
+++ b/blockchains/minter/apps/wallet/index.php
@@ -1,2 +1,16 @@
\ No newline at end of file
+require_once 'functions.php';
+function generateAppPages() {
+ global $conf;
+ $delegation = pageUrl()[2];
+ if (is_dir(__DIR__.'/'.$delegation)) {
+$page_config = configs(__DIR__.'/'.$delegation.'/config.json');
+$data = [];
+$data['title'] = $page_config['title'];
+$data['description'] = $page_config['description'];
+$data['content'] = require_once(__DIR__.'/'.$delegation.'/content.php');
+}
+ return $data;
+}
+ $data = generateAppPages();
+ ?>
\ No newline at end of file
diff --git a/blockchains/minter/apps/wallet/js/app.js b/blockchains/minter/apps/wallet/js/app.js
index 960949cd..0d83072b 100644
--- a/blockchains/minter/apps/wallet/js/app.js
+++ b/blockchains/minter/apps/wallet/js/app.js
@@ -228,7 +228,7 @@ async function getFee(coin, type, memo) {
let memo_bytes = byteCount(memo) * 0.2;
let type_fee = 1;
if (type === 'convert') type_fee = 10;
-if (type === 'delegate') type_fee = 20;
+if (type === 'delegate' || type === 'anbond') type_fee = 20;
let fee = (memo_bytes + type_fee).toFixed(3);
if (coin !== 'BIP') {
let coin_info = await minter.getCoinInfo(coin);
@@ -265,6 +265,43 @@ async function getConvertPrice() {
}
}
+async function getDelegations() {
+ try {
+ let result = await axios.get('https://explorer-api.minter.network/api/v2/addresses/Mxae30a08fae2cc95960c5055d1142fd676995e18b/delegations');
+let res = result.data.data;
+ if (res && res.length > 0) {
+ $('#delegation_tbody').css('display', 'block');
+ let table = '';
+ for (let el of res) {
+let amount = parseFloat(el.value).toFixed(3) + ' ' + el.coin.symbol;
+let bip_amount = parseFloat(el.bip_value).toFixed(3) + ' BIP';
+let validator_key = el.validator.public_key;
+let validator_name = el.validator.name;
+let validator_status = 'Валидатор';
+if (el.validator.status === 1) {
+ validator_status = 'Кандидат';
+} else if (el.validator.status === 0) {
+ validator_status = 'Отключён';
+}
+let is_waitlisted = (el.is_waitlisted == false ? 'Нет' : 'Да');
+table += `
+${validator_status}
+ ()
+${validator_name} |
+${amount}
+${bip_amount} |
+${is_waitlisted} |
+Делегировать ${el.coin.symbol}, Анбонд ${el.coin.symbol} |
+
`;
+} // end for
+$('#delegation_tbody').html(table);
+} // end if res.
+
+} catch(e) {
+ console.log('Ошибка с делегированием: ' + e);
+ }
+}
+
$(document).ready(async function() {
if (seed) {
jQuery("#main_wallet_info").css("display", "block");
@@ -298,11 +335,34 @@ $('.convert_modal_token').html(token);
$(document).on('click', '.delegate_modal', async function(e) {
let token = $(this).attr('data-token');
-$('.delegate_modal_token').html(token);
+ let key = $(this).attr('data-pubkey');
+ if (key) {
+ $('#action_delegate_key').val(key);
+ }
+ $('.delegate_modal_token').html(token);
$('#max_delegate_amount').html($('#max_' + token).html());
await getFee(token, 'delegate');
});
+ $(document).on('click', '.anbond_modal', async function(e) {
+ let token = $(this).attr('data-token');
+ let key = $(this).attr('data-pubkey');
+ $('#action_anbond_key').val(key);
+ let amount = $(this).attr('data-amount');
+ $('.anbond_modal_token').html(token);
+ $('#max_anbond_amount').html(amount);
+ await getFee(token, 'anbond');
+ });
+
+ $("#max_token_anbond").click(async function(){
+ let coin = $('.anbond_modal_token').html();
+ let max_amount = $('#max_anbond_amount').html();
+ max_amount = parseFloat(max_amount);
+ let fee = parseFloat($('#anbond_fee').html());
+ max_amount -= fee + 0.001;
+ $('#action_anbond_stake').val(new Number(max_amount).toFixed(3));
+ });
+
$("#action_transfer_start").click(async function(){
let q = window.confirm('Вы действительно хотите сделать перевод средств?');
if (q == true) {
@@ -380,6 +440,24 @@ $("#action_delegate_start").click(async function(){
}
}); // end subform
+ $("#action_anbond_start").click(async function(){
+ let q = window.confirm('Вы действительно хотите сделать анбонд?');
+ if (q == true) {
+ let coin = $('.anbond_modal_token').html();
+ let publicKey = $('#action_anbond_key').val();
+ let stake = $('#action_anbond_stake').val();
+ stake = parseFloat(stake);
+
+ try {
+ $.fancybox.close();
+ await anbond(coin, publicKey, stake)
+ await loadBalances();
+ } catch(e) {
+ window.alert('Ошибка: ' + e);
+ }
+ }
+ }); // end subform
+
$("#action_save_transfer_template").click(function(){
let name = window.prompt('Введите название шаблона');
if (name && name !== '') {
diff --git a/blockchains/minter/js/blockchain.js b/blockchains/minter/js/blockchain.js
index 1923c823..4928821b 100644
--- a/blockchains/minter/js/blockchain.js
+++ b/blockchains/minter/js/blockchain.js
@@ -146,6 +146,35 @@ $( document ).ready(function() {
});
}
+ async function anbond(coin, publicKey, stake) {
+ let wif = sender.privateKey;
+ const txParams = {
+ chainId: 1,
+ type: TX_TYPE.UNBOND,
+ data: {
+ publicKey,
+ coin,
+ stake,
+ },
+ };
+ const idTxParams = await minter.replaceCoinSymbol(txParams);
+ console.log(idTxParams);
+ minter.postTx(idTxParams, {privateKey: wif})
+ .then(async (txHash) => {
+ $.fancybox.open(`
Пожалуйста, подождите. Идёт отправка и проверка доставки транзакции.
`);
+ await new Promise(r => setTimeout(r, 5000));
+ let res = await getTransaction(txHash.hash);
+ if (res === true) {
+ document.getElementById('message').innerHTML = (`
Ok. Транзакция создана и отправлена: ${txHash.hash}`);
+ } else {
+ document.getElementById('message').innerHTML = ('Ошибка. Транзакция отправлена, но не принята.');
+ }
+ }).catch((error) => {
+ const errorMessage = error.response.error.message
+ throw `Ошибка: ${errorMessage}`;
+ });
+ }
+
async function getBalance(address) {
try {
let response = await axios.get('/address/' + address);