Skip to content
Open
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
8 changes: 5 additions & 3 deletions packages/bitcore-wallet-client/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ for (const network in NetworkChar) { // invert NetworkChar
NetworkChar[NetworkChar[network]] = network;
}

const defaultNumberFormat = 'number'; // 'number' | 'string' | 'hex'

const BASE_URL = 'http://localhost:3232/bws/api';

export class API extends EventEmitter {
Expand Down Expand Up @@ -1400,7 +1402,7 @@ export class API extends EventEmitter {
qs.push(`includeExtendedInfo=${opts.includeExtendedInfo ? '1' : '0'}`);
qs.push(`twoStep=${opts.twoStep ? '1' : '0'}`);
qs.push('serverMessageArray=1');
qs.push('numberFormat=hex'); // Only applies to `pendingTxps` in response. TODO apply this to balances as well.
qs.push('numberFormat=' + defaultNumberFormat); // Only applies to `pendingTxps` in response. TODO apply this to balances as well.

if (opts.tokenAddress) {
qs.push('tokenAddress=' + opts.tokenAddress);
Expand Down Expand Up @@ -1732,7 +1734,7 @@ export class API extends EventEmitter {
const args = {
proposalSignature: Utils.signMessage(hash, this.credentials.requestPrivKey)
};
const qs = `numberFormat=${opts.numberFormat || 'hex'}`;
const qs = `numberFormat=${opts.numberFormat || defaultNumberFormat}`;

const url = `/v2/txproposals/${opts.txp.id}/publish?${qs}`;
const { body: txp } = await this.request.post<object, PublishedTxp>(url, args);
Expand Down Expand Up @@ -1937,7 +1939,7 @@ export class API extends EventEmitter {

opts = opts || {};
const { doNotVerify, forAirGapped, doNotEncryptPkr } = opts;
const qs = `numberFormat=${opts.numberFormat || 'hex'}`;
const qs = `numberFormat=${opts.numberFormat || defaultNumberFormat}`;

const { body: txps } = await this.request.get(`/v2/txproposals?${qs}`);
this._processTxps(txps);
Expand Down
4 changes: 2 additions & 2 deletions packages/bitcore-wallet-client/test/api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5451,8 +5451,8 @@ describe('client API', function() {
txp.outputs[0].message.should.equal('output 0');
txp.message.should.equal('hello');
txp.txType.should.equal(2);
txp.maxGasFee.should.equal('0x4e20'); // 20000
txp.priorityGasFee.should.equal('0x1388'); // 5000
txp.maxGasFee.should.equal(20000); // 0x4e20
txp.priorityGasFee.should.equal(5000); // 0x1388
const signatures = await keys[0].sign(clients[0].getRootPath(), txp);
clients[0].pushSignatures(txp, signatures, (err, txp) => {
should.not.exist(err);
Expand Down