Skip to content

Commit

Permalink
Rename RewardAddresses to ValidationRewardsOwners (#240)
Browse files Browse the repository at this point in the history
  • Loading branch information
dhrubabasu authored Feb 26, 2024
1 parent 3fad5f7 commit 5ec3965
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 22 deletions.
9 changes: 7 additions & 2 deletions mapper/pchain/tx_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ func buildAddValidatorTx(
}

rewardsOwner, err := buildOutputOwner(
metadata.RewardAddresses,
metadata.ValidationRewardsOwners,
metadata.Locktime,
metadata.Threshold,
)
Expand Down Expand Up @@ -203,7 +203,12 @@ func buildAddDelegatorTx(
if err != nil {
return nil, nil, err
}
rewardsOwner, err := buildOutputOwner(metadata.RewardAddresses, metadata.Locktime, metadata.Threshold)

rewardsOwner, err := buildOutputOwner(
metadata.ValidationRewardsOwners,
metadata.Locktime,
metadata.Threshold,
)
if err != nil {
return nil, nil, err
}
Expand Down
16 changes: 8 additions & 8 deletions mapper/pchain/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ type ExportMetadata struct {

// StakingMetadata contain response fields returned by /construction/metadata for P-chain AddValidator/AddDelegator transactions
type StakingMetadata struct {
NodeID string `json:"node_id"`
RewardAddresses []string `json:"reward_addresses"`
Start uint64 `json:"start"`
End uint64 `json:"end"`
Shares uint32 `json:"shares"`
Locktime uint64 `json:"locktime"`
Threshold uint32 `json:"threshold"`
Memo string `json:"memo"`
NodeID string `json:"node_id"`
ValidationRewardsOwners []string `json:"reward_addresses"`
Start uint64 `json:"start"`
End uint64 `json:"end"`
Shares uint32 `json:"shares"`
Locktime uint64 `json:"locktime"`
Threshold uint32 `json:"threshold"`
Memo string `json:"memo"`
}
24 changes: 12 additions & 12 deletions service/backend/pchain/construction.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,20 +156,20 @@ func buildStakingMetadata(options map[string]interface{}) (*pmapper.Metadata, *t
return nil, nil, err
}

stakingMetadata := &pmapper.StakingMetadata{
NodeID: preprocessOptions.NodeID,
Start: preprocessOptions.Start,
End: preprocessOptions.End,
Memo: preprocessOptions.Memo,
Locktime: preprocessOptions.Locktime,
Threshold: preprocessOptions.Threshold,
RewardAddresses: preprocessOptions.RewardAddresses,
Shares: preprocessOptions.Shares,
}

zeroAvax := mapper.AtomicAvaxAmount(big.NewInt(0))

return &pmapper.Metadata{StakingMetadata: stakingMetadata}, zeroAvax, nil
return &pmapper.Metadata{
StakingMetadata: &pmapper.StakingMetadata{
NodeID: preprocessOptions.NodeID,
Start: preprocessOptions.Start,
End: preprocessOptions.End,
Memo: preprocessOptions.Memo,
Locktime: preprocessOptions.Locktime,
Threshold: preprocessOptions.Threshold,
ValidationRewardsOwners: preprocessOptions.RewardAddresses,
Shares: preprocessOptions.Shares,
},
}, zeroAvax, nil
}

func (b *Backend) getBaseTxFee(ctx context.Context) (*types.Amount, error) {
Expand Down

0 comments on commit 5ec3965

Please sign in to comment.