Skip to content
Merged
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
5 changes: 4 additions & 1 deletion .github/workflows/client.yml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,10 @@ jobs:
- uses: securego/gosec@master
with:
args: |
-exclude-dir=pkg/chain/gen
-exclude-dir=pkg/chain/ethereum/beacon/gen
-exclude-dir=pkg/chain/ethereum/ecdsa/gen
-exclude-dir=pkg/chain/ethereum/threshold/gen
-exclude-dir=pkg/chain/ethereum/tbtc/gen
./...

client-format:
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,4 @@ typechain/

# Go bindings generator
pkg/chain/*/*/gen/_contracts
pkg/chain/*/*/gen/_address
3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ RUN apk add --update --no-cache \
nodejs \
npm \
bash \
python3 && \
python3 \
jq && \
rm -rf /var/cache/apk/ && mkdir /var/cache/apk/ && \
rm -rf /usr/share/man

Expand Down
6 changes: 6 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
github.com/decred/dcrd/lru v1.0.0/go.mod h1:mxKOwFd7lFjN2GZYsiz/ecgqR6kkYAl+0pz0tEMk218=
github.com/deepmap/oapi-codegen v1.6.0/go.mod h1:ryDa9AgbELGeB+YEXE1dR53yAjHwFvE9iAUlWl9Al3M=
github.com/deepmap/oapi-codegen v1.8.2 h1:SegyeYGcdi0jLLrpbCMoJxnUUn8GBXHsvr4rbzjuhfU=
github.com/deepmap/oapi-codegen v1.8.2/go.mod h1:YLgSKSDv/bZQB7N4ws6luhozi3cEdRktEqrX88CvjIw=
github.com/dgraph-io/badger v1.5.5-0.20190226225317-8115aed38f8f/go.mod h1:VZxzAIRPHRVNRKRo6AXrX9BJegn6il06VMTZVJYCIjQ=
github.com/dgraph-io/badger v1.6.0-rc1/go.mod h1:zwt7syl517jmP8s94KqSxTlM6IMsdhYy6psNgSztDR4=
Expand Down Expand Up @@ -446,6 +447,7 @@ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad
github.com/gorilla/websocket v1.5.0 h1:PPwGk2jz7EePpoHN/+ClbZu8SPxiqlu12wZP/3sWmnc=
github.com/gorilla/websocket v1.5.0/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/graph-gophers/graphql-go v0.0.0-20191115155744-f33e81362277/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc=
github.com/graph-gophers/graphql-go v1.3.0 h1:Eb9x/q6MFpCLz7jBCiP/WTxjSDrYLR1QY41SORZyNJ0=
github.com/graph-gophers/graphql-go v1.3.0/go.mod h1:9CQHMSxwO4MprSdzoIEobiHpoLtHm77vfxsvsIN5Vuc=
github.com/gregjones/httpcache v0.0.0-20180305231024-9cad4c3443a7/go.mod h1:FecbI9+v66THATjSRHfNgh1IVFe/9kFxbXtjV0ctIMA=
github.com/grpc-ecosystem/go-grpc-middleware v1.0.1-0.20190118093823-f849b5445de4/go.mod h1:FiyG127CGDf3tlThmgyCl78X/SZQqEOJBCDaAfeWzPs=
Expand Down Expand Up @@ -504,13 +506,16 @@ github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
github.com/influxdata/flux v0.65.1/go.mod h1:J754/zds0vvpfwuq7Gc2wRdVwEodfpCFM7mYlOw2LqY=
github.com/influxdata/influxdb v1.2.3-0.20180221223340-01288bdb0883/go.mod h1:qZna6X/4elxqT3yI9iZYdZrWWdeFOOprn86kgg4+IzY=
github.com/influxdata/influxdb v1.8.3 h1:WEypI1BQFTT4teLM+1qkEcvUi0dAvopAI/ir0vAiBg8=
github.com/influxdata/influxdb v1.8.3/go.mod h1:JugdFhsvvI8gadxOI6noqNeeBHvWNTbfYGtiAn+2jhI=
github.com/influxdata/influxdb-client-go/v2 v2.4.0 h1:HGBfZYStlx3Kqvsv1h2pJixbCl/jhnFtxpKFAv9Tu5k=
github.com/influxdata/influxdb-client-go/v2 v2.4.0/go.mod h1:vLNHdxTJkIf2mSLvGrpj8TCcISApPoXkaxP8g9uRlW8=
github.com/influxdata/influxdb1-client v0.0.0-20190809212627-fc22c7df067e/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
github.com/influxdata/influxql v1.1.1-0.20200828144457-65d3ef77d385/go.mod h1:gHp9y86a/pxhjJ+zMjNXiQAA197Xk9wLxaz+fGG+kWk=
github.com/influxdata/line-protocol v0.0.0-20180522152040-32c6aa80de5e/go.mod h1:4kt73NQhadE3daL3WhR5EJ/J2ocX0PZzwxQ0gXJ7oFE=
github.com/influxdata/line-protocol v0.0.0-20200327222509-2487e7298839/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo=
github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097 h1:vilfsDSy7TDxedi9gyBkMvAirat/oRcL0lFdJBf6tdM=
github.com/influxdata/line-protocol v0.0.0-20210311194329-9aa0e372d097/go.mod h1:xaLFMmpvUxqXtVkUJfg9QmT88cDaCJ3ZKgdZ78oO8Qo=
github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19ybifQhZoQNF5D8=
github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE=
Expand Down Expand Up @@ -1323,6 +1328,7 @@ github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtP
github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic=
github.com/performancecopilot/speed v3.0.0+incompatible/go.mod h1:/CLtqpZ5gBg1M9iaPbIdPPGyKcA8hKdoy6hAWba7Yac=
github.com/peterh/liner v1.0.1-0.20180619022028-8c1271fcf47f/go.mod h1:xIteQHvHuaLYG9IFj6mSxM0fCKrs34IrEQUhOYuGPHc=
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7 h1:oYW+YCJ1pachXTQmzR3rNLYGGz4g/UgFcjb28p/viDM=
github.com/peterh/liner v1.1.1-0.20190123174540-a2c9a5303de7/go.mod h1:CRroGNssyjTd/qIG2FyxByd2S8JEAZXBl4qUrZf8GS0=
github.com/philhofer/fwd v1.0.0/go.mod h1:gk3iGcWd9+svBvR0sR+KPcfE+RNWozjowpeBVG3ZVNU=
github.com/pierrec/lz4 v0.0.0-20190327172049-315a67e90e41/go.mod h1:3/3N9NVKO0jef7pBehbT1qWhCMrIgbYNnFAZCqQ5LRc=
Expand Down
Empty file.
7 changes: 7 additions & 0 deletions pkg/chain/ethereum/beacon/gen/gen.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
package gen

