@lifi/sdk 1.1.4 → 1.2.0

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.
Files changed (73) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/Lifi.js +3 -0
  3. package/dist/cjs/Lifi.d.ts +200 -0
  4. package/dist/cjs/Lifi.js +379 -0
  5. package/dist/cjs/allowance/index.d.ts +22 -0
  6. package/dist/cjs/allowance/index.js +78 -0
  7. package/dist/cjs/allowance/utils.d.ts +14 -0
  8. package/dist/cjs/allowance/utils.js +82 -0
  9. package/dist/cjs/balances/index.d.ts +11 -0
  10. package/dist/cjs/balances/index.js +46 -0
  11. package/dist/cjs/balances/utils.d.ts +5 -0
  12. package/dist/cjs/balances/utils.js +150 -0
  13. package/dist/cjs/connectors.d.ts +6 -0
  14. package/dist/cjs/connectors.js +77 -0
  15. package/dist/cjs/execution/StatusManager.d.ts +65 -0
  16. package/dist/cjs/execution/StatusManager.js +167 -0
  17. package/dist/cjs/execution/StepExecutor.d.ts +15 -0
  18. package/dist/cjs/execution/StepExecutor.js +74 -0
  19. package/dist/cjs/execution/allowance.execute.d.ts +4 -0
  20. package/dist/cjs/execution/allowance.execute.js +97 -0
  21. package/dist/cjs/execution/balanceCheck.execute.d.ts +3 -0
  22. package/dist/cjs/execution/balanceCheck.execute.js +48 -0
  23. package/dist/cjs/execution/bridges/bridge.execute.d.ts +7 -0
  24. package/dist/cjs/execution/bridges/bridge.execute.js +154 -0
  25. package/dist/cjs/execution/exchanges/swap.execute.d.ts +7 -0
  26. package/dist/cjs/execution/exchanges/swap.execute.js +164 -0
  27. package/dist/cjs/execution/index.d.ts +1 -0
  28. package/dist/cjs/execution/index.js +17 -0
  29. package/dist/cjs/execution/stepComparison.d.ts +14 -0
  30. package/dist/cjs/execution/stepComparison.js +46 -0
  31. package/dist/cjs/execution/switchChain.d.ts +16 -0
  32. package/dist/cjs/execution/switchChain.js +58 -0
  33. package/dist/cjs/execution/utils.d.ts +6 -0
  34. package/dist/cjs/execution/utils.js +137 -0
  35. package/dist/cjs/helpers.d.ts +19 -0
  36. package/dist/cjs/helpers.js +88 -0
  37. package/dist/cjs/index.d.ts +6 -0
  38. package/dist/cjs/index.js +27 -0
  39. package/dist/cjs/services/ApiService.d.ts +15 -0
  40. package/dist/cjs/services/ApiService.js +272 -0
  41. package/dist/cjs/services/ChainsService.d.ts +11 -0
  42. package/dist/cjs/services/ChainsService.js +54 -0
  43. package/dist/cjs/services/ConfigService.d.ts +23 -0
  44. package/dist/cjs/services/ConfigService.js +98 -0
  45. package/dist/cjs/typeguards.d.ts +4 -0
  46. package/dist/cjs/typeguards.js +53 -0
  47. package/dist/cjs/types/ERC20.d.ts +22 -0
  48. package/dist/cjs/types/ERC20.js +53 -0
  49. package/dist/cjs/types/index.d.ts +4 -0
  50. package/dist/cjs/types/index.js +22 -0
  51. package/dist/cjs/types/internal.types.d.ts +87 -0
  52. package/dist/cjs/types/internal.types.js +2 -0
  53. package/dist/cjs/utils/errors.d.ts +75 -0
  54. package/dist/cjs/utils/errors.js +115 -0
  55. package/dist/cjs/utils/getProvider.d.ts +3 -0
  56. package/dist/cjs/utils/getProvider.js +11 -0
  57. package/dist/cjs/utils/multicall.d.ts +10 -0
  58. package/dist/cjs/utils/multicall.js +77 -0
  59. package/dist/cjs/utils/multicallAbi.json +313 -0
  60. package/dist/cjs/utils/parseError.d.ts +38 -0
  61. package/dist/cjs/utils/parseError.js +141 -0
  62. package/dist/cjs/utils/preRestart.d.ts +2 -0
  63. package/dist/cjs/utils/preRestart.js +31 -0
  64. package/dist/cjs/utils/utils.d.ts +26 -0
  65. package/dist/cjs/utils/utils.js +120 -0
  66. package/dist/cjs/version.d.ts +2 -0
  67. package/dist/cjs/version.js +5 -0
  68. package/dist/helpers.d.ts +1 -0
  69. package/dist/helpers.js +33 -0
  70. package/dist/types/internal.types.d.ts +2 -0
  71. package/dist/version.d.ts +2 -0
  72. package/dist/version.js +2 -0
  73. package/package.json +40 -12
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.version = exports.name = void 0;
4
+ exports.name = '@lifi/sdk';
5
+ exports.version = '1.2.0';
package/dist/helpers.d.ts CHANGED
@@ -16,3 +16,4 @@ export declare const getEthereumPublicKeyHook: (walletAddress: string) => () =>
16
16
  */
