Compare commits
193 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 23f0212a16 | |||
| cb58a62ff7 | |||
| cc8be3bce2 | |||
| a2c6abd3dd | |||
| d289c46e87 | |||
| a6aba3defd | |||
| 6557be3738 | |||
| 7134755073 | |||
| dd1420a65a | |||
| df1bc60464 | |||
| 865e809342 | |||
| 51f9c1ca29 | |||
| 303b014a59 | |||
| e1e20fb13e | |||
| 0c3c13ae88 | |||
| 8c8b7d71d0 | |||
| 3163c5f054 | |||
| 4a1794b2f1 | |||
| 1898b8ed96 | |||
| a23471859d | |||
| 9d8c9edf22 | |||
| 5ea7b24efc | |||
| a43a24faa8 | |||
| 39ee215005 | |||
| ef7961f58e | |||
| e628338b33 | |||
| 1bb137f87f | |||
| 773f9e5ead | |||
| 79f695f138 | |||
| 3aabbcf876 | |||
| d96b7408db | |||
| 728b0f4549 | |||
| 0a37c81709 | |||
| 957cbb45b0 | |||
| 8ec074cb1f | |||
| ab5740087f | |||
| 6af59c303e | |||
| 27b384e034 | |||
| 7f5ce3ffeb | |||
| 89b6667c75 | |||
| a94a9aeaf5 | |||
| 6bc8b88a20 | |||
| 21f3991714 | |||
| cd8eba988a | |||
| d2b3841bbd | |||
| de877fb337 | |||
| d4c2b9060f | |||
| 41ac866729 | |||
| a7afd2a1c7 | |||
| df03daf2cc | |||
| b3f5a4f496 | |||
| d080d661f7 | |||
| 6deb481e5d | |||
| 5b98e18a4e | |||
| 506a0da89c | |||
| c7fdcf0a79 | |||
| f7d38a7ec6 | |||
| 8edc762df9 | |||
| 4459aca933 | |||
| 5b84c58985 | |||
| 4301d91f6c | |||
| 03d28c115e | |||
| 7b15f350cd | |||
| 2b4917b8b1 | |||
| de78ca8d9b | |||
| 58d09e382a | |||
| 0cef12d05b | |||
| 30e73ee795 | |||
| d918b69664 | |||
| 921e558660 | |||
| b3b8d2ab46 | |||
| d62638b8e2 | |||
| 67130a1289 | |||
| 0dabff72bd | |||
| e8e2f195e6 | |||
| fa354016e0 | |||
| 935ee765e9 | |||
| 4c8e59e6fc | |||
| 067f3e6f1a | |||
| 6f09d46dce | |||
| bdef48331b | |||
| 51a6936e51 | |||
| fd456d2952 | |||
| eee1abe593 | |||
| fffad43937 | |||
| 3a79f43a8d | |||
| 2e495f87ab | |||
| 57a9f18f5a | |||
| 0c6a0a9cae | |||
| c80d8d354a | |||
| 3f544dbc69 | |||
| d1e1f15db0 | |||
| 651c314182 | |||
| b957b939cf | |||
| a57545521d | |||
| da60606921 | |||
| 14f9bf7234 | |||
| c1fa92869a | |||
| c8533e3ec8 | |||
| 06c4dd601d | |||
| 4ff80bbab2 | |||
| d7220b1fec | |||
| d92df9ada3 | |||
| 9c19ae322d | |||
| 07893828d8 | |||
| 1167f50543 | |||
| ba1818a903 | |||
| e631219a73 | |||
| 207c6cf2c7 | |||
| c5ece97872 | |||
| 8a2c95d044 | |||
| ba5e3d4efa | |||
| c81623a61a | |||
| 8bb42c2b1b | |||
| 33e161bd59 | |||
| 0233499036 | |||
| a059a29173 | |||
| 83c3398570 | |||
| 93f931459a | |||
| 5a7b19aeb6 | |||
| b901655591 | |||
| a9fdbccb82 | |||
| 9ca3f69aa8 | |||
| c485934b06 | |||
| d62e13c932 | |||
| 47f7a5f795 | |||
| f29200431f | |||
| 0912627e1f | |||
| 70fdcc9be0 | |||
| 90da6f152b | |||
| ad547e516a | |||
| 61c0092f27 | |||
| 851b80aaab | |||
| 1397662fc9 | |||
| 1847c8fe73 | |||
| 8ffe3adf0d | |||
| 3e517b461c | |||
| e42e4ddb9b | |||
| a31f51b7ca | |||
| c41a600bcb | |||
| 7aa34391fb | |||
| f72b56d07e | |||
| 44ddbf9ac3 | |||
| 27c377860a | |||
| 9a3f60f224 | |||
| 5776600db3 | |||
| e851ad8b27 | |||
| 2e0e319511 | |||
| 6dd3e36acb | |||
| 40cbfccb73 | |||
| b49681ef1d | |||
| 7e9409bbef | |||
| a11e674967 | |||
| 2f4e505aac | |||
| 90d8e5305f | |||
| 81a678f9e2 | |||
| 0a4bbf2573 | |||
| 2ae5ebb8cb | |||
| 11be1f8e3e | |||
| 513baba3fd | |||
| 21b87f6af5 | |||
| fe59697aa9 | |||
| 566ceae325 | |||
| 6bc4d32573 | |||
| 1fc3c9f31c | |||
| 3cb08a410e | |||
| 1648aef1d3 | |||
| d98b6b107c | |||
| d3db0fc2cd | |||
| 06b823f4c1 | |||
| 1c0ce9a420 | |||
| dede8899cf | |||
| 70f6059ceb | |||
| fefd2dd267 | |||
| 0fbe77d934 | |||
| 8a267cfe3d | |||
| 5ebb2a3efe | |||
| de605dc3b9 | |||
| 6a01edf5fe | |||
| 806b37bd83 | |||
| ffff596d45 | |||
| ad826da782 | |||
| 3414eeea7a | |||
| 3a32d34fb4 | |||
| 248052aec7 | |||
| 90c00fc343 | |||
| 7bdfbfdcc5 | |||
| 44e22b74a5 | |||
| 7920c27648 | |||
| be733fab5a | |||
| 1fc3c2b792 | |||
| f09b984b20 | |||
| f02f914ae2 |
+4
-4
@@ -19,10 +19,10 @@
|
|||||||
Cargo.* @durch @futurechimp @jstuczyn @neacsu @octol
|
Cargo.* @durch @futurechimp @jstuczyn @neacsu @octol
|
||||||
|
|
||||||
# JS rules:
|
# JS rules:
|
||||||
*.js @mmsinclair @fmtabbara @Aid19801
|
*.js @mmsinclair @fmtabbara
|
||||||
*.ts @mmsinclair @fmtabbara @Aid19801
|
*.ts @mmsinclair @fmtabbara
|
||||||
*.tsx @mmsinclair @fmtabbara @Aid19801
|
*.tsx @mmsinclair @fmtabbara
|
||||||
*.jsx @mmsinclair @fmtabbara @Aid19801
|
*.jsx @mmsinclair @fmtabbara
|
||||||
|
|
||||||
# Something looking like possible documentation rules:
|
# Something looking like possible documentation rules:
|
||||||
*.md @mfahampshire
|
*.md @mfahampshire
|
||||||
|
|||||||
@@ -0,0 +1,36 @@
|
|||||||
|
name: Daily security audit
|
||||||
|
|
||||||
|
on: workflow_dispatch
|
||||||
|
jobs:
|
||||||
|
security_audit:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- uses: actions-rs/audit-check@v1
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
notification:
|
||||||
|
if: ${{ failure() }}
|
||||||
|
needs: security_audit
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Keybase - Node Install
|
||||||
|
run: npm install
|
||||||
|
working-directory: .github/workflows/support-files
|
||||||
|
- name: Keybase - Send Notification
|
||||||
|
env:
|
||||||
|
NYM_NOTIFICATION_KIND: nightly
|
||||||
|
NYM_PROJECT_NAME: "Nym daily audit"
|
||||||
|
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
GIT_COMMIT_MESSAGE: "${{ github.event.head_commit.message }}"
|
||||||
|
GIT_BRANCH: "${GITHUB_REF##*/}"
|
||||||
|
KEYBASE_NYMBOT_USERNAME: "${{ secrets.KEYBASE_NYMBOT_USERNAME }}"
|
||||||
|
KEYBASE_NYMBOT_PAPERKEY: "${{ secrets.KEYBASE_NYMBOT_PAPERKEY }}"
|
||||||
|
KEYBASE_NYMBOT_TEAM: "${{ secrets.KEYBASE_NYMBTECH_TEAM }}"
|
||||||
|
KEYBASE_NYM_CHANNEL: "test"
|
||||||
|
uses: docker://keybaseio/client:stable-node
|
||||||
|
with:
|
||||||
|
args: .github/workflows/support-files/notifications/entry_point.sh
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
name: CI for Network Explorer
|
name: CI for Network Explorer
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
push:
|
push:
|
||||||
paths:
|
paths:
|
||||||
- 'explorer/**'
|
- 'explorer/**'
|
||||||
@@ -75,3 +76,14 @@ jobs:
|
|||||||
uses: docker://keybaseio/client:stable-node
|
uses: docker://keybaseio/client:stable-node
|
||||||
with:
|
with:
|
||||||
args: .github/workflows/support-files/notifications/entry_point.sh
|
args: .github/workflows/support-files/notifications/entry_point.sh
|
||||||
|
- name: Deploy
|
||||||
|
if: github.event_name == 'workflow_dispatch'
|
||||||
|
uses: easingthemes/ssh-deploy@main
|
||||||
|
env:
|
||||||
|
SSH_PRIVATE_KEY: ${{ secrets.CD_PROD_NE_SSH_PRIVATE_KEY }}
|
||||||
|
ARGS: "-rltgoDzvO --delete"
|
||||||
|
SOURCE: "explorer/dist/"
|
||||||
|
REMOTE_HOST: ${{ secrets.CD_PROD_NE_REMOTE_HOST }}
|
||||||
|
REMOTE_USER: ${{ secrets.CD_PROD_NE_REMOTE_USER }}
|
||||||
|
TARGET: ${{ secrets.CD_PROD_NE_REMOTE_TARGET }}
|
||||||
|
EXCLUDE: "/dist/, /node_modules/"
|
||||||
|
|||||||
@@ -0,0 +1,50 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"os":"ubuntu-latest",
|
||||||
|
"rust":"stable",
|
||||||
|
"runOnEvent":"workflow_dispatch"
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"os":"windows-latest",
|
||||||
|
"rust":"stable",
|
||||||
|
"runOnEvent":"workflow_dispatch"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"os":"macos-latest",
|
||||||
|
"rust":"stable",
|
||||||
|
"runOnEvent":"workflow_dispatch"
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"os":"ubuntu-latest",
|
||||||
|
"rust":"beta",
|
||||||
|
"runOnEvent":"workflow_dispatch"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"os":"windows-latest",
|
||||||
|
"rust":"beta",
|
||||||
|
"runOnEvent":"workflow_dispatch"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"os":"macos-latest",
|
||||||
|
"rust":"beta",
|
||||||
|
"runOnEvent":"workflow_dispatch"
|
||||||
|
},
|
||||||
|
|
||||||
|
{
|
||||||
|
"os":"ubuntu-latest",
|
||||||
|
"rust":"nightly",
|
||||||
|
"runOnEvent":"workflow_dispatch"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"os":"windows-latest",
|
||||||
|
"rust":"nightly",
|
||||||
|
"runOnEvent":"workflow_dispatch"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"os":"macos-latest",
|
||||||
|
"rust":"nightly",
|
||||||
|
"runOnEvent":"workflow_dispatch"
|
||||||
|
}
|
||||||
|
]
|
||||||
@@ -0,0 +1,174 @@
|
|||||||
|
name: Nightly builds on dispatch
|
||||||
|
|
||||||
|
on: workflow_dispatch
|
||||||
|
jobs:
|
||||||
|
matrix_prep:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||||
|
steps:
|
||||||
|
# creates the matrix strategy from nightly_build_matrix_includes.json
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- id: set-matrix
|
||||||
|
uses: JoshuaTheMiller/conditional-build-matrix@main
|
||||||
|
with:
|
||||||
|
inputFile: '.github/workflows/nightly_build_matrix_on_dispatch.json'
|
||||||
|
filter: '[?runOnEvent==`${{ github.event_name }}` || runOnEvent==`always`]'
|
||||||
|
build:
|
||||||
|
needs: matrix_prep
|
||||||
|
strategy:
|
||||||
|
matrix: ${{fromJson(needs.matrix_prep.outputs.matrix)}}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
continue-on-error: ${{ matrix.rust == 'nightly' || matrix.rust == 'beta' || matrix.rust == 'stable' }}
|
||||||
|
steps:
|
||||||
|
- name: Install Dependencies (Linux)
|
||||||
|
run: sudo apt-get update && sudo apt-get install libwebkit2gtk-4.0-dev build-essential curl wget libssl-dev libgtk-3-dev squashfs-tools
|
||||||
|
if: matrix.os == 'ubuntu-latest'
|
||||||
|
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
|
||||||
|
- name: Install rust toolchain
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
profile: minimal
|
||||||
|
toolchain: ${{ matrix.rust }}
|
||||||
|
override: true
|
||||||
|
components: rustfmt, clippy
|
||||||
|
|
||||||
|
- name: Build all binaries
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: build
|
||||||
|
args: --workspace
|
||||||
|
|
||||||
|
- name: Run all tests
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
args: --workspace
|
||||||
|
|
||||||
|
- name: Reclaim some disk space (because Windows is being annoying)
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
if: ${{ matrix.os == 'windows-latest' }}
|
||||||
|
with:
|
||||||
|
command: clean
|
||||||
|
|
||||||
|
- name: Run expensive tests
|
||||||
|
if: github.ref == 'refs/heads/develop' || github.event.pull_request.base.ref == 'develop' || github.event.pull_request.base.ref == 'master'
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
args: --workspace --all-features -- --ignored
|
||||||
|
|
||||||
|
- name: Check formatting
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: fmt
|
||||||
|
args: --all -- --check
|
||||||
|
|
||||||
|
- name: Reclaim some disk space (because Windows is being annoying)
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
if: ${{ matrix.os == 'windows-latest' }}
|
||||||
|
with:
|
||||||
|
command: clean
|
||||||
|
|
||||||
|
- uses: actions-rs/clippy-check@v1
|
||||||
|
name: Clippy checks
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
args: --all-features
|
||||||
|
|
||||||
|
- name: Run clippy
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
if: ${{ matrix.rust != 'nightly' }}
|
||||||
|
with:
|
||||||
|
command: clippy
|
||||||
|
args: --workspace --all-targets -- -D warnings
|
||||||
|
|
||||||
|
- name: Reclaim some disk space
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
if: ${{ matrix.os == 'windows-latest' || matrix.os == 'ubuntu-latest' }}
|
||||||
|
with:
|
||||||
|
command: clean
|
||||||
|
|
||||||
|
# COCONUT stuff
|
||||||
|
- name: Build all binaries with coconut enabled
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: build
|
||||||
|
args: --workspace --features=coconut
|
||||||
|
|
||||||
|
- name: Run all tests with coconut enabled
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
args: --workspace --features=coconut
|
||||||
|
|
||||||
|
- name: Reclaim some disk space (because Windows is being annoying)
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
if: ${{ matrix.os == 'windows-latest' }}
|
||||||
|
with:
|
||||||
|
command: clean
|
||||||
|
|
||||||
|
- name: Run clippy with coconut enabled
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
if: ${{ matrix.rust != 'nightly' }}
|
||||||
|
with:
|
||||||
|
command: clippy
|
||||||
|
args: --workspace --all-targets --features=coconut -- -D warnings
|
||||||
|
|
||||||
|
# nym-wallet (the rust part)
|
||||||
|
- name: Build nym-wallet rust code
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: build
|
||||||
|
args: --manifest-path nym-wallet/Cargo.toml --workspace
|
||||||
|
|
||||||
|
- name: Run nym-wallet tests
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: test
|
||||||
|
args: --manifest-path nym-wallet/Cargo.toml --workspace
|
||||||
|
|
||||||
|
- name: Check nym-wallet formatting
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
with:
|
||||||
|
command: fmt
|
||||||
|
args: --manifest-path nym-wallet/Cargo.toml --all -- --check
|
||||||
|
|
||||||
|
- name: Run clippy for nym-wallet
|
||||||
|
uses: actions-rs/cargo@v1
|
||||||
|
if: ${{ matrix.rust != 'nightly' }}
|
||||||
|
with:
|
||||||
|
command: clippy
|
||||||
|
args: --manifest-path nym-wallet/Cargo.toml --workspace --all-targets -- -D warnings
|
||||||
|
|
||||||
|
notification:
|
||||||
|
needs: build
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Collect jobs status
|
||||||
|
uses: technote-space/workflow-conclusion-action@v2
|
||||||
|
- name: Check out repository code
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Keybase - Node Install
|
||||||
|
if: env.WORKFLOW_CONCLUSION == 'failure'
|
||||||
|
run: npm install
|
||||||
|
working-directory: .github/workflows/support-files
|
||||||
|
- name: Keybase - Send Notification
|
||||||
|
if: env.WORKFLOW_CONCLUSION == 'failure'
|
||||||
|
env:
|
||||||
|
NYM_NOTIFICATION_KIND: nightly
|
||||||
|
NYM_PROJECT_NAME: "Nym nightly build"
|
||||||
|
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
GIT_COMMIT_MESSAGE: "${{ github.event.head_commit.message }}"
|
||||||
|
GIT_BRANCH: "${GITHUB_REF##*/}"
|
||||||
|
KEYBASE_NYMBOT_USERNAME: "${{ secrets.KEYBASE_NYMBOT_USERNAME }}"
|
||||||
|
KEYBASE_NYMBOT_PAPERKEY: "${{ secrets.KEYBASE_NYMBOT_PAPERKEY }}"
|
||||||
|
KEYBASE_NYMBOT_TEAM: "${{ secrets.KEYBASE_NYMTECH_TEAM }}"
|
||||||
|
KEYBASE_NYM_CHANNEL: "test"
|
||||||
|
IS_SUCCESS: "${{ env.WORKFLOW_CONCLUSION == 'success' }}"
|
||||||
|
uses: docker://keybaseio/client:stable-node
|
||||||
|
with:
|
||||||
|
args: .github/workflows/support-files/notifications/entry_point.sh
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
name: Publish Nym CLI binaries
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
release:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
env:
|
||||||
|
NETWORK: mainnet
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
publish-nym-cli:
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
platform: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
|
||||||
|
runs-on: ${{ matrix.platform }}
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Check the release tag starts with `nym-cli-`
|
||||||
|
if: startsWith(github.ref, 'refs/tags/nym-cli-') == false && github.event_name != 'workflow_dispatch'
|
||||||
|
uses: actions/github-script@v3
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
core.setFailed('Release tag did not start with nym-cli-...')
|
||||||
|
|
||||||
|
- name: Install Rust stable
|
||||||
|
uses: actions-rs/toolchain@v1
|
||||||
|
with:
|
||||||
|
toolchain: stable
|
||||||
|
|
||||||
|
- name: Build binary
|
||||||
|
run: make build-nym-cli
|
||||||
|
|
||||||
|
- name: Upload Artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: nym-cli-${{ matrix.platform }}
|
||||||
|
path: |
|
||||||
|
target/release/nym-cli*
|
||||||
|
retention-days: 30
|
||||||
|
|
||||||
|
- name: Upload to release based on tag name
|
||||||
|
uses: softprops/action-gh-release@v1
|
||||||
|
if: github.event_name == 'release'
|
||||||
|
with:
|
||||||
|
files: |
|
||||||
|
target/release/nym-cli
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
name: Publish Nym binaries
|
name: Publish Nym binaries
|
||||||
|
|
||||||
on:
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
release:
|
release:
|
||||||
types: [created]
|
types: [created]
|
||||||
|
|
||||||
@@ -18,7 +20,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v3
|
||||||
|
|
||||||
- name: Check the release tag starts with `nym-binaries-`
|
- name: Check the release tag starts with `nym-binaries-`
|
||||||
if: startsWith(github.ref, 'refs/tags/nym-binaries-') == false
|
if: startsWith(github.ref, 'refs/tags/nym-binaries-') == false && github.event_name != 'workflow_dispatch'
|
||||||
uses: actions/github-script@v3
|
uses: actions/github-script@v3
|
||||||
with:
|
with:
|
||||||
script: |
|
script: |
|
||||||
@@ -35,8 +37,24 @@ jobs:
|
|||||||
command: build
|
command: build
|
||||||
args: --workspace --release
|
args: --workspace --release
|
||||||
|
|
||||||
|
- name: Upload Artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: my-artifact
|
||||||
|
path: |
|
||||||
|
target/release/nym-client
|
||||||
|
target/release/nym-gateway
|
||||||
|
target/release/nym-mixnode
|
||||||
|
target/release/nym-socks5-client
|
||||||
|
target/release/nym-validator-api
|
||||||
|
target/release/nym-network-requester
|
||||||
|
target/release/nym-network-statistics
|
||||||
|
target/release/nym-cli
|
||||||
|
retention-days: 30
|
||||||
|
|
||||||
- name: Upload to release based on tag name
|
- name: Upload to release based on tag name
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
|
if: github.event_name == 'release'
|
||||||
with:
|
with:
|
||||||
files: |
|
files: |
|
||||||
target/release/nym-client
|
target/release/nym-client
|
||||||
@@ -45,3 +63,5 @@ jobs:
|
|||||||
target/release/nym-socks5-client
|
target/release/nym-socks5-client
|
||||||
target/release/nym-validator-api
|
target/release/nym-validator-api
|
||||||
target/release/nym-network-requester
|
target/release/nym-network-requester
|
||||||
|
target/release/nym-network-statistics
|
||||||
|
target/release/nym-cli
|
||||||
|
|||||||
+47
-236
@@ -2,13 +2,28 @@
|
|||||||
|
|
||||||
Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
|
## Unreleased
|
||||||
|
|
||||||
## [Unreleased]
|
### Added
|
||||||
|
|
||||||
|
- validator-client: added `query_contract_smart` and `query_contract_raw` on `NymdClient` ([#1558])
|
||||||
|
|
||||||
|
|
||||||
|
### Changed
|
||||||
|
|
||||||
|
- validator-client: made `fee` argument optional for `execute` and `execute_multiple` ([#1541])
|
||||||
|
- wasm-client: fixed build errors on MacOS and changed example JS code to use mainnet ([#1585])
|
||||||
|
|
||||||
|
[#1541]: https://github.com/nymtech/nym/pull/1541
|
||||||
|
[#1558]: https://github.com/nymtech/nym/pull/1558
|
||||||
|
[#1585]: https://github.com/nymtech/nym/pull/1585
|
||||||
|
|
||||||
|
|
||||||
|
## [nym-binaries-1.0.2](https://github.com/nymtech/nym/tree/nym-binaries-1.0.2)
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
|
||||||
- socks5 client/websocket client: add `--force-register-gateway` flag, useful when rerunning init ([#1353])
|
- socks5 client/websocket client: add `--force-register-gateway` flag, useful when rerunning init ([#1353])
|
||||||
- nym-connect: initial proof-of-concept of a UI around the socks5 client was added
|
|
||||||
- all: added network compilation target to `--help` (or `--version`) commands ([#1256]).
|
- all: added network compilation target to `--help` (or `--version`) commands ([#1256]).
|
||||||
- explorer-api: learned how to sum the delegations by owner in a new endpoint.
|
- explorer-api: learned how to sum the delegations by owner in a new endpoint.
|
||||||
- explorer-api: add apy values to `mix_nodes` endpoint
|
- explorer-api: add apy values to `mix_nodes` endpoint
|
||||||
@@ -20,28 +35,45 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https://
|
|||||||
- validator-api: add Swagger to document the REST API ([#1249]).
|
- validator-api: add Swagger to document the REST API ([#1249]).
|
||||||
- validator-api: Added new endpoints for coconut spending flow and communications with coconut & multisig contracts ([#1261])
|
- validator-api: Added new endpoints for coconut spending flow and communications with coconut & multisig contracts ([#1261])
|
||||||
- validator-api: add `uptime`, `estimated_operator_apy`, `estimated_delegators_apy` to `/mixnodes/detailed` endpoint ([#1393])
|
- validator-api: add `uptime`, `estimated_operator_apy`, `estimated_delegators_apy` to `/mixnodes/detailed` endpoint ([#1393])
|
||||||
|
- validator-api: add node info cache storing simulated active set inclusion probabilities
|
||||||
- network-statistics: a new mixnet service that aggregates and exposes anonymized data about mixnet services ([#1328])
|
- network-statistics: a new mixnet service that aggregates and exposes anonymized data about mixnet services ([#1328])
|
||||||
- wallet: when simulating gas costs, an automatic adjustment is being used ([#1388]).
|
|
||||||
- mixnode: Added basic mixnode hardware reporting to the HTTP API ([#1308]).
|
- mixnode: Added basic mixnode hardware reporting to the HTTP API ([#1308]).
|
||||||
- validator-api: endpoint, in coconut mode, for returning the validator-api cosmos address ([#1404]).
|
- validator-api: endpoint, in coconut mode, for returning the validator-api cosmos address ([#1404]).
|
||||||
|
- validator-client: add `denom` argument and add simple test for querying an account balance
|
||||||
|
- gateway, validator-api: Checks for coconut credential double spending attempts, taking the coconut bandwidth contract as source of truth ([#1457])
|
||||||
|
- coconut-bandwidth-contract: Record the state of a coconut credential; create specific proposal for releasing funds ([#1457])
|
||||||
|
- inclusion-probability: add simulator for active set inclusion probability
|
||||||
|
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
||||||
- mixnode, gateway: attempting to determine reconnection backoff to persistently failing mixnode could result in a crash ([#1260])
|
- mixnode, gateway: attempting to determine reconnection backoff to persistently failing mixnode could result in a crash ([#1260])
|
||||||
- mixnode: the mixnode learned how to shutdown gracefully
|
- mixnode: the mixnode learned how to shutdown gracefully
|
||||||
|
- mixnode: listen out for SIGTERM and SIGQUIT too, making it play nicely as a system service.
|
||||||
- native & socks5 clients: fail early when clients try to re-init with a different gateway, which is not supported yet ([#1322])
|
- native & socks5 clients: fail early when clients try to re-init with a different gateway, which is not supported yet ([#1322])
|
||||||
- native & socks5 clients: rerun init will now reuse previous gateway configuration instead of failing ([#1353])
|
- native & socks5 clients: rerun init will now reuse previous gateway configuration instead of failing ([#1353])
|
||||||
- native & socks5 clients: deduplicate big chunks of init logic
|
- native & socks5 clients: deduplicate big chunks of init logic
|
||||||
- validator: fixed local docker-compose setup to work on Apple M1 ([#1329])
|
- validator: fixed local docker-compose setup to work on Apple M1 ([#1329])
|
||||||
|
- explorer-api: listen out for SIGTERM and SIGQUIT too, making it play nicely as a system service ([#1482]).
|
||||||
|
- network-requester: fix filter for suffix-only domains ([#1487])
|
||||||
|
- validator-api: listen out for SIGTERM and SIGQUIT too, making it play nicely as a system service; cleaner shutdown, without panics ([#1496], [#1573]).
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
- nym-connect: reuse config id instead of creating a new id on each connection.
|
|
||||||
- validator-client: created internal `Coin` type that replaces coins from `cosmrs` and `cosmwasm` for API entrypoints [[#1295]]
|
- validator-client: created internal `Coin` type that replaces coins from `cosmrs` and `cosmwasm` for API entrypoints [[#1295]]
|
||||||
- all: updated all `cosmwasm`-related dependencies to `1.0.0` and `cw-storage-plus` to `0.13.4` [[#1318]]
|
- all: updated all `cosmwasm`-related dependencies to `1.0.0` and `cw-storage-plus` to `0.13.4` [[#1318]]
|
||||||
- all: updated `rocket` to `0.5.0-rc.2`.
|
- all: updated `rocket` to `0.5.0-rc.2`.
|
||||||
- network-requester: allow to voluntarily store and send statistical data about the number of bytes the proxied server serves ([#1328])
|
- network-requester: allow to voluntarily store and send statistical data about the number of bytes the proxied server serves ([#1328])
|
||||||
- gateway: allow to voluntarily send statistical data about the number of active inboxes served by a gateway ([#1376])
|
- gateway: allow to voluntarily send statistical data about the number of active inboxes served by a gateway ([#1376])
|
||||||
|
- gateway & mixnode: move detailed build info back to `--version` from `--help`.
|
||||||
|
- socks5 client/websocket client: upgrade to latest clap and switched to declarative commandline parsing.
|
||||||
|
- validator-api: fee payment for multisig operations comes from the gateway account instead of the validator APIs' accounts ([#1419])
|
||||||
|
- multisig-contract: Limit the proposal creating functionality to one address (coconut-bandwidth-contract address) ([#1457])
|
||||||
|
- All binaries and cosmwasm blobs are configured at runtime now; binaries are configured using environment variables or .env files and contracts keep the configuration parameters in storage ([#1463])
|
||||||
|
- gateway, network-statistics: include gateway id in the sent statistical data ([#1478])
|
||||||
|
- network explorer: tweak how active set probability is shown ([#1503])
|
||||||
|
- validator-api: rewarder set update fails without panicking on possible nymd queries ([#1520])
|
||||||
|
- network-requester, socks5 client (nym-connect): send and receive respectively a message error to be displayed about filter check failure ([#1576])
|
||||||
|
|
||||||
|
|
||||||
[#1249]: https://github.com/nymtech/nym/pull/1249
|
[#1249]: https://github.com/nymtech/nym/pull/1249
|
||||||
[#1256]: https://github.com/nymtech/nym/pull/1256
|
[#1256]: https://github.com/nymtech/nym/pull/1256
|
||||||
@@ -59,71 +91,19 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https://
|
|||||||
[#1329]: https://github.com/nymtech/nym/pull/1329
|
[#1329]: https://github.com/nymtech/nym/pull/1329
|
||||||
[#1353]: https://github.com/nymtech/nym/pull/1353
|
[#1353]: https://github.com/nymtech/nym/pull/1353
|
||||||
[#1376]: https://github.com/nymtech/nym/pull/1376
|
[#1376]: https://github.com/nymtech/nym/pull/1376
|
||||||
[#1388]: https://github.com/nymtech/nym/pull/1388
|
|
||||||
[#1393]: https://github.com/nymtech/nym/pull/1393
|
[#1393]: https://github.com/nymtech/nym/pull/1393
|
||||||
[#1404]: https://github.com/nymtech/nym/pull/1404
|
[#1404]: https://github.com/nymtech/nym/pull/1404
|
||||||
|
[#1419]: https://github.com/nymtech/nym/pull/1419
|
||||||
## [nym-contracts-v1.0.1](https://github.com/nymtech/nym/tree/nym-contracts-v1.0.1) (2022-06-22)
|
[#1457]: https://github.com/nymtech/nym/pull/1457
|
||||||
|
[#1463]: https://github.com/nymtech/nym/pull/1463
|
||||||
### Added
|
[#1478]: https://github.com/nymtech/nym/pull/1478
|
||||||
|
[#1482]: https://github.com/nymtech/nym/pull/1482
|
||||||
- mixnet-contract: Added ClaimOperatorReward and ClaimDelegatorReward messages ([#1292])
|
[#1487]: https://github.com/nymtech/nym/pull/1487
|
||||||
- mixnet-contract: Replace all naked `-` with `saturating_sub`.
|
[#1496]: https://github.com/nymtech/nym/pull/1496
|
||||||
- mixnet-contract: Added staking_supply field to ContractStateParams.
|
[#1503]: https://github.com/nymtech/nym/pull/1503
|
||||||
- mixnet-contract: Added a query to get MixnodeBond by identity key ([#1369]).
|
[#1520]: https://github.com/nymtech/nym/pull/1520
|
||||||
- mixnet-contract: Added a query to get GatewayBond by identity key ([#1369]).
|
[#1573]: https://github.com/nymtech/nym/pull/1573
|
||||||
- vesting-contract: Added ClaimOperatorReward and ClaimDelegatorReward messages ([#1292])
|
[#1576]: https://github.com/nymtech/nym/pull/1576
|
||||||
- vesting-contract: Added limit to the amount of tokens one can pledge ([#1331])
|
|
||||||
|
|
||||||
### Fixed
|
|
||||||
|
|
||||||
- mixnet-contract: `estimated_delegator_reward` calculation ([#1284])
|
|
||||||
- mixnet-contract: delegator and operator rewards use lambda and sigma instead of lambda_ticked and sigma_ticked ([#1284])
|
|
||||||
- mixnet-contract: removed `expect` in `query_delegator_reward` and queries containing invalid proxy address should now return a more human-readable error ([#1257])
|
|
||||||
- mixnet-contract: replaced integer division with fixed for performance calculations ([#1284])
|
|
||||||
- mixnet-contract: Under certain circumstances nodes could not be unbonded ([#1255](https://github.com/nymtech/nym/issues/1255)) ([#1258])
|
|
||||||
- mixnet-contract: Using correct staking supply when distributing rewards. ([#1373])
|
|
||||||
- vesting-contract: replaced `checked_sub` with `saturating_sub` to fix the underflow in `get_vesting_tokens` ([#1275])
|
|
||||||
|
|
||||||
|
|
||||||
[#1255]: https://github.com/nymtech/nym/pull/1255
|
|
||||||
[#1257]: https://github.com/nymtech/nym/pull/1257
|
|
||||||
[#1258]: https://github.com/nymtech/nym/pull/1258
|
|
||||||
[#1275]: https://github.com/nymtech/nym/pull/1275
|
|
||||||
[#1284]: https://github.com/nymtech/nym/pull/1284
|
|
||||||
[#1292]: https://github.com/nymtech/nym/pull/1292
|
|
||||||
[#1331]: https://github.com/nymtech/nym/pull/1331
|
|
||||||
[#1369]: https://github.com/nymtech/nym/pull/1369
|
|
||||||
[#1373]: https://github.com/nymtech/nym/pull/1373
|
|
||||||
|
|
||||||
## [nym-wallet-v1.0.6](https://github.com/nymtech/nym/tree/nym-wallet-v1.0.6) (2022-06-21)
|
|
||||||
|
|
||||||
- wallet: undelegating now uses either the mixnet or vesting contract, or both, depending on how delegations were made
|
|
||||||
- wallet: redeeming and compounding now uses both the mixnet and vesting contract
|
|
||||||
- wallet: the wallet backend learned how to archive wallet files
|
|
||||||
- wallet: add ENABLE_QA_MODE environment variable to enable QA mode on built wallet
|
|
||||||
|
|
||||||
## [nym-wallet-v1.0.5](https://github.com/nymtech/nym/tree/nym-wallet-v1.0.5) (2022-06-14)
|
|
||||||
|
|
||||||
- wallet: add simple CLI tool for decrypting and recovering the wallet file.
|
|
||||||
- wallet: added support for multiple accounts ([#1265])
|
|
||||||
- wallet: compound and claim reward endpoints for operators and delegators ([#1302])
|
|
||||||
- wallet: require password to switch accounts
|
|
||||||
- wallet: the wallet backend learned how to keep track of validator name, either hardcoded or by querying the status endpoint.
|
|
||||||
- wallet: new delegation and rewards UI
|
|
||||||
- wallet: show version in nav bar
|
|
||||||
- wallet: contract admin route put back
|
|
||||||
- wallet: staking_supply field to StateParams
|
|
||||||
- wallet: show transaction hash for redeeming or compounding rewards
|
|
||||||
|
|
||||||
[#1265]: https://github.com/nymtech/nym/pull/1265
|
|
||||||
[#1302]: https://github.com/nymtech/nym/pull/1302
|
|
||||||
|
|
||||||
## [nym-wallet-v1.0.4](https://github.com/nymtech/nym/tree/nym-wallet-v1.0.4) (2022-05-04)
|
|
||||||
|
|
||||||
### Changed
|
|
||||||
|
|
||||||
- all: the default behaviour of validator client is changed to use `broadcast_sync` and poll for transaction inclusion instead of using `broadcast_commit` to deal with timeouts ([#1246])
|
|
||||||
|
|
||||||
## [v1.0.1](https://github.com/nymtech/nym/tree/v1.0.1) (2022-05-04)
|
## [v1.0.1](https://github.com/nymtech/nym/tree/v1.0.1) (2022-05-04)
|
||||||
|
|
||||||
@@ -156,77 +136,10 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https://
|
|||||||
|
|
||||||
[Full Changelog](https://github.com/nymtech/nym/compare/nym-wallet-v1.0.3...nym-binaries-1.0.0)
|
[Full Changelog](https://github.com/nymtech/nym/compare/nym-wallet-v1.0.3...nym-binaries-1.0.0)
|
||||||
|
|
||||||
## [nym-wallet-v1.0.3](https://github.com/nymtech/nym/tree/nym-wallet-v1.0.3) (2022-04-25)
|
|
||||||
|
|
||||||
[Full Changelog](https://github.com/nymtech/nym/compare/nym-binaries-1.0.0-rc.2...nym-wallet-v1.0.3)
|
|
||||||
|
|
||||||
**Fixed bugs:**
|
|
||||||
|
|
||||||
- \[Issue\] Wallet 1.0.2 cannot send NYM tokens from a DelayedVestingAccount [\#1215](https://github.com/nymtech/nym/issues/1215)
|
|
||||||
- Main README not showing properly with GitHub dark mode [\#1211](https://github.com/nymtech/nym/issues/1211)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Bugfix - wallet undelegation for vesting accounts [\#1220](https://github.com/nymtech/nym/pull/1220) ([mmsinclair](https://github.com/mmsinclair))
|
|
||||||
- Bugfix/delegation reconcile [\#1219](https://github.com/nymtech/nym/pull/1219) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Bugfix/query proxied pending delegations [\#1218](https://github.com/nymtech/nym/pull/1218) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Using custom gas multiplier in the wallet [\#1217](https://github.com/nymtech/nym/pull/1217) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Feature/vesting accounts support [\#1216](https://github.com/nymtech/nym/pull/1216) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Release/1.0.0 rc.2 [\#1214](https://github.com/nymtech/nym/pull/1214) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- chore: fix dark mode rendering [\#1212](https://github.com/nymtech/nym/pull/1212) ([pwnfoo](https://github.com/pwnfoo))
|
|
||||||
- Feature/spend coconut [\#1210](https://github.com/nymtech/nym/pull/1210) ([neacsu](https://github.com/neacsu))
|
|
||||||
- Bugfix/unique sphinx key [\#1207](https://github.com/nymtech/nym/pull/1207) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Add cache read and write timeouts [\#1206](https://github.com/nymtech/nym/pull/1206) ([durch](https://github.com/durch))
|
|
||||||
- Additional, more informative routes [\#1204](https://github.com/nymtech/nym/pull/1204) ([durch](https://github.com/durch))
|
|
||||||
- Feature/aggregated econ dynamics explorer endpoint [\#1203](https://github.com/nymtech/nym/pull/1203) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Debugging validator [\#1198](https://github.com/nymtech/nym/pull/1198) ([durch](https://github.com/durch))
|
|
||||||
- wallet: expose additional validator configuration functionality to the frontend [\#1195](https://github.com/nymtech/nym/pull/1195) ([octol](https://github.com/octol))
|
|
||||||
- Update rewarding validator address [\#1193](https://github.com/nymtech/nym/pull/1193) ([durch](https://github.com/durch))
|
|
||||||
- Crypto part of the Groth's NIDKG [\#1182](https://github.com/nymtech/nym/pull/1182) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- fix unbond page [\#1180](https://github.com/nymtech/nym/pull/1180) ([tommyv1987](https://github.com/tommyv1987))
|
|
||||||
- Type safe bounds [\#1179](https://github.com/nymtech/nym/pull/1179) ([durch](https://github.com/durch))
|
|
||||||
- Fix delegation paging [\#1174](https://github.com/nymtech/nym/pull/1174) ([durch](https://github.com/durch))
|
|
||||||
- Update binaries to rc version [\#1172](https://github.com/nymtech/nym/pull/1172) ([tommyv1987](https://github.com/tommyv1987))
|
|
||||||
- Bump ansi-regex from 4.1.0 to 4.1.1 in /docker/typescript\_client/upload\_contract [\#1171](https://github.com/nymtech/nym/pull/1171) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
||||||
|
|
||||||
## [nym-binaries-1.0.0-rc.2](https://github.com/nymtech/nym/tree/nym-binaries-1.0.0-rc.2) (2022-04-15)
|
## [nym-binaries-1.0.0-rc.2](https://github.com/nymtech/nym/tree/nym-binaries-1.0.0-rc.2) (2022-04-15)
|
||||||
|
|
||||||
[Full Changelog](https://github.com/nymtech/nym/compare/nym-wallet-v1.0.2...nym-binaries-1.0.0-rc.2)
|
[Full Changelog](https://github.com/nymtech/nym/compare/nym-wallet-v1.0.2...nym-binaries-1.0.0-rc.2)
|
||||||
|
|
||||||
## [nym-wallet-v1.0.2](https://github.com/nymtech/nym/tree/nym-wallet-v1.0.2) (2022-04-05)
|
|
||||||
|
|
||||||
[Full Changelog](https://github.com/nymtech/nym/compare/nym-wallet-v1.0.1...nym-wallet-v1.0.2)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- Wallet 1.0.2 visual tweaks [\#1197](https://github.com/nymtech/nym/pull/1197) ([mmsinclair](https://github.com/mmsinclair))
|
|
||||||
- Password for wallet with routes [\#1196](https://github.com/nymtech/nym/pull/1196) ([fmtabbara](https://github.com/fmtabbara))
|
|
||||||
- Add auto-updater to Nym Wallet [\#1194](https://github.com/nymtech/nym/pull/1194) ([mmsinclair](https://github.com/mmsinclair))
|
|
||||||
- Fix clippy warnings for beta toolchain [\#1191](https://github.com/nymtech/nym/pull/1191) ([octol](https://github.com/octol))
|
|
||||||
- wallet: expose validator urls to the frontend [\#1190](https://github.com/nymtech/nym/pull/1190) ([octol](https://github.com/octol))
|
|
||||||
- wallet: add test for decrypting stored wallet file [\#1189](https://github.com/nymtech/nym/pull/1189) ([octol](https://github.com/octol))
|
|
||||||
- Fix clippy warnings [\#1188](https://github.com/nymtech/nym/pull/1188) ([octol](https://github.com/octol))
|
|
||||||
- Password for wallet with routes [\#1187](https://github.com/nymtech/nym/pull/1187) ([mmsinclair](https://github.com/mmsinclair))
|
|
||||||
- wallet: add validate\_mnemonic [\#1186](https://github.com/nymtech/nym/pull/1186) ([octol](https://github.com/octol))
|
|
||||||
- wallet: support removing accounts from the wallet file [\#1185](https://github.com/nymtech/nym/pull/1185) ([octol](https://github.com/octol))
|
|
||||||
- Feature/adding discord [\#1184](https://github.com/nymtech/nym/pull/1184) ([gala1234](https://github.com/gala1234))
|
|
||||||
- wallet: config backend for validator selection [\#1183](https://github.com/nymtech/nym/pull/1183) ([octol](https://github.com/octol))
|
|
||||||
- Add storybook to wallet [\#1178](https://github.com/nymtech/nym/pull/1178) ([mmsinclair](https://github.com/mmsinclair))
|
|
||||||
- wallet: connection test nymd and api urls independently [\#1170](https://github.com/nymtech/nym/pull/1170) ([octol](https://github.com/octol))
|
|
||||||
- wallet: wire up account storage [\#1153](https://github.com/nymtech/nym/pull/1153) ([octol](https://github.com/octol))
|
|
||||||
- Feature/signature on deposit [\#1151](https://github.com/nymtech/nym/pull/1151) ([neacsu](https://github.com/neacsu))
|
|
||||||
|
|
||||||
## [nym-wallet-v1.0.1](https://github.com/nymtech/nym/tree/nym-wallet-v1.0.1) (2022-04-05)
|
|
||||||
|
|
||||||
[Full Changelog](https://github.com/nymtech/nym/compare/nym-binaries-1.0.0-rc.1...nym-wallet-v1.0.1)
|
|
||||||
|
|
||||||
**Closed issues:**
|
|
||||||
|
|
||||||
- Check enabling bbbc simultaneously with open access. Estimate what it would take to make this the default compilation target. [\#1175](https://github.com/nymtech/nym/issues/1175)
|
|
||||||
- Get coconut credential for deposited tokens [\#1138](https://github.com/nymtech/nym/issues/1138)
|
|
||||||
- Make payments lazy [\#1135](https://github.com/nymtech/nym/issues/1135)
|
|
||||||
- Uptime on node selection for sets [\#1049](https://github.com/nymtech/nym/issues/1049)
|
|
||||||
|
|
||||||
## [nym-binaries-1.0.0-rc.1](https://github.com/nymtech/nym/tree/nym-binaries-1.0.0-rc.1) (2022-03-28)
|
## [nym-binaries-1.0.0-rc.1](https://github.com/nymtech/nym/tree/nym-binaries-1.0.0-rc.1) (2022-03-28)
|
||||||
|
|
||||||
[Full Changelog](https://github.com/nymtech/nym/compare/nym-wallet-v1.0.0...nym-binaries-1.0.0-rc.1)
|
[Full Changelog](https://github.com/nymtech/nym/compare/nym-wallet-v1.0.0...nym-binaries-1.0.0-rc.1)
|
||||||
@@ -305,108 +218,6 @@ Post 1.0.0 release, the changelog format is based on [Keep a Changelog](https://
|
|||||||
- feature/pedersen-commitments [\#1048](https://github.com/nymtech/nym/pull/1048) ([danielementary](https://github.com/danielementary))
|
- feature/pedersen-commitments [\#1048](https://github.com/nymtech/nym/pull/1048) ([danielementary](https://github.com/danielementary))
|
||||||
- Feature/reuse init owner [\#970](https://github.com/nymtech/nym/pull/970) ([neacsu](https://github.com/neacsu))
|
- Feature/reuse init owner [\#970](https://github.com/nymtech/nym/pull/970) ([neacsu](https://github.com/neacsu))
|
||||||
|
|
||||||
## [nym-wallet-v1.0.0](https://github.com/nymtech/nym/tree/nym-wallet-v1.0.0) (2022-02-03)
|
|
||||||
|
|
||||||
[Full Changelog](https://github.com/nymtech/nym/compare/v0.12.1...nym-wallet-v1.0.0)
|
|
||||||
|
|
||||||
**Implemented enhancements:**
|
|
||||||
|
|
||||||
- \[Feature Request\] Please enable registration without need for Telegram account [\#1016](https://github.com/nymtech/nym/issues/1016)
|
|
||||||
- Fast mixnode launch with a pre-built ISO + VM software [\#1001](https://github.com/nymtech/nym/issues/1001)
|
|
||||||
|
|
||||||
**Fixed bugs:**
|
|
||||||
|
|
||||||
- \[Issue\] [\#1000](https://github.com/nymtech/nym/issues/1000)
|
|
||||||
- \[Issue\] `nym-client` requires multiple attempts to run a server [\#869](https://github.com/nymtech/nym/issues/869)
|
|
||||||
- De-'float'-ing `Interval` \(`Display` impl + `serde`\) [\#1065](https://github.com/nymtech/nym/pull/1065) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- display client address on wallet creation [\#1058](https://github.com/nymtech/nym/pull/1058) ([fmtabbara](https://github.com/fmtabbara))
|
|
||||||
|
|
||||||
**Closed issues:**
|
|
||||||
|
|
||||||
- Rewarded set inclusion probability API endpoint [\#1037](https://github.com/nymtech/nym/issues/1037)
|
|
||||||
- Update cw-storage-plus to 0.11 [\#1032](https://github.com/nymtech/nym/issues/1032)
|
|
||||||
- Change `u128` fields in `RewardEstimationResponse` to `u64` [\#1029](https://github.com/nymtech/nym/issues/1029)
|
|
||||||
- Test out the mainnet Gravity Bridge [\#1006](https://github.com/nymtech/nym/issues/1006)
|
|
||||||
- Add vesting contract interface to nym-wallet [\#959](https://github.com/nymtech/nym/issues/959)
|
|
||||||
- Mixnode crash [\#486](https://github.com/nymtech/nym/issues/486)
|
|
||||||
|
|
||||||
**Merged pull requests:**
|
|
||||||
|
|
||||||
- create custom urls for mainnet [\#1095](https://github.com/nymtech/nym/pull/1095) ([fmtabbara](https://github.com/fmtabbara))
|
|
||||||
- Wallet signing on MacOS [\#1093](https://github.com/nymtech/nym/pull/1093) ([mmsinclair](https://github.com/mmsinclair))
|
|
||||||
- Fix rust 2018 idioms warnings [\#1092](https://github.com/nymtech/nym/pull/1092) ([octol](https://github.com/octol))
|
|
||||||
- Prevent contract overwriting [\#1090](https://github.com/nymtech/nym/pull/1090) ([durch](https://github.com/durch))
|
|
||||||
- Logout operation [\#1087](https://github.com/nymtech/nym/pull/1087) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Update to rust edition 2021 everywhere [\#1086](https://github.com/nymtech/nym/pull/1086) ([octol](https://github.com/octol))
|
|
||||||
- Tag contract errors, and print out lines for easier QA [\#1084](https://github.com/nymtech/nym/pull/1084) ([durch](https://github.com/durch))
|
|
||||||
- Feature/flexible vesting + utility queries [\#1083](https://github.com/nymtech/nym/pull/1083) ([durch](https://github.com/durch))
|
|
||||||
- Bump @openzeppelin/contracts from 4.3.1 to 4.4.2 in /contracts/basic-bandwidth-generation [\#1082](https://github.com/nymtech/nym/pull/1082) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
||||||
- Bump nth-check from 2.0.0 to 2.0.1 in /clients/native/examples/js-examples/websocket [\#1081](https://github.com/nymtech/nym/pull/1081) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
||||||
- Bump url-parse from 1.5.1 to 1.5.4 in /clients/native/examples/js-examples/websocket [\#1080](https://github.com/nymtech/nym/pull/1080) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
||||||
- Bump follow-redirects from 1.14.1 to 1.14.7 in /clients/native/examples/js-examples/websocket [\#1079](https://github.com/nymtech/nym/pull/1079) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
||||||
- Bump nanoid from 3.1.23 to 3.2.0 in /clients/native/examples/js-examples/websocket [\#1078](https://github.com/nymtech/nym/pull/1078) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
||||||
- Setup basic test for mixnode stats reporting [\#1077](https://github.com/nymtech/nym/pull/1077) ([octol](https://github.com/octol))
|
|
||||||
- Make wallet\_address mandatory for mixnode init [\#1076](https://github.com/nymtech/nym/pull/1076) ([octol](https://github.com/octol))
|
|
||||||
- Tidy nym-mixnode module visibility [\#1075](https://github.com/nymtech/nym/pull/1075) ([octol](https://github.com/octol))
|
|
||||||
- Feature/wallet login with password [\#1074](https://github.com/nymtech/nym/pull/1074) ([fmtabbara](https://github.com/fmtabbara))
|
|
||||||
- Add trait to mock client dependency in DelayForwarder [\#1073](https://github.com/nymtech/nym/pull/1073) ([octol](https://github.com/octol))
|
|
||||||
- Bump rust-version to latest stable for nym-mixnode [\#1072](https://github.com/nymtech/nym/pull/1072) ([octol](https://github.com/octol))
|
|
||||||
- Fixes CI for our wasm build [\#1069](https://github.com/nymtech/nym/pull/1069) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Add @octol as codeowner [\#1068](https://github.com/nymtech/nym/pull/1068) ([octol](https://github.com/octol))
|
|
||||||
- set-up inclusion probability [\#1067](https://github.com/nymtech/nym/pull/1067) ([fmtabbara](https://github.com/fmtabbara))
|
|
||||||
- Feature/wasm client [\#1066](https://github.com/nymtech/nym/pull/1066) ([neacsu](https://github.com/neacsu))
|
|
||||||
- Changed bech32\_prefix from punk to nymt [\#1064](https://github.com/nymtech/nym/pull/1064) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Bump nanoid from 3.1.30 to 3.2.0 in /testnet-faucet [\#1063](https://github.com/nymtech/nym/pull/1063) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
||||||
- Bump nanoid from 3.1.30 to 3.2.0 in /nym-wallet [\#1062](https://github.com/nymtech/nym/pull/1062) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
||||||
- Rework vesting contract storage [\#1061](https://github.com/nymtech/nym/pull/1061) ([durch](https://github.com/durch))
|
|
||||||
- Mixnet Contract constants extraction [\#1060](https://github.com/nymtech/nym/pull/1060) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- fix: make explorer footer year dynamic [\#1059](https://github.com/nymtech/nym/pull/1059) ([martinyung](https://github.com/martinyung))
|
|
||||||
- Add mnemonic just on creation, to display it [\#1057](https://github.com/nymtech/nym/pull/1057) ([neacsu](https://github.com/neacsu))
|
|
||||||
- Network Explorer: updates to API and UI to show the active set [\#1056](https://github.com/nymtech/nym/pull/1056) ([mmsinclair](https://github.com/mmsinclair))
|
|
||||||
- Made contract addresses for query NymdClient construction optional [\#1055](https://github.com/nymtech/nym/pull/1055) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Introduced RPC query for total token supply [\#1053](https://github.com/nymtech/nym/pull/1053) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Feature/tokio console [\#1052](https://github.com/nymtech/nym/pull/1052) ([durch](https://github.com/durch))
|
|
||||||
- Implemented beta clippy lint recommendations [\#1051](https://github.com/nymtech/nym/pull/1051) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- add new function to update profit percentage [\#1050](https://github.com/nymtech/nym/pull/1050) ([fmtabbara](https://github.com/fmtabbara))
|
|
||||||
- Upgrade Clap and use declarative argument parsing for nym-mixnode [\#1047](https://github.com/nymtech/nym/pull/1047) ([octol](https://github.com/octol))
|
|
||||||
- Feature/additional bond validation [\#1046](https://github.com/nymtech/nym/pull/1046) ([fmtabbara](https://github.com/fmtabbara))
|
|
||||||
- Fix clippy on relevant lints [\#1044](https://github.com/nymtech/nym/pull/1044) ([neacsu](https://github.com/neacsu))
|
|
||||||
- Bump shelljs from 0.8.4 to 0.8.5 in /contracts/basic-bandwidth-generation [\#1043](https://github.com/nymtech/nym/pull/1043) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
||||||
- Endpoint for rewarded set inclusion probabilities [\#1042](https://github.com/nymtech/nym/pull/1042) ([durch](https://github.com/durch))
|
|
||||||
- Bump follow-redirects from 1.14.4 to 1.14.7 in /contracts/basic-bandwidth-generation [\#1041](https://github.com/nymtech/nym/pull/1041) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
||||||
- Bump follow-redirects from 1.14.5 to 1.14.7 in /testnet-faucet [\#1040](https://github.com/nymtech/nym/pull/1040) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
||||||
- Feature/node settings update [\#1036](https://github.com/nymtech/nym/pull/1036) ([fmtabbara](https://github.com/fmtabbara))
|
|
||||||
- Migrate to cw-storage-plus 0.11.1 [\#1035](https://github.com/nymtech/nym/pull/1035) ([durch](https://github.com/durch))
|
|
||||||
- Bump @openzeppelin/contracts from 4.4.1 to 4.4.2 in /contracts/basic-bandwidth-generation [\#1034](https://github.com/nymtech/nym/pull/1034) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
||||||
- Feature/configurable wallet [\#1033](https://github.com/nymtech/nym/pull/1033) ([neacsu](https://github.com/neacsu))
|
|
||||||
- Feature/downcast reward estimation [\#1031](https://github.com/nymtech/nym/pull/1031) ([durch](https://github.com/durch))
|
|
||||||
- Wallet UI updates [\#1028](https://github.com/nymtech/nym/pull/1028) ([fmtabbara](https://github.com/fmtabbara))
|
|
||||||
- Remove migration code [\#1027](https://github.com/nymtech/nym/pull/1027) ([neacsu](https://github.com/neacsu))
|
|
||||||
- Chore/stricter dependency requirements [\#1025](https://github.com/nymtech/nym/pull/1025) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Feature/validator api client endpoints [\#1024](https://github.com/nymtech/nym/pull/1024) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Updated cosmrs to 0.4.1 [\#1023](https://github.com/nymtech/nym/pull/1023) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Feature/testnet deploy scripts [\#1022](https://github.com/nymtech/nym/pull/1022) ([mfahampshire](https://github.com/mfahampshire))
|
|
||||||
- Changed wallet's client to a full validator client [\#1021](https://github.com/nymtech/nym/pull/1021) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Fix 404 link [\#1020](https://github.com/nymtech/nym/pull/1020) ([RiccardoMasutti](https://github.com/RiccardoMasutti))
|
|
||||||
- Feature/additional mixnode endpoints [\#1019](https://github.com/nymtech/nym/pull/1019) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Introduced denom check when trying to withdraw vested coins [\#1018](https://github.com/nymtech/nym/pull/1018) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Add network defaults for qa [\#1017](https://github.com/nymtech/nym/pull/1017) ([neacsu](https://github.com/neacsu))
|
|
||||||
- Feature/expanded events [\#1015](https://github.com/nymtech/nym/pull/1015) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- update frontend to use new profit update api [\#1014](https://github.com/nymtech/nym/pull/1014) ([fmtabbara](https://github.com/fmtabbara))
|
|
||||||
- Feature/node state endpoint [\#1013](https://github.com/nymtech/nym/pull/1013) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Feature/hourly set updates [\#1012](https://github.com/nymtech/nym/pull/1012) ([durch](https://github.com/durch))
|
|
||||||
- Feature/remove unused profit margin [\#1011](https://github.com/nymtech/nym/pull/1011) ([neacsu](https://github.com/neacsu))
|
|
||||||
- Feature/explorer node status [\#1010](https://github.com/nymtech/nym/pull/1010) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Use serial integer instead of random [\#1009](https://github.com/nymtech/nym/pull/1009) ([durch](https://github.com/durch))
|
|
||||||
- Feature/configure profit [\#1008](https://github.com/nymtech/nym/pull/1008) ([neacsu](https://github.com/neacsu))
|
|
||||||
- Feature/fix gateway sign [\#1004](https://github.com/nymtech/nym/pull/1004) ([neacsu](https://github.com/neacsu))
|
|
||||||
- Fix clippy [\#1003](https://github.com/nymtech/nym/pull/1003) ([neacsu](https://github.com/neacsu))
|
|
||||||
- Update wallet version [\#998](https://github.com/nymtech/nym/pull/998) ([tommyv1987](https://github.com/tommyv1987))
|
|
||||||
- Fix wallet build instructions [\#997](https://github.com/nymtech/nym/pull/997) ([tommyv1987](https://github.com/tommyv1987))
|
|
||||||
- Make the separation between testnet-mode and erc20 bandwidth mode clearer [\#994](https://github.com/nymtech/nym/pull/994) ([neacsu](https://github.com/neacsu))
|
|
||||||
- Bump @openzeppelin/contracts from 3.4.0 to 4.4.1 in /contracts/basic-bandwidth-generation [\#983](https://github.com/nymtech/nym/pull/983) ([dependabot[bot]](https://github.com/apps/dependabot))
|
|
||||||
- Feature/implicit runtime [\#973](https://github.com/nymtech/nym/pull/973) ([jstuczyn](https://github.com/jstuczyn))
|
|
||||||
- Differentiate staking and ownership [\#961](https://github.com/nymtech/nym/pull/961) ([durch](https://github.com/durch))
|
|
||||||
|
|
||||||
## [v0.12.1](https://github.com/nymtech/nym/tree/v0.12.1) (2021-12-23)
|
## [v0.12.1](https://github.com/nymtech/nym/tree/v0.12.1) (2021-12-23)
|
||||||
|
|
||||||
|
|||||||
Generated
+63
-97
@@ -568,16 +568,16 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap"
|
name = "clap"
|
||||||
version = "3.1.8"
|
version = "3.2.8"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "71c47df61d9e16dc010b55dba1952a57d8c215dbb533fd13cdd13369aac73b1c"
|
checksum = "190814073e85d238f31ff738fcb0bf6910cedeb73376c87cd69291028966fd83"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"atty",
|
"atty",
|
||||||
"bitflags",
|
"bitflags",
|
||||||
"clap_derive",
|
"clap_derive",
|
||||||
|
"clap_lex",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"lazy_static",
|
"once_cell",
|
||||||
"os_str_bytes",
|
|
||||||
"strsim 0.10.0",
|
"strsim 0.10.0",
|
||||||
"termcolor",
|
"termcolor",
|
||||||
"textwrap 0.15.0",
|
"textwrap 0.15.0",
|
||||||
@@ -585,9 +585,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_derive"
|
name = "clap_derive"
|
||||||
version = "3.1.7"
|
version = "3.2.7"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a3aab4734e083b809aaf5794e14e756d1c798d2c69c7f7de7a09a2f5214993c1"
|
checksum = "759bf187376e1afa7b85b959e6a664a3e7a95203415dba952ad19139e798f902"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"heck 0.4.0",
|
"heck 0.4.0",
|
||||||
"proc-macro-error",
|
"proc-macro-error",
|
||||||
@@ -596,6 +596,15 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "clap_lex"
|
||||||
|
version = "0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2850f2f5a82cbf437dd5af4d49848fbdfc27c157c3d010345776f952765261c5"
|
||||||
|
dependencies = [
|
||||||
|
"os_str_bytes",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "client-core"
|
name = "client-core"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
@@ -635,6 +644,7 @@ name = "coconut-bandwidth-contract-common"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cosmwasm-std",
|
"cosmwasm-std",
|
||||||
|
"multisig-contract-common",
|
||||||
"schemars",
|
"schemars",
|
||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
@@ -773,9 +783,8 @@ checksum = "5827cebf4670468b8772dd191856768aedcb1b0278a04f989f7766351917b9dc"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmos-sdk-proto"
|
name = "cosmos-sdk-proto"
|
||||||
version = "0.12.2"
|
version = "0.12.3"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/neacsu/cosmos-rust?branch=neacsu/feegrant_support#f63ded63ec13e753ebe8bdafe9dc503df265d67d"
|
||||||
checksum = "f109fe191e73898d74b8020c50f86018364ad19bc30318aa074616c382b52856"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"prost 0.10.3",
|
"prost 0.10.3",
|
||||||
"prost-types 0.10.1",
|
"prost-types 0.10.1",
|
||||||
@@ -784,9 +793,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cosmrs"
|
name = "cosmrs"
|
||||||
version = "0.7.0"
|
version = "0.7.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/neacsu/cosmos-rust?branch=neacsu/feegrant_support#f63ded63ec13e753ebe8bdafe9dc503df265d67d"
|
||||||
checksum = "8413275b23cb5a0734d9d1e3e33f0b5b94547c1e94776dbc3149dbf46588a533"
|
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bip32",
|
"bip32",
|
||||||
"cosmos-sdk-proto",
|
"cosmos-sdk-proto",
|
||||||
@@ -884,8 +892,9 @@ dependencies = [
|
|||||||
"async-trait",
|
"async-trait",
|
||||||
"bip39",
|
"bip39",
|
||||||
"cfg-if 0.1.10",
|
"cfg-if 0.1.10",
|
||||||
"clap 3.1.8",
|
"clap 3.2.8",
|
||||||
"coconut-interface",
|
"coconut-interface",
|
||||||
|
"config",
|
||||||
"credential-storage",
|
"credential-storage",
|
||||||
"credentials",
|
"credentials",
|
||||||
"crypto",
|
"crypto",
|
||||||
@@ -920,7 +929,6 @@ dependencies = [
|
|||||||
"coconut-interface",
|
"coconut-interface",
|
||||||
"cosmrs",
|
"cosmrs",
|
||||||
"crypto",
|
"crypto",
|
||||||
"network-defaults",
|
|
||||||
"rand 0.7.3",
|
"rand 0.7.3",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"url",
|
"url",
|
||||||
@@ -1343,9 +1351,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "dirs"
|
name = "dirs"
|
||||||
version = "3.0.2"
|
version = "4.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309"
|
checksum = "ca3aa72a6f96ea37bbc5aa912f6788242832f75369bdfdadcb0e38423f100059"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs-sys",
|
"dirs-sys",
|
||||||
]
|
]
|
||||||
@@ -1583,6 +1591,7 @@ name = "explorer-api"
|
|||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
|
"clap 3.2.8",
|
||||||
"humantime-serde",
|
"humantime-serde",
|
||||||
"isocountry",
|
"isocountry",
|
||||||
"itertools",
|
"itertools",
|
||||||
@@ -1598,6 +1607,7 @@ dependencies = [
|
|||||||
"schemars",
|
"schemars",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
|
"task",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
"validator-client",
|
"validator-client",
|
||||||
@@ -1894,10 +1904,6 @@ name = "futures-timer"
|
|||||||
version = "3.0.2"
|
version = "3.0.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c"
|
checksum = "e64b03909df88034c26dc1547e8970b91f98bdb65165d6a4e9110d94263dbb2c"
|
||||||
dependencies = [
|
|
||||||
"gloo-timers",
|
|
||||||
"send_wrapper",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-util"
|
name = "futures-util"
|
||||||
@@ -2082,18 +2088,6 @@ version = "0.3.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "gloo-timers"
|
|
||||||
version = "0.2.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "4d12a7f4e95cfe710f1d624fb1210b7d961a5fb05c4fd942f4feab06e61f590e"
|
|
||||||
dependencies = [
|
|
||||||
"futures-channel",
|
|
||||||
"futures-core",
|
|
||||||
"js-sys",
|
|
||||||
"wasm-bindgen",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "group"
|
name = "group"
|
||||||
version = "0.10.0"
|
version = "0.10.0"
|
||||||
@@ -2487,6 +2481,15 @@ dependencies = [
|
|||||||
"syn",
|
"syn",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "inclusion-probability"
|
||||||
|
version = "0.1.0"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
"rand 0.8.5",
|
||||||
|
"thiserror",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "indenter"
|
name = "indenter"
|
||||||
version = "0.3.3"
|
version = "0.3.3"
|
||||||
@@ -2734,9 +2737,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.16"
|
version = "0.4.17"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "6389c490849ff5bc16be905ae24bc913a9c8892e19b2341dbc175e14c341c2b8"
|
checksum = "abb12e687cfb44aa40f41fc3978ef76448f9b6038cad6aef4259d3c095a2382e"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
]
|
]
|
||||||
@@ -2863,7 +2866,6 @@ dependencies = [
|
|||||||
"cosmwasm-std",
|
"cosmwasm-std",
|
||||||
"fixed",
|
"fixed",
|
||||||
"log",
|
"log",
|
||||||
"network-defaults",
|
|
||||||
"schemars",
|
"schemars",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_repr",
|
"serde_repr",
|
||||||
@@ -2960,6 +2962,7 @@ name = "network-defaults"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
|
"dotenv",
|
||||||
"hex-literal",
|
"hex-literal",
|
||||||
"once_cell",
|
"once_cell",
|
||||||
"serde",
|
"serde",
|
||||||
@@ -3047,9 +3050,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nym-client"
|
name = "nym-client"
|
||||||
version = "1.0.1"
|
version = "1.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap 2.34.0",
|
"clap 3.2.8",
|
||||||
"client-core",
|
"client-core",
|
||||||
"coconut-interface",
|
"coconut-interface",
|
||||||
"config",
|
"config",
|
||||||
@@ -3057,7 +3060,6 @@ dependencies = [
|
|||||||
"credentials",
|
"credentials",
|
||||||
"crypto",
|
"crypto",
|
||||||
"dirs",
|
"dirs",
|
||||||
"dotenv",
|
|
||||||
"futures",
|
"futures",
|
||||||
"gateway-client",
|
"gateway-client",
|
||||||
"gateway-requests",
|
"gateway-requests",
|
||||||
@@ -3082,14 +3084,14 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nym-gateway"
|
name = "nym-gateway"
|
||||||
version = "1.0.1"
|
version = "1.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"bandwidth-claim-contract",
|
"bandwidth-claim-contract",
|
||||||
"bip39",
|
"bip39",
|
||||||
"bs58",
|
"bs58",
|
||||||
"clap 3.1.8",
|
"clap 3.2.8",
|
||||||
"coconut-interface",
|
"coconut-interface",
|
||||||
"colored",
|
"colored",
|
||||||
"config",
|
"config",
|
||||||
@@ -3130,11 +3132,11 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nym-mixnode"
|
name = "nym-mixnode"
|
||||||
version = "1.0.1"
|
version = "1.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"bs58",
|
"bs58",
|
||||||
"clap 3.1.8",
|
"clap 3.2.8",
|
||||||
"colored",
|
"colored",
|
||||||
"config",
|
"config",
|
||||||
"crypto",
|
"crypto",
|
||||||
@@ -3156,7 +3158,6 @@ dependencies = [
|
|||||||
"rand 0.7.3",
|
"rand 0.7.3",
|
||||||
"rocket",
|
"rocket",
|
||||||
"serde",
|
"serde",
|
||||||
"serial_test",
|
|
||||||
"sysinfo",
|
"sysinfo",
|
||||||
"task",
|
"task",
|
||||||
"tokio",
|
"tokio",
|
||||||
@@ -3171,7 +3172,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nym-network-requester"
|
name = "nym-network-requester"
|
||||||
version = "1.0.1"
|
version = "1.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"clap 2.34.0",
|
"clap 2.34.0",
|
||||||
@@ -3199,7 +3200,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nym-network-statistics"
|
name = "nym-network-statistics"
|
||||||
version = "0.1.0"
|
version = "1.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"dirs",
|
"dirs",
|
||||||
"log",
|
"log",
|
||||||
@@ -3215,9 +3216,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nym-socks5-client"
|
name = "nym-socks5-client"
|
||||||
version = "1.0.1"
|
version = "1.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap 2.34.0",
|
"clap 3.2.8",
|
||||||
"client-core",
|
"client-core",
|
||||||
"coconut-interface",
|
"coconut-interface",
|
||||||
"config",
|
"config",
|
||||||
@@ -3225,7 +3226,6 @@ dependencies = [
|
|||||||
"credentials",
|
"credentials",
|
||||||
"crypto",
|
"crypto",
|
||||||
"dirs",
|
"dirs",
|
||||||
"dotenv",
|
|
||||||
"futures",
|
"futures",
|
||||||
"gateway-client",
|
"gateway-client",
|
||||||
"gateway-requests",
|
"gateway-requests",
|
||||||
@@ -3277,7 +3277,7 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "nym-validator-api"
|
name = "nym-validator-api"
|
||||||
version = "1.0.1"
|
version = "1.0.2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"async-trait",
|
"async-trait",
|
||||||
@@ -3292,12 +3292,15 @@ dependencies = [
|
|||||||
"credential-storage",
|
"credential-storage",
|
||||||
"credentials",
|
"credentials",
|
||||||
"crypto",
|
"crypto",
|
||||||
|
"cw-utils",
|
||||||
|
"cw3",
|
||||||
"dirs",
|
"dirs",
|
||||||
"dotenv",
|
"dotenv",
|
||||||
"futures",
|
"futures",
|
||||||
"gateway-client",
|
"gateway-client",
|
||||||
"getset",
|
"getset",
|
||||||
"humantime-serde",
|
"humantime-serde",
|
||||||
|
"inclusion-probability",
|
||||||
"log",
|
"log",
|
||||||
"mixnet-contract-common",
|
"mixnet-contract-common",
|
||||||
"multisig-contract-common",
|
"multisig-contract-common",
|
||||||
@@ -3317,6 +3320,8 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
"sqlx",
|
"sqlx",
|
||||||
|
"tap",
|
||||||
|
"task",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"time 0.3.9",
|
"time 0.3.9",
|
||||||
"tokio",
|
"tokio",
|
||||||
@@ -3501,9 +3506,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.10.0"
|
version = "1.13.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "87f3e037eac156d1775da914196f0f37741a274155e34a0b7e427c35d2a2ecb9"
|
checksum = "18a6dbe30758c9f83eb00cbea4ac95966305f5a7772f3f42ebfc7fc7eddbd8e1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "oorandom"
|
name = "oorandom"
|
||||||
@@ -3568,9 +3573,6 @@ name = "os_str_bytes"
|
|||||||
version = "6.0.0"
|
version = "6.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
|
checksum = "8e22443d1643a904602595ba1cd8f7d896afe56d26712531c5ff73a15b2fbf64"
|
||||||
dependencies = [
|
|
||||||
"memchr",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "pairing"
|
name = "pairing"
|
||||||
@@ -4908,12 +4910,6 @@ dependencies = [
|
|||||||
"pest",
|
"pest",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "send_wrapper"
|
|
||||||
version = "0.4.0"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "f638d531eccd6e23b980caf34876660d38e265409d8e99b397ab71eb3612fad0"
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.136"
|
version = "1.0.136"
|
||||||
@@ -4975,9 +4971,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.79"
|
version = "1.0.83"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8e8d9fa5c3b304765ce1fd9c4c8a3de2c8db365a5b91be52f186efc675681d95"
|
checksum = "38dd04e3c8279e75b31ef29dbdceebfe5ad89f4d0937213c53f7d49d01b3d5a7"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"itoa 1.0.1",
|
"itoa 1.0.1",
|
||||||
"ryu",
|
"ryu",
|
||||||
@@ -5019,28 +5015,6 @@ dependencies = [
|
|||||||
"yaml-rust",
|
"yaml-rust",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serial_test"
|
|
||||||
version = "0.5.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "e0bccbcf40c8938196944a3da0e133e031a33f4d6b72db3bda3cc556e361905d"
|
|
||||||
dependencies = [
|
|
||||||
"lazy_static",
|
|
||||||
"parking_lot 0.11.2",
|
|
||||||
"serial_test_derive",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "serial_test_derive"
|
|
||||||
version = "0.5.1"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "b2acd6defeddb41eb60bb468f8825d0cfd0c2a76bc03bfd235b6a1dc4f6a1ad5"
|
|
||||||
dependencies = [
|
|
||||||
"proc-macro2",
|
|
||||||
"quote",
|
|
||||||
"syn",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "sha-1"
|
name = "sha-1"
|
||||||
version = "0.8.2"
|
version = "0.8.2"
|
||||||
@@ -5215,6 +5189,7 @@ version = "0.1.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"nymsphinx-addressing",
|
"nymsphinx-addressing",
|
||||||
"ordered-buffer",
|
"ordered-buffer",
|
||||||
|
"thiserror",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -5406,7 +5381,6 @@ version = "1.0.1"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"async-trait",
|
"async-trait",
|
||||||
"log",
|
"log",
|
||||||
"network-defaults",
|
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
@@ -5669,18 +5643,18 @@ checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror"
|
name = "thiserror"
|
||||||
version = "1.0.30"
|
version = "1.0.32"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "854babe52e4df1653706b98fcfc05843010039b406875930a70e4d9644e5c417"
|
checksum = "f5f6586b7f764adc0231f4c79be7b920e766bb2f3e51b3661cdb263828f19994"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"thiserror-impl",
|
"thiserror-impl",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "thiserror-impl"
|
name = "thiserror-impl"
|
||||||
version = "1.0.30"
|
version = "1.0.32"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "aa32fd3f627f367fe16f893e2597ae3c05020f8bba2666a4e6ea73d377e5714b"
|
checksum = "12bafc5b54507e0149cdf1b145a5d80ab80a90bcd9275df43d4fff68460f6c21"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -6354,7 +6328,6 @@ checksum = "49874b5167b65d7193b8aba1567f5c7d93d001cafc34600cee003eda787e483f"
|
|||||||
name = "vesting-contract"
|
name = "vesting-contract"
|
||||||
version = "1.0.1"
|
version = "1.0.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"config",
|
|
||||||
"cosmwasm-std",
|
"cosmwasm-std",
|
||||||
"cw-storage-plus",
|
"cw-storage-plus",
|
||||||
"mixnet-contract-common",
|
"mixnet-contract-common",
|
||||||
@@ -6423,8 +6396,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce"
|
checksum = "632f73e236b219150ea279196e54e610f5dbafa5d61786303d4da54f84e47fce"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"cfg-if 1.0.0",
|
"cfg-if 1.0.0",
|
||||||
"serde",
|
|
||||||
"serde_json",
|
|
||||||
"wasm-bindgen-macro",
|
"wasm-bindgen-macro",
|
||||||
]
|
]
|
||||||
|
|
||||||
@@ -6520,15 +6491,12 @@ dependencies = [
|
|||||||
"ethereum-types",
|
"ethereum-types",
|
||||||
"futures",
|
"futures",
|
||||||
"futures-timer",
|
"futures-timer",
|
||||||
"getrandom 0.2.6",
|
|
||||||
"headers",
|
"headers",
|
||||||
"hex",
|
"hex",
|
||||||
"js-sys",
|
|
||||||
"jsonrpc-core",
|
"jsonrpc-core",
|
||||||
"log",
|
"log",
|
||||||
"parking_lot 0.11.2",
|
"parking_lot 0.11.2",
|
||||||
"pin-project",
|
"pin-project",
|
||||||
"rand 0.8.5",
|
|
||||||
"reqwest",
|
"reqwest",
|
||||||
"rlp",
|
"rlp",
|
||||||
"secp256k1",
|
"secp256k1",
|
||||||
@@ -6540,8 +6508,6 @@ dependencies = [
|
|||||||
"tokio-stream",
|
"tokio-stream",
|
||||||
"tokio-util 0.6.9",
|
"tokio-util 0.6.9",
|
||||||
"url",
|
"url",
|
||||||
"wasm-bindgen",
|
|
||||||
"wasm-bindgen-futures",
|
|
||||||
"web3-async-native-tls",
|
"web3-async-native-tls",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|||||||
+10
-8
@@ -22,22 +22,23 @@ members = [
|
|||||||
"clients/native",
|
"clients/native",
|
||||||
"clients/native/websocket-requests",
|
"clients/native/websocket-requests",
|
||||||
"clients/socks5",
|
"clients/socks5",
|
||||||
|
"common/bandwidth-claim-contract",
|
||||||
"common/client-libs/gateway-client",
|
"common/client-libs/gateway-client",
|
||||||
"common/client-libs/mixnet-client",
|
"common/client-libs/mixnet-client",
|
||||||
"common/client-libs/validator-client",
|
"common/client-libs/validator-client",
|
||||||
"common/credential-storage",
|
|
||||||
"common/coconut-interface",
|
"common/coconut-interface",
|
||||||
"common/config",
|
"common/config",
|
||||||
"common/credentials",
|
|
||||||
"common/crypto",
|
|
||||||
"common/crypto/dkg",
|
|
||||||
"common/execute",
|
|
||||||
"common/bandwidth-claim-contract",
|
|
||||||
"common/cosmwasm-smart-contracts/coconut-bandwidth-contract",
|
"common/cosmwasm-smart-contracts/coconut-bandwidth-contract",
|
||||||
"common/cosmwasm-smart-contracts/contracts-common",
|
"common/cosmwasm-smart-contracts/contracts-common",
|
||||||
"common/cosmwasm-smart-contracts/mixnet-contract",
|
"common/cosmwasm-smart-contracts/mixnet-contract",
|
||||||
"common/cosmwasm-smart-contracts/multisig-contract",
|
"common/cosmwasm-smart-contracts/multisig-contract",
|
||||||
"common/cosmwasm-smart-contracts/vesting-contract",
|
"common/cosmwasm-smart-contracts/vesting-contract",
|
||||||
|
"common/credential-storage",
|
||||||
|
"common/credentials",
|
||||||
|
"common/crypto",
|
||||||
|
"common/crypto/dkg",
|
||||||
|
"common/execute",
|
||||||
|
"common/inclusion-probability",
|
||||||
"common/mixnode-common",
|
"common/mixnode-common",
|
||||||
"common/network-defaults",
|
"common/network-defaults",
|
||||||
"common/nonexhaustive-delayqueue",
|
"common/nonexhaustive-delayqueue",
|
||||||
@@ -53,9 +54,9 @@ members = [
|
|||||||
"common/nymsphinx/params",
|
"common/nymsphinx/params",
|
||||||
"common/nymsphinx/types",
|
"common/nymsphinx/types",
|
||||||
"common/pemstore",
|
"common/pemstore",
|
||||||
"common/statistics",
|
|
||||||
"common/socks5/proxy-helpers",
|
"common/socks5/proxy-helpers",
|
||||||
"common/socks5/requests",
|
"common/socks5/requests",
|
||||||
|
"common/statistics",
|
||||||
"common/task",
|
"common/task",
|
||||||
"common/topology",
|
"common/topology",
|
||||||
"common/types",
|
"common/types",
|
||||||
@@ -76,9 +77,10 @@ default-members = [
|
|||||||
"clients/socks5",
|
"clients/socks5",
|
||||||
"gateway",
|
"gateway",
|
||||||
"service-providers/network-requester",
|
"service-providers/network-requester",
|
||||||
|
"service-providers/network-statistics",
|
||||||
"mixnode",
|
"mixnode",
|
||||||
"validator-api",
|
"validator-api",
|
||||||
"explorer-api",
|
"explorer-api",
|
||||||
]
|
]
|
||||||
|
|
||||||
exclude = ["explorer", "contracts", "tokenomics-py", "clients/webassembly", "nym-wallet"]
|
exclude = ["explorer", "contracts", "tokenomics-py", "clients/webassembly", "nym-wallet", "nym-connect"]
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
|
test: clippy-all cargo-test wasm fmt
|
||||||
test-all: test cargo-test-expensive
|
test-all: test cargo-test-expensive
|
||||||
test: build clippy-all cargo-test wasm fmt
|
|
||||||
no-clippy: build cargo-test wasm fmt
|
no-clippy: build cargo-test wasm fmt
|
||||||
happy: fmt clippy-happy test
|
happy: fmt clippy-happy test
|
||||||
clippy-all: clippy-all-main clippy-all-contracts clippy-all-wallet clippy-all-connect
|
clippy-all: clippy-all-main clippy-all-contracts clippy-all-wallet clippy-all-connect
|
||||||
|
|||||||
@@ -9,8 +9,8 @@ The platform is composed of multiple Rust crates. Top-level executable binary cr
|
|||||||
|
|
||||||
* nym-mixnode - shuffles [Sphinx](https://github.com/nymtech/sphinx) packets together to provide privacy against network-level attackers.
|
* nym-mixnode - shuffles [Sphinx](https://github.com/nymtech/sphinx) packets together to provide privacy against network-level attackers.
|
||||||
* nym-client - an executable which you can build into your own applications. Use it for interacting with Nym nodes.
|
* nym-client - an executable which you can build into your own applications. Use it for interacting with Nym nodes.
|
||||||
* nym-socks5-client - a Socks5 proxy you can run on your machine, and use with existing applications
|
* nym-socks5-client - a Socks5 proxy you can run on your machine and use with existing applications.
|
||||||
* nym-gateway - acts sort of like a mailbox for mixnet messages, removing the need for directly delivery to potentially offline or firewalled devices.
|
* nym-gateway - acts sort of like a mailbox for mixnet messages, which removes the need for direct delivery to potentially offline or firewalled devices.
|
||||||
* nym-network-monitor - sends packets through the full system to check that they are working as expected, and stores node uptime histories as the basis of a rewards system ("mixmining" or "proof-of-mixing").
|
* nym-network-monitor - sends packets through the full system to check that they are working as expected, and stores node uptime histories as the basis of a rewards system ("mixmining" or "proof-of-mixing").
|
||||||
* nym-explorer - a (projected) block explorer and (existing) mixnet viewer.
|
* nym-explorer - a (projected) block explorer and (existing) mixnet viewer.
|
||||||
* nym-wallet - a desktop wallet implemented using the [Tauri](https://tauri.studio/en/docs/about/intro) framework.
|
* nym-wallet - a desktop wallet implemented using the [Tauri](https://tauri.studio/en/docs/about/intro) framework.
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ edition = "2021"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
dirs = "3.0"
|
dirs = "4.0"
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
humantime-serde = "1.0"
|
humantime-serde = "1.0"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
|
|||||||
-1
@@ -133,7 +133,6 @@ where
|
|||||||
let prepared_fragment = self
|
let prepared_fragment = self
|
||||||
.message_preparer
|
.message_preparer
|
||||||
.prepare_chunk_for_sending(chunk_clone, topology, &self.ack_key, &recipient)
|
.prepare_chunk_for_sending(chunk_clone, topology, &self.ack_key, &recipient)
|
||||||
.await
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
real_messages.push(RealMessage::new(
|
real_messages.push(RealMessage::new(
|
||||||
|
|||||||
-1
@@ -83,7 +83,6 @@ where
|
|||||||
let prepared_fragment = self
|
let prepared_fragment = self
|
||||||
.message_preparer
|
.message_preparer
|
||||||
.prepare_chunk_for_sending(chunk_clone, topology_ref, &self.ack_key, packet_recipient)
|
.prepare_chunk_for_sending(chunk_clone, topology_ref, &self.ack_key, packet_recipient)
|
||||||
.await
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
// if we have the ONLY strong reference to the ack data, it means it was removed from the
|
// if we have the ONLY strong reference to the ack data, it means it was removed from the
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use config::defaults::*;
|
|
||||||
use config::NymConfig;
|
use config::NymConfig;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::marker::PhantomData;
|
use std::marker::PhantomData;
|
||||||
@@ -272,7 +271,7 @@ impl<T: NymConfig> Default for Config<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Serialize)]
|
#[derive(Clone, Debug, Default, Deserialize, PartialEq, Eq, Serialize)]
|
||||||
pub struct GatewayEndpoint {
|
pub struct GatewayEndpoint {
|
||||||
/// gateway_id specifies ID of the gateway to which the client should send messages.
|
/// gateway_id specifies ID of the gateway to which the client should send messages.
|
||||||
/// If initially omitted, a random gateway will be chosen from the available topology.
|
/// If initially omitted, a random gateway will be chosen from the available topology.
|
||||||
@@ -296,7 +295,7 @@ impl From<topology::gateway::Node> for GatewayEndpoint {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||||
pub struct Client<T> {
|
pub struct Client<T> {
|
||||||
/// Version of the client for which this configuration was created.
|
/// Version of the client for which this configuration was created.
|
||||||
#[serde(default = "missing_string_value")]
|
#[serde(default = "missing_string_value")]
|
||||||
@@ -366,7 +365,7 @@ impl<T: NymConfig> Default for Client<T> {
|
|||||||
version: env!("CARGO_PKG_VERSION").to_string(),
|
version: env!("CARGO_PKG_VERSION").to_string(),
|
||||||
id: "".to_string(),
|
id: "".to_string(),
|
||||||
disabled_credentials_mode: true,
|
disabled_credentials_mode: true,
|
||||||
validator_api_urls: default_api_endpoints(),
|
validator_api_urls: vec![],
|
||||||
private_identity_key_file: Default::default(),
|
private_identity_key_file: Default::default(),
|
||||||
public_identity_key_file: Default::default(),
|
public_identity_key_file: Default::default(),
|
||||||
private_encryption_key_file: Default::default(),
|
private_encryption_key_file: Default::default(),
|
||||||
@@ -419,7 +418,7 @@ impl<T: NymConfig> Client<T> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Deserialize, PartialEq, Serialize)]
|
#[derive(Debug, Default, Deserialize, PartialEq, Eq, Serialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Logging {}
|
pub struct Logging {}
|
||||||
|
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ url = "2.2"
|
|||||||
tokio = { version = "1.19.1", features = ["rt-multi-thread", "net", "signal", "macros"] } # async runtime
|
tokio = { version = "1.19.1", features = ["rt-multi-thread", "net", "signal", "macros"] } # async runtime
|
||||||
|
|
||||||
coconut-interface = { path = "../../common/coconut-interface" }
|
coconut-interface = { path = "../../common/coconut-interface" }
|
||||||
|
config = { path = "../../common/config" }
|
||||||
credentials = { path = "../../common/credentials" }
|
credentials = { path = "../../common/credentials" }
|
||||||
credential-storage = { path = "../../common/credential-storage" }
|
credential-storage = { path = "../../common/credential-storage" }
|
||||||
crypto = { path = "../../common/crypto", features = ["rand", "asymmetric", "symmetric", "aes", "hashing"] }
|
crypto = { path = "../../common/crypto", features = ["rand", "asymmetric", "symmetric", "aes", "hashing"] }
|
||||||
|
|||||||
@@ -2,9 +2,8 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use crate::error::Result;
|
use crate::error::Result;
|
||||||
use crate::{MNEMONIC, NYMD_URL};
|
|
||||||
use bip39::Mnemonic;
|
use bip39::Mnemonic;
|
||||||
use network_defaults::{DEFAULT_NETWORK, MIX_DENOM, VOUCHER_INFO};
|
use network_defaults::{NymNetworkDetails, VOUCHER_INFO};
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use validator_client::nymd;
|
use validator_client::nymd;
|
||||||
@@ -13,18 +12,23 @@ use validator_client::nymd::{Coin, Fee, NymdClient, SigningNymdClient};
|
|||||||
|
|
||||||
pub(crate) struct Client {
|
pub(crate) struct Client {
|
||||||
nymd_client: NymdClient<SigningNymdClient>,
|
nymd_client: NymdClient<SigningNymdClient>,
|
||||||
|
mix_denom_base: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Client {
|
impl Client {
|
||||||
pub fn new() -> Self {
|
pub fn new(nymd_url: &str, mnemonic: &str) -> Self {
|
||||||
let nymd_url = Url::from_str(NYMD_URL).unwrap();
|
let nymd_url = Url::from_str(nymd_url).unwrap();
|
||||||
let mnemonic = Mnemonic::from_str(MNEMONIC).unwrap();
|
let mnemonic = Mnemonic::from_str(mnemonic).unwrap();
|
||||||
let config = nymd::Config::try_from_nym_network_details(&DEFAULT_NETWORK.details())
|
let network_details = NymNetworkDetails::new_from_env();
|
||||||
|
let config = nymd::Config::try_from_nym_network_details(&network_details)
|
||||||
.expect("failed to construct valid validator client config with the provided network");
|
.expect("failed to construct valid validator client config with the provided network");
|
||||||
let nymd_client =
|
let nymd_client =
|
||||||
NymdClient::connect_with_mnemonic(config, nymd_url.as_ref(), mnemonic, None).unwrap();
|
NymdClient::connect_with_mnemonic(config, nymd_url.as_ref(), mnemonic, None).unwrap();
|
||||||
|
|
||||||
Client { nymd_client }
|
Client {
|
||||||
|
nymd_client,
|
||||||
|
mix_denom_base: network_details.chain_details.mix_denom.base,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn deposit(
|
pub async fn deposit(
|
||||||
@@ -34,7 +38,7 @@ impl Client {
|
|||||||
encryption_key: String,
|
encryption_key: String,
|
||||||
fee: Option<Fee>,
|
fee: Option<Fee>,
|
||||||
) -> Result<String> {
|
) -> Result<String> {
|
||||||
let amount = Coin::new(amount as u128, MIX_DENOM.base.to_string());
|
let amount = Coin::new(amount as u128, self.mix_denom_base.clone());
|
||||||
Ok(self
|
Ok(self
|
||||||
.nymd_client
|
.nymd_client
|
||||||
.deposit(
|
.deposit(
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ use clap::{Args, Subcommand};
|
|||||||
use pickledb::PickleDb;
|
use pickledb::PickleDb;
|
||||||
use rand::rngs::OsRng;
|
use rand::rngs::OsRng;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use url::Url;
|
|
||||||
|
|
||||||
use coconut_interface::{Attribute, Base58, BlindSignRequest, Bytable, Parameters};
|
use coconut_interface::{Attribute, Base58, BlindSignRequest, Bytable, Parameters};
|
||||||
use credential_storage::storage::Storage;
|
use credential_storage::storage::Storage;
|
||||||
@@ -20,7 +19,6 @@ use validator_client::nymd::tx::Hash;
|
|||||||
use crate::client::Client;
|
use crate::client::Client;
|
||||||
use crate::error::{CredentialClientError, Result};
|
use crate::error::{CredentialClientError, Result};
|
||||||
use crate::state::{KeyPair, RequestData, State};
|
use crate::state::{KeyPair, RequestData, State};
|
||||||
use crate::SIGNER_AUTHORITIES;
|
|
||||||
|
|
||||||
#[derive(Subcommand)]
|
#[derive(Subcommand)]
|
||||||
pub(crate) enum Commands {
|
pub(crate) enum Commands {
|
||||||
@@ -39,6 +37,12 @@ pub(crate) trait Execute {
|
|||||||
|
|
||||||
#[derive(Args, Clone)]
|
#[derive(Args, Clone)]
|
||||||
pub(crate) struct Deposit {
|
pub(crate) struct Deposit {
|
||||||
|
/// The nymd URL that should be used
|
||||||
|
#[clap(long)]
|
||||||
|
nymd_url: String,
|
||||||
|
/// A mnemonic for the account that does the deposit
|
||||||
|
#[clap(long)]
|
||||||
|
mnemonic: String,
|
||||||
/// The amount that needs to be deposited
|
/// The amount that needs to be deposited
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
amount: u64,
|
amount: u64,
|
||||||
@@ -51,7 +55,7 @@ impl Execute for Deposit {
|
|||||||
let signing_keypair = KeyPair::from(identity::KeyPair::new(&mut rng));
|
let signing_keypair = KeyPair::from(identity::KeyPair::new(&mut rng));
|
||||||
let encryption_keypair = KeyPair::from(encryption::KeyPair::new(&mut rng));
|
let encryption_keypair = KeyPair::from(encryption::KeyPair::new(&mut rng));
|
||||||
|
|
||||||
let client = Client::new();
|
let client = Client::new(&self.nymd_url, &self.mnemonic);
|
||||||
let tx_hash = client
|
let tx_hash = client
|
||||||
.deposit(
|
.deposit(
|
||||||
self.amount,
|
self.amount,
|
||||||
@@ -96,6 +100,10 @@ pub(crate) struct GetCredential {
|
|||||||
/// The hash of a successful deposit transaction
|
/// The hash of a successful deposit transaction
|
||||||
#[clap(long)]
|
#[clap(long)]
|
||||||
tx_hash: String,
|
tx_hash: String,
|
||||||
|
/// The URLs to the validator-api endpoints the are run as coconut signer authorities, separated
|
||||||
|
/// by comma (,)
|
||||||
|
#[clap(long)]
|
||||||
|
signer_authorities: String,
|
||||||
/// If we want to get the signature without attaching a blind sign request; it is expected that
|
/// If we want to get the signature without attaching a blind sign request; it is expected that
|
||||||
/// there is already a signature stored on the signer
|
/// there is already a signature stored on the signer
|
||||||
#[clap(long, parse(from_flag))]
|
#[clap(long, parse(from_flag))]
|
||||||
@@ -108,7 +116,8 @@ impl Execute for GetCredential {
|
|||||||
let mut state = db
|
let mut state = db
|
||||||
.get::<State>(&self.tx_hash)
|
.get::<State>(&self.tx_hash)
|
||||||
.ok_or(CredentialClientError::NoDeposit)?;
|
.ok_or(CredentialClientError::NoDeposit)?;
|
||||||
let urls = SIGNER_AUTHORITIES.map(|addr| Url::from_str(addr).unwrap());
|
|
||||||
|
let urls = config::parse_validators(&self.signer_authorities);
|
||||||
|
|
||||||
let params = Parameters::new(TOTAL_ATTRIBUTES).unwrap();
|
let params = Parameters::new(TOTAL_ATTRIBUTES).unwrap();
|
||||||
let bandwidth_credential_attributes = if self.__no_request {
|
let bandwidth_credential_attributes = if self.__no_request {
|
||||||
|
|||||||
@@ -11,20 +11,24 @@ cfg_if::cfg_if! {
|
|||||||
|
|
||||||
use commands::{Commands, Execute};
|
use commands::{Commands, Execute};
|
||||||
use error::Result;
|
use error::Result;
|
||||||
|
use network_defaults::setup_env;
|
||||||
|
|
||||||
use clap::Parser;
|
use clap::Parser;
|
||||||
use pickledb::{PickleDb, PickleDbDumpPolicy, SerializationMethod};
|
use pickledb::{PickleDb, PickleDbDumpPolicy, SerializationMethod};
|
||||||
|
|
||||||
pub const MNEMONIC: &str = "jazz fatigue diagram account outer wrist slide cherry mother grid network pause wolf pig round answer mail junior better hair dismiss toward access end";
|
|
||||||
pub const NYMD_URL: &str = "http://127.0.0.1:26657";
|
|
||||||
pub const CONTRACT_ADDRESS: &str = "nymt1nc5tatafv6eyq7llkr2gv50ff9e22mnfp9pc5s";
|
|
||||||
pub const SIGNER_AUTHORITIES: [&str; 1] = [
|
|
||||||
"http://127.0.0.1:8080",
|
|
||||||
];
|
|
||||||
|
|
||||||
#[derive(Parser)]
|
#[derive(Parser)]
|
||||||
#[clap(author = "Nymtech", version, about)]
|
#[clap(author = "Nymtech", version, about)]
|
||||||
struct Cli {
|
struct Cli {
|
||||||
|
/// Path pointing to an env file that configures the client.
|
||||||
|
#[clap(long)]
|
||||||
|
pub(crate) config_env_file: Option<std::path::PathBuf>,
|
||||||
|
|
||||||
|
/// Path where the sqlite credental database will be located.
|
||||||
|
/// It should point to a $HOME/$CLIENT_ID/data/db.sqlite file of
|
||||||
|
/// the client that is supposed to use the credential.
|
||||||
|
#[clap(long)]
|
||||||
|
pub(crate) credential_db_path: std::path::PathBuf,
|
||||||
|
|
||||||
#[clap(subcommand)]
|
#[clap(subcommand)]
|
||||||
command: Commands,
|
command: Commands,
|
||||||
}
|
}
|
||||||
@@ -32,8 +36,9 @@ cfg_if::cfg_if! {
|
|||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<()> {
|
async fn main() -> Result<()> {
|
||||||
let args = Cli::parse();
|
let args = Cli::parse();
|
||||||
|
setup_env(args.config_env_file.clone());
|
||||||
|
|
||||||
let shared_storage = credential_storage::initialise_storage(std::path::PathBuf::from("/tmp/credential.db")).await;
|
let shared_storage = credential_storage::initialise_storage(args.credential_db_path.clone()).await;
|
||||||
let mut db = match PickleDb::load(
|
let mut db = match PickleDb::load(
|
||||||
"credential.db",
|
"credential.db",
|
||||||
PickleDbDumpPolicy::AutoDump,
|
PickleDbDumpPolicy::AutoDump,
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "nym-client"
|
name = "nym-client"
|
||||||
version = "1.0.1"
|
version = "1.0.2"
|
||||||
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>", "Jędrzej Stuczyński <andrew@nymtech.net>"]
|
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>", "Jędrzej Stuczyński <andrew@nymtech.net>"]
|
||||||
|
description = "Implementation of the Nym Client"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.56"
|
rust-version = "1.56"
|
||||||
|
|
||||||
@@ -19,9 +20,8 @@ futures = "0.3" # bunch of futures stuff, however, now that I think about it, it
|
|||||||
# and the single instance of abortable we have should really be refactored anyway
|
# and the single instance of abortable we have should really be refactored anyway
|
||||||
url = "2.2"
|
url = "2.2"
|
||||||
|
|
||||||
clap = "2.33.0" # for the command line arguments
|
clap = { version = "3.2.8", features = ["cargo", "derive"] }
|
||||||
dirs = "3.0" # for determining default store directories in config
|
dirs = "4.0"
|
||||||
dotenv = "0.15.0" # for obtaining environmental variables (only used for RUST_LOG for time being)
|
|
||||||
log = "0.4" # self explanatory
|
log = "0.4" # self explanatory
|
||||||
pretty_env_logger = "0.4" # for formatting log messages
|
pretty_env_logger = "0.4" # for formatting log messages
|
||||||
rand = { version = "0.7.3", features = ["wasm-bindgen"] } # rng-related traits + some rng implementation to use
|
rand = { version = "0.7.3", features = ["wasm-bindgen"] } # rng-related traits + some rng implementation to use
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ use std::path::PathBuf;
|
|||||||
|
|
||||||
mod template;
|
mod template;
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, PartialEq, Serialize, Clone, Copy)]
|
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize, Clone, Copy)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub enum SocketType {
|
pub enum SocketType {
|
||||||
WebSocket,
|
WebSocket,
|
||||||
@@ -50,6 +50,10 @@ impl NymConfig for Config {
|
|||||||
.join("clients")
|
.join("clients")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn try_default_root_directory() -> Option<PathBuf> {
|
||||||
|
dirs::home_dir().map(|path| path.join(".nym").join("clients"))
|
||||||
|
}
|
||||||
|
|
||||||
fn root_directory(&self) -> PathBuf {
|
fn root_directory(&self) -> PathBuf {
|
||||||
self.base.get_nym_root_directory()
|
self.base.get_nym_root_directory()
|
||||||
}
|
}
|
||||||
@@ -105,7 +109,7 @@ impl Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Socket {
|
pub struct Socket {
|
||||||
socket_type: SocketType,
|
socket_type: SocketType,
|
||||||
|
|||||||
@@ -199,9 +199,9 @@ impl NymClient {
|
|||||||
Some(bandwidth_controller),
|
Some(bandwidth_controller),
|
||||||
);
|
);
|
||||||
|
|
||||||
if self.config.get_base().get_disabled_credentials_mode() {
|
gateway_client
|
||||||
gateway_client.set_disabled_credentials_mode(true)
|
.set_disabled_credentials_mode(self.config.get_base().get_disabled_credentials_mode());
|
||||||
}
|
|
||||||
gateway_client
|
gateway_client
|
||||||
.authenticate_and_start()
|
.authenticate_and_start()
|
||||||
.await
|
.await
|
||||||
|
|||||||
@@ -1,88 +1,99 @@
|
|||||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use clap::{App, Arg, ArgMatches};
|
use clap::Args;
|
||||||
use client_core::config::GatewayEndpoint;
|
use client_core::config::GatewayEndpoint;
|
||||||
use config::NymConfig;
|
use config::NymConfig;
|
||||||
|
|
||||||
use crate::client::config::Config;
|
use crate::{
|
||||||
use crate::commands::override_config;
|
client::config::Config,
|
||||||
#[cfg(feature = "eth")]
|
commands::{override_config, OverrideConfig},
|
||||||
#[cfg(not(feature = "coconut"))]
|
|
||||||
use crate::commands::{
|
|
||||||
DEFAULT_ETH_ENDPOINT, DEFAULT_ETH_PRIVATE_KEY, ENABLED_CREDENTIALS_MODE_ARG_NAME,
|
|
||||||
ETH_ENDPOINT_ARG_NAME, ETH_PRIVATE_KEY_ARG_NAME,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn command_args<'a, 'b>() -> clap::App<'a, 'b> {
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
let app = App::new("init")
|
use crate::commands::{DEFAULT_ETH_ENDPOINT, DEFAULT_ETH_PRIVATE_KEY};
|
||||||
.about("Initialise a Nym client. Do this first!")
|
|
||||||
.arg(Arg::with_name("id")
|
|
||||||
.long("id")
|
|
||||||
.help("Id of the nym-mixnet-client we want to create config for.")
|
|
||||||
.takes_value(true)
|
|
||||||
.required(true)
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name("gateway")
|
|
||||||
.long("gateway")
|
|
||||||
.help("Id of the gateway we are going to connect to.")
|
|
||||||
.takes_value(true)
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name("force-register-gateway")
|
|
||||||
.long("force-register-gateway")
|
|
||||||
.help("Force register gateway. WARNING: this will overwrite any existing keys for the given id, potentially causing loss of access.")
|
|
||||||
.takes_value(false)
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name("validators")
|
|
||||||
.long("validators")
|
|
||||||
.help("Comma separated list of rest endpoints of the validators")
|
|
||||||
.takes_value(true),
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name("disable-socket")
|
|
||||||
.long("disable-socket")
|
|
||||||
.help("Whether to not start the websocket")
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name("port")
|
|
||||||
.short("p")
|
|
||||||
.long("port")
|
|
||||||
.help("Port for the socket (if applicable) to listen on in all subsequent runs")
|
|
||||||
.takes_value(true)
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name("fastmode")
|
|
||||||
.long("fastmode")
|
|
||||||
.hidden(true) // this will prevent this flag from being displayed in `--help`
|
|
||||||
.help("Mostly debug-related option to increase default traffic rate so that you would not need to modify config post init")
|
|
||||||
);
|
|
||||||
#[cfg(feature = "eth")]
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
|
||||||
let app = app
|
|
||||||
.arg(
|
|
||||||
Arg::with_name(ENABLED_CREDENTIALS_MODE_ARG_NAME)
|
|
||||||
.long(ENABLED_CREDENTIALS_MODE_ARG_NAME)
|
|
||||||
.help("Set this client to work in a disabled credentials mode that would attempt to use gateway without bandwidth credential requirement. If this value is set, --eth_endpoint and --eth_private_key don't need to be set.")
|
|
||||||
.conflicts_with_all(&[ETH_ENDPOINT_ARG_NAME, ETH_PRIVATE_KEY_ARG_NAME])
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name(ETH_ENDPOINT_ARG_NAME)
|
|
||||||
.long(ETH_ENDPOINT_ARG_NAME)
|
|
||||||
.help("URL of an Ethereum full node that we want to use for getting bandwidth tokens from ERC20 tokens. If you don't want to set this value, use --testnet-mode instead")
|
|
||||||
.takes_value(true)
|
|
||||||
.default_value_if(ENABLED_CREDENTIALS_MODE_ARG_NAME, None, DEFAULT_ETH_ENDPOINT)
|
|
||||||
.required(true))
|
|
||||||
.arg(Arg::with_name(ETH_PRIVATE_KEY_ARG_NAME)
|
|
||||||
.long(ETH_PRIVATE_KEY_ARG_NAME)
|
|
||||||
.help("Ethereum private key used for obtaining bandwidth tokens from ERC20 tokens. If you don't want to set this value, use --testnet-mode instead")
|
|
||||||
.takes_value(true)
|
|
||||||
.default_value_if(ENABLED_CREDENTIALS_MODE_ARG_NAME, None, DEFAULT_ETH_PRIVATE_KEY)
|
|
||||||
.required(true)
|
|
||||||
);
|
|
||||||
|
|
||||||
app
|
#[derive(Args, Clone)]
|
||||||
|
pub(crate) struct Init {
|
||||||
|
/// Id of the nym-mixnet-client we want to create config for.
|
||||||
|
#[clap(long)]
|
||||||
|
id: String,
|
||||||
|
|
||||||
|
/// Id of the gateway we are going to connect to.
|
||||||
|
#[clap(long)]
|
||||||
|
gateway: Option<String>,
|
||||||
|
|
||||||
|
/// Force register gateway. WARNING: this will overwrite any existing keys for the given id,
|
||||||
|
/// potentially causing loss of access.
|
||||||
|
#[clap(long)]
|
||||||
|
force_register_gateway: bool,
|
||||||
|
|
||||||
|
/// Comma separated list of rest endpoints of the validators
|
||||||
|
#[clap(long)]
|
||||||
|
validators: Option<String>,
|
||||||
|
|
||||||
|
/// Whether to not start the websocket
|
||||||
|
#[clap(long)]
|
||||||
|
disable_socket: bool,
|
||||||
|
|
||||||
|
/// Port for the socket (if applicable) to listen on in all subsequent runs
|
||||||
|
#[clap(short, long)]
|
||||||
|
port: Option<u16>,
|
||||||
|
|
||||||
|
/// Mostly debug-related option to increase default traffic rate so that you would not need to
|
||||||
|
/// modify config post init
|
||||||
|
#[clap(long, hidden = true)]
|
||||||
|
fastmode: bool,
|
||||||
|
|
||||||
|
/// Set this client to work in a enabled credentials mode that would attempt to use gateway
|
||||||
|
/// with bandwidth credential requirement.
|
||||||
|
#[cfg(any(feature = "eth", feature = "coconut"))]
|
||||||
|
#[clap(long)]
|
||||||
|
enabled_credentials_mode: bool,
|
||||||
|
|
||||||
|
/// URL of an Ethereum full node that we want to use for getting bandwidth tokens from ERC20
|
||||||
|
/// tokens. If you don't want to set this value, use --enabled-credentials-mode instead
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
#[clap(
|
||||||
|
long,
|
||||||
|
default_value_if("enabled-credentials-mode", None, Some(DEFAULT_ETH_ENDPOINT))
|
||||||
|
)]
|
||||||
|
eth_endpoint: String,
|
||||||
|
|
||||||
|
/// Ethereum private key used for obtaining bandwidth tokens from ERC20 tokens. If you don't
|
||||||
|
/// want to set this value, use --enabled-credentials-mode instead")
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
#[clap(
|
||||||
|
long,
|
||||||
|
default_value_if("enabled-credentials-mode", None, Some(DEFAULT_ETH_PRIVATE_KEY))
|
||||||
|
)]
|
||||||
|
eth_private_key: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn execute(matches: ArgMatches<'static>) {
|
impl From<Init> for OverrideConfig {
|
||||||
|
fn from(init_config: Init) -> Self {
|
||||||
|
OverrideConfig {
|
||||||
|
validators: init_config.validators,
|
||||||
|
disable_socket: init_config.disable_socket,
|
||||||
|
port: init_config.port,
|
||||||
|
fastmode: init_config.fastmode,
|
||||||
|
|
||||||
|
#[cfg(any(feature = "eth", feature = "coconut"))]
|
||||||
|
enabled_credentials_mode: init_config.enabled_credentials_mode,
|
||||||
|
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
eth_private_key: Some(init_config.eth_private_key),
|
||||||
|
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
eth_endpoint: Some(init_config.eth_endpoint),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn execute(args: &Init) {
|
||||||
println!("Initialising client...");
|
println!("Initialising client...");
|
||||||
|
|
||||||
let id = matches.value_of("id").unwrap(); // required for now
|
let id = &args.id;
|
||||||
|
|
||||||
let already_init = Config::default_config_file_path(Some(id)).exists();
|
let already_init = Config::default_config_file_path(Some(id)).exists();
|
||||||
if already_init {
|
if already_init {
|
||||||
@@ -95,7 +106,7 @@ pub async fn execute(matches: ArgMatches<'static>) {
|
|||||||
|
|
||||||
// Usually you only register with the gateway on the first init, however you can force
|
// Usually you only register with the gateway on the first init, however you can force
|
||||||
// re-registering if wanted.
|
// re-registering if wanted.
|
||||||
let user_wants_force_register = matches.is_present("force-register-gateway");
|
let user_wants_force_register = args.force_register_gateway;
|
||||||
|
|
||||||
// If the client was already initialized, don't generate new keys and don't re-register with
|
// If the client was already initialized, don't generate new keys and don't re-register with
|
||||||
// the gateway (because this would create a new shared key).
|
// the gateway (because this would create a new shared key).
|
||||||
@@ -103,14 +114,11 @@ pub async fn execute(matches: ArgMatches<'static>) {
|
|||||||
let register_gateway = !already_init || user_wants_force_register;
|
let register_gateway = !already_init || user_wants_force_register;
|
||||||
|
|
||||||
// Attempt to use a user-provided gateway, if possible
|
// Attempt to use a user-provided gateway, if possible
|
||||||
let user_chosen_gateway_id = matches.value_of("gateway");
|
let user_chosen_gateway_id = args.gateway.as_deref();
|
||||||
|
|
||||||
let mut config = Config::new(id);
|
let mut config = Config::new(id);
|
||||||
|
let override_config_fields = OverrideConfig::from(args.clone());
|
||||||
config = override_config(config, &matches);
|
config = override_config(config, override_config_fields);
|
||||||
if matches.is_present("fastmode") {
|
|
||||||
config.get_base_mut().set_high_default_traffic_volume();
|
|
||||||
}
|
|
||||||
|
|
||||||
let gateway = setup_gateway(id, register_gateway, user_chosen_gateway_id, &config).await;
|
let gateway = setup_gateway(id, register_gateway, user_chosen_gateway_id, &config).await;
|
||||||
config.get_base_mut().with_gateway_endpoint(gateway);
|
config.get_base_mut().with_gateway_endpoint(gateway);
|
||||||
|
|||||||
@@ -2,14 +2,8 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use crate::client::config::{Config, SocketType};
|
use crate::client::config::{Config, SocketType};
|
||||||
use clap::ArgMatches;
|
use clap::{Parser, Subcommand};
|
||||||
use url::Url;
|
|
||||||
|
|
||||||
pub(crate) const ENABLED_CREDENTIALS_MODE_ARG_NAME: &str = "enabled-credentials-mode";
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
|
||||||
pub(crate) const ETH_ENDPOINT_ARG_NAME: &str = "eth_endpoint";
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
|
||||||
pub(crate) const ETH_PRIVATE_KEY_ARG_NAME: &str = "eth_private_key";
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
#[cfg(not(feature = "coconut"))]
|
||||||
pub(crate) const DEFAULT_ETH_ENDPOINT: &str =
|
pub(crate) const DEFAULT_ETH_ENDPOINT: &str =
|
||||||
"https://rinkeby.infura.io/v3/00000000000000000000000000000000";
|
"https://rinkeby.infura.io/v3/00000000000000000000000000000000";
|
||||||
@@ -21,56 +15,148 @@ pub(crate) mod init;
|
|||||||
pub(crate) mod run;
|
pub(crate) mod run;
|
||||||
pub(crate) mod upgrade;
|
pub(crate) mod upgrade;
|
||||||
|
|
||||||
fn parse_validators(raw: &str) -> Vec<Url> {
|
fn long_version() -> String {
|
||||||
raw.split(',')
|
format!(
|
||||||
.map(|raw_validator| {
|
r#"
|
||||||
raw_validator
|
{:<20}{}
|
||||||
.trim()
|
{:<20}{}
|
||||||
.parse()
|
{:<20}{}
|
||||||
.expect("one of the provided validator api urls is invalid")
|
{:<20}{}
|
||||||
})
|
{:<20}{}
|
||||||
.collect()
|
{:<20}{}
|
||||||
|
{:<20}{}
|
||||||
|
{:<20}{}
|
||||||
|
"#,
|
||||||
|
"Build Timestamp:",
|
||||||
|
env!("VERGEN_BUILD_TIMESTAMP"),
|
||||||
|
"Build Version:",
|
||||||
|
env!("VERGEN_BUILD_SEMVER"),
|
||||||
|
"Commit SHA:",
|
||||||
|
env!("VERGEN_GIT_SHA"),
|
||||||
|
"Commit Date:",
|
||||||
|
env!("VERGEN_GIT_COMMIT_TIMESTAMP"),
|
||||||
|
"Commit Branch:",
|
||||||
|
env!("VERGEN_GIT_BRANCH"),
|
||||||
|
"rustc Version:",
|
||||||
|
env!("VERGEN_RUSTC_SEMVER"),
|
||||||
|
"rustc Channel:",
|
||||||
|
env!("VERGEN_RUSTC_CHANNEL"),
|
||||||
|
"cargo Profile:",
|
||||||
|
env!("VERGEN_CARGO_PROFILE"),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn override_config(mut config: Config, matches: &ArgMatches<'_>) -> Config {
|
fn long_version_static() -> &'static str {
|
||||||
if let Some(raw_validators) = matches.value_of("validators") {
|
Box::leak(long_version().into_boxed_str())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Parser)]
|
||||||
|
#[clap(author = "Nymtech", version, long_version = long_version_static(), about)]
|
||||||
|
pub(crate) struct Cli {
|
||||||
|
/// Path pointing to an env file that configures the client.
|
||||||
|
#[clap(long)]
|
||||||
|
pub(crate) config_env_file: Option<std::path::PathBuf>,
|
||||||
|
|
||||||
|
#[clap(subcommand)]
|
||||||
|
command: Commands,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subcommand)]
|
||||||
|
pub(crate) enum Commands {
|
||||||
|
/// Initialise a Nym client. Do this first!
|
||||||
|
Init(init::Init),
|
||||||
|
/// Run the Nym client with provided configuration client optionally overriding set parameters
|
||||||
|
Run(run::Run),
|
||||||
|
/// Try to upgrade the client
|
||||||
|
Upgrade(upgrade::Upgrade),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configuration that can be overridden.
|
||||||
|
pub(crate) struct OverrideConfig {
|
||||||
|
validators: Option<String>,
|
||||||
|
disable_socket: bool,
|
||||||
|
port: Option<u16>,
|
||||||
|
fastmode: bool,
|
||||||
|
|
||||||
|
#[cfg(any(feature = "eth", feature = "coconut"))]
|
||||||
|
enabled_credentials_mode: bool,
|
||||||
|
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
eth_private_key: Option<String>,
|
||||||
|
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
eth_endpoint: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn execute(args: &Cli) {
|
||||||
|
match &args.command {
|
||||||
|
Commands::Init(m) => init::execute(m).await,
|
||||||
|
Commands::Run(m) => run::execute(m).await,
|
||||||
|
Commands::Upgrade(m) => upgrade::execute(m),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Config {
|
||||||
|
if let Some(raw_validators) = args.validators {
|
||||||
config
|
config
|
||||||
.get_base_mut()
|
.get_base_mut()
|
||||||
.set_custom_validator_apis(parse_validators(raw_validators));
|
.set_custom_validator_apis(config::parse_validators(&raw_validators));
|
||||||
|
} else if std::env::var(network_defaults::var_names::CONFIGURED).is_ok() {
|
||||||
|
let raw_validators = std::env::var(network_defaults::var_names::API_VALIDATOR)
|
||||||
|
.expect("api validator not set");
|
||||||
|
config
|
||||||
|
.get_base_mut()
|
||||||
|
.set_custom_validator_apis(config::parse_validators(&raw_validators));
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches.is_present("disable-socket") {
|
if args.disable_socket {
|
||||||
config = config.with_socket(SocketType::None);
|
config = config.with_socket(SocketType::None);
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(port) = matches.value_of("port").map(str::parse) {
|
if let Some(port) = args.port {
|
||||||
if let Err(err) = port {
|
config = config.with_port(port);
|
||||||
// if port was overridden, it must be parsable
|
}
|
||||||
panic!("Invalid port value provided - {:?}", err);
|
|
||||||
|
#[cfg(all(not(feature = "eth"), not(feature = "coconut")))]
|
||||||
|
{
|
||||||
|
config
|
||||||
|
.get_base_mut()
|
||||||
|
.with_eth_endpoint(DEFAULT_ETH_ENDPOINT.to_string());
|
||||||
|
config
|
||||||
|
.get_base_mut()
|
||||||
|
.with_eth_private_key(DEFAULT_ETH_PRIVATE_KEY.to_string());
|
||||||
|
}
|
||||||
|
#[cfg(any(feature = "eth", feature = "coconut"))]
|
||||||
|
{
|
||||||
|
if args.enabled_credentials_mode {
|
||||||
|
config.get_base_mut().with_disabled_credentials(false)
|
||||||
}
|
}
|
||||||
config = config.with_port(port.unwrap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
if let Some(eth_endpoint) = matches.value_of(ETH_ENDPOINT_ARG_NAME) {
|
{
|
||||||
config.get_base_mut().with_eth_endpoint(eth_endpoint);
|
if let Some(eth_endpoint) = args.eth_endpoint {
|
||||||
} else if !cfg!(feature = "eth") {
|
config.get_base_mut().with_eth_endpoint(eth_endpoint);
|
||||||
config
|
}
|
||||||
.get_base_mut()
|
if let Some(eth_private_key) = args.eth_private_key {
|
||||||
.with_eth_endpoint(DEFAULT_ETH_ENDPOINT);
|
config.get_base_mut().with_eth_private_key(eth_private_key);
|
||||||
}
|
}
|
||||||
#[cfg(not(feature = "coconut"))]
|
|
||||||
if let Some(eth_private_key) = matches.value_of(ETH_PRIVATE_KEY_ARG_NAME) {
|
|
||||||
config.get_base_mut().with_eth_private_key(eth_private_key);
|
|
||||||
} else if !cfg!(feature = "eth") {
|
|
||||||
config
|
|
||||||
.get_base_mut()
|
|
||||||
.with_eth_private_key(DEFAULT_ETH_PRIVATE_KEY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if matches.is_present(ENABLED_CREDENTIALS_MODE_ARG_NAME) {
|
if args.fastmode {
|
||||||
config.get_base_mut().with_disabled_credentials(false)
|
config.get_base_mut().set_high_default_traffic_volume();
|
||||||
}
|
}
|
||||||
|
|
||||||
config
|
config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use clap::CommandFactory;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn verify_cli() {
|
||||||
|
Cli::command().debug_assert();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,68 +1,76 @@
|
|||||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use crate::client::config::Config;
|
use crate::{
|
||||||
use crate::client::NymClient;
|
client::{config::Config, NymClient},
|
||||||
use crate::commands::override_config;
|
commands::{override_config, OverrideConfig},
|
||||||
#[cfg(feature = "eth")]
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
|
||||||
use crate::commands::{
|
|
||||||
ENABLED_CREDENTIALS_MODE_ARG_NAME, ETH_ENDPOINT_ARG_NAME, ETH_PRIVATE_KEY_ARG_NAME,
|
|
||||||
};
|
};
|
||||||
use clap::{App, Arg, ArgMatches};
|
|
||||||
|
use clap::Args;
|
||||||
use config::NymConfig;
|
use config::NymConfig;
|
||||||
use log::*;
|
use log::*;
|
||||||
use version_checker::is_minor_version_compatible;
|
use version_checker::is_minor_version_compatible;
|
||||||
|
|
||||||
pub fn command_args<'a, 'b>() -> clap::App<'a, 'b> {
|
#[derive(Args, Clone)]
|
||||||
let app = App::new("run")
|
pub(crate) struct Run {
|
||||||
.about("Run the Nym client with provided configuration client optionally overriding set parameters")
|
/// Id of the nym-mixnet-client we want to run.
|
||||||
.arg(Arg::with_name("id")
|
#[clap(long)]
|
||||||
.long("id")
|
id: String,
|
||||||
.help("Id of the nym-mixnet-client we want to run.")
|
|
||||||
.takes_value(true)
|
|
||||||
.required(true)
|
|
||||||
)
|
|
||||||
// the rest of arguments are optional, they are used to override settings in config file
|
|
||||||
.arg(Arg::with_name("validators")
|
|
||||||
.long("validators")
|
|
||||||
.help("Comma separated list rest rest endpoints of the validators")
|
|
||||||
.takes_value(true),
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name("gateway")
|
|
||||||
.long("gateway")
|
|
||||||
.help("Id of the gateway we want to connect to. If overridden, it is user's responsibility to ensure prior registration happened")
|
|
||||||
.takes_value(true)
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name("disable-socket")
|
|
||||||
.long("disable-socket")
|
|
||||||
.help("Whether to not start the websocket")
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name("port")
|
|
||||||
.short("p")
|
|
||||||
.long("port")
|
|
||||||
.help("Port for the socket (if applicable) to listen on")
|
|
||||||
.takes_value(true)
|
|
||||||
);
|
|
||||||
#[cfg(feature = "eth")]
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
|
||||||
let app = app
|
|
||||||
.arg(
|
|
||||||
Arg::with_name(ENABLED_CREDENTIALS_MODE_ARG_NAME)
|
|
||||||
.long(ENABLED_CREDENTIALS_MODE_ARG_NAME)
|
|
||||||
.help("Set this client to work in a enabled credentials mode that would attempt to use gateway with bandwidth credential requirement. If this value is set, --eth_endpoint and --eth_private_key don't need to be set.")
|
|
||||||
.conflicts_with_all(&[ETH_ENDPOINT_ARG_NAME, ETH_PRIVATE_KEY_ARG_NAME])
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name(ETH_ENDPOINT_ARG_NAME)
|
|
||||||
.long(ETH_ENDPOINT_ARG_NAME)
|
|
||||||
.help("URL of an Ethereum full node that we want to use for getting bandwidth tokens from ERC20 tokens. If you don't want to set this value, use --testnet-mode instead")
|
|
||||||
.takes_value(true))
|
|
||||||
.arg(Arg::with_name(ETH_PRIVATE_KEY_ARG_NAME)
|
|
||||||
.long(ETH_PRIVATE_KEY_ARG_NAME)
|
|
||||||
.help("Ethereum private key used for obtaining bandwidth tokens from ERC20 tokens. If you don't want to set this value, use --testnet-mode instead")
|
|
||||||
.takes_value(true));
|
|
||||||
|
|
||||||
app
|
/// Comma separated list of rest endpoints of the validators
|
||||||
|
#[clap(long)]
|
||||||
|
validators: Option<String>,
|
||||||
|
|
||||||
|
/// Id of the gateway we want to connect to. If overridden, it is user's responsibility to
|
||||||
|
/// ensure prior registration happened
|
||||||
|
#[clap(long)]
|
||||||
|
gateway: Option<String>,
|
||||||
|
|
||||||
|
/// Whether to not start the websocket
|
||||||
|
#[clap(long)]
|
||||||
|
disable_socket: bool,
|
||||||
|
|
||||||
|
/// Port for the socket to listen on
|
||||||
|
#[clap(short, long)]
|
||||||
|
port: Option<u16>,
|
||||||
|
|
||||||
|
/// Set this client to work in a enabled credentials mode that would attempt to use gateway
|
||||||
|
/// with bandwidth credential requirement.
|
||||||
|
#[cfg(any(feature = "eth", feature = "coconut"))]
|
||||||
|
#[clap(long)]
|
||||||
|
enabled_credentials_mode: bool,
|
||||||
|
|
||||||
|
/// URL of an Ethereum full node that we want to use for getting bandwidth tokens from ERC20
|
||||||
|
/// tokens. If you don't want to set this value, use --enabled-credentials-mode instead
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
#[clap(long)]
|
||||||
|
eth_endpoint: Option<String>,
|
||||||
|
|
||||||
|
/// Ethereum private key used for obtaining bandwidth tokens from ERC20 tokens. If you don't
|
||||||
|
/// want to set this value, use --enabled-credentials-mode instead")
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
#[clap(long)]
|
||||||
|
eth_private_key: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Run> for OverrideConfig {
|
||||||
|
fn from(run_config: Run) -> Self {
|
||||||
|
OverrideConfig {
|
||||||
|
validators: run_config.validators,
|
||||||
|
disable_socket: run_config.disable_socket,
|
||||||
|
port: run_config.port,
|
||||||
|
fastmode: false,
|
||||||
|
|
||||||
|
#[cfg(any(feature = "eth", feature = "coconut"))]
|
||||||
|
enabled_credentials_mode: run_config.enabled_credentials_mode,
|
||||||
|
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
eth_private_key: run_config.eth_private_key,
|
||||||
|
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
eth_endpoint: run_config.eth_endpoint,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this only checks compatibility between config the binary. It does not take into consideration
|
// this only checks compatibility between config the binary. It does not take into consideration
|
||||||
@@ -73,7 +81,7 @@ fn version_check(cfg: &Config) -> bool {
|
|||||||
if binary_version == config_version {
|
if binary_version == config_version {
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
warn!("The mixnode binary has different version than what is specified in config file! {} and {}", binary_version, config_version);
|
warn!("The native-client binary has different version than what is specified in config file! {} and {}", binary_version, config_version);
|
||||||
if is_minor_version_compatible(binary_version, config_version) {
|
if is_minor_version_compatible(binary_version, config_version) {
|
||||||
info!("but they are still semver compatible. However, consider running the `upgrade` command");
|
info!("but they are still semver compatible. However, consider running the `upgrade` command");
|
||||||
true
|
true
|
||||||
@@ -84,8 +92,8 @@ fn version_check(cfg: &Config) -> bool {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn execute(matches: ArgMatches<'static>) {
|
pub(crate) async fn execute(args: &Run) {
|
||||||
let id = matches.value_of("id").unwrap();
|
let id = &args.id;
|
||||||
|
|
||||||
let mut config = match Config::load_from_file(Some(id)) {
|
let mut config = match Config::load_from_file(Some(id)) {
|
||||||
Ok(cfg) => cfg,
|
Ok(cfg) => cfg,
|
||||||
@@ -95,7 +103,8 @@ pub async fn execute(matches: ArgMatches<'static>) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
config = override_config(config, &matches);
|
let override_config_fields = OverrideConfig::from(args.clone());
|
||||||
|
config = override_config(config, override_config_fields);
|
||||||
|
|
||||||
if !version_check(&config) {
|
if !version_check(&config) {
|
||||||
error!("failed the local version check");
|
error!("failed the local version check");
|
||||||
|
|||||||
@@ -2,12 +2,13 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use crate::client::config::{Config, MISSING_VALUE};
|
use crate::client::config::{Config, MISSING_VALUE};
|
||||||
use clap::{App, Arg, ArgMatches};
|
|
||||||
use config::defaults::default_api_endpoints;
|
|
||||||
use config::NymConfig;
|
use config::NymConfig;
|
||||||
|
use version_checker::Version;
|
||||||
|
|
||||||
|
use clap::Args;
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
use std::process;
|
use std::process;
|
||||||
use version_checker::Version;
|
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn fail_upgrade<D1: Display, D2: Display>(from_version: D1, to_version: D2) -> ! {
|
fn fail_upgrade<D1: Display, D2: Display>(from_version: D1, to_version: D2) -> ! {
|
||||||
@@ -49,14 +50,11 @@ fn unsupported_upgrade(current_version: &Version, config_version: &Version) -> !
|
|||||||
process::exit(1)
|
process::exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn command_args<'a, 'b>() -> App<'a, 'b> {
|
#[derive(Args, Clone)]
|
||||||
App::new("upgrade").about("Try to upgrade the client").arg(
|
pub(crate) struct Upgrade {
|
||||||
Arg::with_name("id")
|
/// Id of the nym-client we want to upgrade
|
||||||
.long("id")
|
#[clap(long)]
|
||||||
.help("Id of the nym-client we want to upgrade")
|
id: String,
|
||||||
.takes_value(true)
|
|
||||||
.required(true),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_config_version(config: &Config) -> Version {
|
fn parse_config_version(config: &Config) -> Version {
|
||||||
@@ -95,7 +93,7 @@ fn parse_package_version() -> Version {
|
|||||||
|
|
||||||
fn minor_0_12_upgrade(
|
fn minor_0_12_upgrade(
|
||||||
mut config: Config,
|
mut config: Config,
|
||||||
_matches: &ArgMatches<'_>,
|
_matches: &Upgrade,
|
||||||
config_version: &Version,
|
config_version: &Version,
|
||||||
package_version: &Version,
|
package_version: &Version,
|
||||||
) -> Config {
|
) -> Config {
|
||||||
@@ -107,15 +105,6 @@ fn minor_0_12_upgrade(
|
|||||||
|
|
||||||
print_start_upgrade(&config_version, &to_version);
|
print_start_upgrade(&config_version, &to_version);
|
||||||
|
|
||||||
println!(
|
|
||||||
"Setting validator API endpoints to {:?}",
|
|
||||||
default_api_endpoints()
|
|
||||||
);
|
|
||||||
|
|
||||||
config
|
|
||||||
.get_base_mut()
|
|
||||||
.set_custom_validator_apis(default_api_endpoints());
|
|
||||||
|
|
||||||
config
|
config
|
||||||
.get_base_mut()
|
.get_base_mut()
|
||||||
.set_custom_version(to_version.to_string().as_ref());
|
.set_custom_version(to_version.to_string().as_ref());
|
||||||
@@ -131,7 +120,7 @@ fn minor_0_12_upgrade(
|
|||||||
config
|
config
|
||||||
}
|
}
|
||||||
|
|
||||||
fn do_upgrade(mut config: Config, matches: &ArgMatches<'_>, package_version: &Version) {
|
fn do_upgrade(mut config: Config, args: &Upgrade, package_version: &Version) {
|
||||||
loop {
|
loop {
|
||||||
let config_version = parse_config_version(&config);
|
let config_version = parse_config_version(&config);
|
||||||
|
|
||||||
@@ -143,7 +132,7 @@ fn do_upgrade(mut config: Config, matches: &ArgMatches<'_>, package_version: &Ve
|
|||||||
config = match config_version.major {
|
config = match config_version.major {
|
||||||
0 => match config_version.minor {
|
0 => match config_version.minor {
|
||||||
9 | 10 => outdated_upgrade(&config_version, package_version),
|
9 | 10 => outdated_upgrade(&config_version, package_version),
|
||||||
11 => minor_0_12_upgrade(config, matches, &config_version, package_version),
|
11 => minor_0_12_upgrade(config, args, &config_version, package_version),
|
||||||
_ => unsupported_upgrade(&config_version, package_version),
|
_ => unsupported_upgrade(&config_version, package_version),
|
||||||
},
|
},
|
||||||
_ => unsupported_upgrade(&config_version, package_version),
|
_ => unsupported_upgrade(&config_version, package_version),
|
||||||
@@ -151,10 +140,10 @@ fn do_upgrade(mut config: Config, matches: &ArgMatches<'_>, package_version: &Ve
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn execute(matches: &ArgMatches<'_>) {
|
pub(crate) fn execute(args: &Upgrade) {
|
||||||
let package_version = parse_package_version();
|
let package_version = parse_package_version();
|
||||||
|
|
||||||
let id = matches.value_of("id").unwrap();
|
let id = &args.id;
|
||||||
|
|
||||||
let existing_config = Config::load_from_file(Some(id)).unwrap_or_else(|err| {
|
let existing_config = Config::load_from_file(Some(id)).unwrap_or_else(|err| {
|
||||||
eprintln!("failed to load existing config file! - {:?}", err);
|
eprintln!("failed to load existing config file! - {:?}", err);
|
||||||
@@ -167,5 +156,5 @@ pub fn execute(matches: &ArgMatches<'_>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// here be upgrade path to 0.9.X and beyond based on version number from config
|
// here be upgrade path to 0.9.X and beyond based on version number from config
|
||||||
do_upgrade(existing_config, matches, &package_version)
|
do_upgrade(existing_config, args, &package_version)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use clap::{crate_version, App, ArgMatches};
|
use clap::{crate_version, Parser};
|
||||||
use network_defaults::DEFAULT_NETWORK;
|
use network_defaults::setup_env;
|
||||||
|
|
||||||
pub mod client;
|
pub mod client;
|
||||||
pub mod commands;
|
pub mod commands;
|
||||||
@@ -10,34 +10,12 @@ pub mod websocket;
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
dotenv::dotenv().ok();
|
|
||||||
setup_logging();
|
setup_logging();
|
||||||
println!("{}", banner());
|
println!("{}", banner());
|
||||||
|
|
||||||
let arg_matches = App::new("Nym Client")
|
let args = commands::Cli::parse();
|
||||||
.version(crate_version!())
|
setup_env(args.config_env_file.clone());
|
||||||
.long_version(&*long_version())
|
commands::execute(&args).await;
|
||||||
.author("Nymtech")
|
|
||||||
.about("Implementation of the Nym Client")
|
|
||||||
.subcommand(commands::init::command_args())
|
|
||||||
.subcommand(commands::run::command_args())
|
|
||||||
.subcommand(commands::upgrade::command_args())
|
|
||||||
.get_matches();
|
|
||||||
|
|
||||||
execute(arg_matches).await;
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn execute(matches: ArgMatches<'static>) {
|
|
||||||
match matches.subcommand() {
|
|
||||||
("init", Some(m)) => commands::init::execute(m.clone()).await,
|
|
||||||
("run", Some(m)) => commands::run::execute(m.clone()).await,
|
|
||||||
("upgrade", Some(m)) => commands::upgrade::execute(m),
|
|
||||||
_ => println!("{}", usage()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn usage() -> &'static str {
|
|
||||||
"usage: --help to see available options.\n\n"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn banner() -> String {
|
fn banner() -> String {
|
||||||
@@ -57,40 +35,6 @@ fn banner() -> String {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn long_version() -> String {
|
|
||||||
format!(
|
|
||||||
r#"
|
|
||||||
{:<20}{}
|
|
||||||
{:<20}{}
|
|
||||||
{:<20}{}
|
|
||||||
{:<20}{}
|
|
||||||
{:<20}{}
|
|
||||||
{:<20}{}
|
|
||||||
{:<20}{}
|
|
||||||
{:<20}{}
|
|
||||||
{:<20}{}
|
|
||||||
"#,
|
|
||||||
"Build Timestamp:",
|
|
||||||
env!("VERGEN_BUILD_TIMESTAMP"),
|
|
||||||
"Build Version:",
|
|
||||||
env!("VERGEN_BUILD_SEMVER"),
|
|
||||||
"Commit SHA:",
|
|
||||||
env!("VERGEN_GIT_SHA"),
|
|
||||||
"Commit Date:",
|
|
||||||
env!("VERGEN_GIT_COMMIT_TIMESTAMP"),
|
|
||||||
"Commit Branch:",
|
|
||||||
env!("VERGEN_GIT_BRANCH"),
|
|
||||||
"rustc Version:",
|
|
||||||
env!("VERGEN_RUSTC_SEMVER"),
|
|
||||||
"rustc Channel:",
|
|
||||||
env!("VERGEN_RUSTC_CHANNEL"),
|
|
||||||
"cargo Profile:",
|
|
||||||
env!("VERGEN_CARGO_PROFILE"),
|
|
||||||
"Network:",
|
|
||||||
DEFAULT_NETWORK
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn setup_logging() {
|
fn setup_logging() {
|
||||||
let mut log_builder = pretty_env_logger::formatted_timed_builder();
|
let mut log_builder = pretty_env_logger::formatted_timed_builder();
|
||||||
if let Ok(s) = ::std::env::var("RUST_LOG") {
|
if let Ok(s) = ::std::env::var("RUST_LOG") {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use std::fmt;
|
use std::fmt;
|
||||||
|
|
||||||
// no need to go fancy here like we've done in other places.
|
// no need to go fancy here like we've done in other places.
|
||||||
#[derive(PartialEq, Clone, Serialize, Deserialize)]
|
#[derive(PartialEq, Eq, Clone, Serialize, Deserialize)]
|
||||||
pub struct Error {
|
pub struct Error {
|
||||||
pub kind: ErrorKind,
|
pub kind: ErrorKind,
|
||||||
pub message: String,
|
pub message: String,
|
||||||
@@ -30,7 +30,7 @@ impl Error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[repr(u8)]
|
#[repr(u8)]
|
||||||
#[derive(PartialEq, Clone, Serialize, Deserialize)]
|
#[derive(PartialEq, Eq, Clone, Serialize, Deserialize)]
|
||||||
pub enum ErrorKind {
|
pub enum ErrorKind {
|
||||||
/// The received request contained no data.
|
/// The received request contained no data.
|
||||||
EmptyRequest = 0x01,
|
EmptyRequest = 0x01,
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "nym-socks5-client"
|
name = "nym-socks5-client"
|
||||||
version = "1.0.1"
|
version = "1.0.2"
|
||||||
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>"]
|
authors = ["Dave Hrycyszyn <futurechimp@users.noreply.github.com>"]
|
||||||
|
description = "A SOCKS5 localhost proxy that converts incoming messages to Sphinx and sends them to a Nym address"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
rust-version = "1.56"
|
rust-version = "1.56"
|
||||||
|
|
||||||
@@ -10,9 +11,8 @@ name = "nym_socks5"
|
|||||||
path = "src/lib.rs"
|
path = "src/lib.rs"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
clap = "2.33.0"
|
clap = { version = "3.2.8", features = ["cargo", "derive"] }
|
||||||
dirs = "3.0" # for determining default store directories in config
|
dirs = "4.0"
|
||||||
dotenv = "0.15.0"
|
|
||||||
futures = "0.3"
|
futures = "0.3"
|
||||||
log = "0.4"
|
log = "0.4"
|
||||||
pin-project = "1.0"
|
pin-project = "1.0"
|
||||||
|
|||||||
@@ -33,6 +33,10 @@ impl NymConfig for Config {
|
|||||||
.join("socks5-clients")
|
.join("socks5-clients")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn try_default_root_directory() -> Option<PathBuf> {
|
||||||
|
dirs::home_dir().map(|path| path.join(".nym").join("socks5-clients"))
|
||||||
|
}
|
||||||
|
|
||||||
fn root_directory(&self) -> PathBuf {
|
fn root_directory(&self) -> PathBuf {
|
||||||
self.base.get_nym_root_directory()
|
self.base.get_nym_root_directory()
|
||||||
}
|
}
|
||||||
@@ -89,7 +93,7 @@ impl Config {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Deserialize, PartialEq, Serialize)]
|
#[derive(Debug, Deserialize, PartialEq, Eq, Serialize)]
|
||||||
#[serde(deny_unknown_fields)]
|
#[serde(deny_unknown_fields)]
|
||||||
pub struct Socks5 {
|
pub struct Socks5 {
|
||||||
/// The port on which the client will be listening for incoming requests
|
/// The port on which the client will be listening for incoming requests
|
||||||
|
|||||||
@@ -198,9 +198,9 @@ impl NymClient {
|
|||||||
Some(bandwidth_controller),
|
Some(bandwidth_controller),
|
||||||
);
|
);
|
||||||
|
|
||||||
if self.config.get_base().get_disabled_credentials_mode() {
|
gateway_client
|
||||||
gateway_client.set_disabled_credentials_mode(true)
|
.set_disabled_credentials_mode(self.config.get_base().get_disabled_credentials_mode());
|
||||||
}
|
|
||||||
gateway_client
|
gateway_client
|
||||||
.authenticate_and_start()
|
.authenticate_and_start()
|
||||||
.await
|
.await
|
||||||
@@ -287,12 +287,15 @@ impl NymClient {
|
|||||||
pub async fn run_and_listen(&mut self, mut receiver: Socks5ControlMessageReceiver) {
|
pub async fn run_and_listen(&mut self, mut receiver: Socks5ControlMessageReceiver) {
|
||||||
self.start().await;
|
self.start().await;
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
message = receiver.next() => match message {
|
message = receiver.next() => {
|
||||||
Some(Socks5ControlMessage::Stop) => {
|
log::debug!("Received message: {:?}", message);
|
||||||
log::info!("Received: {:?}", message);
|
match message {
|
||||||
log::info!("Shutting down");
|
Some(Socks5ControlMessage::Stop) => {
|
||||||
|
log::info!("Shutting down");
|
||||||
|
log::info!("Graceful shutdown of tasks not yet implemented, you might see (harmless) panics until then");
|
||||||
|
}
|
||||||
|
None => log::debug!("None"),
|
||||||
}
|
}
|
||||||
None => log::info!("none"),
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,91 +1,99 @@
|
|||||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use clap::{App, Arg, ArgMatches};
|
use clap::Args;
|
||||||
use client_core::config::GatewayEndpoint;
|
use client_core::config::GatewayEndpoint;
|
||||||
use config::NymConfig;
|
use config::NymConfig;
|
||||||
|
|
||||||
use crate::client::config::Config;
|
use crate::{
|
||||||
use crate::commands::override_config;
|
client::config::Config,
|
||||||
#[cfg(feature = "eth")]
|
commands::{override_config, OverrideConfig},
|
||||||
#[cfg(not(feature = "coconut"))]
|
|
||||||
use crate::commands::{
|
|
||||||
DEFAULT_ETH_ENDPOINT, DEFAULT_ETH_PRIVATE_KEY, ENABLED_CREDENTIALS_MODE_ARG_NAME,
|
|
||||||
ETH_ENDPOINT_ARG_NAME, ETH_PRIVATE_KEY_ARG_NAME,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
pub fn command_args<'a, 'b>() -> clap::App<'a, 'b> {
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
let app = App::new("init")
|
use crate::commands::{DEFAULT_ETH_ENDPOINT, DEFAULT_ETH_PRIVATE_KEY};
|
||||||
.about("Initialise a Nym client. Do this first!")
|
|
||||||
.arg(Arg::with_name("id")
|
|
||||||
.long("id")
|
|
||||||
.help("Id of the nym-mixnet-client we want to create config for.")
|
|
||||||
.takes_value(true)
|
|
||||||
.required(true)
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name("provider")
|
|
||||||
.long("provider")
|
|
||||||
.help("Address of the socks5 provider to send messages to.")
|
|
||||||
.takes_value(true)
|
|
||||||
.required(true)
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name("gateway")
|
|
||||||
.long("gateway")
|
|
||||||
.help("Id of the gateway we are going to connect to.")
|
|
||||||
.takes_value(true)
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name("force-register-gateway")
|
|
||||||
.long("force-register-gateway")
|
|
||||||
.help("Force register gateway. WARNING: this will overwrite any existing keys for the given id, potentially causing loss of access.")
|
|
||||||
.takes_value(false)
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name("validators")
|
|
||||||
.long("validators")
|
|
||||||
.help("Comma separated list of rest endpoints of the validators")
|
|
||||||
.takes_value(true),
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name("port")
|
|
||||||
.short("p")
|
|
||||||
.long("port")
|
|
||||||
.help("Port for the socket to listen on in all subsequent runs")
|
|
||||||
.takes_value(true)
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name("fastmode")
|
|
||||||
.long("fastmode")
|
|
||||||
.hidden(true) // this will prevent this flag from being displayed in `--help`
|
|
||||||
.help("Mostly debug-related option to increase default traffic rate so that you would not need to modify config post init")
|
|
||||||
);
|
|
||||||
#[cfg(feature = "eth")]
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
|
||||||
let app = app
|
|
||||||
.arg(
|
|
||||||
Arg::with_name(ENABLED_CREDENTIALS_MODE_ARG_NAME)
|
|
||||||
.long(ENABLED_CREDENTIALS_MODE_ARG_NAME)
|
|
||||||
.help("Set this client to work in a enabled credentials mode that would attempt to use gateway with bandwidth credential requirement. If this value is set, --eth_endpoint and --eth_private_key don't need to be set.")
|
|
||||||
.conflicts_with_all(&[ETH_ENDPOINT_ARG_NAME, ETH_PRIVATE_KEY_ARG_NAME])
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name(ETH_ENDPOINT_ARG_NAME)
|
|
||||||
.long(ETH_ENDPOINT_ARG_NAME)
|
|
||||||
.help("URL of an Ethereum full node that we want to use for getting bandwidth tokens from ERC20 tokens. If you don't want to set this value, use --testnet-mode instead")
|
|
||||||
.takes_value(true)
|
|
||||||
.default_value_if(ENABLED_CREDENTIALS_MODE_ARG_NAME, None, DEFAULT_ETH_ENDPOINT)
|
|
||||||
.required(true))
|
|
||||||
.arg(Arg::with_name(ETH_PRIVATE_KEY_ARG_NAME)
|
|
||||||
.long(ETH_PRIVATE_KEY_ARG_NAME)
|
|
||||||
.help("Ethereum private key used for obtaining bandwidth tokens from ERC20 tokens. If you don't want to set this value, use --testnet-mode instead")
|
|
||||||
.takes_value(true)
|
|
||||||
.default_value_if(ENABLED_CREDENTIALS_MODE_ARG_NAME, None, DEFAULT_ETH_PRIVATE_KEY)
|
|
||||||
.required(true)
|
|
||||||
);
|
|
||||||
|
|
||||||
app
|
#[derive(Args, Clone)]
|
||||||
|
pub(crate) struct Init {
|
||||||
|
/// Id of the nym-mixnet-client we want to create config for.
|
||||||
|
#[clap(long)]
|
||||||
|
id: String,
|
||||||
|
|
||||||
|
/// Address of the socks5 provider to send messages to.
|
||||||
|
#[clap(long)]
|
||||||
|
provider: String,
|
||||||
|
|
||||||
|
/// Id of the gateway we are going to connect to.
|
||||||
|
#[clap(long)]
|
||||||
|
gateway: Option<String>,
|
||||||
|
|
||||||
|
/// Force register gateway. WARNING: this will overwrite any existing keys for the given id,
|
||||||
|
/// potentially causing loss of access.
|
||||||
|
#[clap(long)]
|
||||||
|
force_register_gateway: bool,
|
||||||
|
|
||||||
|
/// Comma separated list of rest endpoints of the validators
|
||||||
|
#[clap(long)]
|
||||||
|
validators: Option<String>,
|
||||||
|
|
||||||
|
/// Port for the socket to listen on in all subsequent runs
|
||||||
|
#[clap(short, long)]
|
||||||
|
port: Option<u16>,
|
||||||
|
|
||||||
|
/// Mostly debug-related option to increase default traffic rate so that you would not need to
|
||||||
|
/// modify config post init
|
||||||
|
#[clap(long, hidden = true)]
|
||||||
|
fastmode: bool,
|
||||||
|
|
||||||
|
/// Set this client to work in a enabled credentials mode that would attempt to use gateway
|
||||||
|
/// with bandwidth credential requirement.
|
||||||
|
#[cfg(any(feature = "eth", feature = "coconut"))]
|
||||||
|
#[clap(long)]
|
||||||
|
enabled_credentials_mode: bool,
|
||||||
|
|
||||||
|
/// URL of an Ethereum full node that we want to use for getting bandwidth tokens from ERC20
|
||||||
|
/// tokens. If you don't want to set this value, use --enabled-credentials-mode instead
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
#[clap(
|
||||||
|
long,
|
||||||
|
default_value_if("enabled-credentials-mode", None, Some(DEFAULT_ETH_ENDPOINT))
|
||||||
|
)]
|
||||||
|
eth_endpoint: String,
|
||||||
|
|
||||||
|
/// Ethereum private key used for obtaining bandwidth tokens from ERC20 tokens. If you don't
|
||||||
|
/// want to set this value, use --enabled-credentials-mode instead")
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
#[clap(
|
||||||
|
long,
|
||||||
|
default_value_if("enabled-credentials-mode", None, Some(DEFAULT_ETH_PRIVATE_KEY))
|
||||||
|
)]
|
||||||
|
eth_private_key: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn execute(matches: ArgMatches<'static>) {
|
impl From<Init> for OverrideConfig {
|
||||||
|
fn from(init_config: Init) -> Self {
|
||||||
|
OverrideConfig {
|
||||||
|
validators: init_config.validators,
|
||||||
|
port: init_config.port,
|
||||||
|
fastmode: init_config.fastmode,
|
||||||
|
|
||||||
|
#[cfg(any(feature = "eth", feature = "coconut"))]
|
||||||
|
enabled_credentials_mode: init_config.enabled_credentials_mode,
|
||||||
|
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
eth_private_key: Some(init_config.eth_private_key),
|
||||||
|
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
eth_endpoint: Some(init_config.eth_endpoint),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn execute(args: &Init) {
|
||||||
println!("Initialising client...");
|
println!("Initialising client...");
|
||||||
|
|
||||||
let id = matches.value_of("id").unwrap(); // required for now
|
let id = &args.id;
|
||||||
let provider_address = matches.value_of("provider").unwrap();
|
let provider_address = &args.provider;
|
||||||
|
|
||||||
let already_init = Config::default_config_file_path(Some(id)).exists();
|
let already_init = Config::default_config_file_path(Some(id)).exists();
|
||||||
if already_init {
|
if already_init {
|
||||||
@@ -98,7 +106,7 @@ pub async fn execute(matches: ArgMatches<'static>) {
|
|||||||
|
|
||||||
// Usually you only register with the gateway on the first init, however you can force
|
// Usually you only register with the gateway on the first init, however you can force
|
||||||
// re-registering if wanted.
|
// re-registering if wanted.
|
||||||
let user_wants_force_register = matches.is_present("force-register-gateway");
|
let user_wants_force_register = args.force_register_gateway;
|
||||||
|
|
||||||
// If the client was already initialized, don't generate new keys and don't re-register with
|
// If the client was already initialized, don't generate new keys and don't re-register with
|
||||||
// the gateway (because this would create a new shared key).
|
// the gateway (because this would create a new shared key).
|
||||||
@@ -106,14 +114,11 @@ pub async fn execute(matches: ArgMatches<'static>) {
|
|||||||
let register_gateway = !already_init || user_wants_force_register;
|
let register_gateway = !already_init || user_wants_force_register;
|
||||||
|
|
||||||
// Attempt to use a user-provided gateway, if possible
|
// Attempt to use a user-provided gateway, if possible
|
||||||
let user_chosen_gateway_id = matches.value_of("gateway");
|
let user_chosen_gateway_id = args.gateway.as_deref();
|
||||||
|
|
||||||
let mut config = Config::new(id, provider_address);
|
let mut config = Config::new(id, provider_address);
|
||||||
|
let override_config_fields = OverrideConfig::from(args.clone());
|
||||||
config = override_config(config, &matches);
|
config = override_config(config, override_config_fields);
|
||||||
if matches.is_present("fastmode") {
|
|
||||||
config.get_base_mut().set_high_default_traffic_volume();
|
|
||||||
}
|
|
||||||
|
|
||||||
let gateway = setup_gateway(id, register_gateway, user_chosen_gateway_id, &config).await;
|
let gateway = setup_gateway(id, register_gateway, user_chosen_gateway_id, &config).await;
|
||||||
config.get_base_mut().with_gateway_endpoint(gateway);
|
config.get_base_mut().with_gateway_endpoint(gateway);
|
||||||
|
|||||||
@@ -2,18 +2,13 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use crate::client::config::Config;
|
use crate::client::config::Config;
|
||||||
use clap::ArgMatches;
|
use clap::{Parser, Subcommand};
|
||||||
use url::Url;
|
use config::parse_validators;
|
||||||
|
|
||||||
pub mod init;
|
pub mod init;
|
||||||
pub(crate) mod run;
|
pub(crate) mod run;
|
||||||
pub(crate) mod upgrade;
|
pub(crate) mod upgrade;
|
||||||
|
|
||||||
pub(crate) const ENABLED_CREDENTIALS_MODE_ARG_NAME: &str = "enabled-credentials-mode";
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
|
||||||
pub(crate) const ETH_ENDPOINT_ARG_NAME: &str = "eth_endpoint";
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
|
||||||
pub(crate) const ETH_PRIVATE_KEY_ARG_NAME: &str = "eth_private_key";
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
#[cfg(not(feature = "coconut"))]
|
||||||
pub(crate) const DEFAULT_ETH_ENDPOINT: &str =
|
pub(crate) const DEFAULT_ETH_ENDPOINT: &str =
|
||||||
"https://rinkeby.infura.io/v3/00000000000000000000000000000000";
|
"https://rinkeby.infura.io/v3/00000000000000000000000000000000";
|
||||||
@@ -21,52 +16,141 @@ pub(crate) const DEFAULT_ETH_ENDPOINT: &str =
|
|||||||
pub(crate) const DEFAULT_ETH_PRIVATE_KEY: &str =
|
pub(crate) const DEFAULT_ETH_PRIVATE_KEY: &str =
|
||||||
"0000000000000000000000000000000000000000000000000000000000000001";
|
"0000000000000000000000000000000000000000000000000000000000000001";
|
||||||
|
|
||||||
fn parse_validators(raw: &str) -> Vec<Url> {
|
fn long_version() -> String {
|
||||||
raw.split(',')
|
format!(
|
||||||
.map(|raw_validator| {
|
r#"
|
||||||
raw_validator
|
{:<20}{}
|
||||||
.trim()
|
{:<20}{}
|
||||||
.parse()
|
{:<20}{}
|
||||||
.expect("one of the provided validator api urls is invalid")
|
{:<20}{}
|
||||||
})
|
{:<20}{}
|
||||||
.collect()
|
{:<20}{}
|
||||||
|
{:<20}{}
|
||||||
|
{:<20}{}
|
||||||
|
"#,
|
||||||
|
"Build Timestamp:",
|
||||||
|
env!("VERGEN_BUILD_TIMESTAMP"),
|
||||||
|
"Build Version:",
|
||||||
|
env!("VERGEN_BUILD_SEMVER"),
|
||||||
|
"Commit SHA:",
|
||||||
|
env!("VERGEN_GIT_SHA"),
|
||||||
|
"Commit Date:",
|
||||||
|
env!("VERGEN_GIT_COMMIT_TIMESTAMP"),
|
||||||
|
"Commit Branch:",
|
||||||
|
env!("VERGEN_GIT_BRANCH"),
|
||||||
|
"rustc Version:",
|
||||||
|
env!("VERGEN_RUSTC_SEMVER"),
|
||||||
|
"rustc Channel:",
|
||||||
|
env!("VERGEN_RUSTC_CHANNEL"),
|
||||||
|
"cargo Profile:",
|
||||||
|
env!("VERGEN_CARGO_PROFILE"),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn override_config(mut config: Config, matches: &ArgMatches<'_>) -> Config {
|
fn long_version_static() -> &'static str {
|
||||||
if let Some(raw_validators) = matches.value_of("validators") {
|
Box::leak(long_version().into_boxed_str())
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Parser)]
|
||||||
|
#[clap(author = "Nymtech", version, long_version = long_version_static(), about)]
|
||||||
|
pub(crate) struct Cli {
|
||||||
|
/// Path pointing to an env file that configures the client.
|
||||||
|
#[clap(long)]
|
||||||
|
pub(crate) config_env_file: Option<std::path::PathBuf>,
|
||||||
|
|
||||||
|
#[clap(subcommand)]
|
||||||
|
command: Commands,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Subcommand)]
|
||||||
|
pub(crate) enum Commands {
|
||||||
|
/// Initialise a Nym client. Do this first!
|
||||||
|
Init(init::Init),
|
||||||
|
/// Run the Nym client with provided configuration client optionally overriding set parameters
|
||||||
|
Run(run::Run),
|
||||||
|
/// Try to upgrade the client
|
||||||
|
Upgrade(upgrade::Upgrade),
|
||||||
|
}
|
||||||
|
|
||||||
|
// Configuration that can be overridden.
|
||||||
|
pub(crate) struct OverrideConfig {
|
||||||
|
validators: Option<String>,
|
||||||
|
port: Option<u16>,
|
||||||
|
fastmode: bool,
|
||||||
|
|
||||||
|
#[cfg(any(feature = "eth", feature = "coconut"))]
|
||||||
|
enabled_credentials_mode: bool,
|
||||||
|
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
eth_private_key: Option<String>,
|
||||||
|
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
eth_endpoint: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn execute(args: &Cli) {
|
||||||
|
match &args.command {
|
||||||
|
Commands::Init(m) => init::execute(m).await,
|
||||||
|
Commands::Run(m) => run::execute(m).await,
|
||||||
|
Commands::Upgrade(m) => upgrade::execute(m),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn override_config(mut config: Config, args: OverrideConfig) -> Config {
|
||||||
|
if let Some(raw_validators) = args.validators {
|
||||||
config
|
config
|
||||||
.get_base_mut()
|
.get_base_mut()
|
||||||
.set_custom_validator_apis(parse_validators(raw_validators));
|
.set_custom_validator_apis(parse_validators(&raw_validators));
|
||||||
|
} else if let Ok(raw_validators) = std::env::var(network_defaults::var_names::API_VALIDATOR) {
|
||||||
|
config
|
||||||
|
.get_base_mut()
|
||||||
|
.set_custom_validator_apis(parse_validators(&raw_validators));
|
||||||
}
|
}
|
||||||
|
|
||||||
if let Some(port) = matches.value_of("port").map(|port| port.parse::<u16>()) {
|
if let Some(port) = args.port {
|
||||||
if let Err(err) = port {
|
config = config.with_port(port);
|
||||||
// if port was overridden, it must be parsable
|
}
|
||||||
panic!("Invalid port value provided - {:?}", err);
|
|
||||||
|
#[cfg(all(not(feature = "eth"), not(feature = "coconut")))]
|
||||||
|
{
|
||||||
|
config
|
||||||
|
.get_base_mut()
|
||||||
|
.with_eth_endpoint(DEFAULT_ETH_ENDPOINT.to_string());
|
||||||
|
config
|
||||||
|
.get_base_mut()
|
||||||
|
.with_eth_private_key(DEFAULT_ETH_PRIVATE_KEY.to_string());
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(any(feature = "eth", feature = "coconut"))]
|
||||||
|
{
|
||||||
|
if args.enabled_credentials_mode {
|
||||||
|
config.get_base_mut().with_disabled_credentials(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
{
|
||||||
|
if let Some(eth_endpoint) = args.eth_endpoint {
|
||||||
|
config.get_base_mut().with_eth_endpoint(eth_endpoint);
|
||||||
|
}
|
||||||
|
if let Some(eth_private_key) = args.eth_private_key {
|
||||||
|
config.get_base_mut().with_eth_private_key(eth_private_key);
|
||||||
}
|
}
|
||||||
config = config.with_port(port.unwrap());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
if args.fastmode {
|
||||||
if let Some(eth_endpoint) = matches.value_of(ETH_ENDPOINT_ARG_NAME) {
|
config.get_base_mut().set_high_default_traffic_volume();
|
||||||
config.get_base_mut().with_eth_endpoint(eth_endpoint);
|
|
||||||
} else if !cfg!(feature = "eth") {
|
|
||||||
config
|
|
||||||
.get_base_mut()
|
|
||||||
.with_eth_endpoint(DEFAULT_ETH_ENDPOINT);
|
|
||||||
}
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
|
||||||
if let Some(eth_private_key) = matches.value_of(ETH_PRIVATE_KEY_ARG_NAME) {
|
|
||||||
config.get_base_mut().with_eth_private_key(eth_private_key);
|
|
||||||
} else if !cfg!(feature = "eth") {
|
|
||||||
config
|
|
||||||
.get_base_mut()
|
|
||||||
.with_eth_private_key(DEFAULT_ETH_PRIVATE_KEY);
|
|
||||||
}
|
|
||||||
|
|
||||||
if matches.is_present(ENABLED_CREDENTIALS_MODE_ARG_NAME) {
|
|
||||||
config.get_base_mut().with_disabled_credentials(false)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config
|
config
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use clap::CommandFactory;
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn verify_cli() {
|
||||||
|
Cli::command().debug_assert();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,74 +1,79 @@
|
|||||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use crate::client::config::Config;
|
use crate::{
|
||||||
use crate::client::NymClient;
|
client::{config::Config, NymClient},
|
||||||
use crate::commands::override_config;
|
commands::{override_config, OverrideConfig},
|
||||||
#[cfg(feature = "eth")]
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
|
||||||
use crate::commands::{
|
|
||||||
ENABLED_CREDENTIALS_MODE_ARG_NAME, ETH_ENDPOINT_ARG_NAME, ETH_PRIVATE_KEY_ARG_NAME,
|
|
||||||
};
|
};
|
||||||
use clap::{App, Arg, ArgMatches};
|
|
||||||
|
use clap::Args;
|
||||||
use config::NymConfig;
|
use config::NymConfig;
|
||||||
use log::*;
|
use log::*;
|
||||||
use version_checker::is_minor_version_compatible;
|
use version_checker::is_minor_version_compatible;
|
||||||
|
|
||||||
pub fn command_args<'a, 'b>() -> clap::App<'a, 'b> {
|
#[derive(Args, Clone)]
|
||||||
let app = App::new("run")
|
pub(crate) struct Run {
|
||||||
.about("Run the Nym client with provided configuration client optionally overriding set parameters")
|
/// Id of the nym-mixnet-client we want to run.
|
||||||
.arg(Arg::with_name("id")
|
#[clap(long)]
|
||||||
.long("id")
|
id: String,
|
||||||
.help("Id of the nym-mixnet-client we want to run.")
|
|
||||||
.takes_value(true)
|
|
||||||
.required(true)
|
|
||||||
)
|
|
||||||
// the rest of arguments are optional, they are used to override settings in config file
|
|
||||||
.arg(Arg::with_name("config")
|
|
||||||
.long("config")
|
|
||||||
.help("Custom path to the nym-mixnet-client configuration file")
|
|
||||||
.takes_value(true)
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name("provider")
|
|
||||||
.long("provider")
|
|
||||||
.help("Address of the socks5 provider to send messages to.")
|
|
||||||
.takes_value(true)
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name("gateway")
|
|
||||||
.long("gateway")
|
|
||||||
.help("Id of the gateway we want to connect to. If overridden, it is user's responsibility to ensure prior registration happened")
|
|
||||||
.takes_value(true)
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name("validators")
|
|
||||||
.long("validators")
|
|
||||||
.help("Comma separated list of rest endpoints of the validators")
|
|
||||||
.takes_value(true),
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name("port")
|
|
||||||
.short("p")
|
|
||||||
.long("port")
|
|
||||||
.help("Port for the socket to listen on")
|
|
||||||
.takes_value(true)
|
|
||||||
);
|
|
||||||
#[cfg(feature = "eth")]
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
|
||||||
let app = app
|
|
||||||
.arg(
|
|
||||||
Arg::with_name(ENABLED_CREDENTIALS_MODE_ARG_NAME)
|
|
||||||
.long(ENABLED_CREDENTIALS_MODE_ARG_NAME)
|
|
||||||
.help("Set this client to work in a disabled credentials mode that would attempt to use gateway without bandwidth credential requirement. If this value is set, --eth_endpoint and --eth_private_key don't need to be set.")
|
|
||||||
.conflicts_with_all(&[ETH_ENDPOINT_ARG_NAME, ETH_PRIVATE_KEY_ARG_NAME])
|
|
||||||
)
|
|
||||||
.arg(Arg::with_name(ETH_ENDPOINT_ARG_NAME)
|
|
||||||
.long(ETH_ENDPOINT_ARG_NAME)
|
|
||||||
.help("URL of an Ethereum full node that we want to use for getting bandwidth tokens from ERC20 tokens. If you don't want to set this value, use --testnet-mode instead")
|
|
||||||
.takes_value(true))
|
|
||||||
.arg(Arg::with_name(ETH_PRIVATE_KEY_ARG_NAME)
|
|
||||||
.long(ETH_PRIVATE_KEY_ARG_NAME)
|
|
||||||
.help("Ethereum private key used for obtaining bandwidth tokens from ERC20 tokens. If you don't want to set this value, use --testnet-mode instead")
|
|
||||||
.takes_value(true));
|
|
||||||
|
|
||||||
app
|
/// Custom path to the nym-mixnet-client configuration file
|
||||||
|
#[clap(long)]
|
||||||
|
config: Option<String>,
|
||||||
|
|
||||||
|
/// Address of the socks5 provider to send messages to.
|
||||||
|
#[clap(long)]
|
||||||
|
provider: Option<String>,
|
||||||
|
|
||||||
|
/// Id of the gateway we want to connect to. If overridden, it is user's responsibility to
|
||||||
|
/// ensure prior registration happened
|
||||||
|
#[clap(long)]
|
||||||
|
gateway: Option<String>,
|
||||||
|
|
||||||
|
/// Comma separated list of rest endpoints of the validators
|
||||||
|
#[clap(long)]
|
||||||
|
validators: Option<String>,
|
||||||
|
|
||||||
|
/// Port for the socket to listen on
|
||||||
|
#[clap(short, long)]
|
||||||
|
port: Option<u16>,
|
||||||
|
|
||||||
|
/// Set this client to work in a enabled credentials mode that would attempt to use gateway
|
||||||
|
/// with bandwidth credential requirement.
|
||||||
|
#[cfg(any(feature = "eth", feature = "coconut"))]
|
||||||
|
#[clap(long)]
|
||||||
|
enabled_credentials_mode: bool,
|
||||||
|
|
||||||
|
/// URL of an Ethereum full node that we want to use for getting bandwidth tokens from ERC20
|
||||||
|
/// tokens. If you don't want to set this value, use --enabled-credentials-mode instead
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
#[clap(long)]
|
||||||
|
eth_endpoint: Option<String>,
|
||||||
|
|
||||||
|
/// Ethereum private key used for obtaining bandwidth tokens from ERC20 tokens. If you don't
|
||||||
|
/// want to set this value, use --enabled-credentials-mode instead
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
#[clap(long)]
|
||||||
|
eth_private_key: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Run> for OverrideConfig {
|
||||||
|
fn from(run_config: Run) -> Self {
|
||||||
|
OverrideConfig {
|
||||||
|
validators: run_config.validators,
|
||||||
|
port: run_config.port,
|
||||||
|
fastmode: false,
|
||||||
|
|
||||||
|
#[cfg(any(feature = "eth", feature = "coconut"))]
|
||||||
|
enabled_credentials_mode: run_config.enabled_credentials_mode,
|
||||||
|
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
eth_private_key: run_config.eth_private_key,
|
||||||
|
|
||||||
|
#[cfg(all(feature = "eth", not(feature = "coconut")))]
|
||||||
|
eth_endpoint: run_config.eth_endpoint,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// this only checks compatibility between config the binary. It does not take into consideration
|
// this only checks compatibility between config the binary. It does not take into consideration
|
||||||
@@ -76,8 +81,13 @@ pub fn command_args<'a, 'b>() -> clap::App<'a, 'b> {
|
|||||||
fn version_check(cfg: &Config) -> bool {
|
fn version_check(cfg: &Config) -> bool {
|
||||||
let binary_version = env!("CARGO_PKG_VERSION");
|
let binary_version = env!("CARGO_PKG_VERSION");
|
||||||
let config_version = cfg.get_base().get_version();
|
let config_version = cfg.get_base().get_version();
|
||||||
if binary_version != config_version {
|
if binary_version == config_version {
|
||||||
warn!("The mixnode binary has different version than what is specified in config file! {} and {}", binary_version, config_version);
|
true
|
||||||
|
} else {
|
||||||
|
warn!(
|
||||||
|
"The mixnode binary has different version than what is specified in config file! {} and {}",
|
||||||
|
binary_version, config_version
|
||||||
|
);
|
||||||
if is_minor_version_compatible(binary_version, config_version) {
|
if is_minor_version_compatible(binary_version, config_version) {
|
||||||
info!("but they are still semver compatible. However, consider running the `upgrade` command");
|
info!("but they are still semver compatible. However, consider running the `upgrade` command");
|
||||||
true
|
true
|
||||||
@@ -85,13 +95,11 @@ fn version_check(cfg: &Config) -> bool {
|
|||||||
error!("and they are semver incompatible! - please run the `upgrade` command before attempting `run` again");
|
error!("and they are semver incompatible! - please run the `upgrade` command before attempting `run` again");
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
} else {
|
|
||||||
true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn execute(matches: ArgMatches<'static>) {
|
pub(crate) async fn execute(args: &Run) {
|
||||||
let id = matches.value_of("id").unwrap();
|
let id = &args.id;
|
||||||
|
|
||||||
let mut config = match Config::load_from_file(Some(id)) {
|
let mut config = match Config::load_from_file(Some(id)) {
|
||||||
Ok(cfg) => cfg,
|
Ok(cfg) => cfg,
|
||||||
@@ -101,7 +109,8 @@ pub async fn execute(matches: ArgMatches<'static>) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
config = override_config(config, &matches);
|
let override_config_fields = OverrideConfig::from(args.clone());
|
||||||
|
config = override_config(config, override_config_fields);
|
||||||
|
|
||||||
if !version_check(&config) {
|
if !version_check(&config) {
|
||||||
error!("failed the local version check");
|
error!("failed the local version check");
|
||||||
|
|||||||
@@ -2,13 +2,13 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use crate::client::config::{Config, MISSING_VALUE};
|
use crate::client::config::{Config, MISSING_VALUE};
|
||||||
use clap::{App, Arg, ArgMatches};
|
|
||||||
use config::defaults::default_api_endpoints;
|
|
||||||
use config::NymConfig;
|
use config::NymConfig;
|
||||||
use std::fmt::Display;
|
|
||||||
use std::process;
|
|
||||||
use version_checker::Version;
|
use version_checker::Version;
|
||||||
|
|
||||||
|
use clap::Args;
|
||||||
|
use std::{fmt::Display, process};
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
fn fail_upgrade<D1: Display, D2: Display>(from_version: D1, to_version: D2) -> ! {
|
fn fail_upgrade<D1: Display, D2: Display>(from_version: D1, to_version: D2) -> ! {
|
||||||
print_failed_upgrade(from_version, to_version);
|
print_failed_upgrade(from_version, to_version);
|
||||||
@@ -49,14 +49,11 @@ fn unsupported_upgrade(current_version: &Version, config_version: &Version) -> !
|
|||||||
process::exit(1)
|
process::exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn command_args<'a, 'b>() -> App<'a, 'b> {
|
#[derive(Args, Clone)]
|
||||||
App::new("upgrade").about("Try to upgrade the client").arg(
|
pub(crate) struct Upgrade {
|
||||||
Arg::with_name("id")
|
/// Id of the nym-client we want to upgrade
|
||||||
.long("id")
|
#[clap(long)]
|
||||||
.help("Id of the nym-client we want to upgrade")
|
id: String,
|
||||||
.takes_value(true)
|
|
||||||
.required(true),
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn parse_config_version(config: &Config) -> Version {
|
fn parse_config_version(config: &Config) -> Version {
|
||||||
@@ -95,7 +92,7 @@ fn parse_package_version() -> Version {
|
|||||||
|
|
||||||
fn minor_0_12_upgrade(
|
fn minor_0_12_upgrade(
|
||||||
mut config: Config,
|
mut config: Config,
|
||||||
_matches: &ArgMatches<'_>,
|
_args: &Upgrade,
|
||||||
config_version: &Version,
|
config_version: &Version,
|
||||||
package_version: &Version,
|
package_version: &Version,
|
||||||
) -> Config {
|
) -> Config {
|
||||||
@@ -107,15 +104,6 @@ fn minor_0_12_upgrade(
|
|||||||
|
|
||||||
print_start_upgrade(&config_version, &to_version);
|
print_start_upgrade(&config_version, &to_version);
|
||||||
|
|
||||||
println!(
|
|
||||||
"Setting validator API endpoints to {:?}",
|
|
||||||
default_api_endpoints()
|
|
||||||
);
|
|
||||||
|
|
||||||
config
|
|
||||||
.get_base_mut()
|
|
||||||
.set_custom_validator_apis(default_api_endpoints());
|
|
||||||
|
|
||||||
config
|
config
|
||||||
.get_base_mut()
|
.get_base_mut()
|
||||||
.set_custom_version(to_version.to_string().as_ref());
|
.set_custom_version(to_version.to_string().as_ref());
|
||||||
@@ -131,30 +119,30 @@ fn minor_0_12_upgrade(
|
|||||||
config
|
config
|
||||||
}
|
}
|
||||||
|
|
||||||
fn do_upgrade(mut config: Config, matches: &ArgMatches<'_>, package_version: Version) {
|
fn do_upgrade(mut config: Config, args: &Upgrade, package_version: &Version) {
|
||||||
loop {
|
loop {
|
||||||
let config_version = parse_config_version(&config);
|
let config_version = parse_config_version(&config);
|
||||||
|
|
||||||
if config_version == package_version {
|
if &config_version == package_version {
|
||||||
println!("You're using the most recent version!");
|
println!("You're using the most recent version!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
config = match config_version.major {
|
config = match config_version.major {
|
||||||
0 => match config_version.minor {
|
0 => match config_version.minor {
|
||||||
9 | 10 => outdated_upgrade(&config_version, &package_version),
|
9 | 10 => outdated_upgrade(&config_version, package_version),
|
||||||
11 => minor_0_12_upgrade(config, matches, &config_version, &package_version),
|
11 => minor_0_12_upgrade(config, args, &config_version, package_version),
|
||||||
_ => unsupported_upgrade(&config_version, &package_version),
|
_ => unsupported_upgrade(&config_version, package_version),
|
||||||
},
|
},
|
||||||
_ => unsupported_upgrade(&config_version, &package_version),
|
_ => unsupported_upgrade(&config_version, package_version),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn execute(matches: &ArgMatches<'_>) {
|
pub(crate) fn execute(args: &Upgrade) {
|
||||||
let package_version = parse_package_version();
|
let package_version = parse_package_version();
|
||||||
|
|
||||||
let id = matches.value_of("id").unwrap();
|
let id = &args.id;
|
||||||
|
|
||||||
let existing_config = Config::load_from_file(Some(id)).unwrap_or_else(|err| {
|
let existing_config = Config::load_from_file(Some(id)).unwrap_or_else(|err| {
|
||||||
eprintln!("failed to load existing config file! - {:?}", err);
|
eprintln!("failed to load existing config file! - {:?}", err);
|
||||||
@@ -167,5 +155,5 @@ pub fn execute(matches: &ArgMatches<'_>) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// here be upgrade path to 0.9.X and beyond based on version number from config
|
// here be upgrade path to 0.9.X and beyond based on version number from config
|
||||||
do_upgrade(existing_config, matches, package_version)
|
do_upgrade(existing_config, args, &package_version)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,9 +2,4 @@
|
|||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
pub mod client;
|
pub mod client;
|
||||||
// This is only used as we reach into the init functions in nym-connect. We need to refactor the
|
|
||||||
// init functions so that nym-connect can just call the same init function as the regular socks5
|
|
||||||
// client.
|
|
||||||
#[allow(unused)]
|
|
||||||
pub mod commands;
|
|
||||||
pub mod socks;
|
pub mod socks;
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
use clap::{crate_version, App, ArgMatches};
|
use clap::{crate_version, Parser};
|
||||||
use network_defaults::DEFAULT_NETWORK;
|
use network_defaults::setup_env;
|
||||||
|
|
||||||
pub mod client;
|
pub mod client;
|
||||||
mod commands;
|
mod commands;
|
||||||
@@ -10,34 +10,12 @@ pub mod socks;
|
|||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() {
|
async fn main() {
|
||||||
dotenv::dotenv().ok();
|
|
||||||
setup_logging();
|
setup_logging();
|
||||||
println!("{}", banner());
|
println!("{}", banner());
|
||||||
|
|
||||||
let arg_matches = App::new("Nym Socks5 Proxy")
|
let args = commands::Cli::parse();
|
||||||
.version(env!("CARGO_PKG_VERSION"))
|
setup_env(args.config_env_file.clone());
|
||||||
.author("Nymtech")
|
commands::execute(&args).await;
|
||||||
.long_version(&*long_version())
|
|
||||||
.about("A Socks5 localhost proxy that converts incoming messages to Sphinx and sends them to a Nym address")
|
|
||||||
.subcommand(commands::init::command_args())
|
|
||||||
.subcommand(commands::run::command_args())
|
|
||||||
.subcommand(commands::upgrade::command_args())
|
|
||||||
.get_matches();
|
|
||||||
|
|
||||||
execute(arg_matches).await;
|
|
||||||
}
|
|
||||||
|
|
||||||
async fn execute(matches: ArgMatches<'static>) {
|
|
||||||
match matches.subcommand() {
|
|
||||||
("init", Some(m)) => commands::init::execute(m.clone()).await,
|
|
||||||
("run", Some(m)) => commands::run::execute(m.clone()).await,
|
|
||||||
("upgrade", Some(m)) => commands::upgrade::execute(m),
|
|
||||||
_ => println!("{}", usage()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn usage() -> &'static str {
|
|
||||||
"usage: --help to see available options.\n\n"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fn banner() -> String {
|
fn banner() -> String {
|
||||||
@@ -57,40 +35,6 @@ fn banner() -> String {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn long_version() -> String {
|
|
||||||
format!(
|
|
||||||
r#"
|
|
||||||
{:<20}{}
|
|
||||||
{:<20}{}
|
|
||||||
{:<20}{}
|
|
||||||
{:<20}{}
|
|
||||||
{:<20}{}
|
|
||||||
{:<20}{}
|
|
||||||
{:<20}{}
|
|
||||||
{:<20}{}
|
|
||||||
{:<20}{}
|
|
||||||
"#,
|
|
||||||
"Build Timestamp:",
|
|
||||||
env!("VERGEN_BUILD_TIMESTAMP"),
|
|
||||||
"Build Version:",
|
|
||||||
env!("VERGEN_BUILD_SEMVER"),
|
|
||||||
"Commit SHA:",
|
|
||||||
env!("VERGEN_GIT_SHA"),
|
|
||||||
"Commit Date:",
|
|
||||||
env!("VERGEN_GIT_COMMIT_TIMESTAMP"),
|
|
||||||
"Commit Branch:",
|
|
||||||
env!("VERGEN_GIT_BRANCH"),
|
|
||||||
"rustc Version:",
|
|
||||||
env!("VERGEN_RUSTC_SEMVER"),
|
|
||||||
"rustc Channel:",
|
|
||||||
env!("VERGEN_RUSTC_CHANNEL"),
|
|
||||||
"cargo Profile:",
|
|
||||||
env!("VERGEN_CARGO_PROFILE"),
|
|
||||||
"Network:",
|
|
||||||
DEFAULT_NETWORK
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn setup_logging() {
|
fn setup_logging() {
|
||||||
let mut log_builder = pretty_env_logger::formatted_timed_builder();
|
let mut log_builder = pretty_env_logger::formatted_timed_builder();
|
||||||
if let Ok(s) = ::std::env::var("RUST_LOG") {
|
if let Ok(s) = ::std::env::var("RUST_LOG") {
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ pub(crate) enum AuthenticationMethods {
|
|||||||
NoMethods = 0xFF,
|
NoMethods = 0xFF,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug, PartialEq, Eq)]
|
||||||
/// A socks5 user with a matching password.
|
/// A socks5 user with a matching password.
|
||||||
pub struct User {
|
pub struct User {
|
||||||
pub username: String,
|
pub username: String,
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use futures::StreamExt;
|
|||||||
use log::*;
|
use log::*;
|
||||||
use nymsphinx::receiver::ReconstructedMessage;
|
use nymsphinx::receiver::ReconstructedMessage;
|
||||||
use proxy_helpers::connection_controller::{ControllerCommand, ControllerSender};
|
use proxy_helpers::connection_controller::{ControllerCommand, ControllerSender};
|
||||||
use socks5_requests::Response;
|
use socks5_requests::Message;
|
||||||
|
|
||||||
pub(crate) struct MixnetResponseListener {
|
pub(crate) struct MixnetResponseListener {
|
||||||
buffer_requester: ReceivedBufferRequestSender,
|
buffer_requester: ReceivedBufferRequestSender,
|
||||||
@@ -44,12 +44,23 @@ impl MixnetResponseListener {
|
|||||||
warn!("this message had a surb - we didn't do anything with it");
|
warn!("this message had a surb - we didn't do anything with it");
|
||||||
}
|
}
|
||||||
|
|
||||||
let response = match Response::try_from_bytes(&raw_message) {
|
let response = match Message::try_from_bytes(&raw_message) {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
warn!("failed to parse received response - {:?}", err);
|
warn!("failed to parse received response - {:?}", err);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Ok(data) => data,
|
Ok(Message::Request(_)) => {
|
||||||
|
warn!("unexpected request");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Ok(Message::Response(data)) => data,
|
||||||
|
Ok(Message::NetworkRequesterResponse(r)) => {
|
||||||
|
error!(
|
||||||
|
"Network requester failed on connection id {} with error: {}",
|
||||||
|
r.connection_id, r.network_requester_error
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
self.controller_sender
|
self.controller_sender
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
15.0.1
|
16
|
||||||
@@ -31,9 +31,12 @@
|
|||||||
"eslint-plugin-import": "^2.25.4",
|
"eslint-plugin-import": "^2.25.4",
|
||||||
"eslint-plugin-mocha": "^10.0.3",
|
"eslint-plugin-mocha": "^10.0.3",
|
||||||
"eslint-plugin-prettier": "^4.0.0",
|
"eslint-plugin-prettier": "^4.0.0",
|
||||||
|
"expect": "^28.1.3",
|
||||||
|
"mocha": "^10.0.0",
|
||||||
"prettier": "^2.5.1",
|
"prettier": "^2.5.1",
|
||||||
"typedoc": "^0.22.13",
|
"typedoc": "^0.22.13",
|
||||||
"typescript": "^4.1.3"
|
"ts-mocha": "^10.0.0",
|
||||||
|
"typescript": "^4.6.2"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@cosmjs/cosmwasm-stargate": "^0.28.0",
|
"@cosmjs/cosmwasm-stargate": "^0.28.0",
|
||||||
|
|||||||
@@ -64,23 +64,20 @@ export default class ValidatorClient implements INymClient {
|
|||||||
|
|
||||||
readonly vestingContract: string;
|
readonly vestingContract: string;
|
||||||
|
|
||||||
readonly mainnetDenom = "unym";
|
readonly mainnetDenom = 'unym';
|
||||||
|
|
||||||
readonly mainnetPrefix = "n";
|
readonly mainnetPrefix = 'n';
|
||||||
|
|
||||||
private constructor(
|
private constructor(
|
||||||
client: SigningClient | QueryClient,
|
client: SigningClient | QueryClient,
|
||||||
prefix: string,
|
prefix: string,
|
||||||
mixnetContract: string,
|
mixnetContract: string,
|
||||||
vestingContract: string
|
vestingContract: string,
|
||||||
|
denom: string,
|
||||||
) {
|
) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
this.prefix = prefix;
|
this.prefix = prefix;
|
||||||
if (prefix == this.mainnetPrefix) {
|
this.denom = `u${denom}`;
|
||||||
this.denom = this.mainnetDenom;
|
|
||||||
} else {
|
|
||||||
this.denom = `u${prefix}`;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.mixnetContract = mixnetContract;
|
this.mixnetContract = mixnetContract;
|
||||||
this.vestingContract = vestingContract;
|
this.vestingContract = vestingContract;
|
||||||
@@ -93,11 +90,12 @@ export default class ValidatorClient implements INymClient {
|
|||||||
prefix: string,
|
prefix: string,
|
||||||
mixnetContract: string,
|
mixnetContract: string,
|
||||||
vestingContract: string,
|
vestingContract: string,
|
||||||
|
denom: string,
|
||||||
): Promise<ValidatorClient> {
|
): Promise<ValidatorClient> {
|
||||||
const wallet = await ValidatorClient.buildWallet(mnemonic, prefix);
|
const wallet = await ValidatorClient.buildWallet(mnemonic, prefix);
|
||||||
|
|
||||||
const signingClient = await SigningClient.connectWithNymSigner(wallet, nymdUrl, validatorApiUrl, prefix);
|
const signingClient = await SigningClient.connectWithNymSigner(wallet, nymdUrl, validatorApiUrl, prefix, denom);
|
||||||
return new ValidatorClient(signingClient, prefix, mixnetContract, vestingContract);
|
return new ValidatorClient(signingClient, prefix, mixnetContract, vestingContract, denom);
|
||||||
}
|
}
|
||||||
|
|
||||||
static async connectForQuery(
|
static async connectForQuery(
|
||||||
@@ -106,9 +104,10 @@ export default class ValidatorClient implements INymClient {
|
|||||||
prefix: string,
|
prefix: string,
|
||||||
mixnetContract: string,
|
mixnetContract: string,
|
||||||
vestingContract: string,
|
vestingContract: string,
|
||||||
|
denom: string,
|
||||||
): Promise<ValidatorClient> {
|
): Promise<ValidatorClient> {
|
||||||
const queryClient = await QueryClient.connectWithNym(nymdUrl, validatorApiUrl);
|
const queryClient = await QueryClient.connectWithNym(nymdUrl, validatorApiUrl);
|
||||||
return new ValidatorClient(queryClient, prefix, mixnetContract, vestingContract);
|
return new ValidatorClient(queryClient, prefix, mixnetContract, vestingContract, denom);
|
||||||
}
|
}
|
||||||
|
|
||||||
public get address(): string {
|
public get address(): string {
|
||||||
@@ -457,4 +456,4 @@ export default class ValidatorClient implements INymClient {
|
|||||||
this.assertSigning();
|
this.assertSigning();
|
||||||
return (this.client as ISigningClient).updateContractStateParams(this.mixnetContract, newParams, fee, memo);
|
return (this.client as ISigningClient).updateContractStateParams(this.mixnetContract, newParams, fee, memo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -221,10 +221,12 @@ export default class SigningClient extends SigningCosmWasmClient implements ISig
|
|||||||
nymdUrl: string,
|
nymdUrl: string,
|
||||||
validatorApiUrl: string,
|
validatorApiUrl: string,
|
||||||
prefix: string,
|
prefix: string,
|
||||||
|
denom: string,
|
||||||
): Promise<SigningClient> {
|
): Promise<SigningClient> {
|
||||||
const [{ address }] = await wallet.getAccounts();
|
const [{ address }] = await wallet.getAccounts();
|
||||||
const signerOptions: SigningCosmWasmClientOptions = {
|
const signerOptions: SigningCosmWasmClientOptions = {
|
||||||
gasPrice: nymGasPrice(prefix),
|
prefix,
|
||||||
|
gasPrice: nymGasPrice(denom),
|
||||||
};
|
};
|
||||||
const tmClient = await Tendermint34Client.connect(nymdUrl);
|
const tmClient = await Tendermint34Client.connect(nymdUrl);
|
||||||
return new SigningClient(address, validatorApiUrl, tmClient, wallet, signerOptions);
|
return new SigningClient(address, validatorApiUrl, tmClient, wallet, signerOptions);
|
||||||
|
|||||||
@@ -7,13 +7,12 @@ const mainnetDenom = 'nym';
|
|||||||
export function nymGasPrice(prefix: string): GasPrice {
|
export function nymGasPrice(prefix: string): GasPrice {
|
||||||
if (typeof prefix === 'string') {
|
if (typeof prefix === 'string') {
|
||||||
if (prefix === mainnetPrefix) {
|
if (prefix === mainnetPrefix) {
|
||||||
prefix = mainnetDenom;
|
return GasPrice.fromString(`0.025u${mainnetDenom}`);
|
||||||
}
|
}
|
||||||
return GasPrice.fromString(`0.025u${prefix}`); // TODO: ideally this ugly conversion shouldn't be hardcoded here.
|
return GasPrice.fromString(`0.025u${prefix}`); // TODO: ideally this ugly conversion shouldn't be hardcoded here.
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
throw new Error(`${prefix} is not of type string`);
|
throw new Error(`${prefix} is not of type string`);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export const downloadWasm = async (url: string): Promise<Uint8Array> => {
|
export const downloadWasm = async (url: string): Promise<Uint8Array> => {
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import ValidatorClient from '../../dist';
|
||||||
|
import expect from 'expect';
|
||||||
|
|
||||||
|
describe('Query: balances', () => {
|
||||||
|
it('can query for an account balance', async () => {
|
||||||
|
const client = await ValidatorClient.connectForQuery(
|
||||||
|
'https://rpc.nyx.nodes.guru/', 'https://validator.nymtech.net/api/', 'n', 'n14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sjyvg3g', 'n1nc5tatafv6eyq7llkr2gv50ff9e22mnf70qgjlv737ktmt4eswrq73f2nw', 'nym');
|
||||||
|
const balance = await client.getBalance('n10yyd98e2tuwu0f7ypz9dy3hhjw7v772q6287gy');
|
||||||
|
expect(Number.parseFloat(balance.amount)).toBeGreaterThan(0);
|
||||||
|
}).timeout(5000);
|
||||||
|
})
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
import ValidatorClient from '../../dist';
|
||||||
|
import expect from 'expect';
|
||||||
|
|
||||||
|
// TODO: implement for QA with .env for mnemonics
|
||||||
|
// describe('Sign: send', () => {
|
||||||
|
// it('can send tokens', async () => {
|
||||||
|
// const client = await ValidatorClient.connect(
|
||||||
|
// '<ADD MNEMONIC HERE>',
|
||||||
|
// 'https://rpc.nyx.nodes.guru/', 'https://validator.nymtech.net/api/', 'n', 'n14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sjyvg3g', 'n1nc5tatafv6eyq7llkr2gv50ff9e22mnf70qgjlv737ktmt4eswrq73f2nw', 'nym');
|
||||||
|
// await client.send('<ADD ADDRESS HERE>')
|
||||||
|
// const balance = await client.getBalance('n10yyd98e2tuwu0f7ypz9dy3hhjw7v772q6287gy');
|
||||||
|
// expect(Number.parseFloat(balance.amount)).toBeGreaterThan(0);
|
||||||
|
// }).timeout(5000);
|
||||||
|
// })
|
||||||
@@ -5,7 +5,8 @@
|
|||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"strict": true,
|
"strict": true,
|
||||||
"declaration": true,
|
"declaration": true,
|
||||||
"outDir": "./dist"
|
"outDir": "./dist",
|
||||||
|
"skipLibCheck": true
|
||||||
},
|
},
|
||||||
"typedocOptions": {
|
"typedocOptions": {
|
||||||
"entryPoints": [
|
"entryPoints": [
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -32,7 +32,7 @@ credentials = { path = "../../common/credentials", optional = true }
|
|||||||
crypto = { path = "../../common/crypto" }
|
crypto = { path = "../../common/crypto" }
|
||||||
nymsphinx = { path = "../../common/nymsphinx" }
|
nymsphinx = { path = "../../common/nymsphinx" }
|
||||||
topology = { path = "../../common/topology" }
|
topology = { path = "../../common/topology" }
|
||||||
gateway-client = { path = "../../common/client-libs/gateway-client", default-features = false, features = ["wasm"] }
|
gateway-client = { path = "../../common/client-libs/gateway-client", default-features = false, features = ["wasm", "coconut"] }
|
||||||
validator-client = { path = "../../common/client-libs/validator-client", default-features = false }
|
validator-client = { path = "../../common/client-libs/validator-client", default-features = false }
|
||||||
wasm-utils = { path = "../../common/wasm-utils" }
|
wasm-utils = { path = "../../common/wasm-utils" }
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ async function main() {
|
|||||||
set_panic_hook();
|
set_panic_hook();
|
||||||
|
|
||||||
// validator server we will use to get topology from
|
// validator server we will use to get topology from
|
||||||
const validator = "https://sandbox-validator.nymtech.net/api"; //"http://localhost:8081";
|
const validator = "https://validator.nymtech.net/api"; //"http://localhost:8081";
|
||||||
|
|
||||||
client = new NymClient(validator);
|
client = new NymClient(validator);
|
||||||
|
|
||||||
|
|||||||
@@ -132,9 +132,7 @@ impl NymClient {
|
|||||||
bandwidth_controller,
|
bandwidth_controller,
|
||||||
);
|
);
|
||||||
|
|
||||||
if disabled_credentials_mode {
|
gateway_client.set_disabled_credentials_mode(disabled_credentials_mode);
|
||||||
gateway_client.set_disabled_credentials_mode(true)
|
|
||||||
}
|
|
||||||
|
|
||||||
gateway_client
|
gateway_client
|
||||||
.authenticate_and_start()
|
.authenticate_and_start()
|
||||||
@@ -199,7 +197,6 @@ impl NymClient {
|
|||||||
// don't bother with acks etc. for time being
|
// don't bother with acks etc. for time being
|
||||||
let prepared_fragment = message_preparer
|
let prepared_fragment = message_preparer
|
||||||
.prepare_chunk_for_sending(message_chunk, topology, &self.ack_key, &recipient)
|
.prepare_chunk_for_sending(message_chunk, topology, &self.ack_key, &recipient)
|
||||||
.await
|
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
console_warn!("packet is going to have round trip time of {:?}, but we're not going to do anything for acks anyway ", prepared_fragment.total_delay);
|
console_warn!("packet is going to have round trip time of {:?}, but we're not going to do anything for acks anyway ", prepared_fragment.total_delay);
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ use schemars::JsonSchema;
|
|||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
// Serializable structures for what we find in common/crypto
|
// Serializable structures for what we find in common/crypto
|
||||||
#[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
pub struct PublicKey([u8; 32]);
|
pub struct PublicKey([u8; 32]);
|
||||||
|
|
||||||
impl PublicKey {
|
impl PublicKey {
|
||||||
@@ -24,7 +24,7 @@ impl AsRef<[u8]> for PublicKey {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
pub struct Signature([u8; 32], [u8; 32]);
|
pub struct Signature([u8; 32], [u8; 32]);
|
||||||
|
|
||||||
impl Signature {
|
impl Signature {
|
||||||
|
|||||||
@@ -7,16 +7,16 @@ use serde::{Deserialize, Serialize};
|
|||||||
use crate::keys::PublicKey;
|
use crate::keys::PublicKey;
|
||||||
use crate::payment::LinkPaymentData;
|
use crate::payment::LinkPaymentData;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
pub struct InstantiateMsg {}
|
pub struct InstantiateMsg {}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum ExecuteMsg {
|
pub enum ExecuteMsg {
|
||||||
LinkPayment { data: LinkPaymentData },
|
LinkPayment { data: LinkPaymentData },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum QueryMsg {
|
pub enum QueryMsg {
|
||||||
GetPayments {
|
GetPayments {
|
||||||
@@ -25,6 +25,6 @@ pub enum QueryMsg {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub struct MigrateMsg {}
|
pub struct MigrateMsg {}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
|
|
||||||
use crate::keys::{PublicKey, Signature};
|
use crate::keys::{PublicKey, Signature};
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||||
pub struct Payment {
|
pub struct Payment {
|
||||||
verification_key: PublicKey,
|
verification_key: PublicKey,
|
||||||
gateway_identity: PublicKey,
|
gateway_identity: PublicKey,
|
||||||
@@ -27,7 +27,7 @@ impl Payment {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
pub struct LinkPaymentData {
|
pub struct LinkPaymentData {
|
||||||
pub verification_key: PublicKey,
|
pub verification_key: PublicKey,
|
||||||
pub gateway_identity: PublicKey,
|
pub gateway_identity: PublicKey,
|
||||||
@@ -51,7 +51,7 @@ impl LinkPaymentData {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||||
pub struct PagedPaymentResponse {
|
pub struct PagedPaymentResponse {
|
||||||
pub payments: Vec<Payment>,
|
pub payments: Vec<Payment>,
|
||||||
pub per_page: usize,
|
pub per_page: usize,
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ log = "0.4"
|
|||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
url = "2.2"
|
url = "2.2"
|
||||||
rand = { version = "0.7.3", features = ["wasm-bindgen"] }
|
rand = { version = "0.7.3", features = ["wasm-bindgen"] }
|
||||||
secp256k1 = "0.20.3"
|
secp256k1 = { version = "0.20.3", optional = true }
|
||||||
web3 = { version = "0.17.0", default-features = false }
|
web3 = { version = "0.17.0", default-features = false, optional = true }
|
||||||
async-trait = { version = "0.1.51" }
|
async-trait = { version = "0.1.51" }
|
||||||
|
|
||||||
# internal
|
# internal
|
||||||
@@ -73,5 +73,5 @@ features = ["js"]
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
coconut = ["gateway-requests/coconut", "coconut-interface", "validator-client", "credentials/coconut"]
|
coconut = ["gateway-requests/coconut", "coconut-interface", "validator-client", "credentials/coconut"]
|
||||||
wasm = ["web3/wasm", "web3/http", "web3/signing"]
|
wasm = []
|
||||||
default = ["web3/default"]
|
default = ["web3/default", "secp256k1"]
|
||||||
|
|||||||
@@ -23,7 +23,7 @@ use {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
#[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))]
|
||||||
use {
|
use {
|
||||||
credentials::token::bandwidth::TokenCredential,
|
credentials::token::bandwidth::TokenCredential,
|
||||||
crypto::asymmetric::identity,
|
crypto::asymmetric::identity,
|
||||||
@@ -45,7 +45,7 @@ use {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
#[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))]
|
||||||
pub fn eth_contract(web3: Web3<Http>) -> Contract<Http> {
|
pub fn eth_contract(web3: Web3<Http>) -> Contract<Http> {
|
||||||
Contract::from_json(
|
Contract::from_json(
|
||||||
web3.eth(),
|
web3.eth(),
|
||||||
@@ -58,7 +58,7 @@ pub fn eth_contract(web3: Web3<Http>) -> Contract<Http> {
|
|||||||
.expect("Invalid json abi")
|
.expect("Invalid json abi")
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
#[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))]
|
||||||
pub fn eth_erc20_contract(web3: Web3<Http>) -> Contract<Http> {
|
pub fn eth_erc20_contract(web3: Web3<Http>) -> Contract<Http> {
|
||||||
Contract::from_json(
|
Contract::from_json(
|
||||||
web3.eth(),
|
web3.eth(),
|
||||||
@@ -76,11 +76,11 @@ pub struct BandwidthController<St: Storage> {
|
|||||||
storage: St,
|
storage: St,
|
||||||
#[cfg(feature = "coconut")]
|
#[cfg(feature = "coconut")]
|
||||||
validator_endpoints: Vec<url::Url>,
|
validator_endpoints: Vec<url::Url>,
|
||||||
#[cfg(not(feature = "coconut"))]
|
#[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))]
|
||||||
contract: Contract<Http>,
|
contract: Contract<Http>,
|
||||||
#[cfg(not(feature = "coconut"))]
|
#[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))]
|
||||||
erc20_contract: Contract<Http>,
|
erc20_contract: Contract<Http>,
|
||||||
#[cfg(not(feature = "coconut"))]
|
#[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))]
|
||||||
eth_private_key: SecretKey,
|
eth_private_key: SecretKey,
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,7 +96,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
#[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))]
|
||||||
pub fn new(
|
pub fn new(
|
||||||
storage: St,
|
storage: St,
|
||||||
eth_endpoint: String,
|
eth_endpoint: String,
|
||||||
@@ -120,7 +120,7 @@ where
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
#[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))]
|
||||||
async fn backup_keypair(&self, keypair: &identity::KeyPair) -> Result<(), GatewayClientError> {
|
async fn backup_keypair(&self, keypair: &identity::KeyPair) -> Result<(), GatewayClientError> {
|
||||||
self.storage
|
self.storage
|
||||||
.insert_erc20_credential(
|
.insert_erc20_credential(
|
||||||
@@ -132,7 +132,7 @@ where
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
#[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))]
|
||||||
async fn restore_keypair(&self) -> Result<identity::KeyPair, GatewayClientError> {
|
async fn restore_keypair(&self) -> Result<identity::KeyPair, GatewayClientError> {
|
||||||
let data = self.storage.get_next_erc20_credential().await?;
|
let data = self.storage.get_next_erc20_credential().await?;
|
||||||
let public_key = identity::PublicKey::from_base58_string(data.public_key).unwrap();
|
let public_key = identity::PublicKey::from_base58_string(data.public_key).unwrap();
|
||||||
@@ -141,7 +141,7 @@ where
|
|||||||
Ok(identity::KeyPair::from_keys(private_key, public_key))
|
Ok(identity::KeyPair::from_keys(private_key, public_key))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
#[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))]
|
||||||
async fn mark_keypair_as_spent(
|
async fn mark_keypair_as_spent(
|
||||||
&self,
|
&self,
|
||||||
keypair: &identity::KeyPair,
|
keypair: &identity::KeyPair,
|
||||||
@@ -180,7 +180,7 @@ where
|
|||||||
)?)
|
)?)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
#[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))]
|
||||||
pub async fn prepare_token_credential(
|
pub async fn prepare_token_credential(
|
||||||
&self,
|
&self,
|
||||||
gateway_identity: identity::PublicKey,
|
gateway_identity: identity::PublicKey,
|
||||||
@@ -219,7 +219,7 @@ where
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
#[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))]
|
||||||
pub async fn buy_token_credential(
|
pub async fn buy_token_credential(
|
||||||
&self,
|
&self,
|
||||||
verification_key: identity::PublicKey,
|
verification_key: identity::PublicKey,
|
||||||
@@ -348,7 +348,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(feature = "coconut"))]
|
#[cfg(all(not(target_arch = "wasm32"), not(feature = "coconut")))]
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use network_defaults::ETH_EVENT_NAME;
|
use network_defaults::ETH_EVENT_NAME;
|
||||||
|
|||||||
@@ -162,12 +162,10 @@ impl PartiallyDelegated {
|
|||||||
.expect("stream sender was somehow dropped without sending anything!");
|
.expect("stream sender was somehow dropped without sending anything!");
|
||||||
|
|
||||||
if let Some(res) = receive_res {
|
if let Some(res) = receive_res {
|
||||||
if let Err(err) = res {
|
let _res = res?;
|
||||||
// the receiver got an error. most likely a network one.
|
panic!(
|
||||||
return Err(err);
|
"This should have NEVER happened - returned a stream before receiving notification"
|
||||||
} else {
|
)
|
||||||
panic!("This should have NEVER happened - returned a stream before receiving notification")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// this call failing is incredibly unlikely, but not impossible.
|
// this call failing is incredibly unlikely, but not impossible.
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ validator-api-requests = { path = "../../../validator-api/validator-api-requests
|
|||||||
async-trait = { version = "0.1.51", optional = true }
|
async-trait = { version = "0.1.51", optional = true }
|
||||||
bip39 = { version = "1", features = ["rand"], optional = true }
|
bip39 = { version = "1", features = ["rand"], optional = true }
|
||||||
config = { path = "../../config", optional = true }
|
config = { path = "../../config", optional = true }
|
||||||
cosmrs = { version = "0.7.0", features = ["rpc", "bip32", "cosmwasm"], optional = true}
|
cosmrs = { git = "https://github.com/neacsu/cosmos-rust", branch = "neacsu/feegrant_support", features = ["rpc", "bip32", "cosmwasm"], optional = true}
|
||||||
prost = { version = "0.10", default-features = false, optional = true }
|
prost = { version = "0.10", default-features = false, optional = true }
|
||||||
flate2 = { version = "1.0.20", optional = true }
|
flate2 = { version = "1.0.20", optional = true }
|
||||||
sha2 = { version = "0.9.5", optional = true }
|
sha2 = { version = "0.9.5", optional = true }
|
||||||
|
|||||||
@@ -5,8 +5,7 @@ use crate::{validator_api, ValidatorClientError};
|
|||||||
use mixnet_contract_common::{GatewayBond, IdentityKeyRef, MixNodeBond};
|
use mixnet_contract_common::{GatewayBond, IdentityKeyRef, MixNodeBond};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use validator_api_requests::coconut::{
|
use validator_api_requests::coconut::{
|
||||||
BlindSignRequestBody, BlindedSignatureResponse, ExecuteReleaseFundsRequestBody,
|
BlindSignRequestBody, BlindedSignatureResponse, CosmosAddressResponse, VerificationKeyResponse,
|
||||||
ProposeReleaseFundsRequestBody, ProposeReleaseFundsResponse, VerificationKeyResponse,
|
|
||||||
VerifyCredentialBody, VerifyCredentialResponse,
|
VerifyCredentialBody, VerifyCredentialResponse,
|
||||||
};
|
};
|
||||||
use validator_api_requests::models::{
|
use validator_api_requests::models::{
|
||||||
@@ -29,7 +28,7 @@ use mixnet_contract_common::{
|
|||||||
RewardedSetUpdateDetails,
|
RewardedSetUpdateDetails,
|
||||||
};
|
};
|
||||||
#[cfg(feature = "nymd-client")]
|
#[cfg(feature = "nymd-client")]
|
||||||
use network_defaults::{all::Network, NymNetworkDetails};
|
use network_defaults::NymNetworkDetails;
|
||||||
#[cfg(feature = "nymd-client")]
|
#[cfg(feature = "nymd-client")]
|
||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
@@ -114,9 +113,6 @@ impl Config {
|
|||||||
|
|
||||||
#[cfg(feature = "nymd-client")]
|
#[cfg(feature = "nymd-client")]
|
||||||
pub struct Client<C> {
|
pub struct Client<C> {
|
||||||
// compatibility : (
|
|
||||||
pub network: Network,
|
|
||||||
|
|
||||||
// TODO: we really shouldn't be storing a mnemonic here, but removing it would be
|
// TODO: we really shouldn't be storing a mnemonic here, but removing it would be
|
||||||
// non-trivial amount of work and it's out of scope of the current branch
|
// non-trivial amount of work and it's out of scope of the current branch
|
||||||
mnemonic: Option<bip39::Mnemonic>,
|
mnemonic: Option<bip39::Mnemonic>,
|
||||||
@@ -135,9 +131,6 @@ pub struct Client<C> {
|
|||||||
impl Client<SigningNymdClient> {
|
impl Client<SigningNymdClient> {
|
||||||
pub fn new_signing(
|
pub fn new_signing(
|
||||||
config: Config,
|
config: Config,
|
||||||
// we need to provide network argument due to compatibility with other components (wallet...)
|
|
||||||
// that rely on its existence...
|
|
||||||
network: Network,
|
|
||||||
mnemonic: bip39::Mnemonic,
|
mnemonic: bip39::Mnemonic,
|
||||||
) -> Result<Client<SigningNymdClient>, ValidatorClientError> {
|
) -> Result<Client<SigningNymdClient>, ValidatorClientError> {
|
||||||
let validator_api_client = validator_api::Client::new(config.api_url.clone());
|
let validator_api_client = validator_api::Client::new(config.api_url.clone());
|
||||||
@@ -149,7 +142,6 @@ impl Client<SigningNymdClient> {
|
|||||||
)?;
|
)?;
|
||||||
|
|
||||||
Ok(Client {
|
Ok(Client {
|
||||||
network,
|
|
||||||
mnemonic: Some(mnemonic),
|
mnemonic: Some(mnemonic),
|
||||||
mixnode_page_limit: config.mixnode_page_limit,
|
mixnode_page_limit: config.mixnode_page_limit,
|
||||||
gateway_page_limit: config.gateway_page_limit,
|
gateway_page_limit: config.gateway_page_limit,
|
||||||
@@ -177,18 +169,12 @@ impl Client<SigningNymdClient> {
|
|||||||
|
|
||||||
#[cfg(feature = "nymd-client")]
|
#[cfg(feature = "nymd-client")]
|
||||||
impl Client<QueryNymdClient> {
|
impl Client<QueryNymdClient> {
|
||||||
pub fn new_query(
|
pub fn new_query(config: Config) -> Result<Client<QueryNymdClient>, ValidatorClientError> {
|
||||||
config: Config,
|
|
||||||
// we need to provide network argument due to compatibility with other components (wallet...)
|
|
||||||
// that rely on its existence...
|
|
||||||
network: Network,
|
|
||||||
) -> Result<Client<QueryNymdClient>, ValidatorClientError> {
|
|
||||||
let validator_api_client = validator_api::Client::new(config.api_url.clone());
|
let validator_api_client = validator_api::Client::new(config.api_url.clone());
|
||||||
let nymd_client =
|
let nymd_client =
|
||||||
NymdClient::connect(config.nymd_config.clone(), config.nymd_url.as_str())?;
|
NymdClient::connect(config.nymd_config.clone(), config.nymd_url.as_str())?;
|
||||||
|
|
||||||
Ok(Client {
|
Ok(Client {
|
||||||
network,
|
|
||||||
mnemonic: None,
|
mnemonic: None,
|
||||||
mixnode_page_limit: config.mixnode_page_limit,
|
mixnode_page_limit: config.mixnode_page_limit,
|
||||||
gateway_page_limit: config.gateway_page_limit,
|
gateway_page_limit: config.gateway_page_limit,
|
||||||
@@ -734,6 +720,10 @@ impl ApiClient {
|
|||||||
Ok(self.validator_api.get_coconut_verification_key().await?)
|
Ok(self.validator_api.get_coconut_verification_key().await?)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn get_cosmos_address(&self) -> Result<CosmosAddressResponse, ValidatorClientError> {
|
||||||
|
Ok(self.validator_api.get_cosmos_address().await?)
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn verify_bandwidth_credential(
|
pub async fn verify_bandwidth_credential(
|
||||||
&self,
|
&self,
|
||||||
request_body: &VerifyCredentialBody,
|
request_body: &VerifyCredentialBody,
|
||||||
@@ -743,24 +733,4 @@ impl ApiClient {
|
|||||||
.verify_bandwidth_credential(request_body)
|
.verify_bandwidth_credential(request_body)
|
||||||
.await?)
|
.await?)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn propose_release_funds(
|
|
||||||
&self,
|
|
||||||
request_body: &ProposeReleaseFundsRequestBody,
|
|
||||||
) -> Result<ProposeReleaseFundsResponse, ValidatorClientError> {
|
|
||||||
Ok(self
|
|
||||||
.validator_api
|
|
||||||
.propose_release_funds(request_body)
|
|
||||||
.await?)
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn execute_release_funds(
|
|
||||||
&self,
|
|
||||||
request_body: &ExecuteReleaseFundsRequestBody,
|
|
||||||
) -> Result<(), ValidatorClientError> {
|
|
||||||
Ok(self
|
|
||||||
.validator_api
|
|
||||||
.execute_release_funds(request_body)
|
|
||||||
.await?)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,14 +6,14 @@ use std::fmt;
|
|||||||
pub use cosmrs::Coin as CosmosCoin;
|
pub use cosmrs::Coin as CosmosCoin;
|
||||||
pub use cosmwasm_std::Coin as CosmWasmCoin;
|
pub use cosmwasm_std::Coin as CosmWasmCoin;
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Copy, Default, Debug, PartialEq)]
|
#[derive(Serialize, Deserialize, Clone, Copy, Default, Debug, PartialEq, Eq)]
|
||||||
pub struct MismatchedDenoms;
|
pub struct MismatchedDenoms;
|
||||||
|
|
||||||
// the reason the coin is created here as opposed to different place in the codebase is that
|
// the reason the coin is created here as opposed to different place in the codebase is that
|
||||||
// eventually we want to either publish the cosmwasm client separately or commit it to
|
// eventually we want to either publish the cosmwasm client separately or commit it to
|
||||||
// some other project, like cosmrs. Either way, in that case we can't really have
|
// some other project, like cosmrs. Either way, in that case we can't really have
|
||||||
// a dependency on an internal type
|
// a dependency on an internal type
|
||||||
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq)]
|
#[derive(Serialize, Deserialize, Clone, Default, Debug, PartialEq, Eq)]
|
||||||
pub struct Coin {
|
pub struct Coin {
|
||||||
pub amount: u128,
|
pub amount: u128,
|
||||||
pub denom: String,
|
pub denom: String,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ use cosmrs::rpc::{self, HttpClient, Order};
|
|||||||
use cosmrs::tendermint::abci::Code as AbciCode;
|
use cosmrs::tendermint::abci::Code as AbciCode;
|
||||||
use cosmrs::tendermint::abci::Transaction;
|
use cosmrs::tendermint::abci::Transaction;
|
||||||
use cosmrs::tendermint::{abci, block, chain};
|
use cosmrs::tendermint::{abci, block, chain};
|
||||||
use cosmrs::{tx, AccountId, Coin as CosmosCoin, Denom, Tx};
|
use cosmrs::{tx, AccountId, Coin as CosmosCoin, Tx};
|
||||||
use prost::Message;
|
use prost::Message;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use std::convert::{TryFrom, TryInto};
|
use std::convert::{TryFrom, TryInto};
|
||||||
@@ -121,7 +121,7 @@ pub trait CosmWasmClient: rpc::Client {
|
|||||||
async fn get_balance(
|
async fn get_balance(
|
||||||
&self,
|
&self,
|
||||||
address: &AccountId,
|
address: &AccountId,
|
||||||
search_denom: Denom,
|
search_denom: String,
|
||||||
) -> Result<Option<Coin>, NymdError> {
|
) -> Result<Option<Coin>, NymdError> {
|
||||||
let path = Some("/cosmos.bank.v1beta1.Query/Balance".parse().unwrap());
|
let path = Some("/cosmos.bank.v1beta1.Query/Balance".parse().unwrap());
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,9 @@ use crate::nymd::{Coin, GasAdjustable, GasPrice, TxResponse};
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use cosmrs::bank::MsgSend;
|
use cosmrs::bank::MsgSend;
|
||||||
use cosmrs::distribution::MsgWithdrawDelegatorReward;
|
use cosmrs::distribution::MsgWithdrawDelegatorReward;
|
||||||
|
use cosmrs::feegrant::{
|
||||||
|
AllowedMsgAllowance, BasicAllowance, MsgGrantAllowance, MsgRevokeAllowance,
|
||||||
|
};
|
||||||
use cosmrs::proto::cosmos::tx::signing::v1beta1::SignMode;
|
use cosmrs::proto::cosmos::tx::signing::v1beta1::SignMode;
|
||||||
use cosmrs::rpc::endpoint::broadcast;
|
use cosmrs::rpc::endpoint::broadcast;
|
||||||
use cosmrs::rpc::{Error as TendermintRpcError, HttpClient, HttpClientUrl, SimpleRequest};
|
use cosmrs::rpc::{Error as TendermintRpcError, HttpClient, HttpClientUrl, SimpleRequest};
|
||||||
@@ -23,7 +26,7 @@ use serde::Serialize;
|
|||||||
use sha2::Digest;
|
use sha2::Digest;
|
||||||
use sha2::Sha256;
|
use sha2::Sha256;
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
use std::time::Duration;
|
use std::time::{Duration, SystemTime};
|
||||||
|
|
||||||
const DEFAULT_BROADCAST_POLLING_RATE: Duration = Duration::from_secs(4);
|
const DEFAULT_BROADCAST_POLLING_RATE: Duration = Duration::from_secs(4);
|
||||||
const DEFAULT_BROADCAST_TIMEOUT: Duration = Duration::from_secs(60);
|
const DEFAULT_BROADCAST_TIMEOUT: Duration = Duration::from_secs(60);
|
||||||
@@ -420,6 +423,63 @@ pub trait SigningCosmWasmClient: CosmWasmClient {
|
|||||||
.check_response()
|
.check_response()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[allow(clippy::too_many_arguments)]
|
||||||
|
async fn grant_allowance(
|
||||||
|
&self,
|
||||||
|
granter: &AccountId,
|
||||||
|
grantee: &AccountId,
|
||||||
|
spend_limit: Vec<Coin>,
|
||||||
|
expiration: Option<SystemTime>,
|
||||||
|
allowed_messages: Vec<String>,
|
||||||
|
fee: Fee,
|
||||||
|
memo: impl Into<String> + Send + 'static,
|
||||||
|
) -> Result<TxResponse, NymdError> {
|
||||||
|
let basic_allowance = BasicAllowance {
|
||||||
|
spend_limit: spend_limit.into_iter().map(Into::into).collect(),
|
||||||
|
expiration,
|
||||||
|
}
|
||||||
|
.to_any()
|
||||||
|
.map_err(|_| NymdError::SerializationError("BasicAllowance".to_owned()))?;
|
||||||
|
|
||||||
|
let allowed_msg_allowance = AllowedMsgAllowance {
|
||||||
|
allowance: Some(basic_allowance),
|
||||||
|
allowed_messages,
|
||||||
|
}
|
||||||
|
.to_any()
|
||||||
|
.map_err(|_| NymdError::SerializationError("AllowedMsgAllowance".to_owned()))?;
|
||||||
|
|
||||||
|
let grant_allowance_msg = MsgGrantAllowance {
|
||||||
|
granter: granter.to_owned(),
|
||||||
|
grantee: grantee.to_owned(),
|
||||||
|
allowance: Some(allowed_msg_allowance),
|
||||||
|
}
|
||||||
|
.to_any()
|
||||||
|
.map_err(|_| NymdError::SerializationError("MsgGrantAllowance".to_owned()))?;
|
||||||
|
|
||||||
|
self.sign_and_broadcast(granter, vec![grant_allowance_msg], fee, memo)
|
||||||
|
.await?
|
||||||
|
.check_response()
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn revoke_allowance(
|
||||||
|
&self,
|
||||||
|
granter: &AccountId,
|
||||||
|
grantee: &AccountId,
|
||||||
|
fee: Fee,
|
||||||
|
memo: impl Into<String> + Send + 'static,
|
||||||
|
) -> Result<TxResponse, NymdError> {
|
||||||
|
let revoke_allowance_msg = MsgRevokeAllowance {
|
||||||
|
granter: granter.to_owned(),
|
||||||
|
grantee: grantee.to_owned(),
|
||||||
|
}
|
||||||
|
.to_any()
|
||||||
|
.map_err(|_| NymdError::SerializationError("MsgRevokeAllowance".to_owned()))?;
|
||||||
|
|
||||||
|
self.sign_and_broadcast(granter, vec![revoke_allowance_msg], fee, memo)
|
||||||
|
.await?
|
||||||
|
.check_response()
|
||||||
|
}
|
||||||
|
|
||||||
async fn delegate_tokens(
|
async fn delegate_tokens(
|
||||||
&self,
|
&self,
|
||||||
delegator_address: &AccountId,
|
delegator_address: &AccountId,
|
||||||
@@ -514,10 +574,10 @@ pub trait SigningCosmWasmClient: CosmWasmClient {
|
|||||||
let fee = match fee {
|
let fee = match fee {
|
||||||
Fee::Manual(fee) => fee,
|
Fee::Manual(fee) => fee,
|
||||||
Fee::Auto(multiplier) => auto_fee(multiplier).await?,
|
Fee::Auto(multiplier) => auto_fee(multiplier).await?,
|
||||||
Fee::PayerGranterAuto(multiplier, payer, granter) => {
|
Fee::PayerGranterAuto(auto_feegrant) => {
|
||||||
let mut fee = auto_fee(multiplier).await?;
|
let mut fee = auto_fee(auto_feegrant.gas_adjustment).await?;
|
||||||
fee.payer = payer;
|
fee.payer = auto_feegrant.payer;
|
||||||
fee.granter = granter;
|
fee.granter = auto_feegrant.granter;
|
||||||
fee
|
fee
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
use crate::nymd::Coin;
|
||||||
use crate::nymd::Gas;
|
use crate::nymd::Gas;
|
||||||
use cosmrs::{tx, AccountId};
|
use cosmrs::{tx, AccountId};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use std::fmt::{Display, Formatter};
|
||||||
|
|
||||||
pub mod gas_price;
|
pub mod gas_price;
|
||||||
|
|
||||||
@@ -11,11 +13,74 @@ pub type GasAdjustment = f32;
|
|||||||
|
|
||||||
pub const DEFAULT_SIMULATED_GAS_MULTIPLIER: GasAdjustment = 1.3;
|
pub const DEFAULT_SIMULATED_GAS_MULTIPLIER: GasAdjustment = 1.3;
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
pub struct AutoFeeGrant {
|
||||||
|
pub gas_adjustment: Option<GasAdjustment>,
|
||||||
|
pub payer: Option<AccountId>,
|
||||||
|
pub granter: Option<AccountId>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for AutoFeeGrant {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
if let Some(gas_adjustment) = self.gas_adjustment {
|
||||||
|
write!(f, "Feegrant in auto mode with {gas_adjustment} simulated multiplier with {:?} payer and {:?} granter", self.payer, self.granter)
|
||||||
|
} else {
|
||||||
|
write!(f, "Feegrant in auto mode with no custom simulated multiplier with {:?} payer and {:?} granter", self.payer, self.granter)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
pub enum Fee {
|
pub enum Fee {
|
||||||
Manual(#[serde(with = "sealed::TxFee")] tx::Fee),
|
Manual(#[serde(with = "sealed::TxFee")] tx::Fee),
|
||||||
Auto(Option<GasAdjustment>),
|
Auto(Option<GasAdjustment>),
|
||||||
PayerGranterAuto(Option<GasAdjustment>, Option<AccountId>, Option<AccountId>),
|
PayerGranterAuto(AutoFeeGrant),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Display for Fee {
|
||||||
|
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||||
|
match self {
|
||||||
|
Fee::Manual(fee) => {
|
||||||
|
write!(f, "Fee in manual mode with ")?;
|
||||||
|
for fee in &fee.amount {
|
||||||
|
write!(f, "{}{} paid in fees, ", fee.amount, fee.denom)?;
|
||||||
|
}
|
||||||
|
write!(f, "{} set as gas limit, ", fee.gas_limit)?;
|
||||||
|
if let Some(payer) = &fee.payer {
|
||||||
|
write!(f, "{payer} set as payer, ")?;
|
||||||
|
}
|
||||||
|
if let Some(granter) = &fee.granter {
|
||||||
|
write!(f, "{granter} set as granter")?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Fee::Auto(Some(multiplier)) => {
|
||||||
|
write!(f, "Fee in auto mode with {multiplier} simulated multiplier")
|
||||||
|
}
|
||||||
|
Fee::Auto(None) => write!(f, "Fee in auto mode with no custom simulated multiplier"),
|
||||||
|
Fee::PayerGranterAuto(auto_feegrant) => write!(f, "{}", auto_feegrant),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Fee {
|
||||||
|
pub fn new_payer_granter_auto(
|
||||||
|
gas_adjustment: Option<GasAdjustment>,
|
||||||
|
payer: Option<AccountId>,
|
||||||
|
granter: Option<AccountId>,
|
||||||
|
) -> Self {
|
||||||
|
Fee::PayerGranterAuto(AutoFeeGrant {
|
||||||
|
gas_adjustment,
|
||||||
|
payer,
|
||||||
|
granter,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
pub fn try_get_manual_amount(&self) -> Option<Vec<Coin>> {
|
||||||
|
match self {
|
||||||
|
Fee::Manual(tx_fee) => Some(tx_fee.amount.iter().cloned().map(Into::into).collect()),
|
||||||
|
_ => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<tx::Fee> for Fee {
|
impl From<tx::Fee> for Fee {
|
||||||
|
|||||||
@@ -24,8 +24,9 @@ use mixnet_contract_common::{
|
|||||||
PagedMixDelegationsResponse, PagedMixnodeResponse, PagedRewardedSetResponse, QueryMsg,
|
PagedMixDelegationsResponse, PagedMixnodeResponse, PagedRewardedSetResponse, QueryMsg,
|
||||||
RewardedSetUpdateDetails,
|
RewardedSetUpdateDetails,
|
||||||
};
|
};
|
||||||
use serde::Serialize;
|
use serde::{Deserialize, Serialize};
|
||||||
use std::convert::TryInto;
|
use std::convert::TryInto;
|
||||||
|
use std::time::SystemTime;
|
||||||
use vesting_contract_common::ExecuteMsg as VestingExecuteMsg;
|
use vesting_contract_common::ExecuteMsg as VestingExecuteMsg;
|
||||||
use vesting_contract_common::QueryMsg as VestingQueryMsg;
|
use vesting_contract_common::QueryMsg as VestingQueryMsg;
|
||||||
|
|
||||||
@@ -281,6 +282,30 @@ impl<C> NymdClient<C> {
|
|||||||
self.simulated_gas_multiplier = multiplier;
|
self.simulated_gas_multiplier = multiplier;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub async fn query_contract_smart<M, T>(
|
||||||
|
&self,
|
||||||
|
contract: &AccountId,
|
||||||
|
query_msg: &M,
|
||||||
|
) -> Result<T, NymdError>
|
||||||
|
where
|
||||||
|
C: CosmWasmClient + Sync,
|
||||||
|
M: ?Sized + Serialize + Sync,
|
||||||
|
for<'a> T: Deserialize<'a>,
|
||||||
|
{
|
||||||
|
self.client.query_contract_smart(contract, query_msg).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn query_contract_raw(
|
||||||
|
&self,
|
||||||
|
contract: &AccountId,
|
||||||
|
query_data: Vec<u8>,
|
||||||
|
) -> Result<Vec<u8>, NymdError>
|
||||||
|
where
|
||||||
|
C: CosmWasmClient + Sync,
|
||||||
|
{
|
||||||
|
self.client.query_contract_raw(contract, query_data).await
|
||||||
|
}
|
||||||
|
|
||||||
pub fn wrap_contract_execute_message<M>(
|
pub fn wrap_contract_execute_message<M>(
|
||||||
&self,
|
&self,
|
||||||
contract_address: &AccountId,
|
contract_address: &AccountId,
|
||||||
@@ -388,7 +413,7 @@ impl<C> NymdClient<C> {
|
|||||||
pub async fn get_balance(
|
pub async fn get_balance(
|
||||||
&self,
|
&self,
|
||||||
address: &AccountId,
|
address: &AccountId,
|
||||||
denom: Denom,
|
denom: String,
|
||||||
) -> Result<Option<Coin>, NymdError>
|
) -> Result<Option<Coin>, NymdError>
|
||||||
where
|
where
|
||||||
C: CosmWasmClient + Sync,
|
C: CosmWasmClient + Sync,
|
||||||
@@ -845,11 +870,54 @@ impl<C> NymdClient<C> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Grant a fee allowance from one address to another
|
||||||
|
pub async fn grant_allowance(
|
||||||
|
&self,
|
||||||
|
grantee: &AccountId,
|
||||||
|
spend_limit: Vec<Coin>,
|
||||||
|
expiration: Option<SystemTime>,
|
||||||
|
allowed_messages: Vec<String>,
|
||||||
|
memo: impl Into<String> + Send + 'static,
|
||||||
|
fee: Option<Fee>,
|
||||||
|
) -> Result<TxResponse, NymdError>
|
||||||
|
where
|
||||||
|
C: SigningCosmWasmClient + Sync,
|
||||||
|
{
|
||||||
|
let fee = fee.unwrap_or(Fee::Auto(Some(self.simulated_gas_multiplier)));
|
||||||
|
self.client
|
||||||
|
.grant_allowance(
|
||||||
|
self.address(),
|
||||||
|
grantee,
|
||||||
|
spend_limit,
|
||||||
|
expiration,
|
||||||
|
allowed_messages,
|
||||||
|
fee,
|
||||||
|
memo,
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Revoke a fee allowance from one address to another
|
||||||
|
pub async fn revoke_allowance(
|
||||||
|
&self,
|
||||||
|
grantee: &AccountId,
|
||||||
|
memo: impl Into<String> + Send + 'static,
|
||||||
|
fee: Option<Fee>,
|
||||||
|
) -> Result<TxResponse, NymdError>
|
||||||
|
where
|
||||||
|
C: SigningCosmWasmClient + Sync,
|
||||||
|
{
|
||||||
|
let fee = fee.unwrap_or(Fee::Auto(Some(self.simulated_gas_multiplier)));
|
||||||
|
self.client
|
||||||
|
.revoke_allowance(self.address(), grantee, fee, memo)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
pub async fn execute<M>(
|
pub async fn execute<M>(
|
||||||
&self,
|
&self,
|
||||||
contract_address: &AccountId,
|
contract_address: &AccountId,
|
||||||
msg: &M,
|
msg: &M,
|
||||||
fee: Fee,
|
fee: Option<Fee>,
|
||||||
memo: impl Into<String> + Send + 'static,
|
memo: impl Into<String> + Send + 'static,
|
||||||
funds: Vec<Coin>,
|
funds: Vec<Coin>,
|
||||||
) -> Result<ExecuteResult, NymdError>
|
) -> Result<ExecuteResult, NymdError>
|
||||||
@@ -857,6 +925,7 @@ impl<C> NymdClient<C> {
|
|||||||
C: SigningCosmWasmClient + Sync,
|
C: SigningCosmWasmClient + Sync,
|
||||||
M: ?Sized + Serialize + Sync,
|
M: ?Sized + Serialize + Sync,
|
||||||
{
|
{
|
||||||
|
let fee = fee.unwrap_or(Fee::Auto(Some(self.simulated_gas_multiplier)));
|
||||||
self.client
|
self.client
|
||||||
.execute(self.address(), contract_address, msg, fee, memo, funds)
|
.execute(self.address(), contract_address, msg, fee, memo, funds)
|
||||||
.await
|
.await
|
||||||
@@ -866,7 +935,7 @@ impl<C> NymdClient<C> {
|
|||||||
&self,
|
&self,
|
||||||
contract_address: &AccountId,
|
contract_address: &AccountId,
|
||||||
msgs: I,
|
msgs: I,
|
||||||
fee: Fee,
|
fee: Option<Fee>,
|
||||||
memo: impl Into<String> + Send + 'static,
|
memo: impl Into<String> + Send + 'static,
|
||||||
) -> Result<ExecuteResult, NymdError>
|
) -> Result<ExecuteResult, NymdError>
|
||||||
where
|
where
|
||||||
@@ -874,6 +943,7 @@ impl<C> NymdClient<C> {
|
|||||||
I: IntoIterator<Item = (M, Vec<Coin>)> + Send,
|
I: IntoIterator<Item = (M, Vec<Coin>)> + Send,
|
||||||
M: Serialize,
|
M: Serialize,
|
||||||
{
|
{
|
||||||
|
let fee = fee.unwrap_or(Fee::Auto(Some(self.simulated_gas_multiplier)));
|
||||||
self.client
|
self.client
|
||||||
.execute_multiple(self.address(), contract_address, msgs, fee, memo)
|
.execute_multiple(self.address(), contract_address, msgs, fee, memo)
|
||||||
.await
|
.await
|
||||||
@@ -962,6 +1032,29 @@ impl<C> NymdClient<C> {
|
|||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[execute("mixnet")]
|
||||||
|
fn _compound_reward(
|
||||||
|
&self,
|
||||||
|
operator: Option<String>,
|
||||||
|
delegator: Option<String>,
|
||||||
|
mix_identity: Option<IdentityKey>,
|
||||||
|
proxy: Option<String>,
|
||||||
|
fee: Option<Fee>,
|
||||||
|
) -> (ExecuteMsg, Option<Fee>)
|
||||||
|
where
|
||||||
|
C: SigningCosmWasmClient + Sync,
|
||||||
|
{
|
||||||
|
(
|
||||||
|
ExecuteMsg::CompoundReward {
|
||||||
|
operator,
|
||||||
|
delegator,
|
||||||
|
mix_identity,
|
||||||
|
proxy,
|
||||||
|
},
|
||||||
|
fee,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
#[execute("mixnet")]
|
#[execute("mixnet")]
|
||||||
fn _compound_operator_reward(&self, fee: Option<Fee>) -> (ExecuteMsg, Option<Fee>)
|
fn _compound_operator_reward(&self, fee: Option<Fee>) -> (ExecuteMsg, Option<Fee>)
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -0,0 +1,33 @@
|
|||||||
|
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
use crate::nymd::error::NymdError;
|
||||||
|
use crate::nymd::{CosmWasmClient, NymdClient};
|
||||||
|
|
||||||
|
use coconut_bandwidth_contract_common::msg::QueryMsg;
|
||||||
|
use coconut_bandwidth_contract_common::spend_credential::SpendCredentialResponse;
|
||||||
|
|
||||||
|
use async_trait::async_trait;
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
pub trait CoconutBandwidthQueryClient {
|
||||||
|
async fn get_spent_credential(
|
||||||
|
&self,
|
||||||
|
blinded_serial_number: String,
|
||||||
|
) -> Result<SpendCredentialResponse, NymdError>;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl<C: CosmWasmClient + Sync + Send> CoconutBandwidthQueryClient for NymdClient<C> {
|
||||||
|
async fn get_spent_credential(
|
||||||
|
&self,
|
||||||
|
blinded_serial_number: String,
|
||||||
|
) -> Result<SpendCredentialResponse, NymdError> {
|
||||||
|
let request = QueryMsg::GetSpentCredential {
|
||||||
|
blinded_serial_number,
|
||||||
|
};
|
||||||
|
self.client
|
||||||
|
.query_contract_smart(self.coconut_bandwidth_contract_address(), &request)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
}
|
||||||
+34
@@ -5,6 +5,7 @@ pub use crate::nymd::cosmwasm_client::signing_client::SigningCosmWasmClient;
|
|||||||
use crate::nymd::cosmwasm_client::types::ExecuteResult;
|
use crate::nymd::cosmwasm_client::types::ExecuteResult;
|
||||||
use crate::nymd::error::NymdError;
|
use crate::nymd::error::NymdError;
|
||||||
use crate::nymd::{Coin, Fee, NymdClient};
|
use crate::nymd::{Coin, Fee, NymdClient};
|
||||||
|
use coconut_bandwidth_contract_common::spend_credential::SpendCredentialData;
|
||||||
use coconut_bandwidth_contract_common::{deposit::DepositData, msg::ExecuteMsg};
|
use coconut_bandwidth_contract_common::{deposit::DepositData, msg::ExecuteMsg};
|
||||||
|
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
@@ -19,6 +20,13 @@ pub trait CoconutBandwidthSigningClient {
|
|||||||
encryption_key: String,
|
encryption_key: String,
|
||||||
fee: Option<Fee>,
|
fee: Option<Fee>,
|
||||||
) -> Result<ExecuteResult, NymdError>;
|
) -> Result<ExecuteResult, NymdError>;
|
||||||
|
async fn spend_credential(
|
||||||
|
&self,
|
||||||
|
funds: Coin,
|
||||||
|
blinded_serial_number: String,
|
||||||
|
gateway_cosmos_address: String,
|
||||||
|
fee: Option<Fee>,
|
||||||
|
) -> Result<ExecuteResult, NymdError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
@@ -46,4 +54,30 @@ impl<C: SigningCosmWasmClient + Sync + Send> CoconutBandwidthSigningClient for N
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
async fn spend_credential(
|
||||||
|
&self,
|
||||||
|
funds: Coin,
|
||||||
|
blinded_serial_number: String,
|
||||||
|
gateway_cosmos_address: String,
|
||||||
|
fee: Option<Fee>,
|
||||||
|
) -> Result<ExecuteResult, NymdError> {
|
||||||
|
let fee = fee.unwrap_or(Fee::Auto(Some(self.simulated_gas_multiplier)));
|
||||||
|
let req = ExecuteMsg::SpendCredential {
|
||||||
|
data: SpendCredentialData::new(
|
||||||
|
funds.into(),
|
||||||
|
blinded_serial_number,
|
||||||
|
gateway_cosmos_address,
|
||||||
|
),
|
||||||
|
};
|
||||||
|
self.client
|
||||||
|
.execute(
|
||||||
|
self.address(),
|
||||||
|
self.coconut_bandwidth_contract_address(),
|
||||||
|
&req,
|
||||||
|
fee,
|
||||||
|
"CoconutBandwidth::SpendCredential",
|
||||||
|
vec![],
|
||||||
|
)
|
||||||
|
.await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2021 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
mod coconut_bandwidth_query_client;
|
||||||
mod coconut_bandwidth_signing_client;
|
mod coconut_bandwidth_signing_client;
|
||||||
mod multisig_query_client;
|
mod multisig_query_client;
|
||||||
mod multisig_signing_client;
|
mod multisig_signing_client;
|
||||||
mod vesting_query_client;
|
mod vesting_query_client;
|
||||||
mod vesting_signing_client;
|
mod vesting_signing_client;
|
||||||
|
|
||||||
|
pub use coconut_bandwidth_query_client::CoconutBandwidthQueryClient;
|
||||||
pub use coconut_bandwidth_signing_client::CoconutBandwidthSigningClient;
|
pub use coconut_bandwidth_signing_client::CoconutBandwidthSigningClient;
|
||||||
pub use multisig_query_client::QueryClient;
|
pub use multisig_query_client::MultisigQueryClient;
|
||||||
pub use multisig_signing_client::MultisigSigningClient;
|
pub use multisig_signing_client::MultisigSigningClient;
|
||||||
pub use vesting_query_client::VestingQueryClient;
|
pub use vesting_query_client::VestingQueryClient;
|
||||||
pub use vesting_signing_client::VestingSigningClient;
|
pub use vesting_signing_client::VestingSigningClient;
|
||||||
|
|||||||
@@ -9,12 +9,12 @@ use multisig_contract_common::msg::{ProposalResponse, QueryMsg};
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait QueryClient {
|
pub trait MultisigQueryClient {
|
||||||
async fn get_proposal(&self, proposal_id: u64) -> Result<ProposalResponse, NymdError>;
|
async fn get_proposal(&self, proposal_id: u64) -> Result<ProposalResponse, NymdError>;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
impl<C: CosmWasmClient + Sync + Send> QueryClient for NymdClient<C> {
|
impl<C: CosmWasmClient + Sync + Send> MultisigQueryClient for NymdClient<C> {
|
||||||
async fn get_proposal(&self, proposal_id: u64) -> Result<ProposalResponse, NymdError> {
|
async fn get_proposal(&self, proposal_id: u64) -> Result<ProposalResponse, NymdError> {
|
||||||
let request = QueryMsg::Proposal { proposal_id };
|
let request = QueryMsg::Proposal { proposal_id };
|
||||||
self.client
|
self.client
|
||||||
|
|||||||
@@ -12,7 +12,6 @@ use multisig_contract_common::msg::ExecuteMsg;
|
|||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use cosmwasm_std::{to_binary, Coin, CosmosMsg, WasmMsg};
|
use cosmwasm_std::{to_binary, Coin, CosmosMsg, WasmMsg};
|
||||||
use cw3::Vote;
|
use cw3::Vote;
|
||||||
use network_defaults::DEFAULT_NETWORK;
|
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
pub trait MultisigSigningClient {
|
pub trait MultisigSigningClient {
|
||||||
@@ -49,7 +48,10 @@ impl<C: SigningCosmWasmClient + Sync + Send> MultisigSigningClient for NymdClien
|
|||||||
) -> Result<ExecuteResult, NymdError> {
|
) -> Result<ExecuteResult, NymdError> {
|
||||||
let fee = fee.unwrap_or(Fee::Auto(Some(self.simulated_gas_multiplier)));
|
let fee = fee.unwrap_or(Fee::Auto(Some(self.simulated_gas_multiplier)));
|
||||||
let release_funds_req = CoconutBandwidthExecuteMsg::ReleaseFunds {
|
let release_funds_req = CoconutBandwidthExecuteMsg::ReleaseFunds {
|
||||||
funds: Coin::new(voucher_value, DEFAULT_NETWORK.mix_denom().base),
|
funds: Coin::new(
|
||||||
|
voucher_value,
|
||||||
|
self.config.chain_details.mix_denom.base.clone(),
|
||||||
|
),
|
||||||
};
|
};
|
||||||
let release_funds_msg = CosmosMsg::Wasm(WasmMsg::Execute {
|
let release_funds_msg = CosmosMsg::Wasm(WasmMsg::Execute {
|
||||||
contract_addr: self.coconut_bandwidth_contract_address().to_string(),
|
contract_addr: self.coconut_bandwidth_contract_address().to_string(),
|
||||||
|
|||||||
@@ -7,9 +7,11 @@ use crate::nymd::error::NymdError;
|
|||||||
use crate::nymd::NymdClient;
|
use crate::nymd::NymdClient;
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use cosmwasm_std::{Coin as CosmWasmCoin, Timestamp};
|
use cosmwasm_std::{Coin as CosmWasmCoin, Timestamp};
|
||||||
|
use mixnet_contract_common::IdentityKey;
|
||||||
use vesting_contract::vesting::Account;
|
use vesting_contract::vesting::Account;
|
||||||
use vesting_contract_common::{
|
use vesting_contract_common::{
|
||||||
messages::QueryMsg as VestingQueryMsg, OriginalVestingResponse, Period, PledgeData,
|
messages::QueryMsg as VestingQueryMsg, AllDelegationsResponse, DelegationTimesResponse,
|
||||||
|
OriginalVestingResponse, Period, PledgeData, VestingDelegation,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
@@ -70,6 +72,37 @@ pub trait VestingQueryClient {
|
|||||||
&self,
|
&self,
|
||||||
vesting_account_address: &str,
|
vesting_account_address: &str,
|
||||||
) -> Result<Period, NymdError>;
|
) -> Result<Period, NymdError>;
|
||||||
|
|
||||||
|
async fn get_delegation_timestamps(
|
||||||
|
&self,
|
||||||
|
address: &str,
|
||||||
|
mix_identity: String,
|
||||||
|
) -> Result<DelegationTimesResponse, NymdError>;
|
||||||
|
|
||||||
|
async fn get_all_vesting_delegations_paged(
|
||||||
|
&self,
|
||||||
|
start_after: Option<(u32, IdentityKey, u64)>,
|
||||||
|
limit: Option<u32>,
|
||||||
|
) -> Result<AllDelegationsResponse, NymdError>;
|
||||||
|
|
||||||
|
async fn get_all_vesting_delegations(&self) -> Result<Vec<VestingDelegation>, NymdError> {
|
||||||
|
let mut delegations = Vec::new();
|
||||||
|
let mut start_after = None;
|
||||||
|
loop {
|
||||||
|
let mut paged_response = self
|
||||||
|
.get_all_vesting_delegations_paged(start_after.take(), None)
|
||||||
|
.await?;
|
||||||
|
delegations.append(&mut paged_response.delegations);
|
||||||
|
|
||||||
|
if let Some(start_after_res) = paged_response.start_next_after {
|
||||||
|
start_after = Some(start_after_res)
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(delegations)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[async_trait]
|
#[async_trait]
|
||||||
@@ -232,4 +265,29 @@ impl<C: CosmWasmClient + Sync + Send> VestingQueryClient for NymdClient<C> {
|
|||||||
.query_contract_smart(self.vesting_contract_address(), &request)
|
.query_contract_smart(self.vesting_contract_address(), &request)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn get_delegation_timestamps(
|
||||||
|
&self,
|
||||||
|
address: &str,
|
||||||
|
mix_identity: String,
|
||||||
|
) -> Result<DelegationTimesResponse, NymdError> {
|
||||||
|
let request = VestingQueryMsg::GetDelegationTimes {
|
||||||
|
address: address.to_string(),
|
||||||
|
mix_identity,
|
||||||
|
};
|
||||||
|
self.client
|
||||||
|
.query_contract_smart(self.vesting_contract_address(), &request)
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_all_vesting_delegations_paged(
|
||||||
|
&self,
|
||||||
|
start_after: Option<(u32, IdentityKey, u64)>,
|
||||||
|
limit: Option<u32>,
|
||||||
|
) -> Result<AllDelegationsResponse, NymdError> {
|
||||||
|
let request = VestingQueryMsg::GetAllDelegations { start_after, limit };
|
||||||
|
self.client
|
||||||
|
.query_contract_smart(self.vesting_contract_address(), &request)
|
||||||
|
.await
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -207,35 +207,20 @@ mod tests {
|
|||||||
"acquire rebel spot skin gun such erupt pull swear must define ill chief turtle today flower chunk truth battle claw rigid detail gym feel",
|
"acquire rebel spot skin gun such erupt pull swear must define ill chief turtle today flower chunk truth battle claw rigid detail gym feel",
|
||||||
"step income throw wheat mobile ship wave drink pool sudden upset jaguar bar globe rifle spice frost bless glimpse size regular carry aspect ball"
|
"step income throw wheat mobile ship wave drink pool sudden upset jaguar bar globe rifle spice frost bless glimpse size regular carry aspect ball"
|
||||||
];
|
];
|
||||||
let prefixes = vec![
|
let prefix = MAINNET.bech32_prefix();
|
||||||
MAINNET.bech32_prefix(),
|
|
||||||
SANDBOX.bech32_prefix(),
|
|
||||||
QA.bech32_prefix(),
|
|
||||||
];
|
|
||||||
|
|
||||||
for prefix in prefixes {
|
let addrs = vec![
|
||||||
let addrs = match prefix.as_ref() {
|
"n1jw6mp7d5xqc7w6xm79lha27glmd0vdt3l9artf",
|
||||||
"nymt" => vec![
|
"n1h5hgn94nsq4kh99rjj794hr5h5q6yfm2lr52es",
|
||||||
"nymt1jw6mp7d5xqc7w6xm79lha27glmd0vdt339me94",
|
"n17n9flp6jflljg6fp05dsy07wcprf2uuu8g40rf",
|
||||||
"nymt1h5hgn94nsq4kh99rjj794hr5h5q6yfm23rjshv",
|
];
|
||||||
"nymt17n9flp6jflljg6fp05dsy07wcprf2uuufgn4d4",
|
for (idx, mnemonic) in mnemonics.iter().enumerate() {
|
||||||
],
|
let wallet =
|
||||||
"n" => vec![
|
DirectSecp256k1HdWallet::from_mnemonic(&prefix, mnemonic.parse().unwrap()).unwrap();
|
||||||
"n1jw6mp7d5xqc7w6xm79lha27glmd0vdt3l9artf",
|
assert_eq!(
|
||||||
"n1h5hgn94nsq4kh99rjj794hr5h5q6yfm2lr52es",
|
wallet.try_derive_accounts().unwrap()[0].address,
|
||||||
"n17n9flp6jflljg6fp05dsy07wcprf2uuu8g40rf",
|
addrs[idx].parse().unwrap()
|
||||||
],
|
)
|
||||||
_ => panic!("Test needs to be updated with new bech32 prefix"),
|
|
||||||
};
|
|
||||||
for (idx, mnemonic) in mnemonics.iter().enumerate() {
|
|
||||||
let wallet =
|
|
||||||
DirectSecp256k1HdWallet::from_mnemonic(&prefix, mnemonic.parse().unwrap())
|
|
||||||
.unwrap();
|
|
||||||
assert_eq!(
|
|
||||||
wallet.try_derive_accounts().unwrap()[0].address,
|
|
||||||
addrs[idx].parse().unwrap()
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,9 +8,8 @@ use serde::{Deserialize, Serialize};
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use url::Url;
|
use url::Url;
|
||||||
use validator_api_requests::coconut::{
|
use validator_api_requests::coconut::{
|
||||||
BlindSignRequestBody, BlindedSignatureResponse, CosmosAddressResponse,
|
BlindSignRequestBody, BlindedSignatureResponse, CosmosAddressResponse, VerificationKeyResponse,
|
||||||
ExecuteReleaseFundsRequestBody, ProposeReleaseFundsRequestBody, ProposeReleaseFundsResponse,
|
VerifyCredentialBody, VerifyCredentialResponse,
|
||||||
VerificationKeyResponse, VerifyCredentialBody, VerifyCredentialResponse,
|
|
||||||
};
|
};
|
||||||
use validator_api_requests::models::{
|
use validator_api_requests::models::{
|
||||||
CoreNodeStatusResponse, InclusionProbabilityResponse, MixNodeBondAnnotated,
|
CoreNodeStatusResponse, InclusionProbabilityResponse, MixNodeBondAnnotated,
|
||||||
@@ -405,40 +404,6 @@ impl Client {
|
|||||||
)
|
)
|
||||||
.await
|
.await
|
||||||
}
|
}
|
||||||
|
|
||||||
pub async fn propose_release_funds(
|
|
||||||
&self,
|
|
||||||
request_body: &ProposeReleaseFundsRequestBody,
|
|
||||||
) -> Result<ProposeReleaseFundsResponse, ValidatorAPIError> {
|
|
||||||
self.post_validator_api(
|
|
||||||
&[
|
|
||||||
routes::API_VERSION,
|
|
||||||
routes::COCONUT_ROUTES,
|
|
||||||
routes::BANDWIDTH,
|
|
||||||
routes::COCONUT_PROPOSE_RELEASE_FUNDS,
|
|
||||||
],
|
|
||||||
NO_PARAMS,
|
|
||||||
request_body,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn execute_release_funds(
|
|
||||||
&self,
|
|
||||||
request_body: &ExecuteReleaseFundsRequestBody,
|
|
||||||
) -> Result<(), ValidatorAPIError> {
|
|
||||||
self.post_validator_api(
|
|
||||||
&[
|
|
||||||
routes::API_VERSION,
|
|
||||||
routes::COCONUT_ROUTES,
|
|
||||||
routes::BANDWIDTH,
|
|
||||||
routes::COCONUT_EXECUTE_RELEASE_FUNDS,
|
|
||||||
],
|
|
||||||
NO_PARAMS,
|
|
||||||
request_body,
|
|
||||||
)
|
|
||||||
.await
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// utility function that should solve the double slash problem in validator API forever.
|
// utility function that should solve the double slash problem in validator API forever.
|
||||||
|
|||||||
@@ -19,8 +19,6 @@ pub const COCONUT_PARTIAL_BANDWIDTH_CREDENTIAL: &str = "partial-bandwidth-creden
|
|||||||
pub const COCONUT_VERIFICATION_KEY: &str = "verification-key";
|
pub const COCONUT_VERIFICATION_KEY: &str = "verification-key";
|
||||||
pub const COCONUT_COSMOS_ADDRESS: &str = "cosmos-address";
|
pub const COCONUT_COSMOS_ADDRESS: &str = "cosmos-address";
|
||||||
pub const COCONUT_VERIFY_BANDWIDTH_CREDENTIAL: &str = "verify-bandwidth-credential";
|
pub const COCONUT_VERIFY_BANDWIDTH_CREDENTIAL: &str = "verify-bandwidth-credential";
|
||||||
pub const COCONUT_PROPOSE_RELEASE_FUNDS: &str = "propose-release-funds";
|
|
||||||
pub const COCONUT_EXECUTE_RELEASE_FUNDS: &str = "execute-release-funds";
|
|
||||||
|
|
||||||
pub const STATUS_ROUTES: &str = "status";
|
pub const STATUS_ROUTES: &str = "status";
|
||||||
pub const MIXNODE: &str = "mixnode";
|
pub const MIXNODE: &str = "mixnode";
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ use error::CoconutInterfaceError;
|
|||||||
|
|
||||||
pub use nymcoconut::*;
|
pub use nymcoconut::*;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize, Getters, CopyGetters, Clone, PartialEq)]
|
#[derive(Debug, Serialize, Deserialize, Getters, CopyGetters, Clone, PartialEq, Eq)]
|
||||||
pub struct Credential {
|
pub struct Credential {
|
||||||
#[getset(get = "pub")]
|
#[getset(get = "pub")]
|
||||||
n_params: u32,
|
n_params: u32,
|
||||||
|
|||||||
@@ -41,6 +41,30 @@ pub trait NymConfig: Default + Serialize + DeserializeOwned {
|
|||||||
Self::default_config_directory(id).join(Self::config_file_name())
|
Self::default_config_directory(id).join(Self::config_file_name())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We provide a second set of functions that tries to not panic.
|
||||||
|
|
||||||
|
fn try_default_root_directory() -> Option<PathBuf>;
|
||||||
|
|
||||||
|
fn try_default_config_directory(id: Option<&str>) -> Option<PathBuf> {
|
||||||
|
if let Some(id) = id {
|
||||||
|
Self::try_default_root_directory().map(|d| d.join(id).join("config"))
|
||||||
|
} else {
|
||||||
|
Self::try_default_root_directory().map(|d| d.join("config"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn try_default_data_directory(id: Option<&str>) -> Option<PathBuf> {
|
||||||
|
if let Some(id) = id {
|
||||||
|
Self::try_default_root_directory().map(|d| d.join(id).join("data"))
|
||||||
|
} else {
|
||||||
|
Self::try_default_root_directory().map(|d| d.join("data"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn try_default_config_file_path(id: Option<&str>) -> Option<PathBuf> {
|
||||||
|
Self::try_default_config_directory(id).map(|d| d.join(Self::config_file_name()))
|
||||||
|
}
|
||||||
|
|
||||||
fn root_directory(&self) -> PathBuf;
|
fn root_directory(&self) -> PathBuf;
|
||||||
fn config_directory(&self) -> PathBuf;
|
fn config_directory(&self) -> PathBuf;
|
||||||
fn data_directory(&self) -> PathBuf;
|
fn data_directory(&self) -> PathBuf;
|
||||||
@@ -88,3 +112,14 @@ pub trait NymConfig: Default + Serialize + DeserializeOwned {
|
|||||||
.map_err(|toml_err| io::Error::new(io::ErrorKind::Other, toml_err))
|
.map_err(|toml_err| io::Error::new(io::ErrorKind::Other, toml_err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn parse_validators(raw: &str) -> Vec<url::Url> {
|
||||||
|
raw.split(',')
|
||||||
|
.map(|raw_validator| {
|
||||||
|
raw_validator
|
||||||
|
.trim()
|
||||||
|
.parse()
|
||||||
|
.expect("one of the provided validator api urls is invalid")
|
||||||
|
})
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
|||||||
@@ -9,3 +9,4 @@ edition = "2021"
|
|||||||
cosmwasm-std = "1.0.0"
|
cosmwasm-std = "1.0.0"
|
||||||
schemars = "0.8"
|
schemars = "0.8"
|
||||||
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
|
serde = { version = "1.0.103", default-features = false, features = ["derive"] }
|
||||||
|
multisig-contract-common = { path = "../multisig-contract" }
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
pub struct DepositData {
|
pub struct DepositData {
|
||||||
deposit_info: String,
|
deposit_info: String,
|
||||||
identity_key: String,
|
identity_key: String,
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
pub mod deposit;
|
pub mod deposit;
|
||||||
pub mod events;
|
pub mod events;
|
||||||
pub mod msg;
|
pub mod msg;
|
||||||
|
pub mod spend_credential;
|
||||||
|
|||||||
@@ -5,25 +5,35 @@ use cosmwasm_std::Coin;
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use crate::deposit::DepositData;
|
use crate::{deposit::DepositData, spend_credential::SpendCredentialData};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
pub struct InstantiateMsg {
|
pub struct InstantiateMsg {
|
||||||
pub multisig_addr: String,
|
pub multisig_addr: String,
|
||||||
pub pool_addr: String,
|
pub pool_addr: String,
|
||||||
|
pub mix_denom: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum ExecuteMsg {
|
pub enum ExecuteMsg {
|
||||||
DepositFunds { data: DepositData },
|
DepositFunds { data: DepositData },
|
||||||
|
SpendCredential { data: SpendCredentialData },
|
||||||
ReleaseFunds { funds: Coin },
|
ReleaseFunds { funds: Coin },
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum QueryMsg {}
|
pub enum QueryMsg {
|
||||||
|
GetSpentCredential {
|
||||||
|
blinded_serial_number: String,
|
||||||
|
},
|
||||||
|
GetAllSpentCredentials {
|
||||||
|
limit: Option<u32>,
|
||||||
|
start_after: Option<String>,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub struct MigrateMsg {}
|
pub struct MigrateMsg {}
|
||||||
|
|||||||
@@ -0,0 +1,148 @@
|
|||||||
|
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
use cosmwasm_std::{from_binary, to_binary, Addr, Coin, CosmosMsg, StdResult, WasmMsg};
|
||||||
|
use multisig_contract_common::msg::ExecuteMsg as MultisigExecuteMsg;
|
||||||
|
use schemars::JsonSchema;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
use crate::msg::ExecuteMsg;
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||||
|
pub struct SpendCredentialData {
|
||||||
|
funds: Coin,
|
||||||
|
blinded_serial_number: String,
|
||||||
|
gateway_cosmos_address: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SpendCredentialData {
|
||||||
|
pub fn new(funds: Coin, blinded_serial_number: String, gateway_cosmos_address: String) -> Self {
|
||||||
|
SpendCredentialData {
|
||||||
|
funds,
|
||||||
|
blinded_serial_number,
|
||||||
|
gateway_cosmos_address,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn funds(&self) -> &Coin {
|
||||||
|
&self.funds
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn blinded_serial_number(&self) -> &str {
|
||||||
|
&self.blinded_serial_number
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn gateway_cosmos_address(&self) -> &str {
|
||||||
|
&self.gateway_cosmos_address
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||||
|
pub enum SpendCredentialStatus {
|
||||||
|
InProgress,
|
||||||
|
Spent,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
||||||
|
pub struct SpendCredential {
|
||||||
|
funds: Coin,
|
||||||
|
blinded_serial_number: String,
|
||||||
|
gateway_cosmos_address: Addr,
|
||||||
|
status: SpendCredentialStatus,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SpendCredential {
|
||||||
|
pub fn new(funds: Coin, blinded_serial_number: String, gateway_cosmos_address: Addr) -> Self {
|
||||||
|
SpendCredential {
|
||||||
|
funds,
|
||||||
|
blinded_serial_number,
|
||||||
|
gateway_cosmos_address,
|
||||||
|
status: SpendCredentialStatus::InProgress,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn blinded_serial_number(&self) -> &str {
|
||||||
|
&self.blinded_serial_number
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn status(&self) -> SpendCredentialStatus {
|
||||||
|
self.status
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn mark_as_spent(&mut self) {
|
||||||
|
self.status = SpendCredentialStatus::Spent;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
||||||
|
pub struct PagedSpendCredentialResponse {
|
||||||
|
pub spend_credentials: Vec<SpendCredential>,
|
||||||
|
pub per_page: usize,
|
||||||
|
pub start_next_after: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PagedSpendCredentialResponse {
|
||||||
|
pub fn new(
|
||||||
|
spend_credentials: Vec<SpendCredential>,
|
||||||
|
per_page: usize,
|
||||||
|
start_next_after: Option<String>,
|
||||||
|
) -> Self {
|
||||||
|
PagedSpendCredentialResponse {
|
||||||
|
spend_credentials,
|
||||||
|
per_page,
|
||||||
|
start_next_after,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
||||||
|
pub struct SpendCredentialResponse {
|
||||||
|
pub spend_credential: Option<SpendCredential>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SpendCredentialResponse {
|
||||||
|
pub fn new(spend_credential: Option<SpendCredential>) -> Self {
|
||||||
|
SpendCredentialResponse { spend_credential }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn to_cosmos_msg(
|
||||||
|
funds: Coin,
|
||||||
|
blinded_serial_number: String,
|
||||||
|
coconut_bandwidth_addr: String,
|
||||||
|
multisig_addr: String,
|
||||||
|
) -> StdResult<CosmosMsg> {
|
||||||
|
let release_funds_req = ExecuteMsg::ReleaseFunds { funds };
|
||||||
|
let release_funds_msg = CosmosMsg::Wasm(WasmMsg::Execute {
|
||||||
|
contract_addr: coconut_bandwidth_addr,
|
||||||
|
msg: to_binary(&release_funds_req)?,
|
||||||
|
funds: vec![],
|
||||||
|
});
|
||||||
|
let req = MultisigExecuteMsg::Propose {
|
||||||
|
title: String::from("Release funds, as ordered by Coconut Bandwidth Contract"),
|
||||||
|
description: blinded_serial_number,
|
||||||
|
msgs: vec![release_funds_msg],
|
||||||
|
latest: None,
|
||||||
|
};
|
||||||
|
let msg = CosmosMsg::Wasm(WasmMsg::Execute {
|
||||||
|
contract_addr: multisig_addr,
|
||||||
|
msg: to_binary(&req)?,
|
||||||
|
funds: vec![],
|
||||||
|
});
|
||||||
|
|
||||||
|
Ok(msg)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn funds_from_cosmos_msgs(msgs: Vec<CosmosMsg>) -> Option<Coin> {
|
||||||
|
if let Some(CosmosMsg::Wasm(WasmMsg::Execute {
|
||||||
|
contract_addr: _,
|
||||||
|
msg,
|
||||||
|
funds: _,
|
||||||
|
})) = msgs.get(0)
|
||||||
|
{
|
||||||
|
if let Ok(ExecuteMsg::ReleaseFunds { funds }) = from_binary::<ExecuteMsg>(msg) {
|
||||||
|
return Some(funds);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
@@ -3,6 +3,7 @@ name = "mixnet-contract-common"
|
|||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
authors = ["Jędrzej Stuczyński <andrew@nymtech.net>"]
|
authors = ["Jędrzej Stuczyński <andrew@nymtech.net>"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
rust-version = "1.62"
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
@@ -13,7 +14,6 @@ serde = { version = "1.0", features = ["derive"] }
|
|||||||
serde_repr = "0.1"
|
serde_repr = "0.1"
|
||||||
schemars = "0.8"
|
schemars = "0.8"
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
network-defaults = { path = "../../network-defaults" }
|
|
||||||
fixed = { version = "1.1", features = ["serde"] }
|
fixed = { version = "1.1", features = ["serde"] }
|
||||||
az = "1.1"
|
az = "1.1"
|
||||||
log = "0.4.14"
|
log = "0.4.14"
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ pub struct Delegation {
|
|||||||
pub node_identity: IdentityKey,
|
pub node_identity: IdentityKey,
|
||||||
pub amount: Coin,
|
pub amount: Coin,
|
||||||
pub block_height: u64,
|
pub block_height: u64,
|
||||||
pub proxy: Option<Addr>, // proxy address used to delegate the funds on behalf of anouther address
|
pub proxy: Option<Addr>, // proxy address used to delegate the funds on behalf of another address
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Eq for Delegation {}
|
impl Eq for Delegation {}
|
||||||
@@ -123,7 +123,7 @@ impl Display for Delegation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||||
pub struct PagedMixDelegationsResponse {
|
pub struct PagedMixDelegationsResponse {
|
||||||
pub delegations: Vec<Delegation>,
|
pub delegations: Vec<Delegation>,
|
||||||
pub start_next_after: Option<(String, u64)>,
|
pub start_next_after: Option<(String, u64)>,
|
||||||
@@ -138,7 +138,7 @@ impl PagedMixDelegationsResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||||
pub struct PagedDelegatorDelegationsResponse {
|
pub struct PagedDelegatorDelegationsResponse {
|
||||||
pub delegations: Vec<Delegation>,
|
pub delegations: Vec<Delegation>,
|
||||||
pub start_next_after: Option<IdentityKey>,
|
pub start_next_after: Option<IdentityKey>,
|
||||||
@@ -153,7 +153,7 @@ impl PagedDelegatorDelegationsResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||||
pub struct PagedAllDelegationsResponse {
|
pub struct PagedAllDelegationsResponse {
|
||||||
pub delegations: Vec<Delegation>,
|
pub delegations: Vec<Delegation>,
|
||||||
pub start_next_after: Option<(IdentityKey, Vec<u8>, u64)>,
|
pub start_next_after: Option<(IdentityKey, Vec<u8>, u64)>,
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ use serde::{Deserialize, Serialize};
|
|||||||
use std::cmp::Ordering;
|
use std::cmp::Ordering;
|
||||||
use std::fmt::Display;
|
use std::fmt::Display;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize, JsonSchema)]
|
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, PartialOrd, Serialize, JsonSchema)]
|
||||||
pub struct Gateway {
|
pub struct Gateway {
|
||||||
pub host: String,
|
pub host: String,
|
||||||
pub mix_port: u16,
|
pub mix_port: u16,
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ pub(crate) mod string_rfc3339_offset_date_time {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, PartialOrd, Serialize)]
|
#[derive(Clone, Copy, Debug, Deserialize, PartialEq, Eq, PartialOrd, Serialize)]
|
||||||
pub struct Interval {
|
pub struct Interval {
|
||||||
id: u32,
|
id: u32,
|
||||||
#[serde(with = "string_rfc3339_offset_date_time")]
|
#[serde(with = "string_rfc3339_offset_date_time")]
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ use std::fmt::Display;
|
|||||||
feature = "generate-ts",
|
feature = "generate-ts",
|
||||||
ts(export_to = "ts-packages/types/src/types/rust/RewardedSetNodeStatus.ts")
|
ts(export_to = "ts-packages/types/src/types/rust/RewardedSetNodeStatus.ts")
|
||||||
)]
|
)]
|
||||||
#[derive(Clone, Copy, Debug, Deserialize, Serialize, JsonSchema, PartialEq)]
|
#[derive(Clone, Copy, Debug, Deserialize, Serialize, JsonSchema, PartialEq, Eq)]
|
||||||
pub enum RewardedSetNodeStatus {
|
pub enum RewardedSetNodeStatus {
|
||||||
Active,
|
Active,
|
||||||
Standby,
|
Standby,
|
||||||
@@ -37,6 +37,16 @@ pub enum DelegationEvent {
|
|||||||
Undelegate(PendingUndelegate),
|
Undelegate(PendingUndelegate),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl DelegationEvent {
|
||||||
|
pub fn delegation_amount(&self) -> Option<Coin> {
|
||||||
|
match self {
|
||||||
|
DelegationEvent::Delegate(delegation) => Some(delegation.amount.clone()),
|
||||||
|
// I think it would be nice to also expose an amount here to know how much we're undelegating
|
||||||
|
DelegationEvent::Undelegate(_) => None,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
|
#[derive(Clone, Debug, Deserialize, Serialize, JsonSchema)]
|
||||||
pub struct PendingUndelegate {
|
pub struct PendingUndelegate {
|
||||||
mix_identity: IdentityKey,
|
mix_identity: IdentityKey,
|
||||||
@@ -106,7 +116,7 @@ impl PendingUndelegate {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, PartialOrd, Serialize, JsonSchema)]
|
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, PartialOrd, Serialize, JsonSchema)]
|
||||||
pub struct MixNode {
|
pub struct MixNode {
|
||||||
pub host: String,
|
pub host: String,
|
||||||
pub mix_port: u16,
|
pub mix_port: u16,
|
||||||
@@ -245,7 +255,7 @@ impl DelegatorRewardParams {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, JsonSchema, PartialEq, Serialize, Deserialize, Copy)]
|
#[derive(Debug, Clone, JsonSchema, PartialEq, Eq, Serialize, Deserialize, Copy)]
|
||||||
pub struct StoredNodeRewardResult {
|
pub struct StoredNodeRewardResult {
|
||||||
reward: Uint128,
|
reward: Uint128,
|
||||||
|
|
||||||
|
|||||||
@@ -7,12 +7,13 @@ use crate::{Gateway, IdentityKey, MixNode};
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
pub struct InstantiateMsg {
|
pub struct InstantiateMsg {
|
||||||
pub rewarding_validator_address: String,
|
pub rewarding_validator_address: String,
|
||||||
|
pub mixnet_denom: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum ExecuteMsg {
|
pub enum ExecuteMsg {
|
||||||
UpdateRewardingValidatorAddress {
|
UpdateRewardingValidatorAddress {
|
||||||
@@ -32,6 +33,12 @@ pub enum ExecuteMsg {
|
|||||||
CompoundDelegatorReward {
|
CompoundDelegatorReward {
|
||||||
mix_identity: IdentityKey,
|
mix_identity: IdentityKey,
|
||||||
},
|
},
|
||||||
|
CompoundReward {
|
||||||
|
operator: Option<String>,
|
||||||
|
delegator: Option<String>,
|
||||||
|
mix_identity: Option<IdentityKey>,
|
||||||
|
proxy: Option<String>,
|
||||||
|
},
|
||||||
BondMixnode {
|
BondMixnode {
|
||||||
mix_node: MixNode,
|
mix_node: MixNode,
|
||||||
owner_signature: String,
|
owner_signature: String,
|
||||||
@@ -112,9 +119,10 @@ pub enum ExecuteMsg {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum QueryMsg {
|
pub enum QueryMsg {
|
||||||
|
GetBlacklistedNodes {},
|
||||||
GetCurrentOperatorCost {},
|
GetCurrentOperatorCost {},
|
||||||
GetRewardingValidatorAddress {},
|
GetRewardingValidatorAddress {},
|
||||||
GetAllDelegationKeys {},
|
GetAllDelegationKeys {},
|
||||||
@@ -205,6 +213,31 @@ pub enum QueryMsg {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub struct MigrateMsg {}
|
pub struct MigrateMsg {
|
||||||
|
pub mixnet_denom: String,
|
||||||
|
pub nodes_to_remove: Option<Vec<NodeToRemove>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl MigrateMsg {
|
||||||
|
pub fn nodes_to_remove(&self) -> Vec<NodeToRemove> {
|
||||||
|
self.nodes_to_remove.clone().unwrap_or_default()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
|
pub struct NodeToRemove {
|
||||||
|
owner: String,
|
||||||
|
proxy: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl NodeToRemove {
|
||||||
|
pub fn owner(&self) -> &str {
|
||||||
|
&self.owner
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn proxy(&self) -> Option<&String> {
|
||||||
|
self.proxy.as_ref()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use cosmwasm_std::Uint128;
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Debug, Clone, JsonSchema, PartialEq, Serialize, Deserialize, Copy)]
|
#[derive(Debug, Clone, JsonSchema, PartialEq, Eq, Serialize, Deserialize, Copy)]
|
||||||
pub struct NodeEpochRewards {
|
pub struct NodeEpochRewards {
|
||||||
params: NodeRewardParams,
|
params: NodeRewardParams,
|
||||||
result: StoredNodeRewardResult,
|
result: StoredNodeRewardResult,
|
||||||
@@ -105,7 +105,7 @@ impl NodeEpochRewards {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, JsonSchema, PartialEq, Serialize, Deserialize, Copy)]
|
#[derive(Debug, Clone, JsonSchema, PartialEq, Eq, Serialize, Deserialize, Copy)]
|
||||||
pub struct EpochRewardParams {
|
pub struct EpochRewardParams {
|
||||||
epoch_reward_pool: Uint128,
|
epoch_reward_pool: Uint128,
|
||||||
rewarded_set_size: Uint128,
|
rewarded_set_size: Uint128,
|
||||||
@@ -175,7 +175,7 @@ impl EpochRewardParams {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, JsonSchema, PartialEq, Serialize, Deserialize, Copy)]
|
#[derive(Debug, Clone, JsonSchema, PartialEq, Eq, Serialize, Deserialize, Copy)]
|
||||||
pub struct NodeRewardParams {
|
pub struct NodeRewardParams {
|
||||||
reward_blockstamp: u64,
|
reward_blockstamp: u64,
|
||||||
uptime: Uint128,
|
uptime: Uint128,
|
||||||
@@ -208,7 +208,7 @@ impl NodeRewardParams {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, JsonSchema, PartialEq, Serialize, Deserialize, Copy)]
|
#[derive(Debug, Clone, JsonSchema, PartialEq, Eq, Serialize, Deserialize, Copy)]
|
||||||
pub struct RewardParams {
|
pub struct RewardParams {
|
||||||
pub epoch: EpochRewardParams,
|
pub epoch: EpochRewardParams,
|
||||||
pub node: NodeRewardParams,
|
pub node: NodeRewardParams,
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ impl LayerDistribution {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
pub struct ContractStateParams {
|
pub struct ContractStateParams {
|
||||||
// so currently interval_length is being unused and validator API performs rewarding
|
// so currently interval_length is being unused and validator API performs rewarding
|
||||||
// based on its own interval length config value. I guess that's fine for time being
|
// based on its own interval length config value. I guess that's fine for time being
|
||||||
@@ -72,7 +72,7 @@ impl Display for ContractStateParams {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]
|
#[derive(Default, Debug, Serialize, Deserialize, PartialEq, Eq)]
|
||||||
pub struct RewardingResult {
|
pub struct RewardingResult {
|
||||||
pub node_reward: Uint128,
|
pub node_reward: Uint128,
|
||||||
}
|
}
|
||||||
@@ -124,21 +124,21 @@ pub type IdentityKey = String;
|
|||||||
pub type IdentityKeyRef<'a> = &'a str;
|
pub type IdentityKeyRef<'a> = &'a str;
|
||||||
pub type SphinxKey = String;
|
pub type SphinxKey = String;
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, JsonSchema)]
|
#[derive(Clone, Debug, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
|
||||||
pub struct PagedRewardedSetResponse {
|
pub struct PagedRewardedSetResponse {
|
||||||
pub identities: Vec<(IdentityKey, RewardedSetNodeStatus)>,
|
pub identities: Vec<(IdentityKey, RewardedSetNodeStatus)>,
|
||||||
pub start_next_after: Option<IdentityKey>,
|
pub start_next_after: Option<IdentityKey>,
|
||||||
pub at_height: u64,
|
pub at_height: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||||
pub struct RewardedSetUpdateDetails {
|
pub struct RewardedSetUpdateDetails {
|
||||||
pub refresh_rate_blocks: u64,
|
pub refresh_rate_blocks: u64,
|
||||||
pub last_refreshed_block: u64,
|
pub last_refreshed_block: u64,
|
||||||
pub current_height: u64,
|
pub current_height: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, Deserialize, PartialEq, Serialize, JsonSchema)]
|
#[derive(Clone, Debug, Deserialize, PartialEq, Eq, Serialize, JsonSchema)]
|
||||||
pub struct IntervalRewardedSetHeightsResponse {
|
pub struct IntervalRewardedSetHeightsResponse {
|
||||||
pub interval_id: u32,
|
pub interval_id: u32,
|
||||||
pub heights: Vec<u64>,
|
pub heights: Vec<u64>,
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ use cw_utils::{Duration, Expiration, Threshold};
|
|||||||
pub struct InstantiateMsg {
|
pub struct InstantiateMsg {
|
||||||
// this is the group contract that contains the member list
|
// this is the group contract that contains the member list
|
||||||
pub group_addr: String,
|
pub group_addr: String,
|
||||||
|
pub coconut_bandwidth_contract_address: String,
|
||||||
pub threshold: Threshold,
|
pub threshold: Threshold,
|
||||||
pub max_voting_period: Duration,
|
pub max_voting_period: Duration,
|
||||||
}
|
}
|
||||||
@@ -44,7 +45,7 @@ pub enum ExecuteMsg {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We can also add this as a cw3 extension
|
// We can also add this as a cw3 extension
|
||||||
#[derive(Serialize, Deserialize, Clone, PartialEq, JsonSchema, Debug)]
|
#[derive(Serialize, Deserialize, Clone, PartialEq, Eq, JsonSchema, Debug)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum QueryMsg {
|
pub enum QueryMsg {
|
||||||
/// Return ThresholdResponse
|
/// Return ThresholdResponse
|
||||||
@@ -77,3 +78,8 @@ pub enum QueryMsg {
|
|||||||
limit: Option<u32>,
|
limit: Option<u32>,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub struct MigrateMsg {
|
||||||
|
pub coconut_bandwidth_address: String,
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,17 +1,17 @@
|
|||||||
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
// Copyright 2022 - Nym Technologies SA <contact@nymtech.net>
|
||||||
// SPDX-License-Identifier: Apache-2.0
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
use config::defaults::MIX_DENOM;
|
use cosmwasm_std::{Addr, Coin, Timestamp, Uint128};
|
||||||
use cosmwasm_std::{Coin, Timestamp};
|
|
||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
pub use messages::{ExecuteMsg, InitMsg, MigrateMsg, QueryMsg};
|
pub use messages::{ExecuteMsg, InitMsg, MigrateMsg, QueryMsg};
|
||||||
|
use mixnet_contract_common::IdentityKey;
|
||||||
|
|
||||||
pub mod events;
|
pub mod events;
|
||||||
pub mod messages;
|
pub mod messages;
|
||||||
|
|
||||||
pub fn one_ucoin() -> Coin {
|
pub fn one_ucoin(denom: String) -> Coin {
|
||||||
Coin::new(1, MIX_DENOM.base)
|
Coin::new(1, denom)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
#[cfg_attr(feature = "generate-ts", derive(ts_rs::TS))]
|
||||||
@@ -19,7 +19,7 @@ pub fn one_ucoin() -> Coin {
|
|||||||
feature = "generate-ts",
|
feature = "generate-ts",
|
||||||
ts(export_to = "ts-packages/types/src/types/rust/Period.ts")
|
ts(export_to = "ts-packages/types/src/types/rust/Period.ts")
|
||||||
)]
|
)]
|
||||||
#[derive(Debug, PartialEq, Serialize, Deserialize, Clone, JsonSchema)]
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone, JsonSchema)]
|
||||||
pub enum Period {
|
pub enum Period {
|
||||||
Before,
|
Before,
|
||||||
In(usize),
|
In(usize),
|
||||||
@@ -28,8 +28,8 @@ pub enum Period {
|
|||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||||
pub struct PledgeData {
|
pub struct PledgeData {
|
||||||
amount: Coin,
|
pub amount: Coin,
|
||||||
block_time: Timestamp,
|
pub block_time: Timestamp,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PledgeData {
|
impl PledgeData {
|
||||||
@@ -48,9 +48,9 @@ impl PledgeData {
|
|||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
||||||
pub struct OriginalVestingResponse {
|
pub struct OriginalVestingResponse {
|
||||||
amount: Coin,
|
pub amount: Coin,
|
||||||
number_of_periods: usize,
|
pub number_of_periods: usize,
|
||||||
period_duration: u64,
|
pub period_duration: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl OriginalVestingResponse {
|
impl OriginalVestingResponse {
|
||||||
@@ -74,3 +74,35 @@ impl OriginalVestingResponse {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone, JsonSchema)]
|
||||||
|
pub struct VestingDelegation {
|
||||||
|
pub account_id: u32,
|
||||||
|
pub mix_identity: IdentityKey,
|
||||||
|
pub block_timestamp: u64,
|
||||||
|
pub amount: Uint128,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl VestingDelegation {
|
||||||
|
pub fn storage_key(&self) -> (u32, IdentityKey, u64) {
|
||||||
|
(
|
||||||
|
self.account_id,
|
||||||
|
self.mix_identity.clone(),
|
||||||
|
self.block_timestamp,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone, JsonSchema)]
|
||||||
|
pub struct DelegationTimesResponse {
|
||||||
|
pub owner: Addr,
|
||||||
|
pub account_id: u32,
|
||||||
|
pub mix_identity: IdentityKey,
|
||||||
|
pub delegation_timestamps: Vec<u64>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, PartialEq, Eq, Serialize, Deserialize, Clone, JsonSchema)]
|
||||||
|
pub struct AllDelegationsResponse {
|
||||||
|
pub delegations: Vec<VestingDelegation>,
|
||||||
|
pub start_next_after: Option<(u32, IdentityKey, u64)>,
|
||||||
|
}
|
||||||
|
|||||||
@@ -3,17 +3,20 @@ use mixnet_contract_common::{Gateway, IdentityKey, MixNode};
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub struct InitMsg {
|
pub struct InitMsg {
|
||||||
pub mixnet_contract_address: String,
|
pub mixnet_contract_address: String,
|
||||||
|
pub mix_denom: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub struct MigrateMsg {}
|
pub struct MigrateMsg {
|
||||||
|
pub mix_denom: String,
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema, Default)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, Default)]
|
||||||
pub struct VestingSpecification {
|
pub struct VestingSpecification {
|
||||||
start_time: Option<u64>,
|
start_time: Option<u64>,
|
||||||
period_seconds: Option<u64>,
|
period_seconds: Option<u64>,
|
||||||
@@ -118,7 +121,7 @@ pub enum ExecuteMsg {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
|
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
pub enum QueryMsg {
|
pub enum QueryMsg {
|
||||||
LockedCoins {
|
LockedCoins {
|
||||||
@@ -167,4 +170,12 @@ pub enum QueryMsg {
|
|||||||
address: String,
|
address: String,
|
||||||
},
|
},
|
||||||
GetLockedPledgeCap {},
|
GetLockedPledgeCap {},
|
||||||
|
GetDelegationTimes {
|
||||||
|
address: String,
|
||||||
|
mix_identity: IdentityKey,
|
||||||
|
},
|
||||||
|
GetAllDelegations {
|
||||||
|
start_after: Option<(u32, IdentityKey, u64)>,
|
||||||
|
limit: Option<u32>,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,13 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
bls12_381 = { version = "0.5", default-features = false, features = ["pairings", "alloc", "experimental"] }
|
bls12_381 = { version = "0.5", default-features = false, features = ["pairings", "alloc", "experimental"] }
|
||||||
cosmrs = { version = "0.7.0", optional = true }
|
cosmrs = { git = "https://github.com/neacsu/cosmos-rust", branch = "neacsu/feegrant_support", optional = true }
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
url = "2.2"
|
url = "2.2"
|
||||||
|
|
||||||
# I guess temporarily until we get serde support in coconut up and running
|
# I guess temporarily until we get serde support in coconut up and running
|
||||||
coconut-interface = { path = "../coconut-interface" }
|
coconut-interface = { path = "../coconut-interface" }
|
||||||
crypto = { path = "../crypto", features = ["rand", "asymmetric", "symmetric", "hashing"] }
|
crypto = { path = "../crypto", features = ["rand", "asymmetric", "symmetric", "hashing"] }
|
||||||
network-defaults = { path = "../network-defaults" }
|
|
||||||
validator-api-requests = { path = "../../validator-api/validator-api-requests" }
|
validator-api-requests = { path = "../../validator-api/validator-api-requests" }
|
||||||
validator-client = { path = "../client-libs/validator-client" }
|
validator-client = { path = "../client-libs/validator-client" }
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ use std::ops::Neg;
|
|||||||
use zeroize::Zeroize;
|
use zeroize::Zeroize;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(Clone, PartialEq))]
|
#[cfg_attr(test, derive(Clone, PartialEq, Eq))]
|
||||||
pub struct Ciphertexts {
|
pub struct Ciphertexts {
|
||||||
pub rr: [G1Projective; NUM_CHUNKS],
|
pub rr: [G1Projective; NUM_CHUNKS],
|
||||||
pub ss: [G1Projective; NUM_CHUNKS],
|
pub ss: [G1Projective; NUM_CHUNKS],
|
||||||
|
|||||||
@@ -335,7 +335,7 @@ pub fn keygen(params: &Params, mut rng: impl RngCore) -> (DecryptionKey, PublicK
|
|||||||
(dk, key_with_proof)
|
(dk, key_with_proof)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub struct PublicKey(pub(crate) G1Projective);
|
pub struct PublicKey(pub(crate) G1Projective);
|
||||||
|
|
||||||
impl PublicKey {
|
impl PublicKey {
|
||||||
@@ -345,7 +345,7 @@ impl PublicKey {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq, Eq))]
|
||||||
pub struct PublicKeyWithProof {
|
pub struct PublicKeyWithProof {
|
||||||
pub(crate) key: PublicKey,
|
pub(crate) key: PublicKey,
|
||||||
pub(crate) proof: ProofOfDiscreteLog,
|
pub(crate) proof: ProofOfDiscreteLog,
|
||||||
|
|||||||
@@ -243,7 +243,7 @@ impl Zeroize for Tau {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
|
#[derive(Copy, Clone, Debug, PartialEq, Eq, PartialOrd)]
|
||||||
pub struct Epoch(EpochStore);
|
pub struct Epoch(EpochStore);
|
||||||
|
|
||||||
impl Epoch {
|
impl Epoch {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ impl<'a> Instance<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(Clone, PartialEq))]
|
#[cfg_attr(test, derive(Clone, PartialEq, Eq))]
|
||||||
pub struct ProofOfChunking {
|
pub struct ProofOfChunking {
|
||||||
y0: G1Projective,
|
y0: G1Projective,
|
||||||
bb: Vec<G1Projective>,
|
bb: Vec<G1Projective>,
|
||||||
|
|||||||
@@ -14,7 +14,7 @@ const DISCRETE_LOG_DOMAIN: &[u8] =
|
|||||||
b"NYM_COCONUT_NIDKG_V01_CS01_WITH_BLS12381_XMD:SHA-256_SSWU_RO_PROOF_DISCRETE_LOG";
|
b"NYM_COCONUT_NIDKG_V01_CS01_WITH_BLS12381_XMD:SHA-256_SSWU_RO_PROOF_DISCRETE_LOG";
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq, Eq))]
|
||||||
pub struct ProofOfDiscreteLog {
|
pub struct ProofOfDiscreteLog {
|
||||||
pub(crate) rand_commitment: G1Projective,
|
pub(crate) rand_commitment: G1Projective,
|
||||||
pub(crate) response: Scalar,
|
pub(crate) response: Scalar,
|
||||||
|
|||||||
@@ -77,7 +77,7 @@ impl<'a> Instance<'a> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(Clone, PartialEq))]
|
#[cfg_attr(test, derive(Clone, PartialEq, Eq))]
|
||||||
pub struct ProofOfSecretSharing {
|
pub struct ProofOfSecretSharing {
|
||||||
ff: G1Projective,
|
ff: G1Projective,
|
||||||
aa: G2Projective,
|
aa: G2Projective,
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use std::collections::BTreeMap;
|
|||||||
use zeroize::Zeroize;
|
use zeroize::Zeroize;
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
#[cfg_attr(test, derive(PartialEq))]
|
#[cfg_attr(test, derive(PartialEq, Eq))]
|
||||||
pub struct Dealing {
|
pub struct Dealing {
|
||||||
pub public_coefficients: PublicCoefficients,
|
pub public_coefficients: PublicCoefficients,
|
||||||
pub ciphertexts: Ciphertexts,
|
pub ciphertexts: Ciphertexts,
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user