Skip to content

Commit

Permalink
Merge PR #49 from 'rithvikvibhu/create-auction-txs'
Browse files Browse the repository at this point in the history
  • Loading branch information
pinheadmz committed Jul 15, 2022
2 parents d9b6160 + 6c562be commit 926861b
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 0 deletions.
18 changes: 18 additions & 0 deletions bin/hsw-cli
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ Commands:
$ key [address]: Get wallet key by address.
$ listen: Listen for events.
$ lock: Lock wallet.
$ mkauctiontxs [name] [bid] [lockup] [broadcast]: Create bid and reveal TXs.
$ mktx [address] [value]: Create transaction.
$ mkwallet [id]: Create wallet.
$ pending: View pending TXs.
Expand Down Expand Up @@ -352,6 +353,20 @@ class CLI {
this.log(tx);
}

async createAuctionTxs() {
const options = {
name: this.config.str([0, 'name']),
bid: this.config.ufixed([1, 'bid'], EXP),
lockup: this.config.ufixed([2, 'lockup'], EXP),
broadcastBid: this.config.bool([3, 'broadcastBid']),
passphrase: this.config.str('passphrase')
};

const txs = await this.wallet.createAuctionTxs(options);

this.log(txs);
}

async createTX() {
let output;

Expand Down Expand Up @@ -610,6 +625,9 @@ class CLI {
case 'master':
await this.getMaster();
break;
case 'mkauctiontxs':
await this.createAuctionTxs();
break;
case 'mktx':
await this.createTX();
break;
Expand Down
34 changes: 34 additions & 0 deletions lib/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,23 @@ class WalletClient extends Client {
return this.post(`/wallet/${id}/create`, options);
}

/**
* Create pre-signed bid and reveal txs,
* fill, and optionally sign and broadcast.
* @param {Object} options
* @param {String} options.name
* @param {Number} options.bid
* @param {Number} options.lockup
* @param {String} options.passphrase
* @param {Boolean} options.sign
* @param {Boolean} options.broadcastBid
* @returns {Promise}
*/

createAuctionTxs(id, options) {
return this.post(`/wallet/${id}/auction`, options);
}

/**
* Create a transaction, fill, sign, and broadcast.
* @param {Object} options
Expand Down Expand Up @@ -1158,6 +1175,23 @@ class Wallet extends EventEmitter {
return this.client.createTX(this.id, options);
}

/**
* Create pre-signed bid and reveal txs,
* fill, and optionally sign and broadcast.
* @param {Object} options
* @param {String} options.name
* @param {Number} options.bid
* @param {Number} options.lockup
* @param {String} options.passphrase
* @param {Boolean} options.sign
* @param {Boolean} options.broadcastBid
* @returns {Promise}
*/

createAuctionTxs(options) {
return this.client.createAuctionTxs(this.id, options);
}

/**
* Create a transaction, fill, sign, and broadcast.
* @param {Object} options
Expand Down
144 changes: 144 additions & 0 deletions package-lock.json

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

0 comments on commit 926861b

Please sign in to comment.