Skip to content

Add minting algorithm to dposV3 contract - #1334

Closed
suhasagg wants to merge 65 commits into
masterfrom
Add_Minting_Algorithm_To_DPOS_Contract
Closed

Add minting algorithm to dposV3 contract#1334
suhasagg wants to merge 65 commits into
masterfrom
Add_Minting_Algorithm_To_DPOS_Contract

Conversation

@suhasagg

Copy link
Copy Markdown
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

Comment thread builtin/plugins/coin/coin.go Outdated


// 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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread cmd/loom/dposV3_commands.go Outdated
func MintERC20CmdV3() *cobra.Command {
var flags cli.ContractCallFlags
cmd := &cobra.Command{
Use: "mint-erc20 [amount] [erc20token Address]",

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.

-> mint-vouchers

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.

Done.

Comment thread builtin/plugins/dposv3/dpos.go Outdated

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

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.

Formatting

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.

Done.

Comment thread builtin/plugins/dposv3/dpos.go Outdated
}

//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
Copy Markdown
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
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done.

Comment thread builtin/plugins/dposv3/dpos.go Outdated
}

//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
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

-> MintVouchers

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.

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

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.

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

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.

Added nil check for VoucherTokenAddress as well.

Comment thread builtin/plugins/dposv3/dpos.go Outdated
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Contributor Author

@enlight

enlight commented Nov 11, 2019

Copy link
Copy Markdown
Contributor

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