Skip to content

Conversation

suhasagg
Copy link
Contributor

  • I added unit tests for any code that added
  • I updated the CHANGELOG.md
  • All IP is original and not copied from another source
  • I assign all copyright to Loom Network for the code in the pull request

Add minting algorithm to dposV3 contract
Adds new MintVouchers method to the DPOS contract that can be called only by delegators



// MintToDPOS adds loom coins to the loom coin DPOS contract balance, and updates the total supply.
func (c *Coin) MintToDPOS(ctx contract.Context, req *MintToDPOSRequest) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't need this, the DPOS contract will only mint ERC20

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.

func MintERC20CmdV3() *cobra.Command {
var flags cli.ContractCallFlags
cmd := &cobra.Command{
Use: "mint-erc20 [amount] [erc20token Address]",
Copy link
Contributor

Choose a reason for hiding this comment

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

-> mint-vouchers

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.


func loadERC20Token(ctx contract.Context, tokenAddr loom.Address) (*erc20Context, error) {
erc20 := newERC20Context(ctx, tokenAddr)
return erc20,nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Formatting

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.

}

//MintVouchers method to the DPOS contract that can be called only by delegators - Mints Loom Coin
func (c *DPOS) MintVoucher(ctx contract.Context, req *MintVoucherRequest) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't need this one.

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.

}

//MintVouchersERC20 method to the DPOS contract that can be called only by delegators - Mints Generic ERC20 Token
func (c *DPOS) MintVoucherERC20(ctx contract.Context, req *MintVoucherERC20Request) error {
Copy link
Contributor

Choose a reason for hiding this comment

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

-> MintVouchers

Copy link
Contributor

Choose a reason for hiding this comment

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

Check req.Amount != nil and greater than zero before doing anything else.

Copy link
Contributor

Choose a reason for hiding this comment

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

And this new method should return an error if dpos:v3.6 feature is not enabled.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added nil check for VoucherTokenAddress as well.

sender := ctx.Message().Sender
for _, d := range delegations {
if loom.UnmarshalAddressPB(d.Delegator).Compare(sender) == 0 {
erc20, err := loadERC20Token(ctx, loom.UnmarshalAddressPB(req.TokenAddress))
Copy link
Contributor

Choose a reason for hiding this comment

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

VoucherTokenAddress should be stored in state.Params.VoucherTokenAddress, not passed in the request.

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

@suhasagg suhasagg force-pushed the Add_Minting_Algorithm_To_DPOS_Contract branch from d4777f7 to 33bb821 Compare July 15, 2019 14:35
@suhasagg suhasagg requested a review from enlight July 22, 2019 05:06
@suhasagg suhasagg self-assigned this Jul 25, 2019
@suhasagg suhasagg assigned suhasagg and unassigned suhasagg Jul 25, 2019
@suhasagg
Copy link
Contributor Author

@enlight
Copy link
Contributor

enlight commented Nov 11, 2019

Will revisit this at a later date.

@enlight enlight closed this Nov 11, 2019
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