Skip to content
Open
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
1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"locales": "scripts/sort.sh"
},
"dependencies": {
"@apollo/protobufjs": "^1.2.7",
"apollo-server-express": "^2.25.2",
"await-semaphore": "^0.1.3",
"axios": "^0.21.1",
Expand Down
8 changes: 8 additions & 0 deletions backend/src/graphql/enum/AddressType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
export enum AddressType {
NONE = 0, // if no address was found
HUMAN = 1,
PROJECT = 2, // no creations allowed
SUBACCOUNT = 3, // no creations allowed
CRYPTO_ACCOUNT = 4, // user control his keys, no creations
COMMUNITY_ACCOUNT = 5, // community control keys, creations allowed
}
7 changes: 7 additions & 0 deletions backend/src/graphql/enum/CrossGroupType.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export enum CrossGroupType {
LOCAL = 0,
INBOUND = 1,
OUTBOUND = 2,
// for cross group transaction which haven't a direction like group friend update
CROSS = 3,
}
16 changes: 16 additions & 0 deletions backend/src/proto/GradidoCreation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Field, Message } from '@apollo/protobufjs'

import { TimestampSeconds } from './TimestampSeconds'
import { TransferAmount } from './TransferAmount'

// need signature from group admin or
// percent of group users another than the receiver
// https://www.npmjs.com/package/@apollo/protobufjs
// eslint-disable-next-line no-use-before-define
export class GradidoCreation extends Message<GradidoCreation> {
@Field.d(1, TransferAmount)
public recipient: TransferAmount

@Field.d(3, 'TimestampSeconds')
public targetDate: TimestampSeconds
}
31 changes: 31 additions & 0 deletions backend/src/proto/GradidoDeferredTransfer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { Field, Message } from '@apollo/protobufjs'

import { GradidoTransfer } from './GradidoTransfer'
import { Timestamp } from './Timestamp'

// transaction type for chargeable transactions
// for transaction for people which haven't a account already
// consider using a seed number for key pair generation for recipiant
// using seed as redeem key for claiming transaction, technically make a default Transfer transaction from recipiant address
// seed must be long enough to prevent brute force, maybe base64 encoded
// to own account
// https://www.npmjs.com/package/@apollo/protobufjs
// eslint-disable-next-line no-use-before-define
export class GradidoDeferredTransfer extends Message<GradidoDeferredTransfer> {
// amount is amount with decay for time span between transaction was received and timeout
// useable amount can be calculated
// recipient address don't need to be registered in blockchain with register address
@Field.d(1, GradidoTransfer)
public transfer: GradidoTransfer

// if timeout timestamp is reached if it wasn't used, it will be booked back minus decay
// technically on blockchain no additional transaction will be created because how should sign it?
// the decay for amount and the seconds until timeout is lost no matter what happened
// consider is as fee for this service
// rest decay could be transferred back as separate transaction
@Field.d(2, 'Timestamp')
public timeout: Timestamp

// split for n recipient
// max gradido per recipient? or per transaction with cool down?
}
21 changes: 21 additions & 0 deletions backend/src/proto/GradidoTransaction.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { Field, Message } from '@apollo/protobufjs'

import { SignatureMap } from './SignatureMap'

// https://www.npmjs.com/package/@apollo/protobufjs
// eslint-disable-next-line no-use-before-define
export class GradidoTransaction extends Message<GradidoTransaction> {
@Field.d(1, SignatureMap)
public sigMap: SignatureMap

// inspired by Hedera
// bodyBytes are the payload for signature
// bodyBytes are serialized TransactionBody
@Field.d(2, 'bytes')
public bodyBytes: Buffer

// if it is a cross group transaction the parent message
// id from outbound transaction or other by cross
@Field.d(3, 'bytes')
public parentMessageId: Buffer
}
13 changes: 13 additions & 0 deletions backend/src/proto/GradidoTransfer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Field, Message } from '@apollo/protobufjs'

import { TransferAmount } from './TransferAmount'

// https://www.npmjs.com/package/@apollo/protobufjs
// eslint-disable-next-line no-use-before-define
export class GradidoTransfer extends Message<GradidoTransfer> {
@Field.d(1, TransferAmount)
public sender: TransferAmount

@Field.d(2, 'bytes')
public recipient: Buffer
}
15 changes: 15 additions & 0 deletions backend/src/proto/GroupFriendsUpdate.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { Field, Message } from '@apollo/protobufjs'

// connect group together
// only CrossGroupType CROSS (in TransactionBody)
// https://www.npmjs.com/package/@apollo/protobufjs
// eslint-disable-next-line no-use-before-define
export class GroupFriendsUpdate extends Message<GroupFriendsUpdate> {
// if set to true, colors of this both groups are trait as the same
// on creation user get coins still in there color
// on transfer into another group which a connection exist,
// coins will be automatic swapped into user group color coin
// (if fusion between src coin and dst coin is enabled)
@Field.d(1, 'bool')
public colorFusion: boolean
}
19 changes: 19 additions & 0 deletions backend/src/proto/RegisterAddress.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Field, Message } from '@apollo/protobufjs'

import { AddressType } from '@enum/AddressType'

// https://www.npmjs.com/package/@apollo/protobufjs
// eslint-disable-next-line no-use-before-define
export class RegisterAddress extends Message<RegisterAddress> {
@Field.d(1, 'bytes')
public userPubkey: Buffer

@Field.d(2, 'AddressType')
public addressType: AddressType

@Field.d(3, 'bytes')
public nameHash: Buffer

@Field.d(4, 'bytes')
public subaccountPubkey: Buffer
}
10 changes: 10 additions & 0 deletions backend/src/proto/SignatureMap.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { Field, Message } from '@apollo/protobufjs'

import { SignaturePair } from './SignaturePair'

// https://www.npmjs.com/package/@apollo/protobufjs
// eslint-disable-next-line no-use-before-define
export class SignatureMap extends Message<SignatureMap> {
@Field.d(1, SignaturePair, 'repeated')
public sigPair: SignaturePair
}
11 changes: 11 additions & 0 deletions backend/src/proto/SignaturePair.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { Field, Message } from '@apollo/protobufjs'

// https://www.npmjs.com/package/@apollo/protobufjs
// eslint-disable-next-line no-use-before-define
export class SignaturePair extends Message<SignaturePair> {
@Field.d(1, 'bytes')
public pubKey: Buffer

@Field.d(2, 'bytes')
public signature: Buffer
}
13 changes: 13 additions & 0 deletions backend/src/proto/Timestamp.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Field, Message } from '@apollo/protobufjs'

// https://www.npmjs.com/package/@apollo/protobufjs
// eslint-disable-next-line no-use-before-define
export class Timestamp extends Message<Timestamp> {
// Number of complete seconds since the start of the epoch
@Field.d(1, 'int64')
public seconds: number

// Number of nanoseconds since the start of the last second
@Field.d(2, 'int32')
public nanoSeconds: number
}
9 changes: 9 additions & 0 deletions backend/src/proto/TimestampSeconds.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Field, Message } from '@apollo/protobufjs'

// https://www.npmjs.com/package/@apollo/protobufjs
// eslint-disable-next-line no-use-before-define
export class TimestampSeconds extends Message<TimestampSeconds> {
// Number of complete seconds since the start of the epoch
@Field.d(1, 'int64')
public seconds: number
}
33 changes: 33 additions & 0 deletions backend/src/proto/TransactionBody.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import { Field, Message, OneOf } from '@apollo/protobufjs'

import { CrossGroupType } from '@/graphql/enum/CrossGroupType'

import { TimestampSeconds } from './TimestampSeconds'

// https://www.npmjs.com/package/@apollo/protobufjs
// eslint-disable-next-line no-use-before-define
export class TransactionBody extends Message<TransactionBody> {
@Field.d(1, 'string')
public memo: string

@Field.d(2, TimestampSeconds)
public createdAt: TimestampSeconds

@Field.d(3, 'string')
public versionNumber: string

@Field.d(4, CrossGroupType)
public type: CrossGroupType

@Field.d(5, 'string')
public otherGroup: string

@OneOf.d(
'gradidoTransfer',
'gradidoCreation',
'groupFriendsUpdate',
'registerAddress',
'gradidoDeferredTransfer',
)
public data: string
}
14 changes: 14 additions & 0 deletions backend/src/proto/TransferAmount.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Field, Message } from '@apollo/protobufjs'

// https://www.npmjs.com/package/@apollo/protobufjs
// eslint-disable-next-line no-use-before-define
export class TransferAmount extends Message<TransferAmount> {
@Field.d(1, 'bytes')
public pubkey: Buffer

@Field.d(2, 'string')
public amount: string

@Field.d(3, 'string')
public groupId: string
}
1 change: 1 addition & 0 deletions backend/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
"@enum/*": ["src/graphql/enum/*"],
"@model/*": ["src/graphql/model/*"],
"@union/*": ["src/graphql/union/*"],
"@proto/*": ["src/proto/*"],
"@repository/*": ["src/typeorm/repository/*"],
"@test/*": ["test/*"],
/* external */
Expand Down
20 changes: 19 additions & 1 deletion backend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,24 @@
"@types/node" "^10.1.0"
long "^4.0.0"

"@apollo/protobufjs@^1.2.7":
version "1.2.7"
resolved "https://registry.yarnpkg.com/@apollo/protobufjs/-/protobufjs-1.2.7.tgz#3a8675512817e4a046a897e5f4f16415f16a7d8a"
integrity sha512-Lahx5zntHPZia35myYDBRuF58tlwPskwHc5CWBZC/4bMKB6siTBWwtMrkqXcsNwQiFSzSx5hKdRPUmemrEp3Gg==
dependencies:
"@protobufjs/aspromise" "^1.1.2"
"@protobufjs/base64" "^1.1.2"
"@protobufjs/codegen" "^2.0.4"
"@protobufjs/eventemitter" "^1.1.0"
"@protobufjs/fetch" "^1.1.0"
"@protobufjs/float" "^1.0.2"
"@protobufjs/inquire" "^1.1.0"
"@protobufjs/path" "^1.1.2"
"@protobufjs/pool" "^1.1.0"
"@protobufjs/utf8" "^1.1.0"
"@types/long" "^4.0.0"
long "^4.0.0"

"@apollographql/apollo-tools@^0.5.0":
version "0.5.1"
resolved "https://registry.yarnpkg.com/@apollographql/apollo-tools/-/apollo-tools-0.5.1.tgz#f0baef739ff7e2fafcb8b98ad29f6ac817e53e32"
Expand Down Expand Up @@ -3679,7 +3697,7 @@ graceful-fs@^4.1.6, graceful-fs@^4.2.0:
integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA==

"gradido-database@file:../database":
version "1.22.0"
version "1.22.3"
dependencies:
"@types/uuid" "^8.3.4"
cross-env "^7.0.3"
Expand Down