Skip to content

Commit c588c2f

Browse files
committed
more typing, less any
1 parent cf447f2 commit c588c2f

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

src/blockchain/block.test.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
import Block from './block';
2+
import Transaction from '../wallet/transaction';
23

34
describe('Block', () => {
4-
let data: string;
5+
let data: Transaction[];
56
let lastBlock: Block;
67
let block: Block;
78

89
beforeEach(() => {
9-
data = 'bar';
10+
data = [];
1011
lastBlock = Block.genesis();
1112
block = Block.mineBlock(lastBlock, data);
1213
});

src/blockchain/block.ts

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export default class Block {
4242
// return new this('Genesis time', '-----', 'f1r57-h45h', [], 0, DIFFICULTY);
4343
}
4444

45-
public static mineBlock(lastBlock: Block, data: any): Block {
45+
public static mineBlock(lastBlock: Block, data: Transaction[]): Block {
4646
let hash;
4747
let timestamp;
4848
const lastHash = lastBlock.hash;
@@ -59,7 +59,13 @@ export default class Block {
5959
return new this(timestamp, lastHash, hash, data, nonce, difficulty);
6060
}
6161

62-
public static hash(timestamp: number, lastHash: string, data: any, nonce: number, difficulty: number): string {
62+
public static hash(
63+
timestamp: number,
64+
lastHash: string,
65+
data: Transaction[],
66+
nonce: number,
67+
difficulty: number,
68+
): string {
6369
return ChainUtil.hash(`${timestamp}${lastHash}${data}${nonce}${difficulty}`).toString();
6470
}
6571

src/chain-util.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default class ChainUtil {
1313
return uuidV1();
1414
}
1515

16-
public static hash(data: any): string {
16+
public static hash<T>(data: T): string {
1717
return SHA256(JSON.stringify(data)).toString();
1818
}
1919

src/wallet/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export default class Wallet {
2626
balance : ${this.balance}`;
2727
}
2828

29-
public sign(dataHash: any): ec.Signature {
29+
public sign(dataHash: string): ec.Signature {
3030
return this.keyPair.sign(dataHash);
3131
}
3232

0 commit comments

Comments
 (0)