From 9a1cca0362cdfa06135e734a136a2bbd506b5d65 Mon Sep 17 00:00:00 2001 From: Ali Behjati Date: Mon, 17 Jun 2024 09:42:07 +0200 Subject: [PATCH] fix(target_chains/fuel): update js sdk to properly gen and export types (#1703) * fix(target_chains/fuel): update js sdk to properly gen and export types This change adds type generation to the build path to have them in the resulting library and also fixes the issues around type exports by updating the typescript and using `export type *`. The problem was that the normal `export *` adds a similar export to the produced js file but there is no module to be exported from in our case. * fix: update eslint version --- pnpm-lock.yaml | 38 +++++++------- target_chains/fuel/sdk/js/package.json | 12 ++--- target_chains/fuel/sdk/js/src/index.ts | 2 +- .../factories/PythContractAbi__factory.ts | 52 ++++++++++++++++++- 4 files changed, 76 insertions(+), 28 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 065f262710..bb20331370 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1369,11 +1369,11 @@ importers: version: 0.89.2 devDependencies: '@typescript-eslint/eslint-plugin': - specifier: ^5.21.0 - version: 5.49.0(@typescript-eslint/parser@5.49.0)(eslint@8.56.0)(typescript@4.9.5) + specifier: ^7.7.0 + version: 7.7.1(@typescript-eslint/parser@7.13.0)(eslint@8.56.0)(typescript@5.4.5) '@typescript-eslint/parser': - specifier: ^5.21.0 - version: 5.49.0(eslint@8.56.0)(typescript@4.9.5) + specifier: ^7.7.0 + version: 7.13.0(eslint@8.56.0)(typescript@5.4.5) copyfiles: specifier: ^2.4.1 version: 2.4.1 @@ -1388,13 +1388,13 @@ importers: version: 2.8.8 ts-jest: specifier: ^29.0.5 - version: 29.1.2(@babel/core@7.24.7)(esbuild@0.19.12)(jest@29.7.0)(typescript@4.9.5) + version: 29.1.2(@babel/core@7.24.7)(esbuild@0.19.12)(jest@29.7.0)(typescript@5.4.5) ts-node: specifier: ^10.9.2 - version: 10.9.2(@types/node@20.14.2)(typescript@4.9.5) + version: 10.9.2(@types/node@20.14.2)(typescript@5.4.5) typescript: - specifier: ^4.6.3 - version: 4.9.5 + specifier: ^5.4.5 + version: 5.4.5 target_chains/solana/sdk/js/pyth_solana_receiver: dependencies: @@ -1903,7 +1903,7 @@ packages: '@babel/traverse': 7.24.0 '@babel/types': 7.24.0 convert-source-map: 2.0.0 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.5 gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -9827,7 +9827,7 @@ packages: cbor: 8.1.0 chalk: 4.1.2 compare-versions: 5.0.3 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.5 ethereumjs-util: 7.1.5 proper-lockfile: 4.1.2 solidity-ast: 0.4.43 @@ -12707,7 +12707,7 @@ packages: '@truffle/error': 0.2.0 '@truffle/interface-adapter': 0.5.27 bignumber.js: 7.2.1 - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.5 ethers: 4.0.49 web3: 1.8.1 web3-core-helpers: 1.8.1 @@ -13546,12 +13546,12 @@ packages: '@typescript-eslint/scope-manager': 5.49.0 '@typescript-eslint/type-utils': 5.49.0(eslint@8.56.0)(typescript@4.9.5) '@typescript-eslint/utils': 5.49.0(eslint@8.56.0)(typescript@4.9.5) - debug: 4.3.5 + debug: 4.3.4(supports-color@8.1.1) eslint: 8.56.0 ignore: 5.3.1 natural-compare-lite: 1.4.0 regexpp: 3.2.0 - semver: 7.6.2 + semver: 7.6.0 tsutils: 3.21.0(typescript@4.9.5) typescript: 4.9.5 transitivePeerDependencies: @@ -13829,7 +13829,7 @@ packages: dependencies: '@typescript-eslint/typescript-estree': 7.7.1(typescript@5.4.5) '@typescript-eslint/utils': 7.7.1(eslint@8.56.0)(typescript@5.4.5) - debug: 4.3.4(supports-color@8.1.1) + debug: 4.3.5 eslint: 8.56.0 ts-api-utils: 1.3.0(typescript@5.4.5) typescript: 5.4.5 @@ -22475,7 +22475,7 @@ packages: pretty-format: 29.7.0 slash: 3.0.0 strip-json-comments: 3.1.1 - ts-node: 10.9.2(@types/node@20.14.2)(typescript@4.9.5) + ts-node: 10.9.2(@types/node@20.14.2)(typescript@5.4.5) transitivePeerDependencies: - babel-plugin-macros - supports-color @@ -30213,7 +30213,7 @@ packages: yargs-parser: 21.1.1 dev: true - /ts-jest@29.1.2(@babel/core@7.24.7)(esbuild@0.19.12)(jest@29.7.0)(typescript@4.9.5): + /ts-jest@29.1.2(@babel/core@7.24.7)(esbuild@0.19.12)(jest@29.7.0)(typescript@5.4.5): resolution: {integrity: sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g==} engines: {node: ^16.10.0 || ^18.0.0 || >=20.0.0} hasBin: true @@ -30244,7 +30244,7 @@ packages: lodash.memoize: 4.1.2 make-error: 1.3.6 semver: 7.6.2 - typescript: 4.9.5 + typescript: 5.4.5 yargs-parser: 21.1.1 dev: true @@ -30486,7 +30486,7 @@ packages: yn: 3.1.1 dev: true - /ts-node@10.9.2(@types/node@20.14.2)(typescript@4.9.5): + /ts-node@10.9.2(@types/node@20.14.2)(typescript@5.4.5): resolution: {integrity: sha512-f0FFpIdcHgn8zcPSbf1dRevwt047YMnaiJM3u2w2RewrB+fob/zePZcrOyQoLMMO7aBIddLcQIEK5dYjkLnGrQ==} hasBin: true peerDependencies: @@ -30512,7 +30512,7 @@ packages: create-require: 1.1.1 diff: 4.0.2 make-error: 1.3.6 - typescript: 4.9.5 + typescript: 5.4.5 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 dev: true diff --git a/target_chains/fuel/sdk/js/package.json b/target_chains/fuel/sdk/js/package.json index 2cc6386d7b..8a359ebf50 100644 --- a/target_chains/fuel/sdk/js/package.json +++ b/target_chains/fuel/sdk/js/package.json @@ -1,6 +1,6 @@ { "name": "@pythnetwork/pyth-fuel-js", - "version": "1.0.0", + "version": "1.0.1", "description": "Pyth Network Fuel Utils in JS", "homepage": "https://pyth.network", "author": { @@ -22,13 +22,13 @@ "scripts": { "test": "jest --passWithNoTests", "usage-example": "ts-node src/examples/usage.ts", - "build": "tsc && copyfiles -u 1 \"src/**/*.d.ts\" lib", + "build": "pnpm run generate-fuel-types && tsc && copyfiles -u 1 \"src/**/*.d.ts\" lib", "format": "prettier --write \"src/**/*.ts\"", "lint": "eslint src/", "prepublishOnly": "pnpm run build && pnpm run test && pnpm run lint", "preversion": "pnpm run lint", "version": "pnpm run format && git add -A src", - "generate-fuel-types": "pnpm fuels typegen -i ../../contracts/pyth-contract/out/release/*-abi.json -o ./src/types" + "generate-fuel-types": "pnpm fuels typegen -i ../../contracts/pyth-contract/out/release/*-abi.json -o ./src/types && prettier --write \"./src/types/**/*.ts\"" }, "keywords": [ "pyth", @@ -36,15 +36,15 @@ ], "license": "Apache-2.0", "devDependencies": { - "@typescript-eslint/eslint-plugin": "^5.21.0", - "@typescript-eslint/parser": "^5.21.0", + "@typescript-eslint/eslint-plugin": "^7.7.0", + "@typescript-eslint/parser": "^7.7.0", "copyfiles": "^2.4.1", "eslint": "^8.14.0", "jest": "^29.4.1", "prettier": "^2.6.2", "ts-jest": "^29.0.5", "ts-node": "^10.9.2", - "typescript": "^4.6.3" + "typescript": "^5.4.5" }, "dependencies": { "fuels": "^0.89.2" diff --git a/target_chains/fuel/sdk/js/src/index.ts b/target_chains/fuel/sdk/js/src/index.ts index f3f33e40f3..0be2ee20bd 100644 --- a/target_chains/fuel/sdk/js/src/index.ts +++ b/target_chains/fuel/sdk/js/src/index.ts @@ -10,4 +10,4 @@ export const FUEL_ETH_ASSET_ID = export { PYTH_CONTRACT_ABI }; export * from "./types"; -export * from "./types/PythContractAbi"; +export type * from "./types/PythContractAbi"; diff --git a/target_chains/fuel/sdk/js/src/types/factories/PythContractAbi__factory.ts b/target_chains/fuel/sdk/js/src/types/factories/PythContractAbi__factory.ts index d8a521524f..7eb3669b0d 100644 --- a/target_chains/fuel/sdk/js/src/types/factories/PythContractAbi__factory.ts +++ b/target_chains/fuel/sdk/js/src/types/factories/PythContractAbi__factory.ts @@ -1868,8 +1868,56 @@ const _abi = { ], }; -const _storageSlots: StorageSlot[] = []; - +const _storageSlots: StorageSlot[] = [ + { + key: "6294951dcb0a9111a517be5cf4785670ff4e166fb5ab9c33b17e6881b48e964f", + value: "0000000000000000000000000000000000000000000000000000000000000000", + }, + { + key: "71217a24656901c411894bb65eb78a828dafa5a6844488ef5024eb5ac0cff79c", + value: "0000000000000000000000000000000000000000000000000000000000000000", + }, + { + key: "71217a24656901c411894bb65eb78a828dafa5a6844488ef5024eb5ac0cff79d", + value: "0000000000000000000000000000000000000000000000000000000000000000", + }, + { + key: "7f91d1a929dce734e7f930bbb279ccfccdb5474227502ea8845815c74bd930a7", + value: "0000000000000000000000000000000000000000000000000000000000000000", + }, + { + key: "8a89a0cce819e0426e565819a9a98711329087da5a802fb16edd223c47fa44ef", + value: "0000000000000000000000000000000000000000000000000000000000000000", + }, + { + key: "94b2b70d20da552763c7614981b2a4d984380d7ed4e54c01b28c914e79e44bd5", + value: "0000000000000000000000000000000000000000000000000000000000000000", + }, + { + key: "94b2b70d20da552763c7614981b2a4d984380d7ed4e54c01b28c914e79e44bd6", + value: "0000000000000000000000000000000000000000000000000000000000000000", + }, + { + key: "a9203bbb8366ca9d708705dce980acbb54d44fb753370ffe4c7d351b46b2abbc", + value: "0000000000000000000000000000000000000000000000000000000000000000", + }, + { + key: "b48b753af346966d0d169c0b2e3234611f65d5cfdb57c7b6e7cd6ca93707bee0", + value: "0000000000000000000000000000000000000000000000000000000000000000", + }, + { + key: "c7e08cdde76020f08f4ce5c3257422ae67f9676992689b64b85f35aa58752d9e", + value: "0000000000000000000000000000000000000000000000000000000000000000", + }, + { + key: "c7e08cdde76020f08f4ce5c3257422ae67f9676992689b64b85f35aa58752d9f", + value: "0000000000000000000000000000000000000000000000000000000000000000", + }, + { + key: "d02e07f5a716bd3b6670aaf9a73352164e6b946c24db14f72005b7029e67d96a", + value: "0000000000000000000000000000000000000000000000000000000000000000", + }, +]; export const PythContractAbi__factory = { abi: _abi,