Skip to content

Commit

Permalink
changes as per the comments
Browse files Browse the repository at this point in the history
  • Loading branch information
kaushalrajbacancy committed Apr 12, 2024
1 parent 6497d53 commit 2847314
Show file tree
Hide file tree
Showing 10 changed files with 27 additions and 27 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Changelog
## [1.7.1] - 2024-04-10
## [1.7.1] - 2024-04-12
### New
- Added `getSupportedAssets` to get supported tokens
- Added `getQuotes` to get transaction quotes
Expand Down
8 changes: 4 additions & 4 deletions examples/25-get-quotes.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { utils } from 'ethers';
import { DataUtils } from '../src';
import * as dotenv from 'dotenv';
import { QuotesProvider } from '../src/sdk/data';
import { BridgingProvider } from '../src/sdk/data';

dotenv.config();
const dataApiKey = '';
Expand All @@ -16,7 +16,7 @@ async function main(): Promise<void> {

const supportedAssets = await dataService.getSupportedAssets({
chainId: 1,
provider: QuotesProvider.Connext,
provider: BridgingProvider.Connext,
});
console.log('\x1b[33m%s\x1b[0m', `Connext supported assets per chain:`, supportedAssets.length);

Expand All @@ -28,15 +28,15 @@ async function main(): Promise<void> {
fromToken: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
fromAmount: utils.parseUnits('1', 18),
slippage: 0.1,
provider: QuotesProvider.Connext,
provider: BridgingProvider.Connext,
});
console.log('\x1b[33m%s\x1b[0m', `Connext quote transactions:`, quotes);

const transactionStatus = await dataService.getTransactionStatus({
fromChainId: 100,
toChainId: 56,
transactionHash: '0xfc46adedf462d3fd6cdbe0214ed11c06cba20c385b9875aa4d51c60afbd9725d',
provider: QuotesProvider.Connext,
provider: BridgingProvider.Connext,
});
console.log('\x1b[33m%s\x1b[0m', `Connext transaction status:`, transactionStatus);
}
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/data/classes/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ export * from './token-list-token';
export * from './paginated-tokens';
export * from './transactions';
export * from './token';
export * from './quote-transaction';
export * from './quote';
export * from './transaction-status';
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BigNumberish, BytesLike } from "ethers";

