-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.d.ts
203 lines (187 loc) · 5.77 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
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
export interface ZilPay {
wallet: ZilPayWallet
blockchain: ZilPayBlockchain
crypto: ZilPayCrypto
utils: ZilPayUtils
transactions: ZilPayTransactions
contracts: ZilPayContracts
}
export interface ZilPayWallet {
net: ZilPayNet
defaultAccount: {
base16: string
bech32: string
}
isEnable: boolean
connect: () => Promise<boolean>
sign: () => Promise<{ signature: string, message: string, publicKey: string }>
verify: Function
observableAccount: (...args: string[]) => {
subscribe: Function
unsubscribe: Function
}
observableNetwork: (...args: string[]) => {
subscribe: (hashs?: string[]) => ZilPayNet
unsubscribe: Function
}
observableBlock: (...args: string[]) => {
subscribe: (hashs?: string[]) => Promise<any>
unsubscribe: Function
}
observableTransaction: (...args: string[]) => {
subscribe: any
unsubscribe: Function
}
addTransactionsQueue: (...args: string[]) => any
}
export interface ZilPayTransactions {
// toDs to know if should send to normal or Ds shard
// https://blog.zilliqa.com/provisioning-sharding-for-smart-contracts-a-design-for-zilliqa-cd8d012ee735.
new: (transactionParams: ZilPayTransactionProps, toDs: boolean) => ZilPayTransaction
}
export interface ZilPayTransaction extends ZilPayBlockchainPayload {
result: any
}
export interface ZilPayTransactionProps {
version?: any
toAddr: string
amount: any, // Sending an amount in Zil (1) and converting the amount to Qa
gasPrice: any, // Minimum gasPrice veries. Check the `GetMinimumGasPrice` on the blockchain
gasLimit?: any,
}
export interface ZilPayCrypto {
fromBech32Address: (address: string) => string
toBech32Address: (address: string) => String
isValidChecksumAddress: (address: string) => boolean
toChecksumAddress: (address: string) => string
}
export interface ZilPayUtils {
bytes: {
pack: (chainId: number, msgVersion: number) => any
}
units: {
fromQa: (qa: any, unit: "zil" | "qa", options?: any) => string | number
toQa: (input: string, unit: "zil" | "li") => string | number | any
Units: {
Zil: "zil"
Li: "li"
Qa: "qa"
}
}
}
export interface ZilPayBlockchain {
getBalance: (address: string) => Promise<ZilPayBlockchainPayload & {
result: {
balance: string
nonce: number
}
}>
getBlockChainInfo: () => Promise<ZilPayBlockchainPayload & {
result: {
CurrentDSEpoch: string
CurrentMiniEpoch: string
DSBlockRate: number
NumDSBlocks: string
NumPeers: number
NumTransactions: string
NumTxBlocks: string
NumTxnsDSEpoch: string
NumTxnsTxEpoch: string
ShardingStructure: { NumPeers: number[] }
TransactionRate: number
TxBlockRate: number
}
}>
getContractAddressFromTransactionID: (transactionId: string) => Promise<ZilPayBlockchainPayload & {
result: string
}>
getCurrentDSEpoch: () => Promise<ZilPayBlockchainPayload & {
result: string
}>
getCurrentMiniEpoch: (transactionId: string) => Promise<ZilPayBlockchainPayload & {
result: string
}>
getDSBlock: (blockNum: number) => Promise<ZilPayBlockchainPayload & {
result: ZilPayBlockchainDSBlock
}>
getDSBlockListing: (max: number) => Promise<ZilPayBlockchainPayload & {
result: {
data: {
BlockNum: number
hash: string
}[],
maxPages: number
}
}>
getDSBlockRate: () => Promise<ZilPayBlockchainPayload & {
result: number
}>
getLatestDSBlock: () => Promise<ZilPayBlockchainPayload & {
result: ZilPayBlockchainDSBlock
}>
getMinimumGasPrice: () => Promise<ZilPayBlockchainPayload & {
result: string
}>
createTransaction: (tansaction: ZilPayTransaction) => Promise<ZilPayTransactionProps & any>
}
export interface ZilPayContracts {
at: (address: string) => ZilPayContract
new: (scillaCode: string, params: ZilPayParam[]) => ZilPayContract
}
export interface ZilPayContract {
address: string
code: undefined | string
init: undefined | ZilPayParam[]
transaction: any
call: (transaction: string, params: ZilPayParam[], config: { amount: any, gasPrice: any, gasLimit: any }, toDs: boolean) => Promise<ZilPayContractCall>
deploy: (config: { amount: any, gasPrice: any, gasLimit: any }, toDs: boolean) => Promise<[ZilPayTransaction, ZilPayContract]>
getInit: () => Promise<ZilPayParam[]>
getCode: () => Promise<string>
getState: () => Promise<ZilPayContractState & any>
}
export interface ZilPayContractState {
_balance: string
total_supply: string
}
export interface ZilPayContractCall {
ID: string
Info: string
amount: any
code: string
data: { _tag: string, params: ZilPayParam[] }
from: string
gasLimit: any
gasPrice: any
nonce: number
priority: boolean
pubKey: string
receipt: undefined | any
signature: string
toAddr: string
version: number
}
export interface ZilPayParam {
type: string,
value: string,
vname: string
}
export interface ZilPayBlockchainDSBlock {
header: {
BlockNum: string
Difficulty: number
DifficultyDS: number
GasPrice: string
LeaderPubKey: string
PoWWinners: string[],
PrevHash: string
Timestamp: string
},
signature: string
}
export interface ZilPayBlockchainPayload {
id: number
jsonrpc: string
req: any
}
export type ZilPayNet = "mainnet" | "testnet" | "private"
export type ZilPayUnits = "zil" | "li" | "qa"