Skip to content

Commit

Permalink
totalUnits fees.Add
Browse files Browse the repository at this point in the history
  • Loading branch information
wlawt committed Apr 25, 2024
1 parent a9693dd commit d4fa834
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
3 changes: 1 addition & 2 deletions chain/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -454,7 +454,6 @@ func (t *Transaction) marshalActions(p *codec.Packer) error {
func unmarshalActions(
p *codec.Packer,
actionRegistry *codec.TypeParser[Action, bool],
authRegistry *codec.TypeParser[Auth, bool],
) ([]Action, error) {
actionCount := p.UnpackInt(true)
actions := make([]Action, 0)
Expand Down Expand Up @@ -523,7 +522,7 @@ func UnmarshalTx(
if err != nil {
return nil, fmt.Errorf("%w: could not unmarshal base", err)
}
actions, err := unmarshalActions(p, actionRegistry, authRegistry)
actions, err := unmarshalActions(p, actionRegistry)
if err != nil {
return nil, fmt.Errorf("%w: could not unmarshal actions", err)
}
Expand Down
5 changes: 3 additions & 2 deletions rpc/jsonrpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,17 @@ func (cli *JSONRPCClient) GenerateTransaction(
return nil, nil, 0, err
}

var totalUnits fees.Dimensions
totalUnits := fees.Dimensions{}
for _, action := range actions {
maxUnits, err := chain.EstimateMaxUnits(parser.Rules(time.Now().UnixMilli()), action, authFactory)
if err != nil {
return nil, nil, 0, err
}
totalUnits, err = fees.Add(totalUnits, maxUnits)
nTotalUnits, err := fees.Add(totalUnits, maxUnits)
if err != nil {
return nil, nil, 0, err
}
totalUnits = nTotalUnits
}
maxFee, err := fees.MulSum(unitPrices, totalUnits)
if err != nil {
Expand Down

0 comments on commit d4fa834

Please sign in to comment.