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

Feat/transaction split #23

Merged
merged 43 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
13eb8c5
fix(general): general
guimroque Sep 21, 2023
4747e9a
feat(assets): include new columns on entity to monitore especif asset…
guimroque Sep 22, 2023
9dad0e8
fix(general): general
guimroque Sep 22, 2023
22a9933
fix(assets): general
guimroque Sep 22, 2023
a44fc5a
feat(transaction): send transaction to chain network and recived and …
guimroque Sep 27, 2023
d3b589c
chore(status-transaction): status
guimroque Sep 27, 2023
98ec3e5
fix(fuelsts): lock version fuelsts
guimroque Sep 27, 2023
f029f7f
fix(transaction): make resume on creation
guimroque Sep 27, 2023
3e8b16c
fix(transaction-module): resume transaction
guimroque Sep 27, 2023
7af8aee
feat(transaction): update transaction on process
guimroque Sep 29, 2023
e10f45d
feat(transactions): monitore assets reserved to predicate
guimroque Sep 29, 2023
45cb2f5
Merge branch 'main' into FEAT/transaction-split
guimroque Oct 16, 2023
8851e53
fix(merge): conflicts resolution and auth implement test
guimroque Oct 19, 2023
cc6bc66
fix(wip): fixed to send transactions
guimroque Oct 21, 2023
f0f2af1
chore(): remove unsed items
guimroque Oct 23, 2023
460412c
fix(transactions-module): remove id on chain and find by predicate id…
guimroque Oct 23, 2023
6f50e11
fix(vault-module): allow predicate creation without description
guimroque Oct 23, 2023
055517e
fix(predicate-module): valid and return predicate existing on creation
guimroque Oct 24, 2023
8da6c50
fix(fuelsts): using version of bsafe package
guimroque Oct 26, 2023
364973b
feat(socket): server
guimroque Nov 3, 2023
15f64bf
feat(socket): create a defult channels and middleware to connection
guimroque Nov 6, 2023
94bcb4d
Merge branch 'FEAT/transaction-split' into FEAT/socket-server
guimroque Nov 6, 2023
f4b8da0
feat(wip): dapps table module
guimroque Nov 6, 2023
214f792
Merge branch 'FEAT/transaction-split' into FEAT/dapps
guimroque Nov 6, 2023
2a6c986
feat(dapp): create endpoints and operations to dApps manager
guimroque Nov 6, 2023
b53836c
fix(dapp): clousure validation
guimroque Nov 6, 2023
988902b
Merge branch 'FEAT/dapps' of github.com:infinitybase/bsafe-api into F…
guimroque Nov 6, 2023
e106059
feat(socket): connect proxess
guimroque Nov 7, 2023
db9ddbf
fix: check has predicate id in query strings and allow utxo empty string
luisburigo Nov 8, 2023
cce5c36
feat(socket): transaction confirm event
guimroque Nov 8, 2023
49c50e3
Merge branch 'FEAT/transaction-split' into FEAT/dapps
guimroque Nov 8, 2023
0869c97
Merge pull request #34 from infinitybase/FEAT/socket-server
guimroque Nov 8, 2023
e58c671
Merge branch 'FEAT/transaction-split' into FEAT/dapps
guimroque Nov 8, 2023
d9f1f32
Merge pull request #35 from infinitybase/FEAT/dapps
guimroque Nov 8, 2023
19e3373
wip(socket): dapp management and connect request
guimroque Nov 10, 2023
5eb93c1
chore: WIP send transaction to chain in API
luisburigo Nov 10, 2023
1eb35a5
Merge remote-tracking branch 'origin/FEAT/transaction-split' into FEA…
luisburigo Nov 10, 2023
1e4c85d
wip(socket): transaction pop sender
guimroque Nov 11, 2023
295dd6e
Merge branch 'FEAT/transaction-split' of github.com:infinitybase/bsaf…
guimroque Nov 11, 2023
9b40008
chore(env): localend
guimroque Nov 13, 2023
8cae10a
fix(transaction): clear pagination on find predicate by address
luisburigo Nov 14, 2023
6771793
fix(txdata): return tx_data to db
guimroque Nov 16, 2023
cb09f45
Merge branch 'FEAT/transaction-split' of github.com:infinitybase/bsaf…
guimroque Nov 16, 2023
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
23 changes: 23 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@


