@gearbox-protocol/sdk 3.0.0-vfourabi.4 → 3.0.0-vfourabi.5

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 (61) hide show
  1. package/.yarn/install-state.gz +0 -0
  2. package/dist/cjs/abi/compressors.cjs +3848 -3823
  3. package/dist/cjs/abi/compressors.d.ts +13 -15
  4. package/dist/cjs/abi/errors.cjs +188 -195
  5. package/dist/cjs/abi/errors.d.ts +6 -8
  6. package/dist/cjs/abi/iERC20.cjs +123 -122
  7. package/dist/cjs/abi/iERC20.d.ts +1 -3
  8. package/dist/cjs/abi/iPausable.cjs +37 -39
  9. package/dist/cjs/abi/iPausable.d.ts +1 -3
  10. package/dist/cjs/abi/iPriceFeedStore.cjs +229 -231
  11. package/dist/cjs/abi/iPriceFeedStore.d.ts +1 -3
  12. package/dist/cjs/abi/iUpdatablePriceFeed.cjs +18 -20
  13. package/dist/cjs/abi/iUpdatablePriceFeed.d.ts +1 -3
  14. package/dist/cjs/abi/iVersion.cjs +30 -32
  15. package/dist/cjs/abi/iVersion.d.ts +1 -3
  16. package/dist/cjs/abi/iZapper.cjs +85 -84
  17. package/dist/cjs/abi/iZapper.d.ts +1 -3
  18. package/dist/cjs/abi/index.cjs +27 -0
  19. package/dist/cjs/abi/index.d.ts +11 -0
  20. package/dist/cjs/abi/routerV300.cjs +378 -381
  21. package/dist/cjs/abi/routerV300.d.ts +2 -4
  22. package/dist/cjs/abi/v300.cjs +4125 -4138
  23. package/dist/cjs/abi/v300.d.ts +12 -14
  24. package/dist/cjs/abi/v310.cjs +5141 -5116
  25. package/dist/cjs/abi/v310.d.ts +13 -15
  26. package/dist/cjs/dev/index.d.ts +287 -1
  27. package/dist/cjs/sdk/index.cjs +18865 -18931
  28. package/dist/cjs/sdk/index.d.ts +13552 -8345
  29. package/dist/esm/abi/compressors.d.mts +13 -15
  30. package/dist/esm/abi/compressors.mjs +3845 -3809
  31. package/dist/esm/abi/errors.d.mts +6 -8
  32. package/dist/esm/abi/errors.mjs +185 -188
  33. package/dist/esm/abi/iERC20.d.mts +1 -3
  34. package/dist/esm/abi/iERC20.mjs +120 -120
  35. package/dist/esm/abi/iPausable.d.mts +1 -3
  36. package/dist/esm/abi/iPausable.mjs +34 -37
  37. package/dist/esm/abi/iPriceFeedStore.d.mts +1 -3
  38. package/dist/esm/abi/iPriceFeedStore.mjs +226 -229
  39. package/dist/esm/abi/iUpdatablePriceFeed.d.mts +1 -3
  40. package/dist/esm/abi/iUpdatablePriceFeed.mjs +15 -18
  41. package/dist/esm/abi/iVersion.d.mts +1 -3
  42. package/dist/esm/abi/iVersion.mjs +27 -30
  43. package/dist/esm/abi/iZapper.d.mts +1 -3
  44. package/dist/esm/abi/iZapper.mjs +82 -82
  45. package/dist/esm/abi/index.d.mts +11 -0
  46. package/dist/esm/abi/index.mjs +11 -0
  47. package/dist/esm/abi/routerV300.d.mts +2 -4
  48. package/dist/esm/abi/routerV300.mjs +375 -378
  49. package/dist/esm/abi/v300.d.mts +12 -14
  50. package/dist/esm/abi/v300.mjs +4122 -4125
  51. package/dist/esm/abi/v310.d.mts +13 -15
  52. package/dist/esm/abi/v310.mjs +5138 -5102
  53. package/dist/esm/dev/index.d.mts +287 -1
  54. package/dist/esm/sdk/index.d.mts +13552 -8345
  55. package/dist/esm/sdk/index.mjs +18866 -18908
  56. package/package.json +1 -2
  57. package/src/abi/index.ts +11 -0
  58. package/src/sdk/index.ts +0 -1
  59. package/tsconfig.abi.json +4 -0
  60. package/tsup.config.ts +58 -8
  61. package/tsconfig.build.json +0 -4
package/package.json CHANGED
@@ -1,12 +1,11 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "3.0.0-vfourabi.4",
3
+ "version": "3.0.0-vfourabi.5",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.cjs",
7
7
  "module": "./dist/esm/sdk/index.mjs",
8
8
  "types": "./dist/cjs/sdk/index.d.ts",
9
- "typings": "./dist/cjs/sdk/index.d.ts",
10
9
  "sideEffects": false,
