Skip to content

Commit

Permalink
remove ctx, keep fungible keeper private
Browse files Browse the repository at this point in the history
  • Loading branch information
fbac committed Aug 20, 2024
1 parent 3a31ddb commit fe78f69
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 9 deletions.
4 changes: 2 additions & 2 deletions precompiles/precompiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ func StatefulContracts(

// Define the regular contract function.
if EnabledStatefulContracts[prototype.ContractAddress] {
prototype := func(ctx sdktypes.Context, _ ethparams.Rules) vm.PrecompiledContract {
return prototype.NewIPrototypeContract(ctx, fungibleKeeper, cdc, gasConfig)
prototype := func(_ sdktypes.Context, _ ethparams.Rules) vm.PrecompiledContract {
return prototype.NewIPrototypeContract(fungibleKeeper, cdc, gasConfig)
}

// Append the regular contract to the precompiledContracts slice.
Expand Down
9 changes: 3 additions & 6 deletions precompiles/prototype/prototype.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,22 +65,19 @@ func init() {
type Contract struct {
ptypes.BaseContract

Ctx sdk.Context
FungibleKeeper fungiblekeeper.Keeper
fungibleKeeper fungiblekeeper.Keeper
cdc codec.Codec
kvGasConfig storetypes.GasConfig
}

func NewIPrototypeContract(
context sdk.Context,
fungibleKeeper *fungiblekeeper.Keeper,
cdc codec.Codec,
kvGasConfig storetypes.GasConfig,
) *Contract {
return &Contract{
Ctx: context,
BaseContract: ptypes.NewBaseContract(ContractAddress),
FungibleKeeper: *fungibleKeeper,
fungibleKeeper: *fungibleKeeper,
cdc: cdc,
kvGasConfig: kvGasConfig,
}
Expand Down Expand Up @@ -213,7 +210,7 @@ func (c *Contract) GetGasStabilityPoolBalance(
}
}

balance, err := c.FungibleKeeper.GetGasStabilityPoolBalance(ctx, chainID)
balance, err := c.fungibleKeeper.GetGasStabilityPoolBalance(ctx, chainID)
if err != nil {
return nil, fmt.Errorf("error calling fungible keeper: %s", err.Error())
}
Expand Down
3 changes: 2 additions & 1 deletion precompiles/prototype/prototype_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func Test_IPrototypeContract(t *testing.T) {
/*
Configuration
*/

var encoding ethermint.EncodingConfig
appCodec := encoding.Codec
k, ctx, _, _ := keeper.FungibleKeeper(t)
Expand All @@ -24,7 +25,7 @@ func Test_IPrototypeContract(t *testing.T) {
*/

// Create a new IPrototypeContract instance and get Address and Abi.
contract := NewIPrototypeContract(ctx, k, appCodec, gasConfig)
contract := NewIPrototypeContract(k, appCodec, gasConfig)
require.NotNil(t, contract, "NewIPrototypeContract() should not return a nil contract")

address := contract.Address()
Expand Down

0 comments on commit fe78f69

Please sign in to comment.