-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: smart-contract deployment command + eth_call cmd (#30)
- Loading branch information
Showing
6 changed files
with
92 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package evmos | ||
|
||
import ( | ||
"fmt" | ||
"os" | ||
|
||
"github.com/hanchon/hanchond/playground/evmos" | ||
"github.com/hanchon/hanchond/playground/sql" | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
// ethCodeCmd represents the ethCode command | ||
var ethCodeCmd = &cobra.Command{ | ||
Use: "eth-code [address]", | ||
Args: cobra.ExactArgs(1), | ||
Short: "Get the smartcontract registered eth code", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
queries := sql.InitDBFromCmd(cmd) | ||
nodeID, err := cmd.Flags().GetString("node") | ||
if err != nil { | ||
fmt.Println("node not set") | ||
os.Exit(1) | ||
} | ||
height, err := cmd.Flags().GetString("height") | ||
if err != nil { | ||
fmt.Println("error getting the request height:", err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
e := evmos.NewEvmosFromDB(queries, nodeID) | ||
client := e.NewRequester() | ||
|
||
code, err := client.EthCode(args[0], height) | ||
if err != nil { | ||
fmt.Println("could not get the ethCode:", err.Error()) | ||
os.Exit(1) | ||
} | ||
|
||
fmt.Println(string(code)) | ||
}, | ||
} | ||
|
||
func init() { | ||
EvmosCmd.AddCommand(ethCodeCmd) | ||
ethCodeCmd.Flags().String("height", "latest", "Query at the given height.") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# Eth Code | ||
|
||
The command `eth-code` returns the smart-contract bytecode. | ||
|
||
```sh | ||
hanchond playground query evmos eth-code 0xc0ac82342eacc3e5d38744660f7a57f465568746 | jq . | ||
{ | ||
"jsonrpc": "2.0", | ||
"id": 1, | ||
"result": "0x6080604052348015600f57600080fd5b506004361060285760003560e01c80631627905514602d575b600080fd5b605060048036036020811015604157600080fd5b50356001600160a01b03166064565b604080519115158252519081900360200190f35b6000813f7fc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470818114801590609757508115155b94935050505056fea264697066735822122030375d12bcd1c1173c9972f2bab6ba2db059fae1a35020cc0d1115194a8b445464736f6c634300060c0033" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters