This repository has been archived by the owner on Dec 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
135 lines (112 loc) · 2.57 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
import { IncomingMessage, ServerResponse } from 'http';
import { GraphQLError } from 'graphql';
import WebSocket from 'ws';
import Transaction from './server/lib/Transaction';
import State from './server/lib/State';
import Block from './server/lib/Block';
import Blockchain from './server/lib/Blockchain';
import Wallet from './server/lib/Wallet';
import Node from './server/lib/Node';
import User from './server/lib/User';
import { MessageType } from './server/util/constants';
import Peer from './server/lib/Peer';
export type JWTPayload = {
exp: number,
iat: number,
id: string,
};
export interface ResolverContext extends IncomingMessage {
res: ServerResponse;
}
export interface IException {
key: string;
message: string;
}
export interface IExceptionBag {
[key: string]: string[];
}
export interface IGraphQLError extends GraphQLError {
originalError: IGraphQLError;
state: IExceptionBag;
status: number;
}
export interface IIncomingMessage extends IncomingMessage {
session: any;
}
export interface IWalletProps {
privateKey: string;
publicKey: string;
}
export interface ITransactionProps {
amount: number;
from: string;
nonce?: number;
signature?: string;
to: string;
}
export interface IMineBlockArgs {
minerAddress: string;
transactions: Transaction[];
}
export interface ISendAmountArgs {
from: string;
to: string;
amount: number;
}
export interface IBlockProps extends IMineBlockArgs {
index: number;
nonce?: number;
parentHash: string;
stateHash: string;
trasactions?: Transaction[];
}
export interface IWalletData {
amount: number;
nonce?: number;
}
export interface IStateWallet {
[key: string]: IWalletData;
}
export interface IStateProps {
wallets?: IStateWallet;
}
export interface IBlockchainProps {
blocks?: Block[];
state?: State;
}
export interface IPeerProps {
node?: Node;
reconnectCount?: number;
url?: string;
ws?: WebSocket;
own?: boolean;
}
export interface INodeProps {
blockchain: Blockchain;
peers?: Peer[];
}
export interface IUserData {
address: string;
name: string;
wallet: Wallet;
}
export interface IServerContext extends IncomingMessage {
blockchain: Blockchain;
user: User;
node: Node;
}
export interface ISocketControlMessage extends Object {
type: MessageType;
}
export interface ISocketControlMessage extends Object {
type: MessageType;
peers: IPeerProps[];
}
export interface ISocketControlMessage extends Object {
type: MessageType;
blocks: IBlockProps[];
}
export interface ISocketControlMessage extends Object {
type: MessageType;
state: IStateProps[];
}