Skip to content

Commit

Permalink
feat(ChainSymbol): make work with ChainSymbol in string way (return s…
Browse files Browse the repository at this point in the history
…till ChainSymbol)
  • Loading branch information
AntonKozAllB committed Aug 12, 2024
1 parent e0c8821 commit 327dc8f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/chains/models.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChainType } from "./chain.enums";
import { ChainSymbol, ChainType } from "./chain.enums";

/**
* Contains blockchain's basic information
Expand All @@ -7,7 +7,7 @@ export interface BasicChainProperties {
/**
* The symbol of the chain representing one of the supported blockchain networks (e.g., "ETH" for Ethereum). For more details, see: {@link ChainSymbol}.
*/
chainSymbol: string;
chainSymbol: ChainSymbol;
/**
* Common Blockchain Id</br>
* A 0x-prefixed hexadecimal string</br>
Expand Down
3 changes: 2 additions & 1 deletion src/client/core-api/core-api-mapper.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Chains } from "../../chains";
import { ChainSymbol } from "../../chains/chain.enums";
import {
ChainDetails,
ChainDetailsMap,
Expand Down Expand Up @@ -75,7 +76,7 @@ function mapMessengerKeyDtoToMessenger(dto: MessengerKeyDTO): Messenger | null {

function mapTransferTimeFromDto(dto: TransferTimeDTO): TransferTime {
return Object.entries(dto).reduce<TransferTime>((result, [key, value]) => {
result[key] = mapMessengerTransferTimeFromDto(value);
result[key as ChainSymbol] = mapMessengerTransferTimeFromDto(value);
return result;
}, {});
}
Expand Down
9 changes: 5 additions & 4 deletions src/client/core-api/core-api.model.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ChainSymbol } from "../../chains/chain.enums";
import { PoolInfo } from "../../tokens-info";

export type ChainDetailsResponse = Record<string, ChainDetailsDTO>;
Expand Down Expand Up @@ -97,8 +98,8 @@ export interface CheckAddressResponse {
export interface TransferStatusResponse {
txId: string;

sourceChainSymbol: string;
destinationChainSymbol: string;
sourceChainSymbol: ChainSymbol;
destinationChainSymbol: ChainSymbol;

sendAmount: string;
sendAmountFormatted: number;
Expand Down Expand Up @@ -155,8 +156,8 @@ export interface BridgeTransaction {
isClaimable?: boolean;
}

export type PoolInfoResponse = Record<string, PoolInfo>;
export type PendingInfoResponse = Record<string, TokenPendingInfoDTO>;
export type PoolInfoResponse = Record<ChainSymbol, PoolInfo>;
export type PendingInfoResponse = Partial<Record<ChainSymbol, TokenPendingInfoDTO>>;
export type TokenPendingInfoDTO = Record<string, PendingInfoDTO>;

export interface PendingInfoDTO {
Expand Down
7 changes: 5 additions & 2 deletions src/tokens-info/tokens-info.model.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ChainSymbol } from "../chains/chain.enums";
import { BasicChainProperties } from "../chains/models";
import { Messenger } from "../client/core-api/core-api.model";

Expand Down Expand Up @@ -175,10 +176,12 @@ export interface PoolInfo {
* Type representing transfer times for various blockchain chains.
*
* @typedef {Record<string, MessengerTransferTime>} TransferTime
* @property {string} chainSymbol - The symbol of the chain representing one of the supported blockchain networks (e.g., "ETH" for Ethereum). For more details, see: {@link ChainSymbol}.
* @property {chain} chainSymbol
* @property {MessengerTransferTime} transferTime - The average transfer time details for the specified chain.
*/
export type TransferTime = Record<string, MessengerTransferTime>;
export type TransferTime = {
[chain in ChainSymbol]?: MessengerTransferTime;
};

/**
* Contains Avg transaction time withing different messenger protocols
Expand Down

0 comments on commit 327dc8f

Please sign in to comment.