aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
diff options
context:
space:
mode:
authorElad <theman@elad.im>2019-03-20 16:33:24 +0800
committerViktor TrĂ³n <viktor.tron@gmail.com>2019-03-20 16:33:24 +0800
commite7d1867964734cfa4c1067944f213ba5aaceffe1 (patch)
treeca09fbba4c68fe32a1c952160a24776dd27622d9 /cmd
parentfb458280d1b0b90156745202677dabbc74187697 (diff)
downloadgo-tangerine-e7d1867964734cfa4c1067944f213ba5aaceffe1.tar
go-tangerine-e7d1867964734cfa4c1067944f213ba5aaceffe1.tar.gz
go-tangerine-e7d1867964734cfa4c1067944f213ba5aaceffe1.tar.bz2
go-tangerine-e7d1867964734cfa4c1067944f213ba5aaceffe1.tar.lz
go-tangerine-e7d1867964734cfa4c1067944f213ba5aaceffe1.tar.xz
go-tangerine-e7d1867964734cfa4c1067944f213ba5aaceffe1.tar.zst
go-tangerine-e7d1867964734cfa4c1067944f213ba5aaceffe1.zip
contracts, swarm: implement EIP-1577 (#19285)
* contracts/ens: update public resolver solidity code * contracts/ens: update public resolver, update go bindings * update build * fix ens.sol * contracts/ens: change contract interface * contracts/ens: implement public resolver changes * contracts/ens: added ENSRegistry contract * contracts/ens: reinstate old contract code * contracts/ens: update README.md * contracts/ens: added test coverage for fallback contract * contracts/ens: added support for fallback contract * contracts/ens: removed unused contract code * contracts/ens: add todo and decode multicodec stub * add encode * vendor: add ipfs cid libraries * contracts/ens: cid sanity tests * contracts/ens: more cid sanity checks * contracts/ens: wip integration * wip * Revert "vendor: add ipfs cid libraries" This reverts commit 29d9b6b294ded903a1065d96c8149119713cfd12. * contracts/ens: removed multiformats dependencies * contracts/ens: added decode tests * contracts/ens: added eip spec test, minor changes to exiting tests * contracts/ens: moved cid decoding to own file * contracts/ens: added unit test to encode hash to content hash * contracts/ens: removed unused code * contracts/ens: fix ens tests to use cid decode and encode * contracts/ens: adjust swarm multicodecs after pr merge * contracts/ens: fix linter error * constracts/ens: address PR comments * cmd, contracts: make peoples lives easier * contracts/ens: fix linter error * contracts/ens: address PR comments
Diffstat (limited to 'cmd')
-rw-r--r--cmd/swarm/hash.go59
1 files changed, 58 insertions, 1 deletions
diff --git a/cmd/swarm/hash.go b/cmd/swarm/hash.go
index 471feb53d..2df02c0ed 100644
--- a/cmd/swarm/hash.go
+++ b/cmd/swarm/hash.go
@@ -19,10 +19,13 @@ package main
import (
"context"
+ "encoding/hex"
"fmt"
"os"
"github.com/ethereum/go-ethereum/cmd/utils"
+ "github.com/ethereum/go-ethereum/common"
+ "github.com/ethereum/go-ethereum/contracts/ens"
"github.com/ethereum/go-ethereum/swarm/storage"
"gopkg.in/urfave/cli.v1"
)
@@ -34,7 +37,33 @@ var hashCommand = cli.Command{
Usage: "print the swarm hash of a file or directory",
ArgsUsage: "<file>",
Description: "Prints the swarm hash of file or directory",
-}
+ Subcommands: []cli.Command{
+ {
+ CustomHelpTemplate: helpTemplate,
+ Name: "ens",
+ Usage: "converts a swarm hash to an ens EIP1577 compatible CIDv1 hash",
+ ArgsUsage: "<ref>",
+ Description: "",
+ Subcommands: []cli.Command{
+ {
+ Action: encodeEipHash,
+ CustomHelpTemplate: helpTemplate,
+ Name: "contenthash",
+ Usage: "converts a swarm hash to an ens EIP1577 compatible CIDv1 hash",
+ ArgsUsage: "<ref>",
+ Description: "",
+ },
+ {
+ Action: ensNodeHash,
+ CustomHelpTemplate: helpTemplate,
+ Name: "node",
+ Usage: "converts an ens name to an ENS node hash",
+ ArgsUsage: "<ref>",
+ Description: "",
+ },
+ },
+ },
+ }}
func hash(ctx *cli.Context) {
args := ctx.Args()
@@ -56,3 +85,31 @@ func hash(ctx *cli.Context) {
fmt.Printf("%v\n", addr)
}
}
+func ensNodeHash(ctx *cli.Context) {
+ args := ctx.Args()
+ if len(args) < 1 {
+ utils.Fatalf("Usage: swarm hash ens node <ens name>")
+ }
+ ensName := args[0]
+
+ hash := ens.EnsNode(ensName)
+
+ stringHex := hex.EncodeToString(hash[:])
+ fmt.Println(stringHex)
+}
+func encodeEipHash(ctx *cli.Context) {
+ args := ctx.Args()
+ if len(args) < 1 {
+ utils.Fatalf("Usage: swarm hash ens <swarm hash>")
+ }
+ swarmHash := args[0]
+
+ hash := common.HexToHash(swarmHash)
+ ensHash, err := ens.EncodeSwarmHash(hash)
+ if err != nil {
+ utils.Fatalf("error converting swarm hash", err)
+ }
+
+ stringHex := hex.EncodeToString(ensHash)
+ fmt.Println(stringHex)
+}