Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Priom/CI #10

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
version: 2
jobs:
build:
docker:
- image: circleci/golang:1.10

working_directory: /go/src/github.com/ChainSafeSystems/gobridge
steps:
- checkout

- run: go get -v -t -d ./...
- run: go test -v ./...
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
.virtualgo
truffle/node_modules
log/
vendor/
Empty file.
Empty file.
Empty file.
Empty file added 0x1
Empty file.
Empty file.
Empty file.
Empty file added 0x2
Empty file.
Empty file.
Empty file added 0x3
Empty file.
Empty file.
Empty file added 0x4
Empty file.
Empty file.
Empty file.
Empty file added 0x5
Empty file.
Empty file.
Empty file.
9 changes: 9 additions & 0 deletions 0x5e69365ac7f192b8e423dbd1234df29186554f65,
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

solc \
--abi \
--bin \
--optimize \
--output-dir compiled_contracts \
--overwrite \
contracts/bridge.sol
Empty file added 0x6
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file added 0x95,
Empty file.
Empty file added 0x96,
Empty file.
Empty file added 0x97,
Empty file.
Empty file added 0x98,
Empty file.
Empty file added 0x99,
Empty file.
Empty file added 0x9a,
Empty file.
Empty file.
Empty file added 0x9b,
Empty file.
Empty file added 0x9c,
Empty file.
Empty file added 0x9d,
Empty file.
Empty file.
Empty file added 0x9e,
Empty file.
Empty file added 0x9f,
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
55 changes: 55 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
FROM golang:1.10.3-alpine3.8 as builder

LABEL "priom"="[email protected]"
LABEL version="1.0"

COPY . $GOPATH/src/project/app
WORKDIR $GOPATH/src/project/app

RUN go get -d -v -u github.com/ChainSafeSystems/geth
RUN
RUN go build -o /go/bin/app

FROM scratch

COPY --from=builder /go/bin/app /go/bin/app
ENTRYPOINT [ "/go/bin/app" ]
import { DexVolumeAdapter } from "../dexVolume.type";
import { getTimestampAtStartOfHour } from "../helper/getTimestampAtStartOfHour";

const { fetchURL } = require("../helper/utils");

const endpoints = {
ethereum: "https://api.curve.fi/api/getAllPoolsVolume/ethereum",
};

// type better later
const graphs = (chain: any) => async () => {
const timestamp = getTimestampAtStartOfHour();
let res;
switch (chain) {
case "ethereum":
res = await fetchURL(endpoints.ethereum);
default:
res = await fetchURL(endpoints.ethereum);
}

return {
totalVolume: res?.data?.data?.totalVolume,
timestamp,
};
};

const adapter: DexVolumeAdapter = {
volume: {
ethereum: {
fetch: graphs("ethereum"),
runAtCurrTime: true,
customBackfill: () => {},
start: 0,
},
// TODO custom backfill
},
};
export default adapter;

12 changes: 4 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,11 @@ this is a go implementation of a generic bridge between blockchains. the bridge
* implement support for non EVM based blockchains

### requirements
go 1.9.1
go 1.10.3

go-ethereum
`go get github.com/ethereum/go-ethereum`

jsonparser

in $GOPATH/src
`git clone https://github.com/buger/jsonparser`
Install the dependencies:
`glide i`
_Make sure you have glide installed in your computer, https://glide.sh_

# to get the bridge
`go get github.com/ChainSafeSystems/multi_directional_bridge`
Expand Down
Empty file added ]
Empty file.
Empty file added ],
Empty file.
Binary file renamed multi_directional_bridge → bridge
Binary file not shown.
12 changes: 6 additions & 6 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import (
"syscall"
"sync"

//"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ChainSafeSystems/geth/accounts"
"github.com/ChainSafeSystems/geth/core/types"
"github.com/ChainSafeSystems/geth"
"github.com/ChainSafeSystems/geth/ethclient"
"github.com/ChainSafeSystems/geth/common"
"github.com/ChainSafeSystems/geth/accounts/keystore"
)

/* global variables */
Expand Down
2 changes: 1 addition & 1 deletion client/merkle.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package client

import (
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/ChainSafeSystems/geth/common"
)

