Created
February 9, 2017 13:40
-
-
Save obscuren/1d6b2ed8876c271a96910e848b0fc027 to your computer and use it in GitHub Desktop.
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
diff --git a/eth/backend.go b/eth/backend.go | |
index af120cb..80accdd 100644 | |
--- a/eth/backend.go | |
+++ b/eth/backend.go | |
@@ -31,6 +31,7 @@ import ( | |
"github.com/ethereum/ethash" | |
"github.com/ethereum/go-ethereum/accounts" | |
"github.com/ethereum/go-ethereum/common" | |
+ "github.com/ethereum/go-ethereum/common/hexutil" | |
"github.com/ethereum/go-ethereum/core" | |
"github.com/ethereum/go-ethereum/core/types" | |
"github.com/ethereum/go-ethereum/core/vm" | |
@@ -352,10 +353,25 @@ func (s *Ethereum) APIs() []rpc.API { | |
Version: "1.0", | |
Service: s.netRPCService, | |
Public: true, | |
+ }, { | |
+ Namespace: "shh", | |
+ Version: "0.1", | |
+ Service: PublicWhisperAPI{}, | |
+ Public: true, | |
}, | |
}...) | |
} | |
+type PublicWhisperAPI struct{} | |
+ | |
+func (PublicWhisperAPI) HelloWorld(data hexutil.Bytes) (hexutil.Bytes, error) { | |
+ return append(data, data...), nil | |
+} | |
+ | |
+func (PublicWhisperAPI) HelloWorld2(data hexutil.Bytes) (hexutil.Bytes, error) { | |
+ return nil, fmt.Errorf("hello wold error") | |
+} | |
+ | |
func (s *Ethereum) ResetWithGenesisBlock(gb *types.Block) { | |
s.blockchain.ResetWithGenesisBlock(gb) | |
} | |
diff --git a/internal/web3ext/web3ext.go b/internal/web3ext/web3ext.go | |
index edbe45f..c5f5998 100644 | |
--- a/internal/web3ext/web3ext.go | |
+++ b/internal/web3ext/web3ext.go | |
@@ -470,14 +470,25 @@ web3._extend({ | |
const Shh_JS = ` | |
web3._extend({ | |
property: 'shh', | |
- methods: [], | |
+ methods: [ | |
+ new web3._extend.Method({ | |
+ name:"helloWorld", | |
+ call: "shh_helloWorld", | |
+ params: 1, | |
+ }), | |
+ new web3._extend.Method({ | |
+ name:"helloWorld2", | |
+ call: "shh_helloWorld2", | |
+ params: 1, | |
+ }), | |
+ ], | |
properties: | |
[ | |
new web3._extend.Property({ | |
name: 'version', | |
getter: 'shh_version', | |
outputFormatter: web3._extend.utils.toDecimal | |
- }) | |
+ }), | |
] | |
}); | |
` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment