forked from randlabs/myalgo-connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
205 lines (173 loc) · 4.76 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
204
205
export type Address = string;
export type Base64 = string;
export type TxHash = string;
interface Txn {
from: Address;
fee: number;
firstRound: number;
lastRound: number;
genesisID: string;
genesisHash: Base64;
note?: Uint8Array | Base64;
reKeyTo?: Address;
group?: Buffer | Base64;
flatFee: boolean;
}
interface ConfigTxn extends Txn {
type: "acfg";
assetManager?: Address;
assetReserve?: Address;
assetFreeze?: Address;
assetClawback?: Address;
}
interface TransferTxn extends Txn {
to: Address;
amount: number;
closeRemainderTo?: Address;
}
export interface PaymentTxn extends TransferTxn {
type: "pay";
}
export interface AssetTxn extends TransferTxn {
type: "axfer";
assetRevocationTarget?: Address;
assetIndex: number;
}
export interface AssetConfigTxn extends ConfigTxn {
assetIndex: number;
}
export interface AssetCreateTxn extends ConfigTxn {
assetTotal?: number;
assetDecimals?: number;
assetDefaultFrozen?: boolean;
assetName?: string;
assetUnitName?: string;
assetURL?: string;
assetMetadataHash?: Uint8Array|Base64;
}
export interface DestroyAssetTxn extends ConfigTxn {
assetIndex: number;
}
export interface FreezeAssetTxn extends Txn {
type: "afrz";
assetIndex: number;
freezeAccount: Address;
freezeState: boolean;
}
export interface KeyRegTxn extends Txn {
type: "keyreg";
voteKey?: Base64;
selectionKey?: Base64;
voteFirst: number;
voteLast: number;
voteKeyDilution?: number;
}
// eslint-disable-next-line no-shadow
export enum OnApplicationComplete {
NoOpOC = 0,
OptInOC = 1,
CloseOutOC = 2,
ClearStateOC = 3,
UpdateApplicationOC = 4,
DeleteApplicationOC = 5
}
export interface ApplicationTxn extends Txn {
type: "appl";
appArgs?: Uint8Array[] | Base64[];
appAccounts?: Address[];
appForeignApps?: number[];
appForeignAssets?: number[];
}
export interface CreateApplTxn extends ApplicationTxn {
appApprovalProgram: Uint8Array | Base64;
appClearProgram: Uint8Array | Base64;
appLocalInts: number;
appLocalByteSlices: number;
appGlobalInts: number;
appGlobalByteSlices: number;
appOnComplete?: OnApplicationComplete; // Default value is 0
extraPages?: number;
}
export interface CallApplTxn extends ApplicationTxn {
appIndex: number;
appOnComplete: OnApplicationComplete.NoOpOC;
}
export interface OptInApplTxn extends ApplicationTxn {
appIndex: number;
appOnComplete: OnApplicationComplete.OptInOC;
}
export interface CloseOutApplTxn extends ApplicationTxn {
appIndex: number;
appOnComplete: OnApplicationComplete.CloseOutOC;
}
export interface ClearApplTxn extends ApplicationTxn {
appIndex: number;
appOnComplete: OnApplicationComplete.ClearStateOC;
}
export interface UpdateApplTxn extends ApplicationTxn {
appIndex: number;
appOnComplete: OnApplicationComplete.UpdateApplicationOC;
appApprovalProgram: Uint8Array | Base64;
appClearProgram: Uint8Array | Base64;
}
export interface DeleteApplTxn extends ApplicationTxn {
appIndex: number;
appOnComplete: OnApplicationComplete.DeleteApplicationOC;
}
export type ApplTxn = CreateApplTxn | CallApplTxn | OptInApplTxn | CloseOutApplTxn | ClearApplTxn | UpdateApplTxn;
export type EncodedTransaction = Base64 | Uint8Array;
export type AlgorandTxn = PaymentTxn | AssetTxn | AssetConfigTxn | AssetCreateTxn | DestroyAssetTxn | FreezeAssetTxn | KeyRegTxn | ApplTxn;
export interface SignedTx {
// Transaction hash
txID: TxHash;
// Signed transaction
blob: Uint8Array;
}
export interface Accounts {
address: Address;
name: string;
}
export interface Options {
timeout?: number;
bridgeUrl?: string;
disableLedgerNano?: boolean;
}
export interface ConnectionSettings {
shouldSelectOneAccount?: boolean;
openManager?: boolean;
}
export default class MyAlgoConnect {
/**
* @param {Options} options Override default popup options.
*/
constructor(options?: Options);
/**
* @async
* @description Receives user's accounts from MyAlgo.
* @param {ConnectionSettings} [settings] Connection settings
* @returns Returns an array of Algorand addresses.
*/
connect(settings?: ConnectionSettings): Promise<Accounts[]>;
/**
* @async
* @description Sign an Algorand Transaction.
* @param transaction Expect a valid Algorand transaction
* @returns Returns signed transaction
*/
signTransaction(transaction: AlgorandTxn | EncodedTransaction): Promise<SignedTx>;
/**
* @async
* @description Sign an Algorand Transaction.
* @param transaction Expect a valid Algorand transaction array.
* @returns Returns signed an array of signed transactions.
*/
signTransaction(transaction: (AlgorandTxn | EncodedTransaction)[]): Promise<SignedTx[]>;
/**
* @async
* @description Sign a teal program
* @param logic Teal program
* @param address Signer Address
* @returns Returns signed teal
*/
signLogicSig(logic: Uint8Array | Base64, address: Address): Promise<Uint8Array>;
}