mirror of
https://github.com/placeholder-soft/sui-data-sync.git
synced 2026-04-30 05:26:17 +08:00
refactor
This commit is contained in:
33
src/index.ts
33
src/index.ts
@@ -1,2 +1,35 @@
|
|||||||
|
import { NestFactory } from '@nestjs/core';
|
||||||
|
import {
|
||||||
|
DataSyncModule,
|
||||||
|
DataSyncService,
|
||||||
|
EventSyncSchema,
|
||||||
|
} from './lib/data-sync';
|
||||||
|
|
||||||
export * from './lib/sui-data-sync';
|
export * from './lib/sui-data-sync';
|
||||||
|
|
||||||
|
const schema: EventSyncSchema = {
|
||||||
|
tableSchema: 'gifted',
|
||||||
|
transactionModule: 'simple_gift_box',
|
||||||
|
events: [
|
||||||
|
{
|
||||||
|
eventName: 'GiftBoxMinted',
|
||||||
|
fields: { object_id: 'buffer', name: 'string', creator: 'buffer' },
|
||||||
|
},
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
|
async function main() {
|
||||||
|
const app = await NestFactory.createMicroservice(DataSyncModule, {
|
||||||
|
logger: ['log', 'verbose', 'error', 'warn', 'debug', 'fatal'],
|
||||||
|
});
|
||||||
|
const syncService = app.get(DataSyncService);
|
||||||
|
|
||||||
|
syncService.setSchemas([schema]);
|
||||||
|
syncService.addSyncMoveEventType(
|
||||||
|
`0xceba50ec29ada96392373f340fe4eeffab45140ac66acc9459770e5a3c58abf8::simple_gift_box::GiftBoxMinted`,
|
||||||
|
);
|
||||||
|
|
||||||
|
syncService.startSync();
|
||||||
|
}
|
||||||
|
|
||||||
|
main().catch(console.error);
|
||||||
|
|||||||
@@ -1,33 +1,2 @@
|
|||||||
import { NestFactory } from '@nestjs/core';
|
|
||||||
import { DataSyncService, EventSyncSchema } from './data-sync.interface';
|
|
||||||
import { DataSyncModule } from './data-sync.module';
|
|
||||||
|
|
||||||
export * from './data-sync.interface';
|
export * from './data-sync.interface';
|
||||||
export * from './data-sync.module';
|
export * from './data-sync.module';
|
||||||
|
|
||||||
const schema: EventSyncSchema = {
|
|
||||||
tableSchema: 'gifted',
|
|
||||||
transactionModule: 'simple_gift_box',
|
|
||||||
events: [
|
|
||||||
{
|
|
||||||
eventName: 'GiftBoxMinted',
|
|
||||||
fields: { object_id: 'buffer', name: 'string', creator: 'buffer' },
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
|
||||||
|
|
||||||
async function main() {
|
|
||||||
const app = await NestFactory.createMicroservice(DataSyncModule, {
|
|
||||||
logger: ['log', 'verbose', 'error', 'warn', 'debug', 'fatal'],
|
|
||||||
});
|
|
||||||
const syncService = app.get(DataSyncService);
|
|
||||||
|
|
||||||
syncService.setSchemas([schema]);
|
|
||||||
syncService.addSyncMoveEventType(
|
|
||||||
`0xceba50ec29ada96392373f340fe4eeffab45140ac66acc9459770e5a3c58abf8::simple_gift_box::GiftBoxMinted`,
|
|
||||||
);
|
|
||||||
|
|
||||||
syncService.startSync();
|
|
||||||
}
|
|
||||||
|
|
||||||
main().catch(console.error);
|
|
||||||
|
|||||||
Reference in New Issue
Block a user