11
10
  "exports": {
12
11
  "./package.json": "./package.json",
@@ -0,0 +1,11 @@
1
+ export * from "./compressors";
2
+ export * from "./errors";
3
+ export * from "./iERC20";
4
+ export * from "./iPausable";
5
+ export * from "./iPriceFeedStore";
6
+ export * from "./iUpdatablePriceFeed";
7
+ export * from "./iVersion";
8
+ export * from "./iZapper";
9
+ export * from "./routerV300";
10
+ export * from "./v300";
11
+ export * from "./v310";
package/src/sdk/index.ts CHANGED
@@ -1,4 +1,3 @@
1
- export * from "./abi";
2
1
  export * from "./accounts";
3
2
  export * from "./base";
4
3
  export * from "./bots";
@@ -0,0 +1,4 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "include": ["src/abi/**/*.ts"]
4
+ }
package/tsup.config.ts CHANGED
@@ -1,17 +1,29 @@
1
- import { readFile, writeFile } from "node:fs/promises";
1
+ import { glob, mkdir, readFile, rename, writeFile } from "node:fs/promises";
2
2
 
3
3
  import { sync as spawnSync } from "cross-spawn";
4
4
  import type { Options } from "tsup";
5
5
  import { defineConfig } from "tsup";
6
6
 
7
+ /**
8
+ * Write package.json for subpath with CJS or ESM type
9
+ * @param subpath
10
+ * @param type
11
+ */
7
12
  async function writeDummyPackage(subpath: string, type: "cjs" | "esm") {
8
13
  const body =
9
14
  type === "cjs"
10
15
  ? `{"type": "commonjs"}`
11
16
  : `{"type": "module","sideEffects":false}`;
17
+ await mkdir(`./dist/${type}/${subpath}`, { recursive: true });
12
18
  await writeFile(`./dist/${type}/${subpath}/package.json`, body, "utf-8");
13
19
  }
14
20
 
21
+ /**
22
+ * When building ESM modules from subpath that import core SDK, such as dev
23
+ * they'll have `import {...} from "../sdk"` line
24
+ * This method fixes it by replacing `../sdk` with `../sdk/index.mjs`
25
+ * @param subpath
26
+ */
15
27
  async function fixRelativeImports(subpath: string) {
16
28
  for (const ext of ["d.mts", "mjs"]) {
17
29
  let raw = await readFile(`./dist/esm/${subpath}/index.${ext}`, "utf-8");
@@ -20,15 +32,50 @@ async function fixRelativeImports(subpath: string) {
20
32
  }
21
33
  }
22
34
 
35
+ /**
36
+ * Abis are built separately by tsc
37
+ * @param type
38
+ */
39
+ async function buildAbi(type: "cjs" | "esm") {
40
+ const options =
41
+ type === "cjs"
42
+ ? ["--module", "commonjs", "--moduleResolution", "node"]
43
+ : [];
44
+ spawnSync(
45
+ "yarn",
46
+ [
47
+ "tsc",
48
+ "--project",
49
+ "tsconfig.abi.json",
50
+ "--outDir",
51
+ `./dist/${type}/abi`,
52
+ ...options,
53
+ ],
54
+ {
55
+ stdio: "inherit",
56
+ },
57
+ );
58
+ // rename extensions
59
+ const extensions =
60
+ type === "esm"
61
+ ? [
62
+ ["d.ts", "d.mts"],
63
+ ["js", "mjs"],
64
+ ]
65
+ : [["js", "cjs"]];
66
+ for (const [from, to] of extensions) {
67
+ const files = glob(`./dist/${type}/abi/*.${from}`);
68
+ for await (const file of files) {
69
+ const newFile = file.replace(new RegExp(`\\.${from}$`), `.${to}`);
70
+ await rename(file, newFile);
71
+ }
72
+ }
73
+ }
74
+
23
75
  export default defineConfig(options => {
24
76
  const commonOptions: Partial<Options> = {
25
- entry: [
26
- "src/sdk/index.ts",
27
- "src/dev/index.ts",
28
- "src/adapters/index.ts",
29
- "src/abi/**/*.ts",
30
- ],
31
- clean: true,
77
+ entry: ["src/sdk/index.ts", "src/dev/index.ts", "src/adapters/index.ts"],
78
+ clean: !options.watch, // cleaning in watch mode causes problems with turborepo
32
79
  splitting: false,
33
80
  treeshake: true,
34
81
  sourcemap: false,
@@ -50,6 +97,7 @@ export default defineConfig(options => {
50
97
  writeDummyPackage(subpath, "cjs"),
51
98
  ),
52
99
  );
100
+ await buildAbi("cjs");
53
101
  },
54
102
  },
55
103
  {
@@ -71,6 +119,8 @@ export default defineConfig(options => {
71
119
  writeDummyPackage(subpath, "esm"),
72
120
  ),
73
121
  );
122
+
123
+ await buildAbi("esm");
74
124
  },
75
125
  },
76
126
  ];
@@ -1,4 +0,0 @@
1
- {
2
- "extends": "./tsconfig.json",
3
- "exclude": ["scripts", "tsup.config.ts"]
4
- }