type Root struct {
Expand Down
8 changes: 4 additions & 4 deletions client/rpc.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ package client

import (
"fmt"
"jsonparser"
"github.com/buger/jsonparser"
"net/http"
"bytes"
"io/ioutil"
"encoding/hex"

"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/common"
"github.com/ChainSafeSystems/geth/rlp"
"github.com/ChainSafeSystems/geth/core/types"
"github.com/ChainSafeSystems/geth/common"
)

/***** rpc methods ******/
Expand Down
8 changes: 4 additions & 4 deletions client/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import (
"encoding/hex"
"context"
"math/big"
//"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/core/types"
//"github.com/ethereum/go-ethereum/common"
//"github.com/ChainSafeSystems/geth/accounts/keystore"
"github.com/ChainSafeSystems/geth/accounts"
"github.com/ChainSafeSystems/geth/core/types"
//"github.com/ChainSafeSystems/geth/common"
)

/****** functions to send transactions ******/
Expand Down
6 changes: 3 additions & 3 deletions config.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"1": {
"url": "https://mainnet.infura.io",
"contractAddr": "0x288a9fb92921472d29ab0b3c3e420a8e4bd4f452",
"contractAddr": "0x34F05b33af6c08eF2160a3D93B431D82079067D0",
"gasPrice": "10000000",
"from": "0xe8b7b81f281a947840de4b23f40442b3843c5f49"
},
Expand All @@ -43,7 +43,7 @@
},
"1337": { // geth local chain
"url": "http://127.0.0.1:8545",
"contractAddr": "0x0b197606442affae8402f9030edbe9234c2069fe",
"contractAddr": "0x34F05b33af6c08eF2160a3D93B431D82079067D0",
"gasPrice": "10000000",
"from": "0xe8b7b81f281a947840de4b23f40442b3843c5f49"
},
Expand All @@ -56,7 +56,7 @@
"31": { // rootstock testnet
"url": "http://127.0.0.1:4444",
//"url": "https://public-node.testnet.rsk.co",
"contractAddr": "0x00",
"contractAddr": "0xb8ca1aa1c7061514E24F1C5270587A1b82247065",
"gasPrice": "100000000",
"from": "0xe8b7b81f281a947840de4b23f40442b3843c5f49"
}
Expand Down
Empty file added false
Empty file.
2 changes: 1 addition & 1 deletion function/function.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package function
import (
"encoding/hex"

"github.com/ethereum/go-ethereum/crypto"
"github.com/ChainSafeSystems/geth/crypto"
)

func GenerateSignature(sig string) (string) {
Expand Down
8 changes: 8 additions & 0 deletions glide.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package: projects.go/multi_directional_bridge
import:
- package: github.com/ChainSafeSystems/gobridge
subpackages:
- client
- package: github.com/buger/jsonparser
- package: github.com/ChainSafeSystems/geth
version: ~2.0.0
Empty file added id:
Empty file.
Empty file added internal:
Empty file.
Empty file added jsonrpc:
Empty file.
Empty file added latest
Empty file.
Empty file added latest,
Empty file.
Empty file added logs,
Empty file.
10 changes: 5 additions & 5 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import (
"os"
"sync"

"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/accounts/abi"
"https://github.com/ChainSafeSystems/geth/ethclient"
"https://github.com/ChainSafeSystems/geth/common"
"https://github.com/ChainSafeSystems/geth/accounts/keystore"
"https://github.com/ChainSafeSystems/geth/accounts/abi"

"github.com/ChainSafeSystems/multi_directional_bridge/client"
"https://github.com/ChainSafeSystems/multi_directional_bridge/client"
)

/* global vars */
Expand Down
Empty file added method:
Empty file.
Empty file added newHeads
Empty file.
Empty file added params:
Empty file.
66 changes: 66 additions & 0 deletions scripts/compileContracts.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,69 @@ solc \
--output-dir compiled_contracts \
--overwrite \
contracts/bridge.sol
pragma solidity ^0.4.24;


/**
* @title SafeMath
* @dev Math operations with safety checks that revert on error
*/
library SafeMath {

/**
* @dev Multiplies two numbers, reverts on overflow.
*/
function mul(uint256 _a, uint256 _b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (_a == 0) {
return 0;
}

uint256 c = _a * _b;
require(c / _a == _b);

return c;
}

/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/
function div(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b > 0); // Solidity only automatically asserts when dividing by 0
uint256 c = _a / _b;
// assert(_a == _b * c + _a % _b); // There is no case in which this doesn't hold

return c;
}

/**
* @dev Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 _a, uint256 _b) internal pure returns (uint256) {
require(_b <= _a);
uint256 c = _a - _b;

return c;
}

/**
* @dev Adds two numbers, reverts on overflow.
*/
function add(uint256 _a, uint256 _b) internal pure returns (uint256) {
uint256 c = _a + _b;
require(c >= _a);

return c;
}

/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
}
Empty file added topics:
Empty file.
Empty file added true
Empty file.
36 changes: 1 addition & 35 deletions truffle/contracts/lib/ERC20.sol
Original file line number Diff line number Diff line change
@@ -1,35 +1 @@
pragma solidity ^0.4.24;


/**
* @title ERC20 interface
* @dev see https://github.com/ethereum/EIPs/issues/20
*/
contract ERC20 {
function totalSupply() public view returns (uint256);

function balanceOf(address _who) public view returns (uint256);

function allowance(address _owner, address _spender)
public view returns (uint256);

function transfer(address _to, uint256 _value) public returns (bool);

function approve(address _spender, uint256 _value)
public returns (bool);

function transferFrom(address _from, address _to, uint256 _value)
public returns (bool);

event Transfer(
address indexed from,
address indexed to,
uint256 value
);

event Approval(
address indexed owner,
address indexed spender,
uint256 value
);
}
c
Empty file added {
Empty file.
Empty file added }
Empty file.