Skip to content

Commit

Permalink
feat: Add network type to domain object (#321)
Browse files Browse the repository at this point in the history
Add network type to domain object
  • Loading branch information
FSM1 authored Jan 4, 2024
1 parent 53d38da commit 187dc78
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
7 changes: 6 additions & 1 deletion packages/sdk/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,12 @@ export class Config {
}

public getDomains(): Array<Domain> {
return this.environment.domains.map(({ id, chainId, name }) => ({ id, chainId, name }));
return this.environment.domains.map(({ id, chainId, name, type }) => ({
id,
chainId,
name,
type,
}));
}

public getDomainResources(): Array<Resource> {
Expand Down
2 changes: 2 additions & 0 deletions packages/sdk/src/types/types.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import { ParachainID, XcmMultiAssetIdType } from 'chains/Substrate/types';
import { Network } from './config';

export type Domain = {
id: number;
chainId: number;
name: string;
type: Network;
};

export type Recipient = {
Expand Down
5 changes: 5 additions & 0 deletions packages/sdk/test/chains/EVM/assetTransfer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Environment,
NonFungible,
Fungible,
Network,
} from '../../../src/types';
import { testingConfigData } from '../../constants';
import { ConfigUrl } from '../../../src/constants';
Expand Down Expand Up @@ -79,11 +80,13 @@ describe('EVM asset transfer', () => {
name: 'Sepolia',
chainId: 11155111,
id: 3,
type: Network.EVM,
},
from: {
name: 'Mumbai',
chainId: 80001,
id: 2,
type: Network.EVM,
},
resource: {
resourceId: '0x0000000000000000000000000000000000000000000000000000000000000300',
Expand All @@ -103,11 +106,13 @@ describe('EVM asset transfer', () => {
name: 'Sepolia',
chainId: 11155111,
id: 3,
type: Network.EVM,
},
from: {
name: 'Mumbai',
chainId: 80001,
id: 2,
type: Network.EVM,
},
resource: {
resourceId: '0x0000000000000000000000000000000000000000000000000000000000000300',
Expand Down
6 changes: 5 additions & 1 deletion packages/sdk/test/chains/Substrate/assetTransfer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import { ApiPromise } from '@polkadot/api';
import { BN } from '@polkadot/util';
import { FeeHandlerType, Environment, Transfer, Fungible, ResourceType } from '../../../src/types';
import { FeeHandlerType, Environment, Transfer, Fungible, ResourceType, Network } from '../../../src/types';
import { testingConfigData } from '../../constants';
import { ConfigUrl } from '../../../src/constants';
import { SubstrateAssetTransfer } from '../../../src/chains/Substrate';
Expand Down Expand Up @@ -67,11 +67,13 @@ describe('Substrate asset transfer', () => {
name: 'Sepolia',
chainId: 11155111,
id: 3,
type: Network.EVM,
},
from: {
name: 'rococo-phala',
chainId: 400,
id: 5,
type: Network.SUBSTRATE,
},
resource: {
resourceId: '0x0000000000000000000000000000000000000000000000000000000000001000',
Expand Down Expand Up @@ -110,11 +112,13 @@ describe('Substrate asset transfer', () => {
name: 'Sepolia',
chainId: 11155111,
id: 3,
type: Network.EVM,
},
from: {
name: 'rococo-phala',
chainId: 400,
id: 5,
type: Network.SUBSTRATE,
},
resource: {
resourceId: '0x0000000000000000000000000000000000000000000000000000000000001000',
Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/test/config/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('Config', () => {
const domains = config.getDomains();

expect(domains).toEqual(
testingConfigData.domains.map(({ id, chainId, name }) => ({ id, chainId, name })),
testingConfigData.domains.map(({ id, chainId, name, type }) => ({ id, chainId, name, type })),
);
});
});

0 comments on commit 187dc78

Please sign in to comment.