Skip to content

Commit

Permalink
Merge pull request #654 from 0xPolygonID/develop
Browse files Browse the repository at this point in the history
Develop to main
  • Loading branch information
x1m3 authored Apr 12, 2024
2 parents 84bcb60 + 9ffae93 commit 7e0c661
Show file tree
Hide file tree
Showing 73 changed files with 1,611 additions and 1,161 deletions.
3 changes: 2 additions & 1 deletion .env-api.sample
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ ISSUER_API_UI_ISSUER_DID=<Issuer DID>
ISSUER_API_UI_SCHEMA_CACHE=false
ISSUER_API_IDENTITY_METHOD=polygonid
ISSUER_API_IDENTITY_BLOCKCHAIN=polygon
ISSUER_API_IDENTITY_NETWORK=mumbai
ISSUER_API_IDENTITY_NETWORK=amoy
ISSUER_API_UI_KEY_TYPE=BJJ
ISSUER_API_ENVIRONMENT=local
ISSUER_CUSTOM_DID_METHODS='[{"blockchain":"linea","network":"testnet","networkFlag":"0b01000001","chainID":59140}]'
11 changes: 5 additions & 6 deletions .env-issuer.sample
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,17 @@ ISSUER_KEY_STORE_PLUGIN_IDEN3_MOUNT_PATH=iden3


ISSUER_ETHEREUM_URL=<Ethereum URL of the Issuer>
ISSUER_ETHEREUM_CONTRACT_ADDRESS=0x134B1BE34911E39A8397ec6289782989729807a4
ISSUER_ETHEREUM_CONTRACT_ADDRESS=0x1a4cC30f2aA0377b0c3bc9848766D90cb4404124
ISSUER_ETHEREUM_DEFAULT_GAS_LIMIT=600000
ISSUER_ETHEREUM_CONFIRMATION_TIME_OUT=600s
ISSUER_ETHEREUM_CONFIRMATION_BLOCK_COUNT=5
ISSUER_ETHEREUM_RECEIPT_TIMEOUT=600s
ISSUER_ETHEREUM_MIN_GAS_PRICE=0
ISSUER_ETHEREUM_MAX_GAS_PRICE=1000000
ISSUER_ETHEREUM_MAX_GAS_PRICE=2500000
ISSUER_ETHEREUM_RPC_RESPONSE_TIMEOUT=5s
ISSUER_ETHEREUM_WAIT_RECEIPT_CYCLE_TIME=30s
ISSUER_ETHEREUM_WAIT_BLOCK_CYCLE_TIME=30s
ISSUER_ETHEREUM_RESOLVER_PREFIX=polygon:mumbai
ISSUER_ETHEREUM_INTERNAL_TRANSFER_AMOUNT_WEI=1000000000000000000
ISSUER_ETHEREUM_RESOLVER_PREFIX=polygon:amoy
ISSUER_ETHEREUM_TRANSFER_ACCOUNT_KEY_PATH=pbkey

ISSUER_PROVER_SERVER_URL=http://localhost:8002
Expand All @@ -42,8 +41,8 @@ ISSUER_VAULT_USERPASS_AUTH_ENABLED=false
ISSUER_VAULT_USERPASS_AUTH_PASSWORD=password


ISSUER_CREDENTIAL_STATUS_ONCHAIN_TREE_STORE_SUPPORTED_CONTRACT=<supported-onchain-revocation-contract>
ISSUER_CREDENTIAL_STATUS_ONCHAIN_TREE_STORE_SUPPORTED_CONTRACT=0x3d3763eC0a50CE1AdF83d0b5D99FBE0e3fEB43fb
ISSUER_CREDENTIAL_STATUS_RHS_URL=http://localhost:3001
ISSUER_CREDENTIAL_STATUS_PUBLISHING_KEY_PATH=pbkey
ISSUER_CREDENTIAL_STATUS_RHS_MODE=None
ISSUER_CREDENTIAL_STATUS_RHS_CHAIN_ID=<80001 | 137>
ISSUER_CREDENTIAL_STATUS_RHS_CHAIN_ID=<80002 | 80001 | 137>
2 changes: 1 addition & 1 deletion .env-ui.sample
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ISSUER_UI_AUTH_USERNAME=user-ui
ISSUER_UI_AUTH_PASSWORD=password-ui
ISSUER_UI_BLOCK_EXPLORER_URL=https://mumbai.polygonscan.com
ISSUER_UI_BLOCK_EXPLORER_URL=https://www.oklink.com/amoy
ISSUER_UI_BUILD_TAG=
ISSUER_UI_WARNING_MESSAGE=
ISSUER_UI_IPFS_GATEWAY_URL=https://ipfs.io
Expand Down
72 changes: 72 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
# Contributing to Issuer Node

