@avalabs/glacier-sdk 2.4.1-alpha.10 → 2.4.1-alpha.5

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.
@@ -1,277 +0,0 @@
1
- /* eslint-disable */
2
- /* tslint:disable */
3
- /*
4
- * ---------------------------------------------------------------
5
- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
6
- * ## ##
7
- * ## AUTHOR: acacode ##
8
- * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
9
- * ---------------------------------------------------------------
10
- */
11
-
12
- export interface MoneyDto {
13
- /**
14
- * ISO 4217 currency code.
15
- * @example usd
16
- */
17
- currencyCode:
18
- | 'usd'
19
- | 'eur'
20
- | 'aud'
21
- | 'cad'
22
- | 'chf'
23
- | 'clp'
24
- | 'czk'
25
- | 'dkk'
26
- | 'gbp'
27
- | 'hkd'
28
- | 'huf';
29
-
30
- /**
31
- * Monetary value in base 10 decimals.
32
- * @example 42.42
33
- */
34
- value: number;
35
- }
36
-
37
- export interface NativeTokenBalanceDto {
38
- chainId: string;
39
- name: string;
40
- symbol: string;
41
- decimals: number;
42
- logoUri: string;
43
- price?: MoneyDto;
44
- balance: string;
45
- balanceValue?: MoneyDto;
46
- }
47
-
48
- export interface NativeBalanceDto {
49
- nativeTokenBalance: NativeTokenBalanceDto;
50
- }
51
-
52
- export interface Erc20TokenBalanceDto {
53
- chainId: string;
54
- contractAddress: string;
55
- name: string;
56
- symbol: string;
57
- decimals: number;
58
- tags?: string[];
59
- logoUri?: string;
60
- price?: MoneyDto;
61
- balance: string;
62
- balanceValue?: MoneyDto;
63
- }
64
-
65
- export interface Erc20BalancesDto {
66
- /** A token, which can be sent as `pageToken` to retrieve the next page. If this field is omitted or empty, there are no subsequent pages. */
67
- nextPageToken?: string;
68
- erc20TokenBalances: Erc20TokenBalanceDto[];
69
- }
70
-
71
- export interface Erc721TokenBalanceDto {
72
- chainId: string;
73
- contractAddress: string;
74
- name: string;
75
- symbol: string;
76
- tokenId: string;
77
- tokenUri: string;
78
- }
79
-
80
- export interface Erc721BalancesDto {
81
- /** A token, which can be sent as `pageToken` to retrieve the next page. If this field is omitted or empty, there are no subsequent pages. */
82
- nextPageToken?: string;
83
- erc721TokenBalances: Erc721TokenBalanceDto[];
84
- }
85
-
86
- export interface AddressDto {
87
- /** @example 0x71C7656EC7ab88b098defB751B7401B5f6d8976F */
88
- address: string;
89
- name?: string;
90
- symbol?: string;
91
- tags?: string[];
92
- logoUri?: string;
93
- }
94
-
95
- export interface MethodDto {
96
- /**
97
- * The contract method hash identifier.
98
- * @example 0xa9059cbb
99
- */
100
- methodHash: string;
101
-
102
- /**
103
- * The contract method name including parameter types.
104
- * @example transfer(address,uint256)
105
- */
106
- methodName?: string;
107
- }
108
-
109
- export interface NativeTransactionDto {
110
- /**
111
- * The block number on the chain.
112
- * @example 339
113
- */
114
- blockNumber: string;
115
-
116
- /**
117
- * The block finality timestamp.
118
- * @example 1648672486
119
- */
120
- blockTimestamp: number;
121
-
122
- /**
123
- * The block hash identifier.
124
- * @example 0x17533aeb5193378b9ff441d61728e7a2ebaf10f61fd5310759451627dfca2e7c
125
- */
126
- blockHash: string;
127
-
128
- /**
129
- * The index at which the transaction occured in the block (0-indexed).
130
- * @example 0
131
- */
132
- blockIndex: number;
133
-
134
- /**
135
- * The transaction hash identifier.
136
- * @example 0x3e9303f81be00b4af28515dab7b914bf3dbff209ea10e7071fa24d4af0a112d4
137
- */
138
- txHash: string;
139
-
140
- /**
141
- * The transaction status, which is either 0 (failed) or 1 (successful).
142
- * @example 1
143
- */
144
- txStatus: string;
145
-
146
- /**
147
- * The transaction type.
148
- * @example 1
149
- */
150
- txType: number;
151
-
152
- /**
153
- * The gas limit set for the transaction.
154
- * @example 51373
155
- */
156
- gasLimit: string;
157
-
158
- /**
159
- * The amount of gas used.
160
- * @example 51373
161
- */
162
- gasUsed: string;
163
-
164
- /**
165
- * The gas price denominated by the number of decimals of the native token.
166
- * @example 470000000000
167
- */
168
- gasPrice: string;
169
-
170
- /**
171
- * The nonce used by the sender of the transaction.
172
- * @example 1
173
- */
174
- nonce: string;
175
- from: AddressDto;
176
- to: AddressDto;
177
- method?: MethodDto;
178
-
179
- /** @example 10000000000000000000 */
180
- value: string;
181
- }
182
-
183
- export interface Erc20TokenDto {
184
- /** @example 0x71C7656EC7ab88b098defB751B7401B5f6d8976F */
185
- contractAddress: string;
186
- tokenName: string;
187
- tokenSymbol: string;
188
- tokenDecimals: number;
189
- price?: MoneyDto;
190
- }
191
-
192
- export interface Erc20TransferDetailsDto {
193
- from: AddressDto;
194
- to: AddressDto;
195
- erc20Token: Erc20TokenDto;
196
-
197
- /** @example 10000000000000000000 */
198
- value: string;
199
- }
200
-
201
- export interface Erc721TokenDto {
202
- /** @example 0x71C7656EC7ab88b098defB751B7401B5f6d8976F */
203
- contractAddress: string;
204
- tokenName: string;
205
- tokenSymbol: string;
206
- tokenId: string;
207
- tokenUri: string;
208
- }
209
-
210
- export interface Erc721TransferDetailsDto {
211
- from: AddressDto;
212
- to: AddressDto;
213
- erc721Token: Erc721TokenDto;
214
- }
215
-
216
- export interface InternalTransactionDetailsDto {
217
- from: AddressDto;
218
- to: AddressDto;
219
- internalTxType:
220
- | 'UNKNOWN'
221
- | 'CALL'
222
- | 'CREATE'
223
- | 'CREATE2'
224
- | 'CALLCODE'
225
- | 'DELEGATECALL'
226
- | 'STATICCALL';
227
-
228
- /** @example 10000000000000000000 */
229
- value: string;
230
- isReverted: boolean;
231
- }
232
-
233
- export interface TransactionDetailsDto {
234
- nativeTransaction: NativeTransactionDto;
235
- erc20Transfers?: Erc20TransferDetailsDto[];
236
- erc721Transfers?: Erc721TransferDetailsDto[];
237
- internalTransactions?: InternalTransactionDetailsDto[];
238
- }
239
-
240
- export interface ListTransactionDetailsDto {
241
- /** A token, which can be sent as `pageToken` to retrieve the next page. If this field is omitted or empty, there are no subsequent pages. */
242
- nextPageToken?: string;
243
- transactions: TransactionDetailsDto[];
244
- }
245
-
246
- export interface UtilityAddresses {
247
- multicall?: string;
248
- }
249
-
250
- export interface NetworkToken {
251
- name: string;
252
- symbol: string;
253
- description: string;
254
- decimals: number;
255
- logoUri?: string;
256
- }
257
-
258
- export interface ChainInfoDto {
259
- chainId: string;
260
- chainName: string;
261
- description: string;
262
- platformChainId: string;
263
- subnetId: string;
264
- vmId: string;
265
- vmName: 'EVM' | 'BITCOIN' | 'ETHEREUM';
266
- explorerUrl?: string;
267
- rpcUrl: string;
268
- wsUrl?: string;
269
- isTestnet: boolean;
270
- utilityAddresses?: UtilityAddresses;
271
- networkToken: NetworkToken;
272
- chainLogoUri?: string;
273
- }
274
-
275
- export interface ChainsDto {
276
- chains: ChainInfoDto[];
277
- }
@@ -1,250 +0,0 @@
1
- /* eslint-disable */
2
- /* tslint:disable */
3
- /*
4
- * ---------------------------------------------------------------
5
- * ## THIS FILE WAS GENERATED VIA SWAGGER-TYPESCRIPT-API ##
6
- * ## ##
7
- * ## AUTHOR: acacode ##
8
- * ## SOURCE: https://github.com/acacode/swagger-typescript-api ##
9
- * ---------------------------------------------------------------
10
- */
11
-
12
- export type QueryParamsType = Record<string | number, any>;
13
- export type ResponseFormat = keyof Omit<Body, 'body' | 'bodyUsed'>;
14
-
15
- export interface FullRequestParams extends Omit<RequestInit, 'body'> {
16
- /** set parameter to `true` for call `securityWorker` for this request */
17
- secure?: boolean;
18
- /** request path */
19
- path: string;
20
- /** content type of request body */
21
- type?: ContentType;
22
- /** query params */
23
- query?: QueryParamsType;
24
- /** format of response (i.e. response.json() -> format: "json") */
25
- format?: ResponseFormat;
26
- /** request body */
27
- body?: unknown;
28
- /** base url */
29
- baseUrl?: string;
30
- /** request cancellation token */
31
- cancelToken?: CancelToken;
32
- }
33
-
34
- export type RequestParams = Omit<
35
- FullRequestParams,
36
- 'body' | 'method' | 'query' | 'path'
37
- >;
38
-
39
- export interface ApiConfig<SecurityDataType = unknown> {
40
- baseUrl?: string;
41
- baseApiParams?: Omit<RequestParams, 'baseUrl' | 'cancelToken' | 'signal'>;
42
- securityWorker?: (
43
- securityData: SecurityDataType | null
44
- ) => Promise<RequestParams | void> | RequestParams | void;
45
- customFetch?: typeof fetch;
46
- }
47
-
48
- export interface HttpResponse<D extends unknown, E extends unknown = unknown>
49
- extends Response {
50
- data: D;
51
- error: E;
52
- }
53
-
54
- type CancelToken = Symbol | string | number;
55
-
56
- export enum ContentType {
57
- Json = 'application/json',
58
- FormData = 'multipart/form-data',
59
- UrlEncoded = 'application/x-www-form-urlencoded',
60
- }
61
-
62
- export class HttpClient<SecurityDataType = unknown> {
63
- public baseUrl: string = '';
64
- private securityData: SecurityDataType | null = null;
65
- private securityWorker?: ApiConfig<SecurityDataType>['securityWorker'];
66
- private abortControllers = new Map<CancelToken, AbortController>();
67
- private customFetch = (...fetchParams: Parameters<typeof fetch>) =>
68
- fetch(...fetchParams);
69
-
70
- private baseApiParams: RequestParams = {
71
- credentials: 'same-origin',
72
- headers: {},
73
- redirect: 'follow',
74
- referrerPolicy: 'no-referrer',
75
- };
76
-
77
- constructor(apiConfig: ApiConfig<SecurityDataType> = {}) {
78
- Object.assign(this, apiConfig);
79
- }
80
-
81
- public setSecurityData = (data: SecurityDataType | null) => {
82
- this.securityData = data;
83
- };
84
-
85
- private encodeQueryParam(key: string, value: any) {
86
- const encodedKey = encodeURIComponent(key);
87
- return `${encodedKey}=${encodeURIComponent(
88
- typeof value === 'number' ? value : `${value}`
89
- )}`;
90
- }
91
-
92
- private addQueryParam(query: QueryParamsType, key: string) {
93
- return this.encodeQueryParam(key, query[key]);
94
- }
95
-
96
- private addArrayQueryParam(query: QueryParamsType, key: string) {
97
- const value = query[key];
98
- return value.map((v: any) => this.encodeQueryParam(key, v)).join('&');
99
- }
100
-
101
- protected toQueryString(rawQuery?: QueryParamsType): string {
102
- const query = rawQuery || {};
103
- const keys = Object.keys(query).filter(
104
- (key) => 'undefined' !== typeof query[key]
105
- );
106
- return keys
107
- .map((key) =>
108
- Array.isArray(query[key])
109
- ? this.addArrayQueryParam(query, key)
110
- : this.addQueryParam(query, key)
111
- )
112
- .join('&');
113
- }
114
-
115
- protected addQueryParams(rawQuery?: QueryParamsType): string {
116
- const queryString = this.toQueryString(rawQuery);
117
- return queryString ? `?${queryString}` : '';
118
- }
119
-
120
- private contentFormatters: Record<ContentType, (input: any) => any> = {
121
- [ContentType.Json]: (input: any) =>
122
- input !== null && (typeof input === 'object' || typeof input === 'string')
123
- ? JSON.stringify(input)
124
- : input,
125
- [ContentType.FormData]: (input: any) =>
126
- Object.keys(input || {}).reduce((formData, key) => {
127
- const property = input[key];
128
- formData.append(
129
- key,
130
- property instanceof Blob
131
- ? property
132
- : typeof property === 'object' && property !== null
133
- ? JSON.stringify(property)
134
- : `${property}`
135
- );
136
- return formData;
137
- }, new FormData()),
138
- [ContentType.UrlEncoded]: (input: any) => this.toQueryString(input),
139
- };
140
-
141
- private mergeRequestParams(
142
- params1: RequestParams,
143
- params2?: RequestParams
144
- ): RequestParams {
145
- return {
146
- ...this.baseApiParams,
147
- ...params1,
148
- ...(params2 || {}),
149
- headers: {
150
- ...(this.baseApiParams.headers || {}),
151
- ...(params1.headers || {}),
152
- ...((params2 && params2.headers) || {}),
153
- },
154
- };
155
- }
156
-
157
- private createAbortSignal = (
158
- cancelToken: CancelToken
159
- ): AbortSignal | undefined => {
160
- if (this.abortControllers.has(cancelToken)) {
161
- const abortController = this.abortControllers.get(cancelToken);
162
- if (abortController) {
163
- return abortController.signal;
164
- }
165
- return void 0;
166
- }
167
-
168
- const abortController = new AbortController();
169
- this.abortControllers.set(cancelToken, abortController);
170
- return abortController.signal;
171
- };
172
-
173
- public abortRequest = (cancelToken: CancelToken) => {
174
- const abortController = this.abortControllers.get(cancelToken);
175
-
176
- if (abortController) {
177
- abortController.abort();
178
- this.abortControllers.delete(cancelToken);
179
- }
180
- };
181
-
182
- public request = async <T = any, E = any>({
183
- body,
184
- secure,
185
- path,
186
- type,
187
- query,
188
- format,
189
- baseUrl,
190
- cancelToken,
191
- ...params
192
- }: FullRequestParams): Promise<HttpResponse<T, E>> => {
193
- const secureParams =
194
- ((typeof secure === 'boolean' ? secure : this.baseApiParams.secure) &&
195
- this.securityWorker &&
196
- (await this.securityWorker(this.securityData))) ||
197
- {};
198
- const requestParams = this.mergeRequestParams(params, secureParams);
199
- const queryString = query && this.toQueryString(query);
200
- const payloadFormatter = this.contentFormatters[type || ContentType.Json];
201
- const responseFormat = format || requestParams.format;
202
-
203
- return this.customFetch(
204
- `${baseUrl || this.baseUrl || ''}${path}${
205
- queryString ? `?${queryString}` : ''
206
- }`,
207
- {
208
- ...requestParams,
209
- headers: {
210
- ...(type && type !== ContentType.FormData
211
- ? { 'Content-Type': type }
212
- : {}),
213
- ...(requestParams.headers || {}),
214
- },
215
- signal: cancelToken ? this.createAbortSignal(cancelToken) : void 0,
216
- body:
217
- typeof body === 'undefined' || body === null
218
- ? null
219
- : payloadFormatter(body),
220
- }
221
- ).then(async (response) => {
222
- const r = response as HttpResponse<T, E>;
223
- r.data = null as unknown as T;
224
- r.error = null as unknown as E;
225
-
226
- const data = !responseFormat
227
- ? r
228
- : await response[responseFormat]()
229
- .then((data) => {
230
- if (r.ok) {
231
- r.data = data;
232
- } else {
233
- r.error = data;
234
- }
235
- return r;
236
- })
237
- .catch((e) => {
238
- r.error = e;
239
- return r;
240
- });
241
-
242
- if (cancelToken) {
243
- this.abortControllers.delete(cancelToken);
244
- }
245
-
246
- if (!response.ok) throw data;
247
- return data;
248
- });
249
- };
250
- }