-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Melisa Anabella Rossi
committed
Jul 30, 2024
1 parent
d34c56a
commit 4b30960
Showing
7 changed files
with
116 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { generateLazyValidator, JSONSchema, ValidateFunction } from '../../validation' | ||
import { BaseEvent, Events } from './base' | ||
import { BidEventMetadata } from './blockchain' | ||
|
||
export type BidReceivedEvent = BaseEvent & { | ||
type: Events.Type.MARKETPLACE | ||
subType: Events.SubType.Marketplace.BID_RECEIVED | ||
metadata: BidEventMetadata | ||
} | ||
|
||
export namespace BidReceivedEvent { | ||
export const schema: JSONSchema<BidReceivedEvent> = { | ||
type: 'object', | ||
properties: { | ||
type: { type: 'string', const: Events.Type.MARKETPLACE }, | ||
subType: { type: 'string', const: Events.SubType.Marketplace.BID_RECEIVED }, | ||
key: { type: 'string' }, | ||
timestamp: { type: 'number', minimum: 0 }, | ||
metadata: { | ||
type: 'object', | ||
properties: { | ||
address: { type: 'string' }, | ||
image: { type: 'string' }, | ||
seller: { type: 'string' }, | ||
category: { type: 'string' }, | ||
rarity: { type: 'string', nullable: true }, | ||
link: { type: 'string' }, | ||
nftName: { type: 'string', nullable: true }, | ||
price: { type: 'string' }, | ||
title: { type: 'string' }, | ||
description: { type: 'string' }, | ||
network: { type: 'string' } | ||
}, | ||
required: ['address', 'image', 'seller', 'category', 'link', 'price', 'title', 'network'] | ||
} | ||
}, | ||
required: ['type', 'subType', 'key', 'timestamp', 'metadata'], | ||
additionalProperties: false | ||
} | ||
|
||
export const validate: ValidateFunction<BidReceivedEvent> = generateLazyValidator(schema) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import expect from 'expect' | ||
import { BidReceivedEvent, Events } from '../../../src' | ||
|
||
describe('Marketplace Events tests', () => { | ||
it('BidReceivedEvent static tests must pass', () => { | ||
const event: BidReceivedEvent = { | ||
type: Events.Type.MARKETPLACE, | ||
subType: Events.SubType.Marketplace.BID_RECEIVED, | ||
key: 'key', | ||
timestamp: 1, | ||
metadata: { | ||
address: 'address', | ||
image: 'image', | ||
seller: 'seller', | ||
category: 'category', | ||
rarity: 'rarity', | ||
link: 'link', | ||
nftName: 'nftName', | ||
price: '1', | ||
title: 'title', | ||
description: 'description', | ||
network: 'network' | ||
} | ||
} | ||
|
||
expect(BidReceivedEvent.validate(event)).toEqual(true) | ||
expect(BidReceivedEvent.validate(null)).toEqual(false) | ||
expect(BidReceivedEvent.validate({})).toEqual(false) | ||
}) | ||
}) |