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

Allows DR creation without the need for activation by protocol admin #466

Merged
merged 12 commits into from
Nov 17, 2022

Conversation

anajuliabit
Copy link
Contributor

@anajuliabit anajuliabit commented Nov 14, 2022

This PR allows DR creation without the need for activation by protocol admin.

Contracts changes:

  • Remove activateDisputeResolver function
  • createDisputeResolver:
    • Reverts if active = false
    • Reverts if feeAmount != 0
  • addFeesToDisputeResolver:
    • Reverts if feeAmount != 0
  • Comment code related to feeAmount on storeOffer

Scripts changes

  • Rename create-and-activate-DR -> create-DR and refactor the code to remove activeDisputeResolver calls
  • Remove activateDisputeResolver from estimate-limits

Unit tests

  • Fixes broken unit tests
  • Add new tests related to new revert reasons on createDisputeResolver and addFeesToDisputeResolver
  • Skip tests that depend on feeAmount != 0

@anajuliabit anajuliabit changed the title Dr actived Allow DR to be activated when creating Nov 15, 2022
@anajuliabit anajuliabit changed the title Allow DR to be activated when creating Allows DR creation without the need for activation by protocol admin Nov 15, 2022
@anajuliabit anajuliabit marked this pull request as ready for review November 15, 2022 18:19
@anajuliabit anajuliabit self-assigned this Nov 15, 2022
Copy link
Contributor

@cliffhall cliffhall left a comment

Choose a reason for hiding this comment

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

Just a few cosmetic things and a couple of questions.

*
* @param _disputeResolverId - id of the dispute resolver
* @param _disputeResolverFees - list of fees dispute resolver charges per token type. Zero address is native currency. See {BosonTypes.DisputeResolverFee}
feeAmount will be ignored because protocol doesn't yet support fees yet but DR still needs to provide array of fees to choose supported tokens
Copy link
Contributor

Choose a reason for hiding this comment

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

This long line should be broken into multiple lines with in the comment each with * on the left like normal comment lines.
Screen Shot 2022-11-15 at 2 47 47 PM

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

