Skip to content

Commit 5b0df6f

Browse files
committed
feat: remove totalBalance
1 parent 1bc25eb commit 5b0df6f

8 files changed

Lines changed: 24 additions & 16 deletions

File tree

packages/neuron-wallet/src/database/address/dao.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ export interface Address {
2020
sentBalance: string
2121
pendingBalance: string
2222
balance: string
23-
totalBalance: string
2423
blake160: string
2524
version: AddressVersion
2625
description?: string
@@ -54,7 +53,6 @@ export default class AddressDao {
5453
// pendingBalance means balance of OutputStatus.Pending cells (sent from me, but not committed)
5554
// so the final balance is (liveBalance + sentBalance - pendingBalance)
5655
// balance is the balance of the cells those who don't hold data or type script
57-
// totalBalance means balance of all cells, including those who hold data and type script
5856
public static updateTxCountAndBalance = async (
5957
address: string,
6058
url: string = NodeService.getInstance().core.rpc.node.url
@@ -78,7 +76,6 @@ export default class AddressDao {
7876
addressEntity.liveBalance = await CellsService.getBalance(lockHashes, OutputStatus.Live)
7977
addressEntity.sentBalance = await CellsService.getBalance(lockHashes, OutputStatus.Sent)
8078
addressEntity.pendingBalance = await CellsService.getBalance(lockHashes, OutputStatus.Pending)
81-
addressEntity.totalBalance = '0'
8279
return addressEntity
8380
})
8481
)

packages/neuron-wallet/src/database/address/entities/address.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,6 @@ export default class Address extends BaseEntity {
7373
@Column()
7474
pendingBalance: string = '0'
7575

76-
@Column()
77-
totalBalance: string = '0'
78-
7976
public balance = (): string => {
8077
return (BigInt(this.liveBalance) + BigInt(this.sentBalance)).toString()
8178
}
@@ -94,7 +91,6 @@ export default class Address extends BaseEntity {
9491
sentBalance: this.sentBalance,
9592
pendingBalance: this.pendingBalance,
9693
balance: this.balance(),
97-
totalBalance: this.totalBalance,
9894
description: this.description,
9995
}
10096
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import {MigrationInterface, QueryRunner, TableColumn} from "typeorm";
2+
3+
export class RemoveTotalBalance1573458655136 implements MigrationInterface {
4+
5+
public async up(queryRunner: QueryRunner): Promise<any> {
6+
await queryRunner.dropColumn('address', 'totalBalance')
7+
}
8+
9+
public async down(queryRunner: QueryRunner): Promise<any> {
10+
await queryRunner.addColumn('address', new TableColumn({
11+
name: 'totalBalance',
12+
type: 'varchar',
13+
default: '0',
14+
}))
15+
}
16+
17+
}

packages/neuron-wallet/src/database/address/ormconfig.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import Address from './entities/address'
99
import { AddAddress1561461669542 } from './migrations/1561461669542-AddAddress'
1010
import { extendBalance1562126909151 } from './migrations/1562126909151-extendBalance'
1111
import { AddTotalBalance1567485550388 } from './migrations/1567485550388-AddTotalBalance'
12+
import { RemoveTotalBalance1573458655136 } from './migrations/1573458655136-RemoveTotalBalance'
1213

1314
const dbPath = path.join(env.fileBasePath, 'address.sqlite')
1415

@@ -21,7 +22,12 @@ const connectOptions = (): SqliteConnectionOptions => {
2122
type: 'sqlite',
2223
database,
2324
entities: [Address],
24-
migrations: [AddAddress1561461669542, extendBalance1562126909151, AddTotalBalance1567485550388],
25+
migrations: [
26+
AddAddress1561461669542,
27+
extendBalance1562126909151,
28+
AddTotalBalance1567485550388,
29+
RemoveTotalBalance1573458655136,
30+
],
2531
synchronize: false,
2632
migrationsRun: true,
2733
logging: ['error'],

packages/neuron-wallet/src/services/addresses.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,7 +181,6 @@ export default class AddressService {
181181
sentBalance: '0',
182182
pendingBalance: '0',
183183
balance: '0',
184-
totalBalance: '0',
185184
blake160,
186185
version: AddressVersion.Testnet,
187186
}

packages/neuron-wallet/tests/database/address/balance.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ describe('balance', () => {
3535
sentBalance: sentBalance.toString(),
3636
pendingBalance: pendingBalance.toString(),
3737
balance: '0',
38-
totalBalance: '0',
3938
blake160: '0x36c329ed630d6ce750712a477543672adab57f4c',
4039
version: AddressVersion.Testnet,
4140
}

packages/neuron-wallet/tests/database/address/dao.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ describe('Address Dao tests', () => {
1515
sentBalance: '0',
1616
pendingBalance: '0',
1717
balance: '0',
18-
totalBalance: '0',
1918
blake160: '0x36c329ed630d6ce750712a477543672adab57f4c',
2019
version: AddressVersion.Testnet,
2120
}
@@ -31,7 +30,6 @@ describe('Address Dao tests', () => {
3130
sentBalance: '0',
3231
pendingBalance: '0',
3332
balance: '0',
34-
totalBalance: '0',
3533
blake160: '0x36c329ed630d6ce750712a477543672adab57f4c',
3634
version: AddressVersion.Testnet,
3735
}
@@ -47,7 +45,6 @@ describe('Address Dao tests', () => {
4745
sentBalance: '0',
4846
pendingBalance: '0',
4947
balance: '0',
50-
totalBalance: '0',
5148
blake160: '0x36c329ed630d6ce750712a477543672adab57f4c',
5249
version: AddressVersion.Testnet,
5350
}

packages/neuron-wallet/tests/services/address.test.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ describe('Key tests with db', () => {
5454
sentBalance: '0',
5555
pendingBalance: '0',
5656
balance: '0',
57-
totalBalance: '0',
5857
blake160: '0x36c329ed630d6ce750712a477543672adab57f4c',
5958
version: AddressVersion.Testnet,
6059
}
@@ -70,7 +69,6 @@ describe('Key tests with db', () => {
7069
sentBalance: '0',
7170
pendingBalance: '0',
7271
balance: '0',
73-
totalBalance: '0',
7472
blake160: '0x36c329ed630d6ce750712a477543672adab57f4c',
7573
version: AddressVersion.Testnet,
7674
}
@@ -86,7 +84,6 @@ describe('Key tests with db', () => {
8684
sentBalance: '0',
8785
pendingBalance: '0',
8886
balance: '0',
89-
totalBalance: '0',
9087
blake160: '0x36c329ed630d6ce750712a477543672adab57f4c',
9188
version: AddressVersion.Testnet,
9289
}

0 commit comments

Comments
 (0)