Skip to content

Commit

Permalink
Feedback Changes (#145)
Browse files Browse the repository at this point in the history
* from chainid and to chainid made mandatory

* get exchange supported assets will have optional parameter called chainId

* updated package version
  • Loading branch information
vignesha22 authored Jul 21, 2022
1 parent f791b09 commit 9abd9b0
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 13 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "etherspot",
"version": "1.34.3",
"version": "1.34.4",
"description": "Etherspot SDK",
"keywords": [
"ether",
Expand Down
4 changes: 2 additions & 2 deletions src/sdk/dto/get-cross-chain-bridge-route.dto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,13 @@ export class GetCrossChainBridgeRouteDto {
fromTokenAddress: string;

@IsPositive()
fromChainId?: number;
fromChainId: number;

@IsAddress()
toTokenAddress: string;

@IsPositive()
toChainId?: number;
toChainId: number;

fromAmount: string;

Expand Down
6 changes: 4 additions & 2 deletions src/sdk/dto/get-cross-chain-bridge-token-list.dto.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { IsBoolean, IsEnum, IsInt, IsOptional } from 'class-validator';
import { IsBoolean, IsEnum, IsInt, IsOptional, IsPositive } from 'class-validator';
import { SocketTokenDirection } from '../exchange/constants';

export class GetCrossChainBridgeTokenListDto {
@IsEnum(SocketTokenDirection)
direction: SocketTokenDirection;

@IsInt()
@IsPositive()
fromChainId: number;

@IsInt()
toChainId?: number;
@IsPositive()
toChainId: number;

@IsOptional()
@IsBoolean()
Expand Down
8 changes: 8 additions & 0 deletions src/sdk/dto/get-exchange-supported-assets.dto.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { IsOptional, IsPositive } from 'class-validator';
import { PaginationDto } from './pagination.dto';

export class GetExchangeSupportedAssetsDto extends PaginationDto {
@IsOptional()
@IsPositive()
chainId?: number;
}
1 change: 1 addition & 0 deletions src/sdk/dto/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,3 +70,4 @@ export * from './get-exchange-cross-chain-quote.dto';
export * from './create-stream-payload.dto';
export * from './delete-stream-payload.dto';
export * from './get-stream-list.dto';
export * from './get-exchange-supported-assets.dto';
7 changes: 4 additions & 3 deletions src/sdk/exchange/exchange.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { GetCrossChainBridgeTokenListDto, GetCrossChainBridgeRouteDto } from '..
import { CrossChainServiceProvider } from '.';

export class ExchangeService extends Service {
async getExchangeSupportedAssets(page: number = null, limit: number = null): Promise<PaginatedTokens> {
async getExchangeSupportedAssets(page: number = null, limit: number = null, ChainId: number): Promise<PaginatedTokens> {
const { apiService, accountService } = this.services;

const account = accountService.accountAddress;
Expand All @@ -28,8 +28,8 @@ export class ExchangeService extends Service {
result: PaginatedTokens;
}>(
gql`
query($chainId: Int, $account: String!, $page: Int, $limit: Int) {
result: exchangeSupportedAssets(chainId: $chainId, account: $account, page: $page, limit: $limit) {
query($ChainId: Int, $account: String!, $page: Int, $limit: Int) {
result: exchangeSupportedAssets(chainId: $ChainId, account: $account, page: $page, limit: $limit) {
items {
address
name
Expand All @@ -45,6 +45,7 @@ export class ExchangeService extends Service {
{
variables: {
account,
ChainId,
page: page || 1,
limit: limit || 100,
},
Expand Down
9 changes: 6 additions & 3 deletions src/sdk/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ import {
CreateStreamTransactionPayloadDto,
DeleteStreamTransactionPayloadDto,
GetStreamListDto,
GetExchangeSupportedAssetsDto,
} from './dto';
import { ENSNode, ENSNodeStates, ENSRootNode, ENSService, parseENSName } from './ens';
import { Env, EnvNames } from './env';
Expand Down Expand Up @@ -1275,14 +1276,16 @@ export class Sdk {
* @param dto
* @return Promise<PaginatedTokens>
*/
async getExchangeSupportedAssets(dto: PaginationDto = {}): Promise<PaginatedTokens> {
const { page, limit } = await validateDto(dto, PaginationDto);
async getExchangeSupportedAssets(dto: GetExchangeSupportedAssetsDto = {}): Promise<PaginatedTokens> {
const { page, limit, chainId } = await validateDto(dto, GetExchangeSupportedAssetsDto);

await this.require({
session: true,
});

return this.services.exchangeService.getExchangeSupportedAssets(page, limit);
const getChainId = chainId ? chainId : this.services.networkService.chainId;

return this.services.exchangeService.getExchangeSupportedAssets(page, limit, getChainId);
}

/**
Expand Down

0 comments on commit 9abd9b0

Please sign in to comment.