-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #385 from Daryl-L/feautre/bill_of_sudt
feat: bill of sudt
- Loading branch information
Showing
10 changed files
with
260 additions
and
23 deletions.
There are no files selected for viewing
10 changes: 5 additions & 5 deletions
10
offchain-modules/packages/app-monitor/src/balanceProvider.ts
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
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,32 @@ | ||
import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn, UpdateDateColumn } from 'typeorm'; | ||
|
||
@Entity() | ||
@Index(['txHash', 'index', 'direction'], { unique: true }) | ||
export class Sudt { | ||
@PrimaryGeneratedColumn('increment') | ||
id: number; | ||
|
||
@Column() | ||
txHash: string; | ||
|
||
@Column() | ||
direction: number; | ||
|
||
@Column({ length: 10240 }) | ||
address: string; | ||
|
||
@Column() | ||
sudtArgs: string; | ||
|
||
@Column() | ||
index: number; | ||
|
||
@Column() | ||
amount: string; | ||
|
||
@CreateDateColumn() | ||
createdAt: string; | ||
|
||
@UpdateDateColumn() | ||
updatedAt: string; | ||
} |
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,29 @@ | ||
import { Connection, Repository } from 'typeorm'; | ||
import { Sudt } from './entity/sudt'; | ||
|
||
export class SudtDb { | ||
private sudtRepository: Repository<Sudt>; | ||
|
||
constructor(private connection: Connection) { | ||
this.sudtRepository = connection.getRepository(Sudt); | ||
} | ||
|
||
async createSudtTransferRecord( | ||
hash: string, | ||
direction: 'in' | 'out', | ||
address: string, | ||
sudtArgs: string, | ||
amount: string, | ||
index: number, | ||
): Promise<void> { | ||
const record = this.sudtRepository.create({ | ||
txHash: hash, | ||
direction: direction == 'in' ? 1 : -1, | ||
address, | ||
sudtArgs, | ||
amount, | ||
index, | ||
}); | ||
await this.sudtRepository.save(record); | ||
} | ||
} |
Oops, something went wrong.