Skip to content

Commit

Permalink
Merge pull request #105 from Tonomy-Foundation/testnet
Browse files Browse the repository at this point in the history
Release: CICD for testnet and branches, using Tonomy contract
  • Loading branch information
theblockstalk authored Apr 22, 2024
2 parents 6aa405d + dc6885c commit a83aa46
Show file tree
Hide file tree
Showing 13 changed files with 77 additions and 36 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/check-sdk-version.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
name: Test - Check SDK version

on: pull_request
on:
pull_request:
branches:
- master
- testnet
- development

jobs:
check-sdk-version:
Expand Down
File renamed without changes.
34 changes: 34 additions & 0 deletions .github/workflows/deploy-testnet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Deploy - Testnet

on:
pull_request:
types:
- closed
branches:
- testnet

jobs:
build:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
target: tonomy_communication_base
push: true
tags: tonomy/communication:rc
6 changes: 3 additions & 3 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
name: Test - Pull Requests (not to master)
name: Test - Pull Requests

on:
pull_request:
branches-ignore:
- master
branches:
- development

jobs:
tests:
Expand Down
8 changes: 1 addition & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ yarn run updateSdkVersion master
## Environment variables and configuration

`NODE_ENV` - Determines which config file in `./src/config` to use
`CREATE_ACCOUNT_PRIVATE_KEY` - The private key used to sign the transaction to create a new account
`TONOMY_OPS_PRIVATE_KEY` - The private key used to sign the transaction to create a new account
`HCAPTCHA_SECRET` - The hCaptcha account secret key

## Test
Expand Down Expand Up @@ -68,9 +68,3 @@ Build command: `yarn -v && yarn install && yarn run build`
- NOTE: we need to run `yarn install` again so that we install with `[email protected]` which we force via`.yarnrc.yml` and `.yarn/releases/yarn-3.1.1.cjs`. See <https://github.com/Tonomy-Foundation/Tonomy-Communication/issues/85> for more details.

Run command: `yarn run start:prod`

Environment variables

- NODE_ENV
- CREATE_ACCOUNT_PRIVATE_KEY
- HCAPTCHA_SECRET
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@nestjs/platform-socket.io": "^10.2.3",
"@nestjs/swagger": "^7.1.10",
"@nestjs/websockets": "^10.2.3",
"@tonomy/tonomy-id-sdk": "0.18.0",
"@tonomy/tonomy-id-sdk": "0.19.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"hcaptcha": "^0.1.1",
Expand Down
6 changes: 3 additions & 3 deletions src/accounts/accounts.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { Name, PrivateKey } from '@wharfkit/antelope';
import settings from '../settings';
import { PushTransactionResponse } from '@wharfkit/antelope/src/api/v1/types';
import {
IDContract,
TonomyContract,
EosioUtil,
AntelopePushTransactionError,
} from '@tonomy/tonomy-id-sdk';
import { verify } from 'hcaptcha';

const idContract = IDContract.Instance;
const tonomyContract = TonomyContract.Instance;

