-
Notifications
You must be signed in to change notification settings - Fork 31
Add minting algorithm to dposV3 contract #1334
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
Conversation
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 { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
cmd/loom/dposV3_commands.go
Outdated
func MintERC20CmdV3() *cobra.Command { | ||
var flags cli.ContractCallFlags | ||
cmd := &cobra.Command{ | ||
Use: "mint-erc20 [amount] [erc20token Address]", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> mint-vouchers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
builtin/plugins/dposv3/dpos.go
Outdated
|
||
func loadERC20Token(ctx contract.Context, tokenAddr loom.Address) (*erc20Context, error) { | ||
erc20 := newERC20Context(ctx, tokenAddr) | ||
return erc20,nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Formatting
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
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 { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-> MintVouchers
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
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)) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
…ontract balance, and updates the total supply.
2)Add req.Amount=nil or zero check
d4777f7
to
33bb821
Compare
…oomnetwork/loomchain into Add_Minting_Algorithm_To_DPOS_Contract
In this case minting does not take place as request must come from a delegator
(require msg.sender == dpos) This is for access control for minting SampleERC20Token.sol
https://ci.kanwisher.com/blue/organizations/jenkins/loom-sdk-pipeline-prbuilder/detail/loom-sdk-pipeline-prbuilder/5138/pipeline/ Replayed build is building fine. |
Will revisit this at a later date. |
Add minting algorithm to dposV3 contract
Adds new MintVouchers method to the DPOS contract that can be called only by delegators