import (
_ "embed"
)

//go:generate make download_artifacts
//go:generate make

//go:embed _address/RandomBeacon
var RandomBeaconAddress string
26 changes: 21 additions & 5 deletions pkg/chain/ethereum/common/gen/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,13 @@ artifacts_dir = $(realpath ${contracts_dir}/package/artifacts)
# Go bindings generated for the solidity contracts.
contract_files = $(addprefix contract/,$(addsuffix .go,${required_contracts}))

all: gen_contract_go
# Files containing addresses extracted from the artifacts.
address_files = $(addprefix _address/,${required_contracts})

all: clean ${address_files} gen_contract_go

clean:
rm -rf ${contracts_dir}/*
rm -rf _address/*
rm -rf abi/*
rm -rf contract/*
mkdir tmp && mv cmd/cmd*.go tmp
Expand All @@ -25,7 +28,9 @@ clean:
# It requires npm of at least 7.x version to support `pack-destination` flag.
download_artifacts:
rm -rf ${contracts_dir} && mkdir ${contracts_dir}
npm pack --silent --pack-destination=${contracts_dir} ${npm_package_name}@${npm_package_tag}\
npm pack --silent \
--pack-destination=${contracts_dir} \
$(shell npm view ${npm_package_name}@${npm_package_tag} _id) \
| xargs -I{} tar -zxf ${contracts_dir}/{} -C ${contracts_dir}

gen_contract_go: ${contract_files}
Expand All @@ -36,8 +41,19 @@ abi/%.abi: ${artifacts_dir}/%.json
abi/%.go: abi/%.abi
go run github.com/ethereum/go-ethereum/cmd/abigen --abi $< --pkg abi --type $* --out $@

contract/%.go cmd/%.go: abi/%.abi abi/%.go
# Extract address of a contract from an artifact. Artfifacts that are published
# with `development` tag are not accessible on developers' environments, so we
# replace them with zeros.
_address/%: ${artifacts_dir}/%.json
ifeq ($(npm_package_tag), development)
@echo "Skipping address extraction for development package"
@echo "0x0000000000000000000000000000000000000000" > _address/$*
else
jq -jr .address ${artifacts_dir}/$*.json > _address/$*
endif

contract/%.go cmd/%.go: abi/%.abi abi/%.go _address/% ${artifacts_dir}/%.json
go run github.com/keep-network/keep-common/tools/generators/ethlike $< contract/$*.go cmd/$*.go

# Don't remove intermediate files that got generated.
.PRECIOUS: abi/%.abi abi/%.go
.PRECIOUS: abi/%.abi abi/%.go _address/%
Empty file.
7 changes: 7 additions & 0 deletions pkg/chain/ethereum/ecdsa/gen/gen.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
package gen

import (
_ "embed"
)

//go:generate make download_artifacts
//go:generate make

//go:embed _address/WalletRegistry
var WalletRegistryAddress string
Empty file.
7 changes: 7 additions & 0 deletions pkg/chain/ethereum/tbtc/gen/gen.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
package gen

import (
_ "embed"
)

//go:generate make download_artifacts
//go:generate make

//go:embed _address/Bridge
var BridgeAddress string
Empty file.
7 changes: 7 additions & 0 deletions pkg/chain/ethereum/threshold/gen/gen.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
package gen

import (
_ "embed"
)

//go:generate make download_artifacts
//go:generate make

//go:embed _address/TokenStaking
var TokenStakingAddress string