Skip to content

Commit

Permalink
wallet + swap GUI update
Browse files Browse the repository at this point in the history
  • Loading branch information
madMAx43v3r committed May 22, 2023
1 parent a9a67f5 commit 97c51da
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 26 deletions.
Binary file modified mmx-node/linux/x86_64/lib/libmmx_modules.so
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{ "GIT_COMMIT_HASH": "8a0f73d83671b6494972216f60676bdcd2f1814c" }
{ "GIT_COMMIT_HASH": "df961cbf0f19b8e6605192d8432b35b87ee55a2b" }
24 changes: 11 additions & 13 deletions mmx-node/linux/x86_64/www/web-gui/public/explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -554,7 +554,7 @@ Vue.component('transaction-view', {
<tbody>
<tr>
<td class="key-cell">{{ $t('transaction_view.height') }}</td>
<td colspan="2">
<td>
<template v-if="data.height">
<router-link :to="'/explore/block/height/' + data.height">{{data.height}}</router-link>
</template>
Expand All @@ -563,41 +563,39 @@ Vue.component('transaction-view', {
</tr>
<tr v-if="data.did_fail" class="red--text">
<td class="key-cell">{{ $t('transaction_view.message') }}</td>
<td colspan="2">{{data.message}}</td>
<td>{{data.message}}</td>
</tr>
<tr v-if="data.confirm">
<td class="key-cell">{{ $t('transaction_view.confirmed') }}</td>
<td colspan="2">{{data.confirm}}</td>
<td>{{data.confirm}}</td>
</tr>
<tr v-if="data.expires != 4294967295">
<tr v-if="data.expires < 4294967295">
<td class="key-cell">{{ $t('transaction_view.expires') }}</td>
<td colspan="2">{{data.expires}}</td>
<td>{{data.expires}}</td>
</tr>
<tr>
<td class="key-cell">{{ $t('transaction_view.note') }}</td>
<td colspan="2">{{data.note}}</td>
<td>{{data.note}}</td>
</tr>
<tr v-if="data.time">
<td class="key-cell">{{ $t('transaction_view.time') }}</td>
<td colspan="2">{{new Date(data.time * 1000).toLocaleString()}}</td>
<td>{{new Date(data.time * 1000).toLocaleString()}}</td>
</tr>
<tr v-if="data.deployed">
<td class="key-cell">{{ $t('transaction_view.address') }}</td>
<td colspan="2"><router-link :to="'/explore/address/' + data.address">{{data.address}}</router-link></td>
<td><router-link :to="'/explore/address/' + data.address">{{data.address}}</router-link></td>
</tr>
<tr v-if="data.sender">
<td class="key-cell">{{ $t('transaction_view.sender') }}</td>
<td colspan="2"><router-link :to="'/explore/address/' + data.sender">{{data.sender}}</router-link></td>
<td><router-link :to="'/explore/address/' + data.sender">{{data.sender}}</router-link></td>
</tr>
<tr>
<td class="key-cell">{{ $t('transaction_view.cost') }}</td>
<td class="collapsing"><b>{{data.cost.value}}</b></td>
<td>MMX</td>
<td><b>{{data.cost.value}}</b> MMX</td>
</tr>
<tr>
<td class="key-cell">{{ $t('transaction_view.fee') }}</td>
<td class="collapsing"><b>{{data.fee.value}}</b></td>
<td>MMX</td>
<td><b>{{data.fee.value}}</b> MMX</td>
</tr>
</tbody>
</v-simple-table>
Expand Down
35 changes: 30 additions & 5 deletions mmx-node/linux/x86_64/www/web-gui/public/swap.js
Original file line number Diff line number Diff line change
Expand Up @@ -517,13 +517,15 @@ Vue.component('swap-trade', {
return {
data: null,
buy_fee: null,
buy_price: null,
buy_amount: null,
buy_balance: null,
buy_estimate: null,
buy_num_iter: 20,
buy_slippage: 0.98,
buy_tx_fee: null,
sell_fee: null,
sell_price: null,
sell_amount: null,
sell_balance: null,
sell_estimate: null,
Expand Down Expand Up @@ -567,11 +569,10 @@ Vue.component('swap-trade', {
req.amount = amount;
req.min_trade = min_trade;
req.num_iter = num_iter;
const options = {};
req.options = {};
if(fee_ratio) {
options.fee_ratio = fee_ratio;
req.options.fee_ratio = fee_ratio;
}
req.options = options;
fetch('/wapi/wallet/swap/trade', {body: JSON.stringify(req), method: "post"})
.then(response => {
if(response.ok) {
Expand All @@ -597,24 +598,28 @@ Vue.component('swap-trade', {
},
update_buy_estimate() {
this.buy_fee = null;
this.buy_price = null;
this.buy_estimate = null;
if(this.buy_amount > 0) {
fetch('/wapi/swap/trade_estimate?id=' + this.address + '&index=1&amount=' + this.buy_amount + '&iters=' + this.buy_num_iter)
.then(response => response.json())
.then(data => {
this.buy_fee = (100 * data.fee.value / (parseFloat(data.trade.value) + parseFloat(data.fee.value))).toFixed(2);
this.buy_fee = data.fee_percent.toFixed(2);
this.buy_price = parseFloat((1 / data.avg_price).toPrecision(6));
this.buy_estimate = data.trade.value;
});
}
},
update_sell_estimate() {
this.sell_fee = null;
this.sell_price = null;
this.sell_estimate = null;
if(this.sell_amount > 0) {
fetch('/wapi/swap/trade_estimate?id=' + this.address + '&index=0&amount=' + this.sell_amount + '&iters=' + this.sell_num_iter)
.then(response => response.json())
.then(data => {
this.sell_fee = (100 * data.fee.value / (parseFloat(data.trade.value) + parseFloat(data.fee.value))).toFixed(2);
this.sell_fee = data.fee_percent.toFixed(2);
this.sell_price = parseFloat(data.avg_price.toPrecision(6));
this.sell_estimate = data.trade.value;
});
}
Expand Down Expand Up @@ -685,6 +690,15 @@ Vue.component('swap-trade', {
</v-text-field>
</v-col>
</v-row>
<v-row>
<v-col>
<v-text-field class="text-align-right"
v-model="buy_price"
label="Trade Price (average, including fee)"
:suffix="data.symbols[1] + ' / ' + data.symbols[0]" disabled>
</v-text-field>
</v-col>
</v-row>
<v-row>
<v-col>
<v-select
Expand All @@ -706,6 +720,7 @@ Vue.component('swap-trade', {
</v-row>
</v-card-text>
<v-card-actions class="justify-end">
<v-btn @click="update_buy_estimate()" :disabled="!(buy_amount > 0)">Update</v-btn>
<v-btn color="green lighten-1" @click="submit_buy()" :disabled="!(buy_amount > 0) || !(buy_estimate > 0)">{{ $t('swap.buy') }}</v-btn>
</v-card-actions>
</v-card>
Expand Down Expand Up @@ -746,6 +761,15 @@ Vue.component('swap-trade', {
</v-text-field>
</v-col>
</v-row>
<v-row>
<v-col>
<v-text-field class="text-align-right"
v-model="sell_price"
label="Trade Price (average, including fee)"
:suffix="data.symbols[1] + ' / ' + data.symbols[0]" disabled>
</v-text-field>
</v-col>
</v-row>
<v-row>
<v-col>
<v-select
Expand All @@ -767,6 +791,7 @@ Vue.component('swap-trade', {
</v-row>
</v-card-text>
<v-card-actions class="justify-end">
<v-btn @click="update_sell_estimate()" :disabled="!(sell_amount > 0)">Update</v-btn>
<v-btn color="red lighten-1" @click="submit_sell()" :disabled="!(sell_amount > 0) || !(sell_estimate > 0)">{{ $t('swap.sell') }}</v-btn>
</v-card-actions>
</v-card>
Expand Down
22 changes: 15 additions & 7 deletions mmx-node/linux/x86_64/www/web-gui/public/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1446,7 +1446,7 @@ Vue.component('account-send-form', {
source: null,
address: "",
currency: null,
fee_ratio: 1, // TODO
fee_ratio: 1024,
confirmed: false,
result: null,
error: null,
Expand Down Expand Up @@ -1507,6 +1507,7 @@ Vue.component('account-send-form', {
}
req.dst_addr = this.target;
req.options = {};
req.options.fee_ratio = this.fee_ratio;
req.options.passphrase = passphrase;

fetch('/wapi/wallet/send', {body: JSON.stringify(req), method: "post"})
Expand Down Expand Up @@ -1596,11 +1597,18 @@ Vue.component('account-send-form', {
:disabled="!!target_">
</v-select>
<v-text-field
v-model="target"
:label="$t('account_send_form.destination_address')"
:disabled="!!address || !!target_" placeholder="mmx1...">
</v-text-field>
<v-row>
<v-col>
<v-text-field
v-model="target"
:label="$t('account_send_form.destination_address')"
:disabled="!!address || !!target_" placeholder="mmx1...">
</v-text-field>
</v-col>
<v-col cols="2">
<tx-fee-select @update-value="value => this.fee_ratio = value"></tx-fee-select>
</v-col>
</v-row>
<v-row>
<v-col cols="3">
Expand All @@ -1627,7 +1635,7 @@ Vue.component('account-send-form', {
</v-row>
<v-switch v-model="confirmed" :label="$t('account_offer_form.confirm')" class="d-inline-block"></v-switch><br>
<v-btn @click="submit" outlined color="primary" :disabled="!confirmed">{{ $t('account_send_form.send') }}</v-btn>
<v-btn @click="submit" outlined color="primary" :disabled="!confirmed || !target || !currency || !amount">{{ $t('account_send_form.send') }}</v-btn>
</v-card-text>
</v-card>
Expand Down

0 comments on commit 97c51da

Please sign in to comment.