Skip to content

Commit

Permalink
Merge pull request #40 from kaleido-io/tokenevent
Browse files Browse the repository at this point in the history
Clean up blockchain info passed back to FireFly
  • Loading branch information
dechdev authored Apr 7, 2022
2 parents 627c9ea + cee58c4 commit 6da3a75
Show file tree
Hide file tree
Showing 7 changed files with 298 additions and 298 deletions.
6 changes: 2 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@
"start:prod": "node dist/src/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\"",
"lint:fix": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"test": "jest",
"test:watch": "jest --watch",
"test:cov": "jest --coverage",
"test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand",
"test": "npm run test:unit && npm run test:e2e",
"test:unit": "jest",
"test:e2e": "jest --config ./test/jest-e2e.json"
},
"dependencies": {
Expand Down
133 changes: 60 additions & 73 deletions src/tokens/tokens.interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,41 +114,41 @@ export class TokenPoolConfig {

@ApiProperty()
@IsOptional()
blockNumber?: number;
blockNumber?: string;

@ApiProperty()
@IsOptional()
withData?: boolean;
}

export class TokenPool {
@ApiProperty({ enum: TokenType })
@IsEnum(TokenType)
type: TokenType;

@ApiProperty()
@IsNotEmpty()
name: string;
signer: string;

@ApiProperty()
@IsNotEmpty()
signer: string;
name: string;

@ApiProperty()
@IsOptional()
symbol?: string;

@ApiProperty({ enum: TokenType })
@IsEnum(TokenType)
type: TokenType;

@ApiProperty()
@IsDefined()
config: TokenPoolConfig;
@ApiProperty({ description: requestIdDescription })
@IsOptional()
requestId?: string;

@ApiProperty()
@IsOptional()
data?: string;

@ApiProperty({ description: requestIdDescription })
@IsOptional()
requestId?: string;
@ApiProperty()
@IsDefined()
config: TokenPoolConfig;
}

export class TokenApprovalConfig {
Expand Down Expand Up @@ -191,44 +191,64 @@ export class TokenApproval {
config?: TokenApprovalConfig;
}

export class BlockchainTransaction {
export class BlockLocator {
@ApiProperty()
@IsNotEmpty()
blockNumber: string;
}

export class BlockchainInfo extends BlockLocator {
@ApiProperty()
@IsNotEmpty()
logIndex: string;
transactionIndex: string;

@ApiProperty()
@IsNotEmpty()
transactionHash: string;

@ApiProperty()
@IsNotEmpty()
transactionIndex: string;
logIndex: string;

@ApiProperty()
@IsOptional()
signature: string;

@ApiProperty()
@IsOptional()
address: string;
}

export class BlockchainEvent {
@ApiProperty()
id: string;

@ApiProperty()
name: string;

@ApiProperty()
output: any;

@ApiProperty()
info: BlockchainInfo;

@ApiProperty()
location: string;

@ApiProperty()
signature: string;

@ApiProperty()
timestamp: string;
}

export class TokenPoolActivate {
@ApiProperty()
@IsNotEmpty()
poolId: string;

@ApiProperty()
@IsOptional()
poolConfig?: TokenPoolConfig;
config?: TokenPoolConfig;

@ApiProperty()
@IsOptional()
transaction?: BlockchainTransaction;
locator?: BlockLocator;

@ApiProperty({ description: requestIdDescription })
@IsOptional()
Expand All @@ -237,36 +257,36 @@ export class TokenPoolActivate {

export class TokenTransfer {
@ApiProperty()
@IsOptional()
amount?: string;
@IsNotEmpty()
poolId: string;

@ApiProperty()
@IsOptional()
tokenIndex?: string;

@ApiProperty()
@IsNotEmpty()
from: string;

@ApiProperty()
@IsNotEmpty()
signer: string;

@ApiProperty()
@IsNotEmpty()
poolId: string;
from: string;

@ApiProperty()
@IsNotEmpty()
to: string;

@ApiProperty()
@IsOptional()
data?: string;
amount?: string;

@ApiProperty({ description: requestIdDescription })
@IsOptional()
requestId?: string;

@ApiProperty()
@IsOptional()
data?: string;
}

export class TokenMint extends OmitType(TokenTransfer, ['from']) {}
Expand All @@ -275,32 +295,17 @@ export class TokenBurn extends OmitType(TokenTransfer, ['to']) {}
// Websocket notifications

class tokenEventBase {
@ApiProperty()
data?: string;

@ApiProperty()
signer?: string;

@ApiProperty()
rawOutput?: any;

@ApiProperty()
poolId: string;

@ApiProperty()
timestamp: string;

@ApiProperty()
transaction?: BlockchainTransaction;

@ApiProperty()
type: TokenType;
signer?: string;

@ApiProperty()
location?: string;
data?: string;

@ApiProperty()
signature?: string;
blockchain?: BlockchainEvent;
}

export class TokenPoolEventInfo {
Expand All @@ -315,6 +320,9 @@ export class TokenPoolEventInfo {
}

export class TokenPoolEvent extends tokenEventBase {
@ApiProperty()
type: TokenType;

@ApiProperty()
standard: string;

Expand All @@ -332,6 +340,9 @@ export class TokenTransferEvent extends tokenEventBase {
@ApiProperty()
tokenIndex?: string;

@ApiProperty()
uri?: string;

@ApiProperty()
from: string;

Expand All @@ -340,9 +351,6 @@ export class TokenTransferEvent extends tokenEventBase {

@ApiProperty()
amount: string;

@ApiProperty()
uri?: string;
}

export class TokenMintEvent extends OmitType(TokenTransferEvent, ['from']) {}
Expand All @@ -356,27 +364,6 @@ export class TokenApprovalEvent extends tokenEventBase {
approved: boolean;
}

export interface TransactionDetails {
blockHash: string;
blockNumber: string;
blockNumberHex: string;
from: string;
to: string;
gas: string;
gasHex: string;
gasPrice: string;
gasPriceHex: string;
hash: string;
nonce: string;
nonceHex: string;
transactionIndex: string;
transactionIndexHex: string;
value: string;
valueHex: string;
input: string;
inputArgs: any;
}

export interface IAbiInput {
indexed?: boolean;
internalType: string;
Expand Down
10 changes: 0 additions & 10 deletions src/tokens/tokens.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,6 @@ describe('TokensService', () => {
data: `{"tx":${TX}}`,
poolId: ERC20_NO_DATA_POOL_ID,
standard: 'ERC20',
timestamp: expect.any(String),
type: 'fungible',
symbol: SYMBOL,
info: {
Expand All @@ -245,7 +244,6 @@ describe('TokensService', () => {
const response: TokenPoolEvent = {
poolId: ERC20_NO_DATA_POOL_ID,
standard: 'ERC20',
timestamp: expect.any(String),
type: TokenType.FUNGIBLE,
symbol: SYMBOL,
info: {
Expand Down Expand Up @@ -391,7 +389,6 @@ describe('TokensService', () => {
data: `{"tx":${TX}}`,
poolId: ERC20_WITH_DATA_POOL_ID,
standard: 'ERC20',
timestamp: expect.any(String),
type: 'fungible',
symbol: SYMBOL,
info: {
Expand Down Expand Up @@ -421,7 +418,6 @@ describe('TokensService', () => {
data: `{"tx":${TX}}`,
poolId: ERC20_WITH_DATA_POOL_ID,
standard: 'ERC20',
timestamp: expect.any(String),
type: 'fungible',
symbol: SYMBOL,
info: {
Expand All @@ -446,7 +442,6 @@ describe('TokensService', () => {
const response: TokenPoolEvent = {
poolId: ERC20_WITH_DATA_POOL_ID,
standard: 'ERC20',
timestamp: expect.any(String),
type: TokenType.FUNGIBLE,
symbol: SYMBOL,
info: {
Expand Down Expand Up @@ -588,7 +583,6 @@ describe('TokensService', () => {
data: `{"tx":${TX}}`,
poolId: ERC721_NO_DATA_POOL_ID,
standard: 'ERC721',
timestamp: expect.any(String),
type: 'nonfungible',
symbol: SYMBOL,
info: {
Expand All @@ -613,7 +607,6 @@ describe('TokensService', () => {
const response: TokenPoolEvent = {
poolId: ERC721_NO_DATA_POOL_ID,
standard: 'ERC721',
timestamp: expect.any(String),
type: TokenType.NONFUNGIBLE,
symbol: SYMBOL,
info: {
Expand Down Expand Up @@ -772,7 +765,6 @@ describe('TokensService', () => {
data: `{"tx":${TX}}`,
poolId: ERC721_WITH_DATA_POOL_ID,
standard: 'ERC721',
timestamp: expect.any(String),
type: 'nonfungible',
symbol: SYMBOL,
info: {
Expand Down Expand Up @@ -802,7 +794,6 @@ describe('TokensService', () => {
data: `{"tx":${TX}}`,
poolId: ERC721_WITH_DATA_POOL_ID,
standard: 'ERC721',
timestamp: expect.any(String),
type: 'nonfungible',
symbol: SYMBOL,
info: {
Expand All @@ -827,7 +818,6 @@ describe('TokensService', () => {
const response: TokenPoolEvent = {
poolId: ERC721_WITH_DATA_POOL_ID,
standard: 'ERC721',
timestamp: expect.any(String),
type: TokenType.NONFUNGIBLE,
symbol: SYMBOL,
info: {
Expand Down
Loading

0 comments on commit 6da3a75

Please sign in to comment.