carbon-js-sdk 0.6.0 → 0.6.1
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.
|
@@ -23,6 +23,7 @@ declare class HydrogenClient {
|
|
|
23
23
|
formatFeeQuoteV2: (value: any, blockchain: BlockchainUtils.BlockchainV2) => GetFeeQuoteResponse;
|
|
24
24
|
getStats(): Promise<GetStatsResponse>;
|
|
25
25
|
getTransfers(req: GetTransfersRequest, version?: string): Promise<GetTransfersResponse>;
|
|
26
|
+
/** @deprecated getDetailedTransfers function is deprecated, please use getTransfers instead */
|
|
26
27
|
getDetailedTransfers(req: GetTransfersRequest, version?: string): Promise<GetDetailedTransfersResponse>;
|
|
27
28
|
getRelaysTransfers(req: GetRelaysRequest, version?: string): Promise<GetRelaysResponse>;
|
|
28
29
|
getFeeQuote(req: GetFeeQuoteRequest, blockchain?: BlockchainUtils.Blockchain | BlockchainUtils.BlockchainV2 | undefined, version?: string): Promise<GetFeeQuoteResponse>;
|
|
@@ -53,13 +53,13 @@ const formatRelaysTransfers = (value) => {
|
|
|
53
53
|
var _a, _b;
|
|
54
54
|
if (!value || typeof value !== "object")
|
|
55
55
|
return value;
|
|
56
|
-
return Object.assign(Object.assign({}, value), { created_at: formatDateField((_a = value.created_at) === null || _a === void 0 ? void 0 : _a.toString()), updated_at: formatDateField((_b = value.updated_at) === null || _b === void 0 ? void 0 : _b.toString()), source_blockchain: parseHydrogenBlockchain(value.source_blockchain),
|
|
56
|
+
return Object.assign(Object.assign({}, value), { created_at: formatDateField((_a = value.created_at) === null || _a === void 0 ? void 0 : _a.toString()), updated_at: formatDateField((_b = value.updated_at) === null || _b === void 0 ? void 0 : _b.toString()), source_blockchain: parseHydrogenBlockchain(value.source_blockchain), destination_blockchain: parseHydrogenBlockchain(value.destination_blockchain) });
|
|
57
57
|
};
|
|
58
58
|
const formatChainEvent = (value) => {
|
|
59
59
|
var _a, _b, _c;
|
|
60
60
|
if (!value || typeof value !== "object")
|
|
61
61
|
return value;
|
|
62
|
-
return Object.assign(Object.assign({}, value), { confirmed_at: formatDateField((_a = value.confirmed_at) === null || _a === void 0 ? void 0 : _a.toString()), created_at: formatDateField((_b = value.created_at) === null || _b === void 0 ? void 0 : _b.toString()), updated_at: formatDateField((_c = value.updated_at) === null || _c === void 0 ? void 0 : _c.toString()),
|
|
62
|
+
return Object.assign(Object.assign({}, value), { confirmed_at: formatDateField((_a = value.confirmed_at) === null || _a === void 0 ? void 0 : _a.toString()), created_at: formatDateField((_b = value.created_at) === null || _b === void 0 ? void 0 : _b.toString()), updated_at: formatDateField((_c = value.updated_at) === null || _c === void 0 ? void 0 : _c.toString()), blockchain: parseHydrogenBlockchain(value.blockchain) });
|
|
63
63
|
};
|
|
64
64
|
const formatFeeQuote = (value) => {
|
|
65
65
|
var _a, _b;
|
|
@@ -81,10 +81,10 @@ class HydrogenClient {
|
|
|
81
81
|
constructor(config, tokenClient) {
|
|
82
82
|
this.config = config;
|
|
83
83
|
this.formatCrossChainTransferV2 = (value) => {
|
|
84
|
-
var _a, _b;
|
|
84
|
+
var _a, _b, _c, _d;
|
|
85
85
|
if (typeof value !== "object")
|
|
86
86
|
return value;
|
|
87
|
-
return Object.assign(Object.assign({}, value), { created_at: formatDateField((_a = value.created_at) === null || _a === void 0 ? void 0 : _a.toString()), updated_at: formatDateField((_b = value.updated_at) === null || _b === void 0 ? void 0 : _b.toString()), source_blockchain: this.tokenClient.getBlockchainV2FromIDs(value.from_chain_id, value.bridge_id), bridging_blockchain: getBridgeBlockchainFromId(value.bridge_id), destination_blockchain: this.tokenClient.getBlockchainV2FromIDs(value.to_chain_id, value.bridge_id) });
|
|
87
|
+
return Object.assign(Object.assign({}, value), { created_at: formatDateField((_a = value.created_at) === null || _a === void 0 ? void 0 : _a.toString()), updated_at: formatDateField((_b = value.updated_at) === null || _b === void 0 ? void 0 : _b.toString()), source_blockchain: this.tokenClient.getBlockchainV2FromIDs(value.from_chain_id, value.bridge_id), bridging_blockchain: getBridgeBlockchainFromId(value.bridge_id), destination_blockchain: this.tokenClient.getBlockchainV2FromIDs(value.to_chain_id, value.bridge_id), source_event: this.formatChainEventV2(value.source_event, (_c = value.source_blockchain) !== null && _c !== void 0 ? _c : ''), bridging_event: this.formatChainEventV2(value.bridging_event, getBridgeBlockchainFromId(value.bridge_id)), destination_event: this.formatChainEventV2(value.destination_event, (_d = value.destination_blockchain) !== null && _d !== void 0 ? _d : ''), relay: this.formatRelaysTransfersV2(value.relay) });
|
|
88
88
|
};
|
|
89
89
|
this.formatCrossChainTransferDetailedV2 = (value) => {
|
|
90
90
|
if (!value || typeof value !== "object")
|
|
@@ -98,7 +98,7 @@ class HydrogenClient {
|
|
|
98
98
|
var _a, _b;
|
|
99
99
|
if (!value || typeof value !== "object")
|
|
100
100
|
return value;
|
|
101
|
-
return Object.assign(Object.assign({}, value), { created_at: formatDateField((_a = value.created_at) === null || _a === void 0 ? void 0 : _a.toString()), updated_at: formatDateField((_b = value.updated_at) === null || _b === void 0 ? void 0 : _b.toString())
|
|
101
|
+
return Object.assign(Object.assign({}, value), { created_at: formatDateField((_a = value.created_at) === null || _a === void 0 ? void 0 : _a.toString()), updated_at: formatDateField((_b = value.updated_at) === null || _b === void 0 ? void 0 : _b.toString()) });
|
|
102
102
|
};
|
|
103
103
|
this.formatChainEventV2 = (value, blockchain) => {
|
|
104
104
|
var _a, _b, _c;
|
|
@@ -138,12 +138,13 @@ class HydrogenClient {
|
|
|
138
138
|
getTransfers(req, version = "V1") {
|
|
139
139
|
return __awaiter(this, void 0, void 0, function* () {
|
|
140
140
|
this.checkState();
|
|
141
|
-
const request = this.apiManager.path("transfer_payloads", {}, Object.assign(
|
|
141
|
+
const request = this.apiManager.path("transfer_payloads", {}, Object.assign({}, req));
|
|
142
142
|
const response = yield request.get();
|
|
143
143
|
const result = response.data;
|
|
144
144
|
return Object.assign(Object.assign({}, result), { data: result.data.map(version === "V1" ? formatCrossChainTransfer : this.formatCrossChainTransferV2) });
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
|
+
/** @deprecated getDetailedTransfers function is deprecated, please use getTransfers instead */
|
|
147
148
|
getDetailedTransfers(req, version = "V1") {
|
|
148
149
|
return __awaiter(this, void 0, void 0, function* () {
|
|
149
150
|
this.checkState();
|
|
@@ -65,7 +65,7 @@ declare class TokenClient {
|
|
|
65
65
|
getBridgesFromBridgeId(bridgeId: number): Bridge[] | IbcBridge[];
|
|
66
66
|
getIbcTokens(): TypeUtils.SimpleMap<Token>;
|
|
67
67
|
getPolyNetworkTokens(): TypeUtils.SimpleMap<Token>;
|
|
68
|
-
getBlockchainV2FromIDs(chainId:
|
|
68
|
+
getBlockchainV2FromIDs(chainId: number, bridgeId: number): BlockchainV2 | undefined;
|
|
69
69
|
getBridgeFromToken(token: Token | null): Bridge | IbcBridge | undefined;
|
|
70
70
|
getIbcChainIdFromToken(token: Token | null): string | undefined;
|
|
71
71
|
getCdpUnderlyingToken(cdpDenom: string): Token | undefined;
|
|
@@ -529,12 +529,10 @@ class TokenClient {
|
|
|
529
529
|
}
|
|
530
530
|
getBlockchainV2FromIDs(chainId, bridgeId) {
|
|
531
531
|
var _a, _b;
|
|
532
|
-
|
|
533
|
-
const bridgeIdNum = Number(bridgeId);
|
|
534
|
-
if ((chainIdNum === 5 && bridgeIdNum === 1) || (chainIdNum === 0 && bridgeIdNum === 2))
|
|
532
|
+
if ((chainId === 5 && bridgeId === 1) || (chainId === 0 && bridgeId === 2))
|
|
535
533
|
return "Carbon";
|
|
536
|
-
const bridgeList = this.getBridgesFromBridgeId(
|
|
537
|
-
return (_b = (_a = bridgeList.find(bridge => bridge.chainId.toNumber() ===
|
|
534
|
+
const bridgeList = this.getBridgesFromBridgeId(bridgeId);
|
|
535
|
+
return (_b = (_a = bridgeList.find(bridge => bridge.chainId.toNumber() === chainId)) === null || _a === void 0 ? void 0 : _a.chainName) !== null && _b !== void 0 ? _b : undefined;
|
|
538
536
|
}
|
|
539
537
|
getBridgeFromToken(token) {
|
|
540
538
|
if (!token || !token.bridgeId)
|
package/lib/hydrogen/relays.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Blockchain, BlockchainV2 } from "../util/blockchain";
|
|
2
|
+
import { RelaysResponse } from "./relays";
|
|
2
3
|
export interface GetTransfersRequest {
|
|
3
4
|
bridging_blockchain?: string;
|
|
4
5
|
source_blockchain?: string;
|
|
@@ -36,8 +37,8 @@ export declare enum CrossChainFlowStatus {
|
|
|
36
37
|
}
|
|
37
38
|
export interface CrossChainTransfer {
|
|
38
39
|
id: string;
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
relay: RelaysResponse | null;
|
|
41
|
+
relay_id: string;
|
|
41
42
|
from_address: string;
|
|
42
43
|
from_address_hash: string;
|
|
43
44
|
from_asset: string;
|
|
@@ -53,13 +54,21 @@ export interface CrossChainTransfer {
|
|
|
53
54
|
nonce: string;
|
|
54
55
|
created_at: Date;
|
|
55
56
|
updated_at: Date;
|
|
57
|
+
recovery_address_hash: string;
|
|
58
|
+
recovery_address: string;
|
|
59
|
+
carbon_token_id: string;
|
|
60
|
+
transfer_payload_type: string;
|
|
61
|
+
cross_chain_flow_id: string;
|
|
56
62
|
source_blockchain: Blockchain | BlockchainV2 | null;
|
|
63
|
+
from_chain_id: number;
|
|
57
64
|
bridging_blockchain: Blockchain | BlockchainV2 | null;
|
|
65
|
+
bridge_id: number;
|
|
58
66
|
destination_blockchain: Blockchain | BlockchainV2 | null;
|
|
67
|
+
to_chain_id: number;
|
|
59
68
|
status: CrossChainFlowStatus;
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
69
|
+
source_event: ChainTransaction | null;
|
|
70
|
+
bridging_event: ChainTransaction | null;
|
|
71
|
+
destination_event: ChainTransaction | null;
|
|
63
72
|
}
|
|
64
73
|
export interface CrossChainTransferDetailed extends CrossChainTransfer {
|
|
65
74
|
source_event: ChainTransaction | null;
|