Compare commits
3 Commits
main
...
roy/rm-har
Author | SHA1 | Date | |
---|---|---|---|
e173f0a321 | |||
9bb3dc4216 | |||
0b17e317d3 |
@ -1,7 +1,5 @@
|
|||||||
Dockerfile
|
# localnet-setup
|
||||||
|
|
||||||
**/node_modules
|
|
||||||
init.sh
|
|
||||||
|
|
||||||
build
|
|
||||||
localnet-setup
|
localnet-setup
|
||||||
|
|
||||||
|
# build
|
||||||
|
build
|
@ -1,17 +0,0 @@
|
|||||||
name: Build
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: 1.21
|
|
||||||
check-latest: true
|
|
||||||
- run: |
|
|
||||||
make build
|
|
@ -1,20 +0,0 @@
|
|||||||
name: Deploy Contract
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
deploy:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: 1.21
|
|
||||||
check-latest: true
|
|
||||||
- name: Test contract
|
|
||||||
run: |
|
|
||||||
make contract-tools
|
|
||||||
# This seems to be an empty placeholder.
|
|
||||||
make test-contract
|
|
@ -1,21 +0,0 @@
|
|||||||
name: Tests
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- release/**
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test-importer:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
timeout-minutes: 10
|
|
||||||
steps:
|
|
||||||
- uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: 1.21
|
|
||||||
check-latest: true
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: test-importer
|
|
||||||
run: |
|
|
||||||
make test-import
|
|
@ -1,21 +0,0 @@
|
|||||||
name: Tests
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- release/**
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test-rpc:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
timeout-minutes: 15
|
|
||||||
steps:
|
|
||||||
- uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: 1.21
|
|
||||||
check-latest: true
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Test rpc endpoint
|
|
||||||
run: |
|
|
||||||
make test-rpc
|
|
@ -1,40 +0,0 @@
|
|||||||
name: Tests
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- release/**
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
sdk_tests:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Checkout laconic-sdk
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
path: "./laconic-sdk/"
|
|
||||||
repository: cerc-io/laconic-sdk
|
|
||||||
fetch-depth: 0
|
|
||||||
ref: main
|
|
||||||
- name: Environment
|
|
||||||
run: ls -tlh && env
|
|
||||||
|
|
||||||
- name: Build laconicd container
|
|
||||||
working-directory: tests/sdk_tests
|
|
||||||
run: ./build-laconicd-container.sh
|
|
||||||
|
|
||||||
- name: Build laconic-sdk container
|
|
||||||
working-directory: laconic-sdk
|
|
||||||
run: ./scripts/build-sdk-test-container.sh
|
|
||||||
|
|
||||||
- name: Start containers (auctions enabled)
|
|
||||||
working-directory: tests/sdk_tests
|
|
||||||
env:
|
|
||||||
TEST_AUCTION_ENABLED: true
|
|
||||||
run: docker compose up -d
|
|
||||||
|
|
||||||
- name: Run auction tests
|
|
||||||
working-directory: tests/sdk_tests
|
|
||||||
run: ./run-tests.sh test:auctions
|
|
@ -1,40 +0,0 @@
|
|||||||
name: Tests
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- release/**
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
sdk_tests:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Checkout laconic-sdk
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
path: "./laconic-sdk/"
|
|
||||||
repository: cerc-io/laconic-sdk
|
|
||||||
fetch-depth: 0
|
|
||||||
ref: main
|
|
||||||
- name: Environment
|
|
||||||
run: ls -tlh && env
|
|
||||||
|
|
||||||
- name: Build laconicd container
|
|
||||||
working-directory: tests/sdk_tests
|
|
||||||
run: ./build-laconicd-container.sh
|
|
||||||
|
|
||||||
- name: Build laconic-sdk container
|
|
||||||
working-directory: laconic-sdk
|
|
||||||
run: ./scripts/build-sdk-test-container.sh
|
|
||||||
|
|
||||||
- name: Start containers (expiry enabled)
|
|
||||||
working-directory: tests/sdk_tests
|
|
||||||
env:
|
|
||||||
TEST_REGISTRY_EXPIRY: true
|
|
||||||
run: docker compose up -d
|
|
||||||
|
|
||||||
- name: Run nameservice expiry tests
|
|
||||||
working-directory: tests/sdk_tests
|
|
||||||
run: ./run-tests.sh test:nameservice-expiry
|
|
@ -1,38 +0,0 @@
|
|||||||
name: Tests
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- release/**
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
sdk_tests:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Checkout laconic-sdk
|
|
||||||
uses: actions/checkout@v3
|
|
||||||
with:
|
|
||||||
path: "./laconic-sdk/"
|
|
||||||
repository: cerc-io/laconic-sdk
|
|
||||||
fetch-depth: 0
|
|
||||||
ref: main
|
|
||||||
- name: Environment
|
|
||||||
run: ls -tlh && env
|
|
||||||
|
|
||||||
- name: Build laconicd container
|
|
||||||
working-directory: tests/sdk_tests
|
|
||||||
run: ./build-laconicd-container.sh
|
|
||||||
|
|
||||||
- name: Build laconic-sdk container
|
|
||||||
working-directory: laconic-sdk
|
|
||||||
run: ./scripts/build-sdk-test-container.sh
|
|
||||||
|
|
||||||
- name: Start containers
|
|
||||||
working-directory: tests/sdk_tests
|
|
||||||
run: docker compose up -d
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
working-directory: tests/sdk_tests
|
|
||||||
run: ./run-tests.sh
|
|
@ -1,23 +0,0 @@
|
|||||||
name: Tests
|
|
||||||
on:
|
|
||||||
pull_request:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
- release/**
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
test-unit:
|
|
||||||
# This test case doesn't work in CI, run as root.
|
|
||||||
env:
|
|
||||||
SKIP_UNIT_TESTS: TestInitConfigNonNotExistError
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
steps:
|
|
||||||
- uses: actions/setup-go@v3
|
|
||||||
with:
|
|
||||||
go-version: 1.21
|
|
||||||
check-latest: true
|
|
||||||
- uses: actions/checkout@v3
|
|
||||||
- name: Test
|
|
||||||
run: |
|
|
||||||
make test-unit
|
|
5
.github/CODEOWNERS
vendored
Normal file
5
.github/CODEOWNERS
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
# CODEOWNERS: https://help.github.com/articles/about-codeowners/
|
||||||
|
|
||||||
|
# Primary (global) repo maintainers
|
||||||
|
|
||||||
|
* @evmos/core-engineering
|
18
.github/ISSUE_TEMPLATE/bug-report.md
vendored
Normal file
18
.github/ISSUE_TEMPLATE/bug-report.md
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
---
|
||||||
|
name: Bug Report
|
||||||
|
about: create a bug report
|
||||||
|
---
|
||||||
|
|
||||||
|
__System info:__ [Include Ethermint commit, operating system name, and other relevant details]
|
||||||
|
|
||||||
|
__Steps to reproduce:__
|
||||||
|
|
||||||
|
1. [First Step]
|
||||||
|
2. [Second Step]
|
||||||
|
3. [and so on...]
|
||||||
|
|
||||||
|
__Expected behavior:__ [What you expected to happen]
|
||||||
|
|
||||||
|
__Actual behavior:__ [What actually happened]
|
||||||
|
|
||||||
|
__Additional info:__ [Include gist of relevant config, logs, etc.]
|
15
.github/ISSUE_TEMPLATE/feature-request.md
vendored
Normal file
15
.github/ISSUE_TEMPLATE/feature-request.md
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Opening a feature request kicks off a discussion
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
__Proposal:__ [Description of the feature]
|
||||||
|
|
||||||
|
__Current behavior:__ [What currently happens]
|
||||||
|
|
||||||
|
__Desired behavior:__ [What you would like to happen]
|
||||||
|
|
||||||
|
__Use case:__ [Why is this important (helps with prioritizing requests)]
|
||||||
|
|
||||||
|
Requests may be closed if we're not actively planning to work on them.
|
34
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
34
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<!-- < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < ☺
|
||||||
|
v ✰ Thanks for creating a PR! ✰
|
||||||
|
v Before smashing the submit button please review the checkboxes.
|
||||||
|
v If a checkbox is n/a - please still include it but + a little note why
|
||||||
|
☺ > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > -->
|
||||||
|
|
||||||
|
Closes: #XXX
|
||||||
|
|
||||||
|
## Description
|
||||||
|
|
||||||
|
<!-- Add a description of the changes that this PR introduces and the files that
|
||||||
|
are the most critical to review.
|
||||||
|
-->
|
||||||
|
|
||||||
|
______
|
||||||
|
|
||||||
|
For contributor use:
|
||||||
|
|
||||||
|
- [ ] Targeted PR against correct branch (see [CONTRIBUTING.md](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting))
|
||||||
|
- [ ] Linked to Github issue with discussion and accepted design OR link to spec that describes this work.
|
||||||
|
- [ ] Code follows the [module structure standards](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules/structure.md).
|
||||||
|
- [ ] Wrote unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing)
|
||||||
|
- [ ] Updated relevant documentation (`docs/`) or specification (`x/<module>/spec/`)
|
||||||
|
- [ ] Added relevant `godoc` [comments](https://blog.golang.org/godoc-documenting-go-code).
|
||||||
|
- [ ] Added a relevant changelog entry to the `Unreleased` section in `CHANGELOG.md`
|
||||||
|
- [ ] Re-reviewed `Files changed` in the Github PR explorer
|
||||||
|
|
||||||
|
______
|
||||||
|
|
||||||
|
For admin use:
|
||||||
|
|
||||||
|
- [ ] Added appropriate labels to PR (ex. `WIP`, `R4R`, `docs`, etc)
|
||||||
|
- [ ] Reviewers assigned
|
||||||
|
- [ ] Squashed all commits, uses message "Merge pull request #XYZ: [title]" ([coding standards](https://github.com/tendermint/coding/blob/master/README.md#merging-a-pr))
|
37
.github/labeler.yml
vendored
Normal file
37
.github/labeler.yml
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
"C:Crypto":
|
||||||
|
- crypto/**/*
|
||||||
|
"C:Encoding":
|
||||||
|
- encoding/**/*
|
||||||
|
"C:JSON-RPC":
|
||||||
|
- ethereum/rpc/**/*
|
||||||
|
"C:Proto":
|
||||||
|
- proto/**/*
|
||||||
|
- third_party/**/*
|
||||||
|
- /**/*.pb.go
|
||||||
|
- /**/*.pb.gw.go
|
||||||
|
"C:Types":
|
||||||
|
- types/**/*
|
||||||
|
"C:x/evm":
|
||||||
|
- x/evm/**/*/
|
||||||
|
"Type: Build":
|
||||||
|
- Makefile
|
||||||
|
- Dockerfile
|
||||||
|
- docker-compose.yml
|
||||||
|
- scripts/*
|
||||||
|
- config.yml
|
||||||
|
"Type: CI":
|
||||||
|
- .github/**/*.yml
|
||||||
|
- buf.yaml
|
||||||
|
- .mergify.yml
|
||||||
|
- .golangci.yml
|
||||||
|
"C:CLI":
|
||||||
|
- client/**/*
|
||||||
|
- x/*/client/**/*
|
||||||
|
"Type: Tests":
|
||||||
|
- tests/**/*
|
||||||
|
- /**/*/*_test.go
|
||||||
|
"Type: Docs":
|
||||||
|
- docs/**/*
|
||||||
|
- x/*/spec/**/*
|
||||||
|
"Type: ADR":
|
||||||
|
- docs/architecture/**/*
|
33
.github/workflows/build.yml
vendored
Normal file
33
.github/workflows/build.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
name: Build
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
cleanup-runs:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: rokroskar/workflow-run-cleanup-action@master
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'"
|
||||||
|
|
||||||
|
build:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: 1.19
|
||||||
|
check-latest: true
|
||||||
|
- uses: technote-space/get-diff-action@v6.1.2
|
||||||
|
id: git_diff
|
||||||
|
with:
|
||||||
|
PATTERNS: |
|
||||||
|
**/**.go
|
||||||
|
go.mod
|
||||||
|
go.sum
|
||||||
|
- run: |
|
||||||
|
make build
|
||||||
|
if: env.GIT_DIFF
|
84
.github/workflows/codeql-analysis.yml
vendored
Normal file
84
.github/workflows/codeql-analysis.yml
vendored
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
# For most projects, this workflow file will not need changing; you simply need
|
||||||
|
# to commit it to your repository.
|
||||||
|
#
|
||||||
|
# You may wish to alter this file to override the set of languages analyzed,
|
||||||
|
# or to provide custom queries or build logic.
|
||||||
|
#
|
||||||
|
# ******** NOTE ********
|
||||||
|
# We have attempted to detect the languages in your repository. Please check
|
||||||
|
# the `language` matrix defined below to confirm you have the correct set of
|
||||||
|
# supported CodeQL languages.
|
||||||
|
#
|
||||||
|
name: "CodeQL"
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
pull_request:
|
||||||
|
# The branches below must be a subset of the branches above
|
||||||
|
branches: [ main ]
|
||||||
|
schedule:
|
||||||
|
- cron: '37 21 * * 4'
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
analyze:
|
||||||
|
name: Analyze
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
permissions:
|
||||||
|
actions: read
|
||||||
|
contents: read
|
||||||
|
security-events: write
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
language: [ 'go' ]
|
||||||
|
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python' ]
|
||||||
|
# Learn more:
|
||||||
|
# https://docs.github.com/en/free-pro-team@latest/github/finding-security-vulnerabilities-and-errors-in-your-code/configuring-code-scanning#changing-the-languages-that-are-analyzed
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout repository
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- uses: technote-space/get-diff-action@v6.1.2
|
||||||
|
with:
|
||||||
|
PATTERNS: |
|
||||||
|
**/**.sol
|
||||||
|
**/**.go
|
||||||
|
**/**.ts
|
||||||
|
**/**.js
|
||||||
|
go.mod
|
||||||
|
go.sum
|
||||||
|
|
||||||
|
# Initializes the CodeQL tools for scanning.
|
||||||
|
- name: Initialize CodeQL
|
||||||
|
uses: github/codeql-action/init@v2
|
||||||
|
with:
|
||||||
|
languages: ${{ matrix.language }}
|
||||||
|
# If you wish to specify custom queries, you can do so here or in a config file.
|
||||||
|
# By default, queries listed here will override any specified in a config file.
|
||||||
|
# Prefix the list here with "+" to use these queries and those in the config file.
|
||||||
|
# queries: ./path/to/local/query, your-org/your-repo/queries@main
|
||||||
|
queries: crypto-com/cosmos-sdk-codeql@main,security-and-quality
|
||||||
|
if: env.GIT_DIFF
|
||||||
|
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
|
||||||
|
# If this step fails, then you should remove it and run the build manually (see below)
|
||||||
|
|
||||||
|
- name: Autobuild
|
||||||
|
uses: github/codeql-action/autobuild@v2
|
||||||
|
if: env.GIT_DIFF
|
||||||
|
|
||||||
|
# ℹ️ Command-line programs to run using the OS shell.
|
||||||
|
# 📚 https://git.io/JvXDl
|
||||||
|
|
||||||
|
# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
|
||||||
|
# and modify them (or add more) to build your code if your project
|
||||||
|
# uses a compiled language
|
||||||
|
|
||||||
|
#- run: |
|
||||||
|
# make bootstrap
|
||||||
|
# make release
|
||||||
|
|
||||||
|
- name: Perform CodeQL Analysis
|
||||||
|
uses: github/codeql-action/analyze@v2
|
||||||
|
if: env.GIT_DIFF
|
28
.github/workflows/dependencies.yml
vendored
Normal file
28
.github/workflows/dependencies.yml
vendored
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
name: "Dependency Review"
|
||||||
|
on: pull_request
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
dependency-review:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: 1.19
|
||||||
|
check-latest: true
|
||||||
|
- name: "Checkout Repository"
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- uses: technote-space/get-diff-action@v6.1.2
|
||||||
|
with:
|
||||||
|
PATTERNS: |
|
||||||
|
**/**.go
|
||||||
|
go.mod
|
||||||
|
go.sum
|
||||||
|
- name: "Dependency Review"
|
||||||
|
uses: actions/dependency-review-action@v3
|
||||||
|
if: env.GIT_DIFF
|
||||||
|
- name: "Go vulnerability check"
|
||||||
|
run: make vulncheck
|
||||||
|
if: env.GIT_DIFF
|
38
.github/workflows/deploy-contract.yml
vendored
Normal file
38
.github/workflows/deploy-contract.yml
vendored
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
name: Deploy Contract
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
cleanup-runs:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: rokroskar/workflow-run-cleanup-action@master
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'"
|
||||||
|
|
||||||
|
deploy:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Use Node.js
|
||||||
|
uses: actions/setup-node@v3
|
||||||
|
with:
|
||||||
|
node-version: '12.x'
|
||||||
|
- name: Install dependencies
|
||||||
|
run: npm install
|
||||||
|
- uses: technote-space/get-diff-action@v6.1.2
|
||||||
|
id: git_diff
|
||||||
|
with:
|
||||||
|
PATTERNS: |
|
||||||
|
**/**.sol
|
||||||
|
**/**.go
|
||||||
|
go.mod
|
||||||
|
go.sum
|
||||||
|
- name: Test contract
|
||||||
|
run: |
|
||||||
|
sudo make contract-tools
|
||||||
|
sudo make test-contract
|
||||||
|
if: env.GIT_DIFF
|
@ -20,7 +20,7 @@ jobs:
|
|||||||
- name: Tag docker image
|
- name: Tag docker image
|
||||||
run: docker tag git.vdb.to/cerc-io/laconicd/laconicd:${{steps.vars.outputs.sha}} git.vdb.to/cerc-io/laconicd/laconicd:${{steps.vars.outputs.tag}}
|
run: docker tag git.vdb.to/cerc-io/laconicd/laconicd:${{steps.vars.outputs.sha}} git.vdb.to/cerc-io/laconicd/laconicd:${{steps.vars.outputs.tag}}
|
||||||
- name: Docker Login
|
- name: Docker Login
|
||||||
run: echo ${{ secrets.CICD_PUBLISH_TOKEN }} | docker login https://git.vdb.to -u cerccicd --password-stdin
|
run: echo ${{ secrets.GITEA_TOKEN }} | docker login https://git.vdb.to -u cerccicd --password-stdin
|
||||||
- name: Docker Push
|
- name: Docker Push
|
||||||
run: docker push git.vdb.to/cerc-io/laconicd/laconicd:${{steps.vars.outputs.sha}}
|
run: docker push git.vdb.to/cerc-io/laconicd/laconicd:${{steps.vars.outputs.sha}}
|
||||||
- name: Docker Push TAGGED
|
- name: Docker Push TAGGED
|
@ -15,14 +15,14 @@ jobs:
|
|||||||
- name: Set up Go
|
- name: Set up Go
|
||||||
uses: actions/setup-go@v3
|
uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.21
|
go-version: 1.19
|
||||||
check-latest: true
|
check-latest: true
|
||||||
- name: release dry run
|
- name: release dry run
|
||||||
run: make release-dry-run
|
run: make release-dry-run
|
||||||
- name: setup release environment
|
- name: setup release environment
|
||||||
env:
|
env:
|
||||||
GITHUB_TOKEN: ${{ secrets.CICD_PUBLISH_TOKEN }}
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
run: |-
|
run: |-
|
||||||
echo 'GITHUB_TOKEN=${{secrets.CICD_PUBLISH_TOKEN}}' > .release-env
|
echo 'GITHUB_TOKEN=${{secrets.GITHUB_TOKEN}}' > .release-env
|
||||||
- name: release publish
|
- name: release publish
|
||||||
run: make release
|
run: make release
|
29
.github/workflows/issues-notion-sync.yml
vendored
Normal file
29
.github/workflows/issues-notion-sync.yml
vendored
Normal file
@ -0,0 +1,29 @@
|
|||||||
|
name: Notion Sync
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
issues:
|
||||||
|
types:
|
||||||
|
[
|
||||||
|
opened,
|
||||||
|
edited,
|
||||||
|
labeled,
|
||||||
|
unlabeled,
|
||||||
|
assigned,
|
||||||
|
unassigned,
|
||||||
|
milestoned,
|
||||||
|
demilestoned,
|
||||||
|
reopened,
|
||||||
|
closed,
|
||||||
|
]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
notion_job:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
name: Add GitHub Issues to Notion
|
||||||
|
steps:
|
||||||
|
- name: Add GitHub Issues to Notion
|
||||||
|
uses: vulcanize/notion-github-action@v1.2.4-issueid
|
||||||
|
with:
|
||||||
|
notion-token: ${{ secrets.NOTION_TOKEN }}
|
||||||
|
notion-db: ${{ secrets.NOTION_DATABASE }}
|
14
.github/workflows/labeler.yml
vendored
Normal file
14
.github/workflows/labeler.yml
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
name: "Pull Request Labeler"
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
triage:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/labeler@v4
|
||||||
|
with:
|
||||||
|
repo-token: "${{ secrets.GITHUB_TOKEN }}"
|
@ -16,27 +16,37 @@ jobs:
|
|||||||
# Required: setup-go, for all versions v3.0.0+ of golangci-lint
|
# Required: setup-go, for all versions v3.0.0+ of golangci-lint
|
||||||
- uses: actions/setup-go@v3
|
- uses: actions/setup-go@v3
|
||||||
with:
|
with:
|
||||||
go-version: 1.21
|
go-version: 1.19
|
||||||
check-latest: true
|
check-latest: true
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
- uses: technote-space/get-diff-action@v6.1.2
|
||||||
|
with:
|
||||||
|
PATTERNS: |
|
||||||
|
**/**.go
|
||||||
|
go.mod
|
||||||
|
go.sum
|
||||||
- uses: golangci/golangci-lint-action@v3.3.1
|
- uses: golangci/golangci-lint-action@v3.3.1
|
||||||
with:
|
with:
|
||||||
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
|
||||||
version: latest
|
version: latest
|
||||||
args: --timeout 10m
|
args: --timeout 10m
|
||||||
github-token: ${{ secrets.github_token }}
|
github-token: ${{ secrets.github_token }}
|
||||||
|
# Check only if there are differences in the source code
|
||||||
|
if: env.GIT_DIFF
|
||||||
|
|
||||||
python-lint:
|
python-lint:
|
||||||
# For compatibility with Gitea
|
|
||||||
env:
|
|
||||||
USER: root
|
|
||||||
name: Run flake8 on python integration tests
|
name: Run flake8 on python integration tests
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v2
|
||||||
- uses: cachix/install-nix-action@v20
|
- uses: cachix/install-nix-action@v18
|
||||||
- uses: cachix/cachix-action@v12
|
- uses: cachix/cachix-action@v12
|
||||||
with:
|
with:
|
||||||
name: ethermint
|
name: ethermint
|
||||||
|
- uses: technote-space/get-diff-action@v6.1.2
|
||||||
|
with:
|
||||||
|
PATTERNS: |
|
||||||
|
**/**.py
|
||||||
- run: |
|
- run: |
|
||||||
nix-shell -I nixpkgs=./nix -p test-env --run "make lint-py"
|
nix-shell -I nixpkgs=./nix -p test-env --run "make lint-py"
|
||||||
|
if: env.GIT_DIFF
|
37
.github/workflows/security.yml
vendored
Normal file
37
.github/workflows/security.yml
vendored
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
name: Run Gosec
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Gosec:
|
||||||
|
permissions:
|
||||||
|
security-events: write
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
env:
|
||||||
|
GO111MODULE: on
|
||||||
|
steps:
|
||||||
|
- name: Checkout Source
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
- name: Get Diff
|
||||||
|
uses: technote-space/get-diff-action@v6.1.2
|
||||||
|
with:
|
||||||
|
PATTERNS: |
|
||||||
|
**/*.go
|
||||||
|
go.mod
|
||||||
|
go.sum
|
||||||
|
- name: Run Gosec Security Scanner
|
||||||
|
uses: cosmos/gosec@master
|
||||||
|
with:
|
||||||
|
# we let the report trigger content trigger a failure using the GitHub Security features.
|
||||||
|
args: '-no-fail -fmt sarif -out results.sarif -exclude=G701,G703 ./...'
|
||||||
|
if: "env.GIT_DIFF_FILTERED != ''"
|
||||||
|
- name: Upload SARIF file
|
||||||
|
uses: github/codeql-action/upload-sarif@v2
|
||||||
|
with:
|
||||||
|
# Path to SARIF file relative to the root of the repository
|
||||||
|
sarif_file: results.sarif
|
||||||
|
if: "env.GIT_DIFF_FILTERED != ''"
|
45
.github/workflows/semgrep.yml
vendored
Normal file
45
.github/workflows/semgrep.yml
vendored
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
name: Semgrep
|
||||||
|
on:
|
||||||
|
# Scan changed files in PRs, block on new issues only (existing issues ignored)
|
||||||
|
pull_request: {}
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
paths:
|
||||||
|
- .github/workflows/semgrep.yml
|
||||||
|
schedule:
|
||||||
|
- cron: '0 0 * * 0'
|
||||||
|
jobs:
|
||||||
|
# Update from: https://semgrep.dev/docs/semgrep-ci/sample-ci-configs/#github-actions
|
||||||
|
semgrep:
|
||||||
|
name: Scan
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
container:
|
||||||
|
image: returntocorp/semgrep
|
||||||
|
if: (github.actor != 'dependabot[bot]')
|
||||||
|
steps:
|
||||||
|
- name: Permission issue fix
|
||||||
|
run: git config --global --add safe.directory /__w/laconicd/laconicd
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Get Diff
|
||||||
|
uses: technote-space/get-diff-action@v6.1.2
|
||||||
|
with:
|
||||||
|
PATTERNS: |
|
||||||
|
**/*.go
|
||||||
|
**/*.js
|
||||||
|
**/*.ts
|
||||||
|
**/*.sol
|
||||||
|
go.mod
|
||||||
|
go.sum
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- run: semgrep scan --sarif --output=semgrep.sarif --config auto
|
||||||
|
env:
|
||||||
|
# Upload findings to GitHub Advanced Security Dashboard [step 1/2]
|
||||||
|
SEMGREP_APP_TOKEN: ${{ secrets.SEMGREP_APP_TOKEN }}
|
||||||
|
if: "env.GIT_DIFF_FILTERED != ''"
|
||||||
|
# Upload findings to GitHub Advanced Security Dashboard [step 2/2]
|
||||||
|
- name: Upload SARIF file
|
||||||
|
uses: github/codeql-action/upload-sarif@v2
|
||||||
|
with:
|
||||||
|
sarif_file: semgrep.sarif
|
||||||
|
if: "env.GIT_DIFF_FILTERED != ''"
|
21
.github/workflows/stale.yml
vendored
Normal file
21
.github/workflows/stale.yml
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
name: "Close stale issues & pull requests"
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 0 * * *"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
stale:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/stale@v6
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
stale-pr-message: "This pull request has been automatically marked as stale because it has not had
|
||||||
|
recent activity. It will be closed in 7 days-before-close if no further activity occurs."
|
||||||
|
stale-issue-message: "This issue is stale because it has been open 45 days with no activity. Remove `Status: Stale` label or comment or this will be closed in 7 days."
|
||||||
|
days-before-stale: 45
|
||||||
|
days-before-close: 7
|
||||||
|
exempt-issue-labels: "Status: Blocked, Type: Bug, pinned, automerge"
|
||||||
|
exempt-pr-labels: "Status: Blocked, Type: Bug, pinned, automerge"
|
||||||
|
stale-pr-label: "Status: Stale"
|
||||||
|
stale-issue-label: "Status: Stale"
|
176
.github/workflows/test.yml
vendored
Normal file
176
.github/workflows/test.yml
vendored
Normal file
@ -0,0 +1,176 @@
|
|||||||
|
name: Tests
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
- release/**
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
cleanup-runs:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: rokroskar/workflow-run-cleanup-action@master
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/main'"
|
||||||
|
|
||||||
|
test-unit-cover:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: 1.19
|
||||||
|
check-latest: true
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: technote-space/get-diff-action@v6.1.2
|
||||||
|
with:
|
||||||
|
PATTERNS: |
|
||||||
|
**/**.go
|
||||||
|
go.mod
|
||||||
|
go.sum
|
||||||
|
- name: Test and Create Coverage Report
|
||||||
|
run: |
|
||||||
|
make test-unit-cover
|
||||||
|
if: env.GIT_DIFF
|
||||||
|
- uses: codecov/codecov-action@v3
|
||||||
|
with:
|
||||||
|
file: ./coverage.txt
|
||||||
|
fail_ci_if_error: false
|
||||||
|
if: env.GIT_DIFF
|
||||||
|
|
||||||
|
test-importer:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 10
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: 1.19
|
||||||
|
check-latest: true
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: technote-space/get-diff-action@v6.1.2
|
||||||
|
id: git_diff
|
||||||
|
with:
|
||||||
|
PATTERNS: |
|
||||||
|
**/**.go
|
||||||
|
go.mod
|
||||||
|
go.sum
|
||||||
|
- name: test-importer
|
||||||
|
run: |
|
||||||
|
make test-import
|
||||||
|
if: env.GIT_DIFF
|
||||||
|
|
||||||
|
test-rpc:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
timeout-minutes: 15
|
||||||
|
steps:
|
||||||
|
- uses: actions/setup-go@v3
|
||||||
|
with:
|
||||||
|
go-version: 1.19
|
||||||
|
check-latest: true
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- uses: technote-space/get-diff-action@v6.1.2
|
||||||
|
with:
|
||||||
|
PATTERNS: |
|
||||||
|
**/**.sol
|
||||||
|
**/**.go
|
||||||
|
go.mod
|
||||||
|
go.sum
|
||||||
|
- name: Test rpc endpoint
|
||||||
|
run: |
|
||||||
|
make test-rpc
|
||||||
|
if: env.GIT_DIFF
|
||||||
|
|
||||||
|
sdk_tests:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
- name: Checkout laconic-sdk
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
with:
|
||||||
|
path: "./laconic-sdk/"
|
||||||
|
repository: cerc-io/laconic-sdk
|
||||||
|
fetch-depth: 0
|
||||||
|
ref: jest_timeout
|
||||||
|
- name: Environment
|
||||||
|
run: ls -tlh && env
|
||||||
|
- name: build containers scripts
|
||||||
|
working-directory: tests/sdk_tests
|
||||||
|
run: ./build-laconicd-container.sh && ./build-sdk-test-container.sh
|
||||||
|
- name: start containers
|
||||||
|
working-directory: tests/sdk_tests
|
||||||
|
run: docker compose up -d
|
||||||
|
- name: run-tests.sh
|
||||||
|
working-directory: tests/sdk_tests
|
||||||
|
run: ./run-tests.sh
|
||||||
|
- name: reset containers for auction tests
|
||||||
|
working-directory: tests/sdk_tests
|
||||||
|
if: always()
|
||||||
|
run: docker compose down
|
||||||
|
- name: start auction containers
|
||||||
|
working-directory: tests/sdk_tests
|
||||||
|
run: docker compose -f docker-compose-auctions.yml up -d
|
||||||
|
- name: run-acution-tests.sh
|
||||||
|
working-directory: tests/sdk_tests
|
||||||
|
run: ./run-auction-tests.sh
|
||||||
|
- name: reset containers for nameservice tests
|
||||||
|
working-directory: tests/sdk_tests
|
||||||
|
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
|
||||||
|
# steps:
|
||||||
|
# - uses: actions/checkout@v2
|
||||||
|
# - uses: cachix/install-nix-action@v18
|
||||||
|
# - uses: cachix/cachix-action@v12
|
||||||
|
# with:
|
||||||
|
# name: ethermint
|
||||||
|
# signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
|
||||||
|
# - uses: technote-space/get-diff-action@v6.1.2
|
||||||
|
# with:
|
||||||
|
# PATTERNS: |
|
||||||
|
# **/**.sol
|
||||||
|
# **/**.go
|
||||||
|
# go.mod
|
||||||
|
# go.sum
|
||||||
|
# tests/integration_tests/**
|
||||||
|
# - name: Run integration tests
|
||||||
|
# run: make run-integration-tests
|
||||||
|
# if: env.GIT_DIFF
|
||||||
|
# - name: 'Tar debug files'
|
||||||
|
# if: failure()
|
||||||
|
# run: tar cfz debug_files.tar.gz -C /tmp/pytest-of-runner .
|
||||||
|
# - uses: actions/upload-artifact@v3
|
||||||
|
# if: failure()
|
||||||
|
# with:
|
||||||
|
# name: debug-files
|
||||||
|
# path: debug_files.tar.gz
|
||||||
|
# if-no-files-found: ignore
|
||||||
|
|
||||||
|
# upload-cache:
|
||||||
|
# if: github.event_name == 'push'
|
||||||
|
# needs: ["integration_tests"]
|
||||||
|
# strategy:
|
||||||
|
# matrix:
|
||||||
|
# os: [macos-latest]
|
||||||
|
# runs-on: ${{ matrix.os }}
|
||||||
|
# steps:
|
||||||
|
# - uses: actions/checkout@v2
|
||||||
|
# - uses: cachix/install-nix-action@v18
|
||||||
|
# - uses: cachix/cachix-action@v12
|
||||||
|
# with:
|
||||||
|
# name: ethermint
|
||||||
|
# signingKey: "${{ secrets.CACHIX_SIGNING_KEY }}"
|
||||||
|
# - name: 'instantiate integration test env'
|
||||||
|
# run: nix-store -r "$(nix-instantiate tests/integration_tests/shell.nix)"
|
@ -6,13 +6,14 @@ run:
|
|||||||
linters:
|
linters:
|
||||||
enable:
|
enable:
|
||||||
- bodyclose
|
- bodyclose
|
||||||
# - depguard # 20231120 disable until https://github.com/golangci/golangci-lint/issues/3906 is released
|
- depguard
|
||||||
- dogsled
|
- dogsled
|
||||||
|
- dupl
|
||||||
- errcheck
|
- errcheck
|
||||||
- goconst
|
- goconst
|
||||||
- gocritic
|
- gocritic
|
||||||
- gofumpt
|
- gofumpt
|
||||||
# - revive # 20231120 overly sensitive unused detection
|
- revive
|
||||||
- gosec
|
- gosec
|
||||||
- gosimple
|
- gosimple
|
||||||
- govet
|
- govet
|
||||||
|
12
Dockerfile
12
Dockerfile
@ -1,14 +1,14 @@
|
|||||||
FROM golang:alpine AS build-env
|
FROM golang:alpine AS build-env
|
||||||
|
|
||||||
# Install dependencies
|
# Set up dependencies
|
||||||
RUN apk add --update git build-base linux-headers
|
ENV PACKAGES git build-base
|
||||||
|
|
||||||
# Set working directory for the build
|
# Set working directory for the build
|
||||||
WORKDIR /go/src/github.com/cerc-io/laconicd
|
WORKDIR /go/src/github.com/cerc-io/laconicd
|
||||||
|
|
||||||
# Cache Go modules
|
# Install dependencies
|
||||||
COPY go.mod go.sum ./
|
RUN apk add --update $PACKAGES
|
||||||
RUN go mod download
|
RUN apk add linux-headers
|
||||||
|
|
||||||
# Add source files
|
# Add source files
|
||||||
COPY . .
|
COPY . .
|
||||||
@ -21,10 +21,10 @@ FROM alpine:3.17.0
|
|||||||
|
|
||||||
# Install ca-certificates
|
# Install ca-certificates
|
||||||
RUN apk add --update ca-certificates jq curl
|
RUN apk add --update ca-certificates jq curl
|
||||||
|
WORKDIR /
|
||||||
|
|
||||||
# Copy over binaries from the build-env
|
# Copy over binaries from the build-env
|
||||||
COPY --from=build-env /go/src/github.com/cerc-io/laconicd/build/laconicd /usr/bin/laconicd
|
COPY --from=build-env /go/src/github.com/cerc-io/laconicd/build/laconicd /usr/bin/laconicd
|
||||||
|
|
||||||
WORKDIR /
|
|
||||||
# Run laconicd by default
|
# Run laconicd by default
|
||||||
CMD ["laconicd"]
|
CMD ["laconicd"]
|
||||||
|
12
Makefile
12
Makefile
@ -72,7 +72,7 @@ ifeq ($(ENABLE_ROCKSDB),true)
|
|||||||
BUILD_TAGS += rocksdb_build
|
BUILD_TAGS += rocksdb_build
|
||||||
test_tags += rocksdb_build
|
test_tags += rocksdb_build
|
||||||
else
|
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
|
endif
|
||||||
|
|
||||||
# DB backend selection
|
# DB backend selection
|
||||||
@ -145,7 +145,7 @@ docker-build:
|
|||||||
# update old container
|
# update old container
|
||||||
docker rm laconicd || true
|
docker rm laconicd || true
|
||||||
# create a new container from the latest image
|
# 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
|
# move the binaries to the ./build directory
|
||||||
mkdir -p ./build/
|
mkdir -p ./build/
|
||||||
docker cp laconic:/usr/bin/laconicd ./build/
|
docker cp laconic:/usr/bin/laconicd ./build/
|
||||||
@ -237,7 +237,7 @@ endif
|
|||||||
|
|
||||||
ifeq (, $(shell which go-bindata))
|
ifeq (, $(shell which go-bindata))
|
||||||
@echo "Installing go-bindata..."
|
@echo "Installing go-bindata..."
|
||||||
@go get github.com/kevinburke/go-bindata/go-bindata@v3
|
@go get github.com/kevinburke/go-bindata/go-bindata
|
||||||
else
|
else
|
||||||
@echo "go-bindata already installed; skipping..."
|
@echo "go-bindata already installed; skipping..."
|
||||||
endif
|
endif
|
||||||
@ -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
|
# Test runs-specific rules. To add a new test target, just add
|
||||||
# a new rule, customise ARGS or TEST_PACKAGES ad libitum, and
|
# a new rule, customise ARGS or TEST_PACKAGES ad libitum, and
|
||||||
# append the new rule to the TEST_TARGETS list.
|
# append the new rule to the TEST_TARGETS list.
|
||||||
test-unit: ARGS=-timeout=10m -race -test.v -skip $(SKIP_UNIT_TESTS)
|
test-unit: ARGS=-timeout=10m -race
|
||||||
test-unit: TEST_PACKAGES=$(PACKAGES_UNIT)
|
test-unit: TEST_PACKAGES=$(PACKAGES_UNIT)
|
||||||
|
|
||||||
test-race: ARGS=-race
|
test-race: ARGS=-race
|
||||||
@ -334,10 +334,10 @@ else
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
test-import:
|
test-import:
|
||||||
go test -run TestImporterTestSuite -timeout=20m -v --vet=off github.com/cerc-io/laconicd/tests/importer
|
go test -run TestImporterTestSuite -v --vet=off github.com/cerc-io/laconicd/tests/importer
|
||||||
|
|
||||||
test-rpc:
|
test-rpc:
|
||||||
./scripts/integration-test-all.sh -t "rpc" -q 1 -z 1 -s 10 -m "rpc" -r "true"
|
./scripts/integration-test-all.sh -t "rpc" -q 1 -z 1 -s 2 -m "rpc" -r "true"
|
||||||
|
|
||||||
run-integration-tests:
|
run-integration-tests:
|
||||||
@nix-shell ./tests/integration_tests/shell.nix --run ./scripts/run-integration-tests.sh
|
@nix-shell ./tests/integration_tests/shell.nix --run ./scripts/run-integration-tests.sh
|
||||||
|
@ -24,8 +24,6 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/signer/core/apitypes"
|
"github.com/ethereum/go-ethereum/signer/core/apitypes"
|
||||||
)
|
)
|
||||||
|
|
||||||
const bytesStr = "bytes"
|
|
||||||
|
|
||||||
// WrapTxToTypedData is an ultimate method that wraps Amino-encoded Cosmos Tx JSON data
|
// WrapTxToTypedData is an ultimate method that wraps Amino-encoded Cosmos Tx JSON data
|
||||||
// into an EIP712-compatible TypedData request.
|
// into an EIP712-compatible TypedData request.
|
||||||
func WrapTxToTypedData(
|
func WrapTxToTypedData(
|
||||||
@ -35,6 +33,7 @@ func WrapTxToTypedData(
|
|||||||
data []byte,
|
data []byte,
|
||||||
feeDelegation *FeeDelegationOptions,
|
feeDelegation *FeeDelegationOptions,
|
||||||
) (apitypes.TypedData, error) {
|
) (apitypes.TypedData, error) {
|
||||||
|
|
||||||
domain := apitypes.TypedDataDomain{
|
domain := apitypes.TypedDataDomain{
|
||||||
Name: "Cosmos Web3",
|
Name: "Cosmos Web3",
|
||||||
Version: "1.0.0",
|
Version: "1.0.0",
|
||||||
@ -299,7 +298,7 @@ func traverseFields(
|
|||||||
}
|
}
|
||||||
// convert uint8[] to bytes
|
// convert uint8[] to bytes
|
||||||
if fieldType.Kind() == reflect.Uint8 {
|
if fieldType.Kind() == reflect.Uint8 {
|
||||||
ethTyp = bytesStr
|
ethTyp = "bytes"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if prefix == typeDefPrefix {
|
if prefix == typeDefPrefix {
|
||||||
@ -449,7 +448,7 @@ func typToEth(typ reflect.Type) string {
|
|||||||
ethName := typToEth(typ.Elem())
|
ethName := typToEth(typ.Elem())
|
||||||
if len(ethName) > 0 {
|
if len(ethName) > 0 {
|
||||||
if ethName == "uint8" {
|
if ethName == "uint8" {
|
||||||
return bytesStr
|
return "bytes"
|
||||||
}
|
}
|
||||||
return ethName + "[]"
|
return ethName + "[]"
|
||||||
}
|
}
|
||||||
@ -496,9 +495,7 @@ func patchTxData(data map[string]any, schema apitypes.Types, rootType string) er
|
|||||||
for _, field := range schema[rootType] {
|
for _, field := range schema[rootType] {
|
||||||
encType := field.Type
|
encType := field.Type
|
||||||
encValue := data[field.Name]
|
encValue := data[field.Name]
|
||||||
|
if encType[len(encType)-1:] == "]" {
|
||||||
switch {
|
|
||||||
case encType[len(encType)-1:] == "]":
|
|
||||||
arrayValue, ok := encValue.([]interface{})
|
arrayValue, ok := encValue.([]interface{})
|
||||||
if !ok {
|
if !ok {
|
||||||
return dataMismatchError(encType, encValue)
|
return dataMismatchError(encType, encValue)
|
||||||
@ -526,7 +523,8 @@ func patchTxData(data map[string]any, schema apitypes.Types, rootType string) er
|
|||||||
arrayValue[i] = converted
|
arrayValue[i] = converted
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case schema[encType] != nil:
|
|
||||||
|
} else if schema[encType] != nil {
|
||||||
mapValue, ok := encValue.(map[string]interface{})
|
mapValue, ok := encValue.(map[string]interface{})
|
||||||
if !ok {
|
if !ok {
|
||||||
return dataMismatchError(encType, encValue)
|
return dataMismatchError(encType, encValue)
|
||||||
@ -535,7 +533,7 @@ func patchTxData(data map[string]any, schema apitypes.Types, rootType string) er
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
default:
|
} else {
|
||||||
converted, err := handleConversion(encType, encValue)
|
converted, err := handleConversion(encType, encValue)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -547,7 +545,8 @@ func patchTxData(data map[string]any, schema apitypes.Types, rootType string) er
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handleConversion(encType string, encValue any) (any, error) {
|
func handleConversion(encType string, encValue any) (any, error) {
|
||||||
if encType == bytesStr {
|
switch encType {
|
||||||
|
case "bytes":
|
||||||
// Protobuf encodes byte strings in base64
|
// Protobuf encodes byte strings in base64
|
||||||
if v, ok := encValue.(string); ok {
|
if v, ok := encValue.(string); ok {
|
||||||
return base64.StdEncoding.DecodeString(v)
|
return base64.StdEncoding.DecodeString(v)
|
||||||
|
1
go.mod
1
go.mod
@ -134,7 +134,6 @@ require (
|
|||||||
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
|
github.com/jackpal/go-nat-pmp v1.0.2 // indirect
|
||||||
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
github.com/jmespath/go-jmespath v0.4.0 // indirect
|
||||||
github.com/jmhodges/levigo v1.0.0 // indirect
|
github.com/jmhodges/levigo v1.0.0 // indirect
|
||||||
github.com/kevinburke/go-bindata v3.24.0+incompatible // indirect
|
|
||||||
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
|
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d // indirect
|
||||||
github.com/klauspost/compress v1.15.11 // indirect
|
github.com/klauspost/compress v1.15.11 // indirect
|
||||||
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
|
github.com/klauspost/cpuid/v2 v2.0.9 // indirect
|
||||||
|
6
go.sum
6
go.sum
@ -836,12 +836,6 @@ github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E
|
|||||||
github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0=
|
github.com/jwilder/encoding v0.0.0-20170811194829-b4e1701a28ef/go.mod h1:Ct9fl0F6iIOGgxJ5npU/IUOhOhqlVrGjyIZc8/MagT0=
|
||||||
github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
|
github.com/karalabe/usb v0.0.0-20190919080040-51dc0efba356/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
|
||||||
github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
|
github.com/karalabe/usb v0.0.2/go.mod h1:Od972xHfMJowv7NGVDiWVxk2zxnWgjLlJzE+F4F7AGU=
|
||||||
github.com/kevinburke/go-bindata v1.1.0 h1:JZ8XIdxtkAszuYkgf17qwQzcU/RgsGSVLSULJdN+5bU=
|
|
||||||
github.com/kevinburke/go-bindata v1.1.0/go.mod h1:UJ72WTOoRKzbz+vwtKgARJwsy+1ZGUukVBUCc197TJo=
|
|
||||||
github.com/kevinburke/go-bindata v3.22.0+incompatible h1:/JmqEhIWQ7GRScV0WjX/0tqBrC5D21ALg0H0U/KZ/ts=
|
|
||||||
github.com/kevinburke/go-bindata v3.22.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM=
|
|
||||||
github.com/kevinburke/go-bindata v3.24.0+incompatible h1:qajFA3D0pH94OTLU4zcCCKCDgR+Zr2cZK/RPJHDdFoY=
|
|
||||||
github.com/kevinburke/go-bindata v3.24.0+incompatible/go.mod h1:/pEEZ72flUW2p0yi30bslSp9YqD9pysLxunQDdb2CPM=
|
|
||||||
github.com/kevinmbeaulieu/eq-go v1.0.0/go.mod h1:G3S8ajA56gKBZm4UB9AOyoOS37JO3roToPzKNM8dtdM=
|
github.com/kevinmbeaulieu/eq-go v1.0.0/go.mod h1:G3S8ajA56gKBZm4UB9AOyoOS37JO3roToPzKNM8dtdM=
|
||||||
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM=
|
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d h1:Z+RDyXzjKE0i2sTjZ/b1uxiGtPhFy34Ou/Tk0qwN0kM=
|
||||||
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc=
|
github.com/keybase/go-keychain v0.0.0-20190712205309-48d3d31d256d/go.mod h1:JJNrCn9otv/2QP4D7SMJBgaleKpOf66PnW6F5WGNRIc=
|
||||||
|
6818
gql/generated.go
6818
gql/generated.go
File diff suppressed because it is too large
Load Diff
@ -1,3 +1,5 @@
|
|||||||
|
# .gqlgen.yml example
|
||||||
|
#
|
||||||
# Refer to https://gqlgen.com/config/
|
# Refer to https://gqlgen.com/config/
|
||||||
# for detailed .gqlgen.yml documentation.
|
# for detailed .gqlgen.yml documentation.
|
||||||
|
|
||||||
@ -10,8 +12,3 @@ model:
|
|||||||
resolver:
|
resolver:
|
||||||
filename: resolver.go
|
filename: resolver.go
|
||||||
type: Resolver
|
type: Resolver
|
||||||
|
|
||||||
models:
|
|
||||||
Link:
|
|
||||||
model:
|
|
||||||
- github.com/cerc-io/laconicd/gql.Link
|
|
||||||
|
@ -2,10 +2,6 @@
|
|||||||
|
|
||||||
package gql
|
package gql
|
||||||
|
|
||||||
type Value interface {
|
|
||||||
IsValue()
|
|
||||||
}
|
|
||||||
|
|
||||||
type Account struct {
|
type Account struct {
|
||||||
Address string `json:"address"`
|
Address string `json:"address"`
|
||||||
PubKey *string `json:"pubKey"`
|
PubKey *string `json:"pubKey"`
|
||||||
@ -14,17 +10,6 @@ type Account struct {
|
|||||||
Balance []*Coin `json:"balance"`
|
Balance []*Coin `json:"balance"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ArrayValue struct {
|
|
||||||
Value []Value `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (ArrayValue) IsValue() {}
|
|
||||||
|
|
||||||
type Attribute struct {
|
|
||||||
Key string `json:"key"`
|
|
||||||
Value Value `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type Auction struct {
|
type Auction struct {
|
||||||
ID string `json:"id"`
|
ID string `json:"id"`
|
||||||
Status string `json:"status"`
|
Status string `json:"status"`
|
||||||
@ -68,52 +53,21 @@ type Bond struct {
|
|||||||
Balance []*Coin `json:"balance"`
|
Balance []*Coin `json:"balance"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type BooleanValue struct {
|
|
||||||
Value bool `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (BooleanValue) IsValue() {}
|
|
||||||
|
|
||||||
type BytesValue struct {
|
|
||||||
Value string `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (BytesValue) IsValue() {}
|
|
||||||
|
|
||||||
type Coin struct {
|
type Coin struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Quantity string `json:"quantity"`
|
Quantity string `json:"quantity"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type FloatValue struct {
|
type KeyValue struct {
|
||||||
Value float64 `json:"value"`
|
Key string `json:"key"`
|
||||||
|
Value *Value `json:"value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (FloatValue) IsValue() {}
|
|
||||||
|
|
||||||
type IntValue struct {
|
|
||||||
Value int `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (IntValue) IsValue() {}
|
|
||||||
|
|
||||||
type KeyValueInput struct {
|
type KeyValueInput struct {
|
||||||
Key string `json:"key"`
|
Key string `json:"key"`
|
||||||
Value *ValueInput `json:"value"`
|
Value *ValueInput `json:"value"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type LinkValue struct {
|
|
||||||
Value Link `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (LinkValue) IsValue() {}
|
|
||||||
|
|
||||||
type MapValue struct {
|
|
||||||
Value []*Attribute `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (MapValue) IsValue() {}
|
|
||||||
|
|
||||||
type NameRecord struct {
|
type NameRecord struct {
|
||||||
Latest *NameRecordEntry `json:"latest"`
|
Latest *NameRecordEntry `json:"latest"`
|
||||||
History []*NameRecordEntry `json:"history"`
|
History []*NameRecordEntry `json:"history"`
|
||||||
@ -148,10 +102,18 @@ type Record struct {
|
|||||||
CreateTime string `json:"createTime"`
|
CreateTime string `json:"createTime"`
|
||||||
ExpiryTime string `json:"expiryTime"`
|
ExpiryTime string `json:"expiryTime"`
|
||||||
Owners []string `json:"owners"`
|
Owners []string `json:"owners"`
|
||||||
Attributes []*Attribute `json:"attributes"`
|
Attributes []*KeyValue `json:"attributes"`
|
||||||
References []*Record `json:"references"`
|
References []*Record `json:"references"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Reference struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ReferenceInput struct {
|
||||||
|
ID string `json:"id"`
|
||||||
|
}
|
||||||
|
|
||||||
type Status struct {
|
type Status struct {
|
||||||
Version string `json:"version"`
|
Version string `json:"version"`
|
||||||
Node *NodeInfo `json:"node"`
|
Node *NodeInfo `json:"node"`
|
||||||
@ -163,12 +125,6 @@ type Status struct {
|
|||||||
DiskUsage string `json:"disk_usage"`
|
DiskUsage string `json:"disk_usage"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type StringValue struct {
|
|
||||||
Value string `json:"value"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func (StringValue) IsValue() {}
|
|
||||||
|
|
||||||
type SyncInfo struct {
|
type SyncInfo struct {
|
||||||
LatestBlockHash string `json:"latest_block_hash"`
|
LatestBlockHash string `json:"latest_block_hash"`
|
||||||
LatestBlockHeight string `json:"latest_block_height"`
|
LatestBlockHeight string `json:"latest_block_height"`
|
||||||
@ -182,12 +138,23 @@ type ValidatorInfo struct {
|
|||||||
ProposerPriority *string `json:"proposer_priority"`
|
ProposerPriority *string `json:"proposer_priority"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type ValueInput struct {
|
type Value struct {
|
||||||
|
Null *bool `json:"null"`
|
||||||
Int *int `json:"int"`
|
Int *int `json:"int"`
|
||||||
Float *float64 `json:"float"`
|
Float *float64 `json:"float"`
|
||||||
String *string `json:"string"`
|
String *string `json:"string"`
|
||||||
Boolean *bool `json:"boolean"`
|
Boolean *bool `json:"boolean"`
|
||||||
Link *Link `json:"link"`
|
JSON *string `json:"json"`
|
||||||
Array []*ValueInput `json:"array"`
|
Reference *Reference `json:"reference"`
|
||||||
Map []*KeyValueInput `json:"map"`
|
Values []*Value `json:"values"`
|
||||||
|
}
|
||||||
|
|
||||||
|
type ValueInput struct {
|
||||||
|
Null *bool `json:"null"`
|
||||||
|
Int *int `json:"int"`
|
||||||
|
Float *float64 `json:"float"`
|
||||||
|
String *string `json:"string"`
|
||||||
|
Boolean *bool `json:"boolean"`
|
||||||
|
Reference *ReferenceInput `json:"reference"`
|
||||||
|
Values []*ValueInput `json:"values"`
|
||||||
}
|
}
|
||||||
|
@ -121,7 +121,7 @@ func (q queryResolver) QueryRecords(ctx context.Context, attributes []*KeyValueI
|
|||||||
res, err := nsQueryClient.ListRecords(
|
res, err := nsQueryClient.ListRecords(
|
||||||
context.Background(),
|
context.Background(),
|
||||||
®istrytypes.QueryListRecordsRequest{
|
®istrytypes.QueryListRecordsRequest{
|
||||||
Attributes: toRPCAttributes(attributes),
|
Attributes: parseRequestAttributes(attributes),
|
||||||
All: (all != nil && *all),
|
All: (all != nil && *all),
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
@ -1,33 +0,0 @@
|
|||||||
package gql
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"encoding/json"
|
|
||||||
"fmt"
|
|
||||||
"io"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Represents an IPLD link. Links are generally but not necessarily implemented as CIDs
|
|
||||||
type Link string
|
|
||||||
|
|
||||||
func (l Link) String() string {
|
|
||||||
return string(l)
|
|
||||||
}
|
|
||||||
|
|
||||||
// UnmarshalGQLContext implements the graphql.ContextUnmarshaler interface
|
|
||||||
func (l *Link) UnmarshalGQLContext(_ context.Context, v interface{}) error {
|
|
||||||
s, ok := v.(string)
|
|
||||||
if !ok {
|
|
||||||
return fmt.Errorf("Link must be a string")
|
|
||||||
}
|
|
||||||
*l = Link(s)
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// MarshalGQLContext implements the graphql.ContextMarshaler interface
|
|
||||||
func (l Link) MarshalGQLContext(_ context.Context, w io.Writer) error {
|
|
||||||
encodable := map[string]string{
|
|
||||||
"/": l.String(),
|
|
||||||
}
|
|
||||||
return json.NewEncoder(w).Encode(encodable)
|
|
||||||
}
|
|
254
gql/util.go
254
gql/util.go
@ -2,15 +2,15 @@ package gql
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt" // #nosec G702
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"reflect" // #nosec G702
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
auctiontypes "github.com/cerc-io/laconicd/x/auction/types"
|
auctiontypes "github.com/cerc-io/laconicd/x/auction/types"
|
||||||
bondtypes "github.com/cerc-io/laconicd/x/bond/types"
|
bondtypes "github.com/cerc-io/laconicd/x/bond/types"
|
||||||
registrytypes "github.com/cerc-io/laconicd/x/registry/types"
|
registrytypes "github.com/cerc-io/laconicd/x/registry/types"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
"github.com/ipld/go-ipld-prime"
|
|
||||||
"github.com/ipld/go-ipld-prime/codec/dagjson"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// OwnerAttributeName denotes the owner attribute name for a bond.
|
// OwnerAttributeName denotes the owner attribute name for a bond.
|
||||||
@ -61,21 +61,13 @@ func getGQLRecord(ctx context.Context, resolver QueryResolver, record registryty
|
|||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
node, err := ipld.Decode(record.Attributes, dagjson.Decode)
|
recordType := record.ToReadableRecord()
|
||||||
if err != nil {
|
attributes, err := getAttributes(&recordType)
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if node.Kind() != ipld.Kind_Map {
|
|
||||||
return nil, fmt.Errorf("invalid record attributes")
|
|
||||||
}
|
|
||||||
|
|
||||||
var links []string
|
|
||||||
attributes, err := resolveIPLDNode(node, &links)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
references, err := resolver.GetRecordsByIds(ctx, links)
|
references, err := getReferences(ctx, resolver, &recordType)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -87,96 +79,11 @@ func getGQLRecord(ctx context.Context, resolver QueryResolver, record registryty
|
|||||||
ExpiryTime: record.GetExpiryTime(),
|
ExpiryTime: record.GetExpiryTime(),
|
||||||
Owners: record.GetOwners(),
|
Owners: record.GetOwners(),
|
||||||
Names: record.GetNames(),
|
Names: record.GetNames(),
|
||||||
Attributes: attributes.(MapValue).Value,
|
Attributes: attributes,
|
||||||
References: references,
|
References: references,
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func resolveIPLDNode(node ipld.Node, links *[]string) (Value, error) {
|
|
||||||
switch node.Kind() {
|
|
||||||
case ipld.Kind_Map:
|
|
||||||
var entries []*Attribute
|
|
||||||
for itr := node.MapIterator(); !itr.Done(); {
|
|
||||||
k, v, err := itr.Next()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
if k.Kind() != ipld.Kind_String {
|
|
||||||
return nil, fmt.Errorf("invalid record attribute key type: %s", k.Kind())
|
|
||||||
}
|
|
||||||
s, err := k.AsString()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
val, err := resolveIPLDNode(v, links)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
entries = append(entries, &Attribute{
|
|
||||||
Key: s,
|
|
||||||
Value: val,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
return MapValue{entries}, nil
|
|
||||||
case ipld.Kind_List:
|
|
||||||
var values []Value
|
|
||||||
for itr := node.ListIterator(); !itr.Done(); {
|
|
||||||
_, v, err := itr.Next()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
val, err := resolveIPLDNode(v, links)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
values = append(values, val)
|
|
||||||
}
|
|
||||||
return ArrayValue{values}, nil
|
|
||||||
case ipld.Kind_Null:
|
|
||||||
return nil, nil
|
|
||||||
case ipld.Kind_Bool:
|
|
||||||
val, err := node.AsBool()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return BooleanValue{val}, nil
|
|
||||||
case ipld.Kind_Int:
|
|
||||||
val, err := node.AsInt()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
// TODO: handle bigger ints
|
|
||||||
return IntValue{int(val)}, nil
|
|
||||||
case ipld.Kind_Float:
|
|
||||||
val, err := node.AsFloat()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return FloatValue{val}, nil
|
|
||||||
case ipld.Kind_String:
|
|
||||||
val, err := node.AsString()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return StringValue{val}, nil
|
|
||||||
case ipld.Kind_Bytes:
|
|
||||||
val, err := node.AsBytes()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
return BytesValue{string(val)}, nil
|
|
||||||
case ipld.Kind_Link:
|
|
||||||
val, err := node.AsLink()
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
*links = append(*links, val.String())
|
|
||||||
return LinkValue{Link(val.String())}, nil
|
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("invalid node kind")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func getGQLNameRecord(record *registrytypes.NameRecord) (*NameRecord, error) {
|
func getGQLNameRecord(record *registrytypes.NameRecord) (*NameRecord, error) {
|
||||||
if record == nil {
|
if record == nil {
|
||||||
return nil, fmt.Errorf("got nil record")
|
return nil, fmt.Errorf("got nil record")
|
||||||
@ -256,47 +163,136 @@ func GetGQLAuction(auction *auctiontypes.Auction, bids []*auctiontypes.Bid) (*Au
|
|||||||
return &gqlAuction, nil
|
return &gqlAuction, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func toRPCValue(value *ValueInput) *registrytypes.QueryListRecordsRequest_ValueInput {
|
func getReferences(ctx context.Context, resolver QueryResolver, r *registrytypes.ReadableRecord) ([]*Record, error) {
|
||||||
var rpcval registrytypes.QueryListRecordsRequest_ValueInput
|
var ids []string
|
||||||
|
|
||||||
switch {
|
// #nosec G705
|
||||||
case value == nil:
|
for key := range r.Attributes {
|
||||||
return nil
|
//nolint: all
|
||||||
case value.Int != nil:
|
switch r.Attributes[key].(type) {
|
||||||
rpcval.Value = ®istrytypes.QueryListRecordsRequest_ValueInput_Int{Int: int64(*value.Int)}
|
case interface{}:
|
||||||
case value.Float != nil:
|
if obj, ok := r.Attributes[key].(map[string]interface{}); ok {
|
||||||
rpcval.Value = ®istrytypes.QueryListRecordsRequest_ValueInput_Float{Float: *value.Float}
|
if _, ok := obj["/"]; ok && len(obj) == 1 {
|
||||||
case value.String != nil:
|
if _, ok := obj["/"].(string); ok {
|
||||||
rpcval.Value = ®istrytypes.QueryListRecordsRequest_ValueInput_String_{String_: *value.String}
|
ids = append(ids, obj["/"].(string))
|
||||||
case value.Boolean != nil:
|
}
|
||||||
rpcval.Value = ®istrytypes.QueryListRecordsRequest_ValueInput_Boolean{Boolean: *value.Boolean}
|
|
||||||
case value.Link != nil:
|
|
||||||
rpcval.Value = ®istrytypes.QueryListRecordsRequest_ValueInput_Link{Link: value.Link.String()}
|
|
||||||
case value.Array != nil:
|
|
||||||
var contents registrytypes.QueryListRecordsRequest_ArrayInput
|
|
||||||
for _, val := range value.Array {
|
|
||||||
contents.Values = append(contents.Values, toRPCValue(val))
|
|
||||||
}
|
}
|
||||||
rpcval.Value = ®istrytypes.QueryListRecordsRequest_ValueInput_Array{Array: &contents}
|
|
||||||
case value.Map != nil:
|
|
||||||
var contents registrytypes.QueryListRecordsRequest_MapInput
|
|
||||||
for _, kv := range value.Map {
|
|
||||||
contents.Values[kv.Key] = toRPCValue(kv.Value)
|
|
||||||
}
|
}
|
||||||
rpcval.Value = ®istrytypes.QueryListRecordsRequest_ValueInput_Map{Map: &contents}
|
|
||||||
}
|
}
|
||||||
return &rpcval
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func toRPCAttributes(attrs []*KeyValueInput) []*registrytypes.QueryListRecordsRequest_KeyValueInput {
|
return resolver.GetRecordsByIds(ctx, ids)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getAttributes(r *registrytypes.ReadableRecord) ([]*KeyValue, error) {
|
||||||
|
return mapToKeyValuePairs(r.Attributes)
|
||||||
|
}
|
||||||
|
|
||||||
|
func mapToKeyValuePairs(attrs map[string]interface{}) ([]*KeyValue, error) {
|
||||||
|
kvPairs := []*KeyValue{}
|
||||||
|
|
||||||
|
trueVal := true
|
||||||
|
falseVal := false
|
||||||
|
|
||||||
|
// #nosec G705
|
||||||
|
for key, value := range attrs {
|
||||||
|
kvPair := &KeyValue{
|
||||||
|
Key: key,
|
||||||
|
Value: &Value{},
|
||||||
|
}
|
||||||
|
|
||||||
|
switch val := value.(type) {
|
||||||
|
case nil:
|
||||||
|
kvPair.Value.Null = &trueVal
|
||||||
|
case int:
|
||||||
|
kvPair.Value.Int = &val
|
||||||
|
case float64:
|
||||||
|
kvPair.Value.Float = &val
|
||||||
|
case string:
|
||||||
|
kvPair.Value.String = &val
|
||||||
|
case bool:
|
||||||
|
kvPair.Value.Boolean = &val
|
||||||
|
case interface{}:
|
||||||
|
if obj, ok := value.(map[string]interface{}); ok {
|
||||||
|
if _, ok := obj["/"]; ok && len(obj) == 1 {
|
||||||
|
if _, ok := obj["/"].(string); ok {
|
||||||
|
kvPair.Value.Reference = &Reference{
|
||||||
|
ID: obj["/"].(string),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
bytes, err := json.Marshal(obj)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonStr := string(bytes)
|
||||||
|
kvPair.Value.JSON = &jsonStr
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if kvPair.Value.Null == nil {
|
||||||
|
kvPair.Value.Null = &falseVal
|
||||||
|
}
|
||||||
|
|
||||||
|
valueType := reflect.ValueOf(value)
|
||||||
|
if valueType.Kind() == reflect.Slice {
|
||||||
|
bytes, err := json.Marshal(value)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
jsonStr := string(bytes)
|
||||||
|
kvPair.Value.JSON = &jsonStr
|
||||||
|
}
|
||||||
|
|
||||||
|
kvPairs = append(kvPairs, kvPair)
|
||||||
|
}
|
||||||
|
|
||||||
|
return kvPairs, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func parseRequestAttributes(attrs []*KeyValueInput) []*registrytypes.QueryListRecordsRequest_KeyValueInput {
|
||||||
kvPairs := []*registrytypes.QueryListRecordsRequest_KeyValueInput{}
|
kvPairs := []*registrytypes.QueryListRecordsRequest_KeyValueInput{}
|
||||||
|
|
||||||
for _, value := range attrs {
|
for _, value := range attrs {
|
||||||
parsedValue := toRPCValue(value.Value)
|
|
||||||
kvPair := ®istrytypes.QueryListRecordsRequest_KeyValueInput{
|
kvPair := ®istrytypes.QueryListRecordsRequest_KeyValueInput{
|
||||||
Key: value.Key,
|
Key: value.Key,
|
||||||
Value: parsedValue,
|
Value: ®istrytypes.QueryListRecordsRequest_ValueInput{},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if value.Value.String != nil {
|
||||||
|
kvPair.Value.String_ = *value.Value.String
|
||||||
|
kvPair.Value.Type = "string"
|
||||||
|
}
|
||||||
|
|
||||||
|
if value.Value.Int != nil {
|
||||||
|
kvPair.Value.Int = int64(*value.Value.Int)
|
||||||
|
kvPair.Value.Type = "int"
|
||||||
|
}
|
||||||
|
|
||||||
|
if value.Value.Float != nil {
|
||||||
|
kvPair.Value.Float = *value.Value.Float
|
||||||
|
kvPair.Value.Type = "float"
|
||||||
|
}
|
||||||
|
|
||||||
|
if value.Value.Boolean != nil {
|
||||||
|
kvPair.Value.Boolean = *value.Value.Boolean
|
||||||
|
kvPair.Value.Type = "boolean"
|
||||||
|
}
|
||||||
|
|
||||||
|
if value.Value.Reference != nil {
|
||||||
|
reference := ®istrytypes.QueryListRecordsRequest_ReferenceInput{
|
||||||
|
Id: value.Value.Reference.ID,
|
||||||
|
}
|
||||||
|
|
||||||
|
kvPair.Value.Reference = reference
|
||||||
|
kvPair.Value.Type = "reference"
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Handle arrays.
|
||||||
|
|
||||||
kvPairs = append(kvPairs, kvPair)
|
kvPairs = append(kvPairs, kvPair)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,12 @@
|
|||||||
# Reference to another record.
|
# Reference to another record.
|
||||||
scalar Link
|
type Reference {
|
||||||
|
id: String! # ID of linked record.
|
||||||
|
}
|
||||||
|
|
||||||
|
# Reference to another record.
|
||||||
|
input ReferenceInput {
|
||||||
|
id: String!
|
||||||
|
}
|
||||||
|
|
||||||
# Bonds contain funds that are used to pay rent on record registration and renewal.
|
# Bonds contain funds that are used to pay rent on record registration and renewal.
|
||||||
type Bond {
|
type Bond {
|
||||||
@ -30,71 +37,44 @@ type Account {
|
|||||||
balance: [Coin!] # Current balance for each coin type.
|
balance: [Coin!] # Current balance for each coin type.
|
||||||
}
|
}
|
||||||
|
|
||||||
# Value describes a DAG-JSON compatible value.
|
# Value of a given type.
|
||||||
union Value =
|
type Value {
|
||||||
BooleanValue
|
null: Boolean
|
||||||
| IntValue
|
|
||||||
| FloatValue
|
|
||||||
| StringValue
|
|
||||||
| BytesValue
|
|
||||||
| LinkValue
|
|
||||||
| ArrayValue
|
|
||||||
| MapValue
|
|
||||||
|
|
||||||
type BooleanValue {
|
|
||||||
value: Boolean!
|
|
||||||
}
|
|
||||||
|
|
||||||
type IntValue {
|
|
||||||
value: Int!
|
|
||||||
}
|
|
||||||
|
|
||||||
type FloatValue {
|
|
||||||
value: Float!
|
|
||||||
}
|
|
||||||
|
|
||||||
type StringValue {
|
|
||||||
value: String!
|
|
||||||
}
|
|
||||||
|
|
||||||
type BytesValue {
|
|
||||||
value: String!
|
|
||||||
}
|
|
||||||
|
|
||||||
type ArrayValue {
|
|
||||||
value: [Value]!
|
|
||||||
}
|
|
||||||
|
|
||||||
type LinkValue {
|
|
||||||
value: Link!
|
|
||||||
}
|
|
||||||
|
|
||||||
type MapValue {
|
|
||||||
value: [Attribute!]!
|
|
||||||
}
|
|
||||||
|
|
||||||
# Key/value pair.
|
|
||||||
type Attribute {
|
|
||||||
key: String!
|
|
||||||
value: Value
|
|
||||||
}
|
|
||||||
|
|
||||||
# Value of a given type used as input to queries.
|
|
||||||
# Note: GQL doesn't allow union input types.
|
|
||||||
input ValueInput {
|
|
||||||
int: Int
|
int: Int
|
||||||
float: Float
|
float: Float
|
||||||
string: String
|
string: String
|
||||||
boolean: Boolean
|
boolean: Boolean
|
||||||
link: Link
|
json: String
|
||||||
array: [ValueInput]
|
|
||||||
map: [KeyValueInput!]
|
reference: Reference
|
||||||
|
|
||||||
|
values: [Value]
|
||||||
|
}
|
||||||
|
# Value of a given type used as input to queries.
|
||||||
|
input ValueInput {
|
||||||
|
null: Boolean
|
||||||
|
|
||||||
|
int: Int
|
||||||
|
float: Float
|
||||||
|
string: String
|
||||||
|
boolean: Boolean
|
||||||
|
|
||||||
|
reference: ReferenceInput
|
||||||
|
|
||||||
|
values: [ValueInput]
|
||||||
|
}
|
||||||
|
|
||||||
|
# Key/value pair.
|
||||||
|
type KeyValue {
|
||||||
|
key: String!
|
||||||
|
value: Value!
|
||||||
}
|
}
|
||||||
|
|
||||||
# Key/value pair for inputs.
|
# Key/value pair for inputs.
|
||||||
input KeyValueInput {
|
input KeyValueInput {
|
||||||
key: String!
|
key: String!
|
||||||
value: ValueInput
|
value: ValueInput!
|
||||||
}
|
}
|
||||||
|
|
||||||
# Status information about a node (https://docs.tendermint.com/master/rpc/#/Info/status).
|
# Status information about a node (https://docs.tendermint.com/master/rpc/#/Info/status).
|
||||||
@ -175,7 +155,7 @@ type Record {
|
|||||||
createTime: String! # Record create time.
|
createTime: String! # Record create time.
|
||||||
expiryTime: String! # Record expiry time.
|
expiryTime: String! # Record expiry time.
|
||||||
owners: [String!] # Addresses of record owners.
|
owners: [String!] # Addresses of record owners.
|
||||||
attributes: [Attribute!] # Record attributes.
|
attributes: [KeyValue] # Record attributes.
|
||||||
references: [Record] # Record references.
|
references: [Record] # Record references.
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,7 +195,7 @@ type Query {
|
|||||||
getBondsByIds(ids: [String!]): [Bond]
|
getBondsByIds(ids: [String!]): [Bond]
|
||||||
|
|
||||||
# Query bonds.
|
# Query bonds.
|
||||||
queryBonds(attributes: [KeyValueInput!]): [Bond]
|
queryBonds(attributes: [KeyValueInput]): [Bond]
|
||||||
|
|
||||||
# Query bonds by owner.
|
# Query bonds by owner.
|
||||||
queryBondsByOwner(ownerAddresses: [String!]): [OwnerBonds]
|
queryBondsByOwner(ownerAddresses: [String!]): [OwnerBonds]
|
||||||
@ -230,7 +210,7 @@ type Query {
|
|||||||
# Query records.
|
# Query records.
|
||||||
queryRecords(
|
queryRecords(
|
||||||
# Multiple attribute conditions are in a logical AND.
|
# Multiple attribute conditions are in a logical AND.
|
||||||
attributes: [KeyValueInput!]
|
attributes: [KeyValueInput]
|
||||||
|
|
||||||
# Whether to query all records, not just named ones (false by default).
|
# Whether to query all records, not just named ones (false by default).
|
||||||
all: Boolean
|
all: Boolean
|
115
init.sh
115
init.sh
@ -5,25 +5,18 @@ CHAINID="laconic_9000-1"
|
|||||||
MONIKER="localtestnet"
|
MONIKER="localtestnet"
|
||||||
KEYRING="test"
|
KEYRING="test"
|
||||||
KEYALGO="eth_secp256k1"
|
KEYALGO="eth_secp256k1"
|
||||||
LOGLEVEL="${LOGLEVEL:-info}"
|
LOGLEVEL="info"
|
||||||
# trace evm
|
# trace evm
|
||||||
TRACE="--trace"
|
TRACE="--trace"
|
||||||
# TRACE=""
|
# TRACE=""
|
||||||
|
|
||||||
if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data/blockstore.db" ]; then
|
|
||||||
# validate dependencies are installed
|
# validate dependencies are installed
|
||||||
command -v jq > /dev/null 2>&1 || {
|
command -v jq > /dev/null 2>&1 || { echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"; exit 1; }
|
||||||
echo >&2 "jq not installed. More info: https://stedolan.github.io/jq/download/"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# remove existing daemon and client
|
# remove existing daemon and client
|
||||||
rm -rf $HOME/.laconicd/*
|
rm -rf ~/.laconic*
|
||||||
rm -rf $HOME/.laconic/*
|
|
||||||
|
|
||||||
if [ -n "`which make`" ]; then
|
|
||||||
make install
|
make install
|
||||||
fi
|
|
||||||
|
|
||||||
laconicd config keyring-backend $KEYRING
|
laconicd config keyring-backend $KEYRING
|
||||||
laconicd config chain-id $CHAINID
|
laconicd config chain-id $CHAINID
|
||||||
@ -34,46 +27,41 @@ if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data/blockstore.db" ]; then
|
|||||||
# Set moniker and chain-id for Ethermint (Moniker can be anything, chain-id must be an integer)
|
# Set moniker and chain-id for Ethermint (Moniker can be anything, chain-id must be an integer)
|
||||||
laconicd init $MONIKER --chain-id $CHAINID
|
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
|
# Change parameter token denominations to aphoton
|
||||||
update_genesis '.app_state["staking"]["params"]["bond_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
|
||||||
update_genesis '.app_state["crisis"]["constant_fee"]["denom"]="aphoton"'
|
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
|
||||||
update_genesis '.app_state["gov"]["deposit_params"]["min_deposit"][0]["denom"]="aphoton"'
|
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
|
||||||
update_genesis '.app_state["mint"]["params"]["mint_denom"]="aphoton"'
|
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
|
# Custom modules
|
||||||
update_genesis '.app_state["registry"]["params"]["record_rent"]["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
|
||||||
update_genesis '.app_state["registry"]["params"]["authority_rent"]["denom"]="aphoton"'
|
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
|
||||||
update_genesis '.app_state["registry"]["params"]["authority_auction_commit_fee"]["denom"]="aphoton"'
|
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
|
||||||
update_genesis '.app_state["registry"]["params"]["authority_auction_reveal_fee"]["denom"]="aphoton"'
|
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
|
||||||
update_genesis '.app_state["registry"]["params"]["authority_auction_minimum_bid"]["denom"]="aphoton"'
|
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
|
if [[ "$TEST_REGISTRY_EXPIRY" == "true" ]]; then
|
||||||
echo "Setting timers for expiry tests."
|
echo "Setting timers for expiry tests."
|
||||||
|
|
||||||
update_genesis '.app_state["registry"]["params"]["record_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
|
||||||
update_genesis '.app_state["registry"]["params"]["authority_grace_period"]="60s"'
|
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
|
||||||
update_genesis '.app_state["registry"]["params"]["authority_rent_duration"]="60s"'
|
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
|
fi
|
||||||
|
|
||||||
if [[ "$TEST_AUCTION_ENABLED" == "true" ]]; then
|
if [[ "$TEST_AUCTION_ENABLED" == "true" ]]; then
|
||||||
echo "Enabling auction and setting timers."
|
echo "Enabling auction and setting timers."
|
||||||
|
|
||||||
update_genesis '.app_state["registry"]["params"]["authority_auction_enabled"]=true'
|
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
|
||||||
update_genesis '.app_state["registry"]["params"]["authority_rent_duration"]="60s"'
|
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
|
||||||
update_genesis '.app_state["registry"]["params"]["authority_grace_period"]="300s"'
|
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
|
||||||
update_genesis '.app_state["registry"]["params"]["authority_auction_commits_duration"]="60s"'
|
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
|
||||||
update_genesis '.app_state["registry"]["params"]["authority_auction_reveals_duration"]="60s"'
|
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
|
fi
|
||||||
|
|
||||||
# increase block time (?)
|
# 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
|
# 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
|
# disable produce empty block
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||||
@ -82,33 +70,28 @@ if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data/blockstore.db" ]; then
|
|||||||
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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$1" == "pending" ]]; then
|
if [[ $1 == "pending" ]]; then
|
||||||
alias sed-i="sed -i"
|
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; 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
|
||||||
fi
|
sed -i '' 's/timeout_propose = "3s"/timeout_propose = "30s"/g' $HOME/.laconicd/config/config.toml
|
||||||
sed-i \
|
sed -i '' 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "5s"/g' $HOME/.laconicd/config/config.toml
|
||||||
-e 's/create_empty_blocks_interval = "0s"/create_empty_blocks_interval = "30s"/g' \
|
sed -i '' 's/timeout_prevote = "1s"/timeout_prevote = "10s"/g' $HOME/.laconicd/config/config.toml
|
||||||
-e 's/timeout_propose = "3s"/timeout_propose = "30s"/g' \
|
sed -i '' 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "5s"/g' $HOME/.laconicd/config/config.toml
|
||||||
-e 's/timeout_propose_delta = "500ms"/timeout_propose_delta = "5s"/g' \
|
sed -i '' 's/timeout_precommit = "1s"/timeout_precommit = "10s"/g' $HOME/.laconicd/config/config.toml
|
||||||
-e 's/timeout_prevote = "1s"/timeout_prevote = "10s"/g' \
|
sed -i '' 's/timeout_precommit_delta = "500ms"/timeout_precommit_delta = "5s"/g' $HOME/.laconicd/config/config.toml
|
||||||
-e 's/timeout_prevote_delta = "500ms"/timeout_prevote_delta = "5s"/g' \
|
sed -i '' 's/timeout_commit = "5s"/timeout_commit = "150s"/g' $HOME/.laconicd/config/config.toml
|
||||||
-e 's/timeout_precommit = "1s"/timeout_precommit = "10s"/g' \
|
sed -i '' 's/timeout_broadcast_tx_commit = "10s"/timeout_broadcast_tx_commit = "150s"/g' $HOME/.laconicd/config/config.toml
|
||||||
-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
|
|
||||||
|
|
||||||
# Enable telemetry (prometheus metrics: http://localhost:1317/metrics?format=prometheus)
|
|
||||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
|
||||||
sed -i '' 's/enabled = false/enabled = true/g' $HOME/.laconicd/config/app.toml
|
|
||||||
sed -i '' 's/prometheus-retention-time = 0/prometheus-retention-time = 60/g' $HOME/.laconicd/config/app.toml
|
|
||||||
sed -i '' 's/prometheus = false/prometheus = true/g' $HOME/.laconicd/config/config.toml
|
|
||||||
else
|
else
|
||||||
sed -i 's/enabled = false/enabled = true/g' $HOME/.laconicd/config/app.toml
|
sed -i 's/create_empty_blocks_interval = "0s"/create_empty_blocks_interval = "30s"/g' $HOME/.laconicd/config/config.toml
|
||||||
sed -i 's/prometheus-retention-time = 0/prometheus-retention-time = 60/g' $HOME/.laconicd/config/app.toml
|
sed -i 's/timeout_propose = "3s"/timeout_propose = "30s"/g' $HOME/.laconicd/config/config.toml
|
||||||
sed -i 's/prometheus = false/prometheus = true/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
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Allocate genesis accounts (cosmos formatted addresses)
|
# Allocate genesis accounts (cosmos formatted addresses)
|
||||||
@ -123,19 +106,9 @@ if [ "$1" == "clean" ] || [ ! -d "$HOME/.laconicd/data/blockstore.db" ]; then
|
|||||||
# Run this to ensure everything worked and that the genesis file is setup correctly
|
# Run this to ensure everything worked and that the genesis file is setup correctly
|
||||||
laconicd validate-genesis
|
laconicd validate-genesis
|
||||||
|
|
||||||
if [[ "$1" == "pending" ]]; then
|
if [[ $1 == "pending" ]]; then
|
||||||
echo "pending mode is on, please wait for the first block committed."
|
echo "pending mode is on, please wait for the first block committed."
|
||||||
fi
|
fi
|
||||||
else
|
|
||||||
echo "Using existing database at $HOME/.laconicd. To replace, run '`basename $0` clean'"
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
|
# Start the node (remove the --pruning=nothing flag if historical queries are not needed)
|
||||||
laconicd start \
|
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
|
||||||
--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
|
|
||||||
|
@ -67,26 +67,17 @@ message QueryParamsResponse {
|
|||||||
|
|
||||||
// QueryListRecordsRequest is request type for registry records list
|
// QueryListRecordsRequest is request type for registry records list
|
||||||
message QueryListRecordsRequest {
|
message QueryListRecordsRequest {
|
||||||
message LinkInput {
|
message ReferenceInput {
|
||||||
string id = 1;
|
string id = 1;
|
||||||
}
|
}
|
||||||
message ArrayInput {
|
|
||||||
repeated ValueInput values = 1;
|
|
||||||
}
|
|
||||||
message MapInput {
|
|
||||||
map<string, ValueInput> values = 1;
|
|
||||||
}
|
|
||||||
message ValueInput {
|
message ValueInput {
|
||||||
// Type of record attribute value
|
string type = 1;
|
||||||
oneof value {
|
string string = 2;
|
||||||
string string = 1;
|
int64 int = 3;
|
||||||
int64 int = 2;
|
double float = 4;
|
||||||
double float = 3;
|
bool boolean = 5;
|
||||||
bool boolean = 4;
|
ReferenceInput reference = 6;
|
||||||
string link = 5;
|
repeated ValueInput values = 7;
|
||||||
ArrayInput array = 6;
|
|
||||||
MapInput map = 7;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
message KeyValueInput {
|
message KeyValueInput {
|
||||||
string key = 1;
|
string key = 1;
|
||||||
|
@ -5,6 +5,7 @@ import "google/protobuf/duration.proto";
|
|||||||
import "google/protobuf/timestamp.proto";
|
import "google/protobuf/timestamp.proto";
|
||||||
import "gogoproto/gogo.proto";
|
import "gogoproto/gogo.proto";
|
||||||
import "cosmos/base/v1beta1/coin.proto";
|
import "cosmos/base/v1beta1/coin.proto";
|
||||||
|
import "google/protobuf/any.proto";
|
||||||
|
|
||||||
option go_package = "github.com/cerc-io/laconicd/x/registry/types";
|
option go_package = "github.com/cerc-io/laconicd/x/registry/types";
|
||||||
|
|
||||||
@ -55,7 +56,7 @@ message Params {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Record defines a registry record
|
// Params defines the registry module records
|
||||||
message Record {
|
message Record {
|
||||||
string id = 1 [(gogoproto.moretags) = "json:\"id\" yaml:\"id\""];
|
string id = 1 [(gogoproto.moretags) = "json:\"id\" yaml:\"id\""];
|
||||||
string bond_id = 2 [(gogoproto.moretags) = "json:\"bondId\" yaml:\"bondId\""];
|
string bond_id = 2 [(gogoproto.moretags) = "json:\"bondId\" yaml:\"bondId\""];
|
||||||
@ -68,7 +69,7 @@ message Record {
|
|||||||
string type = 9 [(gogoproto.moretags) = "json:\"types\" yaml:\"types\""];
|
string type = 9 [(gogoproto.moretags) = "json:\"types\" yaml:\"types\""];
|
||||||
}
|
}
|
||||||
|
|
||||||
// AuthorityEntry defines a registry authority
|
// AuthorityEntry defines the registry module AuthorityEntries
|
||||||
message AuthorityEntry {
|
message AuthorityEntry {
|
||||||
string name = 1;
|
string name = 1;
|
||||||
NameAuthority entry = 2;
|
NameAuthority entry = 2;
|
||||||
@ -98,7 +99,7 @@ message NameEntry {
|
|||||||
NameRecord entry = 2;
|
NameRecord entry = 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
// NameRecord defines a versioned name record
|
// NameRecord
|
||||||
message NameRecord {
|
message NameRecord {
|
||||||
NameRecordEntry latest = 1;
|
NameRecordEntry latest = 1;
|
||||||
repeated NameRecordEntry history = 2;
|
repeated NameRecordEntry history = 2;
|
||||||
|
@ -94,10 +94,11 @@ func (s *websocketsServer) Start() {
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
var err error
|
var err error
|
||||||
|
/* #nosec G114 -- http functions have no support for timeouts */
|
||||||
if s.certFile == "" || s.keyFile == "" {
|
if s.certFile == "" || s.keyFile == "" {
|
||||||
err = http.ListenAndServe(s.wsAddr, ws) /* #nosec G114 -- http functions have no support for timeouts */
|
err = http.ListenAndServe(s.wsAddr, ws)
|
||||||
} else {
|
} else {
|
||||||
err = http.ListenAndServeTLS(s.wsAddr, s.certFile, s.keyFile, ws) // #nosec G114
|
err = http.ListenAndServeTLS(s.wsAddr, s.certFile, s.keyFile, ws)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -1,48 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
|
|
||||||
##
|
|
||||||
## This script generates a new account keypair, transfers funds to it, and creates
|
|
||||||
## a bond with those funds. The amount of can be optionally specified, else a
|
|
||||||
## default value estimated to be sufficient for about 5000 records.
|
|
||||||
##
|
|
||||||
## The `laconic` CLI and a valid config file for it are required. The default location
|
|
||||||
## for the config file is `~/.laconic/config.yml`, but this can be controlled with
|
|
||||||
## the environment variable LACONIC_CONFIG. A `userKey` for a source account with
|
|
||||||
## sufficient funds available must be present in this file for the funds transfer
|
|
||||||
## to succeed.
|
|
||||||
##
|
|
||||||
## Example:
|
|
||||||
##
|
|
||||||
## $ scripts/create-and-fund-account.sh 1000000000
|
|
||||||
## {
|
|
||||||
## "name": "68334d7175fd4f86befa4902657e5270",
|
|
||||||
## "type": "local",
|
|
||||||
## "address": "ethm15r5x94km0swq55aszwd7hnr9wksq7wmr38xes7",
|
|
||||||
## "pubkey": "AuKqlSldJJXj4gYMFt2HeX9DJ3aUosYA7n6zBz9Tg7/i",
|
|
||||||
## "mnemonic": "umbrella bean special unaware accident giant distance mix ghost feel possible cost road grant endless man maple derive rebuild learn mask water attract resist",
|
|
||||||
## "bond": "3d3a73f09115d289d330781455e6eac217305dc4a20e19bde808011fe3775a93",
|
|
||||||
## "balance": 1000000000,
|
|
||||||
## "privkey": "480880fde7aff1461da584b436cb3a84692413c84623fda78e127bb4e704ce76"
|
|
||||||
## }
|
|
||||||
##
|
|
||||||
|
|
||||||
AVG_RECORD_PHOTON=1000000
|
|
||||||
NUM_RECORDS=5000
|
|
||||||
BOND_OVERHEAD=200000
|
|
||||||
KEYNAME=`uuidgen | tr -d '-'`
|
|
||||||
KEYRING_DIR=`mktemp -d`
|
|
||||||
KEYRING=test
|
|
||||||
LACONIC_CONFIG=${LACONIC_CONFIG:-$HOME/.laconic/config.yml}
|
|
||||||
BOND_AMOUNT=${1:-$((AVG_RECORD_PHOTON * NUM_RECORDS))}
|
|
||||||
|
|
||||||
ACCOUNT_JSON=$(laconicd keys add $KEYNAME --keyring-backend $KEYRING --algo eth_secp256k1 --keyring-dir $KEYRING_DIR --output json)
|
|
||||||
PRIVATE_KEY=$(yes | laconicd keys export $KEYNAME --keyring-backend $KEYRING --keyring-dir $KEYRING_DIR --unarmored-hex --unsafe)
|
|
||||||
PUB_KEY=$(echo $ACCOUNT_JSON | jq -r ".pubkey | fromjson | .key")
|
|
||||||
|
|
||||||
laconicd keys delete $KEYNAME --keyring-backend $KEYRING --keyring-dir $KEYRING_DIR -y 2> /dev/null
|
|
||||||
rm -rf $KEYRING_DIR
|
|
||||||
|
|
||||||
laconic -c $LACONIC_CONFIG cns tokens send --address $(echo $ACCOUNT_JSON | jq -r '.address') --type aphoton --quantity $((BOND_AMOUNT + BOND_OVERHEAD)) > /dev/null
|
|
||||||
BOND_ID=$(laconic -c $LACONIC_CONFIG cns bond create --user-key $PRIVATE_KEY --type aphoton --quantity $BOND_AMOUNT | jq -r '.bondId')
|
|
||||||
|
|
||||||
echo $ACCOUNT_JSON | jq ".bond = \"$BOND_ID\"" | jq ".balance = $BOND_AMOUNT" | jq ".privkey = \"$PRIVATE_KEY\"" | jq ".pubkey = \"$PUB_KEY\""
|
|
@ -146,7 +146,7 @@ echo "done sleeping"
|
|||||||
set +e
|
set +e
|
||||||
|
|
||||||
if [[ -z $TEST || $TEST == "rpc" || $TEST == "pending" ]]; then
|
if [[ -z $TEST || $TEST == "rpc" || $TEST == "pending" ]]; then
|
||||||
time_out=900s
|
time_out=300s
|
||||||
if [[ $TEST == "pending" ]]; then
|
if [[ $TEST == "pending" ]]; then
|
||||||
time_out=60m0s
|
time_out=60m0s
|
||||||
fi
|
fi
|
||||||
|
52
tests/sdk_tests/Dockerfile-sdk
Normal file
52
tests/sdk_tests/Dockerfile-sdk
Normal file
@ -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
|
#!/usr/bin/env bash
|
||||||
docker build -t cerc/laconicd:local ../.. --progress=plain
|
docker build -t cerc-io/laconicd:local-test ../../
|
||||||
|
|
||||||
|
3
tests/sdk_tests/build-sdk-test-container.sh
Executable file
3
tests/sdk_tests/build-sdk-test-container.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
docker build -t cerc-io/laconic-sdk-tester:local-test -f Dockerfile-sdk .
|
||||||
|
|
31
tests/sdk_tests/docker-compose-auctions.yml
Normal file
31
tests/sdk_tests/docker-compose-auctions.yml
Normal file
@ -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
|
31
tests/sdk_tests/docker-compose-nameservice.yml
Normal file
31
tests/sdk_tests/docker-compose-nameservice.yml
Normal file
@ -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,12 +1,8 @@
|
|||||||
services:
|
services:
|
||||||
laconicd:
|
laconicd:
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
image: cerc/laconicd:local
|
image: cerc-io/laconicd:local-test
|
||||||
entrypoint: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
|
command: ["sh", "/docker-entrypoint-scripts.d/create-fixturenet.sh"]
|
||||||
environment:
|
|
||||||
- TEST_AUCTION_ENABLED
|
|
||||||
- TEST_REGISTRY_EXPIRY
|
|
||||||
- LOGLEVEL
|
|
||||||
volumes:
|
volumes:
|
||||||
- ../../init.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh
|
- ../../init.sh:/docker-entrypoint-scripts.d/create-fixturenet.sh
|
||||||
healthcheck:
|
healthcheck:
|
||||||
@ -26,7 +22,7 @@ services:
|
|||||||
- "1317"
|
- "1317"
|
||||||
|
|
||||||
sdk-test-runner:
|
sdk-test-runner:
|
||||||
image: cerc/laconic-sdk-tester:local
|
image: cerc-io/laconic-sdk-tester:local-test
|
||||||
depends_on:
|
depends_on:
|
||||||
laconicd:
|
laconicd:
|
||||||
condition: service_healthy
|
condition: service_healthy
|
||||||
|
3
tests/sdk_tests/entrypoint.sh
Executable file
3
tests/sdk_tests/entrypoint.sh
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
exec "$@"
|
||||||
|
|
16
tests/sdk_tests/run-auction-tests.sh
Executable file
16
tests/sdk_tests/run-auction-tests.sh
Executable file
@ -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
tests/sdk_tests/run-nameservice-expiry-tests.sh
Executable file
16
tests/sdk_tests/run-nameservice-expiry-tests.sh
Executable file
@ -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,28 +1,18 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# Forwards all args to yarn on the sdk-test-runner container
|
|
||||||
|
|
||||||
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
if [ -n "$CERC_SCRIPT_DEBUG" ]; then
|
||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
yarn_args=("--inspect-brk=8888")
|
|
||||||
yarn_args+=("${@:-test}")
|
|
||||||
|
|
||||||
# Get the key from laconicd
|
# Get the key from laconicd
|
||||||
laconicd_key=$(
|
laconicd_key=$( docker compose exec laconicd echo y | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe )
|
||||||
yes | docker compose exec laconicd laconicd keys export mykey --unarmored-hex --unsafe
|
|
||||||
)
|
|
||||||
# Set parameters for the test suite
|
# Set parameters for the test suite
|
||||||
cosmos_chain_id=laconic_9000-1
|
cosmos_chain_id=laconic_9000-1
|
||||||
laconicd_rest_endpoint=http://laconicd:1317
|
laconicd_rest_endpoint=http://laconicd:1317
|
||||||
laconicd_gql_endpoint=http://laconicd:9473/api
|
laconicd_gql_endpoint=http://laconicd:9473/api
|
||||||
|
|
||||||
docker compose exec laconicd sh -c "curl --retry 10 --retry-delay 3 --retry-connrefused http://127.0.0.1:9473/api"
|
|
||||||
|
|
||||||
# Run tests
|
# Run tests
|
||||||
docker compose exec \
|
docker network inspect sdk_tests_default
|
||||||
-e COSMOS_CHAIN_ID="$cosmos_chain_id" \
|
sleep 30s
|
||||||
-e LACONICD_REST_ENDPOINT="$laconicd_rest_endpoint" \
|
docker logs laconicd
|
||||||
-e LACONICD_GQL_ENDPOINT="$laconicd_gql_endpoint" \
|
docker compose exec laconicd sh -c "curl http://127.0.0.1:9473/api"
|
||||||
-e PRIVATE_KEY="$laconicd_key" \
|
docker compose exec laconicd sh -c "curl http://localhost:9473/api"
|
||||||
sdk-test-runner yarn run "${yarn_args[@]}"
|
|
||||||
|
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...")
|
l.Log("starting test network...")
|
||||||
for _, v := range network.Validators {
|
for _, v := range network.Validators {
|
||||||
l.Log("starting validator:", v.Moniker)
|
|
||||||
err := startInProcess(cfg, v)
|
err := startInProcess(cfg, v)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -1,20 +0,0 @@
|
|||||||
package utils
|
|
||||||
|
|
||||||
import (
|
|
||||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
)
|
|
||||||
|
|
||||||
func CtxWithCustomKVGasConfig(ctx *sdk.Context) *sdk.Context {
|
|
||||||
updatedCtx := ctx.WithKVGasConfig(storetypes.GasConfig{
|
|
||||||
HasCost: 0,
|
|
||||||
DeleteCost: 0,
|
|
||||||
ReadCostFlat: 0,
|
|
||||||
ReadCostPerByte: 0,
|
|
||||||
WriteCostFlat: 0,
|
|
||||||
WriteCostPerByte: 0,
|
|
||||||
IterNextCostFlat: 0,
|
|
||||||
})
|
|
||||||
|
|
||||||
return &updatedCtx
|
|
||||||
}
|
|
@ -15,7 +15,6 @@ import (
|
|||||||
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||||
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||||
params "github.com/cosmos/cosmos-sdk/x/params/types"
|
params "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
|
||||||
|
|
||||||
wnsUtils "github.com/cerc-io/laconicd/utils"
|
wnsUtils "github.com/cerc-io/laconicd/utils"
|
||||||
)
|
)
|
||||||
@ -79,11 +78,6 @@ func NewKeeper(accountKeeper auth.AccountKeeper,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logger returns a module-specific logger.
|
|
||||||
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
|
||||||
return ctx.Logger().With("module", types.ModuleName)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (k *Keeper) SetUsageKeepers(usageKeepers []types.AuctionUsageKeeper) {
|
func (k *Keeper) SetUsageKeepers(usageKeepers []types.AuctionUsageKeeper) {
|
||||||
k.usageKeepers = usageKeepers
|
k.usageKeepers = usageKeepers
|
||||||
}
|
}
|
||||||
|
@ -2,11 +2,9 @@ package keeper
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
|
|
||||||
"github.com/cerc-io/laconicd/utils"
|
|
||||||
"github.com/cerc-io/laconicd/x/auction/types"
|
"github.com/cerc-io/laconicd/x/auction/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -22,7 +20,6 @@ var _ types.MsgServer = msgServer{}
|
|||||||
|
|
||||||
func (s msgServer) CreateAuction(c context.Context, msg *types.MsgCreateAuction) (*types.MsgCreateAuctionResponse, error) {
|
func (s msgServer) CreateAuction(c context.Context, msg *types.MsgCreateAuction) (*types.MsgCreateAuctionResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
|
||||||
|
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -49,15 +46,13 @@ func (s msgServer) CreateAuction(c context.Context, msg *types.MsgCreateAuction)
|
|||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
s.logTxGasConsumed(ctx, "CreateAuction")
|
|
||||||
|
|
||||||
return &types.MsgCreateAuctionResponse{Auction: resp}, nil
|
return &types.MsgCreateAuctionResponse{Auction: resp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CommitBid is the command for committing a bid
|
// CommitBid is the command for committing a bid
|
||||||
|
//nolint: all
|
||||||
func (s msgServer) CommitBid(c context.Context, msg *types.MsgCommitBid) (*types.MsgCommitBidResponse, error) {
|
func (s msgServer) CommitBid(c context.Context, msg *types.MsgCommitBid) (*types.MsgCommitBidResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
|
||||||
|
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -82,15 +77,13 @@ func (s msgServer) CommitBid(c context.Context, msg *types.MsgCommitBid) (*types
|
|||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
s.logTxGasConsumed(ctx, "CommitBid")
|
|
||||||
|
|
||||||
return &types.MsgCommitBidResponse{Bid: resp}, nil
|
return &types.MsgCommitBidResponse{Bid: resp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
//RevealBid is the command for revealing a bid
|
//RevealBid is the command for revealing a bid
|
||||||
|
//nolint: all
|
||||||
func (s msgServer) RevealBid(c context.Context, msg *types.MsgRevealBid) (*types.MsgRevealBidResponse, error) {
|
func (s msgServer) RevealBid(c context.Context, msg *types.MsgRevealBid) (*types.MsgRevealBidResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
|
||||||
|
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -115,12 +108,5 @@ func (s msgServer) RevealBid(c context.Context, msg *types.MsgRevealBid) (*types
|
|||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
s.logTxGasConsumed(ctx, "RevealBid")
|
|
||||||
|
|
||||||
return &types.MsgRevealBidResponse{Auction: resp}, nil
|
return &types.MsgRevealBidResponse{Auction: resp}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s msgServer) logTxGasConsumed(ctx sdk.Context, tx string) {
|
|
||||||
gasConsumed := ctx.GasMeter().GasConsumed()
|
|
||||||
s.Keeper.Logger(ctx).Info("tx executed", "method", tx, "gas_consumed", fmt.Sprintf("%d", gasConsumed))
|
|
||||||
}
|
|
||||||
|
337
x/auction/types/tx.pb.gw.go
generated
337
x/auction/types/tx.pb.gw.go
generated
@ -1,337 +0,0 @@
|
|||||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
|
||||||
// source: vulcanize/auction/v1beta1/tx.proto
|
|
||||||
|
|
||||||
/*
|
|
||||||
Package types is a reverse proxy.
|
|
||||||
|
|
||||||
It translates gRPC into RESTful JSON APIs.
|
|
||||||
*/
|
|
||||||
package types
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/golang/protobuf/descriptor"
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
|
||||||
"github.com/grpc-ecosystem/grpc-gateway/utilities"
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
"google.golang.org/grpc/codes"
|
|
||||||
"google.golang.org/grpc/grpclog"
|
|
||||||
"google.golang.org/grpc/metadata"
|
|
||||||
"google.golang.org/grpc/status"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Suppress "imported and not used" errors
|
|
||||||
var _ codes.Code
|
|
||||||
var _ io.Reader
|
|
||||||
var _ status.Status
|
|
||||||
var _ = runtime.String
|
|
||||||
var _ = utilities.NewDoubleArray
|
|
||||||
var _ = descriptor.ForMessage
|
|
||||||
var _ = metadata.Join
|
|
||||||
|
|
||||||
var (
|
|
||||||
filter_Msg_CreateAuction_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
|
||||||
)
|
|
||||||
|
|
||||||
func request_Msg_CreateAuction_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgCreateAuction
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_CreateAuction_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := client.CreateAuction(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func local_request_Msg_CreateAuction_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgCreateAuction
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_CreateAuction_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.CreateAuction(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
filter_Msg_CommitBid_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
|
||||||
)
|
|
||||||
|
|
||||||
func request_Msg_CommitBid_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgCommitBid
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_CommitBid_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := client.CommitBid(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func local_request_Msg_CommitBid_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgCommitBid
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_CommitBid_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.CommitBid(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
filter_Msg_RevealBid_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
|
||||||
)
|
|
||||||
|
|
||||||
func request_Msg_RevealBid_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgRevealBid
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_RevealBid_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := client.RevealBid(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func local_request_Msg_RevealBid_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgRevealBid
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_RevealBid_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.RevealBid(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux".
|
|
||||||
// UnaryRPC :call MsgServer directly.
|
|
||||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
|
||||||
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead.
|
|
||||||
func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error {
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_CreateAuction_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
var stream runtime.ServerTransportStream
|
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := local_request_Msg_CreateAuction_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_CreateAuction_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_CommitBid_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
var stream runtime.ServerTransportStream
|
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := local_request_Msg_CommitBid_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_CommitBid_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_RevealBid_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
var stream runtime.ServerTransportStream
|
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := local_request_Msg_RevealBid_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_RevealBid_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but
|
|
||||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
|
||||||
func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
|
||||||
conn, err := grpc.Dial(endpoint, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err != nil {
|
|
||||||
if cerr := conn.Close(); cerr != nil {
|
|
||||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
go func() {
|
|
||||||
<-ctx.Done()
|
|
||||||
if cerr := conn.Close(); cerr != nil {
|
|
||||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}()
|
|
||||||
|
|
||||||
return RegisterMsgHandler(ctx, mux, conn)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterMsgHandler registers the http handlers for service Msg to "mux".
|
|
||||||
// The handlers forward requests to the grpc endpoint over "conn".
|
|
||||||
func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
|
||||||
return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn))
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterMsgHandlerClient registers the http handlers for service Msg
|
|
||||||
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient".
|
|
||||||
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient"
|
|
||||||
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
|
||||||
// "MsgClient" to call the correct interceptors.
|
|
||||||
func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error {
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_CreateAuction_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := request_Msg_CreateAuction_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_CreateAuction_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_CommitBid_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := request_Msg_CommitBid_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_CommitBid_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_RevealBid_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := request_Msg_RevealBid_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_RevealBid_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
pattern_Msg_CreateAuction_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "auction", "v1beta1", "create_auction"}, "", runtime.AssumeColonVerbOpt(false)))
|
|
||||||
|
|
||||||
pattern_Msg_CommitBid_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "auction", "v1beta1", "commit_bid"}, "", runtime.AssumeColonVerbOpt(false)))
|
|
||||||
|
|
||||||
pattern_Msg_RevealBid_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "auction", "v1beta1", "reveal_bid"}, "", runtime.AssumeColonVerbOpt(false)))
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
forward_Msg_CreateAuction_0 = runtime.ForwardResponseMessage
|
|
||||||
|
|
||||||
forward_Msg_CommitBid_0 = runtime.ForwardResponseMessage
|
|
||||||
|
|
||||||
forward_Msg_RevealBid_0 = runtime.ForwardResponseMessage
|
|
||||||
)
|
|
@ -14,7 +14,6 @@ import (
|
|||||||
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||||
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// prefixIDToBondIndex is the prefix for ID -> Bond index in the KVStore.
|
// prefixIDToBondIndex is the prefix for ID -> Bond index in the KVStore.
|
||||||
@ -63,11 +62,6 @@ func NewKeeper(cdc codec.BinaryCodec,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logger returns a module-specific logger.
|
|
||||||
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
|
||||||
return ctx.Logger().With("module", types.ModuleName)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Generates Bond ID -> Bond index key.
|
// Generates Bond ID -> Bond index key.
|
||||||
func getBondIndexKey(id string) []byte {
|
func getBondIndexKey(id string) []byte {
|
||||||
return append(prefixIDToBondIndex, []byte(id)...)
|
return append(prefixIDToBondIndex, []byte(id)...)
|
||||||
|
@ -2,12 +2,9 @@ package keeper
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
|
|
||||||
"github.com/cerc-io/laconicd/utils"
|
|
||||||
"github.com/cerc-io/laconicd/x/bond/types"
|
"github.com/cerc-io/laconicd/x/bond/types"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type msgServer struct {
|
type msgServer struct {
|
||||||
@ -23,8 +20,6 @@ var _ types.MsgServer = msgServer{}
|
|||||||
|
|
||||||
func (k msgServer) CreateBond(c context.Context, msg *types.MsgCreateBond) (*types.MsgCreateBondResponse, error) {
|
func (k msgServer) CreateBond(c context.Context, msg *types.MsgCreateBond) (*types.MsgCreateBondResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
|
||||||
|
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -47,15 +42,12 @@ func (k msgServer) CreateBond(c context.Context, msg *types.MsgCreateBond) (*typ
|
|||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
k.logTxGasConsumed(ctx, "CreateBond")
|
|
||||||
|
|
||||||
return &types.MsgCreateBondResponse{}, nil
|
return &types.MsgCreateBondResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint: all
|
||||||
func (k msgServer) RefillBond(c context.Context, msg *types.MsgRefillBond) (*types.MsgRefillBondResponse, error) {
|
func (k msgServer) RefillBond(c context.Context, msg *types.MsgRefillBond) (*types.MsgRefillBondResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
|
||||||
|
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -80,15 +72,12 @@ func (k msgServer) RefillBond(c context.Context, msg *types.MsgRefillBond) (*typ
|
|||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
k.logTxGasConsumed(ctx, "RefillBond")
|
|
||||||
|
|
||||||
return &types.MsgRefillBondResponse{}, nil
|
return &types.MsgRefillBondResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint: all
|
||||||
func (k msgServer) WithdrawBond(c context.Context, msg *types.MsgWithdrawBond) (*types.MsgWithdrawBondResponse, error) {
|
func (k msgServer) WithdrawBond(c context.Context, msg *types.MsgWithdrawBond) (*types.MsgWithdrawBondResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
|
||||||
|
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -113,15 +102,11 @@ func (k msgServer) WithdrawBond(c context.Context, msg *types.MsgWithdrawBond) (
|
|||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
k.logTxGasConsumed(ctx, "WithdrawBond")
|
|
||||||
|
|
||||||
return &types.MsgWithdrawBondResponse{}, nil
|
return &types.MsgWithdrawBondResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k msgServer) CancelBond(c context.Context, msg *types.MsgCancelBond) (*types.MsgCancelBondResponse, error) {
|
func (k msgServer) CancelBond(c context.Context, msg *types.MsgCancelBond) (*types.MsgCancelBondResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
|
||||||
|
|
||||||
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
signerAddress, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -144,12 +129,5 @@ func (k msgServer) CancelBond(c context.Context, msg *types.MsgCancelBond) (*typ
|
|||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
k.logTxGasConsumed(ctx, "CancelBond")
|
|
||||||
|
|
||||||
return &types.MsgCancelBondResponse{}, nil
|
return &types.MsgCancelBondResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k msgServer) logTxGasConsumed(ctx sdk.Context, tx string) {
|
|
||||||
gasConsumed := ctx.GasMeter().GasConsumed()
|
|
||||||
k.Keeper.Logger(ctx).Info("tx executed", "method", tx, "gas_consumed", fmt.Sprintf("%d", gasConsumed))
|
|
||||||
}
|
|
||||||
|
420
x/bond/types/tx.pb.gw.go
generated
420
x/bond/types/tx.pb.gw.go
generated
@ -1,420 +0,0 @@
|
|||||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
|
||||||
// source: vulcanize/bond/v1beta1/tx.proto
|
|
||||||
|
|
||||||
/*
|
|
||||||
Package types is a reverse proxy.
|
|
||||||
|
|
||||||
It translates gRPC into RESTful JSON APIs.
|
|
||||||
*/
|
|
||||||
package types
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/golang/protobuf/descriptor"
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
|
||||||
"github.com/grpc-ecosystem/grpc-gateway/utilities"
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
"google.golang.org/grpc/codes"
|
|
||||||
"google.golang.org/grpc/grpclog"
|
|
||||||
"google.golang.org/grpc/metadata"
|
|
||||||
"google.golang.org/grpc/status"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Suppress "imported and not used" errors
|
|
||||||
var _ codes.Code
|
|
||||||
var _ io.Reader
|
|
||||||
var _ status.Status
|
|
||||||
var _ = runtime.String
|
|
||||||
var _ = utilities.NewDoubleArray
|
|
||||||
var _ = descriptor.ForMessage
|
|
||||||
var _ = metadata.Join
|
|
||||||
|
|
||||||
var (
|
|
||||||
filter_Msg_CreateBond_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
|
||||||
)
|
|
||||||
|
|
||||||
func request_Msg_CreateBond_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgCreateBond
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_CreateBond_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := client.CreateBond(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func local_request_Msg_CreateBond_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgCreateBond
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_CreateBond_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.CreateBond(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
filter_Msg_RefillBond_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
|
||||||
)
|
|
||||||
|
|
||||||
func request_Msg_RefillBond_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgRefillBond
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_RefillBond_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := client.RefillBond(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func local_request_Msg_RefillBond_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgRefillBond
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_RefillBond_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.RefillBond(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
filter_Msg_WithdrawBond_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
|
||||||
)
|
|
||||||
|
|
||||||
func request_Msg_WithdrawBond_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgWithdrawBond
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_WithdrawBond_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := client.WithdrawBond(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func local_request_Msg_WithdrawBond_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgWithdrawBond
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_WithdrawBond_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.WithdrawBond(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
filter_Msg_CancelBond_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
|
||||||
)
|
|
||||||
|
|
||||||
func request_Msg_CancelBond_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgCancelBond
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_CancelBond_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := client.CancelBond(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func local_request_Msg_CancelBond_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgCancelBond
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_CancelBond_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.CancelBond(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux".
|
|
||||||
// UnaryRPC :call MsgServer directly.
|
|
||||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
|
||||||
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead.
|
|
||||||
func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error {
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_CreateBond_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
var stream runtime.ServerTransportStream
|
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := local_request_Msg_CreateBond_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_CreateBond_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_RefillBond_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
var stream runtime.ServerTransportStream
|
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := local_request_Msg_RefillBond_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_RefillBond_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_WithdrawBond_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
var stream runtime.ServerTransportStream
|
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := local_request_Msg_WithdrawBond_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_WithdrawBond_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_CancelBond_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
var stream runtime.ServerTransportStream
|
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := local_request_Msg_CancelBond_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_CancelBond_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but
|
|
||||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
|
||||||
func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
|
||||||
conn, err := grpc.Dial(endpoint, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err != nil {
|
|
||||||
if cerr := conn.Close(); cerr != nil {
|
|
||||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
go func() {
|
|
||||||
<-ctx.Done()
|
|
||||||
if cerr := conn.Close(); cerr != nil {
|
|
||||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}()
|
|
||||||
|
|
||||||
return RegisterMsgHandler(ctx, mux, conn)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterMsgHandler registers the http handlers for service Msg to "mux".
|
|
||||||
// The handlers forward requests to the grpc endpoint over "conn".
|
|
||||||
func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
|
||||||
return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn))
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterMsgHandlerClient registers the http handlers for service Msg
|
|
||||||
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient".
|
|
||||||
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient"
|
|
||||||
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
|
||||||
// "MsgClient" to call the correct interceptors.
|
|
||||||
func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error {
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_CreateBond_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := request_Msg_CreateBond_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_CreateBond_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_RefillBond_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := request_Msg_RefillBond_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_RefillBond_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_WithdrawBond_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := request_Msg_WithdrawBond_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_WithdrawBond_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_CancelBond_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := request_Msg_CancelBond_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_CancelBond_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
pattern_Msg_CreateBond_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "bond", "v1beta1", "create_bond"}, "", runtime.AssumeColonVerbOpt(false)))
|
|
||||||
|
|
||||||
pattern_Msg_RefillBond_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "bond", "v1beta1", "refill_bond"}, "", runtime.AssumeColonVerbOpt(false)))
|
|
||||||
|
|
||||||
pattern_Msg_WithdrawBond_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "bond", "v1beta1", "withdraw_bond"}, "", runtime.AssumeColonVerbOpt(false)))
|
|
||||||
|
|
||||||
pattern_Msg_CancelBond_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "bond", "v1beta1", "cancel_bond"}, "", runtime.AssumeColonVerbOpt(false)))
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
forward_Msg_CreateBond_0 = runtime.ForwardResponseMessage
|
|
||||||
|
|
||||||
forward_Msg_RefillBond_0 = runtime.ForwardResponseMessage
|
|
||||||
|
|
||||||
forward_Msg_WithdrawBond_0 = runtime.ForwardResponseMessage
|
|
||||||
|
|
||||||
forward_Msg_CancelBond_0 = runtime.ForwardResponseMessage
|
|
||||||
)
|
|
@ -32,10 +32,11 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// #nosec 101
|
||||||
const (
|
const (
|
||||||
OpWeightMsgEthSimpleTransfer = "op_weight_msg_eth_simple_transfer" // #nosec G101
|
OpWeightMsgEthSimpleTransfer = "op_weight_msg_eth_simple_transfer"
|
||||||
OpWeightMsgEthCreateContract = "op_weight_msg_eth_create_contract" // #nosec G101
|
OpWeightMsgEthCreateContract = "op_weight_msg_eth_create_contract"
|
||||||
OpWeightMsgEthCallContract = "op_weight_msg_eth_call_contract" // #nosec G101
|
OpWeightMsgEthCallContract = "op_weight_msg_eth_call_contract"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -15,8 +15,6 @@ import (
|
|||||||
tmcli "github.com/tendermint/tendermint/libs/cli"
|
tmcli "github.com/tendermint/tendermint/libs/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
const badPath = "/asdasd"
|
|
||||||
|
|
||||||
func (s *IntegrationTestSuite) TestGRPCQueryParams() {
|
func (s *IntegrationTestSuite) TestGRPCQueryParams() {
|
||||||
val := s.network.Validators[0]
|
val := s.network.Validators[0]
|
||||||
sr := s.Require()
|
sr := s.Require()
|
||||||
@ -30,7 +28,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryParams() {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid url",
|
"invalid url",
|
||||||
reqURL + badPath,
|
reqURL + "/asdasd",
|
||||||
true,
|
true,
|
||||||
"",
|
"",
|
||||||
},
|
},
|
||||||
@ -44,8 +42,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryParams() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
resp, err := rest.GetRequest(tc.url)
|
resp, _ := rest.GetRequest(tc.url)
|
||||||
s.NoError(err)
|
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
require.Contains(string(resp), tc.errorMsg)
|
require.Contains(string(resp), tc.errorMsg)
|
||||||
@ -78,7 +75,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryWhoIs() {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid url",
|
"invalid url",
|
||||||
reqUrl + badPath,
|
reqUrl + "/asdasd",
|
||||||
true,
|
true,
|
||||||
"",
|
"",
|
||||||
func(authorityName string) {
|
func(authorityName string) {
|
||||||
@ -113,11 +110,11 @@ func (s *IntegrationTestSuite) TestGRPCQueryWhoIs() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
|
if !tc.expectErr {
|
||||||
tc.preRun(authorityName)
|
tc.preRun(authorityName)
|
||||||
tc.url = fmt.Sprintf(tc.url, authorityName)
|
tc.url = fmt.Sprintf(tc.url, authorityName)
|
||||||
|
}
|
||||||
resp, err := rest.GetRequest(tc.url)
|
resp, _ := rest.GetRequest(tc.url)
|
||||||
s.NoError(err)
|
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
require.Contains(string(resp), tc.errorMsg)
|
require.Contains(string(resp), tc.errorMsg)
|
||||||
@ -134,7 +131,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryWhoIs() {
|
|||||||
func (s *IntegrationTestSuite) TestGRPCQueryLookup() {
|
func (s *IntegrationTestSuite) TestGRPCQueryLookup() {
|
||||||
val := s.network.Validators[0]
|
val := s.network.Validators[0]
|
||||||
sr := s.Require()
|
sr := s.Require()
|
||||||
reqURL := val.APIAddress + "/vulcanize/registry/v1beta1/lookup"
|
reqURL := val.APIAddress + "/vulcanize/registry/v1beta1/lookup?crn=%s"
|
||||||
authorityName := "QueryLookUp"
|
authorityName := "QueryLookUp"
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
@ -146,7 +143,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryLookup() {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid url",
|
"invalid url",
|
||||||
reqURL + badPath,
|
reqURL + "/asdasd",
|
||||||
true,
|
true,
|
||||||
"",
|
"",
|
||||||
func(authorityName string) {
|
func(authorityName string) {
|
||||||
@ -154,7 +151,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryLookup() {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Success",
|
"Success",
|
||||||
fmt.Sprintf(reqURL+"?crn=crn://%s/", authorityName),
|
reqURL,
|
||||||
false,
|
false,
|
||||||
"",
|
"",
|
||||||
func(authorityName string) {
|
func(authorityName string) {
|
||||||
@ -166,9 +163,11 @@ func (s *IntegrationTestSuite) TestGRPCQueryLookup() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
|
if !tc.expectErr {
|
||||||
tc.preRun(authorityName)
|
tc.preRun(authorityName)
|
||||||
resp, err := rest.GetRequest(tc.url)
|
tc.url = fmt.Sprintf(reqURL, fmt.Sprintf("crn://%s/", authorityName))
|
||||||
s.NoError(err)
|
}
|
||||||
|
resp, _ := rest.GetRequest(tc.url)
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
sr.Contains(string(resp), tc.errorMsg)
|
sr.Contains(string(resp), tc.errorMsg)
|
||||||
} else {
|
} else {
|
||||||
@ -196,7 +195,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid url",
|
"invalid url",
|
||||||
reqUrl + badPath,
|
reqUrl + "/asdasd",
|
||||||
true,
|
true,
|
||||||
"",
|
"",
|
||||||
func(bondId string) {
|
func(bondId string) {
|
||||||
@ -234,11 +233,12 @@ func (s *IntegrationTestSuite) TestGRPCQueryRecordExpiryQueue() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
|
if !tc.expectErr {
|
||||||
tc.preRun(s.bondID)
|
tc.preRun(s.bondID)
|
||||||
|
}
|
||||||
// wait 12 seconds for records expires
|
// wait 12 seconds for records expires
|
||||||
time.Sleep(time.Second * 12)
|
time.Sleep(time.Second * 12)
|
||||||
resp, err := rest.GetRequest(tc.url)
|
resp, _ := rest.GetRequest(tc.url)
|
||||||
s.NoError(err)
|
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
require.Contains(string(resp), tc.errorMsg)
|
require.Contains(string(resp), tc.errorMsg)
|
||||||
@ -267,7 +267,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid url",
|
"invalid url",
|
||||||
reqUrl + badPath,
|
reqUrl + "/asdasd",
|
||||||
true,
|
true,
|
||||||
"",
|
"",
|
||||||
func(authorityName string) {
|
func(authorityName string) {
|
||||||
@ -303,12 +303,13 @@ func (s *IntegrationTestSuite) TestGRPCQueryAuthorityExpiryQueue() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
|
if !tc.expectErr {
|
||||||
tc.preRun("QueryAuthorityExpiryQueue")
|
tc.preRun("QueryAuthorityExpiryQueue")
|
||||||
|
}
|
||||||
// wait 12 seconds to name authorites expires
|
// wait 12 seconds to name authorites expires
|
||||||
time.Sleep(time.Second * 12)
|
time.Sleep(time.Second * 12)
|
||||||
|
|
||||||
resp, err := rest.GetRequest(tc.url)
|
resp, _ := rest.GetRequest(tc.url)
|
||||||
s.NoError(err)
|
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
require.Contains(string(resp), tc.errorMsg)
|
require.Contains(string(resp), tc.errorMsg)
|
||||||
@ -338,7 +339,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryListRecords() {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid url",
|
"invalid url",
|
||||||
reqUrl + badPath,
|
reqUrl + "/asdasd",
|
||||||
true,
|
true,
|
||||||
"",
|
"",
|
||||||
func(bondId string) {
|
func(bondId string) {
|
||||||
@ -376,9 +377,10 @@ func (s *IntegrationTestSuite) TestGRPCQueryListRecords() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
|
if !tc.expectErr {
|
||||||
tc.preRun(s.bondID)
|
tc.preRun(s.bondID)
|
||||||
resp, err := rest.GetRequest(tc.url)
|
}
|
||||||
s.NoError(err)
|
resp, _ := rest.GetRequest(tc.url)
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
require.Contains(string(resp), tc.errorMsg)
|
require.Contains(string(resp), tc.errorMsg)
|
||||||
@ -407,7 +409,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryGetRecordByID() {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid url",
|
"invalid url",
|
||||||
reqURL + badPath,
|
reqURL + "/asdasd",
|
||||||
true,
|
true,
|
||||||
"",
|
"",
|
||||||
func(bondId string) string {
|
func(bondId string) string {
|
||||||
@ -441,11 +443,12 @@ func (s *IntegrationTestSuite) TestGRPCQueryGetRecordByID() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
recordID := tc.preRun(s.bondID)
|
var recordID string
|
||||||
|
if !tc.expectErr {
|
||||||
|
recordID = tc.preRun(s.bondID)
|
||||||
tc.url = fmt.Sprintf(reqURL, recordID)
|
tc.url = fmt.Sprintf(reqURL, recordID)
|
||||||
|
}
|
||||||
resp, err := rest.GetRequest(tc.url)
|
resp, _ := rest.GetRequest(tc.url)
|
||||||
s.NoError(err)
|
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
require.Contains(string(resp), tc.errorMsg)
|
require.Contains(string(resp), tc.errorMsg)
|
||||||
@ -475,7 +478,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryGetRecordByBondID() {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid url",
|
"invalid url",
|
||||||
reqURL + badPath,
|
reqURL + "/asdasd",
|
||||||
true,
|
true,
|
||||||
"",
|
"",
|
||||||
func(bondId string) {
|
func(bondId string) {
|
||||||
@ -495,11 +498,11 @@ func (s *IntegrationTestSuite) TestGRPCQueryGetRecordByBondID() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
|
if !tc.expectErr {
|
||||||
tc.preRun(s.bondID)
|
tc.preRun(s.bondID)
|
||||||
tc.url = fmt.Sprintf(reqURL, s.bondID)
|
tc.url = fmt.Sprintf(reqURL, s.bondID)
|
||||||
|
}
|
||||||
resp, err := rest.GetRequest(tc.url)
|
resp, _ := rest.GetRequest(tc.url)
|
||||||
s.NoError(err)
|
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
require.Contains(string(resp), tc.errorMsg)
|
require.Contains(string(resp), tc.errorMsg)
|
||||||
@ -529,7 +532,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryGetRegistryModuleBalance() {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid url",
|
"invalid url",
|
||||||
reqURL + badPath,
|
reqURL + "/asdasd",
|
||||||
true,
|
true,
|
||||||
"",
|
"",
|
||||||
func(bondId string) {
|
func(bondId string) {
|
||||||
@ -549,9 +552,10 @@ func (s *IntegrationTestSuite) TestGRPCQueryGetRegistryModuleBalance() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
|
if !tc.expectErr {
|
||||||
tc.preRun(s.bondID)
|
tc.preRun(s.bondID)
|
||||||
resp, err := rest.GetRequest(tc.url)
|
}
|
||||||
s.NoError(err)
|
resp, _ := rest.GetRequest(tc.url)
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
require.Contains(string(resp), tc.errorMsg)
|
require.Contains(string(resp), tc.errorMsg)
|
||||||
@ -579,7 +583,7 @@ func (s *IntegrationTestSuite) TestGRPCQueryNamesList() {
|
|||||||
}{
|
}{
|
||||||
{
|
{
|
||||||
"invalid url",
|
"invalid url",
|
||||||
reqURL + badPath,
|
reqURL + "/asdasd",
|
||||||
true,
|
true,
|
||||||
"",
|
"",
|
||||||
func(authorityName string) {
|
func(authorityName string) {
|
||||||
@ -599,9 +603,10 @@ func (s *IntegrationTestSuite) TestGRPCQueryNamesList() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(tc.name, func() {
|
s.Run(tc.name, func() {
|
||||||
|
if !tc.expectErr {
|
||||||
tc.preRun("ListNameRecords")
|
tc.preRun("ListNameRecords")
|
||||||
resp, err := rest.GetRequest(tc.url)
|
}
|
||||||
s.NoError(err)
|
resp, _ := rest.GetRequest(tc.url)
|
||||||
require := s.Require()
|
require := s.Require()
|
||||||
if tc.expectErr {
|
if tc.expectErr {
|
||||||
require.Contains(string(resp), tc.errorMsg)
|
require.Contains(string(resp), tc.errorMsg)
|
||||||
@ -638,5 +643,5 @@ func createRecord(bondID string, s *IntegrationTestSuite) {
|
|||||||
var d sdk.TxResponse
|
var d sdk.TxResponse
|
||||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &d)
|
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &d)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
sr.Zero(d.Code, d.RawLog)
|
sr.Zero(d.Code)
|
||||||
}
|
}
|
||||||
|
@ -538,6 +538,9 @@ func createNameRecord(authorityName string, s *IntegrationTestSuite) {
|
|||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
sr.Zero(d.Code)
|
sr.Zero(d.Code)
|
||||||
|
|
||||||
|
// creating the bond
|
||||||
|
CreateBond(s)
|
||||||
|
|
||||||
// Get the bond-id
|
// Get the bond-id
|
||||||
bondID := GetBondID(s)
|
bondID := GetBondID(s)
|
||||||
|
|
||||||
|
@ -101,24 +101,43 @@ func CreateBond(s *IntegrationTestSuite) {
|
|||||||
val := s.network.Validators[0]
|
val := s.network.Validators[0]
|
||||||
sr := s.Require()
|
sr := s.Require()
|
||||||
|
|
||||||
clientCtx := val.ClientCtx
|
testCases := []struct {
|
||||||
cmd := bondcli.NewCreateBondCmd()
|
name string
|
||||||
args := []string{
|
args []string
|
||||||
|
err bool
|
||||||
|
}{
|
||||||
|
{
|
||||||
|
"create bond",
|
||||||
|
[]string{
|
||||||
fmt.Sprintf("100000000000%s", s.cfg.BondDenom),
|
fmt.Sprintf("100000000000%s", s.cfg.BondDenom),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
fmt.Sprintf("--%s=%s", flags.FlagBroadcastMode, flags.BroadcastBlock),
|
||||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("3%s", s.cfg.BondDenom)),
|
fmt.Sprintf("--%s=%s", flags.FlagFees, fmt.Sprintf("3%s", s.cfg.BondDenom)),
|
||||||
|
},
|
||||||
|
false,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
out, err := clitestutil.ExecTestCLICmd(clientCtx, cmd, args)
|
|
||||||
sr.NoError(err)
|
|
||||||
|
|
||||||
|
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
|
var d sdk.TxResponse
|
||||||
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &d)
|
err = val.ClientCtx.Codec.UnmarshalJSON(out.Bytes(), &d)
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
sr.Zero(d.Code)
|
sr.Zero(d.Code)
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func GetBondID(s *IntegrationTestSuite) string {
|
func GetBondID(s *IntegrationTestSuite) string {
|
||||||
cmd := bondcli.GetQueryBondLists()
|
cmd := bondcli.GetQueryBondLists()
|
||||||
@ -141,11 +160,6 @@ func (s *IntegrationTestSuite) TestGetCmdSetRecord() {
|
|||||||
val := s.network.Validators[0]
|
val := s.network.Validators[0]
|
||||||
sr := s.Require()
|
sr := s.Require()
|
||||||
|
|
||||||
bondID := GetBondID(s)
|
|
||||||
dir, err := os.Getwd()
|
|
||||||
sr.NoError(err)
|
|
||||||
payloadPath := dir + "/service_provider_example.yml"
|
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
@ -165,7 +179,6 @@ func (s *IntegrationTestSuite) TestGetCmdSetRecord() {
|
|||||||
{
|
{
|
||||||
"success",
|
"success",
|
||||||
[]string{
|
[]string{
|
||||||
payloadPath, bondID,
|
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||||
@ -178,6 +191,17 @@ func (s *IntegrationTestSuite) TestGetCmdSetRecord() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
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 + "/service_provider_example.yml"
|
||||||
|
|
||||||
|
tc.args = append([]string{payloadPath, bondID}, tc.args...)
|
||||||
|
}
|
||||||
clientCtx := val.ClientCtx
|
clientCtx := val.ClientCtx
|
||||||
cmd := cli.GetCmdSetRecord()
|
cmd := cli.GetCmdSetRecord()
|
||||||
|
|
||||||
@ -317,6 +341,9 @@ func (s *IntegrationTestSuite) TestGetCmdSetName() {
|
|||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
sr.Zero(d.Code)
|
sr.Zero(d.Code)
|
||||||
|
|
||||||
|
// creating the bond
|
||||||
|
CreateBond(s)
|
||||||
|
|
||||||
// Get the bond-id
|
// Get the bond-id
|
||||||
bondID := GetBondID(s)
|
bondID := GetBondID(s)
|
||||||
|
|
||||||
@ -342,7 +369,9 @@ func (s *IntegrationTestSuite) TestGetCmdSetName() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||||
|
if !tc.err {
|
||||||
tc.preRun(authorityName)
|
tc.preRun(authorityName)
|
||||||
|
}
|
||||||
|
|
||||||
clientCtx := val.ClientCtx
|
clientCtx := val.ClientCtx
|
||||||
cmd := cli.GetCmdSetName()
|
cmd := cli.GetCmdSetName()
|
||||||
@ -365,7 +394,6 @@ func (s *IntegrationTestSuite) TestGetCmdSetAuthorityBond() {
|
|||||||
val := s.network.Validators[0]
|
val := s.network.Validators[0]
|
||||||
sr := s.Require()
|
sr := s.Require()
|
||||||
authorityName := "TestGetCmdSetAuthorityBond"
|
authorityName := "TestGetCmdSetAuthorityBond"
|
||||||
bondID := GetBondID(s)
|
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
@ -389,7 +417,6 @@ func (s *IntegrationTestSuite) TestGetCmdSetAuthorityBond() {
|
|||||||
{
|
{
|
||||||
"success with name and bond-id",
|
"success with name and bond-id",
|
||||||
[]string{
|
[]string{
|
||||||
authorityName, bondID,
|
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||||
@ -422,7 +449,15 @@ func (s *IntegrationTestSuite) TestGetCmdSetAuthorityBond() {
|
|||||||
|
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||||
|
if !tc.err {
|
||||||
|
// reserve the name
|
||||||
tc.preRun(authorityName)
|
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
|
clientCtx := val.ClientCtx
|
||||||
cmd := cli.GetCmdSetAuthorityBond()
|
cmd := cli.GetCmdSetAuthorityBond()
|
||||||
|
|
||||||
@ -466,7 +501,6 @@ func (s *IntegrationTestSuite) TestGetCmdDeleteName() {
|
|||||||
{
|
{
|
||||||
"successfully delete name",
|
"successfully delete name",
|
||||||
[]string{
|
[]string{
|
||||||
fmt.Sprintf("crn://%s/", authorityName),
|
|
||||||
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
fmt.Sprintf("--%s=%s", flags.FlagFrom, accountName),
|
||||||
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
fmt.Sprintf("--%s=true", flags.FlagSkipConfirmation),
|
||||||
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
fmt.Sprintf("--%s=json", tmcli.OutputFlag),
|
||||||
@ -482,8 +516,10 @@ func (s *IntegrationTestSuite) TestGetCmdDeleteName() {
|
|||||||
|
|
||||||
for _, tc := range testCasesForDeletingName {
|
for _, tc := range testCasesForDeletingName {
|
||||||
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
s.Run(fmt.Sprintf("Case %s", tc.name), func() {
|
||||||
|
if !tc.err {
|
||||||
tc.preRun(authorityName, s)
|
tc.preRun(authorityName, s)
|
||||||
|
tc.args = append([]string{fmt.Sprintf("crn://%s/", authorityName)}, tc.args...)
|
||||||
|
}
|
||||||
clientCtx := val.ClientCtx
|
clientCtx := val.ClientCtx
|
||||||
cmd := cli.GetCmdDeleteName()
|
cmd := cli.GetCmdDeleteName()
|
||||||
|
|
||||||
@ -538,6 +574,8 @@ func (s *IntegrationTestSuite) TestGetCmdDissociateBond() {
|
|||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
func(s *IntegrationTestSuite) string {
|
func(s *IntegrationTestSuite) string {
|
||||||
|
// create the bond
|
||||||
|
CreateBond(s)
|
||||||
// get the bond id from bond list
|
// get the bond id from bond list
|
||||||
bondID := GetBondID(s)
|
bondID := GetBondID(s)
|
||||||
dir, err := os.Getwd()
|
dir, err := os.Getwd()
|
||||||
@ -778,6 +816,8 @@ func (s *IntegrationTestSuite) TestGetCmdAssociateBond() {
|
|||||||
},
|
},
|
||||||
false,
|
false,
|
||||||
func(s *IntegrationTestSuite) (string, string) {
|
func(s *IntegrationTestSuite) (string, string) {
|
||||||
|
// create the bond
|
||||||
|
CreateBond(s)
|
||||||
// get the bond id from bond list
|
// get the bond id from bond list
|
||||||
bondID := GetBondID(s)
|
bondID := GetBondID(s)
|
||||||
dir, err := os.Getwd()
|
dir, err := os.Getwd()
|
||||||
|
@ -1,7 +0,0 @@
|
|||||||
record:
|
|
||||||
type: GeneralRecord
|
|
||||||
name: foo
|
|
||||||
version: 1.0.0
|
|
||||||
tags:
|
|
||||||
- tagA
|
|
||||||
- tagB
|
|
@ -47,20 +47,24 @@ func Int64ToBytes(num int64) []byte {
|
|||||||
return buf.Bytes()
|
return buf.Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
func MustMarshalJSON[T any](val T) (bytes []byte) {
|
// MarshalMapToJSONBytes converts map[string]interface{} to bytes.
|
||||||
|
func MarshalMapToJSONBytes(val map[string]interface{}) (bytes []byte) {
|
||||||
bytes, err := json.Marshal(val)
|
bytes, err := json.Marshal(val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("JSON marshal error:" + err.Error())
|
panic("Marshal error.")
|
||||||
}
|
}
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func MustUnmarshalJSON[T any](bytes []byte) T {
|
// UnMarshalMapFromJSONBytes converts bytes to map[string]interface{}.
|
||||||
var val T
|
func UnMarshalMapFromJSONBytes(bytes []byte) map[string]interface{} {
|
||||||
|
var val map[string]interface{}
|
||||||
err := json.Unmarshal(bytes, &val)
|
err := json.Unmarshal(bytes, &val)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("JSON unmarshal error:" + err.Error())
|
panic("Unmarshal error.")
|
||||||
}
|
}
|
||||||
|
|
||||||
return val
|
return val
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"reflect"
|
|
||||||
|
|
||||||
"github.com/cerc-io/laconicd/x/registry/client/cli"
|
"github.com/cerc-io/laconicd/x/registry/client/cli"
|
||||||
"github.com/cerc-io/laconicd/x/registry/helpers"
|
"github.com/cerc-io/laconicd/x/registry/helpers"
|
||||||
@ -40,7 +39,6 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
|||||||
examples := []string{
|
examples := []string{
|
||||||
"/../helpers/examples/service_provider_example.yml",
|
"/../helpers/examples/service_provider_example.yml",
|
||||||
"/../helpers/examples/website_registration_example.yml",
|
"/../helpers/examples/website_registration_example.yml",
|
||||||
"/../helpers/examples/general_record_example.yml",
|
|
||||||
}
|
}
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
msg string
|
msg string
|
||||||
@ -61,7 +59,7 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
|||||||
®istrytypes.QueryListRecordsRequest{},
|
®istrytypes.QueryListRecordsRequest{},
|
||||||
true,
|
true,
|
||||||
false,
|
false,
|
||||||
3,
|
2,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"Filter with type",
|
"Filter with type",
|
||||||
@ -70,7 +68,8 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
|||||||
{
|
{
|
||||||
Key: "type",
|
Key: "type",
|
||||||
Value: ®istrytypes.QueryListRecordsRequest_ValueInput{
|
Value: ®istrytypes.QueryListRecordsRequest_ValueInput{
|
||||||
Value: ®istrytypes.QueryListRecordsRequest_ValueInput_String_{"WebsiteRegistrationRecord"},
|
Type: "string",
|
||||||
|
String_: "WebsiteRegistrationRecord",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -80,69 +79,6 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
|||||||
false,
|
false,
|
||||||
1,
|
1,
|
||||||
},
|
},
|
||||||
// Skip the following test as querying with recursive values not supported (PR https://git.vdb.to/cerc-io/laconicd/pulls/112)
|
|
||||||
// See function RecordsFromAttributes (QueryValueToJSON call) in the registry keeper implementation (x/registry/keeper/keeper.go)
|
|
||||||
// {
|
|
||||||
// "Filter with tag (extant) (https://git.vdb.to/cerc-io/laconicd/issues/129)",
|
|
||||||
// ®istrytypes.QueryListRecordsRequest{
|
|
||||||
// Attributes: []*registrytypes.QueryListRecordsRequest_KeyValueInput{
|
|
||||||
// {
|
|
||||||
// Key: "tags",
|
|
||||||
// // Value: ®istrytypes.QueryListRecordsRequest_ValueInput{
|
|
||||||
// // Value: ®istrytypes.QueryListRecordsRequest_ValueInput_String_{"tagA"},
|
|
||||||
// // },
|
|
||||||
// Value: ®istrytypes.QueryListRecordsRequest_ValueInput{
|
|
||||||
// Value: ®istrytypes.QueryListRecordsRequest_ValueInput_Array{Array: ®istrytypes.QueryListRecordsRequest_ArrayInput{
|
|
||||||
// Values: []*registrytypes.QueryListRecordsRequest_ValueInput{
|
|
||||||
// {
|
|
||||||
// Value: ®istrytypes.QueryListRecordsRequest_ValueInput_String_{"tagA"},
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// }},
|
|
||||||
// },
|
|
||||||
// // Throws: "Recursive query values are not supported"
|
|
||||||
// },
|
|
||||||
// },
|
|
||||||
// All: true,
|
|
||||||
// },
|
|
||||||
// true,
|
|
||||||
// false,
|
|
||||||
// 1,
|
|
||||||
// },
|
|
||||||
{
|
|
||||||
"Filter with tag (non-existent) (https://git.vdb.to/cerc-io/laconicd/issues/129)",
|
|
||||||
®istrytypes.QueryListRecordsRequest{
|
|
||||||
Attributes: []*registrytypes.QueryListRecordsRequest_KeyValueInput{
|
|
||||||
{
|
|
||||||
Key: "tags",
|
|
||||||
Value: ®istrytypes.QueryListRecordsRequest_ValueInput{
|
|
||||||
Value: ®istrytypes.QueryListRecordsRequest_ValueInput_String_{"NOEXIST"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
All: true,
|
|
||||||
},
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
0,
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"Filter test for key collision (https://git.vdb.to/cerc-io/laconicd/issues/122)",
|
|
||||||
®istrytypes.QueryListRecordsRequest{
|
|
||||||
Attributes: []*registrytypes.QueryListRecordsRequest_KeyValueInput{
|
|
||||||
{
|
|
||||||
Key: "typ",
|
|
||||||
Value: ®istrytypes.QueryListRecordsRequest_ValueInput{
|
|
||||||
Value: ®istrytypes.QueryListRecordsRequest_ValueInput_String_{"eWebsiteRegistrationRecord"},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
All: true,
|
|
||||||
},
|
|
||||||
true,
|
|
||||||
false,
|
|
||||||
0,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"Filter with attributes ServiceProviderRegistration",
|
"Filter with attributes ServiceProviderRegistration",
|
||||||
®istrytypes.QueryListRecordsRequest{
|
®istrytypes.QueryListRecordsRequest{
|
||||||
@ -150,7 +86,8 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
|||||||
{
|
{
|
||||||
Key: "x500state_name",
|
Key: "x500state_name",
|
||||||
Value: ®istrytypes.QueryListRecordsRequest_ValueInput{
|
Value: ®istrytypes.QueryListRecordsRequest_ValueInput{
|
||||||
Value: ®istrytypes.QueryListRecordsRequest_ValueInput_String_{"california"},
|
Type: "string",
|
||||||
|
String_: "california",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@ -185,37 +122,18 @@ func (suite *KeeperTestSuite) TestGrpcGetRecordLists() {
|
|||||||
} else {
|
} else {
|
||||||
sr.NoError(err)
|
sr.NoError(err)
|
||||||
sr.Equal(test.noOfRecords, len(resp.GetRecords()))
|
sr.Equal(test.noOfRecords, len(resp.GetRecords()))
|
||||||
if test.createRecords && test.noOfRecords > 0 {
|
if test.createRecords {
|
||||||
recordId = resp.GetRecords()[0].GetId()
|
recordId = resp.GetRecords()[0].GetId()
|
||||||
sr.NotZero(resp.GetRecords())
|
sr.NotZero(resp.GetRecords())
|
||||||
sr.Equal(resp.GetRecords()[0].GetBondId(), suite.bond.GetId())
|
sr.Equal(resp.GetRecords()[0].GetBondId(), suite.bond.GetId())
|
||||||
|
|
||||||
for _, record := range resp.GetRecords() {
|
for _, record := range resp.GetRecords() {
|
||||||
recAttr := helpers.MustUnmarshalJSON[registrytypes.AttributeMap](record.Attributes)
|
recAttr := helpers.UnMarshalMapFromJSONBytes(record.Attributes)
|
||||||
|
|
||||||
for _, attr := range test.req.GetAttributes() {
|
for _, attr := range test.req.GetAttributes() {
|
||||||
enc, err := keeper.QueryValueToJSON(attr.Value)
|
|
||||||
sr.NoError(err)
|
|
||||||
av := helpers.MustUnmarshalJSON[any](enc)
|
|
||||||
|
|
||||||
if nil != av && nil != recAttr[attr.Key] &&
|
|
||||||
reflect.Slice == reflect.TypeOf(recAttr[attr.Key]).Kind() &&
|
|
||||||
reflect.Slice != reflect.TypeOf(av).Kind() {
|
|
||||||
found := false
|
|
||||||
allValues := recAttr[attr.Key].([]interface{})
|
|
||||||
for i := range allValues {
|
|
||||||
if av == allValues[i] {
|
|
||||||
fmt.Printf("Found %s in %s", allValues[i], recAttr[attr.Key])
|
|
||||||
found = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sr.Equal(true, found, fmt.Sprintf("Unable to find %s in %s", av, recAttr[attr.Key]))
|
|
||||||
} else {
|
|
||||||
if attr.Key[:4] == "x500" {
|
if attr.Key[:4] == "x500" {
|
||||||
sr.Equal(av, recAttr["x500"].(map[string]interface{})[attr.Key[4:]])
|
sr.Equal(keeper.GetAttributeValue(attr.Value), recAttr["x500"].(map[string]interface{})[attr.Key[4:]])
|
||||||
} else {
|
} else {
|
||||||
sr.Equal(av, recAttr[attr.Key])
|
sr.Equal(keeper.GetAttributeValue(attr.Value), recAttr[attr.Key])
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,10 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
errorsmod "cosmossdk.io/errors"
|
errorsmod "cosmossdk.io/errors"
|
||||||
|
auctionkeeper "github.com/cerc-io/laconicd/x/auction/keeper"
|
||||||
|
bondkeeper "github.com/cerc-io/laconicd/x/bond/keeper"
|
||||||
|
"github.com/cerc-io/laconicd/x/registry/helpers"
|
||||||
|
"github.com/cerc-io/laconicd/x/registry/types"
|
||||||
"github.com/cosmos/cosmos-sdk/codec"
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
"github.com/cosmos/cosmos-sdk/codec/legacy"
|
"github.com/cosmos/cosmos-sdk/codec/legacy"
|
||||||
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
storetypes "github.com/cosmos/cosmos-sdk/store/types"
|
||||||
@ -16,18 +20,6 @@ import (
|
|||||||
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
auth "github.com/cosmos/cosmos-sdk/x/auth/keeper"
|
||||||
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
bank "github.com/cosmos/cosmos-sdk/x/bank/keeper"
|
||||||
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
paramtypes "github.com/cosmos/cosmos-sdk/x/params/types"
|
||||||
"github.com/gibson042/canonicaljson-go"
|
|
||||||
cid "github.com/ipfs/go-cid"
|
|
||||||
"github.com/ipld/go-ipld-prime"
|
|
||||||
"github.com/ipld/go-ipld-prime/codec/dagjson"
|
|
||||||
cidlink "github.com/ipld/go-ipld-prime/linking/cid"
|
|
||||||
basicnode "github.com/ipld/go-ipld-prime/node/basic"
|
|
||||||
"github.com/tendermint/tendermint/libs/log"
|
|
||||||
|
|
||||||
auctionkeeper "github.com/cerc-io/laconicd/x/auction/keeper"
|
|
||||||
bondkeeper "github.com/cerc-io/laconicd/x/bond/keeper"
|
|
||||||
"github.com/cerc-io/laconicd/x/registry/helpers"
|
|
||||||
"github.com/cerc-io/laconicd/x/registry/types"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -104,15 +96,6 @@ func NewKeeper(cdc codec.BinaryCodec, accountKeeper auth.AccountKeeper, bankKeep
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logger returns a module-specific logger.
|
|
||||||
func (k Keeper) Logger(ctx sdk.Context) log.Logger {
|
|
||||||
return logger(ctx)
|
|
||||||
}
|
|
||||||
|
|
||||||
func logger(ctx sdk.Context) log.Logger {
|
|
||||||
return ctx.Logger().With("module", types.ModuleName)
|
|
||||||
}
|
|
||||||
|
|
||||||
// GetRecordIndexKey Generates Bond ID -> Bond index key.
|
// GetRecordIndexKey Generates Bond ID -> Bond index key.
|
||||||
func GetRecordIndexKey(id string) []byte {
|
func GetRecordIndexKey(id string) []byte {
|
||||||
return append(PrefixCIDToRecordIndex, []byte(id)...)
|
return append(PrefixCIDToRecordIndex, []byte(id)...)
|
||||||
@ -157,11 +140,8 @@ func (k Keeper) ListRecords(ctx sdk.Context) []types.Record {
|
|||||||
func (k Keeper) RecordsFromAttributes(ctx sdk.Context, attributes []*types.QueryListRecordsRequest_KeyValueInput, all bool) ([]types.Record, error) {
|
func (k Keeper) RecordsFromAttributes(ctx sdk.Context, attributes []*types.QueryListRecordsRequest_KeyValueInput, all bool) ([]types.Record, error) {
|
||||||
resultRecordIds := []string{}
|
resultRecordIds := []string{}
|
||||||
for i, attr := range attributes {
|
for i, attr := range attributes {
|
||||||
suffix, err := QueryValueToJSON(attr.Value)
|
val := GetAttributeValue(attr.Value)
|
||||||
if err != nil {
|
attributeIndex := GetAttributesIndexKey(attr.Key, val)
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
attributeIndex := GetAttributesIndexKey(attr.Key, suffix)
|
|
||||||
recordIds, err := k.GetAttributeMapping(ctx, attributeIndex)
|
recordIds, err := k.GetAttributeMapping(ctx, attributeIndex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -189,53 +169,23 @@ func (k Keeper) RecordsFromAttributes(ctx sdk.Context, attributes []*types.Query
|
|||||||
return records, nil
|
return records, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO not recursive, and only should be if we want to support querying with whole sub-objects,
|
func GetAttributeValue(input *types.QueryListRecordsRequest_ValueInput) interface{} {
|
||||||
// which seems unnecessary.
|
if input.Type == "int" {
|
||||||
func QueryValueToJSON(input *types.QueryListRecordsRequest_ValueInput) ([]byte, error) {
|
return input.GetInt()
|
||||||
np := basicnode.Prototype.Any
|
|
||||||
nb := np.NewBuilder()
|
|
||||||
|
|
||||||
switch value := input.GetValue().(type) {
|
|
||||||
case *types.QueryListRecordsRequest_ValueInput_String_:
|
|
||||||
err := nb.AssignString(value.String_)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
case *types.QueryListRecordsRequest_ValueInput_Int:
|
if input.Type == "float" {
|
||||||
err := nb.AssignInt(value.Int)
|
return input.GetFloat()
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
case *types.QueryListRecordsRequest_ValueInput_Float:
|
if input.Type == "string" {
|
||||||
err := nb.AssignFloat(value.Float)
|
return input.GetString_()
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
case *types.QueryListRecordsRequest_ValueInput_Boolean:
|
if input.Type == "boolean" {
|
||||||
err := nb.AssignBool(value.Boolean)
|
return input.GetBoolean()
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
case *types.QueryListRecordsRequest_ValueInput_Link:
|
if input.Type == "reference" {
|
||||||
link := cidlink.Link{Cid: cid.MustParse(value.Link)}
|
return input.GetReference().GetId()
|
||||||
err := nb.AssignLink(link)
|
|
||||||
if err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
}
|
||||||
case *types.QueryListRecordsRequest_ValueInput_Array:
|
return nil
|
||||||
return nil, fmt.Errorf("recursive query values are not supported")
|
|
||||||
case *types.QueryListRecordsRequest_ValueInput_Map:
|
|
||||||
return nil, fmt.Errorf("recursive query values are not supported")
|
|
||||||
default:
|
|
||||||
return nil, fmt.Errorf("value has unexpected type %T", value)
|
|
||||||
}
|
|
||||||
|
|
||||||
n := nb.Build()
|
|
||||||
var buf bytes.Buffer
|
|
||||||
if err := dagjson.Encode(n, &buf); err != nil {
|
|
||||||
return nil, fmt.Errorf("encoding value to JSON failed: %w", err)
|
|
||||||
}
|
|
||||||
return buf.Bytes(), nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func getIntersection(a []string, b []string) []string {
|
func getIntersection(a []string, b []string) []string {
|
||||||
@ -288,7 +238,7 @@ func (k Keeper) GetRecordExpiryQueue(ctx sdk.Context) []*types.ExpiryQueueRecord
|
|||||||
// ProcessSetRecord creates a record.
|
// ProcessSetRecord creates a record.
|
||||||
func (k Keeper) ProcessSetRecord(ctx sdk.Context, msg types.MsgSetRecord) (*types.ReadableRecord, error) {
|
func (k Keeper) ProcessSetRecord(ctx sdk.Context, msg types.MsgSetRecord) (*types.ReadableRecord, error) {
|
||||||
payload := msg.Payload.ToReadablePayload()
|
payload := msg.Payload.ToReadablePayload()
|
||||||
record := types.ReadableRecord{Attributes: payload.RecordAttributes, BondID: msg.BondId}
|
record := types.ReadableRecord{Attributes: payload.Record, BondID: msg.BondId}
|
||||||
|
|
||||||
// Check signatures.
|
// Check signatures.
|
||||||
resourceSignBytes, _ := record.GetSignBytes()
|
resourceSignBytes, _ := record.GetSignBytes()
|
||||||
@ -308,12 +258,14 @@ func (k Keeper) ProcessSetRecord(ctx sdk.Context, msg types.MsgSetRecord) (*type
|
|||||||
for _, sig := range payload.Signatures {
|
for _, sig := range payload.Signatures {
|
||||||
pubKey, err := legacy.PubKeyFromBytes(helpers.BytesFromBase64(sig.PubKey))
|
pubKey, err := legacy.PubKeyFromBytes(helpers.BytesFromBase64(sig.PubKey))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, fmt.Sprint("Error decoding pubKey from bytes: ", err))
|
fmt.Println("Error decoding pubKey from bytes: ", err)
|
||||||
|
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Invalid public key.")
|
||||||
}
|
}
|
||||||
|
|
||||||
sigOK := pubKey.VerifySignature(resourceSignBytes, helpers.BytesFromBase64(sig.Sig))
|
sigOK := pubKey.VerifySignature(resourceSignBytes, helpers.BytesFromBase64(sig.Sig))
|
||||||
if !sigOK {
|
if !sigOK {
|
||||||
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, fmt.Sprint("Signature mismatch: ", sig.PubKey))
|
fmt.Println("Signature mismatch: ", sig.PubKey)
|
||||||
|
return nil, errorsmod.Wrap(sdkerrors.ErrUnauthorized, "Invalid signature.")
|
||||||
}
|
}
|
||||||
record.Owners = append(record.Owners, pubKey.Address().String())
|
record.Owners = append(record.Owners, pubKey.Address().String())
|
||||||
}
|
}
|
||||||
@ -354,7 +306,7 @@ func (k Keeper) processRecord(ctx sdk.Context, record *types.ReadableRecord, isR
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
expiryTimeKey := GetAttributesIndexKey(ExpiryTimeAttributeName, []byte(record.ExpiryTime))
|
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 err
|
||||||
}
|
}
|
||||||
@ -376,51 +328,11 @@ func (k Keeper) PutRecord(ctx sdk.Context, record types.Record) {
|
|||||||
k.updateBlockChangeSetForRecord(ctx, record.Id)
|
k.updateBlockChangeSetForRecord(ctx, record.Id)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (k Keeper) processAttributes(ctx sdk.Context, attrs types.AttributeMap, id string, prefix string) error {
|
func (k Keeper) processAttributes(ctx sdk.Context, attrs map[string]any, id string, prefix string) error {
|
||||||
np := basicnode.Prototype.Map
|
for key, value := range attrs {
|
||||||
nb := np.NewBuilder()
|
if subRecord, ok := value.(map[string]any); ok {
|
||||||
encAttrs, err := canonicaljson.Marshal(attrs)
|
k.processAttributes(ctx, subRecord, id, key)
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
if len(attrs) == 0 {
|
|
||||||
encAttrs = []byte("{}")
|
|
||||||
}
|
|
||||||
err = dagjson.Decode(nb, bytes.NewReader(encAttrs))
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("failed to decode attributes: %w", err)
|
|
||||||
}
|
|
||||||
n := nb.Build()
|
|
||||||
if n.Kind() != ipld.Kind_Map {
|
|
||||||
return fmt.Errorf("record attributes must be a map, not %T", n.Kind())
|
|
||||||
}
|
|
||||||
|
|
||||||
return k.processAttributeMap(ctx, n, id, prefix)
|
|
||||||
}
|
|
||||||
|
|
||||||
func (k Keeper) processAttributeMap(ctx sdk.Context, n ipld.Node, id string, prefix string) error {
|
|
||||||
for it := n.MapIterator(); !it.Done(); {
|
|
||||||
//nolint:misspell
|
|
||||||
keynode, valuenode, err := it.Next()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
key, err := keynode.AsString()
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
if valuenode.Kind() == ipld.Kind_Map {
|
|
||||||
err := k.processAttributeMap(ctx, valuenode, id, key)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
var buf bytes.Buffer
|
|
||||||
if err := dagjson.Encode(valuenode, &buf); err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
value := buf.Bytes()
|
|
||||||
indexKey := GetAttributesIndexKey(prefix+key, value)
|
indexKey := GetAttributesIndexKey(prefix+key, value)
|
||||||
if err := k.SetAttributeMapping(ctx, indexKey, id); err != nil {
|
if err := k.SetAttributeMapping(ctx, indexKey, id); err != nil {
|
||||||
return err
|
return err
|
||||||
@ -430,8 +342,8 @@ func (k Keeper) processAttributeMap(ctx sdk.Context, n ipld.Node, id string, pre
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetAttributesIndexKey(key string, suffix []byte) []byte {
|
func GetAttributesIndexKey(key string, value interface{}) []byte {
|
||||||
keyString := fmt.Sprintf("%s=%s", key, suffix)
|
keyString := fmt.Sprintf("%s%s", key, value)
|
||||||
return append(PrefixAttributesIndex, []byte(keyString)...)
|
return append(PrefixAttributesIndex, []byte(keyString)...)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -443,6 +355,8 @@ func (k Keeper) SetAttributeMapping(ctx sdk.Context, key []byte, recordID string
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("cannot unmarshal byte array, error, %w", err)
|
return fmt.Errorf("cannot unmarshal byte array, error, %w", err)
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
recordIds = []string{}
|
||||||
}
|
}
|
||||||
recordIds = append(recordIds, recordID)
|
recordIds = append(recordIds, recordID)
|
||||||
bz, err := json.Marshal(recordIds)
|
bz, err := json.Marshal(recordIds)
|
||||||
@ -457,8 +371,7 @@ func (k Keeper) GetAttributeMapping(ctx sdk.Context, key []byte) ([]string, erro
|
|||||||
store := ctx.KVStore(k.storeKey)
|
store := ctx.KVStore(k.storeKey)
|
||||||
|
|
||||||
if !store.Has(key) {
|
if !store.Has(key) {
|
||||||
k.Logger(ctx).Debug(fmt.Sprintf("store doesn't have key: %q", key))
|
return nil, fmt.Errorf("store doesn't have key")
|
||||||
return []string{}, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var recordIds []string
|
var recordIds []string
|
||||||
|
@ -2,12 +2,9 @@ package keeper
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
||||||
|
|
||||||
"github.com/cerc-io/laconicd/utils"
|
|
||||||
"github.com/cerc-io/laconicd/x/registry/types"
|
"github.com/cerc-io/laconicd/x/registry/types"
|
||||||
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
type msgServer struct {
|
type msgServer struct {
|
||||||
@ -23,14 +20,16 @@ var _ types.MsgServer = msgServer{}
|
|||||||
|
|
||||||
func (m msgServer) SetRecord(c context.Context, msg *types.MsgSetRecord) (*types.MsgSetRecordResponse, error) {
|
func (m msgServer) SetRecord(c context.Context, msg *types.MsgSetRecord) (*types.MsgSetRecordResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
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 {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -49,15 +48,12 @@ func (m msgServer) SetRecord(c context.Context, msg *types.MsgSetRecord) (*types
|
|||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
m.logTxGasConsumed(ctx, "SetRecord")
|
|
||||||
|
|
||||||
return &types.MsgSetRecordResponse{Id: record.ID}, nil
|
return &types.MsgSetRecordResponse{Id: record.ID}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint: all
|
||||||
func (m msgServer) SetName(c context.Context, msg *types.MsgSetName) (*types.MsgSetNameResponse, error) {
|
func (m msgServer) SetName(c context.Context, msg *types.MsgSetName) (*types.MsgSetNameResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -79,16 +75,11 @@ func (m msgServer) SetName(c context.Context, msg *types.MsgSetName) (*types.Msg
|
|||||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
m.logTxGasConsumed(ctx, "SetName")
|
|
||||||
|
|
||||||
return &types.MsgSetNameResponse{}, nil
|
return &types.MsgSetNameResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m msgServer) ReserveName(c context.Context, msg *types.MsgReserveAuthority) (*types.MsgReserveAuthorityResponse, error) {
|
func (m msgServer) ReserveName(c context.Context, msg *types.MsgReserveAuthority) (*types.MsgReserveAuthorityResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -114,16 +105,12 @@ func (m msgServer) ReserveName(c context.Context, msg *types.MsgReserveAuthority
|
|||||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
m.logTxGasConsumed(ctx, "ReserveName")
|
|
||||||
|
|
||||||
return &types.MsgReserveAuthorityResponse{}, nil
|
return &types.MsgReserveAuthorityResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint: all
|
||||||
func (m msgServer) SetAuthorityBond(c context.Context, msg *types.MsgSetAuthorityBond) (*types.MsgSetAuthorityBondResponse, error) {
|
func (m msgServer) SetAuthorityBond(c context.Context, msg *types.MsgSetAuthorityBond) (*types.MsgSetAuthorityBondResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -145,16 +132,11 @@ func (m msgServer) SetAuthorityBond(c context.Context, msg *types.MsgSetAuthorit
|
|||||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
m.logTxGasConsumed(ctx, "SetAuthorityBond")
|
|
||||||
|
|
||||||
return &types.MsgSetAuthorityBondResponse{}, nil
|
return &types.MsgSetAuthorityBondResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m msgServer) DeleteName(c context.Context, msg *types.MsgDeleteNameAuthority) (*types.MsgDeleteNameAuthorityResponse, error) {
|
func (m msgServer) DeleteName(c context.Context, msg *types.MsgDeleteNameAuthority) (*types.MsgDeleteNameAuthorityResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -175,16 +157,11 @@ func (m msgServer) DeleteName(c context.Context, msg *types.MsgDeleteNameAuthori
|
|||||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
m.logTxGasConsumed(ctx, "DeleteName")
|
|
||||||
|
|
||||||
return &types.MsgDeleteNameAuthorityResponse{}, nil
|
return &types.MsgDeleteNameAuthorityResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m msgServer) RenewRecord(c context.Context, msg *types.MsgRenewRecord) (*types.MsgRenewRecordResponse, error) {
|
func (m msgServer) RenewRecord(c context.Context, msg *types.MsgRenewRecord) (*types.MsgRenewRecordResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -205,16 +182,12 @@ func (m msgServer) RenewRecord(c context.Context, msg *types.MsgRenewRecord) (*t
|
|||||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
m.logTxGasConsumed(ctx, "RenewRecord")
|
|
||||||
|
|
||||||
return &types.MsgRenewRecordResponse{}, nil
|
return &types.MsgRenewRecordResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint: all
|
||||||
func (m msgServer) AssociateBond(c context.Context, msg *types.MsgAssociateBond) (*types.MsgAssociateBondResponse, error) {
|
func (m msgServer) AssociateBond(c context.Context, msg *types.MsgAssociateBond) (*types.MsgAssociateBondResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -237,16 +210,11 @@ func (m msgServer) AssociateBond(c context.Context, msg *types.MsgAssociateBond)
|
|||||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
m.logTxGasConsumed(ctx, "AssociateBond")
|
|
||||||
|
|
||||||
return &types.MsgAssociateBondResponse{}, nil
|
return &types.MsgAssociateBondResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m msgServer) DissociateBond(c context.Context, msg *types.MsgDissociateBond) (*types.MsgDissociateBondResponse, error) {
|
func (m msgServer) DissociateBond(c context.Context, msg *types.MsgDissociateBond) (*types.MsgDissociateBondResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -267,16 +235,11 @@ func (m msgServer) DissociateBond(c context.Context, msg *types.MsgDissociateBon
|
|||||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
m.logTxGasConsumed(ctx, "DissociateBond")
|
|
||||||
|
|
||||||
return &types.MsgDissociateBondResponse{}, nil
|
return &types.MsgDissociateBondResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m msgServer) DissociateRecords(c context.Context, msg *types.MsgDissociateRecords) (*types.MsgDissociateRecordsResponse, error) {
|
func (m msgServer) DissociateRecords(c context.Context, msg *types.MsgDissociateRecords) (*types.MsgDissociateRecordsResponse, error) {
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -297,16 +260,11 @@ func (m msgServer) DissociateRecords(c context.Context, msg *types.MsgDissociate
|
|||||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
m.logTxGasConsumed(ctx, "DissociateRecords")
|
|
||||||
|
|
||||||
return &types.MsgDissociateRecordsResponse{}, nil
|
return &types.MsgDissociateRecordsResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m msgServer) ReAssociateRecords(c context.Context, msg *types.MsgReAssociateRecords) (*types.MsgReAssociateRecordsResponse, error) { //nolint: all
|
func (m msgServer) ReAssociateRecords(c context.Context, msg *types.MsgReAssociateRecords) (*types.MsgReAssociateRecordsResponse, error) { //nolint: all
|
||||||
ctx := sdk.UnwrapSDKContext(c)
|
ctx := sdk.UnwrapSDKContext(c)
|
||||||
ctx = *utils.CtxWithCustomKVGasConfig(&ctx)
|
|
||||||
|
|
||||||
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
_, err := sdk.AccAddressFromBech32(msg.Signer)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -328,13 +286,5 @@ func (m msgServer) ReAssociateRecords(c context.Context, msg *types.MsgReAssocia
|
|||||||
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
sdk.NewAttribute(types.AttributeKeySigner, msg.Signer),
|
||||||
),
|
),
|
||||||
})
|
})
|
||||||
|
|
||||||
m.logTxGasConsumed(ctx, "ReAssociateRecords")
|
|
||||||
|
|
||||||
return &types.MsgReAssociateRecordsResponse{}, nil
|
return &types.MsgReAssociateRecordsResponse{}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m msgServer) logTxGasConsumed(ctx sdk.Context, tx string) {
|
|
||||||
gasConsumed := ctx.GasMeter().GasConsumed()
|
|
||||||
m.Keeper.Logger(ctx).Info("tx executed", "method", tx, "gas_consumed", fmt.Sprintf("%d", gasConsumed))
|
|
||||||
}
|
|
||||||
|
@ -611,7 +611,7 @@ func (k Keeper) ProcessAuthorityExpiryQueue(ctx sdk.Context) {
|
|||||||
k.SetNameAuthority(ctx, name, &authority)
|
k.SetNameAuthority(ctx, name, &authority)
|
||||||
k.DeleteAuthorityExpiryQueue(ctx, name, authority)
|
k.DeleteAuthorityExpiryQueue(ctx, name, authority)
|
||||||
|
|
||||||
k.Logger(ctx).Info(fmt.Sprintf("Marking authority expired as no bond present: %s", name))
|
ctx.Logger().Info(fmt.Sprintf("Marking authority expired as no bond present: %s", name))
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -672,7 +672,7 @@ func (k Keeper) AuthorityExpiryQueueIterator(ctx sdk.Context, endTime time.Time)
|
|||||||
|
|
||||||
// TryTakeAuthorityRent tries to take rent from the authority bond.
|
// TryTakeAuthorityRent tries to take rent from the authority bond.
|
||||||
func (k Keeper) TryTakeAuthorityRent(ctx sdk.Context, name string, authority types.NameAuthority) {
|
func (k Keeper) TryTakeAuthorityRent(ctx sdk.Context, name string, authority types.NameAuthority) {
|
||||||
k.Logger(ctx).Info(fmt.Sprintf("Trying to take rent for authority: %s", name))
|
ctx.Logger().Info(fmt.Sprintf("Trying to take rent for authority: %s", name))
|
||||||
|
|
||||||
params := k.GetParams(ctx)
|
params := k.GetParams(ctx)
|
||||||
rent := params.AuthorityRent
|
rent := params.AuthorityRent
|
||||||
@ -684,7 +684,7 @@ func (k Keeper) TryTakeAuthorityRent(ctx sdk.Context, name string, authority typ
|
|||||||
k.SetNameAuthority(ctx, name, &authority)
|
k.SetNameAuthority(ctx, name, &authority)
|
||||||
k.DeleteAuthorityExpiryQueue(ctx, name, authority)
|
k.DeleteAuthorityExpiryQueue(ctx, name, authority)
|
||||||
|
|
||||||
k.Logger(ctx).Info(fmt.Sprintf("Insufficient funds in owner account to pay authority rent, marking as expired: %s", name))
|
ctx.Logger().Info(fmt.Sprintf("Insufficient funds in owner account to pay authority rent, marking as expired: %s", name))
|
||||||
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@ -699,7 +699,7 @@ func (k Keeper) TryTakeAuthorityRent(ctx sdk.Context, name string, authority typ
|
|||||||
k.SetNameAuthority(ctx, name, &authority)
|
k.SetNameAuthority(ctx, name, &authority)
|
||||||
k.AddBondToAuthorityIndexEntry(ctx, authority.BondId, name)
|
k.AddBondToAuthorityIndexEntry(ctx, authority.BondId, name)
|
||||||
|
|
||||||
k.Logger(ctx).Info(fmt.Sprintf("Authority rent paid successfully: %s", name))
|
ctx.Logger().Info(fmt.Sprintf("Authority rent paid successfully: %s", name))
|
||||||
}
|
}
|
||||||
|
|
||||||
// ListNameAuthorityRecords - get all name authority records.
|
// ListNameAuthorityRecords - get all name authority records.
|
||||||
|
@ -39,14 +39,14 @@ func (k RecordKeeper) OnAuctionWinnerSelected(ctx sdk.Context, auctionID string)
|
|||||||
name := k.GetAuctionToAuthorityMapping(ctx, auctionID)
|
name := k.GetAuctionToAuthorityMapping(ctx, auctionID)
|
||||||
if name == "" {
|
if name == "" {
|
||||||
// We don't know about this auction, ignore.
|
// We don't know about this auction, ignore.
|
||||||
logger(ctx).Info(fmt.Sprintf("Ignoring auction notification, name mapping not found: %s", auctionID))
|
ctx.Logger().Info(fmt.Sprintf("Ignoring auction notification, name mapping not found: %s", auctionID))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
store := ctx.KVStore(k.storeKey)
|
store := ctx.KVStore(k.storeKey)
|
||||||
if !HasNameAuthority(store, name) {
|
if !HasNameAuthority(store, name) {
|
||||||
// We don't know about this authority, ignore.
|
// We don't know about this authority, ignore.
|
||||||
logger(ctx).Info(fmt.Sprintf("Ignoring auction notification, authority not found: %s", auctionID))
|
ctx.Logger().Info(fmt.Sprintf("Ignoring auction notification, authority not found: %s", auctionID))
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,12 +71,12 @@ func (k RecordKeeper) OnAuctionWinnerSelected(ctx sdk.Context, auctionID string)
|
|||||||
// Can be used to check if names are older than the authority itself (stale names).
|
// Can be used to check if names are older than the authority itself (stale names).
|
||||||
authority.Height = uint64(ctx.BlockHeight())
|
authority.Height = uint64(ctx.BlockHeight())
|
||||||
|
|
||||||
logger(ctx).Info(fmt.Sprintf("Winner selected, marking authority as active: %s", name))
|
ctx.Logger().Info(fmt.Sprintf("Winner selected, marking authority as active: %s", name))
|
||||||
} else {
|
} else {
|
||||||
// Mark as expired.
|
// Mark as expired.
|
||||||
authority.Status = types.AuthorityExpired
|
authority.Status = types.AuthorityExpired
|
||||||
|
|
||||||
logger(ctx).Info(fmt.Sprintf("No winner, marking authority as expired: %s", name))
|
ctx.Logger().Info(fmt.Sprintf("No winner, marking authority as expired: %s", name))
|
||||||
}
|
}
|
||||||
|
|
||||||
authority.AuctionId = ""
|
authority.AuctionId = ""
|
||||||
@ -85,7 +85,7 @@ func (k RecordKeeper) OnAuctionWinnerSelected(ctx sdk.Context, auctionID string)
|
|||||||
// Forget about this auction now, we no longer need it.
|
// Forget about this auction now, we no longer need it.
|
||||||
removeAuctionToAuthorityMapping(store, auctionID)
|
removeAuctionToAuthorityMapping(store, auctionID)
|
||||||
} else {
|
} else {
|
||||||
logger(ctx).Info(fmt.Sprintf("Ignoring auction notification, status: %s", auctionObj.Status))
|
ctx.Logger().Info(fmt.Sprintf("Ignoring auction notification, status: %s", auctionObj.Status))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
1391
x/registry/types/query.pb.go
generated
1391
x/registry/types/query.pb.go
generated
File diff suppressed because it is too large
Load Diff
918
x/registry/types/tx.pb.gw.go
generated
918
x/registry/types/tx.pb.gw.go
generated
@ -1,918 +0,0 @@
|
|||||||
// Code generated by protoc-gen-grpc-gateway. DO NOT EDIT.
|
|
||||||
// source: vulcanize/registry/v1beta1/tx.proto
|
|
||||||
|
|
||||||
/*
|
|
||||||
Package types is a reverse proxy.
|
|
||||||
|
|
||||||
It translates gRPC into RESTful JSON APIs.
|
|
||||||
*/
|
|
||||||
package types
|
|
||||||
|
|
||||||
import (
|
|
||||||
"context"
|
|
||||||
"io"
|
|
||||||
"net/http"
|
|
||||||
|
|
||||||
"github.com/golang/protobuf/descriptor"
|
|
||||||
"github.com/golang/protobuf/proto"
|
|
||||||
"github.com/grpc-ecosystem/grpc-gateway/runtime"
|
|
||||||
"github.com/grpc-ecosystem/grpc-gateway/utilities"
|
|
||||||
"google.golang.org/grpc"
|
|
||||||
"google.golang.org/grpc/codes"
|
|
||||||
"google.golang.org/grpc/grpclog"
|
|
||||||
"google.golang.org/grpc/metadata"
|
|
||||||
"google.golang.org/grpc/status"
|
|
||||||
)
|
|
||||||
|
|
||||||
// Suppress "imported and not used" errors
|
|
||||||
var _ codes.Code
|
|
||||||
var _ io.Reader
|
|
||||||
var _ status.Status
|
|
||||||
var _ = runtime.String
|
|
||||||
var _ = utilities.NewDoubleArray
|
|
||||||
var _ = descriptor.ForMessage
|
|
||||||
var _ = metadata.Join
|
|
||||||
|
|
||||||
var (
|
|
||||||
filter_Msg_SetRecord_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
|
||||||
)
|
|
||||||
|
|
||||||
func request_Msg_SetRecord_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgSetRecord
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_SetRecord_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := client.SetRecord(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func local_request_Msg_SetRecord_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgSetRecord
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_SetRecord_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.SetRecord(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
filter_Msg_RenewRecord_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
|
||||||
)
|
|
||||||
|
|
||||||
func request_Msg_RenewRecord_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgRenewRecord
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_RenewRecord_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := client.RenewRecord(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func local_request_Msg_RenewRecord_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgRenewRecord
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_RenewRecord_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.RenewRecord(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
filter_Msg_AssociateBond_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
|
||||||
)
|
|
||||||
|
|
||||||
func request_Msg_AssociateBond_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgAssociateBond
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_AssociateBond_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := client.AssociateBond(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func local_request_Msg_AssociateBond_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgAssociateBond
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_AssociateBond_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.AssociateBond(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
filter_Msg_DissociateBond_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
|
||||||
)
|
|
||||||
|
|
||||||
func request_Msg_DissociateBond_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgDissociateBond
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_DissociateBond_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := client.DissociateBond(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func local_request_Msg_DissociateBond_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgDissociateBond
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_DissociateBond_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.DissociateBond(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
filter_Msg_DissociateRecords_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
|
||||||
)
|
|
||||||
|
|
||||||
func request_Msg_DissociateRecords_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgDissociateRecords
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_DissociateRecords_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := client.DissociateRecords(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func local_request_Msg_DissociateRecords_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgDissociateRecords
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_DissociateRecords_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.DissociateRecords(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
filter_Msg_ReAssociateRecords_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
|
||||||
)
|
|
||||||
|
|
||||||
func request_Msg_ReAssociateRecords_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgReAssociateRecords
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_ReAssociateRecords_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := client.ReAssociateRecords(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func local_request_Msg_ReAssociateRecords_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgReAssociateRecords
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_ReAssociateRecords_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.ReAssociateRecords(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
filter_Msg_SetName_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
|
||||||
)
|
|
||||||
|
|
||||||
func request_Msg_SetName_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgSetName
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_SetName_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := client.SetName(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func local_request_Msg_SetName_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgSetName
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_SetName_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.SetName(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
filter_Msg_ReserveName_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
|
||||||
)
|
|
||||||
|
|
||||||
func request_Msg_ReserveName_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgReserveAuthority
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_ReserveName_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := client.ReserveName(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func local_request_Msg_ReserveName_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgReserveAuthority
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_ReserveName_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.ReserveName(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
filter_Msg_DeleteName_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
|
||||||
)
|
|
||||||
|
|
||||||
func request_Msg_DeleteName_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgDeleteNameAuthority
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_DeleteName_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := client.DeleteName(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func local_request_Msg_DeleteName_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgDeleteNameAuthority
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_DeleteName_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.DeleteName(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
filter_Msg_SetAuthorityBond_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)}
|
|
||||||
)
|
|
||||||
|
|
||||||
func request_Msg_SetAuthorityBond_0(ctx context.Context, marshaler runtime.Marshaler, client MsgClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgSetAuthorityBond
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_SetAuthorityBond_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := client.SetAuthorityBond(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD))
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
func local_request_Msg_SetAuthorityBond_0(ctx context.Context, marshaler runtime.Marshaler, server MsgServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) {
|
|
||||||
var protoReq MsgSetAuthorityBond
|
|
||||||
var metadata runtime.ServerMetadata
|
|
||||||
|
|
||||||
if err := req.ParseForm(); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_Msg_SetAuthorityBond_0); err != nil {
|
|
||||||
return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err)
|
|
||||||
}
|
|
||||||
|
|
||||||
msg, err := server.SetAuthorityBond(ctx, &protoReq)
|
|
||||||
return msg, metadata, err
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterMsgHandlerServer registers the http handlers for service Msg to "mux".
|
|
||||||
// UnaryRPC :call MsgServer directly.
|
|
||||||
// StreamingRPC :currently unsupported pending https://github.com/grpc/grpc-go/issues/906.
|
|
||||||
// Note that using this registration option will cause many gRPC library features to stop working. Consider using RegisterMsgHandlerFromEndpoint instead.
|
|
||||||
func RegisterMsgHandlerServer(ctx context.Context, mux *runtime.ServeMux, server MsgServer) error {
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_SetRecord_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
var stream runtime.ServerTransportStream
|
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := local_request_Msg_SetRecord_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_SetRecord_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_RenewRecord_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
var stream runtime.ServerTransportStream
|
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := local_request_Msg_RenewRecord_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_RenewRecord_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_AssociateBond_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
var stream runtime.ServerTransportStream
|
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := local_request_Msg_AssociateBond_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_AssociateBond_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_DissociateBond_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
var stream runtime.ServerTransportStream
|
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := local_request_Msg_DissociateBond_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_DissociateBond_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_DissociateRecords_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
var stream runtime.ServerTransportStream
|
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := local_request_Msg_DissociateRecords_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_DissociateRecords_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_ReAssociateRecords_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
var stream runtime.ServerTransportStream
|
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := local_request_Msg_ReAssociateRecords_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_ReAssociateRecords_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_SetName_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
var stream runtime.ServerTransportStream
|
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := local_request_Msg_SetName_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_SetName_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_ReserveName_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
var stream runtime.ServerTransportStream
|
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := local_request_Msg_ReserveName_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_ReserveName_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_DeleteName_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
var stream runtime.ServerTransportStream
|
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := local_request_Msg_DeleteName_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_DeleteName_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_SetAuthorityBond_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
var stream runtime.ServerTransportStream
|
|
||||||
ctx = grpc.NewContextWithServerTransportStream(ctx, &stream)
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := local_request_Msg_SetAuthorityBond_0(rctx, inboundMarshaler, server, req, pathParams)
|
|
||||||
md.HeaderMD, md.TrailerMD = metadata.Join(md.HeaderMD, stream.Header()), metadata.Join(md.TrailerMD, stream.Trailer())
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_SetAuthorityBond_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterMsgHandlerFromEndpoint is same as RegisterMsgHandler but
|
|
||||||
// automatically dials to "endpoint" and closes the connection when "ctx" gets done.
|
|
||||||
func RegisterMsgHandlerFromEndpoint(ctx context.Context, mux *runtime.ServeMux, endpoint string, opts []grpc.DialOption) (err error) {
|
|
||||||
conn, err := grpc.Dial(endpoint, opts...)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
defer func() {
|
|
||||||
if err != nil {
|
|
||||||
if cerr := conn.Close(); cerr != nil {
|
|
||||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
go func() {
|
|
||||||
<-ctx.Done()
|
|
||||||
if cerr := conn.Close(); cerr != nil {
|
|
||||||
grpclog.Infof("Failed to close conn to %s: %v", endpoint, cerr)
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
}()
|
|
||||||
|
|
||||||
return RegisterMsgHandler(ctx, mux, conn)
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterMsgHandler registers the http handlers for service Msg to "mux".
|
|
||||||
// The handlers forward requests to the grpc endpoint over "conn".
|
|
||||||
func RegisterMsgHandler(ctx context.Context, mux *runtime.ServeMux, conn *grpc.ClientConn) error {
|
|
||||||
return RegisterMsgHandlerClient(ctx, mux, NewMsgClient(conn))
|
|
||||||
}
|
|
||||||
|
|
||||||
// RegisterMsgHandlerClient registers the http handlers for service Msg
|
|
||||||
// to "mux". The handlers forward requests to the grpc endpoint over the given implementation of "MsgClient".
|
|
||||||
// Note: the gRPC framework executes interceptors within the gRPC handler. If the passed in "MsgClient"
|
|
||||||
// doesn't go through the normal gRPC flow (creating a gRPC client etc.) then it will be up to the passed in
|
|
||||||
// "MsgClient" to call the correct interceptors.
|
|
||||||
func RegisterMsgHandlerClient(ctx context.Context, mux *runtime.ServeMux, client MsgClient) error {
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_SetRecord_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := request_Msg_SetRecord_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_SetRecord_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_RenewRecord_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := request_Msg_RenewRecord_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_RenewRecord_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_AssociateBond_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := request_Msg_AssociateBond_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_AssociateBond_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_DissociateBond_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := request_Msg_DissociateBond_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_DissociateBond_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_DissociateRecords_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := request_Msg_DissociateRecords_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_DissociateRecords_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_ReAssociateRecords_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := request_Msg_ReAssociateRecords_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_ReAssociateRecords_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_SetName_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := request_Msg_SetName_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_SetName_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_ReserveName_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := request_Msg_ReserveName_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_ReserveName_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_DeleteName_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := request_Msg_DeleteName_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_DeleteName_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
mux.Handle("POST", pattern_Msg_SetAuthorityBond_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) {
|
|
||||||
ctx, cancel := context.WithCancel(req.Context())
|
|
||||||
defer cancel()
|
|
||||||
inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req)
|
|
||||||
rctx, err := runtime.AnnotateContext(ctx, mux, req)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
resp, md, err := request_Msg_SetAuthorityBond_0(rctx, inboundMarshaler, client, req, pathParams)
|
|
||||||
ctx = runtime.NewServerMetadataContext(ctx, md)
|
|
||||||
if err != nil {
|
|
||||||
runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
forward_Msg_SetAuthorityBond_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...)
|
|
||||||
|
|
||||||
})
|
|
||||||
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
|
||||||
pattern_Msg_SetRecord_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "registry", "v1beta1", "set_record"}, "", runtime.AssumeColonVerbOpt(false)))
|
|
||||||
|
|
||||||
pattern_Msg_RenewRecord_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "registry", "v1beta1", "renew_record"}, "", runtime.AssumeColonVerbOpt(false)))
|
|
||||||
|
|
||||||
pattern_Msg_AssociateBond_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "registry", "v1beta1", "associate_bond"}, "", runtime.AssumeColonVerbOpt(false)))
|
|
||||||
|
|
||||||
pattern_Msg_DissociateBond_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "registry", "v1beta1", "dissociate_bond"}, "", runtime.AssumeColonVerbOpt(false)))
|
|
||||||
|
|
||||||
pattern_Msg_DissociateRecords_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "registry", "v1beta1", "dissociate_records"}, "", runtime.AssumeColonVerbOpt(false)))
|
|
||||||
|
|
||||||
pattern_Msg_ReAssociateRecords_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "registry", "v1beta1", "reassociate_records"}, "", runtime.AssumeColonVerbOpt(false)))
|
|
||||||
|
|
||||||
pattern_Msg_SetName_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "registry", "v1beta1", "set_name"}, "", runtime.AssumeColonVerbOpt(false)))
|
|
||||||
|
|
||||||
pattern_Msg_ReserveName_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "registry", "v1beta1", "reserve_name"}, "", runtime.AssumeColonVerbOpt(false)))
|
|
||||||
|
|
||||||
pattern_Msg_DeleteName_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "registry", "v1beta1", "delete_name"}, "", runtime.AssumeColonVerbOpt(false)))
|
|
||||||
|
|
||||||
pattern_Msg_SetAuthorityBond_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1, 2, 2, 2, 3}, []string{"vulcanize", "registry", "v1beta1", "set_authority_bond"}, "", runtime.AssumeColonVerbOpt(false)))
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
|
||||||
forward_Msg_SetRecord_0 = runtime.ForwardResponseMessage
|
|
||||||
|
|
||||||
forward_Msg_RenewRecord_0 = runtime.ForwardResponseMessage
|
|
||||||
|
|
||||||
forward_Msg_AssociateBond_0 = runtime.ForwardResponseMessage
|
|
||||||
|
|
||||||
forward_Msg_DissociateBond_0 = runtime.ForwardResponseMessage
|
|
||||||
|
|
||||||
forward_Msg_DissociateRecords_0 = runtime.ForwardResponseMessage
|
|
||||||
|
|
||||||
forward_Msg_ReAssociateRecords_0 = runtime.ForwardResponseMessage
|
|
||||||
|
|
||||||
forward_Msg_SetName_0 = runtime.ForwardResponseMessage
|
|
||||||
|
|
||||||
forward_Msg_ReserveName_0 = runtime.ForwardResponseMessage
|
|
||||||
|
|
||||||
forward_Msg_DeleteName_0 = runtime.ForwardResponseMessage
|
|
||||||
|
|
||||||
forward_Msg_SetAuthorityBond_0 = runtime.ForwardResponseMessage
|
|
||||||
)
|
|
@ -4,7 +4,7 @@ import (
|
|||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
|
|
||||||
"github.com/cerc-io/laconicd/x/registry/helpers"
|
"github.com/cerc-io/laconicd/x/registry/helpers"
|
||||||
"github.com/gibson042/canonicaljson-go"
|
canonicalJson "github.com/gibson042/canonicaljson-go"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
@ -13,16 +13,10 @@ const (
|
|||||||
AuthorityUnderAuction = "auction"
|
AuthorityUnderAuction = "auction"
|
||||||
)
|
)
|
||||||
|
|
||||||
// TODO if schema records are to be more permissive than allowing a map of fields, this type will
|
|
||||||
// become specific to content records. schema records will either occupy a new message or have new
|
|
||||||
// more general purpose helper types.
|
|
||||||
|
|
||||||
type AttributeMap map[string]interface{}
|
|
||||||
|
|
||||||
// ReadablePayload represents a signed record payload that can be serialized from/to YAML.
|
// ReadablePayload represents a signed record payload that can be serialized from/to YAML.
|
||||||
type ReadablePayload struct {
|
type ReadablePayload struct {
|
||||||
RecordAttributes AttributeMap `json:"record" yaml:"record"`
|
Record map[string]interface{} `json:"record"`
|
||||||
Signatures []Signature `json:"signatures" yaml:"signatures"`
|
Signatures []Signature `json:"signatures"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadableRecord represents a WNS record.
|
// ReadableRecord represents a WNS record.
|
||||||
@ -34,22 +28,23 @@ type ReadableRecord struct {
|
|||||||
ExpiryTime string `json:"expiryTime,omitempty"`
|
ExpiryTime string `json:"expiryTime,omitempty"`
|
||||||
Deleted bool `json:"deleted,omitempty"`
|
Deleted bool `json:"deleted,omitempty"`
|
||||||
Owners []string `json:"owners,omitempty"`
|
Owners []string `json:"owners,omitempty"`
|
||||||
Attributes AttributeMap `json:"attributes,omitempty"`
|
Attributes map[string]interface{} `json:"attributes,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToPayload converts PayloadEncodable to Payload object.
|
// ToPayload converts PayloadEncodable to Payload object.
|
||||||
// Why? Because go-amino can't handle maps: https://github.com/tendermint/go-amino/issues/4.
|
// Why? Because go-amino can't handle maps: https://github.com/tendermint/go-amino/issues/4.
|
||||||
func (payloadObj *ReadablePayload) ToPayload() Payload {
|
func (payloadObj *ReadablePayload) ToPayload() Payload {
|
||||||
// Note: record directly contains the attributes here
|
// Note: record directly contains the attributes here
|
||||||
attributes := payloadObj.RecordAttributes
|
attributes := helpers.MarshalMapToJSONBytes(payloadObj.Record)
|
||||||
payload := Payload{
|
payload := Payload{
|
||||||
Record: &Record{
|
Record: &Record{
|
||||||
Deleted: false,
|
Deleted: false,
|
||||||
Owners: nil,
|
Owners: nil,
|
||||||
Attributes: helpers.MustMarshalJSON(attributes),
|
Attributes: attributes,
|
||||||
},
|
},
|
||||||
Signatures: payloadObj.Signatures,
|
Signatures: payloadObj.Signatures,
|
||||||
}
|
}
|
||||||
|
// TODO rm error
|
||||||
return payload
|
return payload
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,28 +52,12 @@ func (payloadObj *ReadablePayload) ToPayload() Payload {
|
|||||||
func (payload Payload) ToReadablePayload() ReadablePayload {
|
func (payload Payload) ToReadablePayload() ReadablePayload {
|
||||||
var encodable ReadablePayload
|
var encodable ReadablePayload
|
||||||
|
|
||||||
encodable.RecordAttributes = helpers.MustUnmarshalJSON[AttributeMap](payload.Record.Attributes)
|
encodable.Record = helpers.UnMarshalMapFromJSONBytes(payload.Record.Attributes)
|
||||||
encodable.Signatures = payload.Signatures
|
encodable.Signatures = payload.Signatures
|
||||||
|
|
||||||
return encodable
|
return encodable
|
||||||
}
|
}
|
||||||
|
|
||||||
// ToRecordObj converts Record to RecordObj.
|
|
||||||
// Why? Because go-amino can't handle maps: https://github.com/tendermint/go-amino/issues/4.
|
|
||||||
func (r *ReadableRecord) ToRecordObj() (Record, error) {
|
|
||||||
var resourceObj Record
|
|
||||||
|
|
||||||
resourceObj.Id = r.ID
|
|
||||||
resourceObj.BondId = r.BondID
|
|
||||||
resourceObj.CreateTime = r.CreateTime
|
|
||||||
resourceObj.ExpiryTime = r.ExpiryTime
|
|
||||||
resourceObj.Deleted = r.Deleted
|
|
||||||
resourceObj.Owners = r.Owners
|
|
||||||
resourceObj.Attributes = helpers.MustMarshalJSON(r.Attributes)
|
|
||||||
|
|
||||||
return resourceObj, nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// ToReadableRecord converts Record to a serializable object
|
// ToReadableRecord converts Record to a serializable object
|
||||||
func (r *Record) ToReadableRecord() ReadableRecord {
|
func (r *Record) ToReadableRecord() ReadableRecord {
|
||||||
var resourceObj ReadableRecord
|
var resourceObj ReadableRecord
|
||||||
@ -90,16 +69,34 @@ func (r *Record) ToReadableRecord() ReadableRecord {
|
|||||||
resourceObj.Deleted = r.Deleted
|
resourceObj.Deleted = r.Deleted
|
||||||
resourceObj.Owners = r.Owners
|
resourceObj.Owners = r.Owners
|
||||||
resourceObj.Names = r.Names
|
resourceObj.Names = r.Names
|
||||||
resourceObj.Attributes = helpers.MustUnmarshalJSON[AttributeMap](r.Attributes)
|
resourceObj.Attributes = helpers.UnMarshalMapFromJSONBytes(r.Attributes)
|
||||||
|
|
||||||
return resourceObj
|
return resourceObj
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ToRecordObj converts Record to RecordObj.
|
||||||
|
// Why? Because go-amino can't handle maps: https://github.com/tendermint/go-amino/issues/4.
|
||||||
|
func (r *ReadableRecord) ToRecordObj() (Record, error) {
|
||||||
|
attributes := helpers.MarshalMapToJSONBytes(r.Attributes)
|
||||||
|
|
||||||
|
var resourceObj Record
|
||||||
|
|
||||||
|
resourceObj.Id = r.ID
|
||||||
|
resourceObj.BondId = r.BondID
|
||||||
|
resourceObj.CreateTime = r.CreateTime
|
||||||
|
resourceObj.ExpiryTime = r.ExpiryTime
|
||||||
|
resourceObj.Deleted = r.Deleted
|
||||||
|
resourceObj.Owners = r.Owners
|
||||||
|
resourceObj.Attributes = attributes
|
||||||
|
|
||||||
|
return resourceObj, nil
|
||||||
|
}
|
||||||
|
|
||||||
// CanonicalJSON returns the canonical JSON representation of the record.
|
// CanonicalJSON returns the canonical JSON representation of the record.
|
||||||
func (r *ReadableRecord) CanonicalJSON() []byte {
|
func (r *ReadableRecord) CanonicalJSON() []byte {
|
||||||
bytes, err := canonicaljson.Marshal(r.Attributes)
|
bytes, err := canonicalJson.Marshal(r.Attributes)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic("error marshaling record: " + err.Error())
|
panic("Record marshal error.")
|
||||||
}
|
}
|
||||||
|
|
||||||
return bytes
|
return bytes
|
||||||
|
Loading…
Reference in New Issue
Block a user