diff --git a/.changeset/rare-tips-promise.md b/.changeset/rare-tips-promise.md new file mode 100644 index 00000000000..4bff7b7daa8 --- /dev/null +++ b/.changeset/rare-tips-promise.md @@ -0,0 +1,8 @@ +--- +"@fuel-ts/abi-typegen": patch +"@fuel-ts/hasher": patch +"@fuel-ts/providers": patch +"@fuel-ts/utils": patch +--- + +Replace lodash with ramda for ESM support diff --git a/packages/abi-typegen/package.json b/packages/abi-typegen/package.json index 22a82f19771..915fcb47653 100644 --- a/packages/abi-typegen/package.json +++ b/packages/abi-typegen/package.json @@ -52,16 +52,14 @@ "commander": "^9.4.1", "glob": "^10.2.6", "handlebars": "^4.7.7", - "lodash.uniq": "^4.5.0", - "lodash.upperfirst": "^4.3.1", "mkdirp": "^1.0.4", + "ramda": "^0.29.0", "rimraf": "^3.0.2" }, "devDependencies": { - "@types/lodash.uniq": "^4.5.7", - "@types/lodash.upperfirst": "^4.3.7", + "@fuel-ts/forc": "workspace:*", "@types/mkdirp": "^1.0.2", - "@types/rimraf": "^3.0.2", - "@fuel-ts/forc": "workspace:*" + "@types/ramda": "^0.29.3", + "@types/rimraf": "^3.0.2" } } diff --git a/packages/abi-typegen/src/templates/utils/formatImports.ts b/packages/abi-typegen/src/templates/utils/formatImports.ts index c46aa019ebb..fd64540960f 100644 --- a/packages/abi-typegen/src/templates/utils/formatImports.ts +++ b/packages/abi-typegen/src/templates/utils/formatImports.ts @@ -1,4 +1,4 @@ -import uniq from 'lodash.uniq'; +import { uniq } from 'ramda'; import type { IType } from '../../types/interfaces/IType'; diff --git a/packages/abi-typegen/src/utils/validateBinFile.ts b/packages/abi-typegen/src/utils/validateBinFile.ts index a229bfaa394..e0d3be5d003 100644 --- a/packages/abi-typegen/src/utils/validateBinFile.ts +++ b/packages/abi-typegen/src/utils/validateBinFile.ts @@ -1,7 +1,7 @@ -import upperFirst from 'lodash.upperfirst'; - import { ProgramTypeEnum } from '../types/enums/ProgramTypeEnum'; +const upperFirst = (s: string): string => s[0].toUpperCase() + s.slice(1); + export function validateBinFile(params: { abiFilepath: string; binFilepath: string; diff --git a/packages/hasher/package.json b/packages/hasher/package.json index 812f753900b..5f05e56cd06 100644 --- a/packages/hasher/package.json +++ b/packages/hasher/package.json @@ -29,10 +29,10 @@ "@fuel-ts/math": "workspace:*", "@fuel-ts/providers": "workspace:*", "@fuel-ts/transactions": "workspace:*", - "lodash.clonedeep": "^4.5.0" + "ramda": "^0.29.0" }, "devDependencies": { "@fuel-ts/testcases": "workspace:*", - "@types/lodash.clonedeep": "^4.5.7" + "@types/ramda": "^0.29.3" } } diff --git a/packages/hasher/src/hasher.ts b/packages/hasher/src/hasher.ts index 6c4419ede54..02989730e3a 100644 --- a/packages/hasher/src/hasher.ts +++ b/packages/hasher/src/hasher.ts @@ -8,7 +8,7 @@ import type { TransactionRequestLike } from '@fuel-ts/providers'; import { transactionRequestify, TransactionType } from '@fuel-ts/providers'; import type { UtxoId } from '@fuel-ts/transactions'; import { OutputType, InputType, TransactionCoder } from '@fuel-ts/transactions'; -import cloneDeep from 'lodash.clonedeep'; +import { clone } from 'ramda'; /** * hash string messages with sha256 @@ -48,7 +48,7 @@ export function hashTransaction(transactionRequestLike: TransactionRequestLike, // Zero out input fields transaction.inputs = transaction.inputs.map((input) => { - const inputClone = cloneDeep(input); + const inputClone = clone(input); switch (inputClone.type) { // Zero out on signing: txPointer, predicateGasUsed @@ -85,7 +85,7 @@ export function hashTransaction(transactionRequestLike: TransactionRequestLike, }); // Zero out output fields transaction.outputs = transaction.outputs.map((output) => { - const outputClone = cloneDeep(output); + const outputClone = clone(output); switch (outputClone.type) { // Zero out on signing: balanceRoot, stateRoot diff --git a/packages/providers/package.json b/packages/providers/package.json index 29096cc656e..cdbf1ac3019 100644 --- a/packages/providers/package.json +++ b/packages/providers/package.json @@ -30,15 +30,15 @@ "@ethersproject/sha2": "^5.7.0", "@fuel-ts/abi-coder": "workspace:*", "@fuel-ts/address": "workspace:*", - "@fuel-ts/interfaces": "workspace:*", "@fuel-ts/crypto": "workspace:*", + "@fuel-ts/errors": "workspace:*", + "@fuel-ts/interfaces": "workspace:*", "@fuel-ts/math": "workspace:*", "@fuel-ts/transactions": "workspace:*", - "@fuel-ts/errors": "workspace:*", "graphql": "^16.6.0", "graphql-request": "^5.0.0", "graphql-tag": "^2.12.6", - "lodash.clonedeep": "^4.5.0" + "ramda": "^0.29.0" }, "devDependencies": { "@fuel-ts/utils": "workspace:*", @@ -46,7 +46,7 @@ "@graphql-codegen/typescript": "^2.8.0", "@graphql-codegen/typescript-graphql-request": "^4.5.7", "@graphql-codegen/typescript-operations": "^2.5.5", - "@types/lodash.clonedeep": "^4.5.7", + "@types/ramda": "^0.29.3", "get-graphql-schema": "^2.1.2", "typescript": "^4.8.4" } diff --git a/packages/providers/src/provider.ts b/packages/providers/src/provider.ts index 9ff522099c4..336e9ff6862 100644 --- a/packages/providers/src/provider.ts +++ b/packages/providers/src/provider.ts @@ -14,7 +14,7 @@ import { TransactionCoder, } from '@fuel-ts/transactions'; import { GraphQLClient } from 'graphql-request'; -import cloneDeep from 'lodash.clonedeep'; +import { clone } from 'ramda'; import { getSdk as getOperationsSdk } from './__generated__/operations'; import type { @@ -526,7 +526,7 @@ export default class Provider { transactionRequestLike: TransactionRequestLike, tolerance: number = 0.2 ): Promise { - const transactionRequest = transactionRequestify(cloneDeep(transactionRequestLike)); + const transactionRequest = transactionRequestify(clone(transactionRequestLike)); const { minGasPrice, gasPerByte, gasPriceFactor, maxGasPerTx } = await this.getNodeInfo(); const gasPrice = max(transactionRequest.gasPrice, minGasPrice); const margin = 1 + tolerance; diff --git a/packages/providers/src/utils/json.ts b/packages/providers/src/utils/json.ts index 52e4772ebe3..ce77faa5ced 100644 --- a/packages/providers/src/utils/json.ts +++ b/packages/providers/src/utils/json.ts @@ -1,7 +1,7 @@ /* eslint-disable no-param-reassign */ /* eslint-disable @typescript-eslint/no-explicit-any */ import { hexlify } from '@ethersproject/bytes'; -import cloneDeep from 'lodash.clonedeep'; +import { clone } from 'ramda'; // When parsing a Transaction to JSON we need // to convert special types into each respective @@ -42,5 +42,5 @@ export function normalizeJSON(root: any) { // Do a single deep clone before normalizing // to avoid mutating the original object // and doing extra clones on each iteration - return normalize(cloneDeep(root)); + return normalize(clone(root)); } diff --git a/packages/utils/package.json b/packages/utils/package.json index 2def9b53e28..3ed7a27ba9e 100644 --- a/packages/utils/package.json +++ b/packages/utils/package.json @@ -35,11 +35,10 @@ }, "license": "Apache-2.0", "dependencies": { - "lodash.upperfirst": "^4.3.1", + "ramda": "^0.29.0", "rimraf": "^3.0.2" }, "devDependencies": { - "@ethersproject/bytes": "^5.7.0", - "@types/lodash.upperfirst": "^4.3.7" + "@ethersproject/bytes": "^5.7.0" } } diff --git a/packages/utils/src/utils/normalizeString.ts b/packages/utils/src/utils/normalizeString.ts index 2e0c21adfb2..6b71ef7260e 100644 --- a/packages/utils/src/utils/normalizeString.ts +++ b/packages/utils/src/utils/normalizeString.ts @@ -1,5 +1,3 @@ -import upperFirst from 'lodash.upperfirst'; - /** * Converts `some.string-value` into `SomeStringValue`. * @@ -16,7 +14,7 @@ export const normalizeString = (str: string): string => { (s) => s.replace(/-[a-z]/g, (match) => match.slice(-1).toUpperCase()), // delete '-' and capitalize the letter after them (s) => s.replace(/-/g, ''), // delete any '-' left (s) => s.replace(/^\d+/, ''), // removes leading digits - (s) => upperFirst(s), + (s) => s[0].toUpperCase() + s.slice(1), // capitalize first letter ]; const output = transformations.reduce((s, t) => t(s), str); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 85f9109a657..35ed4e184d6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -478,15 +478,12 @@ importers: handlebars: specifier: ^4.7.7 version: 4.7.7 - lodash.uniq: - specifier: ^4.5.0 - version: 4.5.0 - lodash.upperfirst: - specifier: ^4.3.1 - version: 4.3.1 mkdirp: specifier: ^1.0.4 version: 1.0.4 + ramda: + specifier: ^0.29.0 + version: 0.29.0 rimraf: specifier: ^3.0.2 version: 3.0.2 @@ -494,15 +491,12 @@ importers: '@fuel-ts/forc': specifier: workspace:* version: link:../forc - '@types/lodash.uniq': - specifier: ^4.5.7 - version: 4.5.7 - '@types/lodash.upperfirst': - specifier: ^4.3.7 - version: 4.3.7 '@types/mkdirp': specifier: ^1.0.2 version: 1.0.2 + '@types/ramda': + specifier: ^0.29.3 + version: 0.29.3 '@types/rimraf': specifier: ^3.0.2 version: 3.0.2 @@ -737,16 +731,16 @@ importers: '@fuel-ts/transactions': specifier: workspace:* version: link:../transactions - lodash.clonedeep: - specifier: ^4.5.0 - version: 4.5.0 + ramda: + specifier: ^0.29.0 + version: 0.29.0 devDependencies: '@fuel-ts/testcases': specifier: workspace:* version: link:../testcases - '@types/lodash.clonedeep': - specifier: ^4.5.7 - version: 4.5.7 + '@types/ramda': + specifier: ^0.29.3 + version: 0.29.3 packages/hdwallet: dependencies: @@ -940,9 +934,9 @@ importers: graphql-tag: specifier: ^2.12.6 version: 2.12.6(graphql@16.6.0) - lodash.clonedeep: - specifier: ^4.5.0 - version: 4.5.0 + ramda: + specifier: ^0.29.0 + version: 0.29.0 devDependencies: '@fuel-ts/utils': specifier: workspace:* @@ -959,9 +953,9 @@ importers: '@graphql-codegen/typescript-operations': specifier: ^2.5.5 version: 2.5.5(graphql@16.6.0) - '@types/lodash.clonedeep': - specifier: ^4.5.7 - version: 4.5.7 + '@types/ramda': + specifier: ^0.29.3 + version: 0.29.3 get-graphql-schema: specifier: ^2.1.2 version: 2.1.2 @@ -1062,9 +1056,9 @@ importers: packages/utils: dependencies: - lodash.upperfirst: - specifier: ^4.3.1 - version: 4.3.1 + ramda: + specifier: ^0.29.0 + version: 0.29.0 rimraf: specifier: ^3.0.2 version: 3.0.2 @@ -1072,9 +1066,6 @@ importers: '@ethersproject/bytes': specifier: ^5.7.0 version: 5.7.0 - '@types/lodash.upperfirst': - specifier: ^4.3.7 - version: 4.3.7 packages/versions: dependencies: @@ -5684,28 +5675,6 @@ packages: resolution: {integrity: sha512-HZQYqbiFVWufzCwexrvh694SOim8z2d+xJl5UNamcvQFejLY/2YUtzXHYi3cHdI7PMlS8ejH2slRAOJQ32aNbA==} dev: true - /@types/lodash.clonedeep@4.5.7: - resolution: {integrity: sha512-ccNqkPptFIXrpVqUECi60/DFxjNKsfoQxSQsgcBJCX/fuX1wgyQieojkcWH/KpE3xzLoWN/2k+ZeGqIN3paSvw==} - dependencies: - '@types/lodash': 4.14.195 - dev: true - - /@types/lodash.uniq@4.5.7: - resolution: {integrity: sha512-qg7DeAbdZMi6DGvCxThlJycykLLhETrJrQZ6F2KaZ+o0sNK1qRHz46lgNA+nHHjwrmA2a91DyiZTp3ey3m1rEw==} - dependencies: - '@types/lodash': 4.14.195 - dev: true - - /@types/lodash.upperfirst@4.3.7: - resolution: {integrity: sha512-CrBjoB4lO6h7tXNMBUl1eh/w0KdMosiEOXOoD5DMECsA/kDWo/WQfOt1KyGKVvgwK3I6cKAY6z8LymKiMazLFg==} - dependencies: - '@types/lodash': 4.14.195 - dev: true - - /@types/lodash@4.14.195: - resolution: {integrity: sha512-Hwx9EUgdwf2GLarOjQp5ZH8ZmblzcbTBC2wtQWNKARBSxM9ezRIAUpeDTgoQRAFB0+8CNWXVA9+MaSOzOF3nPg==} - dev: true - /@types/markdown-it@12.2.3: resolution: {integrity: sha512-GKMHFfv3458yYy+v/N8gjufHO6MSZKCOXpZc5GXIWWy8uldwfmPn98vp81gZ5f9SVw8YYBctgfJ22a2d7AOMeQ==} dependencies: @@ -5789,6 +5758,12 @@ packages: resolution: {integrity: sha512-FGa1F62FT09qcrueBA6qYTrJPVDzah9a+493+o2PCXsesWHIn27G98TsSMs3WPNbZIEj4+VJf6saSFpvD+3Zsw==} dev: false + /@types/ramda@0.29.3: + resolution: {integrity: sha512-Yh/RHkjN0ru6LVhSQtTkCRo6HXkfL9trot/2elzM/yXLJmbLm2v6kJc8yftTnwv1zvUob6TEtqI2cYjdqG3U0Q==} + dependencies: + types-ramda: 0.29.4 + dev: true + /@types/range-parser@1.2.4: resolution: {integrity: sha512-EEhsLsD6UsDM1yFhAvy0Cjr6VwmpMWqFBCb9w07wVugF7w9nfajxLuVmngTIpgS6svCnm6Vaw+MZhoDCKnOfsw==} dev: false @@ -12248,10 +12223,6 @@ packages: dependencies: p-locate: 5.0.0 - /lodash.clonedeep@4.5.0: - resolution: {integrity: sha512-H5ZhCF25riFd9uB5UCkVKo61m3S/xZk1x4wA6yp/L3RFP6Z/eHH1ymQcGLo7J3GMPfm0V/7m1tryHuGVxpqEBQ==} - dev: false - /lodash.debounce@4.0.8: resolution: {integrity: sha512-FT1yDzDYEoYWhnSGnpE/4Kj1fLZkDFyqRb7fNt6FdYOSxlUWAtp42Eh6Wb0rGIv/m9Bgo7x4GhQbm5Ys4SG5ow==} dev: false @@ -12277,10 +12248,6 @@ packages: resolution: {integrity: sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==} dev: false - /lodash.upperfirst@4.3.1: - resolution: {integrity: sha512-sReKOYJIJf74dhJONhU4e0/shzi1trVbSWDOhKYE5XV2O+H7Sb2Dihwuc7xWxVl+DgFPyTqIN3zMfT9cq5iWDg==} - dev: false - /lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} @@ -14511,6 +14478,10 @@ packages: performance-now: 2.1.0 dev: false + /ramda@0.29.0: + resolution: {integrity: sha512-BBea6L67bYLtdbOqfp8f58fPMqEwx0doL+pAi8TZyp2YWz8R9G8z9x75CZI8W+ftqhFHCpEX2cRnUUXK130iKA==} + dev: false + /randombytes@2.1.0: resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==} dependencies: @@ -16354,6 +16325,10 @@ packages: yn: 3.1.1 dev: true + /ts-toolbelt@9.6.0: + resolution: {integrity: sha512-nsZd8ZeNUzukXPlJmTBwUAuABDe/9qtVDelJeT/qW0ow3ZS3BsQJtNkan1802aM9Uf68/Y8ljw86Hu0h5IUW3w==} + dev: true + /tsconfig-paths@3.14.2: resolution: {integrity: sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==} dependencies: @@ -16624,6 +16599,12 @@ packages: shiki: 0.14.3 typescript: 5.1.6 + /types-ramda@0.29.4: + resolution: {integrity: sha512-XO/820iRsCDwqLjE8XE+b57cVGPyk1h+U9lBGpDWvbEky+NQChvHVwaKM05WnW1c5z3EVQh8NhXFmh2E/1YazQ==} + dependencies: + ts-toolbelt: 9.6.0 + dev: true + /typescript@4.9.5: resolution: {integrity: sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==} engines: {node: '>=4.2.0'}