@lifi/sdk 2.0.0-beta.14 → 2.0.0-beta.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/version.d.ts +2 -0
- package/dist/cjs/{src/version.js → version.js} +1 -1
- package/dist/version.d.ts +2 -0
- package/dist/version.js +2 -0
- package/package.json +1 -1
- package/dist/cjs/src/execution/RouteExecutionManager.unit.handlers.d.ts +0 -1
- package/dist/cjs/src/execution/RouteExecutionManager.unit.handlers.js +0 -20
- package/dist/cjs/src/execution/RouteExecutionManager.unit.mock.d.ts +0 -80
- package/dist/cjs/src/execution/RouteExecutionManager.unit.mock.js +0 -76
- package/dist/cjs/src/services/ApiService.unit.handlers.d.ts +0 -1
- package/dist/cjs/src/services/ApiService.unit.handlers.js +0 -50
- package/dist/cjs/src/version.d.ts +0 -2
- package/dist/cjs/test/fixtures.d.ts +0 -7
- package/dist/cjs/test/fixtures.js +0 -157
- package/dist/src/execution/RouteExecutionManager.unit.handlers.d.ts +0 -1
- package/dist/src/execution/RouteExecutionManager.unit.handlers.js +0 -14
- package/dist/src/execution/RouteExecutionManager.unit.mock.d.ts +0 -80
- package/dist/src/execution/RouteExecutionManager.unit.mock.js +0 -72
- package/dist/src/services/ApiService.unit.handlers.d.ts +0 -1
- package/dist/src/services/ApiService.unit.handlers.js +0 -44
- package/dist/src/version.d.ts +0 -2
- package/dist/src/version.js +0 -2
- package/dist/test/fixtures.d.ts +0 -7
- package/dist/test/fixtures.js +0 -152
- /package/dist/{cjs/src/LiFi.d.ts → LiFi.d.ts} +0 -0
- /package/dist/{src/LiFi.js → LiFi.js} +0 -0
- /package/dist/{cjs/src/allowance → allowance}/checkAllowance.d.ts +0 -0
- /package/dist/{src/allowance → allowance}/checkAllowance.js +0 -0
- /package/dist/{cjs/src/allowance → allowance}/index.d.ts +0 -0
- /package/dist/{src/allowance → allowance}/index.js +0 -0
- /package/dist/{cjs/src/allowance → allowance}/tokenApproval.d.ts +0 -0
- /package/dist/{src/allowance → allowance}/tokenApproval.js +0 -0
- /package/dist/{cjs/src/allowance → allowance}/utils.d.ts +0 -0
- /package/dist/{src/allowance → allowance}/utils.js +0 -0
- /package/dist/{cjs/src/balance → balance}/checkBalance.d.ts +0 -0
- /package/dist/{src/balance → balance}/checkBalance.js +0 -0
- /package/dist/{cjs/src/balance → balance}/getTokenBalance.d.ts +0 -0
- /package/dist/{src/balance → balance}/getTokenBalance.js +0 -0
- /package/dist/{cjs/src/balance → balance}/index.d.ts +0 -0
- /package/dist/{src/balance → balance}/index.js +0 -0
- /package/dist/{cjs/src/balance → balance}/utils.d.ts +0 -0
- /package/dist/{src/balance → balance}/utils.js +0 -0
- /package/dist/{src → cjs}/LiFi.d.ts +0 -0
- /package/dist/cjs/{src/LiFi.js → LiFi.js} +0 -0
- /package/dist/{src → cjs}/allowance/checkAllowance.d.ts +0 -0
- /package/dist/cjs/{src/allowance → allowance}/checkAllowance.js +0 -0
- /package/dist/{src → cjs}/allowance/index.d.ts +0 -0
- /package/dist/cjs/{src/allowance → allowance}/index.js +0 -0
- /package/dist/{src → cjs}/allowance/tokenApproval.d.ts +0 -0
- /package/dist/cjs/{src/allowance → allowance}/tokenApproval.js +0 -0
- /package/dist/{src → cjs}/allowance/utils.d.ts +0 -0
- /package/dist/cjs/{src/allowance → allowance}/utils.js +0 -0
- /package/dist/{src → cjs}/balance/checkBalance.d.ts +0 -0
- /package/dist/cjs/{src/balance → balance}/checkBalance.js +0 -0
- /package/dist/{src → cjs}/balance/getTokenBalance.d.ts +0 -0
- /package/dist/cjs/{src/balance → balance}/getTokenBalance.js +0 -0
- /package/dist/{src → cjs}/balance/index.d.ts +0 -0
- /package/dist/cjs/{src/balance → balance}/index.js +0 -0
- /package/dist/{src → cjs}/balance/utils.d.ts +0 -0
- /package/dist/cjs/{src/balance → balance}/utils.js +0 -0
- /package/dist/cjs/{src/connectors.d.ts → connectors.d.ts} +0 -0
- /package/dist/cjs/{src/connectors.js → connectors.js} +0 -0
- /package/dist/cjs/{src/execution → execution}/RouteExecutionManager.d.ts +0 -0
- /package/dist/cjs/{src/execution → execution}/RouteExecutionManager.js +0 -0
- /package/dist/cjs/{src/execution → execution}/StatusManager.d.ts +0 -0
- /package/dist/cjs/{src/execution → execution}/StatusManager.js +0 -0
- /package/dist/cjs/{src/execution → execution}/StepExecutionManager.d.ts +0 -0
- /package/dist/cjs/{src/execution → execution}/StepExecutionManager.js +0 -0
- /package/dist/cjs/{src/execution → execution}/StepExecutor.d.ts +0 -0
- /package/dist/cjs/{src/execution → execution}/StepExecutor.js +0 -0
- /package/dist/cjs/{src/execution → execution}/index.d.ts +0 -0
- /package/dist/cjs/{src/execution → execution}/index.js +0 -0
- /package/dist/cjs/{src/execution → execution}/stepComparison.d.ts +0 -0
- /package/dist/cjs/{src/execution → execution}/stepComparison.js +0 -0
- /package/dist/cjs/{src/execution → execution}/switchChain.d.ts +0 -0
- /package/dist/cjs/{src/execution → execution}/switchChain.js +0 -0
- /package/dist/cjs/{src/execution → execution}/utils.d.ts +0 -0
- /package/dist/cjs/{src/execution → execution}/utils.js +0 -0
- /package/dist/cjs/{src/helpers.d.ts → helpers.d.ts} +0 -0
- /package/dist/cjs/{src/helpers.js → helpers.js} +0 -0
- /package/dist/cjs/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/cjs/{src/index.js → index.js} +0 -0
- /package/dist/cjs/{src/request.d.ts → request.d.ts} +0 -0
- /package/dist/cjs/{src/request.js → request.js} +0 -0
- /package/dist/cjs/{src/services → services}/ApiService.d.ts +0 -0
- /package/dist/cjs/{src/services → services}/ApiService.js +0 -0
- /package/dist/cjs/{src/services → services}/ChainsService.d.ts +0 -0
- /package/dist/cjs/{src/services → services}/ChainsService.js +0 -0
- /package/dist/cjs/{src/services → services}/ConfigService.d.ts +0 -0
- /package/dist/cjs/{src/services → services}/ConfigService.js +0 -0
- /package/dist/cjs/{src/typeguards.d.ts → typeguards.d.ts} +0 -0
- /package/dist/cjs/{src/typeguards.js → typeguards.js} +0 -0
- /package/dist/cjs/{src/types → types}/ERC20.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/ERC20.js +0 -0
- /package/dist/cjs/{src/types → types}/index.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/index.js +0 -0
- /package/dist/cjs/{src/types → types}/internal.types.d.ts +0 -0
- /package/dist/cjs/{src/types → types}/internal.types.js +0 -0
- /package/dist/cjs/{src/utils → utils}/errors.d.ts +0 -0
- /package/dist/cjs/{src/utils → utils}/errors.js +0 -0
- /package/dist/cjs/{src/utils → utils}/getProvider.d.ts +0 -0
- /package/dist/cjs/{src/utils → utils}/getProvider.js +0 -0
- /package/dist/cjs/{src/utils → utils}/multicall.d.ts +0 -0
- /package/dist/cjs/{src/utils → utils}/multicall.js +0 -0
- /package/dist/cjs/{src/utils → utils}/multicallAbi.json +0 -0
- /package/dist/cjs/{src/utils → utils}/parseError.d.ts +0 -0
- /package/dist/cjs/{src/utils → utils}/parseError.js +0 -0
- /package/dist/cjs/{src/utils → utils}/preRestart.d.ts +0 -0
- /package/dist/cjs/{src/utils → utils}/preRestart.js +0 -0
- /package/dist/cjs/{src/utils → utils}/utils.d.ts +0 -0
- /package/dist/cjs/{src/utils → utils}/utils.js +0 -0
- /package/dist/{src/connectors.d.ts → connectors.d.ts} +0 -0
- /package/dist/{src/connectors.js → connectors.js} +0 -0
- /package/dist/{src/execution → execution}/RouteExecutionManager.d.ts +0 -0
- /package/dist/{src/execution → execution}/RouteExecutionManager.js +0 -0
- /package/dist/{src/execution → execution}/StatusManager.d.ts +0 -0
- /package/dist/{src/execution → execution}/StatusManager.js +0 -0
- /package/dist/{src/execution → execution}/StepExecutionManager.d.ts +0 -0
- /package/dist/{src/execution → execution}/StepExecutionManager.js +0 -0
- /package/dist/{src/execution → execution}/StepExecutor.d.ts +0 -0
- /package/dist/{src/execution → execution}/StepExecutor.js +0 -0
- /package/dist/{src/execution → execution}/index.d.ts +0 -0
- /package/dist/{src/execution → execution}/index.js +0 -0
- /package/dist/{src/execution → execution}/stepComparison.d.ts +0 -0
- /package/dist/{src/execution → execution}/stepComparison.js +0 -0
- /package/dist/{src/execution → execution}/switchChain.d.ts +0 -0
- /package/dist/{src/execution → execution}/switchChain.js +0 -0
- /package/dist/{src/execution → execution}/utils.d.ts +0 -0
- /package/dist/{src/execution → execution}/utils.js +0 -0
- /package/dist/{src/helpers.d.ts → helpers.d.ts} +0 -0
- /package/dist/{src/helpers.js → helpers.js} +0 -0
- /package/dist/{src/index.d.ts → index.d.ts} +0 -0
- /package/dist/{src/index.js → index.js} +0 -0
- /package/dist/{src/request.d.ts → request.d.ts} +0 -0
- /package/dist/{src/request.js → request.js} +0 -0
- /package/dist/{src/services → services}/ApiService.d.ts +0 -0
- /package/dist/{src/services → services}/ApiService.js +0 -0
- /package/dist/{src/services → services}/ChainsService.d.ts +0 -0
- /package/dist/{src/services → services}/ChainsService.js +0 -0
- /package/dist/{src/services → services}/ConfigService.d.ts +0 -0
- /package/dist/{src/services → services}/ConfigService.js +0 -0
- /package/dist/{src/typeguards.d.ts → typeguards.d.ts} +0 -0
- /package/dist/{src/typeguards.js → typeguards.js} +0 -0
- /package/dist/{src/types → types}/ERC20.d.ts +0 -0
- /package/dist/{src/types → types}/ERC20.js +0 -0
- /package/dist/{src/types → types}/index.d.ts +0 -0
- /package/dist/{src/types → types}/index.js +0 -0
- /package/dist/{src/types → types}/internal.types.d.ts +0 -0
- /package/dist/{src/types → types}/internal.types.js +0 -0
- /package/dist/{src/utils → utils}/errors.d.ts +0 -0
- /package/dist/{src/utils → utils}/errors.js +0 -0
- /package/dist/{src/utils → utils}/getProvider.d.ts +0 -0
- /package/dist/{src/utils → utils}/getProvider.js +0 -0
- /package/dist/{src/utils → utils}/multicall.d.ts +0 -0
- /package/dist/{src/utils → utils}/multicall.js +0 -0
- /package/dist/{src/utils → utils}/multicallAbi.json +0 -0
- /package/dist/{src/utils → utils}/parseError.d.ts +0 -0
- /package/dist/{src/utils → utils}/parseError.js +0 -0
- /package/dist/{src/utils → utils}/preRestart.d.ts +0 -0
- /package/dist/{src/utils → utils}/preRestart.js +0 -0
- /package/dist/{src/utils → utils}/utils.d.ts +0 -0
- /package/dist/{src/utils → utils}/utils.js +0 -0
package/dist/version.js
ADDED
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const lifiHandlers: import("msw").RestHandler<import("msw/lib/glossary-de6278a9").M<import("msw/lib/glossary-de6278a9").h>>[];
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.lifiHandlers = void 0;
|
|
7
|
-
const msw_1 = require("msw");
|
|
8
|
-
const RouteExecutionManager_unit_mock_1 = require("./RouteExecutionManager.unit.mock");
|
|
9
|
-
const ConfigService_1 = __importDefault(require("../services/ConfigService"));
|
|
10
|
-
const fixtures_1 = require("../../test/fixtures");
|
|
11
|
-
const config = ConfigService_1.default.getInstance().getConfig();
|
|
12
|
-
exports.lifiHandlers = [
|
|
13
|
-
msw_1.rest.post(`${config.apiUrl}/advanced/stepTransaction`, async (_, response, context) => response(context.status(200), context.json((0, RouteExecutionManager_unit_mock_1.mockStepTransactionWithTxRequest)((0, fixtures_1.buildStepObject)({
|
|
14
|
-
includingExecution: true,
|
|
15
|
-
}))))),
|
|
16
|
-
msw_1.rest.get(`${config.apiUrl}/chains`, async (_, response, context) => response(context.status(200), context.json({
|
|
17
|
-
chains: RouteExecutionManager_unit_mock_1.mockChainsResponse,
|
|
18
|
-
}))),
|
|
19
|
-
msw_1.rest.get(`${config.apiUrl}/status`, async (_, response, context) => response(context.status(200), context.json(RouteExecutionManager_unit_mock_1.mockStatus))),
|
|
20
|
-
];
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { LifiStep } from '@lifi/types';
|
|
2
|
-
export declare const mockChainsResponse: {
|
|
3
|
-
key: string;
|
|
4
|
-
chainType: string;
|
|
5
|
-
name: string;
|
|
6
|
-
coin: string;
|
|
7
|
-
id: number;
|
|
8
|
-
mainnet: boolean;
|
|
9
|
-
logoURI: string;
|
|
10
|
-
tokenlistUrl: string;
|
|
11
|
-
faucetUrls: string[];
|
|
12
|
-
multicallAddress: string;
|
|
13
|
-
metamask: {
|
|
14
|
-
chainId: string;
|
|
15
|
-
blockExplorerUrls: string[];
|
|
16
|
-
chainName: string;
|
|
17
|
-
nativeCurrency: {
|
|
18
|
-
name: string;
|
|
19
|
-
symbol: string;
|
|
20
|
-
decimals: number;
|
|
21
|
-
};
|
|
22
|
-
rpcUrls: string[];
|
|
23
|
-
};
|
|
24
|
-
nativeToken: {
|
|
25
|
-
address: string;
|
|
26
|
-
chainId: number;
|
|
27
|
-
symbol: string;
|
|
28
|
-
decimals: number;
|
|
29
|
-
name: string;
|
|
30
|
-
priceUSD: string;
|
|
31
|
-
logoURI: string;
|
|
32
|
-
coinKey: string;
|
|
33
|
-
};
|
|
34
|
-
}[];
|
|
35
|
-
export declare const mockTransactionRequest: {
|
|
36
|
-
transactionRequest: {
|
|
37
|
-
data: string;
|
|
38
|
-
to: string;
|
|
39
|
-
value: string;
|
|
40
|
-
from: string;
|
|
41
|
-
chainId: number;
|
|
42
|
-
gasPrice: string;
|
|
43
|
-
gasLimit: string;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
export declare const mockStatus: {
|
|
47
|
-
status: string;
|
|
48
|
-
receiving: boolean;
|
|
49
|
-
sending: {
|
|
50
|
-
amount: string;
|
|
51
|
-
gasAmount: string;
|
|
52
|
-
gasAmountUSD: string;
|
|
53
|
-
gasPrice: string;
|
|
54
|
-
gasToken: string;
|
|
55
|
-
gasUsed: string;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
export declare const mockStepTransactionWithTxRequest: (step?: LifiStep) => {
|
|
59
|
-
transactionRequest: {
|
|
60
|
-
transactionRequest: {
|
|
61
|
-
data: string;
|
|
62
|
-
to: string;
|
|
63
|
-
value: string;
|
|
64
|
-
from: string;
|
|
65
|
-
chainId: number;
|
|
66
|
-
gasPrice: string;
|
|
67
|
-
gasLimit: string;
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
type: "lifi";
|
|
71
|
-
includedSteps: import("@lifi/types").Step[];
|
|
72
|
-
id: string;
|
|
73
|
-
referrer?: string | undefined;
|
|
74
|
-
action: import("@lifi/types").Action | import("@lifi/types").CallAction;
|
|
75
|
-
estimate: import("@lifi/types").Estimate;
|
|
76
|
-
tool: string;
|
|
77
|
-
toolDetails: Pick<import("@lifi/types").Bridge | import("@lifi/types").ExchangeAggregator | import("@lifi/types").Exchange, "key" | "name" | "logoURI">;
|
|
78
|
-
integrator?: string | undefined;
|
|
79
|
-
execution?: import("@lifi/types").Execution | undefined;
|
|
80
|
-
};
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mockStepTransactionWithTxRequest = exports.mockStatus = exports.mockTransactionRequest = exports.mockChainsResponse = void 0;
|
|
4
|
-
const fixtures_1 = require("../../test/fixtures");
|
|
5
|
-
exports.mockChainsResponse = [
|
|
6
|
-
{
|
|
7
|
-
key: 'pol',
|
|
8
|
-
chainType: 'EVM',
|
|
9
|
-
name: 'Polygon',
|
|
10
|
-
coin: 'MATIC',
|
|
11
|
-
id: 137,
|
|
12
|
-
mainnet: true,
|
|
13
|
-
logoURI: 'https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/chains/polygon.svg',
|
|
14
|
-
tokenlistUrl: 'https://unpkg.com/quickswap-default-token-list@1.0.71/build/quickswap-default.tokenlist.json',
|
|
15
|
-
faucetUrls: ['https://stakely.io/faucet/polygon-matic'],
|
|
16
|
-
multicallAddress: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
17
|
-
metamask: {
|
|
18
|
-
chainId: '0x89',
|
|
19
|
-
blockExplorerUrls: [
|
|
20
|
-
'https://polygonscan.com/',
|
|
21
|
-
'https://explorer-mainnet.maticvigil.com/',
|
|
22
|
-
],
|
|
23
|
-
chainName: 'Matic(Polygon) Mainnet',
|
|
24
|
-
nativeCurrency: {
|
|
25
|
-
name: 'MATIC',
|
|
26
|
-
symbol: 'MATIC',
|
|
27
|
-
decimals: 18,
|
|
28
|
-
},
|
|
29
|
-
rpcUrls: [
|
|
30
|
-
'https://polygon-rpc.com/',
|
|
31
|
-
'https://rpc-mainnet.maticvigil.com/',
|
|
32
|
-
],
|
|
33
|
-
},
|
|
34
|
-
nativeToken: {
|
|
35
|
-
address: '0x0000000000000000000000000000000000000000',
|
|
36
|
-
chainId: 137,
|
|
37
|
-
symbol: 'MATIC',
|
|
38
|
-
decimals: 18,
|
|
39
|
-
name: 'MATIC',
|
|
40
|
-
priceUSD: '0.899628',
|
|
41
|
-
logoURI: 'https://static.debank.com/image/matic_token/logo_url/matic/6f5a6b6f0732a7a235131bd7804d357c.png',
|
|
42
|
-
coinKey: 'MATIC',
|
|
43
|
-
},
|
|
44
|
-
},
|
|
45
|
-
];
|
|
46
|
-
exports.mockTransactionRequest = {
|
|
47
|
-
transactionRequest: {
|
|
48
|
-
// eslint-disable-next-line max-len
|
|
49
|
-
data: '0xdata',
|
|
50
|
-
to: '0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE',
|
|
51
|
-
value: '0x0600830dbc7f5bf7',
|
|
52
|
-
from: '0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0',
|
|
53
|
-
chainId: 137,
|
|
54
|
-
gasPrice: '0x27c01c1727',
|
|
55
|
-
gasLimit: '682701',
|
|
56
|
-
},
|
|
57
|
-
};
|
|
58
|
-
exports.mockStatus = {
|
|
59
|
-
status: 'DONE',
|
|
60
|
-
receiving: true,
|
|
61
|
-
sending: {
|
|
62
|
-
amount: '123',
|
|
63
|
-
gasAmount: '123',
|
|
64
|
-
gasAmountUSD: '123',
|
|
65
|
-
gasPrice: '123',
|
|
66
|
-
gasToken: '123',
|
|
67
|
-
gasUsed: '123',
|
|
68
|
-
},
|
|
69
|
-
};
|
|
70
|
-
const mockStepTransactionWithTxRequest = (step = (0, fixtures_1.buildStepObject)({
|
|
71
|
-
includingExecution: false,
|
|
72
|
-
})) => ({
|
|
73
|
-
...step,
|
|
74
|
-
transactionRequest: exports.mockTransactionRequest,
|
|
75
|
-
});
|
|
76
|
-
exports.mockStepTransactionWithTxRequest = mockStepTransactionWithTxRequest;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const handlers: import("msw").RestHandler<import("msw/lib/glossary-de6278a9").M<import("msw/lib/glossary-de6278a9").h>>[];
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.handlers = void 0;
|
|
7
|
-
const types_1 = require("@lifi/types");
|
|
8
|
-
const msw_1 = require("msw");
|
|
9
|
-
const ConfigService_1 = __importDefault(require("./ConfigService"));
|
|
10
|
-
const config = ConfigService_1.default.getInstance().getConfig();
|
|
11
|
-
exports.handlers = [
|
|
12
|
-
msw_1.rest.post(`${config.apiUrl}/advanced/routes`, async (request, response, context) => {
|
|
13
|
-
const data = await request.json();
|
|
14
|
-
if (isNaN(parseFloat(data.fromAmount))) {
|
|
15
|
-
return response(context.status(500), context.json({ message: `Oops` }));
|
|
16
|
-
}
|
|
17
|
-
return response(context.json({}));
|
|
18
|
-
}),
|
|
19
|
-
msw_1.rest.post(`${config.apiUrl}/advanced/possibilities`, async (request, response, context) => {
|
|
20
|
-
return response(context.json({}));
|
|
21
|
-
}),
|
|
22
|
-
msw_1.rest.get(`${config.apiUrl}/token`, async (request, response, context) => {
|
|
23
|
-
return response(context.json({}));
|
|
24
|
-
}),
|
|
25
|
-
msw_1.rest.get(`${config.apiUrl}/quote`, async (request, response, context) => {
|
|
26
|
-
return response(context.json({}));
|
|
27
|
-
}),
|
|
28
|
-
msw_1.rest.get(`${config.apiUrl}/status`, async (request, response, context) => {
|
|
29
|
-
return response(context.json({}));
|
|
30
|
-
}),
|
|
31
|
-
msw_1.rest.get(`${config.apiUrl}/chains`, async (request, response, context) => {
|
|
32
|
-
return response(context.json({ chains: [{ id: 1 }] }));
|
|
33
|
-
}),
|
|
34
|
-
msw_1.rest.get(`${config.apiUrl}/tools`, async (request, response, context) => {
|
|
35
|
-
return response(context.json({ bridges: [], exchanges: [] }));
|
|
36
|
-
}),
|
|
37
|
-
msw_1.rest.get(`${config.apiUrl}/tokens`, async (request, response, context) => {
|
|
38
|
-
return response(context.json({
|
|
39
|
-
tokens: {
|
|
40
|
-
[types_1.ChainId.ETH]: [(0, types_1.findDefaultToken)(types_1.CoinKey.ETH, types_1.ChainId.ETH)],
|
|
41
|
-
},
|
|
42
|
-
}));
|
|
43
|
-
}),
|
|
44
|
-
msw_1.rest.post(`${config.apiUrl}/advanced/stepTransaction`, async (request, response, context) => {
|
|
45
|
-
return response(context.json({}));
|
|
46
|
-
}),
|
|
47
|
-
msw_1.rest.get(`${config.apiUrl}/gas/suggestion/${types_1.ChainId.OPT}`, async (request, response, context) => {
|
|
48
|
-
return response(context.json({}));
|
|
49
|
-
}),
|
|
50
|
-
];
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { LifiStep, Route } from '@lifi/types';
|
|
2
|
-
export declare const buildStepObject: ({ includingExecution, }: {
|
|
3
|
-
includingExecution?: boolean | undefined;
|
|
4
|
-
}) => LifiStep;
|
|
5
|
-
export declare const buildRouteObject: ({ step, }: {
|
|
6
|
-
step?: LifiStep | undefined;
|
|
7
|
-
}) => Route;
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// This file holds generator functions to create objects for testing purposes
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.buildRouteObject = exports.buildStepObject = void 0;
|
|
5
|
-
const types_1 = require("@lifi/types");
|
|
6
|
-
const SOME_TOKEN = {
|
|
7
|
-
...(0, types_1.findDefaultToken)(types_1.CoinKey.USDC, types_1.ChainId.DAI),
|
|
8
|
-
priceUSD: '',
|
|
9
|
-
};
|
|
10
|
-
const SOME_OTHER_TOKEN = {
|
|
11
|
-
...(0, types_1.findDefaultToken)(types_1.CoinKey.USDT, types_1.ChainId.DAI),
|
|
12
|
-
priceUSD: '',
|
|
13
|
-
};
|
|
14
|
-
const SOME_DATE = new Date('2021-04-10').getTime();
|
|
15
|
-
const buildStepObject = ({ includingExecution = true, }) => ({
|
|
16
|
-
id: '8d3a0474-4ee3-4a7a-90c7-2a2264b7f3a9',
|
|
17
|
-
type: 'lifi',
|
|
18
|
-
tool: '1inch',
|
|
19
|
-
toolDetails: {
|
|
20
|
-
key: '1inch',
|
|
21
|
-
name: '1inch',
|
|
22
|
-
logoURI: 'https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/exchanges/oneinch.png',
|
|
23
|
-
},
|
|
24
|
-
action: {
|
|
25
|
-
fromChainId: 137,
|
|
26
|
-
toChainId: 137,
|
|
27
|
-
fromToken: SOME_TOKEN,
|
|
28
|
-
toToken: SOME_OTHER_TOKEN,
|
|
29
|
-
fromAmount: '1000000',
|
|
30
|
-
slippage: 0.03,
|
|
31
|
-
fromAddress: '0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0',
|
|
32
|
-
toAddress: '0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0',
|
|
33
|
-
},
|
|
34
|
-
estimate: {
|
|
35
|
-
fromAmount: '1000000',
|
|
36
|
-
fromAmountUSD: '100',
|
|
37
|
-
toAmount: '260982615655554',
|
|
38
|
-
toAmountUSD: '26098',
|
|
39
|
-
toAmountMin: '253153137185887',
|
|
40
|
-
approvalAddress: '0x11111112542d85b3ef69ae05771c2dccff4faa26',
|
|
41
|
-
executionDuration: 300,
|
|
42
|
-
tool: '1inch',
|
|
43
|
-
},
|
|
44
|
-
includedSteps: [
|
|
45
|
-
{
|
|
46
|
-
id: 'f8474598-a553-4643-bbd1-bf8c77e679b3',
|
|
47
|
-
type: 'swap',
|
|
48
|
-
action: {
|
|
49
|
-
fromChainId: 137,
|
|
50
|
-
fromAmount: '5000000000000000000',
|
|
51
|
-
fromToken: {
|
|
52
|
-
address: '0x0000000000000000000000000000000000000000',
|
|
53
|
-
chainId: 137,
|
|
54
|
-
symbol: 'MATIC',
|
|
55
|
-
decimals: 18,
|
|
56
|
-
name: 'MATIC',
|
|
57
|
-
priceUSD: '1.124763',
|
|
58
|
-
logoURI: 'https://static.debank.com/image/matic_token/logo_url/matic/6f5a6b6f0732a7a235131bd7804d357c.png',
|
|
59
|
-
coinKey: types_1.CoinKey.MATIC,
|
|
60
|
-
},
|
|
61
|
-
toChainId: 137,
|
|
62
|
-
toToken: {
|
|
63
|
-
address: '0xc2132d05d31c914a87c6611c10748aeb04b58e8f',
|
|
64
|
-
chainId: 137,
|
|
65
|
-
symbol: 'USDT',
|
|
66
|
-
decimals: 6,
|
|
67
|
-
name: '(PoS) Tether USD',
|
|
68
|
-
priceUSD: '1.00081',
|
|
69
|
-
logoURI: 'https://static.debank.com/image/coin/logo_url/usdt/23af7472292cb41dc39b3f1146ead0fe.png',
|
|
70
|
-
coinKey: types_1.CoinKey.USDT,
|
|
71
|
-
},
|
|
72
|
-
slippage: 0.005,
|
|
73
|
-
},
|
|
74
|
-
estimate: {
|
|
75
|
-
tool: '1inch',
|
|
76
|
-
fromAmount: '5000000000000000000',
|
|
77
|
-
toAmount: '5617317',
|
|
78
|
-
toAmountMin: '5589230',
|
|
79
|
-
approvalAddress: '0x1111111254eeb25477b68fb85ed929f73a960582',
|
|
80
|
-
executionDuration: 30,
|
|
81
|
-
feeCosts: [],
|
|
82
|
-
gasCosts: [
|
|
83
|
-
{
|
|
84
|
-
type: 'SEND',
|
|
85
|
-
price: '149725515512',
|
|
86
|
-
estimate: '258059',
|
|
87
|
-
limit: '344079',
|
|
88
|
-
amount: '51517405651853448',
|
|
89
|
-
amountUSD: '0.06',
|
|
90
|
-
token: {
|
|
91
|
-
address: '0x0000000000000000000000000000000000000000',
|
|
92
|
-
chainId: 137,
|
|
93
|
-
symbol: 'MATIC',
|
|
94
|
-
decimals: 18,
|
|
95
|
-
name: 'MATIC',
|
|
96
|
-
priceUSD: '1.124763',
|
|
97
|
-
logoURI: 'https://static.debank.com/image/matic_token/logo_url/matic/6f5a6b6f0732a7a235131bd7804d357c.png',
|
|
98
|
-
coinKey: types_1.CoinKey.MATIC,
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
},
|
|
103
|
-
tool: '1inch',
|
|
104
|
-
toolDetails: {
|
|
105
|
-
key: '1inch',
|
|
106
|
-
name: '1inch',
|
|
107
|
-
logoURI: 'https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/exchanges/oneinch.png',
|
|
108
|
-
},
|
|
109
|
-
},
|
|
110
|
-
],
|
|
111
|
-
execution: includingExecution
|
|
112
|
-
? {
|
|
113
|
-
status: 'PENDING',
|
|
114
|
-
process: [
|
|
115
|
-
{
|
|
116
|
-
type: 'TOKEN_ALLOWANCE',
|
|
117
|
-
startedAt: SOME_DATE,
|
|
118
|
-
message: 'Somethings done',
|
|
119
|
-
status: 'DONE',
|
|
120
|
-
doneAt: SOME_DATE + 10,
|
|
121
|
-
txHash: '0x11111112542d85b3ef69ae05771c2dccff4faa26',
|
|
122
|
-
txLink: 'https://example.com',
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
type: 'SWAP',
|
|
126
|
-
startedAt: SOME_DATE + 20,
|
|
127
|
-
message: 'Somethings pending',
|
|
128
|
-
status: 'PENDING',
|
|
129
|
-
},
|
|
130
|
-
],
|
|
131
|
-
fromAmount: '1000000',
|
|
132
|
-
toAmount: '261490494702370',
|
|
133
|
-
}
|
|
134
|
-
: undefined,
|
|
135
|
-
});
|
|
136
|
-
exports.buildStepObject = buildStepObject;
|
|
137
|
-
const buildRouteObject = ({ step = (0, exports.buildStepObject)({}), }) => ({
|
|
138
|
-
id: '0x433df53dbf6dbd7b946fc4f3b501c3ff32957d77d96c9d5ba1805b01eb6461cc',
|
|
139
|
-
fromChainId: 137,
|
|
140
|
-
fromAmountUSD: '1.00',
|
|
141
|
-
fromAmount: '1000000',
|
|
142
|
-
fromToken: SOME_TOKEN,
|
|
143
|
-
fromAddress: '0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0',
|
|
144
|
-
toChainId: 137,
|
|
145
|
-
toAmountUSD: '1.00',
|
|
146
|
-
toAmount: '260982615655554',
|
|
147
|
-
toAmountMin: '253153137185887',
|
|
148
|
-
toToken: SOME_OTHER_TOKEN,
|
|
149
|
-
toAddress: '0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0',
|
|
150
|
-
gasCostUSD: '0.01',
|
|
151
|
-
steps: [step],
|
|
152
|
-
insurance: {
|
|
153
|
-
feeAmountUsd: '0',
|
|
154
|
-
state: 'NOT_INSURABLE',
|
|
155
|
-
},
|
|
156
|
-
});
|
|
157
|
-
exports.buildRouteObject = buildRouteObject;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const lifiHandlers: import("msw").RestHandler<import("msw/lib/glossary-de6278a9").M<import("msw/lib/glossary-de6278a9").h>>[];
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { rest } from 'msw';
|
|
2
|
-
import { mockStepTransactionWithTxRequest, mockChainsResponse, mockStatus, } from './RouteExecutionManager.unit.mock';
|
|
3
|
-
import ConfigService from '../services/ConfigService';
|
|
4
|
-
import { buildStepObject } from '../../test/fixtures';
|
|
5
|
-
const config = ConfigService.getInstance().getConfig();
|
|
6
|
-
export const lifiHandlers = [
|
|
7
|
-
rest.post(`${config.apiUrl}/advanced/stepTransaction`, async (_, response, context) => response(context.status(200), context.json(mockStepTransactionWithTxRequest(buildStepObject({
|
|
8
|
-
includingExecution: true,
|
|
9
|
-
}))))),
|
|
10
|
-
rest.get(`${config.apiUrl}/chains`, async (_, response, context) => response(context.status(200), context.json({
|
|
11
|
-
chains: mockChainsResponse,
|
|
12
|
-
}))),
|
|
13
|
-
rest.get(`${config.apiUrl}/status`, async (_, response, context) => response(context.status(200), context.json(mockStatus))),
|
|
14
|
-
];
|
|
@@ -1,80 +0,0 @@
|
|
|
1
|
-
import { LifiStep } from '@lifi/types';
|
|
2
|
-
export declare const mockChainsResponse: {
|
|
3
|
-
key: string;
|
|
4
|
-
chainType: string;
|
|
5
|
-
name: string;
|
|
6
|
-
coin: string;
|
|
7
|
-
id: number;
|
|
8
|
-
mainnet: boolean;
|
|
9
|
-
logoURI: string;
|
|
10
|
-
tokenlistUrl: string;
|
|
11
|
-
faucetUrls: string[];
|
|
12
|
-
multicallAddress: string;
|
|
13
|
-
metamask: {
|
|
14
|
-
chainId: string;
|
|
15
|
-
blockExplorerUrls: string[];
|
|
16
|
-
chainName: string;
|
|
17
|
-
nativeCurrency: {
|
|
18
|
-
name: string;
|
|
19
|
-
symbol: string;
|
|
20
|
-
decimals: number;
|
|
21
|
-
};
|
|
22
|
-
rpcUrls: string[];
|
|
23
|
-
};
|
|
24
|
-
nativeToken: {
|
|
25
|
-
address: string;
|
|
26
|
-
chainId: number;
|
|
27
|
-
symbol: string;
|
|
28
|
-
decimals: number;
|
|
29
|
-
name: string;
|
|
30
|
-
priceUSD: string;
|
|
31
|
-
logoURI: string;
|
|
32
|
-
coinKey: string;
|
|
33
|
-
};
|
|
34
|
-
}[];
|
|
35
|
-
export declare const mockTransactionRequest: {
|
|
36
|
-
transactionRequest: {
|
|
37
|
-
data: string;
|
|
38
|
-
to: string;
|
|
39
|
-
value: string;
|
|
40
|
-
from: string;
|
|
41
|
-
chainId: number;
|
|
42
|
-
gasPrice: string;
|
|
43
|
-
gasLimit: string;
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
export declare const mockStatus: {
|
|
47
|
-
status: string;
|
|
48
|
-
receiving: boolean;
|
|
49
|
-
sending: {
|
|
50
|
-
amount: string;
|
|
51
|
-
gasAmount: string;
|
|
52
|
-
gasAmountUSD: string;
|
|
53
|
-
gasPrice: string;
|
|
54
|
-
gasToken: string;
|
|
55
|
-
gasUsed: string;
|
|
56
|
-
};
|
|
57
|
-
};
|
|
58
|
-
export declare const mockStepTransactionWithTxRequest: (step?: LifiStep) => {
|
|
59
|
-
transactionRequest: {
|
|
60
|
-
transactionRequest: {
|
|
61
|
-
data: string;
|
|
62
|
-
to: string;
|
|
63
|
-
value: string;
|
|
64
|
-
from: string;
|
|
65
|
-
chainId: number;
|
|
66
|
-
gasPrice: string;
|
|
67
|
-
gasLimit: string;
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
type: "lifi";
|
|
71
|
-
includedSteps: import("@lifi/types").Step[];
|
|
72
|
-
id: string;
|
|
73
|
-
referrer?: string | undefined;
|
|
74
|
-
action: import("@lifi/types").Action | import("@lifi/types").CallAction;
|
|
75
|
-
estimate: import("@lifi/types").Estimate;
|
|
76
|
-
tool: string;
|
|
77
|
-
toolDetails: Pick<import("@lifi/types").Bridge | import("@lifi/types").ExchangeAggregator | import("@lifi/types").Exchange, "key" | "name" | "logoURI">;
|
|
78
|
-
integrator?: string | undefined;
|
|
79
|
-
execution?: import("@lifi/types").Execution | undefined;
|
|
80
|
-
};
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { buildStepObject } from '../../test/fixtures';
|
|
2
|
-
export const mockChainsResponse = [
|
|
3
|
-
{
|
|
4
|
-
key: 'pol',
|
|
5
|
-
chainType: 'EVM',
|
|
6
|
-
name: 'Polygon',
|
|
7
|
-
coin: 'MATIC',
|
|
8
|
-
id: 137,
|
|
9
|
-
mainnet: true,
|
|
10
|
-
logoURI: 'https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/chains/polygon.svg',
|
|
11
|
-
tokenlistUrl: 'https://unpkg.com/quickswap-default-token-list@1.0.71/build/quickswap-default.tokenlist.json',
|
|
12
|
-
faucetUrls: ['https://stakely.io/faucet/polygon-matic'],
|
|
13
|
-
multicallAddress: '0xcA11bde05977b3631167028862bE2a173976CA11',
|
|
14
|
-
metamask: {
|
|
15
|
-
chainId: '0x89',
|
|
16
|
-
blockExplorerUrls: [
|
|
17
|
-
'https://polygonscan.com/',
|
|
18
|
-
'https://explorer-mainnet.maticvigil.com/',
|
|
19
|
-
],
|
|
20
|
-
chainName: 'Matic(Polygon) Mainnet',
|
|
21
|
-
nativeCurrency: {
|
|
22
|
-
name: 'MATIC',
|
|
23
|
-
symbol: 'MATIC',
|
|
24
|
-
decimals: 18,
|
|
25
|
-
},
|
|
26
|
-
rpcUrls: [
|
|
27
|
-
'https://polygon-rpc.com/',
|
|
28
|
-
'https://rpc-mainnet.maticvigil.com/',
|
|
29
|
-
],
|
|
30
|
-
},
|
|
31
|
-
nativeToken: {
|
|
32
|
-
address: '0x0000000000000000000000000000000000000000',
|
|
33
|
-
chainId: 137,
|
|
34
|
-
symbol: 'MATIC',
|
|
35
|
-
decimals: 18,
|
|
36
|
-
name: 'MATIC',
|
|
37
|
-
priceUSD: '0.899628',
|
|
38
|
-
logoURI: 'https://static.debank.com/image/matic_token/logo_url/matic/6f5a6b6f0732a7a235131bd7804d357c.png',
|
|
39
|
-
coinKey: 'MATIC',
|
|
40
|
-
},
|
|
41
|
-
},
|
|
42
|
-
];
|
|
43
|
-
export const mockTransactionRequest = {
|
|
44
|
-
transactionRequest: {
|
|
45
|
-
// eslint-disable-next-line max-len
|
|
46
|
-
data: '0xdata',
|
|
47
|
-
to: '0x1231DEB6f5749EF6cE6943a275A1D3E7486F4EaE',
|
|
48
|
-
value: '0x0600830dbc7f5bf7',
|
|
49
|
-
from: '0x552008c0f6870c2f77e5cC1d2eb9bdff03e30Ea0',
|
|
50
|
-
chainId: 137,
|
|
51
|
-
gasPrice: '0x27c01c1727',
|
|
52
|
-
gasLimit: '682701',
|
|
53
|
-
},
|
|
54
|
-
};
|
|
55
|
-
export const mockStatus = {
|
|
56
|
-
status: 'DONE',
|
|
57
|
-
receiving: true,
|
|
58
|
-
sending: {
|
|
59
|
-
amount: '123',
|
|
60
|
-
gasAmount: '123',
|
|
61
|
-
gasAmountUSD: '123',
|
|
62
|
-
gasPrice: '123',
|
|
63
|
-
gasToken: '123',
|
|
64
|
-
gasUsed: '123',
|
|
65
|
-
},
|
|
66
|
-
};
|
|
67
|
-
export const mockStepTransactionWithTxRequest = (step = buildStepObject({
|
|
68
|
-
includingExecution: false,
|
|
69
|
-
})) => ({
|
|
70
|
-
...step,
|
|
71
|
-
transactionRequest: mockTransactionRequest,
|
|
72
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const handlers: import("msw").RestHandler<import("msw/lib/glossary-de6278a9").M<import("msw/lib/glossary-de6278a9").h>>[];
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import { ChainId, CoinKey, findDefaultToken } from '@lifi/types';
|
|
2
|
-
import { rest } from 'msw';
|
|
3
|
-
import ConfigService from './ConfigService';
|
|
4
|
-
const config = ConfigService.getInstance().getConfig();
|
|
5
|
-
export const handlers = [
|
|
6
|
-
rest.post(`${config.apiUrl}/advanced/routes`, async (request, response, context) => {
|
|
7
|
-
const data = await request.json();
|
|
8
|
-
if (isNaN(parseFloat(data.fromAmount))) {
|
|
9
|
-
return response(context.status(500), context.json({ message: `Oops` }));
|
|
10
|
-
}
|
|
11
|
-
return response(context.json({}));
|
|
12
|
-
}),
|
|
13
|
-
rest.post(`${config.apiUrl}/advanced/possibilities`, async (request, response, context) => {
|
|
14
|
-
return response(context.json({}));
|
|
15
|
-
}),
|
|
16
|
-
rest.get(`${config.apiUrl}/token`, async (request, response, context) => {
|
|
17
|
-
return response(context.json({}));
|
|
18
|
-
}),
|
|
19
|
-
rest.get(`${config.apiUrl}/quote`, async (request, response, context) => {
|
|
20
|
-
return response(context.json({}));
|
|
21
|
-
}),
|
|
22
|
-
rest.get(`${config.apiUrl}/status`, async (request, response, context) => {
|
|
23
|
-
return response(context.json({}));
|
|
24
|
-
}),
|
|
25
|
-
rest.get(`${config.apiUrl}/chains`, async (request, response, context) => {
|
|
26
|
-
return response(context.json({ chains: [{ id: 1 }] }));
|
|
27
|
-
}),
|
|
28
|
-
rest.get(`${config.apiUrl}/tools`, async (request, response, context) => {
|
|
29
|
-
return response(context.json({ bridges: [], exchanges: [] }));
|
|
30
|
-
}),
|
|
31
|
-
rest.get(`${config.apiUrl}/tokens`, async (request, response, context) => {
|
|
32
|
-
return response(context.json({
|
|
33
|
-
tokens: {
|
|
34
|
-
[ChainId.ETH]: [findDefaultToken(CoinKey.ETH, ChainId.ETH)],
|
|
35
|
-
},
|
|
36
|
-
}));
|
|
37
|
-
}),
|
|
38
|
-
rest.post(`${config.apiUrl}/advanced/stepTransaction`, async (request, response, context) => {
|
|
39
|
-
return response(context.json({}));
|
|
40
|
-
}),
|
|
41
|
-
rest.get(`${config.apiUrl}/gas/suggestion/${ChainId.OPT}`, async (request, response, context) => {
|
|
42
|
-
return response(context.json({}));
|
|
43
|
-
}),
|
|
44
|
-
];
|
package/dist/src/version.d.ts
DELETED
package/dist/src/version.js
DELETED
package/dist/test/fixtures.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { LifiStep, Route } from '@lifi/types';
|
|
2
|
-
export declare const buildStepObject: ({ includingExecution, }: {
|
|
3
|
-
includingExecution?: boolean | undefined;
|
|
4
|
-
}) => LifiStep;
|
|
5
|
-
export declare const buildRouteObject: ({ step, }: {
|
|
6
|
-
step?: LifiStep | undefined;
|
|
7
|
-
}) => Route;
|