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

Implement token interactions #16

Merged
merged 23 commits into from
Dec 7, 2020
Merged

Conversation

HristiyanG
Copy link
Contributor

@HristiyanG HristiyanG commented Nov 30, 2020

  • rework [Cashier] requestCreateOrder (renamed to requestCreateOrder_ETH_ETH)
    • accepts array instead of 6 params
    • refactored flow as in some cases will accept too many params and will hit "stack too deep"
  • [Cashier] requestVoucher renamed to requestVoucher_ETH_ETH
  • removed event LogVoucherDelivered from [Cashier] into [VoucherKernel] to keep it consistent as all other voucher logs are emitted from the VoucherKernel
  • created functions
    • requestCreateOrder_TKN_TKN_WithPermit
    • requestCreateOrder_ETH_TKN_WithPermit
    • requestCreateOrder_TKN_ETH_WithPermit
    • requestVoucher_TKN_TKN_WithPermit
    • requestVoucher_ETH_TKN_WithPermit
    • requestVoucher_TKN_ETH_WithPermit
  • withdraw is refactored to pay to participants based on tokensupply payment method
  • added tests and refactored old ones to call the proper functions, or to look for LogVoucherDelivered from the [VoucherKernel] already

contracts/BosonToken.sol Outdated Show resolved Hide resolved
contracts/Cashier.sol Outdated Show resolved Hide resolved
contracts/Cashier.sol Outdated Show resolved Hide resolved
contracts/Cashier.sol Outdated Show resolved Hide resolved
contracts/ERC20WithPermit.sol Outdated Show resolved Hide resolved
contracts/IERC20WithPermit.sol Outdated Show resolved Hide resolved
contracts/VoucherKernel.sol Show resolved Hide resolved
contract BosonToken is ERC20WithPermit, AccessControl {
// SPDX-License-Identifier: MIT

address private owner;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we use Ownable here from OpenZeppelin? If not we would need to also implement transferOwnership - and the other functions there

Copy link
Contributor

Choose a reason for hiding this comment

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

Or we can use the Admin from the AccessControl instead of owner.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

this is fixed in #15

mapping(address => mapping(address => uint256)) public override allowance;

bytes32 public override DOMAIN_SEPARATOR;
bytes32 public override constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry probably we had some misunderstanding on the previous PR. I think it would be helpful if we have the comment here, how this permit hash is constructed, otherwise it just looks like magic.


address public cashierAddress; //address of the Cashier contract

mapping(bytes32 => Promise) public promises; //promises to deliver goods or services
mapping(address => uint256) public tokenNonces;
Copy link
Contributor

Choose a reason for hiding this comment

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

Can you add a comment here why the Nonces are used

@HristiyanG HristiyanG mentioned this pull request Dec 1, 2020
emit LogOrderCreated(tokenIdSupply, msg.sender, metadata[5]);
}

function requestCreateOrder_TKN_ETH_WithPermit(
Copy link
Contributor

Choose a reason for hiding this comment

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

Here, we do not have a Permit, probably wrong name of the function

contracts/Cashier.sol Show resolved Hide resolved
emit LogOrderCreated(tokenIdSupply, msg.sender, metadata[5]);
}

function requestCreateOrder_TKN_TKN_WithPermit(
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need one more set of TKN functions, for tokens that do not support permit - you can use USDC/USDT/DAI as an example, as probably they would be used here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This feature has a separate task. It's not planned for the ongoing sprint.

emit LogVoucherDelivered(_tokenIdSupply, voucherTokenId, _issuer, msg.sender, voucherKernel.getPromiseIdFromVoucherId(voucherTokenId));
}

function requestVoucher_TKN_TKN_WithPermit(
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above, set of functions to support different cases for ETH_TKN, TKN_TKN, TKN_ETH without Permit

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This feature has a separate task. It's not planned for the ongoing sprint.

@HristiyanG HristiyanG merged commit 78cff70 into master Dec 7, 2020
@HristiyanG HristiyanG deleted the implement-token-interactions branch December 7, 2020 14:33
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.

3 participants