@algorandfoundation/algokit-utils 0.1.0 → 1.0.0-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +31 -0
- package/dist/account.d.ts +87 -0
- package/dist/account.d.ts.map +1 -0
- package/dist/account.js +148 -0
- package/dist/account.js.map +1 -0
- package/dist/algo-amount.d.ts +18 -0
- package/dist/algo-amount.d.ts.map +1 -0
- package/dist/algo-amount.js +31 -0
- package/dist/algo-amount.js.map +1 -0
- package/dist/algo-http-client-with-retry.d.ts +14 -0
- package/dist/algo-http-client-with-retry.d.ts.map +1 -0
- package/dist/algo-http-client-with-retry.js +62 -0
- package/dist/algo-http-client-with-retry.js.map +1 -0
- package/dist/algod-type.d.ts +124 -0
- package/dist/algod-type.d.ts.map +1 -0
- package/dist/algod-type.js +3 -0
- package/dist/algod-type.js.map +1 -0
- package/dist/app.d.ts +150 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +160 -0
- package/dist/app.js.map +1 -0
- package/dist/application-client.d.ts +1 -0
- package/dist/application-client.d.ts.map +1 -0
- package/dist/application-client.js +69 -0
- package/dist/application-client.js.map +1 -0
- package/dist/config.d.ts +25 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +28 -0
- package/dist/config.js.map +1 -0
- package/dist/deploy-app.d.ts +149 -0
- package/dist/deploy-app.d.ts.map +1 -0
- package/dist/deploy-app.js +418 -0
- package/dist/deploy-app.js.map +1 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +29 -0
- package/dist/index.js.map +1 -0
- package/dist/indexer-lookup.d.ts +31 -0
- package/dist/indexer-lookup.d.ts.map +1 -0
- package/dist/indexer-lookup.js +96 -0
- package/dist/indexer-lookup.js.map +1 -0
- package/dist/indexer-type.d.ts +314 -0
- package/dist/indexer-type.d.ts.map +1 -0
- package/dist/indexer-type.js +25 -0
- package/dist/indexer-type.js.map +1 -0
- package/dist/localnet.d.ts +54 -0
- package/dist/localnet.d.ts.map +1 -0
- package/dist/localnet.js +121 -0
- package/dist/localnet.js.map +1 -0
- package/dist/network-client.d.ts +102 -0
- package/dist/network-client.d.ts.map +1 -0
- package/dist/network-client.js +182 -0
- package/dist/network-client.js.map +1 -0
- package/dist/package.json +20 -0
- package/dist/transaction.d.ts +147 -0
- package/dist/transaction.d.ts.map +1 -0
- package/dist/transaction.js +274 -0
- package/dist/transaction.js.map +1 -0
- package/dist/transfer.d.ts +24 -0
- package/dist/transfer.d.ts.map +1 -0
- package/dist/transfer.js +33 -0
- package/dist/transfer.js.map +1 -0
- package/dist/urlTokenBaseHTTPClient.d.ts +41 -0
- package/dist/urlTokenBaseHTTPClient.d.ts.map +1 -0
- package/dist/urlTokenBaseHTTPClient.js +151 -0
- package/dist/urlTokenBaseHTTPClient.js.map +1 -0
- package/package.json +101 -12
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { TransactionType } from 'algosdk';
|
|
2
|
+
import { TealKeyValue } from 'algosdk/dist/types/client/v2/algod/models/types';
|
|
3
|
+
/** https://developer.algorand.org/docs/rest-apis/indexer/#get-v2transactions */
|
|
4
|
+
export interface TransactionSearchResults {
|
|
5
|
+
'current-round': string;
|
|
6
|
+
'next-token': string;
|
|
7
|
+
transactions: TransactionResult[];
|
|
8
|
+
}
|
|
9
|
+
/** https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-id */
|
|
10
|
+
export interface AccountLookupResult {
|
|
11
|
+
'current-round': string;
|
|
12
|
+
account: AccountResult;
|
|
13
|
+
}
|
|
14
|
+
/** https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idassets */
|
|
15
|
+
export interface AssetsLookupResult {
|
|
16
|
+
'current-round': string;
|
|
17
|
+
'next-token': string;
|
|
18
|
+
assets: AssetHolding[];
|
|
19
|
+
}
|
|
20
|
+
/** https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idcreated-assets */
|
|
21
|
+
export interface AssetsCreatedLookupResult {
|
|
22
|
+
'current-round': string;
|
|
23
|
+
'next-token': string;
|
|
24
|
+
assets: AssetResult[];
|
|
25
|
+
}
|
|
26
|
+
/** https://developer.algorand.org/docs/rest-apis/indexer/#get-v2accountsaccount-idcreated-applications */
|
|
27
|
+
export interface ApplicationCreatedLookupResult {
|
|
28
|
+
'current-round': string;
|
|
29
|
+
'next-token': string;
|
|
30
|
+
applications: ApplicationResult[];
|
|
31
|
+
}
|
|
32
|
+
/** https://developer.algorand.org/docs/rest-apis/indexer/#get-v2assetsasset-id */
|
|
33
|
+
export interface AssetLookupResult {
|
|
34
|
+
'current-round': string;
|
|
35
|
+
asset: AssetResult;
|
|
36
|
+
}
|
|
37
|
+
/** https://developer.algorand.org/docs/rest-apis/indexer/#get-v2transactionstxid */
|
|
38
|
+
export interface TransactionLookupResult {
|
|
39
|
+
'current-round': number;
|
|
40
|
+
transaction: TransactionResult;
|
|
41
|
+
}
|
|
42
|
+
/** https://developer.algorand.org/docs/rest-apis/indexer/#get-v2applicationsapplication-id */
|
|
43
|
+
export interface ApplicationLookupResult {
|
|
44
|
+
'current-round': string;
|
|
45
|
+
application: ApplicationResult;
|
|
46
|
+
}
|
|
47
|
+
/** Indexer result for a transaction, @see https://developer.algorand.org/docs/rest-apis/indexer/#transaction */
|
|
48
|
+
export interface TransactionResult {
|
|
49
|
+
id: string;
|
|
50
|
+
fee: number;
|
|
51
|
+
sender: string;
|
|
52
|
+
'first-valid': number;
|
|
53
|
+
'last-valid': number;
|
|
54
|
+
'confirmed-round'?: number;
|
|
55
|
+
group?: string;
|
|
56
|
+
note?: string;
|
|
57
|
+
logs?: string[];
|
|
58
|
+
'round-time'?: number;
|
|
59
|
+
'intra-round-offset'?: number;
|
|
60
|
+
signature?: TransactionSignature;
|
|
61
|
+
'application-transaction'?: ApplicationTransactionResult;
|
|
62
|
+
'created-application-index'?: number;
|
|
63
|
+
'asset-config-transaction': AssetConfigTransactionResult;
|
|
64
|
+
'created-asset-index'?: number;
|
|
65
|
+
'asset-freeze-transaction'?: AssetFreezeTransactionResult;
|
|
66
|
+
'asset-transfer-transaction'?: AssetTransferTransactionResult;
|
|
67
|
+
'keyreg-transaction'?: any;
|
|
68
|
+
'payment-transaction'?: PaymentTransactionResult;
|
|
69
|
+
'auth-addr'?: string;
|
|
70
|
+
'closing-amount'?: number;
|
|
71
|
+
'genesis-hash'?: string;
|
|
72
|
+
'genesis-id'?: string;
|
|
73
|
+
'inner-txns'?: TransactionResult[];
|
|
74
|
+
'rekey-to'?: string;
|
|
75
|
+
lease?: string;
|
|
76
|
+
'local-state-delta'?: Record<string, EvalDelta>[];
|
|
77
|
+
'global-state-delta'?: Record<string, EvalDelta>[];
|
|
78
|
+
'receiver-rewards'?: number;
|
|
79
|
+
'sender-rewards'?: number;
|
|
80
|
+
'close-rewards'?: number;
|
|
81
|
+
'tx-type': TransactionType;
|
|
82
|
+
}
|
|
83
|
+
export interface AccountResult {
|
|
84
|
+
address: string;
|
|
85
|
+
amount: number;
|
|
86
|
+
'amount-without-pending-rewards': number;
|
|
87
|
+
'apps-local-state'?: AppLocalState[];
|
|
88
|
+
'apps-total-extra-pages'?: number;
|
|
89
|
+
'apps-total-schema'?: StateSchema;
|
|
90
|
+
'auth-addr'?: string;
|
|
91
|
+
'closed-at-round'?: number;
|
|
92
|
+
'created-at-round'?: number;
|
|
93
|
+
deleted?: boolean;
|
|
94
|
+
participation: any;
|
|
95
|
+
'pending-rewards': number;
|
|
96
|
+
'reward-base': number;
|
|
97
|
+
rewards: number;
|
|
98
|
+
round: number;
|
|
99
|
+
'sig-type': SignatureType;
|
|
100
|
+
status: AccountStatus;
|
|
101
|
+
}
|
|
102
|
+
export interface PaymentTransactionResult {
|
|
103
|
+
amount: number;
|
|
104
|
+
'close-amount'?: number;
|
|
105
|
+
'close-remainder-to'?: string;
|
|
106
|
+
receiver: string;
|
|
107
|
+
}
|
|
108
|
+
export interface ApplicationTransactionResult extends Exclude<{
|
|
109
|
+
creator: string;
|
|
110
|
+
'global-state': TealKeyValue[];
|
|
111
|
+
}, ApplicationParams> {
|
|
112
|
+
'application-id': number;
|
|
113
|
+
'on-completion': ApplicationOnComplete;
|
|
114
|
+
'application-args'?: string[];
|
|
115
|
+
accounts?: string[];
|
|
116
|
+
'foreign-apps'?: number[];
|
|
117
|
+
'foreign-assets'?: number[];
|
|
118
|
+
}
|
|
119
|
+
export interface AssetConfigTransactionResult {
|
|
120
|
+
'asset-id': number;
|
|
121
|
+
params: AssetParams;
|
|
122
|
+
}
|
|
123
|
+
export interface AssetFreezeTransactionResult {
|
|
124
|
+
address: string;
|
|
125
|
+
'asset-id': number;
|
|
126
|
+
'new-freeze-status': boolean;
|
|
127
|
+
}
|
|
128
|
+
export interface AssetTransferTransactionResult {
|
|
129
|
+
amount: number;
|
|
130
|
+
'asset-id': number;
|
|
131
|
+
'close-amount'?: number;
|
|
132
|
+
'close-to'?: string;
|
|
133
|
+
receiver?: string;
|
|
134
|
+
sender?: string;
|
|
135
|
+
}
|
|
136
|
+
export interface AssetResult {
|
|
137
|
+
index: number;
|
|
138
|
+
deleted?: boolean;
|
|
139
|
+
'created-at-round': number;
|
|
140
|
+
'deleted-at-round': number;
|
|
141
|
+
params: AssetParams;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* The result of looking up an application
|
|
145
|
+
*/
|
|
146
|
+
export interface ApplicationResult {
|
|
147
|
+
id: number;
|
|
148
|
+
params: ApplicationParams;
|
|
149
|
+
'created-at-round'?: number;
|
|
150
|
+
deleted?: boolean;
|
|
151
|
+
'deleted-at-round'?: number;
|
|
152
|
+
}
|
|
153
|
+
interface TransactionSignature {
|
|
154
|
+
logicsig: LogicTransactionSignature;
|
|
155
|
+
multisig: MultisigTransactionSignature;
|
|
156
|
+
sig: string;
|
|
157
|
+
}
|
|
158
|
+
interface LogicTransactionSignature {
|
|
159
|
+
args: string[];
|
|
160
|
+
logic: string;
|
|
161
|
+
'multisig-signature': MultisigTransactionSignature;
|
|
162
|
+
signature: string;
|
|
163
|
+
}
|
|
164
|
+
interface MultisigTransactionSignature {
|
|
165
|
+
subsignature: MultisigTransactionSubSignature;
|
|
166
|
+
threshold: number;
|
|
167
|
+
version: number;
|
|
168
|
+
}
|
|
169
|
+
interface MultisigTransactionSubSignature {
|
|
170
|
+
'public-key': string;
|
|
171
|
+
signature: string;
|
|
172
|
+
}
|
|
173
|
+
export interface EvalDelta {
|
|
174
|
+
action: number;
|
|
175
|
+
bytes: string;
|
|
176
|
+
uint: number;
|
|
177
|
+
}
|
|
178
|
+
interface ApplicationParams {
|
|
179
|
+
creator: string;
|
|
180
|
+
'approval-program': string;
|
|
181
|
+
'clear-state-program': string;
|
|
182
|
+
'extra-program-pages'?: number;
|
|
183
|
+
'global-state': TealKeyValue[];
|
|
184
|
+
'global-state-schema'?: StateSchema;
|
|
185
|
+
'local-state-schema'?: StateSchema;
|
|
186
|
+
}
|
|
187
|
+
interface StateSchema {
|
|
188
|
+
'num-byte-slice': number;
|
|
189
|
+
'num-uint': number;
|
|
190
|
+
}
|
|
191
|
+
export declare enum ApplicationOnComplete {
|
|
192
|
+
noop = "noop",
|
|
193
|
+
optin = "optin",
|
|
194
|
+
closeout = "closeout",
|
|
195
|
+
clear = "clear",
|
|
196
|
+
update = "update",
|
|
197
|
+
delete = "delete"
|
|
198
|
+
}
|
|
199
|
+
interface AssetParams {
|
|
200
|
+
/**
|
|
201
|
+
* The address that created this asset. This is the address where the parameters
|
|
202
|
+
* for this asset can be found, and also the address where unwanted asset units can
|
|
203
|
+
* be sent in the worst case.
|
|
204
|
+
*/
|
|
205
|
+
creator: string;
|
|
206
|
+
/**
|
|
207
|
+
* (dc) The number of digits to use after the decimal point when displaying this
|
|
208
|
+
* asset. If 0, the asset is not divisible. If 1, the base unit of the asset is in
|
|
209
|
+
* tenths. If 2, the base unit of the asset is in hundredths, and so on. This value
|
|
210
|
+
* must be between 0 and 19 (inclusive).
|
|
211
|
+
*/
|
|
212
|
+
decimals: number | bigint;
|
|
213
|
+
/**
|
|
214
|
+
* (t) The total number of units of this asset.
|
|
215
|
+
*/
|
|
216
|
+
total: number | bigint;
|
|
217
|
+
/**
|
|
218
|
+
* (c) Address of account used to clawback holdings of this asset. If empty,
|
|
219
|
+
* clawback is not permitted.
|
|
220
|
+
*/
|
|
221
|
+
clawback?: string;
|
|
222
|
+
/**
|
|
223
|
+
* (df) Whether holdings of this asset are frozen by default.
|
|
224
|
+
*/
|
|
225
|
+
'default-frozen'?: boolean;
|
|
226
|
+
/**
|
|
227
|
+
* (f) Address of account used to freeze holdings of this asset. If empty, freezing
|
|
228
|
+
* is not permitted.
|
|
229
|
+
*/
|
|
230
|
+
freeze?: string;
|
|
231
|
+
/**
|
|
232
|
+
* (m) Address of account used to manage the keys of this asset and to destroy it.
|
|
233
|
+
*/
|
|
234
|
+
manager?: string;
|
|
235
|
+
/**
|
|
236
|
+
* (am) A commitment to some unspecified asset metadata. The format of this
|
|
237
|
+
* metadata is up to the application.
|
|
238
|
+
*/
|
|
239
|
+
'metadata-hash'?: Uint8Array;
|
|
240
|
+
/**
|
|
241
|
+
* (an) Name of this asset, as supplied by the creator. Included only when the
|
|
242
|
+
* asset name is composed of printable utf-8 characters.
|
|
243
|
+
*/
|
|
244
|
+
name?: string;
|
|
245
|
+
/**
|
|
246
|
+
* Base64 encoded name of this asset, as supplied by the creator.
|
|
247
|
+
*/
|
|
248
|
+
'name-b64'?: Uint8Array;
|
|
249
|
+
/**
|
|
250
|
+
* (r) Address of account holding reserve (non-minted) units of this asset.
|
|
251
|
+
*/
|
|
252
|
+
reserve?: string;
|
|
253
|
+
/**
|
|
254
|
+
* (un) Name of a unit of this asset, as supplied by the creator. Included only
|
|
255
|
+
* when the name of a unit of this asset is composed of printable utf-8 characters.
|
|
256
|
+
*/
|
|
257
|
+
'unit-name'?: string;
|
|
258
|
+
/**
|
|
259
|
+
* Base64 encoded name of a unit of this asset, as supplied by the creator.
|
|
260
|
+
*/
|
|
261
|
+
'unit-name-b64'?: Uint8Array;
|
|
262
|
+
/**
|
|
263
|
+
* (au) URL where more information about the asset can be retrieved. Included only
|
|
264
|
+
* when the URL is composed of printable utf-8 characters.
|
|
265
|
+
*/
|
|
266
|
+
url?: string;
|
|
267
|
+
/**
|
|
268
|
+
* Base64 encoded URL where more information about the asset can be retrieved.
|
|
269
|
+
*/
|
|
270
|
+
'url-b64'?: Uint8Array;
|
|
271
|
+
}
|
|
272
|
+
export declare enum SignatureType {
|
|
273
|
+
sig = "sig",
|
|
274
|
+
msig = "msig",
|
|
275
|
+
lsig = "lsig"
|
|
276
|
+
}
|
|
277
|
+
export declare enum AccountStatus {
|
|
278
|
+
Offline = "Offline",
|
|
279
|
+
Online = "Online",
|
|
280
|
+
NotParticipating = "NotParticipating"
|
|
281
|
+
}
|
|
282
|
+
interface AppLocalState {
|
|
283
|
+
'closed-out-at-round': number;
|
|
284
|
+
deleted: boolean;
|
|
285
|
+
id: number;
|
|
286
|
+
'key-value': TealKeyValue[];
|
|
287
|
+
'opted-in-at-round': number;
|
|
288
|
+
schema: StateSchema;
|
|
289
|
+
}
|
|
290
|
+
export interface AssetHolding {
|
|
291
|
+
/**
|
|
292
|
+
* (a) number of units held.
|
|
293
|
+
*/
|
|
294
|
+
amount: number;
|
|
295
|
+
/**
|
|
296
|
+
* Asset ID of the holding.
|
|
297
|
+
*/
|
|
298
|
+
'asset-id': number;
|
|
299
|
+
/**
|
|
300
|
+
* Address that created this asset. This is the address where the parameters for
|
|
301
|
+
* this asset can be found, and also the address where unwanted asset units can be
|
|
302
|
+
* sent in the worst case.
|
|
303
|
+
*/
|
|
304
|
+
creator: string;
|
|
305
|
+
/**
|
|
306
|
+
* (f) whether or not the holding is frozen.
|
|
307
|
+
*/
|
|
308
|
+
'is-frozen': boolean;
|
|
309
|
+
deleted?: boolean;
|
|
310
|
+
'opted-in-at-round': number;
|
|
311
|
+
'opted-out-at-round': number;
|
|
312
|
+
}
|
|
313
|
+
export {};
|
|
314
|
+
//# sourceMappingURL=indexer-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexer-type.d.ts","sourceRoot":"","sources":["../src/indexer-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,SAAS,CAAA;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,iDAAiD,CAAA;AAE9E,gFAAgF;AAChF,MAAM,WAAW,wBAAwB;IACvC,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,iBAAiB,EAAE,CAAA;CAClC;AAED,sFAAsF;AACtF,MAAM,WAAW,mBAAmB;IAClC,eAAe,EAAE,MAAM,CAAA;IACvB,OAAO,EAAE,aAAa,CAAA;CACvB;AAED,4FAA4F;AAC5F,MAAM,WAAW,kBAAkB;IACjC,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,YAAY,EAAE,CAAA;CACvB;AAED,oGAAoG;AACpG,MAAM,WAAW,yBAAyB;IACxC,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,MAAM,EAAE,WAAW,EAAE,CAAA;CACtB;AAED,0GAA0G;AAC1G,MAAM,WAAW,8BAA8B;IAC7C,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,EAAE,MAAM,CAAA;IACpB,YAAY,EAAE,iBAAiB,EAAE,CAAA;CAClC;AAED,kFAAkF;AAClF,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE,MAAM,CAAA;IACvB,KAAK,EAAE,WAAW,CAAA;CACnB;AAED,oFAAoF;AACpF,MAAM,WAAW,uBAAuB;IACtC,eAAe,EAAE,MAAM,CAAA;IACvB,WAAW,EAAE,iBAAiB,CAAA;CAC/B;AAED,8FAA8F;AAC9F,MAAM,WAAW,uBAAuB;IACtC,eAAe,EAAE,MAAM,CAAA;IACvB,WAAW,EAAE,iBAA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M,CAAA;IACb;;OAEG;IACH,UAAU,CAAC,EAAE,UAAU,CAAA;IACvB;;OAEG;IACH,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB;;OAEG;IACH,eAAe,CAAC,EAAE,UAAU,CAAA;IAC5B;;;OAGG;IACH,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ;;OAEG;IACH,SAAS,CAAC,EAAE,UAAU,CAAA;CACvB;AAED,oBAAY,aAAa;IACvB,GAAG,QAAQ;IACX,IAAI,SAAS;IACb,IAAI,SAAS;CACd;AAED,oBAAY,aAAa;IACvB,OAAO,YAAY;IACnB,MAAM,WAAW;IACjB,gBAAgB,qBAAqB;CACtC;AAED,UAAU,aAAa;IACrB,qBAAqB,EAAE,MAAM,CAAA;IAC7B,OAAO,EAAE,OAAO,CAAA;IAChB,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,EAAE,YAAY,EAAE,CAAA;IAC3B,mBAAmB,EAAE,MAAM,CAAA;IAC3B,MAAM,EAAE,WAAW,CAAA;CACpB;AAED,MAAM,WAAW,YAAY;IAC3B;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IACd;;OAEG;IACH,UAAU,EAAE,MAAM,CAAA;IAClB;;;;OAIG;IACH,OAAO,EAAE,MAAM,CAAA;IACf;;OAEG;IACH,WAAW,EAAE,OAAO,CAAA;IACpB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,mBAAmB,EAAE,MAAM,CAAA;IAC3B,oBAAoB,EAAE,MAAM,CAAA;CAC7B"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AccountStatus = exports.SignatureType = exports.ApplicationOnComplete = void 0;
|
|
4
|
+
var ApplicationOnComplete;
|
|
5
|
+
(function (ApplicationOnComplete) {
|
|
6
|
+
ApplicationOnComplete["noop"] = "noop";
|
|
7
|
+
ApplicationOnComplete["optin"] = "optin";
|
|
8
|
+
ApplicationOnComplete["closeout"] = "closeout";
|
|
9
|
+
ApplicationOnComplete["clear"] = "clear";
|
|
10
|
+
ApplicationOnComplete["update"] = "update";
|
|
11
|
+
ApplicationOnComplete["delete"] = "delete";
|
|
12
|
+
})(ApplicationOnComplete = exports.ApplicationOnComplete || (exports.ApplicationOnComplete = {}));
|
|
13
|
+
var SignatureType;
|
|
14
|
+
(function (SignatureType) {
|
|
15
|
+
SignatureType["sig"] = "sig";
|
|
16
|
+
SignatureType["msig"] = "msig";
|
|
17
|
+
SignatureType["lsig"] = "lsig";
|
|
18
|
+
})(SignatureType = exports.SignatureType || (exports.SignatureType = {}));
|
|
19
|
+
var AccountStatus;
|
|
20
|
+
(function (AccountStatus) {
|
|
21
|
+
AccountStatus["Offline"] = "Offline";
|
|
22
|
+
AccountStatus["Online"] = "Online";
|
|
23
|
+
AccountStatus["NotParticipating"] = "NotParticipating";
|
|
24
|
+
})(AccountStatus = exports.AccountStatus || (exports.AccountStatus = {}));
|
|
25
|
+
//# sourceMappingURL=indexer-type.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexer-type.js","sourceRoot":"","sources":["../src/indexer-type.ts"],"names":[],"mappings":";;;AAoNA,IAAY,qBAOX;AAPD,WAAY,qBAAqB;IAC/B,sCAAa,CAAA;IACb,wCAAe,CAAA;IACf,8CAAqB,CAAA;IACrB,wCAAe,CAAA;IACf,0CAAiB,CAAA;IACjB,0CAAiB,CAAA;AACnB,CAAC,EAPW,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAOhC;AA4ED,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,4BAAW,CAAA;IACX,8BAAa,CAAA;IACb,8BAAa,CAAA;AACf,CAAC,EAJW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAIxB;AAED,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,oCAAmB,CAAA;IACnB,kCAAiB,CAAA;IACjB,sDAAqC,CAAA;AACvC,CAAC,EAJW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAIxB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { Account, Algodv2, Kmd } from 'algosdk';
|
|
2
|
+
import { AlgoAmount } from './algo-amount';
|
|
3
|
+
/** Returns true if the algod client is pointing to a LocalNet Algorand network */
|
|
4
|
+
export declare function isLocalNet(algod: Algodv2): Promise<boolean>;
|
|
5
|
+
/**
|
|
6
|
+
* Gets an account with private key loaded from a KMD wallet of the given name, or alternatively creates one with funds in it via a KMD wallet of the given name.
|
|
7
|
+
*
|
|
8
|
+
* This is useful to get idempotent accounts from a local sandbox without having to specify the private key (which will change when resetting the sandbox).
|
|
9
|
+
*
|
|
10
|
+
* This significantly speeds up local dev time and improves experience since you can write code that *just works* first go without manual config in a fresh sandbox.
|
|
11
|
+
*
|
|
12
|
+
* If this is used via @see {getAccount}, then you can even use the same code that runs on production without changes for local development!
|
|
13
|
+
*
|
|
14
|
+
* @param walletAccount The wallet details with:
|
|
15
|
+
* * `name`: The name of the wallet to retrieve / create
|
|
16
|
+
* * `fundWith`: The number of Algos to fund the account with it it gets created, if not specified then 1000 Algos will be funded from the dispenser account @see {getDispenserAccount}
|
|
17
|
+
* @param algod An algod client
|
|
18
|
+
* @param kmdClient A KMD client, if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
|
|
19
|
+
*
|
|
20
|
+
* @returns An Algorand account with private key loaded - either one that already existed in the given KMD wallet, or a new one that is funded for you
|
|
21
|
+
*/
|
|
22
|
+
export declare function getOrCreateKmdWalletAccount(walletAccount: {
|
|
23
|
+
name: string;
|
|
24
|
+
fundWith?: AlgoAmount;
|
|
25
|
+
}, algod: Algodv2, kmdClient?: Kmd): Promise<Account>;
|
|
26
|
+
/**
|
|
27
|
+
* Returns an Algorand account with private key loaded from the given KMD wallet (identified by name).
|
|
28
|
+
*
|
|
29
|
+
* @param walletAccount The details of the wallet, with:
|
|
30
|
+
* * `name`: The name of the wallet to retrieve an account from
|
|
31
|
+
* * `predicate`: An optional filter to use to find the account (otherwise it will return a random account from the wallet)
|
|
32
|
+
* @param algod An algod client
|
|
33
|
+
* @param kmdClient A KMD client, if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
|
|
34
|
+
* @example Get default funded account in a LocalNet
|
|
35
|
+
*
|
|
36
|
+
* ```
|
|
37
|
+
* const defaultDispenserAccount = await getKmdWalletAccount(algod,
|
|
38
|
+
* 'unencrypted-default-wallet',
|
|
39
|
+
* a => a.status !== 'Offline' && a.amount > 1_000_000_000
|
|
40
|
+
* )
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function getKmdWalletAccount(walletAccount: {
|
|
44
|
+
name: string;
|
|
45
|
+
predicate?: (account: Record<string, any>) => boolean;
|
|
46
|
+
}, algod: Algodv2, kmdClient?: Kmd): Promise<Account | undefined>;
|
|
47
|
+
/**
|
|
48
|
+
* Returns an Algorand account with private key loaded for the default LocalNet dispenser account (that can be used to fund other accounts)
|
|
49
|
+
*
|
|
50
|
+
* @param algod An algod client
|
|
51
|
+
* @param kmdClient A KMD client, if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
|
|
52
|
+
*/
|
|
53
|
+
export declare function getLocalNetDispenserAccount(algod: Algodv2, kmdClient?: Kmd): Promise<Account>;
|
|
54
|
+
//# sourceMappingURL=localnet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localnet.d.ts","sourceRoot":"","sources":["../src/localnet.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AAExD,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAA;AAK1C,kFAAkF;AAClF,wBAAsB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAIjE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,2BAA2B,CAC/C,aAAa,EAAE;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,EAAE,UAAU,CAAA;CAAE,EACtD,KAAK,EAAE,OAAO,EACd,SAAS,CAAC,EAAE,GAAG,GACd,OAAO,CAAC,OAAO,CAAC,CAmClB;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAsB,mBAAmB,CACvC,aAAa,EAAE;IACb,IAAI,EAAE,MAAM,CAAA;IAEZ,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,KAAK,OAAO,CAAA;CACtD,EACD,KAAK,EAAE,OAAO,EACd,SAAS,CAAC,EAAE,GAAG,GACd,OAAO,CAAC,OAAO,GAAG,SAAS,CAAC,CAmC9B;AAED;;;;;GAKG;AACH,wBAAsB,2BAA2B,CAAC,KAAK,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,GAAG,GAAG,OAAO,CAAC,OAAO,CAAC,CAWnG"}
|
package/dist/localnet.js
ADDED
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.getLocalNetDispenserAccount = exports.getKmdWalletAccount = exports.getOrCreateKmdWalletAccount = exports.isLocalNet = void 0;
|
|
7
|
+
const algosdk_1 = __importDefault(require("algosdk"));
|
|
8
|
+
const account_1 = require("./account");
|
|
9
|
+
const algo_amount_1 = require("./algo-amount");
|
|
10
|
+
const config_1 = require("./config");
|
|
11
|
+
const network_client_1 = require("./network-client");
|
|
12
|
+
const transfer_1 = require("./transfer");
|
|
13
|
+
/** Returns true if the algod client is pointing to a LocalNet Algorand network */
|
|
14
|
+
async function isLocalNet(algod) {
|
|
15
|
+
const params = await algod.getTransactionParams().do();
|
|
16
|
+
return params.genesisID === 'devnet-v1' || params.genesisID === 'sandnet-v1';
|
|
17
|
+
}
|
|
18
|
+
exports.isLocalNet = isLocalNet;
|
|
19
|
+
/**
|
|
20
|
+
* Gets an account with private key loaded from a KMD wallet of the given name, or alternatively creates one with funds in it via a KMD wallet of the given name.
|
|
21
|
+
*
|
|
22
|
+
* This is useful to get idempotent accounts from a local sandbox without having to specify the private key (which will change when resetting the sandbox).
|
|
23
|
+
*
|
|
24
|
+
* This significantly speeds up local dev time and improves experience since you can write code that *just works* first go without manual config in a fresh sandbox.
|
|
25
|
+
*
|
|
26
|
+
* If this is used via @see {getAccount}, then you can even use the same code that runs on production without changes for local development!
|
|
27
|
+
*
|
|
28
|
+
* @param walletAccount The wallet details with:
|
|
29
|
+
* * `name`: The name of the wallet to retrieve / create
|
|
30
|
+
* * `fundWith`: The number of Algos to fund the account with it it gets created, if not specified then 1000 Algos will be funded from the dispenser account @see {getDispenserAccount}
|
|
31
|
+
* @param algod An algod client
|
|
32
|
+
* @param kmdClient A KMD client, if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
|
|
33
|
+
*
|
|
34
|
+
* @returns An Algorand account with private key loaded - either one that already existed in the given KMD wallet, or a new one that is funded for you
|
|
35
|
+
*/
|
|
36
|
+
async function getOrCreateKmdWalletAccount(walletAccount, algod, kmdClient) {
|
|
37
|
+
const kmd = kmdClient ?? (0, network_client_1.getAlgoKmdClient)();
|
|
38
|
+
// Get an existing account from the KMD wallet
|
|
39
|
+
const existing = await getKmdWalletAccount(walletAccount, algod, kmd);
|
|
40
|
+
if (existing) {
|
|
41
|
+
return existing;
|
|
42
|
+
}
|
|
43
|
+
// None existed: create the KMD wallet instead
|
|
44
|
+
const walletId = (await kmd.createWallet(walletAccount.name, '')).wallet.id;
|
|
45
|
+
const walletHandle = (await kmd.initWalletHandle(walletId, '')).wallet_handle_token;
|
|
46
|
+
await kmd.generateKey(walletHandle);
|
|
47
|
+
// Get the account from the new KMD wallet
|
|
48
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
49
|
+
const account = (await getKmdWalletAccount(walletAccount, algod, kmd));
|
|
50
|
+
config_1.AlgoKitConfig.logger.info(`Couldn't find existing account in Sandbox under name '${walletAccount.name}'; created account ${account.addr} with keys stored in KMD and funding with ${walletAccount.fundWith?.algos ?? 1000} ALGOs`);
|
|
51
|
+
// Fund the account from the dispenser
|
|
52
|
+
await (0, transfer_1.transferAlgos)({
|
|
53
|
+
amount: walletAccount.fundWith ?? algo_amount_1.AlgoAmount.Algos(1000),
|
|
54
|
+
from: await (0, account_1.getDispenserAccount)(algod),
|
|
55
|
+
to: account.addr,
|
|
56
|
+
}, algod);
|
|
57
|
+
return account;
|
|
58
|
+
}
|
|
59
|
+
exports.getOrCreateKmdWalletAccount = getOrCreateKmdWalletAccount;
|
|
60
|
+
/**
|
|
61
|
+
* Returns an Algorand account with private key loaded from the given KMD wallet (identified by name).
|
|
62
|
+
*
|
|
63
|
+
* @param walletAccount The details of the wallet, with:
|
|
64
|
+
* * `name`: The name of the wallet to retrieve an account from
|
|
65
|
+
* * `predicate`: An optional filter to use to find the account (otherwise it will return a random account from the wallet)
|
|
66
|
+
* @param algod An algod client
|
|
67
|
+
* @param kmdClient A KMD client, if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
|
|
68
|
+
* @example Get default funded account in a LocalNet
|
|
69
|
+
*
|
|
70
|
+
* ```
|
|
71
|
+
* const defaultDispenserAccount = await getKmdWalletAccount(algod,
|
|
72
|
+
* 'unencrypted-default-wallet',
|
|
73
|
+
* a => a.status !== 'Offline' && a.amount > 1_000_000_000
|
|
74
|
+
* )
|
|
75
|
+
* ```
|
|
76
|
+
*/
|
|
77
|
+
async function getKmdWalletAccount(walletAccount, algod, kmdClient) {
|
|
78
|
+
const { name, predicate } = walletAccount;
|
|
79
|
+
const kmd = kmdClient ?? (0, network_client_1.getAlgoKmdClient)();
|
|
80
|
+
const wallets = await kmd.listWallets();
|
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
82
|
+
const wallet = wallets.wallets.filter((w) => w.name === name);
|
|
83
|
+
if (wallet.length === 0) {
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
const walletId = wallet[0].id;
|
|
87
|
+
const walletHandle = (await kmd.initWalletHandle(walletId, '')).wallet_handle_token;
|
|
88
|
+
const keyIds = (await kmd.listKeys(walletHandle)).addresses;
|
|
89
|
+
let i = 0;
|
|
90
|
+
if (predicate) {
|
|
91
|
+
for (i = 0; i < keyIds.length; i++) {
|
|
92
|
+
const key = keyIds[i];
|
|
93
|
+
const account = await algod.accountInformation(key).do();
|
|
94
|
+
if (predicate(account)) {
|
|
95
|
+
break;
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
if (i >= keyIds.length) {
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
102
|
+
const accountKey = (await kmd.exportKey(walletHandle, '', keyIds[i])).private_key;
|
|
103
|
+
const accountMnemonic = algosdk_1.default.secretKeyToMnemonic(accountKey);
|
|
104
|
+
return (0, account_1.getAccountFromMnemonic)(accountMnemonic);
|
|
105
|
+
}
|
|
106
|
+
exports.getKmdWalletAccount = getKmdWalletAccount;
|
|
107
|
+
/**
|
|
108
|
+
* Returns an Algorand account with private key loaded for the default LocalNet dispenser account (that can be used to fund other accounts)
|
|
109
|
+
*
|
|
110
|
+
* @param algod An algod client
|
|
111
|
+
* @param kmdClient A KMD client, if not specified then a default KMD client will be loaded from environment variables @see {getAlgoKmdClient}
|
|
112
|
+
*/
|
|
113
|
+
async function getLocalNetDispenserAccount(algod, kmdClient) {
|
|
114
|
+
if (!(await isLocalNet(algod))) {
|
|
115
|
+
throw "Can't get default account from non LocalNet network";
|
|
116
|
+
}
|
|
117
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
118
|
+
return (await getKmdWalletAccount({ name: 'unencrypted-default-wallet', predicate: (a) => a.status !== 'Offline' && a.amount > 1000000000 }, algod, kmdClient));
|
|
119
|
+
}
|
|
120
|
+
exports.getLocalNetDispenserAccount = getLocalNetDispenserAccount;
|
|
121
|
+
//# sourceMappingURL=localnet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"localnet.js","sourceRoot":"","sources":["../src/localnet.ts"],"names":[],"mappings":";;;;;;AAAA,sDAAwD;AACxD,uCAAuE;AACvE,+CAA0C;AAC1C,qCAAwC;AACxC,qDAAmD;AACnD,yCAA0C;AAE1C,kFAAkF;AAC3E,KAAK,UAAU,UAAU,CAAC,KAAc;IAC7C,MAAM,MAAM,GAAG,MAAM,KAAK,CAAC,oBAAoB,EAAE,CAAC,EAAE,EAAE,CAAA;IAEtD,OAAO,MAAM,CAAC,SAAS,KAAK,WAAW,IAAI,MAAM,CAAC,SAAS,KAAK,YAAY,CAAA;AAC9E,CAAC;AAJD,gCAIC;AAED;;;;;;;;;;;;;;;;GAgBG;AACI,KAAK,UAAU,2BAA2B,CAC/C,aAAsD,EACtD,KAAc,EACd,SAAe;IAEf,MAAM,GAAG,GAAG,SAAS,IAAI,IAAA,iCAAgB,GAAE,CAAA;IAE3C,8CAA8C;IAC9C,MAAM,QAAQ,GAAG,MAAM,mBAAmB,CAAC,aAAa,EAAE,KAAK,EAAE,GAAG,CAAC,CAAA;IACrE,IAAI,QAAQ,EAAE;QACZ,OAAO,QAAQ,CAAA;KAChB;IAED,8CAA8C;IAC9C,MAAM,QAAQ,GAAG,CAAC,MAAM,GAAG,CAAC,YAAY,CAAC,aAAa,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,CAAA;IAC3E,MAAM,YAAY,GAAG,CAAC,MAAM,GAAG,CAAC,gBAAgB,CAAC,QAAQ,EAAE,EAAE,CAAC,CAAC,CAAC,mBAAmB,CAAA;IACnF,MAAM,GAAG,CAAC,WAAW,CAAC,YAAY,CAAC,CAAA;IAEnC,0CA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,KAAK,EACL,SAAS,CACV,CAAE,CAAA;AACL,CAAC;AAXD,kEAWC"}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { Algodv2, Indexer, Kmd } from 'algosdk';
|
|
2
|
+
import { TokenHeader } from 'algosdk/dist/types/client/urlTokenBaseHTTPClient';
|
|
3
|
+
/** Config for an Algorand SDK client */
|
|
4
|
+
export interface AlgoClientConfig {
|
|
5
|
+
/** Base URL of the server e.g. http://localhost, https://testnet-api.algonode.cloud/, etc. */
|
|
6
|
+
server: string;
|
|
7
|
+
/** The port to use e.g. 4001, 443, etc. */
|
|
8
|
+
port?: string | number;
|
|
9
|
+
/** The token to use for API authentication (or undefined if none needed) - can be a string, or an object with the header key => value */
|
|
10
|
+
token?: string | TokenHeader;
|
|
11
|
+
}
|
|
12
|
+
/** Retrieve the algod configuration from environment variables (expects to be called from a Node.js environment not algod-side) */
|
|
13
|
+
export declare function getAlgodConfigFromEnvironment(): AlgoClientConfig;
|
|
14
|
+
/** Retrieve the indexer configuration from environment variables (expects to be called from a Node.js environment not algod-side) */
|
|
15
|
+
export declare function getIndexerConfigFromEnvironment(): AlgoClientConfig;
|
|
16
|
+
/** Returns the Algorand configuration to point to the AlgoNode service
|
|
17
|
+
*
|
|
18
|
+
* @param network Which network to connect to - TestNet or MainNet
|
|
19
|
+
* @param config Which algod config to return - Algod or Indexer
|
|
20
|
+
*/
|
|
21
|
+
export declare function getAlgoNodeConfig(network: 'testnet' | 'mainnet', config: 'algod' | 'indexer'): AlgoClientConfig;
|
|
22
|
+
/** Returns the Algorand configuration to point to the default LocalNet
|
|
23
|
+
*
|
|
24
|
+
* @param configOrPort Which algod config to return - algod, kmd, or indexer OR a port number
|
|
25
|
+
*/
|
|
26
|
+
export declare function getDefaultLocalNetConfig(configOrPort: 'algod' | 'indexer' | 'kmd' | number): AlgoClientConfig;
|
|
27
|
+
/** Returns an algod SDK client that automatically retries on idempotent calls
|
|
28
|
+
*
|
|
29
|
+
* @param config The config if you want to override the default (getting config from process.env)
|
|
30
|
+
* @example Default (load from environment variables)
|
|
31
|
+
*
|
|
32
|
+
* ```
|
|
33
|
+
* // Uses process.env.ALGOD_SERVER, process.env.ALGOD_PORT and process.env.ALGOD_TOKEN
|
|
34
|
+
* // Automatically detects if you are using PureStake to switch in the right header name for ALGOD_TOKEN
|
|
35
|
+
* const algod = getAlgoClient()
|
|
36
|
+
* await algod.healthCheck().do()
|
|
37
|
+
* ```
|
|
38
|
+
* @example AlgoNode (testnet)
|
|
39
|
+
* ```
|
|
40
|
+
* const algod = getAlgoClient(getAlgoNodeConfig('testnet', 'algod'))
|
|
41
|
+
* await algod.healthCheck().do()
|
|
42
|
+
* ```
|
|
43
|
+
* @example AlgoNode (mainnet)
|
|
44
|
+
* ```
|
|
45
|
+
* const algod = getAlgoClient(getAlgoNodeConfig('mainnet', 'algod'))
|
|
46
|
+
* await algod.healthCheck().do()
|
|
47
|
+
* ```
|
|
48
|
+
* @example Custom (e.g. default local sandbox, although we recommend loading this into a .env and using the Default option instead)
|
|
49
|
+
* ```
|
|
50
|
+
* const algod = getAlgoClient({server: 'http://localhost', port: '4001', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
51
|
+
* await algod.healthCheck().do()
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare function getAlgoClient(config?: AlgoClientConfig): Algodv2;
|
|
55
|
+
/** Returns an indexer SDK client that automatically retries on idempotent calls
|
|
56
|
+
*
|
|
57
|
+
* @param config The config if you want to override the default (getting config from process.env)
|
|
58
|
+
* @example Default (load from environment variables)
|
|
59
|
+
*
|
|
60
|
+
* ```
|
|
61
|
+
* // Uses process.env.INDEXER_SERVER, process.env.INDEXER_PORT and process.env.INDEXER_TOKEN
|
|
62
|
+
* // Automatically detects if you are using PureStake to switch in the right header name for INDEXER_TOKEN
|
|
63
|
+
* const indexer = getAlgoIndexerClient()
|
|
64
|
+
* await indexer.makeHealthCheck().do()
|
|
65
|
+
* ```
|
|
66
|
+
* @example AlgoNode (testnet)
|
|
67
|
+
* ```
|
|
68
|
+
* const indexer = getAlgoIndexerClient(getAlgoNodeConfig('testnet', 'indexer'))
|
|
69
|
+
* await indexer.makeHealthCheck().do()
|
|
70
|
+
* ```
|
|
71
|
+
* @example AlgoNode (mainnet)
|
|
72
|
+
* ```
|
|
73
|
+
* const indexer = getAlgoIndexerClient(getAlgoNodeConfig('mainnet', 'indexer'))
|
|
74
|
+
* await indexer.makeHealthCheck().do()
|
|
75
|
+
* ```
|
|
76
|
+
* @example Custom (e.g. default local sandbox, although we recommend loading this into a .env and using the Default option instead)
|
|
77
|
+
* ```
|
|
78
|
+
* const indexer = getAlgoIndexerClient({server: 'http://localhost', port: '8980', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
79
|
+
* await indexer.makeHealthCheck().do()
|
|
80
|
+
* ```
|
|
81
|
+
*/
|
|
82
|
+
export declare function getAlgoIndexerClient(config?: AlgoClientConfig): Indexer;
|
|
83
|
+
/**
|
|
84
|
+
* Returns a KMD SDK client that automatically retries on idempotent calls
|
|
85
|
+
*
|
|
86
|
+
* KMD client allows you to export private keys, which is useful to get the default account in a sandbox network.
|
|
87
|
+
*
|
|
88
|
+
* @param config The config if you want to override the default (getting config from process.env)
|
|
89
|
+
* @example Default (load from environment variables)
|
|
90
|
+
*
|
|
91
|
+
* ```
|
|
92
|
+
* // Uses process.env.ALGOD_SERVER, process.env.KMD_PORT (or if not specified: port 4002) and process.env.ALGOD_TOKEN
|
|
93
|
+
* const kmd = getAlgoKmdClient()
|
|
94
|
+
* ```
|
|
95
|
+
* @example Custom (e.g. default local sandbox, although we recommend loading this into a .env and using the Default option instead)
|
|
96
|
+
* ```
|
|
97
|
+
* const kmd = getAlgoKmdClient({server: 'http://localhost', port: '4002', token: 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa'})
|
|
98
|
+
* ```
|
|
99
|
+
*/
|
|
100
|
+
export declare function getAlgoKmdClient(config?: AlgoClientConfig): Kmd;
|
|
101
|
+
export { isLocalNet } from './localnet';
|
|
102
|
+
//# sourceMappingURL=network-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"network-client.d.ts","sourceRoot":"","sources":["../src/network-client.ts"],"names":[],"mappings":"AAAA,OAAgB,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,SAAS,CAAA;AACxD,OAAO,EAAE,WAAW,EAAE,MAAM,kDAAkD,CAAA;AAG9E,wCAAwC;AACxC,MAAM,WAAW,gBAAgB;IAC/B,8FAA8F;IAC9F,MAAM,EAAE,MAAM,CAAA;IACd,2CAA2C;IAC3C,IAAI,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB,yIAAyI;IACzI,KAAK,CAAC,EAAE,MAAM,GAAG,WAAW,CAAA;CAC7B;AAED,mIAAmI;AACnI,wBAAgB,6BAA6B,IAAI,gBAAgB,CAchE;AAED,qIAAqI;AACrI,wBAAgB,+BAA+B,IAAI,gBAAgB,CAclE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,SAAS,GAAG,SAAS,EAAE,MAAM,EAAE,OAAO,GAAG,SAAS,GAAG,gBAAgB,CAK/G;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,YAAY,EAAE,OAAO,GAAG,SAAS,GAAG,KAAK,GAAG,MAAM,GAAG,gBAAgB,CAM7G;AAUD;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,aAAa,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAIhE;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAIvE;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,gBAAgB,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,GAAG,CAK/D;AAED,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAA"}
|