Welcome to Issuer Node! We're thrilled to have you here. Before you get started, please take a moment to review the following guidelines.

### Contents

- [How to Contribute](#how-to-contribute)
- [Getting Started](#getting-started)
- [Issue Tracker Guidelines](#issue-tracker-guidelines)
- [Code Contribution Guidelines](#code-contribution-guidelines)
- [Testing Guidelines](#testing-guidelines)
- [Documentation](#documentation)
- [License Information](#license-information)
- [Contact Information](#contact-information)

## How to Contribute

**Reporting Issues**: If you encounter any bugs or have suggestions for improvements, please open an issue on GitHub. If the bug is a security vulnerability, please report it directly [here](https://support.polygon.technology/support/solutions/categories/82000473421/folders/82000694808).

**Requesting Features**: If you have ideas for new features or enhancements, please submit a feature request on GitHub.

**Submitting Changes**: Fork the repository, make your changes, and submit a pull request. Be sure to follow the guidelines outlined below.

## Getting Started

To set up the project locally, follow the [README](./README.md#quick-start-installation) instructions.

For an advanced setup, visit our [extended documentation](https://devs.polygonid.com/docs/issuer/issuer-configuration).

## Issue Tracker Guidelines

Search for existing issues before creating new ones.

Provide detailed information and steps to reproduce when reporting bugs.

Follow the issue template if available.

## Code Contribution Guidelines
Before submitting a contribution, please consider whether it will be useful to the community and try to minimise breaking changes. In general, a Pull Request with breaking changes is unlikely to be accepted immediately.
Submit concise and focused pull requests with clear descriptions.

Follow the [conventional commits](https://www.conventionalcommits.org/en/v1.0.0/) specification both for the commits and PR names.

Use develop as the base and target branch for pull requests.

Be responsive to feedback and address any review comments promptly.

## Testing Guidelines

Write tests for new features or changes

Ensure all existing tests pass and the linter reports no errors before submitting your changes.

Run tests and linter locally with:
``` bash
make up-test // To start the database used by tests
make tests // run all tests
make lint // run linter
```

## Documentation

Keep documentation up-to-date with any changes or additions.
Help improve existing documentation or contribute new documentation as needed.

## License Information

By contributing to this project, you agree to the terms of licenses [Apache](LICENSE-APACHE) and [Mit](LICENSE-MIT).

## Contact Information

If you have any questions or need assistance, feel free to contact the project maintainers [here](https://support.polygon.technology/support/solutions/categories/82000473421/folders/82000694808).
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.20.5 as base
FROM golang:1.21 as base
ARG VERSION
WORKDIR /service
ENV GOBIN /service/bin
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test-race:

$(BIN)/oapi-codegen: tools.go go.mod go.sum ## install code generator for API files.
go get github.com/deepmap/oapi-codegen/cmd/oapi-codegen
$(GO) install github.com/deepmap/oapi-codegen/cmd/oapi-codegen
$(GO) install github.com/deepmap/oapi-codegen/v2/cmd/oapi-codegen

.PHONY: api
api: $(BIN)/oapi-codegen
Expand Down
14 changes: 10 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Streamline the **Verifiable Credentials issuance** process with the user-friendl
- [Docker Engine](https://docs.docker.com/engine/) `1.27+`
- Makefile toolchain `GNU Make 3.81`
- Publicly accessible URL - The issuer node API must be publicly reachable. Please make sure you properly configure your proxy or use a tool like [Localtunnel](https://theboroer.github.io/localtunnel-www/) for testing purposes.
- Polygon Mumbai or Main RPC - You can get one in any of the providers of this list
- Polygon Amoy or Main RPC - You can get one in any of the providers of this list
- [Chainstack](https://chainstack.com/)
- [Ankr](https://ankr.com/)
- [QuickNode](https://quicknode.com/)
Expand All @@ -54,14 +54,14 @@ Streamline the **Verifiable Credentials issuance** process with the user-friendl
In this section we will cover the installation of the Issuer Node API.

> [!NOTE]
> This Quick Installation Guide is prepared for Polygon Mumbai (Testnet) both for the state contract and issuer dids. If you want to deploy the node with Polygon Main configuration, please visit our [advanced Issuer Node configuration guide](https://devs.polygonid.com/docs/issuer/issuer-configuration/)).
> This Quick Installation Guide is prepared for Polygon Amoy (Testnet) both for the state contract and issuer dids. If you want to deploy the node with Polygon Main configuration, please visit our [advanced Issuer Node configuration guide](https://devs.polygonid.com/docs/issuer/issuer-configuration/)).

#### Deploy Issuer Node Infrastructure

1. Copy the config sample files:

```bash
```shell
cp .env-issuer.sample .env-issuer
cp .env-api.sample .env-api
```
Expand All @@ -84,7 +84,7 @@ In this section we will cover the installation of the Issuer Node API.
make add-vault-token
```

5. Write the private key in the vault. This step is needed in order to be able to transit the issuer's state. To perform that action the given account has to be funded. For Mumbai network you can request some testing Matic [here](https://mumbaifaucet.com/).
5. Write the private key in the vault. This step is needed in order to be able to transit the issuer's state. To perform that action the given account has to be funded. For Amoy network you can request some testing Matic [here](https://www.alchemy.com/faucets/polygon-amoy).
```bash
make private_key=<YOUR_WALLET_PRIVATE_KEY> add-private-key
Expand Down Expand Up @@ -175,6 +175,12 @@ In order to make the UI work, we will need configure some env variables in the `
ISSUER_API_UI_SERVER_URL={PUBLICLY_ACCESSIBLE_URL_POINTING_TO_ISSUER_API_UI_SERVER_PORT}
```
> **_NOTE:_** It is possible to register custom did methods. This field accepts an array of objects in JSON format.</br>
> Example:
```
ISSUER_CUSTOM_DID_METHODS='[{"blockchain":"linea","network":"testnet","networkFlag":"0b01000001","chainID":59140}]'
```
2. Generate Issuer DID:
```bash
Expand Down
8 changes: 2 additions & 6 deletions api/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ info:
Documentation for the Issuer
version: "1"

servers:
- description: Local
url: http://localhost:3001

tags:
- name: Identity
description: Collection of endpoints related to Identity
Expand Down Expand Up @@ -266,7 +262,7 @@ paths:
name: subject
schema:
type: string
description: Filter per subject. Example - did:polygonid:polygon:mumbai:2qE1BZ7gcmEoP2KppvFPCZqyzyb5tK9T6Gec5HFANQ
description: Filter per subject. Example - did:polygonid:polygon:amoy:2qE1BZ7gcmEoP2KppvFPCZqyzyb5tK9T6Gec5HFANQ
- in: query
name: revoked
schema:
Expand Down Expand Up @@ -523,7 +519,7 @@ components:
network:
type: string
x-omitempty: false
example: "mumbai"
example: "amoy"
type:
type: string
x-omitempty: false
Expand Down
10 changes: 10 additions & 0 deletions api/spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</head>
<body>
<rapi-doc
id = "the-doc"
spec-url="/static/docs/api/api.yaml"
theme = "light"
regular-font = "Nunito"
Expand All @@ -21,5 +22,14 @@
>
<!-- <img slot="nav-logo" src="{logo}" style="width:50px; height:50px"/>-->
</rapi-doc>
<script>
window.addEventListener('DOMContentLoaded', () => {
const rapidocEl = document.getElementById('the-doc');
rapidocEl["server-url"] = globalThis.origin;
rapidocEl.addEventListener('spec-loaded', () => {
rapidocEl.setApiServer(globalThis.origin);
});
});
</script>
</body>
</html>
23 changes: 8 additions & 15 deletions api_ui/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,6 @@ info:
Documentation for the Issuer - UI API
version: "1"

servers:
- description: Local
url: http://localhost:3002

tags:
- name: Credential
description: Collection of endpoints related to Credential
Expand Down Expand Up @@ -84,7 +80,7 @@ paths:
description: >
Type:
* `link` - (default value) Return a QR code with a link redirection to the raw content. Easier to scan.
* `raw` - Return the raw QR code. (default value)
* `raw` - Return the raw QR code.
schema:
type: string
enum: [ raw, link ]
Expand Down Expand Up @@ -334,7 +330,7 @@ paths:
name: did
schema:
type: string
example: did:polygonid:polygon:mumbai:2qFpPHotk6oyaX1fcrpQFT4BMnmg8YszUwxYtaoGoe
example: did:polygonid:polygon:amoy:2qFpPHotk6oyaX1fcrpQFT4BMnmg8YszUwxYtaoGoe
- in: query
name: status
schema:
Expand Down Expand Up @@ -503,7 +499,7 @@ paths:
description: >
Type:
* `link` - (default value) Return a QR code with a link redirection to the raw content. Easier to scan.
* `raw` - Return the raw QR code. (default value)
* `raw` - Return the raw QR code.
- $ref: '#/components/parameters/id'

responses:
Expand Down Expand Up @@ -1089,7 +1085,7 @@ components:
example: [ ]
from:
type: string
example: did:polygonid:polygon:mumbai:2qFpPHotk6oyaX1fcrpQFT4BMnmg8YszUwxYtaoGoe
example: did:polygonid:polygon:amoy:2qFpPHotk6oyaX1fcrpQFT4BMnmg8YszUwxYtaoGoe

QrCodeLinkShortResponse:
type: object
Expand Down Expand Up @@ -1287,13 +1283,10 @@ components:
example:
birthday: 19960424
documentType: 2
id: "did:polygonid:polygon:mumbai:2qDDDKmo436EZGCBAvkqZjADYoNRJszkG7UymZeCHQ"
id: "did:polygonid:polygon:amoy:2qDDDKmo436EZGCBAvkqZjADYoNRJszkG7UymZeCHQ"
userID:
type: string
example: did:polygonid:polygon:mumbai:2qFpPHotk6oyaX1fcrpQFT4BMnmg8YszUwxYtaoGoe
schemaTypeDescription:
type: string
example: "KYC Age Credential"
example: did:polygonid:polygon:amoy:2qFpPHotk6oyaX1fcrpQFT4BMnmg8YszUwxYtaoGoe
refreshService:
$ref: '#/components/schemas/RefreshService'
displayMethod:
Expand Down Expand Up @@ -1500,11 +1493,11 @@ components:
userID:
type: string
x-omitempty: false
example: did:polygonid:polygon:mumbai:2qMZrfBsXuGFTwSqkqYki78zF3pe1vtXoqH4yRLsfs
example: did:polygonid:polygon:amoy:2qMZrfBsXuGFTwSqkqYki78zF3pe1vtXoqH4yRLsfs
issuerID:
type: string
x-omitempty: false
example: did:polygonid:polygon:mumbai:2qFpPHotk6oyaX1fcrpQFT4BMnmg8YszUwxYtaoGoe
example: did:polygonid:polygon:amoy:2qFpPHotk6oyaX1fcrpQFT4BMnmg8YszUwxYtaoGoe
createdAt:
$ref: '#/components/schemas/TimeUTC'
credentials:
Expand Down
10 changes: 10 additions & 0 deletions api_ui/spec.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
</head>
<body>
<rapi-doc
id = "the-doc"
spec-url="/static/docs/api_ui/api.yaml"
theme = "light"
regular-font = "Nunito"
Expand All @@ -26,5 +27,14 @@
>
<!-- <img slot="nav-logo" src="{logo}" style="width:50px; height:50px"/>-->
</rapi-doc>
<script>
window.addEventListener('DOMContentLoaded', () => {
const rapidocEl = document.getElementById('the-doc');
rapidocEl["server-url"] = globalThis.origin;
rapidocEl.addEventListener('spec-loaded', () => {
rapidocEl.setApiServer(globalThis.origin);
});
});
</script>
</body>
</html>
15 changes: 11 additions & 4 deletions cmd/issuer_initializer/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,28 @@ const (
)

func main() {
log.Info(context.Background(), "starting issuer node...", "revision", build)
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

log.Info(ctx, "starting issuer node...", "revision", build)
cfg, err := config.Load("")
if err != nil {
log.Error(context.Background(), "cannot load config", "err", err)
log.Error(ctx, "cannot load config", "err", err)
return
}

ctx, cancel := context.WithCancel(log.NewContext(context.Background(), cfg.Log.Level, cfg.Log.Mode, os.Stdout))
defer cancel()
log.Config(cfg.Log.Level, cfg.Log.Mode, os.Stdout)

if err := cfg.Sanitize(ctx); err != nil {
log.Error(ctx, "there are errors in the configuration that prevent server to start", "err", err)
return
}

if err := services.RegisterCustomDIDMethods(ctx, cfg.CustomDIDMethods); err != nil {
log.Error(ctx, "cannot register custom DID methods. Server cannot start", "err", err)
return
}

storage, err := db.NewStorage(cfg.Database.URL)
if err != nil {
log.Error(ctx, "cannot connect to database", "err", err)
Expand Down
9 changes: 6 additions & 3 deletions cmd/migrate/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,15 @@ import (
)

func main() {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

cfg, err := config.Load("")
if err != nil {
log.Error(context.Background(), "cannot load config", "err", err)
log.Error(ctx, "cannot load config", "err", err)
}
// Context with log
ctx := log.NewContext(context.Background(), cfg.Log.Level, cfg.Log.Mode, os.Stdout)

log.Config(cfg.Log.Level, cfg.Log.Mode, os.Stdout)
log.Debug(ctx, "database", "url", cfg.Database.URL)

if err := schema.Migrate(cfg.Database.URL); err != nil {
Expand Down
Loading

0 comments on commit 7e0c661

Please sign in to comment.