1.0.49 • Published 9 months ago

@msafe/sui3-model v1.0.49

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@msafe/sui3-model

Database and model for MSafe V3 SUI.

Installation

yarn add @msafe/sui3-model

Usage

There are 3 models, each can be accessed by different services.

  • sync: Pull latest data from blockchain and write raw data to database.
  • core: MSafe multi-sig business logic.
  • stream: MPay service, which is stream payment.
import { CoreModel } from '@msafe/sui3-model/core';
import { StreamModel } from '@msafe/sui3-model/stream';
import { SyncModel } from '@msafe/sui3-model/sync';

const LOCAL_DB_CONFIG: ModelConfig = {
  host: '127.0.0.1',
  port: 3306,
  username: 'msafe',
  password: 'msafe',
  database: 'msafe_sui_local',
  logging: false,
};

const core = await CoreModel.New(LOCAL_DB_CONFIG);
// Handle core model queries

const sync = await SyncModel.New(LOCAL_DB_CONFIG);
// Handle core model queries

const stream = await StreamModel.New(LOCAL_DB_CONFIG);
// Handle core model queries

For each module, the Repository and DataSource from typeOrm is exported in each instance. Please refer to TypeOrm documentation for more database operations.

Appendix

Install and initialize mysql on local

MacOS

brew install mysql
mysql -u root

> create database msafe_sui_local;

Create a new user and grant permission to database

> CREATE USER 'msafe'@'localhost' IDENTIFIED BY 'msafe';
> use msafe_sui_local;
> GRANT ALL PRIVILEGES ON msafe_sui_local.* TO 'msafe'@'localhost'
> exit

Test our new user connection:

mysql -u msafe -p
// Input password `msafe`
use msafe_sui_local

Now you have user and database set.

Scripts

Database initialization

After the database has been created, use scripts/initialize.ts to initialize the database schema.

yarn initialize config/config.local.yaml

To access database for other environments, please request the config file from admin.

1.0.44

9 months ago

1.0.43

9 months ago

1.0.42

9 months ago

1.0.48

9 months ago

1.0.47

9 months ago

1.0.46

9 months ago

1.0.45

9 months ago

1.0.49

9 months ago

1.0.41

12 months ago

1.0.40

1 year ago

1.0.39

1 year ago

1.0.38

1 year ago

1.0.37

1 year ago

1.0.36

1 year ago

1.0.35

1 year ago

1.0.33

1 year ago

1.0.32

1 year ago

1.0.31

1 year ago

1.0.34

1 year ago

1.0.30

1 year ago

1.0.29

1 year ago

1.0.28

1 year ago

1.0.26

1 year ago

1.0.27

1 year ago

1.0.25

1 year ago

1.0.24

1 year ago

1.0.23

1 year ago

1.0.22

1 year ago

1.0.21

1 year ago

1.0.20

1 year ago

1.0.19

1 year ago

1.0.18

1 year ago

1.0.17

1 year ago

1.0.16

1 year ago

1.0.15

1 year ago

1.0.14

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

0.5.6-pre.0

1 year ago

0.5.4-pre.0

1 year ago

1.0.3

1 year ago

0.5.3-pre.0

1 year ago

1.0.4-pre.0

1 year ago

0.5.5-pre.0

1 year ago

0.5.7-pre.0

1 year ago

0.5.2-pre.0

1 year ago

1.0.0

1 year ago

1.0.1

2 years ago

0.0.6

2 years ago