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

Change: node-dlc post163 integration #136

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

maxpolizzo
Copy link
Collaborator

@maxpolizzo maxpolizzo commented Aug 5, 2023

Changes for compatibility with post-163 node-dlc dependencies (see node-dlc PR 187)

To do before merging to master:

  • node-dlc dependencies should be fixed once v0.21.5 is published to NPM (currently those are pointing to local node-dlc packages)
  • Version numbers of modified packages should be incremented

@changeset-bot
Copy link

changeset-bot bot commented Aug 5, 2023

⚠️ No Changeset found

Latest commit: f8bff38

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@maxpolizzo maxpolizzo force-pushed the maxpolizzo/dlc-specs-163 branch 2 times, most recently from 3d2359b to 57c9b94 Compare August 25, 2023 02:01
@maxpolizzo maxpolizzo force-pushed the maxpolizzo/dlc-specs-163 branch from 57c9b94 to f8bff38 Compare August 28, 2023 22:32
@maxpolizzo maxpolizzo changed the title WIP Change: node-dlc post163 integration Change: node-dlc post163 integration Aug 28, 2023
Copy link
Contributor

@matthewjablack matthewjablack left a comment

Choose a reason for hiding this comment

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

Thanks for this great work @maxpolizzo

Looking forward to taking another look at this after node-dlc is finalized


// Assign unique temporaryContractId to finalize DLC offer
const dlcOffer = tempDlcOffer;
dlcOffer.temporaryContractId = sha256(tempDlcOffer.serialize());
Copy link
Contributor

Choose a reason for hiding this comment

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

At first glance, I was concerned about what if a user created two offers back to back (if the first one failed for example) which would result in an identical temporaryContractId. However, if they call createDlcOffer again, it'll randomly generate new serial ids, which should result in a different temporaryContractId

This LGTM 👍


// The following line is commented out because specifying empty
// negotiationFields causes dlcAccept serialization to fail
// dlcAccept.negotiationFields = new SingleNegotiationFields();
Copy link
Contributor

Choose a reason for hiding this comment

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

This makes sense since negotiationFields was made an optional field in the DlcAccept in https://github.com/discreetlogcontracts/dlcspecs/pull/163/files#diff-e0f5b925f91a1c09c6daf26f9a7d28816cb9ff9f08863faca719b7ee0a1cc065R204

Looks good to remove 👍

A future iteration of this could include the option to provide negotiation fields, but this can be added later.

(a, b) => Number(a.endpoint) - Number(b.endpoint),
// Deep copy payoutFunction.pieces into piecesSorted to prevent sorting the
// original payoutFunction.pieces array with .sort()
const piecesSorted = Object.assign([], payoutFunction.pieces);
Copy link
Contributor

Choose a reason for hiding this comment

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

Good catch 👍

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.

2 participants