Skip to content

feat: balance event timestamps#78

Merged
benjlevesque merged 7 commits into
masterfrom
balance-events-timestamp
Dec 9, 2019
Merged

feat: balance event timestamps#78
benjlevesque merged 7 commits into
masterfrom
balance-events-timestamp

Conversation

@benjlevesque
Copy link
Copy Markdown
Contributor

Description of the changes

  • always have timestamp on balance events
  • add txHash & block on balance events of ERC20
  • Refactoring of payment detection:
    • unification of variable names
    • strong typings

Link to Jira

PROT-1042
PROT-1043

@benjlevesque benjlevesque force-pushed the balance-events-timestamp branch 2 times, most recently from d69f56b to e123cf7 Compare December 5, 2019 16:51
Copy link
Copy Markdown
Contributor

@vrolland vrolland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good move. Nice to see improvements of this part of code.

I have a concern about the amount outside event.parameters, see comments.

(a: Types.IPaymentNetworkEvent, b: Types.IPaymentNetworkEvent) =>
a.parameters.timestamp - b.parameters.timestamp,
const events: Types.BTCPaymentNetworkEvent[] = [...payments.events, ...refunds.events].sort(
(a, b) => (a.timestamp || 0) - (b.timestamp || 0),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

less typing but more clarity... @romaric-juniet's brain may explode! 😄

.map(
(tx: any): Types.IPaymentNetworkEvent => ({
(tx: any): Types.BTCPaymentNetworkEvent => ({
amount: tx.value.toString(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imo, amount should stay in event.parameters because all the events won't have necessary an amount. (e.g "deny a payment")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This may need to be discussed with the team

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

discussed with Vince, we agreed that it's OK to have an amount of 0 for specific events.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to be included in this discussion. I'm not sure this makes a lot of sense to me.

timestamp: output.timestamp,
txHash: output.txHash,
},
timestamp: output.timestamp,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

timestamp outside parameters make more sense! 👍

Copy link
Copy Markdown
Contributor

@vrolland vrolland left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🖐️

Comment thread packages/integration-test/test/erc20.test.ts Outdated
.map(
(tx: any): Types.IPaymentNetworkEvent => ({
(tx: any): Types.BTCPaymentNetworkEvent => ({
amount: tx.value.toString(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would like to be included in this discussion. I'm not sure this makes a lot of sense to me.

'0x627306090abaB3A6e1400e9345bC60c78a8BEf57',
);
expect(balance.events[0].parameters.value).to.be.equal('10');
// TODO: add to & from to parameters?
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

forgotten?

Comment thread packages/request-client.js/src/types.ts
Comment thread packages/request-client.js/src/api/payment-network/erc20/info-retriever.ts Outdated
});
// Clean up the Transfer logs data
const events = await Bluebird.map(logs, async log => {
if (!log.blockNumber) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If this can actually fail, it may mean we need some other considerations on the code. For example, to wait block confirmations.

@benjlevesque benjlevesque force-pushed the balance-events-timestamp branch from 255bbd7 to dff55fd Compare December 9, 2019 09:26
@coveralls
Copy link
Copy Markdown

Coverage Status

Coverage decreased (-0.2%) to 90.615% when pulling dff55fd on balance-events-timestamp into 61664cd on master.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants