From 85c0bf9099335143e9b1099bc7a0ca1188265c14 Mon Sep 17 00:00:00 2001 From: Laurent Le Houerou Date: Mon, 18 Apr 2022 16:11:14 +0400 Subject: [PATCH] add galactic punks staking contract --- protocols/galacticpunks/staking.go | 32 ++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 protocols/galacticpunks/staking.go diff --git a/protocols/galacticpunks/staking.go b/protocols/galacticpunks/staking.go new file mode 100644 index 0000000..e3d70cb --- /dev/null +++ b/protocols/galacticpunks/staking.go @@ -0,0 +1,32 @@ +package galacticpunks + +import ( + "github.com/galacticship/terra" + "github.com/galacticship/terra/cosmos" + "github.com/pkg/errors" +) + +type Staking struct { + *terra.Contract +} + +func NewStaking(querier *terra.Querier) (*Staking, error) { + contract, err := terra.NewContract(querier, "terra10t4pgfs6s3qeykqgfq9r74s89jmu7zx5gfkga5") + if err != nil { + return nil, errors.Wrap(err, "init contract object") + } + + return &Staking{ + Contract: contract, + }, nil +} + +func (s *Staking) NewWithdrawRewardsMessage(sender cosmos.AccAddress, tokenId string) (cosmos.Msg, error) { + var q struct { + WithdrawRewards struct { + TokenId string `json:"token_id"` + } `json:"withdraw_rewards"` + } + q.WithdrawRewards.TokenId = tokenId + return s.NewMsgExecuteContract(sender, q) +}