From 26952ac11bfd2494d8c8ca11dd9712a9a8e3409c Mon Sep 17 00:00:00 2001 From: Derek Sonnenberg Date: Wed, 20 Sep 2023 10:07:31 -0500 Subject: [PATCH] feat(turbo): use turbo sdk for upload PE-4472 --- package.json | 2 +- src/CLICommand/parameters_helper.ts | 3 +-- src/commands/create_drive.ts | 8 +++++++- src/commands/create_folder.ts | 8 +++++++- src/commands/create_manifest.ts | 8 +++++++- src/commands/move_file.ts | 8 +++++++- src/commands/move_folder.ts | 8 +++++++- src/commands/rename_drive.ts | 4 +++- src/commands/rename_file.ts | 4 +++- src/commands/rename_folder.ts | 4 +++- src/commands/upload_file.ts | 4 +++- tsconfig.json | 3 ++- 12 files changed, 51 insertions(+), 13 deletions(-) diff --git a/package.json b/package.json index 4c4f636e..03b291d6 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ }, "types": "./lib/index.d.ts", "dependencies": { - "ardrive-core-js": "2.0.0", + "ardrive-core-js": "../ardrive-core-js", "arweave": "1.11.4", "axios": "^0.21.1", "bn.js": "^5.2.1", diff --git a/src/CLICommand/parameters_helper.ts b/src/CLICommand/parameters_helper.ts index 7efd1dc5..e73765df 100644 --- a/src/CLICommand/parameters_helper.ts +++ b/src/CLICommand/parameters_helper.ts @@ -47,7 +47,6 @@ 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; @@ -466,7 +465,7 @@ export class ParametersHelper { if (!userProvidedURL) { // Return default CLI turbo if no turbo url can be derived from the user - return new URL(turboProdUrl); + return new URL('https://upload.ardrive.dev'); } if (userProvidedURL.hostname === '') { diff --git a/src/commands/create_drive.ts b/src/commands/create_drive.ts index 99e097d5..85acf9ce 100644 --- a/src/commands/create_drive.ts +++ b/src/commands/create_drive.ts @@ -43,7 +43,13 @@ new CLICommand({ dryRun, shouldBundle, arweave, - turboSettings: useTurbo ? { turboUrl } : undefined + turboSettings: useTurbo + ? { + turboUploadUrl: turboUrl, + turboPaymentUrl: new URL(turboUrl.toString().replace('upload', 'payment')), + isDryRun: dryRun + } + : undefined }); const createDriveResult = await (async function () { diff --git a/src/commands/create_folder.ts b/src/commands/create_folder.ts index 46393bf9..32d31dce 100644 --- a/src/commands/create_folder.ts +++ b/src/commands/create_folder.ts @@ -40,7 +40,13 @@ new CLICommand({ feeMultiple: parameters.getOptionalBoostSetting(), dryRun, arweave, - turboSettings: useTurbo ? { turboUrl } : undefined + turboSettings: useTurbo + ? { + turboUploadUrl: turboUrl, + turboPaymentUrl: new URL(turboUrl.toString().replace('upload', 'payment')), + isDryRun: parameters.isDryRun() + } + : undefined }); const parentFolderId = parameters.getRequiredParameterValue(ParentFolderIdParameter, EID); diff --git a/src/commands/create_manifest.ts b/src/commands/create_manifest.ts index ad52d814..8947e971 100644 --- a/src/commands/create_manifest.ts +++ b/src/commands/create_manifest.ts @@ -47,7 +47,13 @@ new CLICommand({ feeMultiple: parameters.getOptionalBoostSetting(), dryRun: parameters.isDryRun(), arweave, - turboSettings: useTurbo ? { turboUrl } : undefined + turboSettings: useTurbo + ? { + turboUploadUrl: turboUrl, + turboPaymentUrl: new URL(turboUrl.toString().replace('upload', 'payment')), + isDryRun: parameters.isDryRun() + } + : undefined }); const folderId = parameters.getRequiredParameterValue(FolderIdParameter, EID); diff --git a/src/commands/move_file.ts b/src/commands/move_file.ts index 06916f9d..0e0de097 100644 --- a/src/commands/move_file.ts +++ b/src/commands/move_file.ts @@ -42,7 +42,13 @@ new CLICommand({ wallet: wallet, feeMultiple: parameters.getOptionalBoostSetting(), dryRun, - turboSettings: shouldUseTurbo ? { turboUrl } : undefined, + turboSettings: shouldUseTurbo + ? { + turboUploadUrl: turboUrl, + turboPaymentUrl: new URL(turboUrl.toString().replace('upload', 'payment')), + isDryRun: parameters.isDryRun() + } + : undefined, arweave }); diff --git a/src/commands/move_folder.ts b/src/commands/move_folder.ts index 35590ea9..708aaaab 100644 --- a/src/commands/move_folder.ts +++ b/src/commands/move_folder.ts @@ -41,7 +41,13 @@ new CLICommand({ const ardrive = cliArDriveFactory({ wallet: wallet, feeMultiple: parameters.getOptionalBoostSetting(), - turboSettings: shouldUseTurbo ? { turboUrl } : undefined, + turboSettings: shouldUseTurbo + ? { + turboUploadUrl: turboUrl, + turboPaymentUrl: new URL(turboUrl.toString().replace('upload', 'payment')), + isDryRun: parameters.isDryRun() + } + : undefined, dryRun, arweave }); diff --git a/src/commands/rename_drive.ts b/src/commands/rename_drive.ts index 547d9edb..c45ebe31 100644 --- a/src/commands/rename_drive.ts +++ b/src/commands/rename_drive.ts @@ -42,7 +42,9 @@ new CLICommand({ wallet, feeMultiple: parameters.getOptionalBoostSetting(), dryRun, - turboSettings: shouldUseTurbo ? { turboUrl } : undefined, + turboSettings: shouldUseTurbo + ? { turboUploadUrl: turboUrl, turboPaymentUrl: turboUrl, isDryRun: parameters.isDryRun() } + : undefined, arweave }); diff --git a/src/commands/rename_file.ts b/src/commands/rename_file.ts index 00a1fb31..5cfad148 100644 --- a/src/commands/rename_file.ts +++ b/src/commands/rename_file.ts @@ -42,7 +42,9 @@ new CLICommand({ wallet: wallet, feeMultiple: parameters.getOptionalBoostSetting(), dryRun, - turboSettings: shouldUseTurbo ? { turboUrl } : undefined, + turboSettings: shouldUseTurbo + ? { turboUploadUrl: turboUrl, turboPaymentUrl: turboUrl, isDryRun: parameters.isDryRun() } + : undefined, arweave }); diff --git a/src/commands/rename_folder.ts b/src/commands/rename_folder.ts index 1a43822e..36bb1937 100644 --- a/src/commands/rename_folder.ts +++ b/src/commands/rename_folder.ts @@ -42,7 +42,9 @@ new CLICommand({ const ardrive = cliArDriveFactory({ wallet: wallet, feeMultiple: parameters.getOptionalBoostSetting(), - turboSettings: shouldUseTurbo ? { turboUrl } : undefined, + turboSettings: shouldUseTurbo + ? { turboUploadUrl: turboUrl, turboPaymentUrl: turboUrl, isDryRun: dryRun } + : undefined, dryRun, arweave }); diff --git a/src/commands/upload_file.ts b/src/commands/upload_file.ts index 3ecbb03d..05d6cbd5 100644 --- a/src/commands/upload_file.ts +++ b/src/commands/upload_file.ts @@ -239,7 +239,9 @@ new CLICommand({ feeMultiple: parameters.getOptionalBoostSetting(), dryRun: parameters.isDryRun(), shouldBundle, - turboSettings: shouldUseTurbo ? { turboUrl } : undefined, + turboSettings: shouldUseTurbo + ? { turboUploadUrl: turboUrl, turboPaymentUrl: turboUrl, isDryRun: parameters.isDryRun() } + : undefined, arweave }); diff --git a/tsconfig.json b/tsconfig.json index 051b26dd..c4445cb7 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -14,7 +14,8 @@ "noUnusedLocals": true, "noUnusedParameters": true, "noImplicitReturns": true, - "noFallthroughCasesInSwitch": true + "noFallthroughCasesInSwitch": true, + "skipLibCheck": true }, "include": ["src", "tests"] }