generated from KyberNetwork/go-project-template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from KyberNetwork/feat/one-inch-rfq-trades
feat: parse oneinch rfq trades
- Loading branch information
Showing
19 changed files
with
4,895 additions
and
11 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 |
---|---|---|
|
@@ -3,4 +3,7 @@ cmd/*/* | |
!cmd/*/*.go | ||
!cmd/*/migrations | ||
*/cmd/*/* | ||
!*/cmd/*/*.go | ||
!*/cmd/*/*.go | ||
.idea | ||
.env.example | ||
.env |
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
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,21 @@ | ||
package app | ||
|
||
import "github.com/urfave/cli" | ||
|
||
const ( | ||
RPCUrlFlagName = "rpc-url" | ||
) | ||
|
||
var ( | ||
RPCUrlFlag = &cli.StringFlag{ | ||
Name: RPCUrlFlagName, | ||
EnvVar: "RPC_URL", | ||
Usage: "RPC node url", | ||
} | ||
) | ||
|
||
func RPCNodeFlags() []cli.Flag { | ||
return []cli.Flag{ | ||
RPCUrlFlag, | ||
} | ||
} |
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 @@ | ||
package types | ||
|
||
type ContractCallParam struct { | ||
Name string `json:"name"` | ||
Value interface{} `json:"value"` | ||
Type string `json:"type"` | ||
} | ||
type ContractCall struct { | ||
ContractType string `json:"contract_type,omitempty"` | ||
Name string `json:"name"` | ||
Params []ContractCallParam `json:"params"` | ||
} |
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,39 @@ | ||
package types | ||
|
||
import ( | ||
"github.com/ethereum/go-ethereum/common" | ||
ethereumTypes "github.com/ethereum/go-ethereum/core/types" | ||
) | ||
|
||
type TraceCallResponse struct { | ||
Jsonrpc string `json:"jsonrpc"` | ||
ID int `json:"id"` | ||
Result CallFrame `json:"result"` | ||
} | ||
|
||
type CallLog struct { | ||
Address common.Address `json:"address"` | ||
Topics []common.Hash `json:"topics"` | ||
Data string `json:"data"` | ||
} | ||
|
||
func (l CallLog) ToEthereumLog() ethereumTypes.Log { | ||
return ethereumTypes.Log{ | ||
Address: l.Address, | ||
Topics: l.Topics, | ||
Data: common.Hex2Bytes(l.Data), | ||
} | ||
} | ||
|
||
type CallFrame struct { | ||
From string `json:"from"` | ||
Gas string `json:"gas"` | ||
GasUsed string `json:"gasUsed"` | ||
To string `json:"to"` | ||
Input string `json:"input"` | ||
Output string `json:"output"` | ||
Calls []CallFrame `json:"calls"` | ||
Value string `json:"value"` | ||
Type string `json:"type"` | ||
Logs []CallLog `json:"logs"` | ||
} |
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,8 @@ | ||
package worker | ||
|
||
import "github.com/KyberNetwork/tradelogs/pkg/storage" | ||
|
||
type parseEventLogResult struct { | ||
tradeLogOrder storage.TradeLog | ||
err error | ||
} |
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,8 @@ | ||
package abitypes | ||
|
||
import "github.com/ethereum/go-ethereum/accounts/abi" | ||
|
||
var ( | ||
Uint256, _ = abi.NewType("uint256", "", nil) | ||
Bytes32, _ = abi.NewType("bytes32", "", nil) | ||
) |
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,48 @@ | ||
package decoder | ||
|
||
import ( | ||
"encoding/hex" | ||
"fmt" | ||
"github.com/KyberNetwork/tradelogs/internal/types" | ||
"github.com/ethereum/go-ethereum/accounts/abi" | ||
"github.com/ethereum/go-ethereum/common" | ||
) | ||
|
||
func Decode(ABI *abi.ABI, input string) (*types.ContractCall, error) { | ||
if ABI == nil { | ||
return nil, fmt.Errorf("missing abi") | ||
} | ||
inputBytes := common.FromHex(input) | ||
method, err := ABI.MethodById(inputBytes) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
bytes, err := hex.DecodeString(input[10:]) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
inputs, err := method.Inputs.Unpack(bytes) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
nonIndexedArgs := method.Inputs.NonIndexed() | ||
|
||
contractCall := &types.ContractCall{ | ||
Name: method.Name, | ||
} | ||
|
||
for i, input := range inputs { | ||
arg := nonIndexedArgs[i] | ||
param := types.ContractCallParam{ | ||
Name: arg.Name, | ||
Value: input, | ||
Type: arg.Type.String(), | ||
} | ||
contractCall.Params = append(contractCall.Params, param) | ||
} | ||
|
||
return contractCall, nil | ||
} |
Oops, something went wrong.