Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CI #14

Merged
merged 7 commits into from
May 9, 2024
Merged

CI #14

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 40 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
language: generic

os: linux

addons:
apt:
update: true

jobs:
include:
- name: "Docker and Integration Tests"
os: linux
dist: jammy
services:
- docker
env:
- TAG=`if [ $TRAVIS_BRANCH == "master" ]; then echo -n latest; else echo -n $TRAVIS_BRANCH; fi`
- REST_TAG=$TAG
before_install:
- sudo systemctl stop docker.service && sudo systemctl stop docker.socket
- sudo apt-get install ca-certificates curl
- sudo install -m 0755 -d /etc/apt/keyrings
- sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc
- sudo chmod a+r /etc/apt/keyrings/docker.asc
- |
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
- sudo apt-get update
install:
- sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
before_script:
- echo $DOCKER_PASSWORD | docker login -u $DOCKER_USERNAME --password-stdin
- docker build . -t $TRAVIS_REPO_SLUG:$TAG
after_success:
- |
if [ "$TRAVIS_PULL_REQUEST" = "false" ]; then
docker push $TRAVIS_REPO_SLUG:$TAG
fi
38 changes: 38 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# https://towardsserverless.com/articles/dockerize-nextjs-app

FROM node:18-alpine AS build
# Install dependencies only when needed
# Check https://github.com/nodejs/docker-node/tree/b4117f9333da4138b03a546ec926ef50a31506c3#nodealpine to understand why libc6-compat might be needed.
RUN apk add --no-cache libc6-compat python3
WORKDIR /app
# Copy and install the dependencies for the project
COPY package.json yarn.lock ./
RUN yarn install
# Copy all other project files to working directory
COPY . .
# Run the next build process and generate the artifacts
RUN yarn build

# we are using multi stage build process to keep the image size as small as possible
FROM node:18-alpine
# update and install latest dependencies, add dumb-init package
# add a non root user
RUN apk update && apk upgrade && apk add dumb-init python3

# set work dir as app
WORKDIR /app
# copy the public folder from the project as this is not included in the build process
COPY --from=build /app/public ./public
# copy the standalone folder inside the .next folder generated from the build process
COPY --from=build /app/.next/standalone ./
# copy the static folder inside the .next folder generated from the build process
COPY --from=build /app/.next/static ./.next/static

# expose 3000 on container
EXPOSE 3000

# set app host ,port and node env
ENV HOST=0.0.0.0 PORT=3000 NODE_ENV=production
# start the app with dumb init to spawn the Node.js runtime process
# with signal support
CMD ["dumb-init","node","server.js"]
26 changes: 13 additions & 13 deletions app.config.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
declare global {
namespace NodeJS {
interface ProcessEnv {
JSONRPC_URL: string,
KAP_ADDRESS: string,
NICKNAMES_ADDRESS: string
}
}
}

export type Config = {
jsonRPC: string
systemContracts: Record<string, string>
contracts: Record<string, string>
}

export const config: Config = {
jsonRPC: 'http://localhost:8080/',
systemContracts: {
koin: '15DJN4a8SgrbGhhGksSBASiSYjGnMU8dGL',
vhp: '18tWNU7E4yuQzz7hMVpceb9ixmaWLVyQsr',
pob: '159myq5YUhhoVWu3wsHKHiJYKPKGUrGiyv',
claim: '18zw3ZokdfHtudzaWAUnU4tUvKzKiJeN76',
governance: '19qj51eTbSFJYU7ZagudkpxPgNSzPMfdPX',
nameservice: '19WxDJ9Kcvx4VqQFkpwVmwVEy1hMuwXtQE',
resources: '1HGN9h47CzoFwU2bQZwe6BYoX4TM6pXc4b'
},
jsonRPC: process.env.JSONRPC_URL || 'http://localhost:8080/',
contracts: {
kap: '13tmzDmfqCsbYT26C4CmKxq86d33senqH3',
nicknames:'1KD9Es7LBBjA1FY3ViCgQJ7e6WH1ipKbhz'
kap: process.env.KAP_ADDRESS || '13tmzDmfqCsbYT26C4CmKxq86d33senqH3',
nicknames: process.env.NICKNAMES_ADDRESS || '1KD9Es7LBBjA1FY3ViCgQJ7e6WH1ipKbhz'
}
}
12 changes: 6 additions & 6 deletions app/v1/account/[account]/history/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { AppError, getErrorMessage, handleError } from '@/utils/errors'
import { decodeEvents } from '@/utils/events'
import { decodeOperations } from '@/utils/operations'
import { getProvider } from '@/utils/providers'
import { interfaces } from 'koilib'
import { BlockHeaderJson, EventData, TransactionJson, TransactionReceipt } from 'koilib'
import { NextRequest, NextResponse } from 'next/server'

