Removed from as a requirement and changed
Removed the from as a requiremet from the RPC eth_call. Xeth#Call now also default values to: 1. Supplied account 2. First account if any 3. No managed account => 000000..00
This commit is contained in:
		
							parent
							
								
									204ac81188
								
							
						
					
					
						commit
						a9959805e5
					
				| @ -279,11 +279,6 @@ func (args *CallArgs) UnmarshalJSON(b []byte) (err error) { | ||||
| 		return NewDecodeParamError(err.Error()) | ||||
| 	} | ||||
| 
 | ||||
| 	if len(ext.From) == 0 { | ||||
| 		return NewValidationError("from", "is required") | ||||
| 	} | ||||
| 	args.From = ext.From | ||||
| 
 | ||||
| 	if len(ext.To) == 0 { | ||||
| 		return NewValidationError("to", "is required") | ||||
| 	} | ||||
|  | ||||
| @ -671,10 +671,6 @@ func TestCallArgs(t *testing.T) { | ||||
| 		t.Error(err) | ||||
| 	} | ||||
| 
 | ||||
| 	if expected.From != args.From { | ||||
| 		t.Errorf("From shoud be %#v but is %#v", expected.From, args.From) | ||||
| 	} | ||||
| 
 | ||||
| 	if expected.To != args.To { | ||||
| 		t.Errorf("To shoud be %#v but is %#v", expected.To, args.To) | ||||
| 	} | ||||
| @ -895,19 +891,8 @@ func TestCallArgsNotStrings(t *testing.T) { | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func TestCallArgsFromEmpty(t *testing.T) { | ||||
| 	input := `[{"to": "0xb60e8dd61c5d32be8058bb8eb970870f07233155"}]` | ||||
| 
 | ||||
| 	args := new(CallArgs) | ||||
| 	str := ExpectValidationError(json.Unmarshal([]byte(input), &args)) | ||||
| 	if len(str) > 0 { | ||||
| 		t.Error(str) | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func TestCallArgsToEmpty(t *testing.T) { | ||||
| 	input := `[{"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155"}]` | ||||
| 
 | ||||
| 	args := new(CallArgs) | ||||
| 	str := ExpectValidationError(json.Unmarshal([]byte(input), &args)) | ||||
| 	if len(str) > 0 { | ||||
|  | ||||
							
								
								
									
										14
									
								
								xeth/xeth.go
									
									
									
									
									
								
							
							
						
						
									
										14
									
								
								xeth/xeth.go
									
									
									
									
									
								
							| @ -572,8 +572,20 @@ func (self *XEth) PushTx(encodedTx string) (string, error) { | ||||
| 
 | ||||
| func (self *XEth) Call(fromStr, toStr, valueStr, gasStr, gasPriceStr, dataStr string) (string, error) { | ||||
| 	statedb := self.State().State() //self.eth.ChainManager().TransState()
 | ||||
| 	var from *state.StateObject | ||||
| 	if len(fromStr) == 0 { | ||||
| 		accounts, err := self.backend.AccountManager().Accounts() | ||||
| 		if err != nil || len(accounts) == 0 { | ||||
| 			from = statedb.GetOrNewStateObject(common.Address{}) | ||||
| 		} else { | ||||
| 			from = statedb.GetOrNewStateObject(common.BytesToAddress(accounts[0].Address)) | ||||
| 		} | ||||
| 	} else { | ||||
| 		from = statedb.GetOrNewStateObject(common.HexToAddress(fromStr)) | ||||
| 	} | ||||
| 
 | ||||
| 	msg := callmsg{ | ||||
| 		from:     statedb.GetOrNewStateObject(common.HexToAddress(fromStr)), | ||||
| 		from:     from, | ||||
| 		to:       common.HexToAddress(toStr), | ||||
| 		gas:      common.Big(gasStr), | ||||
| 		gasPrice: common.Big(gasPriceStr), | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user