|
4 | 4 | "context" |
5 | 5 | "encoding/base64" |
6 | 6 | "fmt" |
| 7 | + "strconv" |
7 | 8 | "strings" |
8 | 9 |
|
9 | 10 | "cosmossdk.io/math" |
@@ -201,21 +202,21 @@ func verifyIDs(ticketMetadata, metadata codec.Layout) error { |
201 | 202 | // verifyActionFee checks if the action fee is sufficient for the given data size |
202 | 203 | // It fetches action parameters, calculates the required fee, and compares it with the action price |
203 | 204 | func (task *CascadeRegistrationTask) verifyActionFee(ctx context.Context, action *actiontypes.Action, dataSize int, fields logtrace.Fields) error { |
204 | | - // Fetch action parameters |
205 | | - params, err := task.lumeraClient.GetActionParams(ctx) |
| 205 | + |
| 206 | + dataSizeInKBs := dataSize / 1024 |
| 207 | + fee, err := task.lumeraClient.GetActionFee(ctx, strconv.Itoa(dataSizeInKBs)) |
206 | 208 | if err != nil { |
207 | | - return task.wrapErr(ctx, "failed to get action parameters", err, fields) |
| 209 | + return task.wrapErr(ctx, "failed to get action fee", err, fields) |
208 | 210 | } |
209 | 211 |
|
210 | | - // Get base fee and fee per byte |
211 | | - baseFee := params.Params.BaseActionFee |
212 | | - feePerByte := params.Params.FeePerByte.Amount |
| 212 | + // Parse fee amount from string to int64 |
| 213 | + amount, err := strconv.ParseInt(fee.Amount, 10, 64) |
| 214 | + if err != nil { |
| 215 | + return task.wrapErr(ctx, "failed to parse fee amount", err, fields) |
| 216 | + } |
213 | 217 |
|
214 | 218 | // Calculate per-byte fee based on data size |
215 | | - perByteFee := sdk.NewCoin(baseFee.Denom, feePerByte.Mul(math.NewInt(int64(dataSize)))) |
216 | | - |
217 | | - // Calculate total fee |
218 | | - requiredFee := baseFee.Add(perByteFee) |
| 219 | + requiredFee := sdk.NewCoin("ulume", math.NewInt(amount)) |
219 | 220 |
|
220 | 221 | // Log the calculated fee |
221 | 222 | logtrace.Info(ctx, "calculated required fee", logtrace.Fields{ |
|
0 commit comments