Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dev #2

Merged
merged 4 commits into from
Jan 12, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion generate-transaction.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ <h1 class="text-center">Generate Transaction</h1>
<label for="op_type">Operation Type</label>
<select name="op_type" id="op_type" class="form-control" required>
<option value="">Select an operation</option>
<option value="vote">Vote</option>
<option value="transfer">Transfer</option>
<option value="transfer_to_vesting">Power Up</option>
<option value="withdraw_vesting">Power Down</option>
<option value="delegate_vesting_shares">Delegate SP</option>
<option value="account_witness_vote">Vote Witness</option>
</select>
</div>

Expand Down
2 changes: 1 addition & 1 deletion js/app.js

Large diffs are not rendered by default.

20 changes: 20 additions & 0 deletions multiauth-account.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,26 @@ <h1 class="text-center">Steem Multiple Authority</h1>
<button class="btn btn-sm btn-danger" id="remove-key-field">Remove</button>
</div>

<div id="accounts">
<div class="form-group">
<div class="row">
<div class="col-sm-8">
<label for="accounts">Account</label>
<input type="text" name="accounts[]" class="form-control">
</div>
<div class="col-sm-4">
<label for="account_weights">Weight</label>
<input type="number" name="account_weights[]" class="form-control" min="1">
</div>
</div>
</div>
</div>

<div class="form-group">
<button class="btn btn-sm btn-warning" id="add-account-field">Add</button>
<button class="btn btn-sm btn-danger" id="remove-account-field">Remove</button>
</div>

<div class="form-group">
<label for="threshold">Weight Threshold</label>
<input type="number" name="threshold" id="threshold" class="form-control" min="1" required>
Expand Down
43 changes: 27 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@
"author": "",
"license": "ISC",
"dependencies": {
"dsteem": "0.10.1",
"dsteem": "0.11.2",
"jquery": "^3.3.1",
"steem": "^0.7.3"
"regenerator-runtime": "^0.13.1",
"steem": "^0.7.4"
},
"devDependencies": {
"browserify": "^16.2.3",
Expand Down
47 changes: 44 additions & 3 deletions src/app.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
const $ = require('jquery');
const dsteem = require('dsteem');
const { auth } = require('steem');
const regeneratorRuntime = require('regenerator-runtime/runtime');
const { generateTrx } = require('./utils');

// Setting global varables
window.$ = $;
window.jQuery = $;
window.regeneratorRuntime = regeneratorRuntime;

require('./gen-transaction');
require('./sign-transaction');
Expand All @@ -18,6 +21,7 @@ let user = localStorage.getItem('user');

if (user) {
user = JSON.parse(localStorage.getItem('user'));
window.user = user;

$('input[name="username"]').val(user.name);
$('#welcome').html(`Hello, you are logged in as <span class="text-info">@${user.name}</span>. <a href="#" class="text-danger" id="logout">Logout</a>`);
Expand Down Expand Up @@ -68,11 +72,16 @@ $(document).ready(async () => {
const threshold = parseInt($('#threshold').val(), 10);
const publickeys = $('input[name="publickeys[]"]').map((i, e) => $(e).val()).get();
const weights = $('input[name="weights[]"]').map((i, e) => parseInt($(e).val(), 10)).get();
const accounts = $('input[name="accounts[]"]').map((i, e) => $(e).val()).get();
const accountWeights = $('input[name="account_weights[]"]').map((i, e) => parseInt($(e).val(), 10)).get();
let wif = $('#wif').val();

// Matching keys with the respected weights
const keyAuths = publickeys.map((k, i) => ([k, weights[i]]));

// Matching accounts with the respected weights
const accountAuths = accounts.map((k, i) => ([k, accountWeights[i]]));

const authority = {
key_auths: keyAuths,
weight_threshold: threshold,
Expand All @@ -87,17 +96,17 @@ $(document).ready(async () => {

switch (type) {
case 'posting':
authority.account_auths = user.posting_account_auth;
authority.account_auths = accountAuths;
operation[1].posting = authority;
break;

case 'active':
authority.account_auths = user.active_account_auth;
authority.account_auths = accountAuths;
operation[1].active = authority;
break;

case 'owner':
authority.account_auths = user.owner_account_auth;
authority.account_auths = accountAuths;
operation[1].owner = authority;
// Generating owner key for owner update
wif = (dsteem.PrivateKey.fromLogin(user.name, wif, 'owner')).toString();
Expand Down Expand Up @@ -161,6 +170,38 @@ $(document).ready(async () => {
e.preventDefault();
});

// Adding additional account field on button click
$('#add-account-field').click((e) => {
const html = `
<div class="form-group">
<div class="row">
<div class="col-sm-8">
<label for="accounts">Account</label>
<input type="text" name="accounts[]" class="form-control">
</div>
<div class="col-sm-4">
<label for="account_weight">Weight</label>
<input type="number" name="account_weights[]" class="form-control" min="1">
</div>
</div>
</div>`;

$('#accounts').append(html);

e.preventDefault();
});

// Removing additional key field on button click
$('#remove-account-field').click((e) => {
const children = $('#accounts').children('.form-group');

if (children.length > 1) {
children.last().remove();
}

e.preventDefault();
});

// Generating Private and Public key along with seed for the key if none was provided
$('#gen-key').submit((event) => {
let seed = $('#seed').val();
Expand Down
Loading