@Injectable()
export class AccountsService {
Expand Down Expand Up @@ -69,7 +69,7 @@ export class AccountsService {
let res: PushTransactionResponse;

try {
res = await idContract.newperson(
res = await tonomyContract.newperson(
createAccountRequest.usernameHash,
createAccountRequest.publicKey,
createAccountRequest.salt,
Expand Down
4 changes: 0 additions & 4 deletions src/config/config.demo.json

This file was deleted.

4 changes: 4 additions & 0 deletions src/config/config.production.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"blockchainUrl": "https://blockchain-api.pangea.web4.world",
"loggerLevel": "info"
}
4 changes: 4 additions & 0 deletions src/config/config.testnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"blockchainUrl": "https://blockchain-api-testnet.pangea.web4.world",
"loggerLevel": "info"
}
26 changes: 14 additions & 12 deletions src/settings.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import * as configDefault from './config/config.json';
import * as configStaging from './config/config.staging.json';
import * as configDemo from './config/config.demo.json';
import { EosioUtil } from '@tonomy/tonomy-id-sdk';
import * as configTestnet from './config/config.testnet.json';
import * as configProduction from './config/config.production.json';

const env = process.env.NODE_ENV || 'development';

Expand Down Expand Up @@ -57,11 +57,13 @@ switch (env) {
case 'staging':
config = configStaging as FixLoggerLevelEnumType<typeof configStaging>;
break;
case 'demo':
config = configDemo as FixLoggerLevelEnumType<typeof configDemo>;
case 'testnet':
config = configTestnet as FixLoggerLevelEnumType<typeof configTestnet>;
break;
case 'production':
throw new Error('Production config not implemented yet');
config = configProduction as FixLoggerLevelEnumType<
typeof configProduction
>;
default:
throw new Error('Unknown environment: ' + env);
}
Expand All @@ -77,19 +79,19 @@ if (process.env.BLOCKCHAIN_URL) {
if (env !== 'test') console.log('settings', settings);

settings.secrets = {
createAccountPrivateKey: EosioUtil.defaultAntelopePrivateKey.toString(),
createAccountPrivateKey:
'PVT_K1_24kG9VcMk3VkkgY4hh42X262AWV18YcPjBTd2Hox4YWoP8vRTU',
hCaptchaSecret: '0x0000000000000000000000000000000000000000',
};

if (process.env.CREATE_ACCOUNT_PRIVATE_KEY) {
console.log('Using CREATE_ACCOUNT_PRIVATE_KEY from env');
settings.secrets.createAccountPrivateKey =
process.env.CREATE_ACCOUNT_PRIVATE_KEY;
}

if (process.env.HCAPTCHA_SECRET) {
console.log('Using HCAPTCHA_SECRET from env');
settings.secrets.hCaptchaSecret = process.env.HCAPTCHA_SECRET;
}

if (process.env.TONOMY_OPS_PRIVATE_KEY) {
console.log('Using TONOMY_OPS_PRIVATE_KEY from env');
settings.secrets.createAccountPrivateKey = process.env.TONOMY_OPS_PRIVATE_KEY;
}

export default settings;
2 changes: 2 additions & 0 deletions update_sdk_version.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ set +e
# Get the latest version of the SDK for the correct npmjs tag based on branch
if [ "${BRANCH}" == "master" ]; then
VERSION=$(npm view @tonomy/tonomy-id-sdk version)
elif [ "${BRANCH}" == "testnet" ]; then
VERSION=$(npm view @tonomy/tonomy-id-sdk@testnet version)
elif [ "${BRANCH}" == "development" ]; then
VERSION=$(npm view @tonomy/tonomy-id-sdk@development version)
else
Expand Down
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1576,9 +1576,9 @@ __metadata:
languageName: node
linkType: hard

"@tonomy/tonomy-id-sdk@npm:0.18.0":
version: 0.18.0
resolution: "@tonomy/tonomy-id-sdk@npm:0.18.0"
"@tonomy/tonomy-id-sdk@npm:0.19.0":
version: 0.19.0
resolution: "@tonomy/tonomy-id-sdk@npm:0.19.0"
dependencies:
"@consento/sync-randombytes": ^1.0.5
"@tonomy/antelope-did": ^0.1.5
Expand All @@ -1593,7 +1593,7 @@ __metadata:
elliptic: ^6.5.4
socket.io-client: ^4.5.4
universal-base64url: ^1.1.0
checksum: 7d307eb4c38ba503608f4d15c83488572c52c03030b108a71460ffa0649b8f0bcd34b65b723873393cea177b618320e0c7ca2c0e115bf08dbc86581b1acf3d7e
checksum: 05bf0812a27d425f136ace2c27ec98f501a84d0004923047dd1c05d21fd5c1ae8068654ce157b4967f34453d5634af88b4d70fafc656659bc15be746a064ecef
languageName: node
linkType: hard

Expand Down Expand Up @@ -7713,7 +7713,7 @@ __metadata:
"@nestjs/swagger": ^7.1.10
"@nestjs/testing": ^10.2.3
"@nestjs/websockets": ^10.2.3
"@tonomy/tonomy-id-sdk": 0.18.0
"@tonomy/tonomy-id-sdk": 0.19.0
"@types/express": ^4.17.13
"@types/jest": 29.2.4
"@types/node": 18.11.18
Expand Down

0 comments on commit a83aa46

Please sign in to comment.