17
17
  export declare const getRandomNumber: (min: number, max: number) => number;
18
18
  export declare const isSameToken: (tokenA: Token, tokenB: Token) => boolean;
19
+ export declare const checkPackageUpdates: (packageName?: string, packageVersion?: string, disableCheck?: boolean) => Promise<void>;
package/dist/helpers.js CHANGED
@@ -7,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
+ import { name, version } from './version';
10
11
  const ethereumRequest = (method, params) => __awaiter(void 0, void 0, void 0, function* () {
11
12
  // If ethereum.request() exists, the provider is probably EIP-1193 compliant.
12
13
  if (!ethereum || !ethereum.request) {
@@ -45,3 +46,35 @@ export const getRandomNumber = (min, max) => {
45
46
  };
46
47
  export const isSameToken = (tokenA, tokenB) => tokenA.chainId === tokenB.chainId &&
47
48
  tokenA.address.toLowerCase() === tokenB.address.toLowerCase();
49
+ function semverCompare(a, b) {
50
+ if (a.startsWith(b + '-')) {
51
+ return -1;
52
+ }
53
+ if (b.startsWith(a + '-')) {
54
+ return 1;
55
+ }
56
+ return a.localeCompare(b, undefined, {
57
+ numeric: true,
58
+ sensitivity: 'case',
59
+ caseFirst: 'upper',
60
+ });
61
+ }
62
+ export const checkPackageUpdates = (packageName, packageVersion, disableCheck) => __awaiter(void 0, void 0, void 0, function* () {
63
+ if (disableCheck || process.env.NODE_ENV !== 'development') {
64
+ return;
65
+ }
66
+ try {
67
+ const pkgName = packageName !== null && packageName !== void 0 ? packageName : name;
68
+ const response = yield (yield fetch(`https://unpkg.com/${pkgName}/package.json`)).json();
69
+ const latestVersion = response.version;
70
+ const currentVersion = packageVersion !== null && packageVersion !== void 0 ? packageVersion : version;
71
+ if (semverCompare(latestVersion, currentVersion)) {
72
+ console.warn(
73
+ // eslint-disable-next-line max-len
74
+ `${pkgName}: new package version is available. Please update as soon as possible to enjoy the newest features. Current version: ${currentVersion}. Latest version: ${latestVersion}.`);
75
+ }
76
+ }
77
+ catch (error) {
78
+ // Cannot verify version, might be network error etc. We don't bother showing anything in that case
79
+ }
80
+ });
@@ -35,6 +35,7 @@ export declare type Config = {
35
35
  multicallAddresses: Record<ChainId, string | undefined>;
36
36
  defaultExecutionSettings: InternalExecutionSettings;
37
37
  defaultRouteOptions: RouteOptions;
38
+ disableVersionCheck?: boolean;
38
39
  };
39
40
  export declare type ConfigUpdate = {
40
41
  apiUrl?: string;
@@ -42,6 +43,7 @@ export declare type ConfigUpdate = {
42
43
  multicallAddresses?: Record<number, string | undefined>;
43
44
  defaultExecutionSettings?: ExecutionSettings;
44
45
  defaultRouteOptions?: RouteOptions;
46
+ disableVersionCheck?: boolean;
45
47
  };
46
48
  export declare type SwitchChainHook = (requiredChainId: number) => Promise<Signer | undefined>;
47
49
  export interface AcceptSlippageUpdateHookParams {
@@ -0,0 +1,2 @@
1
+ export declare const name = "@lifi/sdk";
2
+ export declare const version = "1.2.0";
@@ -0,0 +1,2 @@
1
+ export const name = '@lifi/sdk';
2
+ export const version = '1.2.0';
package/package.json CHANGED
@@ -1,12 +1,17 @@
1
1
  {
2
2
  "name": "@lifi/sdk",
3
- "version": "1.1.4",
3
+ "version": "1.2.0",
4
4
  "description": "LI.FI Any-to-Any Cross-Chain-Swap SDK",
5
- "main": "./dist/index.js",
5
+ "main": "./dist/cjs/index.js",
6
+ "module": "./dist/index.js",
6
7
  "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ "require": "./dist/cjs/index.js",
10
+ "import": "./dist/index.js"
11
+ },
7
12
  "scripts": {
8
13
  "watch": "tsc -w -p ./tsconfig.json",
9
- "build": "yarn clean && tsc --project ./tsconfig.json",
14
+ "build": "yarn clean && tsc --project ./tsconfig.json && tsc --project ./tsconfig.cjs.json",
10
15
  "clean": "node tools/cleanup",
11
16
  "package": "npm run build && npm pack",
12
17
  "test": "jest --no-cache --runInBand --forceExit",
@@ -25,7 +30,12 @@
25
30
  "prepublishOnly": "run-s build use:npmReadme && pinst --enable",
26
31
  "postpublish": "npm run use:gitReadme && pinst --enable",
27
32
  "prepare": "husky install",
28
- "release": "standard-version"
33
+ "release": "standard-version -a"
34
+ },
35
+ "standard-version": {
36
+ "scripts": {
37
+ "postbump": "node scripts/version.js && git add ."
38
+ }
29
39
  },
30
40
  "lint-staged": {
31
41
  "src/**/*.{ts,tsx}": [
@@ -41,6 +51,24 @@
41
51
  },
42
52
  "author": "Max Klenk <max@li.finance>",
43
53
  "license": "Apache-2.0",
54
+ "keywords": [
55
+ "sdk",
56
+ "ethereum",
57
+ "dapp",
58
+ "bridge",
59
+ "swap",
60
+ "web3",
61
+ "lifi",
62
+ "ethers",
63
+ "cross-chain",
64
+ "defi",
65
+ "web3-react",
66
+ "cross-chain-applications",
67
+ "cross-chain-bridge",
68
+ "bridge-aggregation",
69
+ "multi-chain",
70
+ "metamask"
71
+ ],
44
72
  "homepage": "https://github.com/lifinance/sdk",
45
73
  "repository": {
46
74
  "type": "git",
@@ -52,9 +80,9 @@
52
80
  "dependencies": {
53
81
  "@ethersproject/abi": "^5.6.4",
54
82
  "@ethersproject/contracts": "^5.6.2",
55
- "@lifi/types": "^1.3.0",
83
+ "@lifi/types": "^1.5.1",
56
84
  "axios": "^0.27.2",
57
- "bignumber.js": "^9.0.1",
85
+ "bignumber.js": "^9.1.0",
58
86
  "eth-rpc-errors": "^4.0.3",
59
87
  "ethers": "^5.6.9"
60
88
  },
@@ -62,13 +90,13 @@
62
90
  "@commitlint/cli": "^17.0.3",
63
91
  "@commitlint/config-conventional": "^17.0.3",
64
92
  "@types/bip39": "^3.0.0",
65
- "@types/chai": "^4.3.1",
93
+ "@types/chai": "^4.3.3",
66
94
  "@types/hdkey": "^2.0.0",
67
- "@types/jest": "^28.1.4",
95
+ "@types/jest": "^28.1.7",
68
96
  "@types/websocket": "^1.0.4",
69
- "@typescript-eslint/eslint-plugin": "^5.32.0",
70
- "@typescript-eslint/parser": "^5.32.0",
71
- "eslint": "^8.19.0",
97
+ "@typescript-eslint/eslint-plugin": "^5.33.1",
98
+ "@typescript-eslint/parser": "^5.33.1",
99
+ "eslint": "^8.22.0",
72
100
  "eslint-config-prettier": "^8.3.0",
73
101
  "eslint-plugin-prettier": "^4.2.1",
74
102
  "husky": "^8.0.1",
@@ -78,7 +106,7 @@
78
106
  "pinst": "^3.0.0",
79
107
  "prettier": "^2.7.1",
80
108
  "standard-version": "^9.5.0",
81
- "ts-jest": "^28.0.5",
109
+ "ts-jest": "^28.0.8",
82
110
  "ts-loader": "^9.3.1",
83
111
  "typescript": "^4.7.4",
84
112
  "webpack": "^5.73.0",