Skip to content

Commit 2192cc9

Browse files
author
Justin Kook
committed
Revert "Fix data: null for backwards compatibility BWC <= 8.9.0"
This reverts commit dc040c9.
1 parent dc040c9 commit 2192cc9

File tree

3 files changed

+21
-15
lines changed

3 files changed

+21
-15
lines changed

packages/bitcore-wallet-client/src/lib/common/utils.ts

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -355,10 +355,14 @@ export class Utils {
355355

356356
return t;
357357
} else {
358-
const { data, outputs, payProUrl, tokenAddress } = txp;
359-
// Convert toAddress to address
360-
outputs.forEach(output => {
361-
output.address = output.toAddress;
358+
const { data, outputs, payProUrl, tokenAddress } = txp;
359+
const recipients = outputs.map(output => {
360+
return {
361+
amount: output.amount,
362+
address: output.toAddress,
363+
data: output.data,
364+
gasLimit: output.gasLimit
365+
};
362366
});
363367
// Backwards compatibility BWC <= 8.9.0
364368
if (data) {
@@ -367,13 +371,13 @@ export class Utils {
367371
const unsignedTxs = [];
368372
const isERC20 = tokenAddress && !payProUrl;
369373
const chain = isERC20 ? 'ERC20' : this.getChain(coin);
370-
for (let index = 0; index < outputs.length; index++) {
374+
for (let index = 0; index < recipients.length; index++) {
371375
const rawTx = Transactions.create({
372376
...txp,
373-
...outputs[index],
377+
...recipients[index],
374378
chain,
375379
nonce: Number(txp.nonce) + Number(index),
376-
recipients: [outputs[index]]
380+
recipients: [recipients[index]]
377381
});
378382
unsignedTxs.push(rawTx);
379383
}

packages/bitcore-wallet-service/src/lib/chain/eth/index.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -140,22 +140,26 @@ export class EthChain implements IChain {
140140
const { data, outputs, payProUrl, tokenAddress } = txp;
141141
const isERC20 = tokenAddress && !payProUrl;
142142
const chain = isERC20 ? 'ERC20' : 'ETH';
143-
// Convert toAddress to address
144-
outputs.forEach(output => {
145-
output.address = output.toAddress;
143+
const recipients = outputs.map(output => {
144+
return {
145+
amount: output.amount,
146+
address: output.toAddress,
147+
data: output.data,
148+
gasLimit: output.gasLimit
149+
};
146150
});
147151
// Backwards compatibility BWC <= 8.9.0
148152
if (data) {
149153
outputs[0].data = data;
150154
}
151155
const unsignedTxs = [];
152-
for (let index = 0; index < outputs.length; index++) {
156+
for (let index = 0; index < recipients.length; index++) {
153157
const rawTx = Transactions.create({
154158
...txp,
155-
...outputs[index],
159+
...recipients[index],
156160
chain,
157161
nonce: Number(txp.nonce) + Number(index),
158-
recipients: [outputs[index]]
162+
recipients: [recipients[index]]
159163
});
160164
unsignedTxs.push(rawTx);
161165
}

packages/bitcore-wallet-service/test/integration/server.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3177,7 +3177,6 @@ describe('Wallet service', function() {
31773177
tx.gasPrice.should.equal(12300);
31783178
tx.nonce.should.equal('5');
31793179
tx.outputs.should.deep.equal([{
3180-
address: addressStr,
31813180
toAddress: addressStr,
31823181
gasLimit: 21000,
31833182
amount: amount,
@@ -4957,7 +4956,6 @@ describe('#createTX ETH Only tests', () => {
49574956
should.not.exist(err);
49584957
should.exist(tx);
49594958
tx.outputs.should.deep.equal([{
4960-
address: '0x37d7B3bBD88EFdE6a93cF74D2F5b0385D3E3B08A',
49614959
toAddress: '0x37d7B3bBD88EFdE6a93cF74D2F5b0385D3E3B08A',
49624960
gasLimit: 21000,
49634961
amount: amount,

0 commit comments

Comments
 (0)