@@ -177,15 +173,16 @@ contract OfferBase is ProtocolBase, IBosonOfferEvents {
uint256 feeIndex = lookups.disputeResolverFeeTokenIndex[_disputeResolverId][_offer.exchangeToken];
require(feeIndex > 0, DR_UNSUPPORTED_FEE);

uint256 feeAmount = disputeResolverFees[feeIndex - 1].feeAmount;
// uint256 feeAmount = disputeResolverFees[feeIndex - 1].feeAmount;
Copy link
Contributor

Choose a reason for hiding this comment

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

add the // Protocol doesn't yet support DR fees comment above

Copy link
Member

Choose a reason for hiding this comment

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

I believe that we should simply keep this in. Yes, it is a redundant operation, since feeAmount will be always zero (which is effectively the same as it is now). But if we comment this out and want that the change is actually applied to diamon, we need to upgrade both OfferHandler and OrchestrationHandler.

Then when we finally enable non-zero fee amount, we'd need to do the upgrade again (or at least do the cuts to point back to the current implementation).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I put it back

*
* @param _disputeResolver - the fully populated struct with dispute resolver id set to 0x0
* @param _disputeResolverFees - array of fees dispute resolver charges per token type. Zero address is native currency. Can be empty.
* @param _disputeResolverFees - list of fees dispute resolver charges per token type. Zero address is native currency. See {BosonTypes.DisputeResolverFee}
feeAmount will be ignored because protocol doesn't yet support DR fees but DR still needs to provide array of fees to choose supported tokens
Copy link
Contributor

Choose a reason for hiding this comment

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

See the comment for this function in the IBosonAccountHandler interface 👆

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

* @param _sellerAllowList - list of ids of sellers that can choose this dispute resolver. If empty, there are no restrictions on which seller can chose it.
*/
function createDisputeResolver(
DisputeResolver memory _disputeResolver,
DisputeResolverFee[] calldata _disputeResolverFees,
DisputeResolverFee[] memory _disputeResolverFees,
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does _disputeResolverFees change from calldata to memory?

Copy link
Contributor Author

@anajuliabit anajuliabit Nov 16, 2022

Choose a reason for hiding this comment

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

I changed it because at first I was setting feeAmount = 0 but I forgot to put it back to calldata after we decided to revert instead of set to 0. Fixed

*
* @param _disputeResolverId - id of the dispute resolver
* @param _disputeResolverFees - list of fees dispute resolver charges per token type. Zero address is native currency. See {BosonTypes.DisputeResolverFee}
feeAmount will be ignored because protocol doesn't yet support DR fees but DR still needs to provide array of fees to choose supported tokens
Copy link
Contributor

Choose a reason for hiding this comment

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

See the comment in the IBosonAccountHandler interface 👆

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed

test/protocol/OfferHandlerTest.js Show resolved Hide resolved
test/protocol/OfferHandlerTest.js Show resolved Hide resolved
@@ -253,13 +253,13 @@ describe("IBosonOrchestrationHandler", function () {
adminDR.address,
clerkDR.address,
treasuryDR.address,
false
true
);
expect(disputeResolver.isValid()).is.true;

//Create DisputeResolverFee array so offer creation will succeed
Copy link
Contributor

Choose a reason for hiding this comment

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

I know it was pre-existing, but could you also fix this while you're at it? I've noticed these are randomly sprinkled around, we should fix as we go.
//Create // Create

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

test/protocol/OrchestrationHandlerTest.js Show resolved Hide resolved
test/protocol/OrchestrationHandlerTest.js Show resolved Hide resolved
contracts/interfaces/handlers/IBosonAccountHandler.sol Outdated Show resolved Hide resolved
@@ -177,15 +173,16 @@ contract OfferBase is ProtocolBase, IBosonOfferEvents {
uint256 feeIndex = lookups.disputeResolverFeeTokenIndex[_disputeResolverId][_offer.exchangeToken];
require(feeIndex > 0, DR_UNSUPPORTED_FEE);

uint256 feeAmount = disputeResolverFees[feeIndex - 1].feeAmount;
// uint256 feeAmount = disputeResolverFees[feeIndex - 1].feeAmount;
Copy link
Member

Choose a reason for hiding this comment

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

I believe that we should simply keep this in. Yes, it is a redundant operation, since feeAmount will be always zero (which is effectively the same as it is now). But if we comment this out and want that the change is actually applied to diamon, we need to upgrade both OfferHandler and OrchestrationHandler.

Then when we finally enable non-zero fee amount, we'd need to do the upgrade again (or at least do the cuts to point back to the current implementation).

scripts/util/create-DR.js Outdated Show resolved Hide resolved
scripts/util/estimate-limits.js Show resolved Hide resolved
zajck
zajck previously approved these changes Nov 16, 2022
@@ -44,7 +43,7 @@ const addressNotFound = (address) => {
process.exit(1);
};

const createAndActivateDR = async (path, createOnly, activateOnly) => {
const createDR = async (path) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Since this method name is shorter now, I believe we should call it createDisputeResolver. We don't want to abbreviate unless we have to.

hswopeams
hswopeams previously approved these changes Nov 16, 2022
@anajuliabit anajuliabit dismissed stale reviews from hswopeams and zajck via bd3f82f November 17, 2022 13:59
Copy link
Contributor

@cliffhall cliffhall left a comment

Choose a reason for hiding this comment

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

LGTM! 👍

@cliffhall cliffhall merged commit 5489ea6 into main Nov 17, 2022
@zajck zajck deleted the dr_actived branch November 17, 2022 16:23
@anajuliabit anajuliabit mentioned this pull request Dec 30, 2022
38 tasks
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.

4 participants