Skip to content

Commit

Permalink
Merge pull request #37 from interlay/tom/enable-usdt-support
Browse files Browse the repository at this point in the history
Tom/enable usdt support
  • Loading branch information
tomjeatt authored Jan 16, 2023
2 parents 2b73e28 + 679a7cf commit 9a53b42
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 43 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@interlay/bridge",
"version": "0.1.12",
"version": "0.1.13",
"description": "polkawallet bridge sdk",
"main": "build/index.js",
"typings": "build/index.d.ts",
Expand Down Expand Up @@ -88,8 +88,8 @@
"stableVersion": "0.0.5-4",
"jest": {
"testPathIgnorePatterns": [
"<rootDir>/dist/",
"<rootDir>/build/",
"<rootDir>/dist/",
"<rootDir>/build/",
"<rootDir>/node_modules/"
]
}
Expand Down
39 changes: 18 additions & 21 deletions src/adapters/interlay.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { chains, ChainName } from "../configs";
import { Bridge } from "..";
import { PolkadotAdapter } from "./polkadot";
import { InterlayAdapter } from "./interlay";
// import { StatemintAdapter } from "./statemint";
import { StatemintAdapter } from "./statemint";

describe.skip("interlay-adapter should work", () => {
jest.setTimeout(30000);
Expand All @@ -20,25 +20,20 @@ describe.skip("interlay-adapter should work", () => {
}

test("connect interlay to do xcm", async () => {
// const fromChains = ["interlay", "polkadot", "statemint"] as ChainName[];
const fromChains = ["interlay", "polkadot"] as ChainName[];
const fromChains = ["interlay", "polkadot", "statemint"] as ChainName[];

await connect(fromChains);

const interlay = new InterlayAdapter();
const polkadot = new PolkadotAdapter();
// const statemint = new StatemintAdapter();
const statemint = new StatemintAdapter();

await interlay.setApi(provider.getApi(fromChains[0]));
await polkadot.setApi(provider.getApi(fromChains[1]));
// await statemint.setApi(provider.getApi(fromChains[2]));

// const bridge = new Bridge({
// adapters: [interlay, polkadot, statemint],
// });
await statemint.setApi(provider.getApi(fromChains[2]));

const bridge = new Bridge({
adapters: [interlay, polkadot],
adapters: [interlay, polkadot, statemint],
});

expect(
Expand All @@ -48,10 +43,12 @@ describe.skip("interlay-adapter should work", () => {
}).length
).toEqual(1);

// expect(
// bridge.router.getDestinationChains({ from: chains.interlay, token: "USDT" })
// .length
// ).toEqual(1);
expect(
bridge.router.getDestinationChains({
from: chains.interlay,
token: "USDT",
}).length
).toEqual(1);

const adapter = bridge.findAdapter(fromChains[0]);

Expand Down Expand Up @@ -119,19 +116,19 @@ describe.skip("interlay-adapter should work", () => {
});

expect(tx.method.section).toEqual("xTokens");
// expect(tx.args.length).toEqual(4);
// if (to === "statemint") {
// expect(tx.method.method).toEqual("transferMulticurrencies");
// } else {
// expect(tx.method.method).toEqual("transfer");
// }
expect(tx.args.length).toEqual(4);
if (to === "statemint") {
expect(tx.method.method).toEqual("transferMulticurrencies");
} else {
expect(tx.method.method).toEqual("transfer");
}

expect(tx.args.length).toEqual(4);
expect(tx.method.method).toEqual("transfer");
}
}

await runMyTestSuit("polkadot", "DOT");
// await runMyTestSuit("statemint", "USDT");
await runMyTestSuit("statemint", "USDT");
});
});
40 changes: 21 additions & 19 deletions src/adapters/interlay.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
} from "../types";
import { isChainEqual } from "../utils/is-chain-equal";

const DEST_WEIGHT = "5000000000";
const DEST_WEIGHT = "180000000000";

export const interlayRoutersConfig: Omit<CrossChainRouterConfigs, "from">[] = [
{
Expand All @@ -28,14 +28,14 @@ export const interlayRoutersConfig: Omit<CrossChainRouterConfigs, "from">[] = [
weightLimit: DEST_WEIGHT,
},
},
// {
// to: "statemint",
// token: "USDT",
// xcm: {
// fee: { token: "DOT", amount: "1000000000" },
// weightLimit: DEST_WEIGHT,
// },
// },
{
to: "statemint",
token: "USDT",
xcm: {
fee: { token: "DOT", amount: "1000000000" },
weightLimit: DEST_WEIGHT,
},
},
];

export const kintsugiRoutersConfig: Omit<CrossChainRouterConfigs, "from">[] = [
Expand All @@ -47,12 +47,14 @@ export const kintsugiRoutersConfig: Omit<CrossChainRouterConfigs, "from">[] = [
weightLimit: DEST_WEIGHT,
},
},
// {
// to: "statemine",
// token: "USDT",
// // todo: determine fee amount - current value is a placeholder
// xcm: { fee: { token: "USDT", amount: "10" }, weightLimit: DEST_WEIGHT },
// },
{
to: "statemine",
token: "USDT",
xcm: {
fee: { token: "KSM", amount: "1500000000" },
weightLimit: DEST_WEIGHT,
},
},
];

export const interlayTokensConfig: Record<
Expand All @@ -61,22 +63,22 @@ export const interlayTokensConfig: Record<
> = {
interlay: {
DOT: { name: "DOT", symbol: "DOT", decimals: 10, ed: "0" },
// USDT: { name: "USDT", symbol: "USDT", decimals: 6, ed: "0" },
USDT: { name: "USDT", symbol: "USDT", decimals: 6, ed: "0" },
},
kintsugi: {
KSM: { name: "KSM", symbol: "KSM", decimals: 12, ed: "0" },
// USDT: { name: "USDT", symbol: "USDT", decimals: 6, ed: "0" },
USDT: { name: "USDT", symbol: "USDT", decimals: 6, ed: "0" },
},
};

const KINTSUGI_SUPPORTED_TOKENS: Record<string, unknown> = {
KSM: { Token: "KSM" },
// USDT: { ForeignAsset: 3 },
USDT: { ForeignAsset: 3 },
};

const INTERLAY_SUPPORTED_TOKENS: Record<string, unknown> = {
DOT: { Token: "DOT" },
// USDT: { ForeignAsset: 2 },
USDT: { ForeignAsset: 2 },
};

const getSupportedTokens = (chainname: string): Record<string, unknown> => {
Expand Down

0 comments on commit 9a53b42

Please sign in to comment.