@avalabs/glacier-sdk 2.8.0-alpha.175 → 2.8.0-alpha.176
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/dist/index.d.ts +50 -12
- package/dist/index.js +67 -38
- package/esm/generated/Glacier.d.ts +2 -0
- package/esm/generated/Glacier.js +3 -0
- package/esm/generated/core/CancelablePromise.d.ts +2 -8
- package/esm/generated/core/CancelablePromise.js +38 -36
- package/esm/generated/core/request.js +3 -2
- package/esm/generated/models/RegisterWebhookRequest.d.ts +1 -1
- package/esm/generated/models/RpcErrorDto.d.ts +7 -0
- package/esm/generated/models/RpcErrorResponseDto.d.ts +9 -0
- package/esm/generated/models/RpcRequestBodyDto.d.ts +8 -0
- package/esm/generated/models/RpcSuccessResponseDto.d.ts +7 -0
- package/esm/generated/models/UpdateWebhookRequest.d.ts +1 -1
- package/esm/generated/models/WebhookResponse.d.ts +1 -1
- package/esm/generated/services/RpcService.d.ts +25 -0
- package/esm/generated/services/RpcService.js +24 -0
- package/esm/index.d.ts +5 -0
- package/esm/index.js +1 -0
- package/package.json +3 -3
package/dist/index.d.ts
CHANGED
|
@@ -23,15 +23,9 @@ interface OnCancel {
|
|
|
23
23
|
(cancelHandler: () => void): void;
|
|
24
24
|
}
|
|
25
25
|
declare class CancelablePromise<T> implements Promise<T> {
|
|
26
|
-
|
|
27
|
-
private _isResolved;
|
|
28
|
-
private _isRejected;
|
|
29
|
-
private _isCancelled;
|
|
30
|
-
private readonly _cancelHandlers;
|
|
31
|
-
private readonly _promise;
|
|
32
|
-
private _resolve?;
|
|
33
|
-
private _reject?;
|
|
26
|
+
#private;
|
|
34
27
|
constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void, onCancel: OnCancel) => void);
|
|
28
|
+
get [Symbol.toStringTag](): string;
|
|
35
29
|
then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
36
30
|
catch<TResult = never>(onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
|
|
37
31
|
finally(onFinally?: (() => void) | null): Promise<T>;
|
|
@@ -4108,6 +4102,49 @@ declare class PrimaryNetworkVerticesService {
|
|
|
4108
4102
|
}): CancelablePromise<ListXChainVerticesResponse>;
|
|
4109
4103
|
}
|
|
4110
4104
|
|
|
4105
|
+
type RpcErrorDto = {
|
|
4106
|
+
code: number;
|
|
4107
|
+
message: string;
|
|
4108
|
+
data?: Record<string, any>;
|
|
4109
|
+
};
|
|
4110
|
+
|
|
4111
|
+
type RpcErrorResponseDto = {
|
|
4112
|
+
jsonrpc: string;
|
|
4113
|
+
id?: (string | number);
|
|
4114
|
+
error: RpcErrorDto;
|
|
4115
|
+
};
|
|
4116
|
+
|
|
4117
|
+
type RpcRequestBodyDto = {
|
|
4118
|
+
method: string;
|
|
4119
|
+
params?: Record<string, any>;
|
|
4120
|
+
id?: (string | number);
|
|
4121
|
+
jsonrpc?: string;
|
|
4122
|
+
};
|
|
4123
|
+
|
|
4124
|
+
type RpcSuccessResponseDto = {
|
|
4125
|
+
jsonrpc: string;
|
|
4126
|
+
id?: (string | number);
|
|
4127
|
+
result: Record<string, any>;
|
|
4128
|
+
};
|
|
4129
|
+
|
|
4130
|
+
declare class RpcService {
|
|
4131
|
+
readonly httpRequest: BaseHttpRequest;
|
|
4132
|
+
constructor(httpRequest: BaseHttpRequest);
|
|
4133
|
+
/**
|
|
4134
|
+
* Calls JSON-RPC method
|
|
4135
|
+
* Calls JSON-RPC method.
|
|
4136
|
+
* @returns any
|
|
4137
|
+
* @throws ApiError
|
|
4138
|
+
*/
|
|
4139
|
+
rpc({ chainId, requestBody, }: {
|
|
4140
|
+
/**
|
|
4141
|
+
* A supported evm chain id, chain alias or blockchain id. Use the `/chains` endpoint to get a list of supported chain ids.
|
|
4142
|
+
*/
|
|
4143
|
+
chainId: string;
|
|
4144
|
+
requestBody: (RpcRequestBodyDto | Array<RpcRequestBodyDto>);
|
|
4145
|
+
}): CancelablePromise<(RpcSuccessResponseDto | RpcErrorResponseDto)>;
|
|
4146
|
+
}
|
|
4147
|
+
|
|
4111
4148
|
type TeleporterDestinationTransaction = {
|
|
4112
4149
|
txHash: string;
|
|
4113
4150
|
timestamp: number;
|
|
@@ -4311,7 +4348,7 @@ type WebhookResponse = {
|
|
|
4311
4348
|
/**
|
|
4312
4349
|
* Whether to include traces in the webhook payload.
|
|
4313
4350
|
*/
|
|
4314
|
-
|
|
4351
|
+
includeInternalTxs?: boolean;
|
|
4315
4352
|
/**
|
|
4316
4353
|
* Whether to include logs in the webhook payload.
|
|
4317
4354
|
*/
|
|
@@ -4340,7 +4377,7 @@ type RegisterWebhookRequest = {
|
|
|
4340
4377
|
/**
|
|
4341
4378
|
* Whether to include traces in the webhook payload.
|
|
4342
4379
|
*/
|
|
4343
|
-
|
|
4380
|
+
includeInternalTxs?: boolean;
|
|
4344
4381
|
/**
|
|
4345
4382
|
* Whether to include logs in the webhook payload.
|
|
4346
4383
|
*/
|
|
@@ -4356,7 +4393,7 @@ type UpdateWebhookRequest = {
|
|
|
4356
4393
|
description?: string;
|
|
4357
4394
|
url?: string;
|
|
4358
4395
|
status?: WebhookStatusType;
|
|
4359
|
-
|
|
4396
|
+
includeInternalTxs?: boolean;
|
|
4360
4397
|
includeLogs?: boolean;
|
|
4361
4398
|
};
|
|
4362
4399
|
|
|
@@ -4468,6 +4505,7 @@ declare class Glacier {
|
|
|
4468
4505
|
readonly primaryNetworkTransactions: PrimaryNetworkTransactionsService;
|
|
4469
4506
|
readonly primaryNetworkUtxOs: PrimaryNetworkUtxOsService;
|
|
4470
4507
|
readonly primaryNetworkVertices: PrimaryNetworkVerticesService;
|
|
4508
|
+
readonly rpc: RpcService;
|
|
4471
4509
|
readonly teleporter: TeleporterService;
|
|
4472
4510
|
readonly webhooks: WebhooksService;
|
|
4473
4511
|
readonly request: BaseHttpRequest;
|
|
@@ -4491,4 +4529,4 @@ declare class ApiError extends Error {
|
|
|
4491
4529
|
constructor(request: ApiRequestOptions, response: ApiResult, message: string);
|
|
4492
4530
|
}
|
|
4493
4531
|
|
|
4494
|
-
export { ActiveDelegatorDetails, ActiveValidatorDetails, AddressActivityMetadata, AggregatedAssetAmount, ApiError, AssetAmount, AssetWithPriceInfo, BaseHttpRequest, Blockchain, BlockchainId, BlockchainIds, BlockchainInfo, CChainAtomicBalances, CChainExportTransaction, CChainImportTransaction, CChainSharedAssetBalance, CancelError, CancelablePromise, ChainAddressChainIdMap, ChainAddressChainIdMapListResponse, ChainInfo, ChainStatus, CompletedDelegatorDetails, CompletedValidatorDetails, ContractDeploymentDetails, ContractSubmissionBody, ContractSubmissionErc1155, ContractSubmissionErc20, ContractSubmissionErc721, ContractSubmissionUnknown, CreateEvmTransactionExportRequest, CreatePrimaryNetworkTransactionExportRequest, CurrencyCode, DefaultService, DelegationStatusType, DelegatorsDetails, DeliveredSourceNotIndexedTeleporterMessage, DeliveredTeleporterMessage, EVMInput, EVMOperationType, EVMOutput, Erc1155Contract, Erc1155Token, Erc1155TokenBalance, Erc1155TokenMetadata, Erc1155Transfer, Erc1155TransferDetails, Erc20Contract, Erc20Token, Erc20TokenBalance, Erc20Transfer, Erc20TransferDetails, Erc721Contract, Erc721Token, Erc721TokenBalance, Erc721TokenMetadata, Erc721Transfer, Erc721TransferDetails, EventType, EvmBalancesService, EvmBlock, EvmBlocksService, EvmChainsService, EvmContractsService, EvmNetworkOptions, EvmTransactionsService, FullNativeTransactionDetails, GetChainResponse, GetEvmBlockResponse, GetNativeBalanceResponse, GetNetworkDetailsResponse, GetPrimaryNetworkBlockResponse, GetTransactionResponse, Glacier, GlacierApiFeature, HealthCheckService, HistoricalReward, ImageAsset, InternalTransaction, InternalTransactionDetails, InternalTransactionOpCall, ListBlockchainsResponse, ListCChainAtomicBalancesResponse, ListCChainAtomicTransactionsResponse, ListChainsResponse, ListCollectibleBalancesResponse, ListContractsResponse, ListDelegatorDetailsResponse, ListErc1155BalancesResponse, ListErc1155TransactionsResponse, ListErc20BalancesResponse, ListErc20TransactionsResponse, ListErc721BalancesResponse, ListErc721TransactionsResponse, ListEvmBlocksResponse, ListHistoricalRewardsResponse, ListInternalTransactionsResponse, ListNativeTransactionsResponse, ListNftTokens, ListPChainBalancesResponse, ListPChainTransactionsResponse, ListPChainUtxosResponse, ListPendingRewardsResponse, ListPrimaryNetworkBlocksResponse, ListSubnetsResponse, ListTransactionDetailsResponse, ListTransfersResponse, ListUtxosResponse, ListValidatorDetailsResponse, ListWebhooksResponse, ListXChainBalancesResponse, ListXChainTransactionsResponse, ListXChainVerticesResponse, Method, Money, NativeTokenBalance, NativeTransaction, Network, NetworkToken, NetworkTokenDetails, NetworkType, NextPageToken, NfTsService, NftTokenMetadataStatus, OpenAPI, OpenAPIConfig, OperationStatus, OperationStatusCode, OperationStatusResponse, OperationType, OperationsService, PChainBalance, PChainId, PChainSharedAsset, PChainTransaction, PChainTransactionType, PChainUtxo, PendingDelegatorDetails, PendingReward, PendingTeleporterMessage, PendingValidatorDetails, PricingProviders, PrimaryNetwork, PrimaryNetworkAssetCap, PrimaryNetworkAssetType, PrimaryNetworkBalancesService, PrimaryNetworkBlock, PrimaryNetworkBlocksService, PrimaryNetworkChainInfo, PrimaryNetworkChainName, PrimaryNetworkOperationType, PrimaryNetworkOptions, PrimaryNetworkRewardsService, PrimaryNetworkService, PrimaryNetworkTransactionsService, PrimaryNetworkTxType, PrimaryNetworkUtxOsService, PrimaryNetworkVerticesService, ProposerDetails, RegisterWebhookRequest, RemovedValidatorDetails, ResourceLink, ResourceLinkType, RewardType, Rewards, RichAddress, SharedSecretsResponse, SortOrder, StakingDistribution, Subnet, SubnetOwnershipInfo, TeleporterDestinationTransaction, TeleporterReceipt, TeleporterRewardDetails, TeleporterService, TeleporterSourceTransaction, TransactionDetails, TransactionExportMetadata, TransactionMethodType, TransactionStatus, TransactionVertexDetail, UnknownContract, UpdateContractResponse, UpdateWebhookRequest, UtilityAddresses, Utxo, UtxoCredential, UtxoType, ValidationStatusType, ValidatorHealthDetails, ValidatorsDetails, VmName, WebhookResponse, WebhookStatus, WebhookStatusType, WebhooksService, XChainAssetDetails, XChainBalances, XChainId, XChainLinearTransaction, XChainNonLinearTransaction, XChainSharedAssetBalance, XChainTransactionType, XChainVertex };
|
|
4532
|
+
export { ActiveDelegatorDetails, ActiveValidatorDetails, AddressActivityMetadata, AggregatedAssetAmount, ApiError, AssetAmount, AssetWithPriceInfo, BaseHttpRequest, Blockchain, BlockchainId, BlockchainIds, BlockchainInfo, CChainAtomicBalances, CChainExportTransaction, CChainImportTransaction, CChainSharedAssetBalance, CancelError, CancelablePromise, ChainAddressChainIdMap, ChainAddressChainIdMapListResponse, ChainInfo, ChainStatus, CompletedDelegatorDetails, CompletedValidatorDetails, ContractDeploymentDetails, ContractSubmissionBody, ContractSubmissionErc1155, ContractSubmissionErc20, ContractSubmissionErc721, ContractSubmissionUnknown, CreateEvmTransactionExportRequest, CreatePrimaryNetworkTransactionExportRequest, CurrencyCode, DefaultService, DelegationStatusType, DelegatorsDetails, DeliveredSourceNotIndexedTeleporterMessage, DeliveredTeleporterMessage, EVMInput, EVMOperationType, EVMOutput, Erc1155Contract, Erc1155Token, Erc1155TokenBalance, Erc1155TokenMetadata, Erc1155Transfer, Erc1155TransferDetails, Erc20Contract, Erc20Token, Erc20TokenBalance, Erc20Transfer, Erc20TransferDetails, Erc721Contract, Erc721Token, Erc721TokenBalance, Erc721TokenMetadata, Erc721Transfer, Erc721TransferDetails, EventType, EvmBalancesService, EvmBlock, EvmBlocksService, EvmChainsService, EvmContractsService, EvmNetworkOptions, EvmTransactionsService, FullNativeTransactionDetails, GetChainResponse, GetEvmBlockResponse, GetNativeBalanceResponse, GetNetworkDetailsResponse, GetPrimaryNetworkBlockResponse, GetTransactionResponse, Glacier, GlacierApiFeature, HealthCheckService, HistoricalReward, ImageAsset, InternalTransaction, InternalTransactionDetails, InternalTransactionOpCall, ListBlockchainsResponse, ListCChainAtomicBalancesResponse, ListCChainAtomicTransactionsResponse, ListChainsResponse, ListCollectibleBalancesResponse, ListContractsResponse, ListDelegatorDetailsResponse, ListErc1155BalancesResponse, ListErc1155TransactionsResponse, ListErc20BalancesResponse, ListErc20TransactionsResponse, ListErc721BalancesResponse, ListErc721TransactionsResponse, ListEvmBlocksResponse, ListHistoricalRewardsResponse, ListInternalTransactionsResponse, ListNativeTransactionsResponse, ListNftTokens, ListPChainBalancesResponse, ListPChainTransactionsResponse, ListPChainUtxosResponse, ListPendingRewardsResponse, ListPrimaryNetworkBlocksResponse, ListSubnetsResponse, ListTransactionDetailsResponse, ListTransfersResponse, ListUtxosResponse, ListValidatorDetailsResponse, ListWebhooksResponse, ListXChainBalancesResponse, ListXChainTransactionsResponse, ListXChainVerticesResponse, Method, Money, NativeTokenBalance, NativeTransaction, Network, NetworkToken, NetworkTokenDetails, NetworkType, NextPageToken, NfTsService, NftTokenMetadataStatus, OpenAPI, OpenAPIConfig, OperationStatus, OperationStatusCode, OperationStatusResponse, OperationType, OperationsService, PChainBalance, PChainId, PChainSharedAsset, PChainTransaction, PChainTransactionType, PChainUtxo, PendingDelegatorDetails, PendingReward, PendingTeleporterMessage, PendingValidatorDetails, PricingProviders, PrimaryNetwork, PrimaryNetworkAssetCap, PrimaryNetworkAssetType, PrimaryNetworkBalancesService, PrimaryNetworkBlock, PrimaryNetworkBlocksService, PrimaryNetworkChainInfo, PrimaryNetworkChainName, PrimaryNetworkOperationType, PrimaryNetworkOptions, PrimaryNetworkRewardsService, PrimaryNetworkService, PrimaryNetworkTransactionsService, PrimaryNetworkTxType, PrimaryNetworkUtxOsService, PrimaryNetworkVerticesService, ProposerDetails, RegisterWebhookRequest, RemovedValidatorDetails, ResourceLink, ResourceLinkType, RewardType, Rewards, RichAddress, RpcErrorDto, RpcErrorResponseDto, RpcRequestBodyDto, RpcService, RpcSuccessResponseDto, SharedSecretsResponse, SortOrder, StakingDistribution, Subnet, SubnetOwnershipInfo, TeleporterDestinationTransaction, TeleporterReceipt, TeleporterRewardDetails, TeleporterService, TeleporterSourceTransaction, TransactionDetails, TransactionExportMetadata, TransactionMethodType, TransactionStatus, TransactionVertexDetail, UnknownContract, UpdateContractResponse, UpdateWebhookRequest, UtilityAddresses, Utxo, UtxoCredential, UtxoType, ValidationStatusType, ValidatorHealthDetails, ValidatorsDetails, VmName, WebhookResponse, WebhookStatus, WebhookStatusType, WebhooksService, XChainAssetDetails, XChainBalances, XChainId, XChainLinearTransaction, XChainNonLinearTransaction, XChainSharedAssetBalance, XChainTransactionType, XChainVertex };
|
package/dist/index.js
CHANGED
|
@@ -33,71 +33,73 @@ class CancelError extends Error {
|
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
35
|
class CancelablePromise {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
_reject;
|
|
36
|
+
#isResolved;
|
|
37
|
+
#isRejected;
|
|
38
|
+
#isCancelled;
|
|
39
|
+
#cancelHandlers;
|
|
40
|
+
#promise;
|
|
41
|
+
#resolve;
|
|
42
|
+
#reject;
|
|
44
43
|
constructor(executor) {
|
|
45
|
-
this
|
|
46
|
-
this
|
|
47
|
-
this
|
|
48
|
-
this
|
|
49
|
-
this
|
|
50
|
-
this
|
|
51
|
-
this
|
|
44
|
+
this.#isResolved = false;
|
|
45
|
+
this.#isRejected = false;
|
|
46
|
+
this.#isCancelled = false;
|
|
47
|
+
this.#cancelHandlers = [];
|
|
48
|
+
this.#promise = new Promise((resolve, reject) => {
|
|
49
|
+
this.#resolve = resolve;
|
|
50
|
+
this.#reject = reject;
|
|
52
51
|
const onResolve = (value) => {
|
|
53
|
-
if (this
|
|
52
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
54
53
|
return;
|
|
55
54
|
}
|
|
56
|
-
this
|
|
57
|
-
this
|
|
55
|
+
this.#isResolved = true;
|
|
56
|
+
this.#resolve?.(value);
|
|
58
57
|
};
|
|
59
58
|
const onReject = (reason) => {
|
|
60
|
-
if (this
|
|
59
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
61
60
|
return;
|
|
62
61
|
}
|
|
63
|
-
this
|
|
64
|
-
this
|
|
62
|
+
this.#isRejected = true;
|
|
63
|
+
this.#reject?.(reason);
|
|
65
64
|
};
|
|
66
65
|
const onCancel = (cancelHandler) => {
|
|
67
|
-
if (this
|
|
66
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
68
67
|
return;
|
|
69
68
|
}
|
|
70
|
-
this.
|
|
69
|
+
this.#cancelHandlers.push(cancelHandler);
|
|
71
70
|
};
|
|
72
71
|
Object.defineProperty(onCancel, "isResolved", {
|
|
73
|
-
get: () => this
|
|
72
|
+
get: () => this.#isResolved
|
|
74
73
|
});
|
|
75
74
|
Object.defineProperty(onCancel, "isRejected", {
|
|
76
|
-
get: () => this
|
|
75
|
+
get: () => this.#isRejected
|
|
77
76
|
});
|
|
78
77
|
Object.defineProperty(onCancel, "isCancelled", {
|
|
79
|
-
get: () => this
|
|
78
|
+
get: () => this.#isCancelled
|
|
80
79
|
});
|
|
81
80
|
return executor(onResolve, onReject, onCancel);
|
|
82
81
|
});
|
|
83
82
|
}
|
|
83
|
+
get [Symbol.toStringTag]() {
|
|
84
|
+
return "Cancellable Promise";
|
|
85
|
+
}
|
|
84
86
|
then(onFulfilled, onRejected) {
|
|
85
|
-
return this.
|
|
87
|
+
return this.#promise.then(onFulfilled, onRejected);
|
|
86
88
|
}
|
|
87
89
|
catch(onRejected) {
|
|
88
|
-
return this.
|
|
90
|
+
return this.#promise.catch(onRejected);
|
|
89
91
|
}
|
|
90
92
|
finally(onFinally) {
|
|
91
|
-
return this.
|
|
93
|
+
return this.#promise.finally(onFinally);
|
|
92
94
|
}
|
|
93
95
|
cancel() {
|
|
94
|
-
if (this
|
|
96
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
95
97
|
return;
|
|
96
98
|
}
|
|
97
|
-
this
|
|
98
|
-
if (this.
|
|
99
|
+
this.#isCancelled = true;
|
|
100
|
+
if (this.#cancelHandlers.length) {
|
|
99
101
|
try {
|
|
100
|
-
for (const cancelHandler of this
|
|
102
|
+
for (const cancelHandler of this.#cancelHandlers) {
|
|
101
103
|
cancelHandler();
|
|
102
104
|
}
|
|
103
105
|
} catch (error) {
|
|
@@ -105,11 +107,11 @@ class CancelablePromise {
|
|
|
105
107
|
return;
|
|
106
108
|
}
|
|
107
109
|
}
|
|
108
|
-
this.
|
|
109
|
-
this
|
|
110
|
+
this.#cancelHandlers.length = 0;
|
|
111
|
+
this.#reject?.(new CancelError("Request aborted"));
|
|
110
112
|
}
|
|
111
113
|
get isCancelled() {
|
|
112
|
-
return this
|
|
114
|
+
return this.#isCancelled;
|
|
113
115
|
}
|
|
114
116
|
}
|
|
115
117
|
|
|
@@ -238,7 +240,7 @@ const getHeaders = async (config, options) => {
|
|
|
238
240
|
return new Headers(headers);
|
|
239
241
|
};
|
|
240
242
|
const getRequestBody = (options) => {
|
|
241
|
-
if (options.body) {
|
|
243
|
+
if (options.body !== void 0) {
|
|
242
244
|
if (options.mediaType?.includes("/json")) {
|
|
243
245
|
return JSON.stringify(options.body);
|
|
244
246
|
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
|
|
@@ -277,7 +279,8 @@ const getResponseBody = async (response) => {
|
|
|
277
279
|
try {
|
|
278
280
|
const contentType = response.headers.get("Content-Type");
|
|
279
281
|
if (contentType) {
|
|
280
|
-
const
|
|
282
|
+
const jsonTypes = ["application/json", "application/problem+json"];
|
|
283
|
+
const isJSON = jsonTypes.some((type) => contentType.toLowerCase().startsWith(type));
|
|
281
284
|
if (isJSON) {
|
|
282
285
|
return await response.json();
|
|
283
286
|
} else {
|
|
@@ -1432,6 +1435,29 @@ class PrimaryNetworkVerticesService {
|
|
|
1432
1435
|
}
|
|
1433
1436
|
}
|
|
1434
1437
|
|
|
1438
|
+
class RpcService {
|
|
1439
|
+
constructor(httpRequest) {
|
|
1440
|
+
this.httpRequest = httpRequest;
|
|
1441
|
+
}
|
|
1442
|
+
rpc({
|
|
1443
|
+
chainId,
|
|
1444
|
+
requestBody
|
|
1445
|
+
}) {
|
|
1446
|
+
return this.httpRequest.request({
|
|
1447
|
+
method: "POST",
|
|
1448
|
+
url: "/v1/ext/bc/{chainId}/rpc",
|
|
1449
|
+
path: {
|
|
1450
|
+
"chainId": chainId
|
|
1451
|
+
},
|
|
1452
|
+
body: requestBody,
|
|
1453
|
+
mediaType: "application/json",
|
|
1454
|
+
errors: {
|
|
1455
|
+
504: `Request timed out`
|
|
1456
|
+
}
|
|
1457
|
+
});
|
|
1458
|
+
}
|
|
1459
|
+
}
|
|
1460
|
+
|
|
1435
1461
|
class TeleporterService {
|
|
1436
1462
|
constructor(httpRequest) {
|
|
1437
1463
|
this.httpRequest = httpRequest;
|
|
@@ -1566,6 +1592,7 @@ class Glacier {
|
|
|
1566
1592
|
primaryNetworkTransactions;
|
|
1567
1593
|
primaryNetworkUtxOs;
|
|
1568
1594
|
primaryNetworkVertices;
|
|
1595
|
+
rpc;
|
|
1569
1596
|
teleporter;
|
|
1570
1597
|
webhooks;
|
|
1571
1598
|
request;
|
|
@@ -1597,6 +1624,7 @@ class Glacier {
|
|
|
1597
1624
|
this.primaryNetworkTransactions = new PrimaryNetworkTransactionsService(this.request);
|
|
1598
1625
|
this.primaryNetworkUtxOs = new PrimaryNetworkUtxOsService(this.request);
|
|
1599
1626
|
this.primaryNetworkVertices = new PrimaryNetworkVerticesService(this.request);
|
|
1627
|
+
this.rpc = new RpcService(this.request);
|
|
1600
1628
|
this.teleporter = new TeleporterService(this.request);
|
|
1601
1629
|
this.webhooks = new WebhooksService(this.request);
|
|
1602
1630
|
}
|
|
@@ -2172,6 +2200,7 @@ exports.PrimaryNetworkUtxOsService = PrimaryNetworkUtxOsService;
|
|
|
2172
2200
|
exports.PrimaryNetworkVerticesService = PrimaryNetworkVerticesService;
|
|
2173
2201
|
exports.ResourceLinkType = ResourceLinkType;
|
|
2174
2202
|
exports.RewardType = RewardType;
|
|
2203
|
+
exports.RpcService = RpcService;
|
|
2175
2204
|
exports.SortOrder = SortOrder;
|
|
2176
2205
|
exports.TeleporterService = TeleporterService;
|
|
2177
2206
|
exports.TransactionMethodType = TransactionMethodType;
|
|
@@ -16,6 +16,7 @@ import { PrimaryNetworkRewardsService } from './services/PrimaryNetworkRewardsSe
|
|
|
16
16
|
import { PrimaryNetworkTransactionsService } from './services/PrimaryNetworkTransactionsService.js';
|
|
17
17
|
import { PrimaryNetworkUtxOsService } from './services/PrimaryNetworkUtxOsService.js';
|
|
18
18
|
import { PrimaryNetworkVerticesService } from './services/PrimaryNetworkVerticesService.js';
|
|
19
|
+
import { RpcService } from './services/RpcService.js';
|
|
19
20
|
import { TeleporterService } from './services/TeleporterService.js';
|
|
20
21
|
import { WebhooksService } from './services/WebhooksService.js';
|
|
21
22
|
|
|
@@ -37,6 +38,7 @@ declare class Glacier {
|
|
|
37
38
|
readonly primaryNetworkTransactions: PrimaryNetworkTransactionsService;
|
|
38
39
|
readonly primaryNetworkUtxOs: PrimaryNetworkUtxOsService;
|
|
39
40
|
readonly primaryNetworkVertices: PrimaryNetworkVerticesService;
|
|
41
|
+
readonly rpc: RpcService;
|
|
40
42
|
readonly teleporter: TeleporterService;
|
|
41
43
|
readonly webhooks: WebhooksService;
|
|
42
44
|
readonly request: BaseHttpRequest;
|
package/esm/generated/Glacier.js
CHANGED
|
@@ -15,6 +15,7 @@ import { PrimaryNetworkRewardsService } from './services/PrimaryNetworkRewardsSe
|
|
|
15
15
|
import { PrimaryNetworkTransactionsService } from './services/PrimaryNetworkTransactionsService.js';
|
|
16
16
|
import { PrimaryNetworkUtxOsService } from './services/PrimaryNetworkUtxOsService.js';
|
|
17
17
|
import { PrimaryNetworkVerticesService } from './services/PrimaryNetworkVerticesService.js';
|
|
18
|
+
import { RpcService } from './services/RpcService.js';
|
|
18
19
|
import { TeleporterService } from './services/TeleporterService.js';
|
|
19
20
|
import { WebhooksService } from './services/WebhooksService.js';
|
|
20
21
|
|
|
@@ -35,6 +36,7 @@ class Glacier {
|
|
|
35
36
|
primaryNetworkTransactions;
|
|
36
37
|
primaryNetworkUtxOs;
|
|
37
38
|
primaryNetworkVertices;
|
|
39
|
+
rpc;
|
|
38
40
|
teleporter;
|
|
39
41
|
webhooks;
|
|
40
42
|
request;
|
|
@@ -66,6 +68,7 @@ class Glacier {
|
|
|
66
68
|
this.primaryNetworkTransactions = new PrimaryNetworkTransactionsService(this.request);
|
|
67
69
|
this.primaryNetworkUtxOs = new PrimaryNetworkUtxOsService(this.request);
|
|
68
70
|
this.primaryNetworkVertices = new PrimaryNetworkVerticesService(this.request);
|
|
71
|
+
this.rpc = new RpcService(this.request);
|
|
69
72
|
this.teleporter = new TeleporterService(this.request);
|
|
70
73
|
this.webhooks = new WebhooksService(this.request);
|
|
71
74
|
}
|
|
@@ -9,15 +9,9 @@ interface OnCancel {
|
|
|
9
9
|
(cancelHandler: () => void): void;
|
|
10
10
|
}
|
|
11
11
|
declare class CancelablePromise<T> implements Promise<T> {
|
|
12
|
-
|
|
13
|
-
private _isResolved;
|
|
14
|
-
private _isRejected;
|
|
15
|
-
private _isCancelled;
|
|
16
|
-
private readonly _cancelHandlers;
|
|
17
|
-
private readonly _promise;
|
|
18
|
-
private _resolve?;
|
|
19
|
-
private _reject?;
|
|
12
|
+
#private;
|
|
20
13
|
constructor(executor: (resolve: (value: T | PromiseLike<T>) => void, reject: (reason?: any) => void, onCancel: OnCancel) => void);
|
|
14
|
+
get [Symbol.toStringTag](): string;
|
|
21
15
|
then<TResult1 = T, TResult2 = never>(onFulfilled?: ((value: T) => TResult1 | PromiseLike<TResult1>) | null, onRejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2>;
|
|
22
16
|
catch<TResult = never>(onRejected?: ((reason: any) => TResult | PromiseLike<TResult>) | null): Promise<T | TResult>;
|
|
23
17
|
finally(onFinally?: (() => void) | null): Promise<T>;
|
|
@@ -8,71 +8,73 @@ class CancelError extends Error {
|
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
10
|
class CancelablePromise {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
_reject;
|
|
11
|
+
#isResolved;
|
|
12
|
+
#isRejected;
|
|
13
|
+
#isCancelled;
|
|
14
|
+
#cancelHandlers;
|
|
15
|
+
#promise;
|
|
16
|
+
#resolve;
|
|
17
|
+
#reject;
|
|
19
18
|
constructor(executor) {
|
|
20
|
-
this
|
|
21
|
-
this
|
|
22
|
-
this
|
|
23
|
-
this
|
|
24
|
-
this
|
|
25
|
-
this
|
|
26
|
-
this
|
|
19
|
+
this.#isResolved = false;
|
|
20
|
+
this.#isRejected = false;
|
|
21
|
+
this.#isCancelled = false;
|
|
22
|
+
this.#cancelHandlers = [];
|
|
23
|
+
this.#promise = new Promise((resolve, reject) => {
|
|
24
|
+
this.#resolve = resolve;
|
|
25
|
+
this.#reject = reject;
|
|
27
26
|
const onResolve = (value) => {
|
|
28
|
-
if (this
|
|
27
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
29
28
|
return;
|
|
30
29
|
}
|
|
31
|
-
this
|
|
32
|
-
this
|
|
30
|
+
this.#isResolved = true;
|
|
31
|
+
this.#resolve?.(value);
|
|
33
32
|
};
|
|
34
33
|
const onReject = (reason) => {
|
|
35
|
-
if (this
|
|
34
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
36
35
|
return;
|
|
37
36
|
}
|
|
38
|
-
this
|
|
39
|
-
this
|
|
37
|
+
this.#isRejected = true;
|
|
38
|
+
this.#reject?.(reason);
|
|
40
39
|
};
|
|
41
40
|
const onCancel = (cancelHandler) => {
|
|
42
|
-
if (this
|
|
41
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
43
42
|
return;
|
|
44
43
|
}
|
|
45
|
-
this.
|
|
44
|
+
this.#cancelHandlers.push(cancelHandler);
|
|
46
45
|
};
|
|
47
46
|
Object.defineProperty(onCancel, "isResolved", {
|
|
48
|
-
get: () => this
|
|
47
|
+
get: () => this.#isResolved
|
|
49
48
|
});
|
|
50
49
|
Object.defineProperty(onCancel, "isRejected", {
|
|
51
|
-
get: () => this
|
|
50
|
+
get: () => this.#isRejected
|
|
52
51
|
});
|
|
53
52
|
Object.defineProperty(onCancel, "isCancelled", {
|
|
54
|
-
get: () => this
|
|
53
|
+
get: () => this.#isCancelled
|
|
55
54
|
});
|
|
56
55
|
return executor(onResolve, onReject, onCancel);
|
|
57
56
|
});
|
|
58
57
|
}
|
|
58
|
+
get [Symbol.toStringTag]() {
|
|
59
|
+
return "Cancellable Promise";
|
|
60
|
+
}
|
|
59
61
|
then(onFulfilled, onRejected) {
|
|
60
|
-
return this.
|
|
62
|
+
return this.#promise.then(onFulfilled, onRejected);
|
|
61
63
|
}
|
|
62
64
|
catch(onRejected) {
|
|
63
|
-
return this.
|
|
65
|
+
return this.#promise.catch(onRejected);
|
|
64
66
|
}
|
|
65
67
|
finally(onFinally) {
|
|
66
|
-
return this.
|
|
68
|
+
return this.#promise.finally(onFinally);
|
|
67
69
|
}
|
|
68
70
|
cancel() {
|
|
69
|
-
if (this
|
|
71
|
+
if (this.#isResolved || this.#isRejected || this.#isCancelled) {
|
|
70
72
|
return;
|
|
71
73
|
}
|
|
72
|
-
this
|
|
73
|
-
if (this.
|
|
74
|
+
this.#isCancelled = true;
|
|
75
|
+
if (this.#cancelHandlers.length) {
|
|
74
76
|
try {
|
|
75
|
-
for (const cancelHandler of this
|
|
77
|
+
for (const cancelHandler of this.#cancelHandlers) {
|
|
76
78
|
cancelHandler();
|
|
77
79
|
}
|
|
78
80
|
} catch (error) {
|
|
@@ -80,11 +82,11 @@ class CancelablePromise {
|
|
|
80
82
|
return;
|
|
81
83
|
}
|
|
82
84
|
}
|
|
83
|
-
this.
|
|
84
|
-
this
|
|
85
|
+
this.#cancelHandlers.length = 0;
|
|
86
|
+
this.#reject?.(new CancelError("Request aborted"));
|
|
85
87
|
}
|
|
86
88
|
get isCancelled() {
|
|
87
|
-
return this
|
|
89
|
+
return this.#isCancelled;
|
|
88
90
|
}
|
|
89
91
|
}
|
|
90
92
|
|
|
@@ -126,7 +126,7 @@ const getHeaders = async (config, options) => {
|
|
|
126
126
|
return new Headers(headers);
|
|
127
127
|
};
|
|
128
128
|
const getRequestBody = (options) => {
|
|
129
|
-
if (options.body) {
|
|
129
|
+
if (options.body !== void 0) {
|
|
130
130
|
if (options.mediaType?.includes("/json")) {
|
|
131
131
|
return JSON.stringify(options.body);
|
|
132
132
|
} else if (isString(options.body) || isBlob(options.body) || isFormData(options.body)) {
|
|
@@ -165,7 +165,8 @@ const getResponseBody = async (response) => {
|
|
|
165
165
|
try {
|
|
166
166
|
const contentType = response.headers.get("Content-Type");
|
|
167
167
|
if (contentType) {
|
|
168
|
-
const
|
|
168
|
+
const jsonTypes = ["application/json", "application/problem+json"];
|
|
169
|
+
const isJSON = jsonTypes.some((type) => contentType.toLowerCase().startsWith(type));
|
|
169
170
|
if (isJSON) {
|
|
170
171
|
return await response.json();
|
|
171
172
|
} else {
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { RpcErrorResponseDto } from '../models/RpcErrorResponseDto.js';
|
|
2
|
+
import { RpcRequestBodyDto } from '../models/RpcRequestBodyDto.js';
|
|
3
|
+
import { RpcSuccessResponseDto } from '../models/RpcSuccessResponseDto.js';
|
|
4
|
+
import { CancelablePromise } from '../core/CancelablePromise.js';
|
|
5
|
+
import { BaseHttpRequest } from '../core/BaseHttpRequest.js';
|
|
6
|
+
|
|
7
|
+
declare class RpcService {
|
|
8
|
+
readonly httpRequest: BaseHttpRequest;
|
|
9
|
+
constructor(httpRequest: BaseHttpRequest);
|
|
10
|
+
/**
|
|
11
|
+
* Calls JSON-RPC method
|
|
12
|
+
* Calls JSON-RPC method.
|
|
13
|
+
* @returns any
|
|
14
|
+
* @throws ApiError
|
|
15
|
+
*/
|
|
16
|
+
rpc({ chainId, requestBody, }: {
|
|
17
|
+
/**
|
|
18
|
+
* A supported evm chain id, chain alias or blockchain id. Use the `/chains` endpoint to get a list of supported chain ids.
|
|
19
|
+
*/
|
|
20
|
+
chainId: string;
|
|
21
|
+
requestBody: (RpcRequestBodyDto | Array<RpcRequestBodyDto>);
|
|
22
|
+
}): CancelablePromise<(RpcSuccessResponseDto | RpcErrorResponseDto)>;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export { RpcService };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
class RpcService {
|
|
2
|
+
constructor(httpRequest) {
|
|
3
|
+
this.httpRequest = httpRequest;
|
|
4
|
+
}
|
|
5
|
+
rpc({
|
|
6
|
+
chainId,
|
|
7
|
+
requestBody
|
|
8
|
+
}) {
|
|
9
|
+
return this.httpRequest.request({
|
|
10
|
+
method: "POST",
|
|
11
|
+
url: "/v1/ext/bc/{chainId}/rpc",
|
|
12
|
+
path: {
|
|
13
|
+
"chainId": chainId
|
|
14
|
+
},
|
|
15
|
+
body: requestBody,
|
|
16
|
+
mediaType: "application/json",
|
|
17
|
+
errors: {
|
|
18
|
+
504: `Request timed out`
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export { RpcService };
|
package/esm/index.d.ts
CHANGED
|
@@ -146,6 +146,10 @@ export { ResourceLinkType } from './generated/models/ResourceLinkType.js';
|
|
|
146
146
|
export { Rewards } from './generated/models/Rewards.js';
|
|
147
147
|
export { RewardType } from './generated/models/RewardType.js';
|
|
148
148
|
export { RichAddress } from './generated/models/RichAddress.js';
|
|
149
|
+
export { RpcErrorDto } from './generated/models/RpcErrorDto.js';
|
|
150
|
+
export { RpcErrorResponseDto } from './generated/models/RpcErrorResponseDto.js';
|
|
151
|
+
export { RpcRequestBodyDto } from './generated/models/RpcRequestBodyDto.js';
|
|
152
|
+
export { RpcSuccessResponseDto } from './generated/models/RpcSuccessResponseDto.js';
|
|
149
153
|
export { SharedSecretsResponse } from './generated/models/SharedSecretsResponse.js';
|
|
150
154
|
export { SortOrder } from './generated/models/SortOrder.js';
|
|
151
155
|
export { StakingDistribution } from './generated/models/StakingDistribution.js';
|
|
@@ -198,5 +202,6 @@ export { PrimaryNetworkRewardsService } from './generated/services/PrimaryNetwor
|
|
|
198
202
|
export { PrimaryNetworkTransactionsService } from './generated/services/PrimaryNetworkTransactionsService.js';
|
|
199
203
|
export { PrimaryNetworkUtxOsService } from './generated/services/PrimaryNetworkUtxOsService.js';
|
|
200
204
|
export { PrimaryNetworkVerticesService } from './generated/services/PrimaryNetworkVerticesService.js';
|
|
205
|
+
export { RpcService } from './generated/services/RpcService.js';
|
|
201
206
|
export { TeleporterService } from './generated/services/TeleporterService.js';
|
|
202
207
|
export { WebhooksService } from './generated/services/WebhooksService.js';
|
package/esm/index.js
CHANGED
|
@@ -83,5 +83,6 @@ export { PrimaryNetworkRewardsService } from './generated/services/PrimaryNetwor
|
|
|
83
83
|
export { PrimaryNetworkTransactionsService } from './generated/services/PrimaryNetworkTransactionsService.js';
|
|
84
84
|
export { PrimaryNetworkUtxOsService } from './generated/services/PrimaryNetworkUtxOsService.js';
|
|
85
85
|
export { PrimaryNetworkVerticesService } from './generated/services/PrimaryNetworkVerticesService.js';
|
|
86
|
+
export { RpcService } from './generated/services/RpcService.js';
|
|
86
87
|
export { TeleporterService } from './generated/services/TeleporterService.js';
|
|
87
88
|
export { WebhooksService } from './generated/services/WebhooksService.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@avalabs/glacier-sdk",
|
|
3
|
-
"version": "2.8.0-alpha.
|
|
3
|
+
"version": "2.8.0-alpha.176",
|
|
4
4
|
"description": "sdk for interacting with glacier-api",
|
|
5
5
|
"author": "Oliver Wang <oliver.wang@avalabs.org>",
|
|
6
6
|
"homepage": "https://github.com/ava-labs/avalanche-sdks#readme",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
],
|
|
15
15
|
"sideEffects": false,
|
|
16
16
|
"devDependencies": {
|
|
17
|
-
"openapi-typescript-codegen": "0.
|
|
17
|
+
"openapi-typescript-codegen": "0.24.0"
|
|
18
18
|
},
|
|
19
19
|
"repository": {
|
|
20
20
|
"type": "git",
|
|
@@ -29,5 +29,5 @@
|
|
|
29
29
|
"bugs": {
|
|
30
30
|
"url": "https://github.com/ava-labs/avalanche-sdks/issues"
|
|
31
31
|
},
|
|
32
|
-
"gitHead": "
|
|
32
|
+
"gitHead": "b7bd44ce5a279f293f552046eac6c45824b29244"
|
|
33
33
|
}
|