Skip to content

Commit 04c7848

Browse files
gzliudanwanwiset25
authored andcommitted
internal/ethapi: refactor func ToMessage for CallArgs
1 parent 1ba51c8 commit 04c7848

File tree

2 files changed

+7
-6
lines changed

2 files changed

+7
-6
lines changed

core/types/transaction.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -778,3 +778,8 @@ func (m Message) CheckNonce() bool { return m.checkNonce }
778778
func (m Message) AccessList() AccessList { return m.accessList }
779779

780780
func (m *Message) SetNonce(nonce uint64) { m.nonce = nonce }
781+
782+
func (m *Message) SetBalanceTokenFeeForCall() {
783+
m.balanceTokenFee = new(big.Int).SetUint64(m.gasLimit)
784+
m.balanceTokenFee.Mul(m.balanceTokenFee, m.gasPrice)
785+
}

internal/ethapi/api.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,6 @@ type CallArgs struct {
12491249
}
12501250

12511251
// ToMessage converts CallArgs to the Message type used by the core evm
1252-
// TODO: set balanceTokenFee
12531252
func (args *CallArgs) ToMessage(b Backend, number *big.Int, globalGasCap uint64) types.Message {
12541253
// Set sender address or use a default if none specified
12551254
var addr common.Address
@@ -1298,11 +1297,7 @@ func (args *CallArgs) ToMessage(b Backend, number *big.Int, globalGasCap uint64)
12981297
accessList = *args.AccessList
12991298
}
13001299

1301-
balanceTokenFee := big.NewInt(0).SetUint64(gas)
1302-
balanceTokenFee = balanceTokenFee.Mul(balanceTokenFee, gasPrice)
1303-
1304-
// Create new call message
1305-
msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, data, accessList, false, balanceTokenFee, number)
1300+
msg := types.NewMessage(addr, args.To, 0, value, gas, gasPrice, data, accessList, false, nil, number)
13061301
return msg
13071302
}
13081303

@@ -1321,6 +1316,7 @@ func DoCall(ctx context.Context, b Backend, args CallArgs, blockNrOrHash rpc.Blo
13211316
}
13221317

13231318
msg := args.ToMessage(b, header.Number, globalGasCap)
1319+
msg.SetBalanceTokenFeeForCall()
13241320

13251321
// Setup context so it may be cancelled the call has completed
13261322
// or, in case of unmetered gas, setup a context with a timeout.

0 commit comments

Comments
 (0)