forked from cerc-io/laconicd-deprecated
Compare commits
35
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bbb6d2a7ab | ||
|
|
656b8dc79b | ||
|
|
f827ea46b8 | ||
|
|
5cd07d9104 | ||
|
|
30cbba44e7 | ||
|
|
b59eb6878d | ||
|
|
b90bb05b3f | ||
|
|
beb1ad2df7 | ||
|
|
6025fadc71 | ||
|
|
fa406be65f | ||
|
|
e18541523d | ||
|
|
4d5568bf83 | ||
|
|
ff10aac7d7 | ||
|
|
38c77c10f6 | ||
|
|
bd04a6307e | ||
|
|
6e272334e4 | ||
|
|
bf1670be78 | ||
|
|
67208b08af | ||
|
|
2e986c4d5e | ||
|
|
e38ed67657 | ||
|
|
145d52f92e | ||
|
|
4ba723a384 | ||
|
|
420042b9de | ||
|
|
d44ab22d87 | ||
|
|
66cf0f758c | ||
|
|
c3774a3b96 | ||
|
|
39038980cc | ||
|
|
26300b0738 | ||
|
|
021ab7df1f | ||
|
|
6eeed3de91 | ||
|
|
9e91a70f31 | ||
|
|
961f0f737a | ||
|
|
930cca939f | ||
|
|
e8fe95114a | ||
|
|
82b2c32575 |
+4
-6
@@ -1,7 +1,5 @@
|
||||
Dockerfile
|
||||
# localnet-setup
|
||||
localnet-setup
|
||||
|
||||
**/node_modules
|
||||
init.sh
|
||||
|
||||
build
|
||||
localnet-setup
|
||||
# build
|
||||
build
|
||||
@@ -0,0 +1,5 @@
|
||||
# CODEOWNERS: https://help.github.com/articles/about-codeowners/
|
||||
|
||||
# Primary (global) repo maintainers
|
||||
|
||||
* @evmos/core-engineering
|
||||
+23
-18
@@ -94,34 +94,39 @@ jobs:
|
||||
ref: jest_timeout
|
||||
- name: Environment
|
||||
run: ls -tlh && env
|
||||
- name: Build containers scripts
|
||||
- name: build containers scripts
|
||||
working-directory: tests/sdk_tests
|
||||
run: ./build-laconicd-container.sh && ./build-sdk-test-container.sh
|
||||
|
||||
- name: Start containers
|
||||
- name: start containers
|
||||
working-directory: tests/sdk_tests
|
||||
run: docker compose up -d
|
||||
- name: Run tests
|
||||
- name: run-tests.sh
|
||||
working-directory: tests/sdk_tests
|
||||
run: ./run-tests.sh
|
||||
|
||||
- name: Start auction containers
|
||||
- name: reset containers for auction tests
|
||||
working-directory: tests/sdk_tests
|
||||
env:
|
||||
TEST_AUCTION_ENABLED: true
|
||||
run: docker compose up -d
|
||||
- name: Run auction tests
|
||||
if: always()
|
||||
run: docker compose down
|
||||
- name: start auction containers
|
||||
working-directory: tests/sdk_tests
|
||||
run: ./run-tests.sh test:auctions
|
||||
|
||||
- name: Start auction containers
|
||||
run: docker compose -f docker-compose-auctions.yml up -d
|
||||
- name: run-acution-tests.sh
|
||||
working-directory: tests/sdk_tests
|
||||
env:
|
||||
TEST_REGISTRY_EXPIRY: true
|
||||
run: docker compose up -d
|
||||
- name: Run nameservice expiry tests
|
||||
run: ./run-auction-tests.sh
|
||||
- name: reset containers for nameservice tests
|
||||
working-directory: tests/sdk_tests
|
||||
run: ./run-tests.sh test:nameservice-expiry
|
||||
if: always()
|
||||
run: docker compose -f docker-compose-auctions.yml down
|
||||
- name: start auction containers
|
||||
working-directory: tests/sdk_tests
|
||||
run: docker compose -f docker-compose-nameservice.yml up -d
|
||||
- name: run-nameservice-expiry-tests.sh
|
||||
working-directory: tests/sdk_tests
|
||||
run: ./run-nameservice-expiry-tests.sh
|
||||
- name: reset containers for nameservice tests
|
||||
working-directory: tests/sdk_tests
|
||||
if: always()
|
||||
run: docker compose -f docker-compose-nameservice.yml down
|
||||
|
||||
# integration_tests:
|
||||
# runs-on: ubuntu-latest
|
||||
|
||||
@@ -19,9 +19,6 @@ test/
|
||||
tests/
|
||||
*_test.go
|
||||
|
||||
# false positive; TODO: https://github.com/cerc-io/laconicd/issues/104
|
||||
testutil/network/network.go
|
||||
|
||||
# Semgrep rules folder
|
||||
.semgrep
|
||||
|
||||
|
||||
+7
-7
@@ -1,14 +1,14 @@
|
||||
FROM golang:alpine AS build-env
|
||||
|
||||
# Install dependencies
|
||||
RUN apk add --update git build-base linux-headers
|
||||
# Set up dependencies
|
||||
ENV PACKAGES git build-base
|
||||
|
||||
# Set working directory for the build
|
||||
WORKDIR /go/src/github.com/cerc-io/laconicd
|
||||
|
||||
# Cache Go modules
|
||||
COPY go.mod go.sum ./
|
||||
RUN go mod download
|
||||
# Install dependencies
|
||||
RUN apk add --update $PACKAGES
|
||||
RUN apk add linux-headers
|
||||
|
||||
# Add source files
|
||||
COPY . .
|
||||
@@ -21,10 +21,10 @@ FROM alpine:3.17.0
|
||||
|
||||
# Install ca-certificates
|
||||
RUN apk add --update ca-certificates jq curl
|
||||
WORKDIR /
|
||||
|
||||
# Copy over binaries from the build-env
|
||||
COPY --from=build-env /go/src/github.com/cerc-io/laconicd/build/laconicd /usr/bin/laconicd
|
||||
|
||||
WORKDIR /
|
||||
# Run laconicd by default
|
||||
ENTRYPOINT ["laconicd"]
|
||||
CMD ["laconicd"]
|
||||
|
||||
@@ -72,7 +72,7 @@ ifeq ($(ENABLE_ROCKSDB),true)
|
||||
BUILD_TAGS += rocksdb_build
|
||||
test_tags += rocksdb_build
|
||||
else
|
||||
$(info RocksDB support is disabled; to build and test with RocksDB support, set ENABLE_ROCKSDB=true)
|
||||
$(warning RocksDB support is disabled; to build and test with RocksDB support, set ENABLE_ROCKSDB=true)
|
||||
endif
|
||||
|
||||
# DB backend selection
|
||||
@@ -145,7 +145,7 @@ docker-build:
|
||||
# update old container
|
||||
docker rm laconicd || true
|
||||
# create a new container from the latest image
|
||||
docker create --name laconic -t -i ${DOCKER_IMAGE}:${DOCKER_TAG} laconicd
|
||||
docker create --name laconic -t -i cerc-io/laconicd:latest laconicd
|
||||
# move the binaries to the ./build directory
|
||||
mkdir -p ./build/
|
||||
docker cp laconic:/usr/bin/laconicd ./build/
|
||||
@@ -316,7 +316,7 @@ TEST_TARGETS := test-unit test-unit-cover test-race
|
||||
# Test runs-specific rules. To add a new test target, just add
|
||||
# a new rule, customise ARGS or TEST_PACKAGES ad libitum, and
|
||||
# append the new rule to the TEST_TARGETS list.
|
||||
test-unit: ARGS=-timeout=10m -race -test.v
|
||||
test-unit: ARGS=-timeout=10m -race
|
||||
test-unit: TEST_PACKAGES=$(PACKAGES_UNIT)
|
||||
|
||||
test-race: ARGS=-race
|
||||
|
||||
@@ -27,7 +27,7 @@ require (
|
||||
github.com/holiman/uint256 v1.2.1
|
||||
github.com/improbable-eng/grpc-web v0.15.0
|
||||
github.com/ipfs/go-cid v0.3.2
|
||||
github.com/ipld/go-ipld-prime v0.19.0
|
||||
github.com/ipld/go-ipld-prime v0.18.0
|
||||
github.com/miguelmota/go-ethereum-hdwallet v0.1.1
|
||||
github.com/onsi/ginkgo/v2 v2.5.1
|
||||
github.com/onsi/gomega v1.24.1
|
||||
@@ -156,7 +156,7 @@ require (
|
||||
github.com/multiformats/go-base32 v0.0.3 // indirect
|
||||
github.com/multiformats/go-base36 v0.1.0 // indirect
|
||||
github.com/multiformats/go-multibase v0.0.3 // indirect
|
||||
github.com/multiformats/go-multihash v0.2.1 // indirect
|
||||
github.com/multiformats/go-multihash v0.2.0 // indirect
|
||||
github.com/multiformats/go-varint v0.0.6 // indirect
|
||||
github.com/olekukonko/tablewriter v0.0.5 // indirect
|
||||
github.com/pelletier/go-toml v1.9.5 // indirect
|
||||
|
||||
@@ -798,8 +798,8 @@ github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mq
|
||||
github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po=
|
||||
github.com/ipfs/go-cid v0.3.2 h1:OGgOd+JCFM+y1DjWPmVH+2/4POtpDzwcr7VgnB7mZXc=
|
||||
github.com/ipfs/go-cid v0.3.2/go.mod h1:gQ8pKqT/sUxGY+tIwy1RPpAojYu7jAyCp5Tz1svoupw=
|
||||
github.com/ipld/go-ipld-prime v0.19.0 h1:5axC7rJmPc17Emw6TelxGwnzALk0PdupZ2oj2roDj04=
|
||||
github.com/ipld/go-ipld-prime v0.19.0/go.mod h1:Q9j3BaVXwaA3o5JUDNvptDDr/x8+F7FG6XJ8WI3ILg4=
|
||||
github.com/ipld/go-ipld-prime v0.18.0 h1:xUk7NUBSWHEXdjiOu2sLXouFJOMs0yoYzeI5RAqhYQo=
|
||||
github.com/ipld/go-ipld-prime v0.18.0/go.mod h1:735yXW548CKrLwVCYXzqx90p5deRJMVVxM9eJ4Qe+qE=
|
||||
github.com/jackpal/go-nat-pmp v1.0.2-0.20160603034137-1fa385a6f458/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
|
||||
github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus=
|
||||
github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc=
|
||||
@@ -967,9 +967,9 @@ github.com/multiformats/go-base36 v0.1.0 h1:JR6TyF7JjGd3m6FbLU2cOxhC0Li8z8dLNGQ8
|
||||
github.com/multiformats/go-base36 v0.1.0/go.mod h1:kFGE83c6s80PklsHO9sRn2NCoffoRdUUOENyW/Vv6sM=
|
||||
github.com/multiformats/go-multibase v0.0.3 h1:l/B6bJDQjvQ5G52jw4QGSYeOTZoAwIO77RblWplfIqk=
|
||||
github.com/multiformats/go-multibase v0.0.3/go.mod h1:5+1R4eQrT3PkYZ24C3W2Ue2tPwIdYQD509ZjSb5y9Oc=
|
||||
github.com/multiformats/go-multicodec v0.6.0 h1:KhH2kSuCARyuJraYMFxrNO3DqIaYhOdS039kbhgVwpE=
|
||||
github.com/multiformats/go-multihash v0.2.1 h1:aem8ZT0VA2nCHHk7bPJ1BjUbHNciqZC/d16Vve9l108=
|
||||
github.com/multiformats/go-multihash v0.2.1/go.mod h1:WxoMcYG85AZVQUyRyo9s4wULvW5qrI9vb2Lt6evduFc=
|
||||
github.com/multiformats/go-multicodec v0.5.0 h1:EgU6cBe/D7WRwQb1KmnBvU7lrcFGMggZVTPtOW9dDHs=
|
||||
github.com/multiformats/go-multihash v0.2.0 h1:oytJb9ZA1OUW0r0f9ea18GiaPOo4SXyc7p2movyUuo4=
|
||||
github.com/multiformats/go-multihash v0.2.0/go.mod h1:WxoMcYG85AZVQUyRyo9s4wULvW5qrI9vb2Lt6evduFc=
|
||||
github.com/multiformats/go-varint v0.0.6 h1:gk85QWKxh3TazbLxED/NlDVv8+q+ReFJk7Y2W/KhfNY=
|
||||
github.com/multiformats/go-varint v0.0.6/go.mod h1:3Ls8CIEsrijN6+B7PbrXRPxHRPuXSrVKRY101jdMZYE=
|
||||
github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U=
|
||||
|
||||
@@ -5,20 +5,19 @@ CHAINID="laconic_9000-1"
|
||||
MONIKER="localtestnet"
|
||||
KEYRING="test"
|
||||
KEYALGO="eth_secp256k1"
|
||||
LOGLEVEL="${LOGLEVEL:-info}"
|
||||
LOGLEVEL="info"
|
||||
# trace evm
|
||||
TRACE="--trace"
|
||||
# TRACE=""
|
||||
|
||||
# validate dependencies are installed
|
||||
command -v jq > /dev/null 2>&1 || {
|
||||
echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"
|
||||
exit 1
|
||||
}
|
||||
command -v jq > /dev/null 2>&1 || { echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"; exit 1; }
|
||||
|
||||
# remove existing daemon and client
|
||||
rm -rf ~/.laconic*
|
||||
|
||||
make install
|
||||
|
||||
laconicd config keyring-backend $KEYRING
|
||||
laconicd config chain-id $CHAINID
|
||||
|
||||
@@ -28,70 +27,71 @@ laconicd keys add $KEY --keyring-backend $KEYRING --algo $KEYALGO
|
||||
# Set moniker and chain-id for Ethermint (Moniker can be anything, chain-id must be an integer)
|
||||
laconicd init $MONIKER --chain-id $CHAINID
|
||||
|
||||
update_genesis() {
|
||||
jq "$1" $HOME/.laconicd/config/genesis.json > $HOME/.laconicd/config/tmp_genesis.json &&
|
||||
mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
}
|
||||
|
||||
# Change parameter token denominations to aphoton
|
||||
update_genesis '.app_state["staking"]["params"]["bond_denom"]="aphoton"'
|
||||
update_genesis '.app_state["crisis"]["constant_fee"]["denom"]="aphoton"'
|
||||
update_genesis '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="aphoton"'
|
||||
update_genesis '.app_state["mint"]["params"]["mint_denom"]="aphoton"'
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["staking"]["params"]["bond_denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["crisis"]["constant_fee"]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["mint"]["params"]["mint_denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
# Custom modules
|
||||
update_genesis '.app_state["registry"]["params"]["record_rent"]["denom"]="aphoton"'
|
||||
update_genesis '.app_state["registry"]["params"]["authority_rent"]["denom"]="aphoton"'
|
||||
update_genesis '.app_state["registry"]["params"]["authority_auction_commit_fee"]["denom"]="aphoton"'
|
||||
update_genesis '.app_state["registry"]["params"]["authority_auction_reveal_fee"]["denom"]="aphoton"'
|
||||
update_genesis '.app_state["registry"]["params"]["authority_auction_minimum_bid"]["denom"]="aphoton"'
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["record_rent"]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_rent"]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_auction_commit_fee"]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_auction_reveal_fee"]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_auction_minimum_bid"]["denom"]="aphoton"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
|
||||
if [[ "$TEST_REGISTRY_EXPIRY" == "true" ]]; then
|
||||
echo "Setting timers for expiry tests."
|
||||
|
||||
update_genesis '.app_state["registry"]["params"]["record_rent_duration"]="60s"'
|
||||
update_genesis '.app_state["registry"]["params"]["authority_grace_period"]="60s"'
|
||||
update_genesis '.app_state["registry"]["params"]["authority_rent_duration"]="60s"'
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["record_rent_duration"]="60s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_grace_period"]="60s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_rent_duration"]="60s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
fi
|
||||
|
||||
if [[ "$TEST_AUCTION_ENABLED" == "true" ]]; then
|
||||
echo "Enabling auction and setting timers."
|
||||
|
||||
update_genesis '.app_state["registry"]["params"]["authority_auction_enabled"]=true'
|
||||
update_genesis '.app_state["registry"]["params"]["authority_rent_duration"]="60s"'
|
||||
update_genesis '.app_state["registry"]["params"]["authority_grace_period"]="300s"'
|
||||
update_genesis '.app_state["registry"]["params"]["authority_auction_commits_duration"]="60s"'
|
||||
update_genesis '.app_state["registry"]["params"]["authority_auction_reveals_duration"]="60s"'
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_auction_enabled"]=true' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_rent_duration"]="60s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_grace_period"]="300s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_auction_commits_duration"]="60s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.app_state["registry"]["params"]["authority_auction_reveals_duration"]="60s"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
fi
|
||||
|
||||
# increase block time (?)
|
||||
update_genesis '.consensus_params["block"]["time_iota_ms"]="1000"'
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.consensus_params["block"]["time_iota_ms"]="1000"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
|
||||
# Set gas limit in genesis
|
||||
update_genesis '.consensus_params["block"]["max_gas"]="10000000"'
|
||||
cat $HOME/.laconicd/config/genesis.json | jq '.consensus_params["block"]["max_gas"]="10000000"' > $HOME/.laconicd/config/tmp_genesis.json && mv $HOME/.laconicd/config/tmp_genesis.json $HOME/.laconicd/config/genesis.json
|
||||
|
||||
# disable produce empty block
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
sed -i '' 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml
|
||||
else
|
||||
sed -i 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml
|
||||
sed -i '' 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml
|
||||
else
|
||||
sed -i 's/create_empty_blocks = true/create_empty_blocks = false/g' $HOME/.laconicd/config/config.toml
|
||||
fi
|
||||
|
||||
if [[ "$1" == "pending" ]]; then
|
||||
alias sed-i="sed -i"
|
||||
if [[ $1 == "pending" ]]; then
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
alias sed-i="sed -i ''"
|
||||
sed -i '' 's/create_empty_blocks_interval = "0s"/create_empty_blocks_interval = "30s"/g' $HOME/.laconicd/config/config.toml
|
||||
sed -i '' 's/timeout_propose = "3s"/timeout_propose = "30s"/g' $HOME/.laconicd/config/config.toml
|
||||
sed -i '' 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "5s"/g' $HOME/.laconicd/config/config.toml
|
||||
sed -i '' 's/timeout_prevote = "1s"/timeout_prevote = "10s"/g' $HOME/.laconicd/config/config.toml
|
||||
sed -i '' 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "5s"/g' $HOME/.laconicd/config/config.toml
|
||||
sed -i '' 's/timeout_precommit = "1s"/timeout_precommit = "10s"/g' $HOME/.laconicd/config/config.toml
|
||||
sed -i '' 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "5s"/g' $HOME/.laconicd/config/config.toml
|
||||
sed -i '' 's/timeout_commit = "5s"/timeout_commit = "150s"/g' $HOME/.laconicd/config/config.toml
|
||||
sed -i '' 's/timeout_broadcast_tx_commit = "10s"/timeout_broadcast_tx_commit = "150s"/g' $HOME/.laconicd/config/config.toml
|
||||
else
|
||||
sed -i 's/create_empty_blocks_interval = "0s"/create_empty_blocks_interval = "30s"/g' $HOME/.laconicd/config/config.toml
|
||||
sed -i 's/timeout_propose = "3s"/timeout_propose = "30s"/g' $HOME/.laconicd/config/config.toml
|
||||
sed -i 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "5s"/g' $HOME/.laconicd/config/config.toml
|
||||
sed -i 's/timeout_prevote = "1s"/timeout_prevote = "10s"/g' $HOME/.laconicd/config/config.toml
|
||||
sed -i 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "5s"/g' $HOME/.laconicd/config/config.toml
|
||||
sed -i 's/timeout_precommit = "1s"/timeout_precommit = "10s"/g' $HOME/.laconicd/config/config.toml
|
||||
sed -i 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "5s"/g' $HOME/.laconicd/config/config.toml
|
||||
sed -i 's/timeout_commit = "5s"/timeout_commit = "150s"/g' $HOME/.laconicd/config/config.toml
|
||||
sed -i 's/timeout_broadcast_tx_commit = "10s"/timeout_broadcast_tx_commit = "150s"/g' $HOME/.laconicd/config/config.toml
|
||||
fi
|
||||
sed-i \
|
||||
-e 's/create_empty_blocks_interval = "0s"/create_empty_blocks_interval = "30s"/g' \
|
||||
-e 's/timeout_propose = "3s"/timeout_propose = "30s"/g' \
|
||||
-e 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "5s"/g' \
|
||||
-e 's/timeout_prevote = "1s"/timeout_prevote = "10s"/g' \
|
||||
-e 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "5s"/g' \
|
||||
-e 's/timeout_precommit = "1s"/timeout_precommit = "10s"/g' \
|
||||
-e 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "5s"/g' \
|
||||
-e 's/timeout_commit = "5s"/timeout_commit = "150s"/g' \
|
||||
-e 's/timeout_broadcast_tx_commit = "10s"/timeout_broadcast_tx_commit = "150s"/g' \
|
||||
$HOME/.laconicd/config/config.toml
|
||||
fi
|
||||
|
||||
# Allocate genesis accounts (cosmos formatted addresses)
|
||||
@@ -106,16 +106,9 @@ laconicd collect-gentxs
|
||||
# Run this to ensure everything worked and that the genesis file is setup correctly
|
||||
laconicd validate-genesis
|
||||
|
||||
if [[ "$1" == "pending" ]]; then
|
||||
if [[ $1 == "pending" ]]; then
|
||||
echo "pending mode is on, please wait for the first block committed."
|
||||
fi
|
||||
|
||||
# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
|
||||
laconicd start \
|
||||
--pruning=nothing \
|
||||
--evm.tracer=json $TRACE \
|
||||
--log_level $LOGLEVEL \
|
||||
--minimum-gas-prices=0.0001aphoton \
|
||||
--json-rpc.api eth,txpool,personal,net,debug,web3,miner \
|
||||
--api.enable \
|
||||
--gql-server --gql-playground
|
||||
laconicd start --pruning=nothing --evm.tracer=json $TRACE --log_level $LOGLEVEL --minimum-gas-prices=0.0001aphoton --json-rpc.api eth,txpool,personal,net,debug,web3,miner --api.enable --gql-server --gql-playground
|
||||
|
||||
@@ -5,29 +5,109 @@ import "gogoproto/gogo.proto";
|
||||
|
||||
option go_package = "github.com/cerc-io/laconicd/x/registry/types";
|
||||
|
||||
message ServiceProviderRegistration {
|
||||
message HashReference{
|
||||
string ref =1 [(gogoproto.jsontag) = "/"];
|
||||
}
|
||||
|
||||
message ServiceProviderRecord {
|
||||
string bond_id = 1 [(gogoproto.moretags) = "json:\"bondId\" yaml:\"bondId\""];
|
||||
string laconic_id = 2 [(gogoproto.moretags) = "json:\"laconicId\" yaml:\"laconicId\""];
|
||||
X500 x500 = 3 [(gogoproto.moretags) = "json:\"x500\" yaml:\"x500\""];
|
||||
string type = 4 [(gogoproto.moretags) = "json:\"type\" yaml:\"type\""];
|
||||
string version = 6 [(gogoproto.moretags) = "json:\"version\" yaml:\"version\""];
|
||||
|
||||
message X500 {
|
||||
string common_name = 1 [(gogoproto.moretags) = "json:\"commonName\" yaml:\"commonName\""];
|
||||
string organization_unit = 2 [(gogoproto.moretags) = "json:\"organizationUnit\" yaml:\"organizationUnit\""];
|
||||
string organization_name = 3 [(gogoproto.moretags) = "json:\"organizationName\" yaml:\"organizationName\""];
|
||||
string locality_name = 4 [(gogoproto.moretags) = "json:\"localityName\" yaml:\"localityName\""];
|
||||
string state_name = 5 [(gogoproto.moretags) = "json:\"stateName\" yaml:\"stateName\""];
|
||||
string country = 6 [(gogoproto.moretags) = "json:\"country\" yaml:\"country\""];
|
||||
}
|
||||
}
|
||||
|
||||
message X500 {
|
||||
string common_name = 1 [(gogoproto.moretags) = "json:\"commonName\" yaml:\"commonName\""];
|
||||
string organization_unit = 2 [(gogoproto.moretags) = "json:\"organizationUnit\" yaml:\"organizationUnit\""];
|
||||
string organization_name = 3 [(gogoproto.moretags) = "json:\"organizationName\" yaml:\"organizationName\""];
|
||||
string locality_name = 4 [(gogoproto.moretags) = "json:\"localityName\" yaml:\"localityName\""];
|
||||
string state_name = 5 [(gogoproto.moretags) = "json:\"stateName\" yaml:\"stateName\""];
|
||||
string country = 6 [(gogoproto.moretags) = "json:\"country\" yaml:\"country\""];
|
||||
}
|
||||
|
||||
|
||||
message WebsiteRegistrationRecord {
|
||||
string url = 1 [(gogoproto.moretags) = "json:\"url\" yaml:\"url\""];
|
||||
string repo_registration_record_cid = 2
|
||||
[(gogoproto.moretags) = "json:\"repoRegistrationRecordCID\" yaml:\"repoRegistrationRecordCID\""];
|
||||
string build_artifact_cid = 3 [(gogoproto.moretags) = "json:\"buildArtifactCID\" yaml:\"buildArtifactCID\""];
|
||||
string tls_cert_cid = 4 [(gogoproto.moretags) = "json:\"TLSCertCID\" yaml:\"TLSCertCID\""];
|
||||
HashReference repo_reference = 2
|
||||
[(gogoproto.moretags) = "json:\"repoReference\" yaml:\"repoReference\""];
|
||||
HashReference build_artifact_ref = 3 [(gogoproto.moretags) = "json:\"buildArtifactRef\" yaml:\"buildArtifactRef\""];
|
||||
HashReference tls_cert_ref = 4 [(gogoproto.moretags) = "json:\"tlsCertRef\" yaml:\"tlsCertRef\""];
|
||||
string type = 5 [(gogoproto.moretags) = "json:\"type\" yaml:\"type\""];
|
||||
string version = 6 [(gogoproto.moretags) = "json:\"version\" yaml:\"version\""];
|
||||
}
|
||||
|
||||
message GitRepository{
|
||||
string name =1 [(gogoproto.moretags) = "json:\"name\" yaml:\"name\""];
|
||||
string repo_reference=2 [(gogoproto.moretags) = "json:\"repo_reference\" yaml:\"repo_reference\""];
|
||||
string description=3 [(gogoproto.moretags) = "json:\"description\" yaml:\"description\""];
|
||||
string version = 4 [(gogoproto.moretags) = "json:\"version\" yaml:\"version\""];
|
||||
string type =5 [(gogoproto.moretags) = "json:\"type\" yaml:\"type\""];
|
||||
}
|
||||
|
||||
message Binary{
|
||||
HashReference hash_reference=1;
|
||||
string targeted_arch=2;
|
||||
string runtime_version=3;
|
||||
HashReference repo_reference=4;
|
||||
string version=5;
|
||||
string type=6;
|
||||
}
|
||||
|
||||
message DockerImage{
|
||||
string image_id=1;
|
||||
HashReference binary_reference=2;
|
||||
HashReference repo_reference=3;
|
||||
string version=4;
|
||||
string type=5;
|
||||
}
|
||||
|
||||
message WatcherRegistrationRecord{
|
||||
WatcherMetadata metadata =1;
|
||||
HashReference repo_reference=2;
|
||||
WASMBinary wasm=3;
|
||||
string version=4;
|
||||
string type=5;
|
||||
|
||||
message WatcherMetadata{
|
||||
string version=1;
|
||||
HashReference chain_reference=2;
|
||||
}
|
||||
|
||||
message WASMBinary{
|
||||
HashReference hash_reference=1;
|
||||
WASMBinaryMetadata metadata=2;
|
||||
}
|
||||
|
||||
message WASMBinaryMetadata{
|
||||
string compiler_version=1;
|
||||
string execution_engine_version=2;
|
||||
}
|
||||
}
|
||||
|
||||
message ResponderContract{
|
||||
HashReference service_provider_ref=1;
|
||||
HashReference auction_ref=2;
|
||||
HashReference watcher_ref=3;
|
||||
string version=4;
|
||||
string type=5;
|
||||
}
|
||||
|
||||
message JSPackage{
|
||||
HashReference repo_reference=1;
|
||||
HashReference js_package_ref=2;
|
||||
string version=3;
|
||||
string type=4;
|
||||
string name =5;
|
||||
}
|
||||
|
||||
message ChainRegistrationRecord{
|
||||
string name=1;
|
||||
repeated string ipld_types=2;
|
||||
string type=3;
|
||||
string version=4;
|
||||
string chain_id=5;
|
||||
string network_id=6;
|
||||
HashReference genesis_hash=7;
|
||||
}
|
||||
@@ -56,7 +56,7 @@ message Params {
|
||||
];
|
||||
}
|
||||
|
||||
// Record defines a registry record
|
||||
// Params defines the registry module records
|
||||
message Record {
|
||||
string id = 1 [(gogoproto.moretags) = "json:\"id\" yaml:\"id\""];
|
||||
string bond_id = 2 [(gogoproto.moretags) = "json:\"bondId\" yaml:\"bondId\""];
|
||||
@@ -69,7 +69,7 @@ message Record {
|
||||
string type = 9 [(gogoproto.moretags) = "json:\"types\" yaml:\"types\""];
|
||||
}
|
||||
|
||||
// AuthorityEntry defines a registry authority
|
||||
// AuthorityEntry defines the registry module AuthorityEntries
|
||||
message AuthorityEntry {
|
||||
string name = 1;
|
||||
NameAuthority entry = 2;
|
||||
@@ -99,7 +99,7 @@ message NameEntry {
|
||||
NameRecord entry = 2;
|
||||
}
|
||||
|
||||
// NameRecord defines a versioned name record
|
||||
// NameRecord
|
||||
message NameRecord {
|
||||
NameRecordEntry latest = 1;
|
||||
repeated NameRecordEntry history = 2;
|
||||
@@ -131,4 +131,4 @@ message BlockChangeSet {
|
||||
message AuctionBidInfo {
|
||||
string auction_id = 1 [(gogoproto.moretags) = "json:\"auctionID\" yaml:\"auctionID\""];
|
||||
string bidder_address = 2 [(gogoproto.moretags) = "json:\"bidderAddress\" yaml:\"bidderAddress\""];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
# Originally from: https://github.com/devcontainers/images/blob/main/src/javascript-node/.devcontainer/Dockerfile
|
||||
# [Choice] Node.js version (use -bullseye variants on local arm64/Apple Silicon): 18, 16, 14, 18-bullseye, 16-bullseye, 14-bullseye, 18-buster, 16-buster, 14-buster
|
||||
ARG VARIANT=16-bullseye
|
||||
FROM node:${VARIANT}
|
||||
|
||||
ARG USERNAME=node
|
||||
ARG NPM_GLOBAL=/usr/local/share/npm-global
|
||||
|
||||
# Add NPM global to PATH.
|
||||
ENV PATH=${NPM_GLOBAL}/bin:${PATH}
|
||||
|
||||
RUN \
|
||||
# Configure global npm install location, use group to adapt to UID/GID changes
|
||||
if ! cat /etc/group | grep -e "^npm:" > /dev/null 2>&1; then groupadd -r npm; fi \
|
||||
&& usermod -a -G npm ${USERNAME} \
|
||||
&& umask 0002 \
|
||||
&& mkdir -p ${NPM_GLOBAL} \
|
||||
&& touch /usr/local/etc/npmrc \
|
||||
&& chown ${USERNAME}:npm ${NPM_GLOBAL} /usr/local/etc/npmrc \
|
||||
&& chmod g+s ${NPM_GLOBAL} \
|
||||
&& npm config -g set prefix ${NPM_GLOBAL} \
|
||||
&& su ${USERNAME} -c "npm config -g set prefix ${NPM_GLOBAL}" \
|
||||
# Install eslint
|
||||
&& su ${USERNAME} -c "umask 0002 && npm install -g eslint" \
|
||||
&& npm cache clean --force > /dev/null 2>&1
|
||||
|
||||
# [Optional] Uncomment this section to install additional OS packages.
|
||||
# RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
|
||||
# && apt-get -y install --no-install-recommends <your-package-list-here>
|
||||
|
||||
# [Optional] Uncomment if you want to install an additional version of node using nvm
|
||||
# ARG EXTRA_NODE_VERSION=10
|
||||
# RUN su node -c "source /usr/local/share/nvm/nvm.sh && nvm install ${EXTRA_NODE_VERSION}"
|
||||
|
||||
# [Optional] Uncomment if you want to install more global node modules
|
||||
# RUN su node -c "npm install -g <your-package-list-here>"
|
||||
|
||||
WORKDIR /
|
||||
COPY entrypoint.sh .
|
||||
ENTRYPOINT ["/entrypoint.sh"]
|
||||
# Placeholder CMD : generally this will be overridden at run time like :
|
||||
# docker run -it -v /home/builder/cerc/laconic-sdk:/workspace cerc/builder-js sh -c 'cd /workspace && yarn && yarn build'
|
||||
CMD node --version
|
||||
|
||||
# Temp hack, clone the laconic-sdk repo here
|
||||
WORKDIR /app
|
||||
RUN \
|
||||
git clone https://github.com/cerc-io/laconic-sdk.git \
|
||||
&& cd laconic-sdk \
|
||||
&& yarn install
|
||||
|
||||
WORKDIR /app/laconic-sdk
|
||||
@@ -1,2 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
docker build -t cerc/laconicd:local ../.. --progress=plain
|
||||
docker build -t cerc-io/laconicd:local-test ../../
|
||||
|
||||
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/usr/bin/env bash
|
||||
docker build -t cerc-io/laconic-sdk-tester:local-test -f Dockerfile-sdk .
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
services:
|
||||
laconicd:
|
||||
restart: unless-stopped
|
||||
image: cerc-io/laconicd:local-test
|
||||
environment:
|
||||
- TEST_AUCTION_ENABLED=true
|
||||
command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
|
||||
volumes:
|
||||
- ../../init.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-v", "http://127.0.0.1:6060"]
|
||||
interval: 1s
|
||||
timeout: 5s
|
||||
retries: 30
|
||||
ports:
|
||||
- "6060"
|
||||
- "26657"
|
||||
- "26656"
|
||||
- "9473"
|
||||
- "8545"
|
||||
- "8546"
|
||||
- "9090"
|
||||
- "9091"
|
||||
- "1317"
|
||||
|
||||
sdk-test-runner:
|
||||
image: cerc-io/laconic-sdk-tester:local-test
|
||||
depends_on:
|
||||
laconicd:
|
||||
condition: service_healthy
|
||||
command: tail -F /dev/null
|
||||
@@ -0,0 +1,31 @@
|
||||
services:
|
||||
laconicd:
|
||||
restart: unless-stopped
|
||||
image: cerc-io/laconicd:local-test
|
||||
environment:
|
||||
- TEST_REGISTRY_EXPIRY=true
|
||||
command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
|
||||
volumes:
|
||||
- ../../init.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-v", "http://127.0.0.1:6060"]
|
||||
interval: 1s
|
||||
timeout: 5s
|
||||
retries: 30
|
||||
ports:
|
||||
- "6060"
|
||||
- "26657"
|
||||
- "26656"
|
||||
- "9473"
|
||||
- "8545"
|
||||
- "8546"
|
||||
- "9090"
|
||||
- "9091"
|
||||
- "1317"
|
||||
|
||||
sdk-test-runner:
|
||||
image: cerc-io/laconic-sdk-tester:local-test
|
||||
depends_on:
|
||||
laconicd:
|
||||
condition: service_healthy
|
||||
command: tail -F /dev/null
|
||||
@@ -1,14 +1,10 @@
|
||||
services:
|
||||
laconicd:
|
||||
restart: unless-stopped
|
||||
image: cerc/laconicd:local
|
||||
entrypoint: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
|
||||
environment:
|
||||
- TEST_AUCTION_ENABLED
|
||||
- TEST_REGISTRY_EXPIRY
|
||||
- LOGLEVEL
|
||||
image: cerc-io/laconicd:local-test
|
||||
command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
|
||||
volumes:
|
||||
- ../../init.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh
|
||||
- ../../init.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh
|
||||
healthcheck:
|
||||
test: ["CMD", "curl", "-v", "http://127.0.0.1:6060"]
|
||||
interval: 1s
|
||||
@@ -26,7 +22,7 @@ services:
|
||||
- "1317"
|
||||
|
||||
sdk-test-runner:
|
||||
image: cerc/laconic-sdk-tester:local
|
||||
image: cerc-io/laconic-sdk-tester:local-test
|
||||
depends_on:
|
||||
laconicd:
|
||||
condition: service_healthy
|
||||
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/sh
|
||||
exec "$@"
|
||||
|
||||
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
# Get the key from laconicd
|
||||
laconicd_key=$( docker compose exec laconicd echo y | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe )
|
||||
# Set parameters for the test suite
|
||||
cosmos_chain_id=laconic_9000-1
|
||||
laconicd_rest_endpoint=http://laconicd:1317
|
||||
laconicd_gql_endpoint=http://laconicd:9473/api
|
||||
# Run tests
|
||||
docker network inspect sdk_tests_default
|
||||
sleep 30s
|
||||
docker logs sdk_tests-laconicd-1
|
||||
|
||||
docker compose exec sdk-test-runner sh -c "COSMOS_CHAIN_ID=${cosmos_chain_id} LACONICD_REST_ENDPOINT=${laconicd_rest_endpoint} LACONICD_GQL_ENDPOINT=${laconicd_gql_endpoint} PRIVATE_KEY=${laconicd_key} yarn test:auctions"
|
||||
+16
@@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
# Get the key from laconicd
|
||||
laconicd_key=$( docker compose exec laconicd echo y | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe )
|
||||
# Set parameters for the test suite
|
||||
cosmos_chain_id=laconic_9000-1
|
||||
laconicd_rest_endpoint=http://laconicd:1317
|
||||
laconicd_gql_endpoint=http://laconicd:9473/api
|
||||
# Run tests
|
||||
docker network inspect sdk_tests_default
|
||||
sleep 30s
|
||||
docker logs sdk_tests-laconicd-1
|
||||
|
||||
docker compose exec sdk-test-runner sh -c "COSMOS_CHAIN_ID=${cosmos_chain_id} LACONICD_REST_ENDPOINT=${laconicd_rest_endpoint} LACONICD_GQL_ENDPOINT=${laconicd_gql_endpoint} PRIVATE_KEY=${laconicd_key} yarn test:nameservice-expiry"
|
||||
@@ -1,26 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
# Forwards all args to yarn on the sdk-test-runner container
|
||||
|
||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||
set -x
|
||||
fi
|
||||
|
||||
yarn_args=("--inspect-brk=8888")
|
||||
yarn_args+=("${@:-test}")
|
||||
|
||||
# Get the key from laconicd
|
||||
laconicd_key=$(
|
||||
yes | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe
|
||||
)
|
||||
laconicd_key=$( docker compose exec laconicd echo y | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe )
|
||||
# Set parameters for the test suite
|
||||
cosmos_chain_id=laconic_9000-1
|
||||
laconicd_rest_endpoint=http://laconicd:1317
|
||||
laconicd_gql_endpoint=http://laconicd:9473/api
|
||||
|
||||
# Run tests
|
||||
docker compose exec \
|
||||
-e COSMOS_CHAIN_ID="$cosmos_chain_id" \
|
||||
-e LACONICD_REST_ENDPOINT="$laconicd_rest_endpoint" \
|
||||
-e LACONICD_GQL_ENDPOINT="$laconicd_gql_endpoint" \
|
||||
-e PRIVATE_KEY="$laconicd_key" \
|
||||
sdk-test-runner yarn run "${yarn_args[@]}"
|
||||
docker network inspect sdk_tests_default
|
||||
sleep 30s
|
||||
docker logs laconicd
|
||||
docker compose exec laconicd sh -c "curl http://127.0.0.1:9473/api"
|
||||
docker compose exec laconicd sh -c "curl http://localhost:9473/api"
|
||||
|
||||
docker compose exec sdk-test-runner sh -c "COSMOS_CHAIN_ID=${cosmos_chain_id} LACONICD_REST_ENDPOINT=${laconicd_rest_endpoint} LACONICD_GQL_ENDPOINT=${laconicd_gql_endpoint} PRIVATE_KEY=${laconicd_key} yarn test"
|
||||
|
||||
@@ -519,7 +519,6 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) {
|
||||
|
||||
l.Log("starting test network...")
|
||||
for _, v := range network.Validators {
|
||||
l.Log("starting validator:", v.Moniker)
|
||||
err := startInProcess(cfg, v)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
||||
@@ -72,6 +72,10 @@ $ %s tx %s set [payload file path] [bond-id]
|
||||
}
|
||||
|
||||
msg := types.NewMsgSetRecord(payload, args[1], clientCtx.GetFromAddress())
|
||||
err = msg.ValidateBasic()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return tx.GenerateOrBroadcastTxCLI(clientCtx, cmd.Flags(), &msg)
|
||||
},
|
||||
}
|
||||
|
||||
@@ -42,8 +42,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryParams() {
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
resp, err := rest.GetRequest(tc.url)
|
||||
s.NoError(err)
|
||||
resp, _ := rest.GetRequest(tc.url)
|
||||
require := s.Require()
|
||||
if tc.expectErr {
|
||||
require.Contains(string(resp), tc.errorMsg)
|
||||
@@ -61,7 +60,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryParams() {
|
||||
}
|
||||
}
|
||||
|
||||
// nolint: all
|
||||
//nolint:all
|
||||
func (s *IntegrationTestSuite) TestGRPCQueryWhoIs() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
@@ -111,11 +110,11 @@ func (s *IntegrationTestSuite) TestGRPCQueryWhoIs() {
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
tc.preRun(authorityName)
|
||||
tc.url = fmt.Sprintf(tc.url, authorityName)
|
||||
|
||||
resp, err := rest.GetRequest(tc.url)
|
||||
s.NoError(err)
|
||||
if !tc.expectErr {
|
||||
tc.preRun(authorityName)
|
||||
tc.url = fmt.Sprintf(tc.url, authorityName)
|
||||
}
|
||||
resp, _ := rest.GetRequest(tc.url)
|
||||
require := s.Require()
|
||||
if tc.expectErr {
|
||||
require.Contains(string(resp), tc.errorMsg)
|
||||
@@ -132,7 +131,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryWhoIs() {
|
||||
func (s *IntegrationTestSuite) TestGRPCQueryLookup() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
reqURL := val.APIAddress + "/vulcanize/registry/v1beta1/lookup"
|
||||
reqURL := val.APIAddress + "/vulcanize/registry/v1beta1/lookup?crn=%s"
|
||||
authorityName := "QueryLookUp"
|
||||
|
||||
testCases := []struct {
|
||||
@@ -152,7 +151,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryLookup() {
|
||||
},
|
||||
{
|
||||
"Success",
|
||||
fmt.Sprintf(reqURL+"?crn=crn://%s/", authorityName),
|
||||
reqURL,
|
||||
false,
|
||||
"",
|
||||
func(authorityName string) {
|
||||
@@ -164,9 +163,11 @@ func (s *IntegrationTestSuite) TestGRPCQueryLookup() {
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
tc.preRun(authorityName)
|
||||
resp, err := rest.GetRequest(tc.url)
|
||||
s.NoError(err)
|
||||
if !tc.expectErr {
|
||||
tc.preRun(authorityName)
|
||||
tc.url = fmt.Sprintf(reqURL, fmt.Sprintf("crn://%s/", authorityName))
|
||||
}
|
||||
resp, _ := rest.GetRequest(tc.url)
|
||||
if tc.expectErr {
|
||||
sr.Contains(string(resp), tc.errorMsg)
|
||||
} else {
|
||||
@@ -179,7 +180,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryLookup() {
|
||||
}
|
||||
}
|
||||
|
||||
// nolint: all
|
||||
//nolint:all
|
||||
func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
@@ -208,7 +209,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() {
|
||||
func(bondId string) {
|
||||
dir, err := os.Getwd()
|
||||
sr.NoError(err)
|
||||
payloadPath := dir + "/service_provider_example.yml"
|
||||
payloadPath := dir + "/../../helpers/examples/service_provider_example.yml"
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
@@ -232,11 +233,12 @@ func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() {
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
tc.preRun(s.bondID)
|
||||
if !tc.expectErr {
|
||||
tc.preRun(s.bondID)
|
||||
}
|
||||
// wait 12 seconds for records expires
|
||||
time.Sleep(time.Second * 12)
|
||||
resp, err := rest.GetRequest(tc.url)
|
||||
s.NoError(err)
|
||||
resp, _ := rest.GetRequest(tc.url)
|
||||
require := s.Require()
|
||||
if tc.expectErr {
|
||||
require.Contains(string(resp), tc.errorMsg)
|
||||
@@ -250,7 +252,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() {
|
||||
}
|
||||
}
|
||||
|
||||
// nolint: all
|
||||
//nolint:all
|
||||
func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
@@ -301,12 +303,13 @@ func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() {
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
tc.preRun("QueryAuthorityExpiryQueue")
|
||||
if !tc.expectErr {
|
||||
tc.preRun("QueryAuthorityExpiryQueue")
|
||||
}
|
||||
// wait 12 seconds to name authorites expires
|
||||
time.Sleep(time.Second * 12)
|
||||
|
||||
resp, err := rest.GetRequest(tc.url)
|
||||
s.NoError(err)
|
||||
resp, _ := rest.GetRequest(tc.url)
|
||||
require := s.Require()
|
||||
if tc.expectErr {
|
||||
require.Contains(string(resp), tc.errorMsg)
|
||||
@@ -321,7 +324,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() {
|
||||
}
|
||||
}
|
||||
|
||||
// nolint: all
|
||||
//nolint:all
|
||||
func (s *IntegrationTestSuite) TestGRPCQueryListRecords() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
@@ -350,7 +353,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryListRecords() {
|
||||
func(bondId string) {
|
||||
dir, err := os.Getwd()
|
||||
sr.NoError(err)
|
||||
payloadPath := dir + "/service_provider_example.yml"
|
||||
payloadPath := dir + "/../../helpers/examples/service_provider_example.yml"
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
@@ -374,9 +377,10 @@ func (s *IntegrationTestSuite) TestGRPCQueryListRecords() {
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
tc.preRun(s.bondID)
|
||||
resp, err := rest.GetRequest(tc.url)
|
||||
s.NoError(err)
|
||||
if !tc.expectErr {
|
||||
tc.preRun(s.bondID)
|
||||
}
|
||||
resp, _ := rest.GetRequest(tc.url)
|
||||
require := s.Require()
|
||||
if tc.expectErr {
|
||||
require.Contains(string(resp), tc.errorMsg)
|
||||
@@ -439,11 +443,12 @@ func (s *IntegrationTestSuite) TestGRPCQueryGetRecordByID() {
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
recordID := tc.preRun(s.bondID)
|
||||
tc.url = fmt.Sprintf(reqURL, recordID)
|
||||
|
||||
resp, err := rest.GetRequest(tc.url)
|
||||
s.NoError(err)
|
||||
var recordID string
|
||||
if !tc.expectErr {
|
||||
recordID = tc.preRun(s.bondID)
|
||||
tc.url = fmt.Sprintf(reqURL, recordID)
|
||||
}
|
||||
resp, _ := rest.GetRequest(tc.url)
|
||||
require := s.Require()
|
||||
if tc.expectErr {
|
||||
require.Contains(string(resp), tc.errorMsg)
|
||||
@@ -493,11 +498,11 @@ func (s *IntegrationTestSuite) TestGRPCQueryGetRecordByBondID() {
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
tc.preRun(s.bondID)
|
||||
tc.url = fmt.Sprintf(reqURL, s.bondID)
|
||||
|
||||
resp, err := rest.GetRequest(tc.url)
|
||||
s.NoError(err)
|
||||
if !tc.expectErr {
|
||||
tc.preRun(s.bondID)
|
||||
tc.url = fmt.Sprintf(reqURL, s.bondID)
|
||||
}
|
||||
resp, _ := rest.GetRequest(tc.url)
|
||||
require := s.Require()
|
||||
if tc.expectErr {
|
||||
require.Contains(string(resp), tc.errorMsg)
|
||||
@@ -547,9 +552,10 @@ func (s *IntegrationTestSuite) TestGRPCQueryGetRegistryModuleBalance() {
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
tc.preRun(s.bondID)
|
||||
resp, err := rest.GetRequest(tc.url)
|
||||
s.NoError(err)
|
||||
if !tc.expectErr {
|
||||
tc.preRun(s.bondID)
|
||||
}
|
||||
resp, _ := rest.GetRequest(tc.url)
|
||||
require := s.Require()
|
||||
if tc.expectErr {
|
||||
require.Contains(string(resp), tc.errorMsg)
|
||||
@@ -597,9 +603,10 @@ func (s *IntegrationTestSuite) TestGRPCQueryNamesList() {
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(tc.name, func() {
|
||||
tc.preRun("ListNameRecords")
|
||||
resp, err := rest.GetRequest(tc.url)
|
||||
s.NoError(err)
|
||||
if !tc.expectErr {
|
||||
tc.preRun("ListNameRecords")
|
||||
}
|
||||
resp, _ := rest.GetRequest(tc.url)
|
||||
require := s.Require()
|
||||
if tc.expectErr {
|
||||
require.Contains(string(resp), tc.errorMsg)
|
||||
@@ -619,7 +626,7 @@ func createRecord(bondID string, s *IntegrationTestSuite) {
|
||||
|
||||
dir, err := os.Getwd()
|
||||
sr.NoError(err)
|
||||
payloadPath := dir + "/service_provider_example.yml"
|
||||
payloadPath := dir + "/../../helpers/examples/service_provider_example.yml"
|
||||
args := []string{
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
@@ -636,5 +643,5 @@ func createRecord(bondID string, s *IntegrationTestSuite) {
|
||||
var d sdk.TxResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &d)
|
||||
sr.NoError(err)
|
||||
sr.Zero(d.Code, d.RawLog)
|
||||
sr.Zero(d.Code)
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ func (s *IntegrationTestSuite) TestGetCmdQueryForRecords() {
|
||||
bondID := GetBondID(s)
|
||||
dir, err := os.Getwd()
|
||||
sr.NoError(err)
|
||||
payloadPath := dir + "/service_provider_example.yml"
|
||||
payloadPath := dir + "/../../helpers/examples/service_provider_example.yml"
|
||||
args := []string{
|
||||
payloadPath, bondID,
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||
@@ -538,6 +538,9 @@ func createNameRecord(authorityName string, s *IntegrationTestSuite) {
|
||||
sr.NoError(err)
|
||||
sr.Zero(d.Code)
|
||||
|
||||
// creating the bond
|
||||
CreateBond(s)
|
||||
|
||||
// Get the bond-id
|
||||
bondID := GetBondID(s)
|
||||
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
|
||||
record:
|
||||
type: ServiceProviderRegistration
|
||||
bond_id: madeUpBondID
|
||||
laconic_id: madeUpLaconicID
|
||||
version: 1.0.0
|
||||
x500:
|
||||
common_name: cerc-io
|
||||
organization_unit: xyz
|
||||
organization_name: abc
|
||||
state_name: california
|
||||
country: US
|
||||
locality_name: local
|
||||
@@ -101,23 +101,42 @@ func CreateBond(s *IntegrationTestSuite) {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
|
||||
clientCtx := val.ClientCtx
|
||||
cmd := bondcli.NewCreateBondCmd()
|
||||
args := []string{
|
||||
fmt.Sprintf("100000000000%s", s.cfg.BondDenom),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("3%s", s.cfg.BondDenom)),
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
err bool
|
||||
}{
|
||||
{
|
||||
"create bond",
|
||||
[]string{
|
||||
fmt.Sprintf("100000000000%s", s.cfg.BondDenom),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("3%s", s.cfg.BondDenom)),
|
||||
},
|
||||
false,
|
||||
},
|
||||
}
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
|
||||
sr.NoError(err)
|
||||
|
||||
var d sdk.TxResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &d)
|
||||
sr.NoError(err)
|
||||
sr.Zero(d.Code)
|
||||
for _, tc := range testCases {
|
||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||
clientCtx := val.ClientCtx
|
||||
cmd := bondcli.NewCreateBondCmd()
|
||||
|
||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, tc.args)
|
||||
if tc.err {
|
||||
sr.Error(err)
|
||||
} else {
|
||||
sr.NoError(err)
|
||||
var d sdk.TxResponse
|
||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &d)
|
||||
sr.NoError(err)
|
||||
sr.Zero(d.Code)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
func GetBondID(s *IntegrationTestSuite) string {
|
||||
@@ -141,11 +160,6 @@ func (s *IntegrationTestSuite) TestGetCmdSetRecord() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
|
||||
bondID := GetBondID(s)
|
||||
dir, err := os.Getwd()
|
||||
sr.NoError(err)
|
||||
payloadPath := dir + "/service_provider_example.yml"
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
args []string
|
||||
@@ -165,7 +179,6 @@ func (s *IntegrationTestSuite) TestGetCmdSetRecord() {
|
||||
{
|
||||
"success",
|
||||
[]string{
|
||||
payloadPath, bondID,
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
@@ -178,6 +191,17 @@ func (s *IntegrationTestSuite) TestGetCmdSetRecord() {
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||
if !tc.err {
|
||||
// create the bond
|
||||
CreateBond(s)
|
||||
// get the bond id from bond list
|
||||
bondID := GetBondID(s)
|
||||
dir, err := os.Getwd()
|
||||
sr.NoError(err)
|
||||
payloadPath := dir + "/../../helpers/examples/watcher_registration_example.yml"
|
||||
|
||||
tc.args = append([]string{payloadPath, bondID}, tc.args...)
|
||||
}
|
||||
clientCtx := val.ClientCtx
|
||||
cmd := cli.GetCmdSetRecord()
|
||||
|
||||
@@ -317,6 +341,9 @@ func (s *IntegrationTestSuite) TestGetCmdSetName() {
|
||||
sr.NoError(err)
|
||||
sr.Zero(d.Code)
|
||||
|
||||
// creating the bond
|
||||
CreateBond(s)
|
||||
|
||||
// Get the bond-id
|
||||
bondID := GetBondID(s)
|
||||
|
||||
@@ -342,7 +369,9 @@ func (s *IntegrationTestSuite) TestGetCmdSetName() {
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||
tc.preRun(authorityName)
|
||||
if !tc.err {
|
||||
tc.preRun(authorityName)
|
||||
}
|
||||
|
||||
clientCtx := val.ClientCtx
|
||||
cmd := cli.GetCmdSetName()
|
||||
@@ -365,7 +394,6 @@ func (s *IntegrationTestSuite) TestGetCmdSetAuthorityBond() {
|
||||
val := s.network.Validators[0]
|
||||
sr := s.Require()
|
||||
authorityName := "TestGetCmdSetAuthorityBond"
|
||||
bondID := GetBondID(s)
|
||||
|
||||
testCases := []struct {
|
||||
name string
|
||||
@@ -389,7 +417,6 @@ func (s *IntegrationTestSuite) TestGetCmdSetAuthorityBond() {
|
||||
{
|
||||
"success with name and bond-id",
|
||||
[]string{
|
||||
authorityName, bondID,
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
@@ -422,7 +449,15 @@ func (s *IntegrationTestSuite) TestGetCmdSetAuthorityBond() {
|
||||
|
||||
for _, tc := range testCases {
|
||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||
tc.preRun(authorityName)
|
||||
if !tc.err {
|
||||
// reserve the name
|
||||
tc.preRun(authorityName)
|
||||
// creating the bond
|
||||
CreateBond(s)
|
||||
// getting the bond-id
|
||||
bondID := GetBondID(s)
|
||||
tc.args = append([]string{authorityName, bondID}, tc.args...)
|
||||
}
|
||||
clientCtx := val.ClientCtx
|
||||
cmd := cli.GetCmdSetAuthorityBond()
|
||||
|
||||
@@ -466,7 +501,6 @@ func (s *IntegrationTestSuite) TestGetCmdDeleteName() {
|
||||
{
|
||||
"successfully delete name",
|
||||
[]string{
|
||||
fmt.Sprintf("crn://%s/", authorityName),
|
||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||
@@ -482,8 +516,10 @@ func (s *IntegrationTestSuite) TestGetCmdDeleteName() {
|
||||
|
||||
for _, tc := range testCasesForDeletingName {
|
||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||
tc.preRun(authorityName, s)
|
||||
|
||||
if !tc.err {
|
||||
tc.preRun(authorityName, s)
|
||||
tc.args = append([]string{fmt.Sprintf("crn://%s/", authorityName)}, tc.args...)
|
||||
}
|
||||
clientCtx := val.ClientCtx
|
||||
cmd := cli.GetCmdDeleteName()
|
||||
|
||||
@@ -538,11 +574,13 @@ func (s *IntegrationTestSuite) TestGetCmdDissociateBond() {
|
||||
},
|
||||
false,
|
||||
func(s *IntegrationTestSuite) string {
|
||||
// create the bond
|
||||
CreateBond(s)
|
||||
// get the bond id from bond list
|
||||
bondID := GetBondID(s)
|
||||
dir, err := os.Getwd()
|
||||
sr.NoError(err)
|
||||
payloadPath := dir + "/service_provider_example.yml"
|
||||
payloadPath := dir + "/../../helpers/examples/service_provider_example.yml"
|
||||
|
||||
args := []string{
|
||||
payloadPath, bondID,
|
||||
@@ -778,11 +816,13 @@ func (s *IntegrationTestSuite) TestGetCmdAssociateBond() {
|
||||
},
|
||||
false,
|
||||
func(s *IntegrationTestSuite) (string, string) {
|
||||
// create the bond
|
||||
CreateBond(s)
|
||||
// get the bond id from bond list
|
||||
bondID := GetBondID(s)
|
||||
dir, err := os.Getwd()
|
||||
sr.NoError(err)
|
||||
payloadPath := dir + "/service_provider_example.yml"
|
||||
payloadPath := dir + "/../../helpers/examples/service_provider_example.yml"
|
||||
|
||||
txArgs := []string{
|
||||
payloadPath, bondID,
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
record:
|
||||
type: WebsiteRegistrationRecord
|
||||
url: https://cerc.io
|
||||
repo_registration_record_cid: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
build_artifact_cid: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
tls_cert_cid: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
version: 1.0.0
|
||||
@@ -0,0 +1,9 @@
|
||||
record:
|
||||
hash_reference:
|
||||
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
targeted_arch: x86_64
|
||||
runtime_version: go 1.18
|
||||
repo_reference:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
version: 1.0.0
|
||||
type: Binary
|
||||
@@ -0,0 +1,13 @@
|
||||
record:
|
||||
name: Laconic
|
||||
ipld_types:
|
||||
- type3
|
||||
- type11
|
||||
- schema2
|
||||
- codec5
|
||||
type: ChainRegistrationRecord
|
||||
version: 0.11.2
|
||||
chain_id: laconic_9000-1
|
||||
network_id: "1392"
|
||||
genesis_hash:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
@@ -0,0 +1,8 @@
|
||||
record:
|
||||
image_id: 77af4d6b9913
|
||||
binary_reference:
|
||||
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
repo_reference:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
version: 1.0.0
|
||||
type: DockerImage
|
||||
@@ -0,0 +1,6 @@
|
||||
record:
|
||||
name: cosmos-sdk
|
||||
repo_reference: https://github.com/cosmos/cosmos-sdk
|
||||
description: This is a description string
|
||||
version: 0.46.7
|
||||
type: GitRepository
|
||||
+6
-5
@@ -1,7 +1,8 @@
|
||||
record:
|
||||
attr1: value1
|
||||
attr2: value2
|
||||
link1:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
link2:
|
||||
repo_reference:
|
||||
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
js_package_ref:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
version: 1.0.0
|
||||
type: JSPackage
|
||||
name: test-JSPackage
|
||||
@@ -0,0 +1,9 @@
|
||||
record:
|
||||
service_provider_ref:
|
||||
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
auction_ref:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
watcher_ref:
|
||||
/: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
version: 1.0.0
|
||||
type: ResponderContract
|
||||
@@ -1,6 +1,6 @@
|
||||
|
||||
record:
|
||||
type: ServiceProviderRegistration
|
||||
type: ServiceProviderRecord
|
||||
bond_id: madeUpBondID
|
||||
laconic_id: madeUpLaconicID
|
||||
version: 1.0.0
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
record:
|
||||
metadata:
|
||||
version: 0.32.0
|
||||
chain_reference:
|
||||
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
repo_reference:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
wasm:
|
||||
hash_reference:
|
||||
/: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
metadata:
|
||||
compiler_version: 1.15.0
|
||||
execution_engine_version: 0.16.1
|
||||
version: 1.0.0
|
||||
type: WatcherRegistrationRecord
|
||||
@@ -1,7 +1,10 @@
|
||||
record:
|
||||
type: WebsiteRegistrationRecord
|
||||
url: https://cerc.io
|
||||
repo_registration_record_cid: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
build_artifact_cid: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
tls_cerc_cid: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
repo_reference:
|
||||
/: QmSnuWmxptJZdLJpKRarxBMS2Ju2oANVrgbr2xWbie9b2D
|
||||
build_artifact_ref:
|
||||
/: QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9
|
||||
tls_cert_ref:
|
||||
/: QmbWqxBEKC3P8tqsKc98xmWNzrzDtRLMiMPL8wBuTGsMnR
|
||||
version: 1.0.0
|
||||
@@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
"github.com/cerc-io/laconicd/x/registry/client/cli"
|
||||
"github.com/cerc-io/laconicd/x/registry/helpers"
|
||||
@@ -37,7 +38,14 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
||||
sr := suite.Require()
|
||||
var recordId string
|
||||
examples := []string{
|
||||
"/../helpers/examples/binary_example.yml",
|
||||
"/../helpers/examples/chain_registration_example.yml",
|
||||
"/../helpers/examples/docker_image_example.yml",
|
||||
"/../helpers/examples/git_repo_example.yml",
|
||||
"/../helpers/examples/js_package_example.yml",
|
||||
"/../helpers/examples/responder_contract_example.yml",
|
||||
"/../helpers/examples/service_provider_example.yml",
|
||||
"/../helpers/examples/watcher_registration_example.yml",
|
||||
"/../helpers/examples/website_registration_example.yml",
|
||||
}
|
||||
testCases := []struct {
|
||||
@@ -59,14 +67,14 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
||||
®istrytypes.QueryListRecordsRequest{},
|
||||
true,
|
||||
false,
|
||||
2,
|
||||
len(examples),
|
||||
},
|
||||
{
|
||||
"Filter with type",
|
||||
®istrytypes.QueryListRecordsRequest{
|
||||
Attributes: []*registrytypes.QueryListRecordsRequest_KeyValueInput{
|
||||
{
|
||||
Key: "type",
|
||||
Key: "type---",
|
||||
Value: ®istrytypes.QueryListRecordsRequest_ValueInput{
|
||||
Type: "string",
|
||||
String_: "WebsiteRegistrationRecord",
|
||||
@@ -80,11 +88,11 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
||||
1,
|
||||
},
|
||||
{
|
||||
"Filter with attributes ServiceProviderRegistration",
|
||||
"Filter with attributes ServiceProviderRecord",
|
||||
®istrytypes.QueryListRecordsRequest{
|
||||
Attributes: []*registrytypes.QueryListRecordsRequest_KeyValueInput{
|
||||
{
|
||||
Key: "x500state_name",
|
||||
Key: "x500---state_name---",
|
||||
Value: ®istrytypes.QueryListRecordsRequest_ValueInput{
|
||||
Type: "string",
|
||||
String_: "california",
|
||||
@@ -97,6 +105,42 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
||||
false,
|
||||
1,
|
||||
},
|
||||
{
|
||||
"Filter with attributes WatcherRegistrationRecord",
|
||||
®istrytypes.QueryListRecordsRequest{
|
||||
Attributes: []*registrytypes.QueryListRecordsRequest_KeyValueInput{
|
||||
{
|
||||
Key: "metadata---chain_reference---/---",
|
||||
Value: ®istrytypes.QueryListRecordsRequest_ValueInput{
|
||||
Type: "string",
|
||||
String_: "QmP8jTG1m9GSDJLCbeWhVSVgEzCPPwXRdCRuJtQ5Tz9Kc9",
|
||||
},
|
||||
},
|
||||
},
|
||||
All: true,
|
||||
},
|
||||
true,
|
||||
false,
|
||||
1,
|
||||
},
|
||||
{
|
||||
"Filter with attributes version",
|
||||
®istrytypes.QueryListRecordsRequest{
|
||||
Attributes: []*registrytypes.QueryListRecordsRequest_KeyValueInput{
|
||||
{
|
||||
Key: "version---",
|
||||
Value: ®istrytypes.QueryListRecordsRequest_ValueInput{
|
||||
Type: "string",
|
||||
String_: "1.0.0",
|
||||
},
|
||||
},
|
||||
},
|
||||
All: true,
|
||||
},
|
||||
true,
|
||||
false,
|
||||
7,
|
||||
},
|
||||
}
|
||||
for _, test := range testCases {
|
||||
suite.Run(fmt.Sprintf("Case %s ", test.msg), func() {
|
||||
@@ -133,11 +177,7 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
||||
sr.NoError(err)
|
||||
recAttr := helpers.UnMarshalMapFromJSONBytes(bz)
|
||||
for _, attr := range test.req.GetAttributes() {
|
||||
if attr.Key[:4] == "x500" {
|
||||
sr.Equal(keeper.GetAttributeValue(attr.Value), recAttr["x500"].(map[string]interface{})[attr.Key[4:]])
|
||||
} else {
|
||||
sr.Equal(keeper.GetAttributeValue(attr.Value), recAttr[attr.Key])
|
||||
}
|
||||
sr.Equal(keeper.GetAttributeValue(attr.Value), getAttributesFromRecord(recAttr, attr.Key))
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -228,6 +268,17 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
||||
}
|
||||
}
|
||||
|
||||
func getAttributesFromRecord(recordAttr map[string]interface{}, key string) interface{} {
|
||||
keys := strings.Split(key, "---")
|
||||
for i, str := range keys {
|
||||
if i == len(keys)-2 {
|
||||
return recordAttr[str].(string)
|
||||
}
|
||||
recordAttr = recordAttr[str].(map[string]interface{})
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (suite *KeeperTestSuite) TestGrpcQueryRegistryModuleBalance() {
|
||||
grpcClient, ctx := suite.queryClient, suite.ctx
|
||||
sr := suite.Require()
|
||||
|
||||
+28
-38
@@ -4,6 +4,7 @@ import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"reflect" // #nosec G702 This is also used in eip712 antehandler code. No new risk introduced.
|
||||
"sort"
|
||||
"time"
|
||||
|
||||
@@ -256,13 +257,13 @@ func (k Keeper) ProcessSetRecord(ctx sdk.Context, msg types.MsgSetRecord) (*type
|
||||
pubKey, err := legacy.PubKeyFromBytes(helpers.BytesFromBase64(sig.PubKey))
|
||||
if err != nil {
|
||||
fmt.Println("Error decoding pubKey from bytes: ", err)
|
||||
return nil, errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "Invalid public key: %s", err)
|
||||
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Invalid public key.")
|
||||
}
|
||||
|
||||
sigOK := pubKey.VerifySignature(resourceSignBytes, helpers.BytesFromBase64(sig.Sig))
|
||||
if !sigOK {
|
||||
fmt.Println("Signature mismatch: ", sig.PubKey)
|
||||
return nil, errorsmod.Wrapf(sdkerrors.ErrUnauthorized, "Invalid signature: %s", sig.PubKey)
|
||||
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Invalid signature.")
|
||||
}
|
||||
record.Owners = append(record.Owners, pubKey.Address().String())
|
||||
}
|
||||
@@ -317,55 +318,44 @@ func (k Keeper) PutRecord(ctx sdk.Context, record types.Record) {
|
||||
}
|
||||
|
||||
func (k Keeper) ProcessAttributes(ctx sdk.Context, record types.RecordType) error {
|
||||
switch record.Attributes["type"] {
|
||||
case "ServiceProviderRegistration":
|
||||
{
|
||||
// #nosec G705
|
||||
for key := range record.Attributes {
|
||||
if key == "x500" {
|
||||
// #nosec G705
|
||||
for x500Key, x500Val := range record.Attributes[key].(map[string]interface{}) {
|
||||
indexKey := GetAttributesIndexKey(fmt.Sprintf("x500%s", x500Key), x500Val)
|
||||
if err := k.SetAttributeMapping(ctx, indexKey, record.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
indexKey := GetAttributesIndexKey(key, record.Attributes[key])
|
||||
if err := k.SetAttributeMapping(ctx, indexKey, record.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
case "WebsiteRegistrationRecord":
|
||||
{
|
||||
// #nosec G705
|
||||
for key := range record.Attributes {
|
||||
indexKey := GetAttributesIndexKey(key, record.Attributes[key])
|
||||
if err := k.SetAttributeMapping(ctx, indexKey, record.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
}
|
||||
default:
|
||||
return fmt.Errorf("unsupported record type %s", record.Attributes["type"])
|
||||
if err := k.insertAttributes(ctx, record.ID, record.Attributes, ""); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
expiryTimeKey := GetAttributesIndexKey(ExpiryTimeAttributeName, record.ExpiryTime)
|
||||
if err := k.SetAttributeMapping(ctx, expiryTimeKey, record.ID); err != nil {
|
||||
if err := k.setAttributeMapping(ctx, expiryTimeKey, record.ID); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (k Keeper) insertAttributes(ctx sdk.Context, recordID string, attr interface{}, keyPrefix string) error {
|
||||
if reflect.TypeOf(attr).Kind() == reflect.Map {
|
||||
val := attr.(map[string]interface{})
|
||||
// #nosec G705
|
||||
for key := range val {
|
||||
newKeyPrefix := fmt.Sprint(keyPrefix + key + "---")
|
||||
if err := k.insertAttributes(ctx, recordID, val[key], newKeyPrefix); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
} else {
|
||||
indexKey := GetAttributesIndexKey(keyPrefix, attr)
|
||||
if err := k.setAttributeMapping(ctx, indexKey, recordID); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func GetAttributesIndexKey(key string, value interface{}) []byte {
|
||||
keyString := fmt.Sprintf("%s%s", key, value)
|
||||
return append(PrefixAttributesIndex, []byte(keyString)...)
|
||||
}
|
||||
|
||||
func (k Keeper) SetAttributeMapping(ctx sdk.Context, key []byte, recordID string) error {
|
||||
func (k Keeper) setAttributeMapping(ctx sdk.Context, key []byte, recordID string) error {
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
var recordIds []string
|
||||
if store.Has(key) {
|
||||
@@ -389,7 +379,7 @@ func (k Keeper) GetAttributeMapping(ctx sdk.Context, key []byte) ([]string, erro
|
||||
store := ctx.KVStore(k.storeKey)
|
||||
|
||||
if !store.Has(key) {
|
||||
return nil, nil
|
||||
return nil, fmt.Errorf("store doesn't have key")
|
||||
}
|
||||
|
||||
var recordIds []string
|
||||
|
||||
@@ -25,7 +25,11 @@ func (m msgServer) SetRecord(c context.Context, msg *types.MsgSetRecord) (*types
|
||||
return nil, err
|
||||
}
|
||||
|
||||
record, err := m.Keeper.ProcessSetRecord(ctx, *msg)
|
||||
record, err := m.Keeper.ProcessSetRecord(ctx, types.MsgSetRecord{
|
||||
BondId: msg.GetBondId(),
|
||||
Signer: msg.GetSigner(),
|
||||
Payload: msg.GetPayload(),
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -47,7 +51,7 @@ func (m msgServer) SetRecord(c context.Context, msg *types.MsgSetRecord) (*types
|
||||
return &types.MsgSetRecordResponse{Id: record.ID}, nil
|
||||
}
|
||||
|
||||
// nolint: all
|
||||
//nolint: all
|
||||
func (m msgServer) SetName(c context.Context, msg *types.MsgSetName) (*types.MsgSetNameResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
@@ -104,7 +108,7 @@ func (m msgServer) ReserveName(c context.Context, msg *types.MsgReserveAuthority
|
||||
return &types.MsgReserveAuthorityResponse{}, nil
|
||||
}
|
||||
|
||||
// nolint: all
|
||||
//nolint: all
|
||||
func (m msgServer) SetAuthorityBond(c context.Context, msg *types.MsgSetAuthorityBond) (*types.MsgSetAuthorityBondResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
@@ -181,7 +185,7 @@ func (m msgServer) RenewRecord(c context.Context, msg *types.MsgRenewRecord) (*t
|
||||
return &types.MsgRenewRecordResponse{}, nil
|
||||
}
|
||||
|
||||
// nolint: all
|
||||
//nolint: all
|
||||
func (m msgServer) AssociateBond(c context.Context, msg *types.MsgAssociateBond) (*types.MsgAssociateBondResponse, error) {
|
||||
ctx := sdk.UnwrapSDKContext(c)
|
||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||
|
||||
Generated
+3985
-157
File diff suppressed because it is too large
Load Diff
@@ -40,9 +40,9 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
)
|
||||
|
||||
registry.RegisterInterface(
|
||||
"vulcanize.registry.v1beta1.ServiceProvideRegistration",
|
||||
"vulcanize.registry.v1beta1.ServiceProviderRecord",
|
||||
(*Attributes)(nil),
|
||||
&ServiceProviderRegistration{},
|
||||
&ServiceProviderRecord{},
|
||||
)
|
||||
|
||||
registry.RegisterInterface(
|
||||
@@ -50,6 +50,48 @@ func RegisterInterfaces(registry types.InterfaceRegistry) {
|
||||
(*Attributes)(nil),
|
||||
&WebsiteRegistrationRecord{},
|
||||
)
|
||||
|
||||
registry.RegisterInterface(
|
||||
"vulcanize.registry.v1beta1.GitRepository",
|
||||
(*Attributes)(nil),
|
||||
&GitRepository{},
|
||||
)
|
||||
|
||||
registry.RegisterInterface(
|
||||
"vulcanize.registry.v1beta1.Binary",
|
||||
(*Attributes)(nil),
|
||||
&Binary{},
|
||||
)
|
||||
|
||||
registry.RegisterInterface(
|
||||
"vulcanize.registry.v1beta1.DockerImage",
|
||||
(*Attributes)(nil),
|
||||
&DockerImage{},
|
||||
)
|
||||
|
||||
registry.RegisterInterface(
|
||||
"vulcanize.registry.v1beta1.WatcherRegistrationRecord",
|
||||
(*Attributes)(nil),
|
||||
&WatcherRegistrationRecord{},
|
||||
)
|
||||
|
||||
registry.RegisterInterface(
|
||||
"vulcanize.registry.v1beta1.ResponderContract",
|
||||
(*Attributes)(nil),
|
||||
&ResponderContract{},
|
||||
)
|
||||
|
||||
registry.RegisterInterface(
|
||||
"vulcanize.registry.v1beta1.JSPackage",
|
||||
(*Attributes)(nil),
|
||||
&JSPackage{},
|
||||
)
|
||||
|
||||
registry.RegisterInterface(
|
||||
"vulcanize.registry.v1beta1.ChainRegistrationRecord",
|
||||
(*Attributes)(nil),
|
||||
&ChainRegistrationRecord{},
|
||||
)
|
||||
msgservice.RegisterMsgServiceDesc(registry, &_Msg_serviceDesc)
|
||||
}
|
||||
|
||||
|
||||
+158
-4
@@ -50,9 +50,9 @@ func payLoadAttributes(recordPayLoad map[string]interface{}) (*codectypes.Any, e
|
||||
bz := helpers.MarshalMapToJSONBytes(recordPayLoad)
|
||||
|
||||
switch recordType.(string) {
|
||||
case "ServiceProviderRegistration":
|
||||
case "ServiceProviderRecord":
|
||||
{
|
||||
var attributes ServiceProviderRegistration
|
||||
var attributes ServiceProviderRecord
|
||||
err := json.Unmarshal(bz, &attributes)
|
||||
if err != nil {
|
||||
return &codectypes.Any{}, err
|
||||
@@ -68,6 +68,69 @@ func payLoadAttributes(recordPayLoad map[string]interface{}) (*codectypes.Any, e
|
||||
}
|
||||
return codectypes.NewAnyWithValue(&attributes)
|
||||
}
|
||||
case "GitRepository":
|
||||
{
|
||||
var attributes GitRepository
|
||||
err := json.Unmarshal(bz, &attributes)
|
||||
if err != nil {
|
||||
return &codectypes.Any{}, err
|
||||
}
|
||||
return codectypes.NewAnyWithValue(&attributes)
|
||||
}
|
||||
case "Binary":
|
||||
{
|
||||
var attributes Binary
|
||||
err := json.Unmarshal(bz, &attributes)
|
||||
if err != nil {
|
||||
return &codectypes.Any{}, err
|
||||
}
|
||||
return codectypes.NewAnyWithValue(&attributes)
|
||||
}
|
||||
case "DockerImage":
|
||||
{
|
||||
var attributes DockerImage
|
||||
err := json.Unmarshal(bz, &attributes)
|
||||
if err != nil {
|
||||
return &codectypes.Any{}, err
|
||||
}
|
||||
return codectypes.NewAnyWithValue(&attributes)
|
||||
}
|
||||
case "WatcherRegistrationRecord":
|
||||
{
|
||||
var attributes WatcherRegistrationRecord
|
||||
err := json.Unmarshal(bz, &attributes)
|
||||
if err != nil {
|
||||
return &codectypes.Any{}, err
|
||||
}
|
||||
return codectypes.NewAnyWithValue(&attributes)
|
||||
}
|
||||
case "ResponderContract":
|
||||
{
|
||||
var attributes ResponderContract
|
||||
err := json.Unmarshal(bz, &attributes)
|
||||
if err != nil {
|
||||
return &codectypes.Any{}, err
|
||||
}
|
||||
return codectypes.NewAnyWithValue(&attributes)
|
||||
}
|
||||
case "JSPackage":
|
||||
{
|
||||
var attributes JSPackage
|
||||
err := json.Unmarshal(bz, &attributes)
|
||||
if err != nil {
|
||||
return &codectypes.Any{}, err
|
||||
}
|
||||
return codectypes.NewAnyWithValue(&attributes)
|
||||
}
|
||||
case "ChainRegistrationRecord":
|
||||
{
|
||||
var attributes ChainRegistrationRecord
|
||||
err := json.Unmarshal(bz, &attributes)
|
||||
if err != nil {
|
||||
return &codectypes.Any{}, err
|
||||
}
|
||||
return codectypes.NewAnyWithValue(&attributes)
|
||||
}
|
||||
default:
|
||||
return &codectypes.Any{}, fmt.Errorf("unsupported record type %s", recordType.(string))
|
||||
}
|
||||
@@ -114,9 +177,9 @@ func GetJSONBytesFromAny(any codectypes.Any) ([]byte, error) {
|
||||
var bz []byte
|
||||
s := strings.Split(any.TypeUrl, ".")
|
||||
switch s[len(s)-1] {
|
||||
case "ServiceProviderRegistration":
|
||||
case "ServiceProviderRecord":
|
||||
{
|
||||
var attributes ServiceProviderRegistration
|
||||
var attributes ServiceProviderRecord
|
||||
err := proto.Unmarshal(any.Value, &attributes)
|
||||
if err != nil {
|
||||
panic("Proto unmarshal error")
|
||||
@@ -135,6 +198,97 @@ func GetJSONBytesFromAny(any codectypes.Any) ([]byte, error) {
|
||||
panic("Proto unmarshal error")
|
||||
}
|
||||
|
||||
bz, err = json.Marshal(attributes)
|
||||
if err != nil {
|
||||
panic("JSON marshal error")
|
||||
}
|
||||
}
|
||||
case "GitRepository":
|
||||
{
|
||||
var attributes GitRepository
|
||||
err := proto.Unmarshal(any.Value, &attributes)
|
||||
if err != nil {
|
||||
panic("Proto unmarshal error")
|
||||
}
|
||||
|
||||
bz, err = json.Marshal(attributes)
|
||||
if err != nil {
|
||||
panic("JSON marshal error")
|
||||
}
|
||||
}
|
||||
case "Binary":
|
||||
{
|
||||
var attributes Binary
|
||||
err := proto.Unmarshal(any.Value, &attributes)
|
||||
if err != nil {
|
||||
panic("Proto unmarshal error")
|
||||
}
|
||||
|
||||
bz, err = json.Marshal(attributes)
|
||||
if err != nil {
|
||||
panic("JSON marshal error")
|
||||
}
|
||||
}
|
||||
case "DockerImage":
|
||||
{
|
||||
var attributes DockerImage
|
||||
err := proto.Unmarshal(any.Value, &attributes)
|
||||
if err != nil {
|
||||
panic("Proto unmarshal error")
|
||||
}
|
||||
|
||||
bz, err = json.Marshal(attributes)
|
||||
if err != nil {
|
||||
panic("JSON marshal error")
|
||||
}
|
||||
}
|
||||
case "WatcherRegistrationRecord":
|
||||
{
|
||||
var attributes WatcherRegistrationRecord
|
||||
err := proto.Unmarshal(any.Value, &attributes)
|
||||
if err != nil {
|
||||
panic("Proto unmarshal error")
|
||||
}
|
||||
|
||||
bz, err = json.Marshal(attributes)
|
||||
if err != nil {
|
||||
panic("JSON marshal error")
|
||||
}
|
||||
}
|
||||
case "ResponderContract":
|
||||
{
|
||||
var attributes ResponderContract
|
||||
err := proto.Unmarshal(any.Value, &attributes)
|
||||
if err != nil {
|
||||
panic("Proto unmarshal error")
|
||||
}
|
||||
|
||||
bz, err = json.Marshal(attributes)
|
||||
if err != nil {
|
||||
panic("JSON marshal error")
|
||||
}
|
||||
}
|
||||
case "JSPackage":
|
||||
{
|
||||
var attributes JSPackage
|
||||
err := proto.Unmarshal(any.Value, &attributes)
|
||||
if err != nil {
|
||||
panic("Proto unmarshal error")
|
||||
}
|
||||
|
||||
bz, err = json.Marshal(attributes)
|
||||
if err != nil {
|
||||
panic("JSON marshal error")
|
||||
}
|
||||
}
|
||||
case "ChainRegistrationRecord":
|
||||
{
|
||||
var attributes ChainRegistrationRecord
|
||||
err := proto.Unmarshal(any.Value, &attributes)
|
||||
if err != nil {
|
||||
panic("Proto unmarshal error")
|
||||
}
|
||||
|
||||
bz, err = json.Marshal(attributes)
|
||||
if err != nil {
|
||||
panic("JSON marshal error")
|
||||
|
||||
Reference in New Issue
Block a user