# Database
DATABASE_HOST = 127.0.0.1
DATABASE_PORT = 5432
DATABASE_USERNAME = postgres
DATABASE_PASSWORD = postgres
DATABASE_NAME = postgres


DATABASE_PORT_TEST = 5432
# APP
API_PORT=3333
APP_NAME=bsafe-api
# ADMIN USER
APP_ADMIN_EMAIL=admin_user_email
APP_ADMIN_PASSWORD=admin_user_password
# TOKENS
ACCESS_TOKEN_SECRET=access_token_secret
REFRESH_TOKEN_SECRET=refresh_token_secret
# AWS
UI_URL=https://app.bsafe.pro

2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ DATABASE_PASSWORD = database_password
DATABASE_NAME = database_name

# App
API_PORT = 80
API_PORT = 3333

# Admin user
APP_ADMIN_EMAIL = admin_user_email
Expand Down
27 changes: 21 additions & 6 deletions docker/database/.env.dev
Original file line number Diff line number Diff line change
@@ -1,6 +1,21 @@
DATABASE_HOST=127.0.0.1
DATABASE_PORT=5432
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=postgres
DATABASE_NAME=postgres
NODE_ENV=development
# Database
DATABASE_HOST = 127.0.0.1
DATABASE_PORT = 5432
DATABASE_USERNAME = postgres
DATABASE_PASSWORD = postgres
DATABASE_NAME = postgres

# App
API_PORT = 3333

# Admin user
APP_ADMIN_EMAIL = [email protected]
APP_ADMIN_PASSWORD = admin_user_password