export class QuoteTransaction {
export class Quote {
to?: string;
data?: BytesLike;
value?: BigNumberish;
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/data/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export enum CrossChainServiceProvider {
Etherspot = 'Connext',
}

export enum QuotesProvider {
export enum BridgingProvider {
Connext = 'Connext',
}

Expand Down
20 changes: 10 additions & 10 deletions src/sdk/data/data.module.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { BigNumber } from 'ethers';
import { Route } from '@lifi/sdk';
import { ObjectSubject } from '../common';
import { AccountBalances, AdvanceRoutesLiFi, Token, QuoteTransaction, TransactionStatus, ExchangeOffer, NftList, PaginatedTokens, RateData, StepTransactions, TokenList, TokenListToken, Transaction, Transactions } from './classes';
import { AccountBalances, AdvanceRoutesLiFi, Token, Quote, TransactionStatus, ExchangeOffer, NftList, PaginatedTokens, RateData, StepTransactions, TokenList, TokenListToken, Transaction, Transactions } from './classes';
import { RestApiService } from '../api';
import { API_ENDPOINTS, MethodTypes } from '../api/constants';
import { QuotesProvider } from './constants';
import { BridgingProvider } from './constants';

export class DataModule {
readonly apiKey$ = new ObjectSubject<string>('');
Expand Down Expand Up @@ -251,7 +251,7 @@ export class DataModule {
}
}

async getSupportedAssets(chainId?: number, provider?: QuotesProvider): Promise<Token[]> {
async getSupportedAssets(chainId?: number, provider?: BridgingProvider): Promise<Token[]> {
try {
const queryParams = {
'api-key': this.currentApi,
Expand All @@ -260,7 +260,7 @@ export class DataModule {
let apiUrl: string;

switch (provider) {
case QuotesProvider.Connext:
case BridgingProvider.Connext:
apiUrl = API_ENDPOINTS.GET_CONNEXT_SUPPORTED_ASSETS;
break;
default:
Expand All @@ -284,8 +284,8 @@ export class DataModule {
fromToken: string,
fromAmount: BigNumber,
slippage: number,
provider?: QuotesProvider
): Promise<QuoteTransaction[]> {
provider?: BridgingProvider
): Promise<Quote[]> {
try {
const queryParams = {
'api-key': this.currentApi,
Expand All @@ -300,23 +300,23 @@ export class DataModule {
let apiUrl: string;

switch (provider) {
case QuotesProvider.Connext:
case BridgingProvider.Connext:
apiUrl = API_ENDPOINTS.GET_CONNEXT_QUOTE_TRANSACTIONS;
break;
default:
apiUrl = API_ENDPOINTS.GET_CONNEXT_QUOTE_TRANSACTIONS;
break;
}

const result: { transactions: QuoteTransaction[] } = await this.apiService.makeRequest(apiUrl, MethodTypes.GET, queryParams);
const result: { transactions: Quote[] } = await this.apiService.makeRequest(apiUrl, MethodTypes.GET, queryParams);

return result ? result.transactions : [];
} catch (error) {
throw new Error(error.message || 'Failed to get quotes transactions');
}
}

async getTransactionStatus(fromChainId: number, toChainId: number, transactionHash: string, provider?: QuotesProvider): Promise<TransactionStatus> {
async getTransactionStatus(fromChainId: number, toChainId: number, transactionHash: string, provider?: BridgingProvider): Promise<TransactionStatus> {
try {
const queryParams = {
'api-key': this.currentApi,
Expand All @@ -327,7 +327,7 @@ export class DataModule {
let apiUrl: string;

switch (provider) {
case QuotesProvider.Connext:
case BridgingProvider.Connext:
apiUrl = API_ENDPOINTS.GET_CONNEXT_TRANSACTION_STATUS;
break;
default:
Expand Down
6 changes: 3 additions & 3 deletions src/sdk/dataUtils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import "reflect-metadata";
import { AccountBalances, AdvanceRoutesLiFi, Token, QuoteTransaction, TransactionStatus, DataModule, ExchangeOffer, NftList, PaginatedTokens, RateData, StepTransactions, TokenList, TokenListToken, Transaction, Transactions } from "./data";
import { AccountBalances, AdvanceRoutesLiFi, Token, Quote, TransactionStatus, DataModule, ExchangeOffer, NftList, PaginatedTokens, RateData, StepTransactions, TokenList, TokenListToken, Transaction, Transactions } from "./data";
import { FetchExchangeRatesDto, GetAccountBalancesDto, GetAdvanceRoutesLiFiDto, GetSupportedAssetsDto, GetTransactionStatusDto, GetExchangeOffersDto, GetExchangeSupportedAssetsDto, GetNftListDto, GetStepTransactionsLiFiDto, GetTokenListDto, GetTokenListsDto, GetTransactionDto, GetTransactionsDto, GetQuotesDto, validateDto } from "./dto";
import { BigNumber } from "ethers";

Expand Down Expand Up @@ -239,9 +239,9 @@ export class DataUtils {
/**
* gets quote transactions
* @param dto
* @return Promise<QuoteTransaction[]>
* @return Promise<Quote[]>
*/
async getQuotes(dto: GetQuotesDto): Promise<QuoteTransaction[]> {
async getQuotes(dto: GetQuotesDto): Promise<Quote[]> {
const {
fromAddress,
toAddress,
Expand Down
4 changes: 2 additions & 2 deletions src/sdk/dto/get-quotes.dto.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BigNumberish } from 'ethers';
import { IsAddress, IsBigNumberish } from './validators';
import { IsOptional } from 'class-validator';
import { QuotesProvider } from '../data';
import { BridgingProvider } from '../data';

export class GetQuotesDto {
@IsAddress()
Expand All @@ -25,5 +25,5 @@ export class GetQuotesDto {
slippage: number;

@IsOptional()
provider?: QuotesProvider;
provider?: BridgingProvider;
}
4 changes: 2 additions & 2 deletions src/sdk/dto/get-supported-assets.dto.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IsInt, IsOptional, IsPositive } from 'class-validator';
import { QuotesProvider } from '../data';
import { BridgingProvider } from '../data';

export class GetSupportedAssetsDto {
@IsOptional()
Expand All @@ -8,5 +8,5 @@ export class GetSupportedAssetsDto {
chainId?: number = null;

@IsOptional()
provider?: QuotesProvider;
provider?: BridgingProvider;
}
4 changes: 2 additions & 2 deletions src/sdk/dto/get-transaction-status.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { IsInt, IsOptional, IsPositive } from 'class-validator';
import { IsHex32 } from './validators';
import { QuotesProvider } from '../data';
import { BridgingProvider } from '../data';

export class GetTransactionStatusDto {
@IsPositive()
Expand All @@ -15,5 +15,5 @@ export class GetTransactionStatusDto {
transactionHash: string;

@IsOptional()
provider?: QuotesProvider;
provider?: BridgingProvider;
}

0 comments on commit 2847314

Please sign in to comment.