Skip to content

Commit

Permalink
rename and generate bindings automatically
Browse files Browse the repository at this point in the history
  • Loading branch information
fbac committed Aug 19, 2024
1 parent ddee0c5 commit c1d41e2
Show file tree
Hide file tree
Showing 15 changed files with 424 additions and 756 deletions.
4 changes: 2 additions & 2 deletions e2e/e2etests/test_precompiles_regular.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ import (
"github.com/stretchr/testify/require"

"github.com/zeta-chain/zetacore/e2e/runner"
"github.com/zeta-chain/zetacore/precompiles/regular"
"github.com/zeta-chain/zetacore/precompiles/prototype"
)

func TestPrecompilesRegular(r *runner.E2ERunner, args []string) {
require.Len(r, args, 0, "No arguments expected")

caller, err := regular.NewRegularCaller(regular.ContractAddress, r.ZEVMClient)
caller, err := prototype.NewIPrototypeCaller(prototype.ContractAddress, r.ZEVMClient)
require.NoError(r, err, "Failed to create precompiled contract caller")

res, err := caller.Bech32ify(nil, "zeta", common.HexToAddress("0xB9Dbc229Bf588A613C00BEE8e662727AB8121cfE"))
Expand Down
8 changes: 4 additions & 4 deletions precompiles/precompiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import (
ethparams "github.com/ethereum/go-ethereum/params"
evmkeeper "github.com/zeta-chain/ethermint/x/evm/keeper"

"github.com/zeta-chain/zetacore/precompiles/regular"
"github.com/zeta-chain/zetacore/precompiles/prototype"
"github.com/zeta-chain/zetacore/x/fungible/keeper"
)

var EnabledStatefulContracts = map[common.Address]bool{
regular.ContractAddress: true,
prototype.ContractAddress: true,
}

// StatefulContracts returns all the registered precompiled contracts.
Expand All @@ -27,9 +27,9 @@ func StatefulContracts(
precompiledContracts = make([]evmkeeper.CustomContractFn, 0)

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

Check warning on line 32 in precompiles/precompiles.go

View check run for this annotation

Codecov / codecov/patch

precompiles/precompiles.go#L32

Added line #L32 was not covered by tests
}

// Append the regular contract to the precompiledContracts slice.
Expand Down
69 changes: 69 additions & 0 deletions precompiles/prototype/IPrototype.abi
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
[
{
"inputs": [
{
"internalType": "string",
"name": "bech32",
"type": "string"
}
],
"name": "bech32ToHexAddr",
"outputs": [
{
"internalType": "address",
"name": "addr",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "prefix",
"type": "string"
},
{
"internalType": "address",
"name": "addr",
"type": "address"
}
],
"name": "bech32ify",
"outputs": [
{
"internalType": "string",
"name": "bech32",
"type": "string"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [
{
"internalType": "string",
"name": "method",
"type": "string"
},
{
"internalType": "address",
"name": "addr",
"type": "address"
}
],
"name": "regularCall",
"outputs": [
{
"internalType": "uint256",
"name": "result",
"type": "uint256"
}
],
"stateMutability": "nonpayable",
"type": "function"
}
]
264 changes: 264 additions & 0 deletions precompiles/prototype/IPrototype.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c1d41e2

Please sign in to comment.