/**
Expand Down Expand Up @@ -126,9 +126,9 @@ export type BlockReceiptJson = {
network_bandwidth_used?: string
compute_bandwidth_used?: string
state_merkle_root?: string
events?: interfaces.EventData[]
events?: EventData[]
token_events: string[]
transaction_receipts?: interfaces.TransactionReceipt[]
transaction_receipts?: TransactionReceipt[]
logs?: string[]
disk_storage_charged?: string
network_bandwidth_charged?: string
Expand All @@ -147,20 +147,20 @@ export type TransactionReceiptJson = {
network_bandwidth_used: string
compute_bandwidth_used: string
reverted: boolean
events: interfaces.EventData[]
events: EventData[]
token_events: string[]
logs: string[]
amount?: string
}

export type HistoryRecord = {
trx?: {
transaction: interfaces.TransactionJson
transaction: TransactionJson
receipt: TransactionReceiptJson
}

block?: {
header: interfaces.BlockHeaderJson
header: BlockHeaderJson
receipt: BlockReceiptJson
}

Expand Down
14 changes: 7 additions & 7 deletions app/v1/block/[block_id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { interfaces } from 'koilib'
import { BlockJson, EventData, TransactionReceipt } from 'koilib'
import { AppError, handleError } from '@/utils/errors'
import { getProvider } from '@/utils/providers'
import { decodeEvents } from '@/utils/events'
Expand Down Expand Up @@ -127,10 +127,10 @@ export async function GET(request: Request, { params }: { params: { block_id: st
block_items: {
block_id: string
block_height: string
block: interfaces.BlockJson
block: BlockJson
receipt: {
events: interfaces.EventData[]
transaction_receipts: interfaces.TransactionReceipt[]
events: EventData[]
transaction_receipts: TransactionReceipt[]
}
}[]
}>('block_store.get_blocks_by_id', {
Expand All @@ -143,10 +143,10 @@ export async function GET(request: Request, { params }: { params: { block_id: st
block_items: {
block_id: string
block_height: string
block: interfaces.BlockJson
block: BlockJson
receipt: {
events: interfaces.EventData[]
transaction_receipts: interfaces.TransactionReceipt[]
events: EventData[]
transaction_receipts: TransactionReceipt[]
}
}[]
}>('block_store.get_blocks_by_height', {
Expand Down
4 changes: 2 additions & 2 deletions app/v1/contract/[contract_id]/abi/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { getContractId } from '@/utils/contracts'
import { AppError, handleError } from '@/utils/errors'
import { getProvider } from '@/utils/providers'
import { interfaces } from 'koilib'
import { Abi } from 'koilib'
import { convert } from '@roamin/koinos-pb-to-proto'
import protobufjs from 'protobufjs'

Expand Down Expand Up @@ -70,7 +70,7 @@ export async function GET(request: Request, { params }: { params: { contract_id:
throw new AppError(`abi not available for contract ${contract_id}`)
}

const abi: interfaces.Abi = {
const abi: Abi = {
...JSON.parse(response.meta.abi)
}

Expand Down
4 changes: 2 additions & 2 deletions app/v1/decode/events/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppError, getErrorMessage, handleError } from '@/utils/errors'
import { interfaces } from 'koilib'
import { EventData } from 'koilib'
import { NextRequest, NextResponse } from 'next/server'
import { decodeEvents } from '@/utils/events'

Expand Down Expand Up @@ -92,7 +92,7 @@ import { decodeEvents } from '@/utils/events'
export async function POST(request: NextRequest) {
try {
try {
const events = (await request.json()) as interfaces.EventData[]
const events = (await request.json()) as EventData[]
const result = await decodeEvents(events)

return NextResponse.json(result)
Expand Down
4 changes: 2 additions & 2 deletions app/v1/decode/operations/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppError, getErrorMessage, handleError } from '@/utils/errors'
import { interfaces } from 'koilib'
import { OperationJson } from 'koilib'
import { NextRequest, NextResponse } from 'next/server'
import { decodeOperations } from '@/utils/operations'

Expand Down Expand Up @@ -55,7 +55,7 @@ import { decodeOperations } from '@/utils/operations'
export async function POST(request: NextRequest) {
try {
try {
const operations = (await request.json()) as interfaces.OperationJson[]
const operations = (await request.json()) as OperationJson[]
const result = await decodeOperations(operations)

return NextResponse.json(result)
Expand Down
6 changes: 3 additions & 3 deletions app/v1/transaction/[transaction_id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { AppError, handleError } from '@/utils/errors'
import { decodeEvents } from '@/utils/events'
import { decodeOperations } from '@/utils/operations'
import { getProvider } from '@/utils/providers'
import { interfaces } from 'koilib'
import { BlockJson, TransactionReceipt } from 'koilib'

/**
* @swagger
Expand Down Expand Up @@ -173,9 +173,9 @@ export async function GET(request: Request, { params }: { params: { transaction_
block_items: {
block_id: string
block_height: string
block: interfaces.BlockJson
block: BlockJson
receipt: {
transaction_receipts: interfaces.TransactionReceipt[]
transaction_receipts: TransactionReceipt[]
}
}[]
}>('block_store.get_blocks_by_id', {
Expand Down
4 changes: 2 additions & 2 deletions app/v1/transaction/prepare/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppError, getErrorMessage, handleError } from '@/utils/errors'
import { interfaces, Transaction } from 'koilib'
import { Transaction, TransactionJson } from 'koilib'
import { getProvider } from '@/utils/providers'
import { NextRequest, NextResponse } from 'next/server'

Expand Down Expand Up @@ -106,7 +106,7 @@ export async function POST(request: NextRequest) {
try {
try {
const provider = getProvider()
const transaction = (await request.json()) as interfaces.TransactionJson
const transaction = (await request.json()) as TransactionJson

const preparedTransaction = await Transaction.prepareTransaction(transaction, provider)

Expand Down
4 changes: 2 additions & 2 deletions app/v1/transaction/submit/route.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppError, getErrorMessage, handleError } from '@/utils/errors'
import { interfaces } from 'koilib'
import { TransactionJson } from 'koilib'
import { getProvider } from '@/utils/providers'
import { NextRequest, NextResponse } from 'next/server'
import { revalidatePath } from 'next/cache'
Expand Down Expand Up @@ -39,7 +39,7 @@ export async function POST(request: NextRequest) {
// Get the JSON RPC provider
const provider = getProvider()

const transaction = (await request.json()) as interfaces.TransactionJson
const transaction = (await request.json()) as TransactionJson

const { searchParams } = new URL(request.url)
const broadcast = searchParams.get('broadcast') !== 'false'
Expand Down
4 changes: 3 additions & 1 deletion next.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
/** @type {import('next').NextConfig} */
const nextConfig = {}
const nextConfig = {
output: 'standalone'
}

module.exports = nextConfig
Loading