diff --git a/.github/workflows/add-to-project.yml b/.github/workflows/add-to-project.yml index 0fe098c..0612db8 100644 --- a/.github/workflows/add-to-project.yml +++ b/.github/workflows/add-to-project.yml @@ -10,7 +10,7 @@ jobs: name: Add issue to project runs-on: ubuntu-latest steps: - - uses: actions/add-to-project@v1.0.0 + - uses: actions/add-to-project@v1.0.2 with: - project-url: https://github.com/orgs/okp4/projects/9 - github-token: ${{ secrets.OKP4_TOKEN }} + project-url: https://github.com/orgs/axone-protocol/projects/2 + github-token: ${{ secrets.OPS_TOKEN }} diff --git a/.github/workflows/auto-merge.yml b/.github/workflows/auto-merge.yml index 0d02ac8..7dcf3a2 100644 --- a/.github/workflows/auto-merge.yml +++ b/.github/workflows/auto-merge.yml @@ -12,4 +12,4 @@ jobs: uses: ahmadnassri/action-dependabot-auto-merge@v2 with: target: minor - github-token: ${{ secrets.OKP4_TOKEN }} + github-token: ${{ secrets.OPS_TOKEN }} diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5e59f33..8d8484f 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,10 +4,10 @@ on: workflow_call: push: - branches: [ main ] + branches: [main] pull_request: - branches: [ main ] + branches: [main] concurrency: group: build-${{ github.ref }} @@ -21,20 +21,10 @@ jobs: uses: actions/checkout@v4 - name: Setup Go environment - uses: actions/setup-go@v5.0.0 + uses: actions/setup-go@v5.0.2 with: - go-version: "1.21" + go-version: '1.21' - name: Build go project run: | make build - - build-docker: - runs-on: ubuntu-22.04 - steps: - - name: Check out repository - uses: actions/checkout@v4 - - - name: Build docker image - run: | - docker build . diff --git a/.github/workflows/follow-contributor.yml b/.github/workflows/follow-contributor.yml index 88b881a..8d22e28 100644 --- a/.github/workflows/follow-contributor.yml +++ b/.github/workflows/follow-contributor.yml @@ -12,4 +12,4 @@ jobs: uses: okp4/follow-contributor-action@v1.1.0 with: username: ${{ github.event.pull_request.user.login }} - token: ${{ secrets.OKP4_TOKEN }} + token: ${{ secrets.OPS_TOKEN }} diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 9ea51b2..73a3be2 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,17 +1,13 @@ name: Lint on: - workflow_call: - push: branches: [ main ] pull_request: branches: [ main ] -concurrency: - group: lint-${{ github.ref }} - cancel-in-progress: true + workflow_dispatch: jobs: lint-commits: @@ -36,7 +32,6 @@ jobs: uses: avto-dev/markdown-lint@v1.5.0 with: args: "**/*.md" - ignore: "CHANGELOG.md" lint-yaml: runs-on: ubuntu-22.04 @@ -53,10 +48,12 @@ jobs: steps: - name: Check out repository uses: actions/checkout@v4 + with: + fetch-depth: 0 - name: Find changed go files id: changed-go-files - uses: tj-actions/changed-files@v44.0.0 + uses: tj-actions/changed-files@v44.5.7 with: files: | **/*.go @@ -64,16 +61,66 @@ jobs: go.sum - name: Setup Go environment - uses: actions/setup-go@v5.0.0 + uses: actions/setup-go@v5.0.2 if: steps.changed-go-files.outputs.any_changed == 'true' with: go-version: "1.21" + cache: false - name: Lint go code (golangci-lint) - uses: golangci/golangci-lint-action@v4 + uses: golangci/golangci-lint-action@v6 if: steps.changed-go-files.outputs.any_changed == 'true' with: - version: v1.55 + version: v1.59 + + - name: Lint go code (gofumpt) + if: steps.changed-go-files.outputs.any_changed == 'true' + run: | + go install mvdan.cc/gofumpt@v0.6.0 + if [ "$(gofumpt -l .)" != "" ]; then + echo "โŒ Code is not gofumpt!" + exit 1 + fi + echo "โœ… Code is gofumpt!" + + analyze-go: + runs-on: ubuntu-22.04 + permissions: + actions: read + contents: read + security-events: write + + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Find changed go files + id: changed-go-files + uses: tj-actions/changed-files@v44.5.7 + with: + files: | + **/*.go + go.mod + go.sum + + - name: Setup Go environment + uses: actions/setup-go@v5.0.2 + with: + go-version: "1.21" + cache: false + + - name: Initialize CodeQL + uses: github/codeql-action/init@v3 + with: + languages: "go" + + - name: Autobuild project + uses: github/codeql-action/autobuild@v3 + + - name: Perform CodeQL Analysis + uses: github/codeql-action/analyze@v3 lint-dockerfile: runs-on: ubuntu-22.04 @@ -84,13 +131,22 @@ jobs: - name: Lint dockerfile (hadolint) uses: hadolint/hadolint-action@v3.1.0 + with: + verbose: true + + lint-shell: + runs-on: ubuntu-22.04 + steps: + - name: Check out repository + uses: actions/checkout@v4 - - name: Lint dockerfile (docker-lint) - uses: luke142367/Docker-Lint-Action@v1.1.1 + - name: Lint shell scripts + uses: ludeeus/action-shellcheck@2.0.0 with: - target: Dockerfile + scandir: . + version: "v0.9.0" env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SHELLCHECK_OPTS: -e SC2034 lint-branch-name: runs-on: ubuntu-22.04 @@ -125,7 +181,7 @@ jobs: if: ${{ failure() }} uses: codelytv/no-pull-requests@v1 with: - GITHUB_TOKEN: ${{ secrets.OKP4_TOKEN }} + GITHUB_TOKEN: ${{ secrets.OPS_TOKEN }} message: ๐Ÿ™… Closing the PR because it does not respect naming conventions. Edit the branch name and submit a new PR. env: - GITHUB_TOKEN: ${{ secrets.OKP4_TOKEN }} + GITHUB_TOKEN: ${{ secrets.OPS_TOKEN }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 1552341..9a42409 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -16,9 +16,8 @@ jobs: - name: Check out repository uses: actions/checkout@v4 - - name: Set up context - id: project_context - uses: FranzDiebold/github-env-vars-action@v2.8.0 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 - name: Extract metadata (tags, labels) for Docker id: docker_metadata @@ -26,7 +25,7 @@ jobs: with: images: ghcr.io/${{ github.repository }} tags: | - type=raw,value=nightly + type=raw,enable=${{ endsWith(github.ref, github.event.repository.default_branch) }},value=nightly type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=semver,pattern={{major}} @@ -41,10 +40,10 @@ jobs: password: ${{ secrets.DOCKER_REGISTRY_TOKEN }} - name: Build and publish image(s) - uses: docker/build-push-action@v5 + uses: docker/build-push-action@v6 with: context: . - platforms: linux/amd64 + platforms: linux/amd64,linux/arm64 push: true tags: ${{ steps.docker_metadata.outputs.tags }} labels: ${{ steps.docker_metadata.outputs.labels }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9006da9..804d52b 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -27,13 +27,13 @@ jobs: - name: Check out repository uses: actions/checkout@v4 with: - token: ${{ secrets.OKP4_TOKEN }} + token: ${{ secrets.OPS_TOKEN }} - name: Import GPG key uses: crazy-max/ghaction-import-gpg@v6 with: - gpg_private_key: ${{ secrets.OKP4_BOT_GPG_PRIVATE_KEY }} - passphrase: ${{ secrets.OKP4_BOT_GPG_PASSPHRASE }} + gpg_private_key: ${{ secrets.BOT_GPG_PRIVATE_KEY }} + passphrase: ${{ secrets.BOT_GPG_PASSPHRASE }} git_config_global: true git_user_signingkey: true git_commit_gpgsign: true @@ -59,8 +59,8 @@ jobs: extends: | conventional-changelog-conventionalcommits@7.0.1 env: - GITHUB_TOKEN: ${{ secrets.OKP4_TOKEN }} - GIT_AUTHOR_NAME: ${{ secrets.OKP4_BOT_GIT_AUTHOR_NAME }} - GIT_AUTHOR_EMAIL: ${{ secrets.OKP4_BOT_GIT_AUTHOR_EMAIL }} - GIT_COMMITTER_NAME: ${{ secrets.OKP4_BOT_GIT_COMMITTER_NAME }} - GIT_COMMITTER_EMAIL: ${{ secrets.OKP4_BOT_GIT_COMMITTER_EMAIL }} + GITHUB_TOKEN: ${{ secrets.OPS_TOKEN }} + GIT_AUTHOR_NAME: ${{ vars.BOT_GIT_AUTHOR_NAME }} + GIT_AUTHOR_EMAIL: ${{ vars.BOT_GIT_AUTHOR_EMAIL }} + GIT_COMMITTER_NAME: ${{ vars.BOT_GIT_COMMITTER_NAME }} + GIT_COMMITTER_EMAIL: ${{ vars.BOT_GIT_COMMITTER_EMAIL }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7303787..c16b082 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -21,19 +21,10 @@ jobs: uses: actions/checkout@v4 - name: Setup Go environment - uses: actions/setup-go@v5.0.0 + uses: actions/setup-go@v5.0.2 with: go-version: "1.21" - name: Test go project run: | make test-go - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 - if: github.actor != 'dependabot[bot]' - with: - files: ./target/coverage.out - env_vars: OS,GOLANG - fail_ci_if_error: true - verbose: true diff --git a/.github/workflows/thank.yml b/.github/workflows/thank.yml index dd86db6..ab0511d 100644 --- a/.github/workflows/thank.yml +++ b/.github/workflows/thank.yml @@ -1,6 +1,8 @@ name: Give thanks on: + workflow_dispatch: + push: branches: [ main ] @@ -15,7 +17,7 @@ jobs: - name: Find changed dependencies id: changed-dependencies - uses: tj-actions/changed-files@v44.0.0 + uses: tj-actions/changed-files@v44.5.7 with: files: | go.mod @@ -27,4 +29,4 @@ jobs: -v $(pwd):/home \ psampaz/gothanks:v0.4.0 \ -y \ - -github-token=${{ secrets.OKP4_TOKEN }} + -github-token=${{ secrets.OPS_TOKEN }} diff --git a/.releaserc.yml b/.releaserc.yml index 76c9fc0..c6372bc 100644 --- a/.releaserc.yml +++ b/.releaserc.yml @@ -4,11 +4,30 @@ branches: plugins: - - "@semantic-release/commit-analyzer" - preset: conventionalcommits + releaseRules: + - type: build + scope: deps + release: patch + - type: build + scope: deps-dev + release: patch + - type: refactor + release: patch + - type: style + release: patch + - type: ci + release: patch + - type: chore + release: patch + - type: docs + release: patch + - breaking: true + release: major - - "@semantic-release/release-notes-generator" - preset: conventionalcommits - - "@semantic-release/changelog" - changelogFile: CHANGELOG.md - changelogTitle: "# ร˜KP4 S3 auth proxy" + changelogTitle: "# Axone S3 auth proxy" - - "@google/semantic-release-replace-plugin" - replacements: - files: [version] @@ -20,6 +39,9 @@ plugins: hasChanged: true numMatches: 1 numReplacements: 1 + - - "@semantic-release/exec" + - prepareCmd: | + ./scripts/bump-module.sh - - "@semantic-release/exec" - prepareCmd: | make build-go-all @@ -41,4 +63,7 @@ plugins: - assets: - CHANGELOG.md - version + - go.mod + - go.sum + - "**/*.go" message: "chore(release): perform release ${nextRelease.version}" diff --git a/Makefile b/Makefile index d8331e6..be46887 100644 --- a/Makefile +++ b/Makefile @@ -19,9 +19,9 @@ COLOR_RESET = $(shell tput -Txterm sgr0) VERSION := $(shell cat version) COMMIT := $(shell git log -1 --format='%H') LD_FLAGS = \ - -X okp4/s3-auth-proxy/internal/version.Name=$(BINARY_NAME) \ - -X okp4/s3-auth-proxy/internal/version.Version=$(VERSION) \ - -X okp4/s3-auth-proxy/internal/version.Commit=$(COMMIT) + -X axone-protocol/s3-auth-proxy/internal/version.Name=$(BINARY_NAME) \ + -X axone-protocol/s3-auth-proxy/internal/version.Version=$(VERSION) \ + -X axone-protocol/s3-auth-proxy/internal/version.Commit=$(COMMIT) BUILD_FLAGS := -ldflags '$(LD_FLAGS)' # Commands diff --git a/README.md b/README.md index e419a66..3f2fb99 100644 --- a/README.md +++ b/README.md @@ -1,15 +1,15 @@ # S3 auth proxy -> S3 proxy ensuring authentication and authorization layer based on OKP4. +> S3 proxy ensuring authentication and authorization layer based on Axone. -[![version](https://img.shields.io/github/v/release/okp4/s3-auth-proxy?style=for-the-badge&logo=github)](https://github.com/okp4/s3-auth-proxy/releases) -[![lint](https://img.shields.io/github/actions/workflow/status/okp4/s3-auth-proxy/lint.yml?branch=main&label=lint&style=for-the-badge&logo=github)](https://github.com/okp4/s3-auth-proxy/actions/workflows/lint.yml) -[![build](https://img.shields.io/github/actions/workflow/status/okp4/s3-auth-proxy/build.yml?branch=main&label=build&style=for-the-badge&logo=github)](https://github.com/okp4/s3-auth-proxy/actions/workflows/build.yml) -[![test](https://img.shields.io/github/actions/workflow/status/okp4/s3-auth-proxy/test.yml?branch=main&label=test&style=for-the-badge&logo=github)](https://github.com/okp4/s3-auth-proxy/actions/workflows/test.yml) -[![codecov](https://img.shields.io/codecov/c/github/okp4/s3-auth-proxy?style=for-the-badge&token=6NL9ICGZQS&logo=codecov)](https://codecov.io/gh/okp4/s3-auth-proxy) +[![version](https://img.shields.io/github/v/release/axone-protocol/s3-auth-proxy?style=for-the-badge&logo=github)](https://github.com/axone-protocol/s3-auth-proxy/releases) +[![lint](https://img.shields.io/github/actions/workflow/status/axone-protocol/s3-auth-proxy/lint.yml?branch=main&label=lint&style=for-the-badge&logo=github)](https://github.com/axone-protocol/s3-auth-proxy/actions/workflows/lint.yml) +[![build](https://img.shields.io/github/actions/workflow/status/axone-protocol/s3-auth-proxy/build.yml?branch=main&label=build&style=for-the-badge&logo=github)](https://github.com/axone-protocol/s3-auth-proxy/actions/workflows/build.yml) +[![test](https://img.shields.io/github/actions/workflow/status/axone-protocol/s3-auth-proxy/test.yml?branch=main&label=test&style=for-the-badge&logo=github)](https://github.com/axone-protocol/s3-auth-proxy/actions/workflows/test.yml) +[![codecov](https://img.shields.io/codecov/c/github/axone-protocol/s3-auth-proxy?style=for-the-badge&token=6NL9ICGZQS&logo=codecov)](https://codecov.io/gh/axone-protocol/s3-auth-proxy) [![conventional commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-yellow.svg?style=for-the-badge&logo=conventionalcommits)](https://conventionalcommits.org) [![semantic-release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg?style=for-the-badge)](https://github.com/semantic-release/semantic-release) -[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg?style=for-the-badge)](https://github.com/okp4/.github/blob/main/CODE_OF_CONDUCT.md) +[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-2.1-4baaaa.svg?style=for-the-badge)](https://github.com/axone-protocol/.github/blob/main/CODE_OF_CONDUCT.md) [![License](https://img.shields.io/badge/License-BSD_3--Clause-blue.svg?style=for-the-badge)](https://opensource.org/licenses/BSD-3-Clause) ## Prerequisites @@ -38,23 +38,23 @@ We'll see how we can submit an execution order to set the file accessible throug Some tools are needed in order to run the example: - [docker](https://docs.docker.com/engine/install/) -- [okp4d](https://github.com/okp4/okp4d) +- [axoned](https://github.com/axone-protocol/axoned) - [jsonld](https://github.com/digitalbazaar/jsonld-cli) -The local chain must be running with our [contracts](https://github.com/okp4/contracts) stored. +The local chain must be running with our [contracts](https://github.com/axone-protocol/contracts) stored. -The local configuration of `okp4d` in `$OKP4D_HOME/config/client.toml` shall be self-sufficient to sign and broadcast transaction without additional command flags (e.g. `--chain-id`, `--keyring-backend`, etc..) +The local configuration of `axoned` in `$AXONED_HOME/config/client.toml` shall be self-sufficient to sign and broadcast transaction without additional command flags (e.g. `--chain-id`, `--keyring-backend`, etc..) ### Steps #### Instantiate Smart contracts -For each contract instantiation, keep the contract addresses, as they will be required for future interactions. You can inspect the transaction hash generated by the broadcasting process with `okp4d query tx $TX_HASH` and look for the events section. +For each contract instantiation, keep the contract addresses, as they will be required for future interactions. You can inspect the transaction hash generated by the broadcasting process with `axoned query tx $TX_HASH` and look for the events section. Let's begin with the objectarium: ```bash -okp4d tx wasm instantiate $OBJECTARIUM_CODE_ID \ +axoned tx wasm instantiate $OBJECTARIUM_CODE_ID \ --label "my-prologtarium" \ --from $MY_WALLET_ADDR \ --admin $MY_WALLET_ADDR \ @@ -65,13 +65,13 @@ okp4d tx wasm instantiate $OBJECTARIUM_CODE_ID \ Now let's create the law-stones containing the minio & dataset prolog governance codes: ```bash -okp4d tx wasm instantiate $LAW_STONE_CODE_ID \ +axoned tx wasm instantiate $LAW_STONE_CODE_ID \ --label "minio-gov" \ --from local \ --admin local \ --gas 100000000 \ "{\"program\":\"$(cat example/s3-gov.pl | base64)\", \"storage_address\": \"$OBJECTARIUM_ADDR\"}" -okp4d tx wasm instantiate 2 \ +axoned tx wasm instantiate 2 \ --label "data-gov" \ --from local \ --admin local \ @@ -82,7 +82,7 @@ okp4d tx wasm instantiate 2 \ Finally, the dataverse: ```bash -okp4d tx wasm instantiate $DATAVERSE_CODE_ID \ +axoned tx wasm instantiate $DATAVERSE_CODE_ID \ --label "my-local-dataverse" \ --from $MY_WALLET_ADDR \ --admin $MY_WALLET_ADDR \ @@ -103,7 +103,7 @@ Now let's declare the storage service and the dataset in the dataverse: we'll ha Before submitting them we need to update the law stone addresses related to the governances in the [example/vc-s3-gov.jsonld](example/vc-s3-gov.jsonld) and [example/vc-data-gov.jsonld](example/vc-data-gov.jsonld) credentials. Those VCs are not signed. For that we'll need to have some cryptographic keys to act as the issuers of those verifiable credentials. To facilitate this, we provide a keyring located at [example/keyring-test](example/keyring-test). -You can list the keys with `okp4d --keyring-backend test --keyring-dir example keys list` if needed. +You can list the keys with `axoned --keyring-backend test --keyring-dir example keys list` if needed. To sign and submit the verifiable credentials we have a simple script that you can use: diff --git a/cmd/version.go b/cmd/version.go index c6174ac..577721f 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -4,7 +4,7 @@ import ( "encoding/json" "strings" - "github.com/okp4/s3-auth-proxy/internal/version" + "github.com/axone-protocol/s3-auth-proxy/internal/version" "github.com/spf13/cobra" "gopkg.in/yaml.v2" diff --git a/go.mod b/go.mod index 89bad1e..578fd60 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/okp4/s3-auth-proxy +module github.com/axone-protocol/s3-auth-proxy go 1.22.5 diff --git a/main.go b/main.go index a7422e3..a0d062a 100644 --- a/main.go +++ b/main.go @@ -3,7 +3,7 @@ package main import ( "os" - "github.com/okp4/s3-auth-proxy/cmd" + "github.com/axone-protocol/s3-auth-proxy/cmd" "github.com/rs/zerolog" "github.com/rs/zerolog/log" diff --git a/scripts/bump-module.sh b/scripts/bump-module.sh new file mode 100755 index 0000000..ca2f41b --- /dev/null +++ b/scripts/bump-module.sh @@ -0,0 +1,29 @@ +#!/usr/bin/env bash + +set -eo pipefail + +major_version=$(cut -d. -f1 < version) + +if [ "${major_version}" -gt 1 ]; then + module_name=$(go mod edit -json | jq -r '.Module.Path') + module_name_unversioned=$(echo "${module_name}" | sed -E 's|/v[0-9]+$||') + module_name_versioned="${module_name_unversioned}/v${major_version}" + echo "๐Ÿ”ฌ major version detected, updating module path to ${module_name_versioned}" + + go mod edit -module "${module_name_versioned}" + echo "โœ… module name updated to ${module_name_versioned} in go.mod" + + if [ "$(uname)" = "Darwin" ]; then + find . -type f -name "*.go" -exec \ + sed -i '' "s|\"${module_name}|\"${module_name_versioned}|g" {} \; + else + find . -type f -name "*.go" -exec \ + sed -i "s|\"${module_name}|\"${module_name_versioned}|g" {} \; + fi + echo "โœ… packages updated to ${module_name_versioned} in source files" + + echo "๐Ÿงน cleaning up go.sum" + go mod tidy +else + echo "๐Ÿ™…version is not greater than 1, no need to update module path" +fi diff --git a/scripts/end-exec.sh b/scripts/end-exec.sh index 9a004a4..6e818d5 100755 --- a/scripts/end-exec.sh +++ b/scripts/end-exec.sh @@ -7,6 +7,6 @@ if [ $# != 2 ]; then exit 1 fi -BASEDIR=$(dirname $0) +BASEDIR=$(dirname "$0") -./${BASEDIR}/submit-vc.sh "${BASEDIR}/../example/vc-exec-finished.jsonld" exec-svc $1 $2 +./"${BASEDIR}"/submit-vc.sh "${BASEDIR}/../example/vc-exec-finished.jsonld" exec-svc "$1" "$2" diff --git a/scripts/issue-auth-cred.sh b/scripts/issue-auth-cred.sh index 0c7e3b2..1e22321 100755 --- a/scripts/issue-auth-cred.sh +++ b/scripts/issue-auth-cred.sh @@ -7,7 +7,7 @@ if [ $# != 0 ]; then exit 1 fi -BASEDIR=$(dirname $0) +BASEDIR=$(dirname "$0") # Sign the auth credential -okp4d --keyring-backend test --keyring-dir ${BASEDIR}/../example credential sign --from exec-svc "${BASEDIR}/../example/vc-exec-auth.jsonld" +axoned --keyring-backend test --keyring-dir "${BASEDIR}"/../example credential sign --from exec-svc "${BASEDIR}/../example/vc-exec-auth.jsonld" diff --git a/scripts/order-exec.sh b/scripts/order-exec.sh index c3d2077..e16f329 100755 --- a/scripts/order-exec.sh +++ b/scripts/order-exec.sh @@ -7,7 +7,7 @@ if [ $# != 2 ]; then exit 1 fi -BASEDIR=$(dirname $0) +BASEDIR=$(dirname "$0") -./${BASEDIR}/submit-vc.sh "${BASEDIR}/../example/vc-exec-order.jsonld" user $1 $2 -./${BASEDIR}/submit-vc.sh "${BASEDIR}/../example/vc-exec.jsonld" exec-svc $1 $2 +./"${BASEDIR}"/submit-vc.sh "${BASEDIR}/../example/vc-exec-order.jsonld" user "$1" "$2" +./"${BASEDIR}"/submit-vc.sh "${BASEDIR}/../example/vc-exec.jsonld" exec-svc "$1" "$2" diff --git a/scripts/setup.sh b/scripts/setup.sh index 5a3bb27..7088a00 100755 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -7,10 +7,10 @@ if [ $# != 2 ]; then exit 1 fi -BASEDIR=$(dirname $0) +BASEDIR=$(dirname "$0") -./${BASEDIR}/submit-vc.sh "${BASEDIR}/../example/vc-s3-desc.jsonld" s3-issuer $1 $2 -./${BASEDIR}/submit-vc.sh "${BASEDIR}/../example/vc-s3-gov.jsonld" s3 $1 $2 -./${BASEDIR}/submit-vc.sh "${BASEDIR}/../example/vc-data-desc.jsonld" data-issuer $1 $2 -./${BASEDIR}/submit-vc.sh "${BASEDIR}/../example/vc-data-gov.jsonld" data $1 $2 -./${BASEDIR}/submit-vc.sh "${BASEDIR}/../example/vc-publish.jsonld" s3-issuer $1 $2 +./"${BASEDIR}"/submit-vc.sh "${BASEDIR}/../example/vc-s3-desc.jsonld" s3-issuer "$1" "$2" +./"${BASEDIR}"/submit-vc.sh "${BASEDIR}/../example/vc-s3-gov.jsonld" s3 "$1" "$2" +./"${BASEDIR}"/submit-vc.sh "${BASEDIR}/../example/vc-data-desc.jsonld" data-issuer "$1" "$2" +./"${BASEDIR}"/submit-vc.sh "${BASEDIR}/../example/vc-data-gov.jsonld" data "$1" "$2" +./"${BASEDIR}"/submit-vc.sh "${BASEDIR}/../example/vc-publish.jsonld" s3-issuer "$1" "$2" diff --git a/scripts/submit-vc.sh b/scripts/submit-vc.sh index a70fc0c..31e5294 100755 --- a/scripts/submit-vc.sh +++ b/scripts/submit-vc.sh @@ -7,24 +7,24 @@ if [ $# != 4 ]; then exit 1 fi -BASEDIR=$(dirname $0) +BASEDIR=$(dirname "$0") -mkdir -p ${BASEDIR}/tmp +mkdir -p "${BASEDIR}"/tmp # Sign the verifiable credential -okp4d --keyring-backend test --keyring-dir ${BASEDIR}/../example credential sign --from $2 $1 > ${BASEDIR}/tmp/vc-signed.jsonld +axoned --keyring-backend test --keyring-dir "${BASEDIR}"/../example credential sign --from "$2" "$1" > "${BASEDIR}"/tmp/vc-signed.jsonld # Convert the jsonld VC to N-Quads -jsonld toRdf -q ${BASEDIR}/tmp/vc-signed.jsonld > ${BASEDIR}/tmp/vc.nq +jsonld toRdf -q "${BASEDIR}"/tmp/vc-signed.jsonld > "${BASEDIR}"/tmp/vc.nq # Submit the VC to the dataverse -TX_HASH=$(okp4d tx wasm execute --from $3 $4 --gas 20000000000 --yes -ojson \ - "{\"submit_claims\":{\"metadata\":\"$(cat ${BASEDIR}/tmp/vc.nq | base64)\"}}" \ +TX_HASH=$(axoned tx wasm execute --from "$3" "$4" --gas 20000000000 --yes -ojson \ + "{\"submit_claims\":{\"metadata\":\"$(base64 < "${BASEDIR}"/tmp/vc.nq)\"}}" \ | jq -r '.txhash') # Wait for the tx to pass -okp4d query event-query-tx-for $TX_HASH > /dev/null || true +axoned query event-query-tx-for "$TX_HASH" > /dev/null || true echo "Submitted claim '$1', tx: '$TX_HASH'" -rm -rf ${BASEDIR}/tmp +rm -rf "${BASEDIR}"/tmp