forked from vechain/connex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
account.d.ts
102 lines (82 loc) · 3.13 KB
/
account.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
declare namespace Connex.Thor {
/** the account model */
type Account = {
/** balance (VET) in hex string */
balance: string
/** energy (VTHO) in hex string */
energy: string
/** whether the account has code */
hasCode: boolean
}
namespace Account {
/** storage entry */
type Storage = {
value: string
}
/** code entry */
type Code = {
code: string
}
/** the account visitor interface */
interface Visitor {
/** the account address to be visited */
readonly address: string
/** query the account */
get(): Promise<Account>
/** query the account code */
getCode(): Promise<Code>
/**
* query the account storage
* @param key storage key
* @returns the storage entry
*/
getStorage(key: string): Promise<Storage>
/**
* Create a method object, to perform contract call, or build vm clause
* @param abi method's JSON ABI object
* @returns method object
*/
method(abi: object): Method
/**
* Create an object to visit events associated to this account
* @param abi event's JSON ABI object
* @returns event visitor
*/
event(abi: object): Event
}
/** the account method interface */
interface Method {
/** set VET amount to transfer in unit WEI, presented by hex/dec string or number type */
value(val: string | number): this
/** set method caller (msg.sender) */
caller(addr: string): this
/** set max allowed gas */
gas(gas: number): this
/** set gas price, presented by hex/dec string or number type */
gasPrice(gp: string | number): this
/** set gas payer */
gasPayer(addr: string): this
/**
* turn on call result cache
* @param hints a set of addresses, as the condition of cache invalidation
*/
cache(hints: string[]): this
/** encode arguments into clause */
asClause(...args: any[]): Transaction['clauses'][0]
/** call the method (dry-run, without altering blockchain) */
call(...args: any[]): Promise<VM.Output & WithDecoded>
/** initiate a signing service to commit this method as a transaction */
transact(...args: any[]): Vendor.TxSigningService
}
/** the interface to visit account associated events */
interface Event {
/** encode indexed event args into Criteria */
asCriteria(indexed: object): Thor.Filter.Criteria<'event'>
/** create a filter with a set of Criteria encoded by a set of indexed event args */
filter(indexedSet: object[]): Thor.Filter<'event', WithDecoded>
}
type WithDecoded = {
decoded: Record<string | number, any>
}
}
}