# Tokens
ACCESS_TOKEN_SECRET = access_token_secret
REFRESH_TOKEN_SECRET = refresh_token_secret
# Time should be in minutes
TOKEN_EXPIRATION_TIME = 15
UI_URL=http://localhost:5173
# UI_URL=https://app.bsafe.pro
3 changes: 2 additions & 1 deletion docker/database/.env.test
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ DATABASE_PORT=5432
DATABASE_USERNAME=postgres
DATABASE_PASSWORD=postgres
DATABASE_NAME=postgres
NODE_ENV=test
NODE_ENV=test
UI_URL=https://app.bsafe.pro
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"main": "src/index.ts",
"license": "MIT",
"scripts": {
"dev": "ts-node-dev --respawn --transpile-only -r tsconfig-paths/register -r dotenv/config src/server/index.ts",
"dev": "NODE_ENV=development ts-node-dev --respawn --transpile-only -r tsconfig-paths/register -r dotenv/config src/server/index.ts",
"test": "chmod +x ./scripts/init_test.sh && ./scripts/init_test.sh",
"start": "ts-node -r dotenv/config ./build/index.js",
"build": "tsc --project . && tscpaths -p tsconfig.json -s ./src -o ./build",
Expand All @@ -22,20 +22,21 @@
"axios": "1.5.1",
"bcrypt": "5.1.0",
"body-parser": "1.20.2",
"bsafe": "../bsafe/",
"class-validator": "0.14.0",
"cookie-parser": "1.4.6",
"cors": "2.8.5",
"date-fns": "2.30.0",
"dotenv": "8.2.0",
"express": "4.17.1",
"express-joi-validation": "5.0.0",
"fuels": "0.55.0",
"joi": "17.4.0",
"jsonwebtoken": "9.0.1",
"morgan": "1.10.0",
"patch-package": "8.0.0",
"pg": "8.5.1",
"reflect-metadata": "0.1.13",
"socket.io": "4.7.2",
"ts-node": "^10.9.1",
"tsconfig-paths": "^3.9.0",
"typeorm": "^0.2.29",
Expand Down
5 changes: 2 additions & 3 deletions scripts/init_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
yarn database:test

#give a timeout and run migrations
sleep 5 && yarn migration:run
sleep 5

#run jest tests
node --experimental-vm-modules ./node_modules/jest/bin/jest.js

NODE_ENV=test node --experimental-vm-modules ./node_modules/jest/bin/jest.js
65 changes: 0 additions & 65 deletions src/app.ts

This file was deleted.

17 changes: 4 additions & 13 deletions src/config/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,11 @@ const {
DATABASE_NAME,
DATABASE_PORT,
NODE_ENV,
DATABASE_PORT_TEST,
} = process.env;

console.log({
DATABASE_PASSWORD,
DATABASE_HOST,
DATABASE_URL,
DATABASE_USERNAME,
DATABASE_NAME,
DATABASE_PORT,
NODE_ENV,
});

const [host, port] = String(DATABASE_URL).split(':');
const environment = NODE_ENV;
const environment: string = NODE_ENV;
const entitiesDir = path.resolve(__dirname, '..', 'models', '**', '*{.ts,.js}');
export const migrationsDir = path.resolve(
__dirname,
Expand Down Expand Up @@ -59,13 +50,13 @@ const development: ConnectionOptions = {
migrationsDir: './src/database/migrations/',
},
synchronize: false,
migrationsRun: false,
migrationsRun: true,
};

const test: ConnectionOptions = {
type: 'postgres',
host: DATABASE_HOST,
port: Number(port),
port: Number(process.env.DATABASE_PORT_TEST),
username: DATABASE_USERNAME,
password: DATABASE_PASSWORD,
database: DATABASE_NAME,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class createTablePredicates1694193586666 implements MigrationInterface {
{
name: 'description',
type: 'varchar',
isNullable: true,
},
{
name: 'minSigners',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export class createTableTransactions1694536141266 implements MigrationInterface
default: `uuid_generate_v4()`,
},
{
name: 'predicateAdress',
name: 'predicate_address',
type: 'varchar',
},
{
Expand All @@ -28,12 +28,12 @@ export class createTableTransactions1694536141266 implements MigrationInterface
type: 'varchar',
},
{
name: 'txData',
name: 'hash',
type: 'varchar',
},
{
name: 'hash',
type: 'varchar',
name: 'tx_data',
type: 'jsonb',
},
{
name: 'status',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ import { MigrationInterface, QueryRunner, Table } from 'typeorm';

export class createTableWitnesses1694543036941 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE EXTENSION IF NOT EXISTS "uuid-ossp"`);
await queryRunner.createTable(
new Table({
name: 'witnesses',
columns: [
{
name: 'id',
type: 'integer',
unsigned: true,
type: 'uuid',
isPrimary: true,
isGenerated: true,
generationStrategy: 'increment',
isUnique: true,
generationStrategy: 'uuid',
default: `uuid_generate_v4()`,
},
{
name: 'signature',
Expand Down
15 changes: 10 additions & 5 deletions src/database/migrations/1694545394302-create-table-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,21 @@ import { MigrationInterface, QueryRunner, Table } from 'typeorm';

export class createTableAssets1694545394302 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.query(`CREATE EXTENSION IF NOT EXISTS "uuid-ossp"`);
await queryRunner.createTable(
new Table({
name: 'assets',
columns: [
{
name: 'id',
type: 'integer',
unsigned: true,
type: 'uuid',
isPrimary: true,
isGenerated: true,
generationStrategy: 'increment',
isUnique: true,
generationStrategy: 'uuid',
default: `uuid_generate_v4()`,
},
{
name: 'assetID',
name: 'assetId',
type: 'varchar',
},
{
Expand All @@ -30,6 +31,10 @@ export class createTableAssets1694545394302 implements MigrationInterface {
name: 'amount',
type: 'varchar',
},
{
name: 'utxo',
type: 'varchar',
},
{
name: 'created_at',
type: 'timestamp',
Expand Down
65 changes: 65 additions & 0 deletions src/database/migrations/1699272433660-add-column-dapps.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { MigrationInterface, QueryRunner, Table } from 'typeorm';

export class addColumnDapps1699272433660 implements MigrationInterface {
public async up(queryRunner: QueryRunner): Promise<void> {
await queryRunner.createTable(
new Table({
name: 'dapp',
columns: [
{
name: 'id',
type: 'uuid',
isPrimary: true,
isUnique: true,
generationStrategy: 'uuid',
default: `uuid_generate_v4()`,
},
{
name: 'session_id',
type: 'varchar',
},
{
name: 'origin',
type: 'varchar',
},
{
name: 'current',
type: 'uuid',
},
{
name: 'name',
type: 'varchar',
isNullable: true,
},
{
name: 'created_at',
type: 'timestamp',
},
{
name: 'updated_at',
type: 'timestamp',
isNullable: true,
},
{
name: 'deleted_at',
type: 'timestamp',
isNullable: true,
},
],
foreignKeys: [
{
name: 'FK-transaction-witnesses',
columnNames: ['current'],
referencedColumnNames: ['id'],
referencedTableName: 'predicates',
onDelete: 'CASCADE',
},
],
}),
);
}

public async down(queryRunner: QueryRunner): Promise<void> {
await queryRunner.dropTable('dapps');
}
}
Loading