-
Notifications
You must be signed in to change notification settings - Fork 8
/
types.ts
117 lines (108 loc) · 2.58 KB
/
types.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
import { AccountBlockBlock } from '@vite/vitejs/distSrc/utils/type';
import { ViteAPI } from '@vite/vitejs/distSrc/viteAPI/type';
import CafeContract from '../contracts/Cafe';
import en from '../i18n/en';
import { setStateType } from './globalContext';
import { VC } from './viteConnect';
type Network = {
name: string;
rpcUrl: string;
explorerUrl?: string;
};
type injectedScriptEvents = 'accountChange' | 'networkChange';
type VitePassport = {
// These methods are relayed from contentScript.ts => injectedScript.ts
getConnectedAddress: () => Promise<undefined | string>;
disconnectWallet: () => Promise<undefined>;
getNetwork: () => Promise<Network>;
// These methods are relayed from contentScript.ts => background.ts => popup => contentScript.ts => injectedScript.ts
connectWallet: () => Promise<{ domain: string }>;
writeAccountBlock: (type: string, params: object) => Promise<{ block: AccountBlockBlock }>;
// `on` subscribes to `event` and returns an unsubscribe function
on: (
event: injectedScriptEvents,
callback: (payload: { activeAddress?: string; activeNetwork: Network }) => void
) => () => void;
};
declare global {
interface Window {
vitePassport?: VitePassport;
}
}
export type State = {
setState: setStateType;
callContract: (
contract: typeof CafeContract,
methodName: string,
params?: any[],
tokenId?: string,
amount?: string
) => Promise<object>;
scanEvents: (
abi: any[],
address: string,
fromHeight: string,
eventName: string
) => Promise<object>;
viteApi: ViteAPI;
toast: any;
languageType: string;
activeNetworkIndex: number;
i18n: typeof en;
vcInstance?: VC;
vpAddress?: string;
activeAddress?: string;
viteBalanceInfo: ViteBalanceInfo;
copyWithToast: (text: string) => void;
};
export type ViteBalanceInfo = {
balance: {
address: string;
blockCount: string;
balanceInfoMap?: {
[tokenId: string]: {
tokenInfo: TokenInfo;
balance: string;
};
};
};
unreceived: {
address: string;
blockCount: string;
};
};
export type TokenInfo = {
tokenName: string;
tokenSymbol: string;
totalSupply: string;
decimals: number;
owner: string;
tokenId: string;
maxSupply: string;
ownerBurnOnly: false;
isReIssuable: false;
index: number;
isOwnerBurnOnly: false;
};
export type NewAccountBlock = {
hash: string;
height: number;
heightStr: string;
removed: boolean;
};
export type CoffeeBuyEvent = {
returnValues: {
from: string;
to: string;
num: string;
};
event: string;
raw: {
data: string;
topics: [string];
};
signature: string;
accountBlockHeight: string;
accountBlockHash: string;
address: string;
};