Skip to content

Commit 146d59b

Browse files
committed
1 parent f5c1b11 commit 146d59b

File tree

4 files changed

+6
-59
lines changed

4 files changed

+6
-59
lines changed

dist/library/wallet.js

Lines changed: 2 additions & 25 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/library/wallet.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "goodchain",
3-
"version": "3.0.1",
3+
"version": "3.0.2",
44
"description": "GoodChain: Blockchain for Everyone",
55
"main": "index.js",
66
"type": "module",

src/library/wallet.ts

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,6 @@ class Wallet
5050
{
5151
this.cacheWallet = {};
5252
const newTransactions: TransactionData[] = [];
53-
const wallets = await this.allWallets();
5453
for ( const tmpTrx of transactions )
5554
{
5655
try
@@ -69,9 +68,9 @@ class Wallet
6968
console.warn( "Dropping transaction with transaction number less than wallet transaction number" );
7069
continue;
7170
}
72-
minusBalance( trx.from, trx.amount + trx.fee );
71+
await this.minusBalance( trx.from, trx.amount + trx.fee );
7372
}
74-
await addBalance( trx.to, trx.amount ); // todo you can use this.addbalance again
73+
await this.addBalance( trx.to, trx.amount ); // todo you can use this.addbalance again
7574
newTransactions.push( trx.data );
7675
}
7776
catch ( error )
@@ -81,35 +80,6 @@ class Wallet
8180
}
8281
this.cacheWallet = {};
8382
return newTransactions;
84-
85-
function minusBalance ( address: string, amount: number )
86-
{
87-
if ( !wallets[address] )
88-
{
89-
wallets[address] = {
90-
balance: 0,
91-
transaction_number: 0
92-
};
93-
}
94-
if ( wallets[address].balance < amount )
95-
{
96-
throw new Error( "Insufficient balance", { cause: { address, amount } });
97-
}
98-
wallets[address].balance -= amount;
99-
wallets[address].transaction_number++;
100-
}
101-
102-
function addBalance ( address: string, amount: number )
103-
{
104-
if ( !wallets[address] )
105-
{
106-
wallets[address] = {
107-
balance: 0,
108-
transaction_number: 0
109-
};
110-
}
111-
wallets[address].balance += amount;
112-
}
11383
}
11484

11585
async getBalance ( address: string ): Promise<UserWallet>

0 commit comments

Comments
 (0)