forked from vechain/connex
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vendor.d.ts
93 lines (76 loc) · 2.96 KB
/
vendor.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
declare namespace Connex {
/** the vendor interface to interact with wallets */
interface Vendor {
/** create the tx signing service */
sign(kind: 'tx', msg: Vendor.TxMessage): Vendor.TxSigningService
/** create the cert signing service */
sign(kind: 'cert', msg: Vendor.CertMessage): Vendor.CertSigningService
}
namespace Vendor {
/** the interface is for requesting user wallet to sign transactions */
interface TxSigningService {
/** designate the signer address */
signer(addr: string): this
/** set the max allowed gas */
gas(gas: number): this
/** set another txid as dependency */
dependsOn(txid: string): this
/**
* provides the url of web page to reveal tx related information.
* first appearance of slice '{txid}' in the given link url will be replaced with txid.
*/
link(url: string): this
/** set comment for the tx content */
comment(text: string): this
/**
* enable VIP-191 by providing url of web api, which provides delegation service
* @param url the url of web api
* @param signer hint of the delegator address
*/
delegate(url: string, signer?: string): this
/** register a callback function fired when the request is accepted by user wallet */
accepted(cb: () => void): this
/** send the request */
request(): Promise<TxResponse>
}
/** the interface is for requesting user wallet to sign certificates */
interface CertSigningService {
/** designate the signer address */
signer(addr: string): this
/**
* provides the url of web page to reveal cert related information.
* first appearance of slice '{certid}' in the given link url will be replaced with certid.
*/
link(url: string): this
/** register a callback function fired when the request is accepted by user wallet */
accepted(cb: () => void): this
/** send the request */
request(): Promise<CertResponse>
}
type TxMessage = Array<Connex.VM.Clause & {
/** comment to the clause */
comment?: string
/** as the hint for wallet to decode clause data */
abi?: object
}>
type CertMessage = {
purpose: 'identification' | 'agreement'
payload: {
type: 'text'
content: string
}
}
type TxResponse = {
txid: string
signer: string
}
type CertResponse = {
annex: {
domain: string
timestamp: number
signer: string
}
signature: string
}
}
}