diff --git a/.pnp.cjs b/.pnp.cjs index 98494a31..3ab39838 100755 --- a/.pnp.cjs +++ b/.pnp.cjs @@ -41,7 +41,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@types/source-map-support", "npm:0.5.4"],\ ["@typescript-eslint/eslint-plugin", "virtual:6f50bb9424c73c7612c66dab5cf8914d8ec79550c84d8ca5e4888e80022682c708b4b5a1c510d282a03285cc9bb19002b477ae70d15882aa995ea1d5d6bf24ab#npm:6.2.1"],\ ["@typescript-eslint/parser", "virtual:6f50bb9424c73c7612c66dab5cf8914d8ec79550c84d8ca5e4888e80022682c708b4b5a1c510d282a03285cc9bb19002b477ae70d15882aa995ea1d5d6bf24ab#npm:6.2.1"],\ - ["ardrive-core-js", "npm:2.0.0-alpha-0"],\ + ["ardrive-core-js", "npm:2.0.0"],\ ["arweave", "npm:1.11.4"],\ ["axios", "npm:0.21.1"],\ ["bn.js", "npm:5.2.1"],\ @@ -349,6 +349,14 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["regenerator-runtime", "npm:0.13.9"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:7.22.10", {\ + "packageLocation": "./.yarn/cache/@babel-runtime-npm-7.22.10-2771d0ecab-524d41517e.zip/node_modules/@babel/runtime/",\ + "packageDependencies": [\ + ["@babel/runtime", "npm:7.22.10"],\ + ["regenerator-runtime", "npm:0.14.0"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["@babel/template", [\ @@ -2191,7 +2199,7 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["@types/source-map-support", "npm:0.5.4"],\ ["@typescript-eslint/eslint-plugin", "virtual:6f50bb9424c73c7612c66dab5cf8914d8ec79550c84d8ca5e4888e80022682c708b4b5a1c510d282a03285cc9bb19002b477ae70d15882aa995ea1d5d6bf24ab#npm:6.2.1"],\ ["@typescript-eslint/parser", "virtual:6f50bb9424c73c7612c66dab5cf8914d8ec79550c84d8ca5e4888e80022682c708b4b5a1c510d282a03285cc9bb19002b477ae70d15882aa995ea1d5d6bf24ab#npm:6.2.1"],\ - ["ardrive-core-js", "npm:2.0.0-alpha-0"],\ + ["ardrive-core-js", "npm:2.0.0"],\ ["arweave", "npm:1.11.4"],\ ["axios", "npm:0.21.1"],\ ["bn.js", "npm:5.2.1"],\ @@ -2219,15 +2227,16 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { }]\ ]],\ ["ardrive-core-js", [\ - ["npm:2.0.0-alpha-0", {\ - "packageLocation": "./.yarn/cache/ardrive-core-js-npm-2.0.0-alpha-0-b90abfd5f0-7f922ef022.zip/node_modules/ardrive-core-js/",\ + ["npm:2.0.0", {\ + "packageLocation": "./.yarn/cache/ardrive-core-js-npm-2.0.0-ce42dc7f81-6d4e58e676.zip/node_modules/ardrive-core-js/",\ "packageDependencies": [\ - ["ardrive-core-js", "npm:2.0.0-alpha-0"],\ + ["ardrive-core-js", "npm:2.0.0"],\ ["@alexsasharegan/simple-cache", "npm:3.3.3"],\ ["arbundles", "npm:0.6.19"],\ ["arweave", "npm:1.11.4"],\ ["arweave-mnemonic-keys", "npm:0.0.9"],\ ["axios", "npm:0.21.1"],\ + ["axios-retry", "npm:3.6.0"],\ ["base64-js", "npm:1.5.1"],\ ["bignumber.js", "npm:9.0.1"],\ ["bn.js", "npm:5.2.1"],\ @@ -2491,6 +2500,17 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD"\ }]\ ]],\ + ["axios-retry", [\ + ["npm:3.6.0", {\ + "packageLocation": "./.yarn/cache/axios-retry-npm-3.6.0-98bcf77508-9ed0879453.zip/node_modules/axios-retry/",\ + "packageDependencies": [\ + ["axios-retry", "npm:3.6.0"],\ + ["@babel/runtime", "npm:7.22.10"],\ + ["is-retry-allowed", "npm:2.2.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["balanced-match", [\ ["npm:1.0.0", {\ "packageLocation": "./.yarn/cache/balanced-match-npm-1.0.0-951a2ad706-9b67bfe558.zip/node_modules/balanced-match/",\ @@ -5429,6 +5449,15 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { "linkType": "HARD"\ }]\ ]],\ + ["is-retry-allowed", [\ + ["npm:2.2.0", {\ + "packageLocation": "./.yarn/cache/is-retry-allowed-npm-2.2.0-b4b58fc581-3d1103a929.zip/node_modules/is-retry-allowed/",\ + "packageDependencies": [\ + ["is-retry-allowed", "npm:2.2.0"]\ + ],\ + "linkType": "HARD"\ + }]\ + ]],\ ["is-shared-array-buffer", [\ ["npm:1.0.2", {\ "packageLocation": "./.yarn/cache/is-shared-array-buffer-npm-1.0.2-32e4181fcd-9508929cf1.zip/node_modules/is-shared-array-buffer/",\ @@ -7569,6 +7598,13 @@ function $$SETUP_STATE(hydrateRuntimeState, basePath) { ["regenerator-runtime", "npm:0.13.9"]\ ],\ "linkType": "HARD"\ + }],\ + ["npm:0.14.0", {\ + "packageLocation": "./.yarn/cache/regenerator-runtime-npm-0.14.0-e060897cf7-1c977ad82a.zip/node_modules/regenerator-runtime/",\ + "packageDependencies": [\ + ["regenerator-runtime", "npm:0.14.0"]\ + ],\ + "linkType": "HARD"\ }]\ ]],\ ["regexp.prototype.flags", [\ diff --git a/.yarn/cache/@babel-runtime-npm-7.22.10-2771d0ecab-524d41517e.zip b/.yarn/cache/@babel-runtime-npm-7.22.10-2771d0ecab-524d41517e.zip new file mode 100644 index 00000000..e82a0261 Binary files /dev/null and b/.yarn/cache/@babel-runtime-npm-7.22.10-2771d0ecab-524d41517e.zip differ diff --git a/.yarn/cache/ardrive-core-js-npm-2.0.0-alpha-0-b90abfd5f0-7f922ef022.zip b/.yarn/cache/ardrive-core-js-npm-2.0.0-ce42dc7f81-6d4e58e676.zip similarity index 65% rename from .yarn/cache/ardrive-core-js-npm-2.0.0-alpha-0-b90abfd5f0-7f922ef022.zip rename to .yarn/cache/ardrive-core-js-npm-2.0.0-ce42dc7f81-6d4e58e676.zip index ed9d1c67..8d357cb5 100644 Binary files a/.yarn/cache/ardrive-core-js-npm-2.0.0-alpha-0-b90abfd5f0-7f922ef022.zip and b/.yarn/cache/ardrive-core-js-npm-2.0.0-ce42dc7f81-6d4e58e676.zip differ diff --git a/.yarn/cache/axios-retry-npm-3.6.0-98bcf77508-9ed0879453.zip b/.yarn/cache/axios-retry-npm-3.6.0-98bcf77508-9ed0879453.zip new file mode 100644 index 00000000..ea14731f Binary files /dev/null and b/.yarn/cache/axios-retry-npm-3.6.0-98bcf77508-9ed0879453.zip differ diff --git a/.yarn/cache/is-retry-allowed-npm-2.2.0-b4b58fc581-3d1103a929.zip b/.yarn/cache/is-retry-allowed-npm-2.2.0-b4b58fc581-3d1103a929.zip new file mode 100644 index 00000000..e849b484 Binary files /dev/null and b/.yarn/cache/is-retry-allowed-npm-2.2.0-b4b58fc581-3d1103a929.zip differ diff --git a/.yarn/cache/regenerator-runtime-npm-0.14.0-e060897cf7-1c977ad82a.zip b/.yarn/cache/regenerator-runtime-npm-0.14.0-e060897cf7-1c977ad82a.zip new file mode 100644 index 00000000..743dca6a Binary files /dev/null and b/.yarn/cache/regenerator-runtime-npm-0.14.0-e060897cf7-1c977ad82a.zip differ diff --git a/README.md b/README.md index b874a709..56b7d8d2 100644 --- a/README.md +++ b/README.md @@ -93,6 +93,7 @@ ardrive upload-file --wallet-file /path/to/my/wallet.json --parent-folder-id "f0 3. [Wallet Operations](#wallet-operations) 4. [Working With Entities](#working-with-entities) 1. [Dry Run](#dry-run) + 2. [Uploading to Turbo (BETA)](#upload-to-turbo) 5. [Working With Drives](#working-with-drives) 1. [Understanding Drive Hierarchies](#understanding-drive-hierarchies) 1. [Fetching Drive Info](#drive-info) @@ -393,6 +394,16 @@ ardrive --dry-run This can be very useful for gathering price estimations or to confirm that you've copy-pasted your entity IDs correctly before committing to an upload. +### Uploading to Turbo (BETA) + +Users can optionally choose to send each ArFS entities created to [ArDrive Turbo][ardrive-turbo] using the `--turbo` flag. Instead of using AR from an Arweave wallet, you can use Turbo Credits or take advantage of free/discounted upload promotions. + +```shell +ardrive --turbo +``` + +This flag will skip any balance check on the CLI side. Turbo will check a user's balance and accept/reject a data item at the time of upload. The `--turbo` flag by default will send your files to `upload.ardrive.io` to be bundled. To change the Turbo destination, users can use the `--turbo-url` flag. + ## Working With Drives ### Understanding Drive Hierarchies @@ -1571,3 +1582,4 @@ ardrive --help [viewblock]: https://viewblock.io/arweave/ [tx_anchors]: https://docs.arweave.org/developers/server/http-api#field-definitions [gql-guide]: https://gql-guide.vercel.app/#owners +[ardrive-turbo]: https://ardrive.io/turbo/ diff --git a/package.json b/package.json index e772b8ce..4c4f636e 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ }, "types": "./lib/index.d.ts", "dependencies": { - "ardrive-core-js": "2.0.0-alpha-0", + "ardrive-core-js": "2.0.0", "arweave": "1.11.4", "axios": "^0.21.1", "bn.js": "^5.2.1", @@ -18,7 +18,7 @@ "prompts": "^2.4.0" }, "engines": { - "node": ">=18.17.0" + "node": ">=18" }, "devDependencies": { "@istanbuljs/nyc-config-typescript": "^1.0.1", diff --git a/src/CLICommand/parameters_helper.ts b/src/CLICommand/parameters_helper.ts index a664e92e..7efd1dc5 100644 --- a/src/CLICommand/parameters_helper.ts +++ b/src/CLICommand/parameters_helper.ts @@ -18,7 +18,8 @@ import { MetaDataFileParameter, MetaDataGqlTagsParameter, MetadataJsonParameter, - DataGqlTagsParameter + DataGqlTagsParameter, + TurboUrlParameter } from '../parameter_declarations'; import { cliWalletDao } from '..'; import passwordPrompt from 'prompts'; @@ -46,12 +47,14 @@ import { } from 'ardrive-core-js'; import { JWKInterface } from 'arweave/node/lib/wallet'; import { deriveIpfsCid } from '../utils/ipfs_utils'; +import { turboProdUrl } from 'ardrive-core-js/lib/utils/constants'; // eslint-disable-next-line @typescript-eslint/no-explicit-any type ParameterOptions = any; const DEFAULT_GATEWAY = 'https://arweave.net:443'; const ARWEAVE_GATEWAY_ENV_VAR = 'ARWEAVE_GATEWAY'; +const TURBO_URL_ENV_VAR = 'TURBO_URL'; interface GetDriveKeyParams { driveId: DriveID; @@ -437,6 +440,42 @@ export class ParametersHelper { return userProvidedURL; } + /** + * Gathers a valid turbo URL from user provided turbo parameter, + * an environment variable, or returns the default arweave turbo + * + * @throws on user provided turbos that are incompatible with URL class constructor + * @throws when hostName cannot be derived from a user provided turbo + */ + public getTurbo(): URL { + const userProvidedURL = (() => { + // Use optional --turbo-url supplied parameter as first choice + const turboFromParam = this.getParameterValue(TurboUrlParameter); + if (turboFromParam) { + return new URL(turboFromParam); + } + + // Then check for an ENV provided turbo + const envTurbo = process.env[TURBO_URL_ENV_VAR]; + if (envTurbo) { + return new URL(envTurbo); + } + + return undefined; + })(); + + if (!userProvidedURL) { + // Return default CLI turbo if no turbo url can be derived from the user + return new URL(turboProdUrl); + } + + if (userProvidedURL.hostname === '') { + // Ensure a valid host name was provided to be used in Arweave.init() + throw new TypeError(`Host name could not be determined from provided URL: ${userProvidedURL.href}`); + } + return userProvidedURL; + } + public isDryRun(): boolean { const dryRun = this.getParameterValue(DryRunParameter); return !!dryRun; diff --git a/src/commands/create_drive.ts b/src/commands/create_drive.ts index dad02b9f..99e097d5 100644 --- a/src/commands/create_drive.ts +++ b/src/commands/create_drive.ts @@ -1,11 +1,13 @@ import { CLICommand, ParametersHelper } from '../CLICommand'; import { BoostParameter, + TurboUrlParameter, DriveCreationPrivacyParameters, DriveNameParameter, DryRunParameter, GatewayParameter, - ShouldBundleParameter + ShouldBundleParameter, + ShouldTurboParameter } from '../parameter_declarations'; import { cliArDriveFactory } from '..'; import { SUCCESS_EXIT_CODE } from '../CLICommand/error_codes'; @@ -21,7 +23,9 @@ new CLICommand({ ...DriveCreationPrivacyParameters, ShouldBundleParameter, BoostParameter, - GatewayParameter + GatewayParameter, + ShouldTurboParameter, + TurboUrlParameter ], action: new CLIAction(async function action(options) { const parameters = new ParametersHelper(options); @@ -29,14 +33,17 @@ new CLICommand({ const dryRun = parameters.isDryRun(); const driveName = parameters.getRequiredParameterValue(DriveNameParameter); const shouldBundle = !!parameters.getParameterValue(ShouldBundleParameter); + const useTurbo = !!parameters.getParameterValue(ShouldTurboParameter); const arweave = getArweaveFromURL(parameters.getGateway()); + const turboUrl = parameters.getTurbo(); const ardrive = cliArDriveFactory({ wallet: wallet, feeMultiple: parameters.getOptionalBoostSetting(), dryRun, shouldBundle, - arweave + arweave, + turboSettings: useTurbo ? { turboUrl } : undefined }); const createDriveResult = await (async function () { diff --git a/src/commands/create_folder.ts b/src/commands/create_folder.ts index ab9e8e77..46393bf9 100644 --- a/src/commands/create_folder.ts +++ b/src/commands/create_folder.ts @@ -5,7 +5,9 @@ import { DryRunParameter, ParentFolderIdParameter, DrivePrivacyParameters, - GatewayParameter + GatewayParameter, + ShouldTurboParameter, + TurboUrlParameter } from '../parameter_declarations'; import { cliArDriveFactory } from '..'; import { SUCCESS_EXIT_CODE } from '../CLICommand/error_codes'; @@ -21,19 +23,24 @@ new CLICommand({ BoostParameter, DryRunParameter, ...DrivePrivacyParameters, - GatewayParameter + GatewayParameter, + ShouldTurboParameter, + TurboUrlParameter ], action: new CLIAction(async function action(options) { const parameters = new ParametersHelper(options); const wallet: Wallet = await parameters.getRequiredWallet(); const dryRun = parameters.isDryRun(); const arweave = getArweaveFromURL(parameters.getGateway()); + const useTurbo = !!parameters.getParameterValue(ShouldTurboParameter); + const turboUrl = parameters.getTurbo(); const ardrive = cliArDriveFactory({ wallet, feeMultiple: parameters.getOptionalBoostSetting(), dryRun, - arweave + arweave, + turboSettings: useTurbo ? { turboUrl } : undefined }); const parentFolderId = parameters.getRequiredParameterValue(ParentFolderIdParameter, EID); diff --git a/src/commands/create_manifest.ts b/src/commands/create_manifest.ts index a5637fa9..ad52d814 100644 --- a/src/commands/create_manifest.ts +++ b/src/commands/create_manifest.ts @@ -12,7 +12,9 @@ import { WalletFileParameter, DestinationManifestNameParameter, ConflictResolutionParams, - GatewayParameter + GatewayParameter, + ShouldTurboParameter, + TurboUrlParameter } from '../parameter_declarations'; import { fileUploadConflictPrompts } from '../prompts'; import { getArweaveFromURL } from '../utils/get_arweave_for_url'; @@ -28,19 +30,24 @@ new CLICommand({ SeedPhraseParameter, ...ConflictResolutionParams, ...TreeDepthParams, - GatewayParameter + GatewayParameter, + ShouldTurboParameter, + TurboUrlParameter ], action: new CLIAction(async function action(options) { const parameters = new ParametersHelper(options, cliWalletDao); const wallet = await parameters.getRequiredWallet(); const arweave = getArweaveFromURL(parameters.getGateway()); + const useTurbo = !!parameters.getParameterValue(ShouldTurboParameter); + const turboUrl = parameters.getTurbo(); const arDrive = cliArDriveFactory({ wallet: wallet, feeMultiple: parameters.getOptionalBoostSetting(), dryRun: parameters.isDryRun(), - arweave + arweave, + turboSettings: useTurbo ? { turboUrl } : undefined }); const folderId = parameters.getRequiredParameterValue(FolderIdParameter, EID); diff --git a/src/commands/move_file.ts b/src/commands/move_file.ts index 555d4561..06916f9d 100644 --- a/src/commands/move_file.ts +++ b/src/commands/move_file.ts @@ -5,7 +5,9 @@ import { FileIdParameter, ParentFolderIdParameter, DrivePrivacyParameters, - GatewayParameter + GatewayParameter, + ShouldTurboParameter, + TurboUrlParameter } from '../parameter_declarations'; import { cliArDriveFactory } from '..'; import { SUCCESS_EXIT_CODE } from '../CLICommand/error_codes'; @@ -20,6 +22,8 @@ new CLICommand({ ParentFolderIdParameter, BoostParameter, DryRunParameter, + ShouldTurboParameter, + TurboUrlParameter, ...DrivePrivacyParameters, GatewayParameter ], @@ -30,12 +34,15 @@ new CLICommand({ const dryRun = parameters.isDryRun(); const fileId = parameters.getRequiredParameterValue(FileIdParameter, EID); const newParentFolderId = parameters.getRequiredParameterValue(ParentFolderIdParameter, EID); + const shouldUseTurbo = !!parameters.getParameterValue(ShouldTurboParameter); + const turboUrl = parameters.getTurbo(); const wallet: Wallet = await parameters.getRequiredWallet(); const ardrive = cliArDriveFactory({ wallet: wallet, feeMultiple: parameters.getOptionalBoostSetting(), dryRun, + turboSettings: shouldUseTurbo ? { turboUrl } : undefined, arweave }); diff --git a/src/commands/move_folder.ts b/src/commands/move_folder.ts index 5fb78762..35590ea9 100644 --- a/src/commands/move_folder.ts +++ b/src/commands/move_folder.ts @@ -5,7 +5,9 @@ import { FolderIdParameter, ParentFolderIdParameter, DrivePrivacyParameters, - GatewayParameter + GatewayParameter, + TurboUrlParameter, + ShouldTurboParameter } from '../parameter_declarations'; import { SUCCESS_EXIT_CODE } from '../CLICommand/error_codes'; import { CLIAction } from '../CLICommand/action'; @@ -20,6 +22,8 @@ new CLICommand({ ParentFolderIdParameter, BoostParameter, DryRunParameter, + ShouldTurboParameter, + TurboUrlParameter, ...DrivePrivacyParameters, GatewayParameter ], @@ -30,11 +34,14 @@ new CLICommand({ const dryRun = parameters.isDryRun(); const folderId = parameters.getRequiredParameterValue(FolderIdParameter, EID); const newParentFolderId = parameters.getRequiredParameterValue(ParentFolderIdParameter, EID); + const shouldUseTurbo = !!parameters.getParameterValue(ShouldTurboParameter); + const turboUrl = parameters.getTurbo(); const wallet: Wallet = await parameters.getRequiredWallet(); const ardrive = cliArDriveFactory({ wallet: wallet, feeMultiple: parameters.getOptionalBoostSetting(), + turboSettings: shouldUseTurbo ? { turboUrl } : undefined, dryRun, arweave }); diff --git a/src/commands/rename_drive.ts b/src/commands/rename_drive.ts index ebdcb6cd..547d9edb 100644 --- a/src/commands/rename_drive.ts +++ b/src/commands/rename_drive.ts @@ -5,7 +5,9 @@ import { DriveIdParameter, DrivePrivacyParameters, DriveNameParameter, - GatewayParameter + GatewayParameter, + ShouldTurboParameter, + TurboUrlParameter } from '../parameter_declarations'; import { cliArDriveFactory } from '..'; import { SUCCESS_EXIT_CODE } from '../CLICommand/error_codes'; @@ -21,6 +23,8 @@ new CLICommand({ BoostParameter, DryRunParameter, ...DrivePrivacyParameters, + ShouldTurboParameter, + TurboUrlParameter, GatewayParameter ], action: new CLIAction(async function action(options) { @@ -30,12 +34,15 @@ new CLICommand({ const dryRun = parameters.isDryRun(); const driveId = parameters.getRequiredParameterValue(DriveIdParameter, EID); const newName = parameters.getRequiredParameterValue(DriveNameParameter); + const shouldUseTurbo = !!parameters.getParameterValue(ShouldTurboParameter); + const turboUrl = parameters.getTurbo(); const wallet: Wallet = await parameters.getRequiredWallet(); const ardrive = cliArDriveFactory({ wallet, feeMultiple: parameters.getOptionalBoostSetting(), dryRun, + turboSettings: shouldUseTurbo ? { turboUrl } : undefined, arweave }); diff --git a/src/commands/rename_file.ts b/src/commands/rename_file.ts index 580483b7..00a1fb31 100644 --- a/src/commands/rename_file.ts +++ b/src/commands/rename_file.ts @@ -5,7 +5,9 @@ import { FileIdParameter, DrivePrivacyParameters, FileNameParameter, - GatewayParameter + GatewayParameter, + ShouldTurboParameter, + TurboUrlParameter } from '../parameter_declarations'; import { cliArDriveFactory } from '..'; import { SUCCESS_EXIT_CODE } from '../CLICommand/error_codes'; @@ -19,6 +21,8 @@ new CLICommand({ FileIdParameter, FileNameParameter, BoostParameter, + ShouldTurboParameter, + TurboUrlParameter, DryRunParameter, ...DrivePrivacyParameters, GatewayParameter @@ -30,12 +34,15 @@ new CLICommand({ const dryRun = parameters.isDryRun(); const fileId = parameters.getRequiredParameterValue(FileIdParameter, EID); const newName = parameters.getRequiredParameterValue(FileNameParameter); + const shouldUseTurbo = !!parameters.getParameterValue(ShouldTurboParameter); + const turboUrl = parameters.getTurbo(); const wallet: Wallet = await parameters.getRequiredWallet(); const ardrive = cliArDriveFactory({ wallet: wallet, feeMultiple: parameters.getOptionalBoostSetting(), dryRun, + turboSettings: shouldUseTurbo ? { turboUrl } : undefined, arweave }); diff --git a/src/commands/rename_folder.ts b/src/commands/rename_folder.ts index f7cdbe4b..1a43822e 100644 --- a/src/commands/rename_folder.ts +++ b/src/commands/rename_folder.ts @@ -5,7 +5,9 @@ import { FolderIdParameter, DrivePrivacyParameters, FolderNameParameter, - GatewayParameter + GatewayParameter, + ShouldTurboParameter, + TurboUrlParameter } from '../parameter_declarations'; import { cliArDriveFactory } from '..'; import { SUCCESS_EXIT_CODE } from '../CLICommand/error_codes'; @@ -20,6 +22,8 @@ new CLICommand({ FolderNameParameter, BoostParameter, DryRunParameter, + ShouldTurboParameter, + TurboUrlParameter, ...DrivePrivacyParameters, GatewayParameter ], @@ -31,11 +35,14 @@ new CLICommand({ const dryRun = parameters.isDryRun(); const folderId = parameters.getRequiredParameterValue(FolderIdParameter, EID); const newName = parameters.getRequiredParameterValue(FolderNameParameter); + const shouldUseTurbo = !!parameters.getParameterValue(ShouldTurboParameter); + const turboUrl = parameters.getTurbo(); const wallet: Wallet = await parameters.getRequiredWallet(); const ardrive = cliArDriveFactory({ wallet: wallet, feeMultiple: parameters.getOptionalBoostSetting(), + turboSettings: shouldUseTurbo ? { turboUrl } : undefined, dryRun, arweave }); diff --git a/src/commands/upload_file.ts b/src/commands/upload_file.ts index 62ae3b7e..3ecbb03d 100644 --- a/src/commands/upload_file.ts +++ b/src/commands/upload_file.ts @@ -16,7 +16,9 @@ import { CustomContentTypeParameter, RemotePathParameter, CustomMetaDataParameters, - IPFSParameter + IPFSParameter, + TurboUrlParameter, + ShouldTurboParameter } from '../parameter_declarations'; import { fileAndFolderUploadConflictPrompts } from '../prompts'; import { ERROR_EXIT_CODE, SUCCESS_EXIT_CODE } from '../CLICommand/error_codes'; @@ -183,16 +185,16 @@ new CLICommand({ ParentFolderIdParameter, DestinationFileNameParameter, BoostParameter, - DryRunParameter, ShouldBundleParameter, + ShouldTurboParameter, ...ConflictResolutionParams, ...DrivePrivacyParameters, CustomContentTypeParameter, ...CustomMetaDataParameters, LocalFilePathParameter_DEPRECATED, LocalFilesParameter_DEPRECATED, - BoostParameter, GatewayParameter, + TurboUrlParameter, RemotePathParameter, IPFSParameter ], @@ -226,15 +228,18 @@ new CLICommand({ const conflictResolution = parameters.getFileNameConflictResolution(); const shouldBundle = !!parameters.getParameterValue(ShouldBundleParameter); + const shouldUseTurbo = !!parameters.getParameterValue(ShouldTurboParameter); const remoteFilePath = parameters.getParameterValue(RemotePathParameter); const arweave = getArweaveFromURL(parameters.getGateway()); + const turboUrl = parameters.getTurbo(); const arDrive = cliArDriveFactory({ wallet, feeMultiple: parameters.getOptionalBoostSetting(), dryRun: parameters.isDryRun(), shouldBundle, + turboSettings: shouldUseTurbo ? { turboUrl } : undefined, arweave }); diff --git a/src/index.ts b/src/index.ts index e3eca8ee..a1ebeaec 100755 --- a/src/index.ts +++ b/src/index.ts @@ -59,6 +59,7 @@ export const cliArDriveFactory = ({ communityOracle, priceEstimator, shouldBundle = true, + turboSettings = undefined, arFSTagSettings = new ArFSTagSettings({ appName, appVersion }), uploadPlanner }: ArDriveSettings): ArDrive => @@ -75,7 +76,8 @@ export const cliArDriveFactory = ({ priceEstimator, shouldBundle, arFSTagSettings, - uploadPlanner + uploadPlanner, + turboSettings }); export const cliArDriveAnonymousFactory = ({ arweave = cliArweave }: ArDriveSettingsAnonymous): ArDriveAnonymous => diff --git a/src/parameter_declarations.ts b/src/parameter_declarations.ts index ec29a44b..b419c475 100644 --- a/src/parameter_declarations.ts +++ b/src/parameter_declarations.ts @@ -35,11 +35,13 @@ export const UpsertParameter = 'upsert'; export const AskParameter = 'ask'; export const NoVerifyParameter = 'verify'; // commander maps --no-x style params to options.x and always includes in options export const ShouldBundleParameter = 'bundle'; // commander maps --no-x style params to options.x and always includes in options +export const ShouldTurboParameter = 'turbo'; // commander maps --no-x style params to options.x and always includes in options export const LocalPathParameter = 'localPath'; export const LocalPathsParameter = 'localPaths'; export const LocalCSVParameter = 'localCsv'; export const WithKeysParameter = 'withKeys'; export const GatewayParameter = 'gateway'; +export const TurboUrlParameter = 'turboUrl'; export const CustomContentTypeParameter = 'contentType'; export const RemotePathParameter = 'remotePath'; export const IPFSParameter = 'addIpfsTag'; @@ -63,6 +65,7 @@ export const AllParameters = [ AddressParameter, AllParameter, ArAmountParameter, + TurboUrlParameter, BoostParameter, ConfirmationsParameter, CustomContentTypeParameter, @@ -89,6 +92,7 @@ export const AllParameters = [ MetaDataGqlTagsParameter, MetadataJsonParameter, ShouldBundleParameter, + ShouldTurboParameter, NoVerifyParameter, ParentFolderIdParameter, PrivateParameter, @@ -408,6 +412,13 @@ Parameter.declare({ type: 'boolean' }); +Parameter.declare({ + name: ShouldTurboParameter, + aliases: ['--turbo'], + description: '(OPTIONAL) Send data items to turbo service. BETA FEATURE.', + type: 'boolean' +}); + Parameter.declare({ name: LocalPathParameter, aliases: ['--local-path'], @@ -485,6 +496,12 @@ Parameter.declare({ description: `(OPTIONAL) a 'protocol://host:port' formatted string specifying the connection info for the Arweave gateway server to use` }); +Parameter.declare({ + name: TurboUrlParameter, + aliases: ['--turbo-url'], + description: `(OPTIONAL) a 'protocol://host:port' formatted string specifying the connection info for which turbo service to send data items to` +}); + Parameter.declare({ name: CustomContentTypeParameter, aliases: ['--content-type'], diff --git a/yarn.lock b/yarn.lock index 4d78bc80..accc8b2c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -248,6 +248,15 @@ __metadata: languageName: node linkType: hard +"@babel/runtime@npm:^7.15.4": + version: 7.22.10 + resolution: "@babel/runtime@npm:7.22.10" + dependencies: + regenerator-runtime: ^0.14.0 + checksum: 524d41517e68953dbc73a4f3616b8475e5813f64e28ba89ff5fca2c044d535c2ea1a3f310df1e5bb06162e1f0b401b5c4af73fe6e2519ca2450d9d8c44cf268d + languageName: node + linkType: hard + "@babel/template@npm:^7.15.4": version: 7.15.4 resolution: "@babel/template@npm:7.15.4" @@ -1793,7 +1802,7 @@ __metadata: "@types/source-map-support": ^0 "@typescript-eslint/eslint-plugin": ^6.2.1 "@typescript-eslint/parser": ^6.2.1 - ardrive-core-js: 2.0.0-alpha-0 + ardrive-core-js: 2.0.0 arweave: 1.11.4 axios: ^0.21.1 bn.js: ^5.2.1 @@ -1821,15 +1830,16 @@ __metadata: languageName: unknown linkType: soft -"ardrive-core-js@npm:2.0.0-alpha-0": - version: 2.0.0-alpha-0 - resolution: "ardrive-core-js@npm:2.0.0-alpha-0" +"ardrive-core-js@npm:2.0.0": + version: 2.0.0 + resolution: "ardrive-core-js@npm:2.0.0" dependencies: "@alexsasharegan/simple-cache": ^3.3.3 arbundles: ^0.6.19 arweave: ^1.11.4 arweave-mnemonic-keys: ^0.0.9 axios: ^0.21.1 + axios-retry: ^3.6.0 base64-js: ^1.5.1 bignumber.js: ^9.0.1 bn.js: ^5.2.1 @@ -1841,7 +1851,7 @@ __metadata: smartweave: ^0.4.49 utf8: ^3.0.0 uuid: ^8.3.2 - checksum: 7f922ef02246c992ccf1bbe0bd017b6a2ff8d6b4e1336e50dcd4698d369f2dd6c33d1408bc823f2167a4099877a1af3893f17fc075429539fe22096a6d26493a + checksum: 6d4e58e676e7cd2f6509b7f0b9ae922767facc3c48979ef458d990a44bfceb6a0cc4b2565d9ace2379d06434a30313c34df6396bb9647a7be876db8061cd142c languageName: node linkType: hard @@ -2025,6 +2035,16 @@ __metadata: languageName: node linkType: hard +"axios-retry@npm:^3.6.0": + version: 3.6.0 + resolution: "axios-retry@npm:3.6.0" + dependencies: + "@babel/runtime": ^7.15.4 + is-retry-allowed: ^2.2.0 + checksum: 9ed0879453170a55960dea21116e7f732f1e78acb72eb49d80b1620583814d94bda78200d0767bae82d37cc2ab80752f0aec49717ce4b141858059c0c6b9921c + languageName: node + linkType: hard + "axios@npm:^0.21.1": version: 0.21.1 resolution: "axios@npm:0.21.1" @@ -4602,6 +4622,13 @@ fsevents@~2.3.2: languageName: node linkType: hard +"is-retry-allowed@npm:^2.2.0": + version: 2.2.0 + resolution: "is-retry-allowed@npm:2.2.0" + checksum: 3d1103a9290b5d03626756a41054844633eac78bc5d3e3a95b13afeae94fa3cfbcf7f0b5520d83f75f48a25ce7b142fdbac4217dc4b0630f3ea55e866ec3a029 + languageName: node + linkType: hard + "is-shared-array-buffer@npm:^1.0.2": version: 1.0.2 resolution: "is-shared-array-buffer@npm:1.0.2" @@ -6504,6 +6531,13 @@ fsevents@~2.3.2: languageName: node linkType: hard +"regenerator-runtime@npm:^0.14.0": + version: 0.14.0 + resolution: "regenerator-runtime@npm:0.14.0" + checksum: 1c977ad82a82a4412e4f639d65d22be376d3ebdd30da2c003eeafdaaacd03fc00c2320f18120007ee700900979284fc78a9f00da7fb593f6e6eeebc673fba9a3 + languageName: node + linkType: hard + "regexp.prototype.flags@npm:^1.4.3": version: 1.4.3 resolution: "regexp.prototype.flags@npm:1.4.3"