Sfoglia il codice sorgente

fixed eth sign unittest

Bas van Kervel 10 anni fa
parent
commit
6d596b1ad1
5 ha cambiato i file con 27 aggiunte e 9 eliminazioni
  1. 2 2
      rpc/api/eth.go
  2. 6 6
      rpc/api/eth_args.go
  3. 17 0
      rpc/api/eth_js.go
  4. 2 0
      rpc/api/utils.go
  5. 0 1
      rpc/shared/utils.go

+ 2 - 2
rpc/api/eth.go

@@ -46,7 +46,7 @@ var (
 		"eth_getData":                             (*ethApi).GetData,
 		"eth_getCode":                             (*ethApi).GetData,
 		"eth_sign":                                (*ethApi).Sign,
-		"eth_sendRawTransaction":                  (*ethApi).PushTx,
+		"eth_sendRawTransaction":                  (*ethApi).SendRawTransaction,
 		"eth_sendTransaction":                     (*ethApi).SendTransaction,
 		"eth_transact":                            (*ethApi).SendTransaction,
 		"eth_estimateGas":                         (*ethApi).EstimateGas,
@@ -250,7 +250,7 @@ func (self *ethApi) Sign(req *shared.Request) (interface{}, error) {
 	return v, nil
 }
 
-func (self *ethApi) PushTx(req *shared.Request) (interface{}, error) {
+func (self *ethApi) SendRawTransaction(req *shared.Request) (interface{}, error) {
 	args := new(NewDataArgs)
 	if err := self.codec.Decode(req.Params, &args); err != nil {
 		return nil, shared.NewDecodeParamError(err.Error())

+ 6 - 6
rpc/api/eth_args.go

@@ -466,21 +466,21 @@ func (args *CallArgs) UnmarshalJSON(b []byte) (err error) {
 	}
 	args.Value = num
 
-	if ext.Gas == nil {
-		num = big.NewInt(0)
-	} else {
+	if ext.Gas != nil {
 		if num, err = numString(ext.Gas); err != nil {
 			return err
 		}
+	} else {
+		num = nil
 	}
 	args.Gas = num
 
-	if ext.GasPrice == nil {
-		num = big.NewInt(0)
-	} else {
+	if ext.GasPrice != nil {
 		if num, err = numString(ext.GasPrice); err != nil {
 			return err
 		}
+	} else {
+		num = nil
 	}
 	args.GasPrice = num
 

+ 17 - 0
rpc/api/eth_js.go

@@ -1,3 +1,20 @@
 package api
 
 // JS api provided by web3.js
+// eth_sign not standard
+
+const Eth_JS = `
+web3._extend({
+	property: 'eth',
+	methods:
+	[
+		new web3._extend.Method({
+			name: 'sign',
+			call: 'eth_sign',
+			params: 2,
+			inputFormatter: [web3._extend.formatters.formatInputString,web3._extend.formatters.formatInputString],
+			outputFormatter: web3._extend.formatters.formatOutputString
+		})
+	]
+});
+`

+ 2 - 0
rpc/api/utils.go

@@ -178,6 +178,8 @@ func Javascript(name string) string {
 		return Debug_JS
 	case shared.DbApiName:
 		return Db_JS
+	case shared.EthApiName:
+		return Eth_JS
 	case shared.MinerApiName:
 		return Miner_JS
 	case shared.NetApiName:

+ 0 - 1
rpc/shared/utils.go

@@ -25,4 +25,3 @@ var (
 		ShhApiName, TxPoolApiName, PersonalApiName, Web3ApiName,
 	}, ",")
 )
-