From 61efd494d41a9389d71b5a0fbf8ea676345d0f2e Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Mon, 26 Feb 2024 14:33:06 +0545 Subject: [PATCH 1/6] fix: Fetch turbo subsidy size instead of hardcoding --- README.md | 2 +- src/lib/arweaveHelper.ts | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 11156d3..e1840db 100644 --- a/README.md +++ b/README.md @@ -63,7 +63,7 @@ This command sets the global threshold cost for push consent to `0.0003 AR`. Whe Here's how it decides when to ask for your consent before uploading: -- **No Set Threshold**: Without the threshold set, you'll only be asked for consent if the upload size exceeds the free subsidy size (For example: Turbo bundler used here allows upto 500KB uploads for free). +- **No Set Threshold**: Without the threshold set, you'll only be asked for consent if the upload size exceeds the free subsidy size (For example: Turbo bundler used here allows upto 105KB uploads for free). - **Over the Threshold**: If the upload cost is more than the threshold, consent is requested only if the upload size is larger than what's freely allowed. - **Under the Threshold**: For costs below the threshold, consent isn't needed, and uploads proceed automatically. diff --git a/src/lib/arweaveHelper.ts b/src/lib/arweaveHelper.ts index 0606169..d63992b 100644 --- a/src/lib/arweaveHelper.ts +++ b/src/lib/arweaveHelper.ts @@ -105,6 +105,20 @@ const shouldPushChanges = async ( } }; +async function getTurboSubsidy() { + const defaultSubsidy = 107520; + try { + const response = await fetch('https://turbo.ardrive.io/'); + if (!response.ok) return defaultSubsidy; + + const data = (await response.json()) as { + freeUploadLimitBytes: number; + }; + return +data.freeUploadLimitBytes ?? defaultSubsidy; + } catch (err) {} + return defaultSubsidy; +} + export async function uploadRepo( zipBuffer: Buffer, tags: Tag[], @@ -127,8 +141,9 @@ export async function uploadRepo( //continue } - // 500KB subsidySize for TurboUpload and 0 subsidySize for ArweaveUpload - const subsidySize = Math.max(500 * 1024, 0); + // 105KB subsidySize for TurboUpload and 0 subsidySize for ArweaveUpload + const turboSubsidySize = await getTurboSubsidy(); + const subsidySize = Math.max(turboSubsidySize, 0); const pushChanges = await shouldPushChanges( uploadSize, uploadCost, From 3e70bc1f6677c6d8e4f5615cc24ae7c7556b51c3 Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Mon, 26 Feb 2024 14:38:12 +0545 Subject: [PATCH 2/6] refactor: Send repo id over github sync api trigger --- src/lib/githubSync.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/lib/githubSync.ts b/src/lib/githubSync.ts index 5d315e0..0ecd49a 100644 --- a/src/lib/githubSync.ts +++ b/src/lib/githubSync.ts @@ -92,7 +92,10 @@ export async function triggerGithubSync(repo: Repo) { 'X-GitHub-Api-Version': '2022-11-28', Authorization: `Bearer ${accessToken}`, }, - body: JSON.stringify({ ref: githubSync?.branch, inputs: {} }), + body: JSON.stringify({ + ref: githubSync?.branch, + inputs: { repoId: repo.id }, + }), } ); From ae034eb7c29286c37445792bc2c2e8d0e1f20f29 Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Mon, 26 Feb 2024 15:10:55 +0545 Subject: [PATCH 3/6] fix: Update turbo subsidy fetching function --- src/lib/arweaveHelper.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/lib/arweaveHelper.ts b/src/lib/arweaveHelper.ts index d63992b..738ba53 100644 --- a/src/lib/arweaveHelper.ts +++ b/src/lib/arweaveHelper.ts @@ -114,7 +114,12 @@ async function getTurboSubsidy() { const data = (await response.json()) as { freeUploadLimitBytes: number; }; - return +data.freeUploadLimitBytes ?? defaultSubsidy; + + const freeUploadLimitBytes = +data.freeUploadLimitBytes; + + if (Number.isFinite(freeUploadLimitBytes)) return freeUploadLimitBytes; + + return defaultSubsidy; } catch (err) {} return defaultSubsidy; } From 452751bbbce9525ba4373acda343a4decaf1f7a4 Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Mon, 26 Feb 2024 15:25:51 +0545 Subject: [PATCH 4/6] chore: Add changeset --- .changeset/little-cheetahs-perform.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/little-cheetahs-perform.md diff --git a/.changeset/little-cheetahs-perform.md b/.changeset/little-cheetahs-perform.md new file mode 100644 index 0000000..a1f0e31 --- /dev/null +++ b/.changeset/little-cheetahs-perform.md @@ -0,0 +1,5 @@ +--- +'@protocol.land/git-remote-helper': patch +--- + +Fetch turbo free upload limit & send repo id over github sync api call From e648d1722259efc390917decd71124ff8531e6db Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Wed, 6 Mar 2024 21:52:04 +0545 Subject: [PATCH 5/6] chore: Update changeset for release --- .changeset/kind-goats-promise.md | 7 +++++++ .changeset/little-cheetahs-perform.md | 5 ----- 2 files changed, 7 insertions(+), 5 deletions(-) create mode 100644 .changeset/kind-goats-promise.md delete mode 100644 .changeset/little-cheetahs-perform.md diff --git a/.changeset/kind-goats-promise.md b/.changeset/kind-goats-promise.md new file mode 100644 index 0000000..0630fd9 --- /dev/null +++ b/.changeset/kind-goats-promise.md @@ -0,0 +1,7 @@ +--- +'@protocol.land/git-remote-helper': minor +--- + +- fix: Fetch turbo free upload limit & send repo id over github sync api call #25 +- feat: Clone repo using username/repoName or repo id #26 +- perf: Improve warp caching #27 diff --git a/.changeset/little-cheetahs-perform.md b/.changeset/little-cheetahs-perform.md deleted file mode 100644 index a1f0e31..0000000 --- a/.changeset/little-cheetahs-perform.md +++ /dev/null @@ -1,5 +0,0 @@ ---- -'@protocol.land/git-remote-helper': patch ---- - -Fetch turbo free upload limit & send repo id over github sync api call From 0cb9b9179c76ab517393b436ca35c917e7c91d74 Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Mon, 11 Mar 2024 20:52:15 +0545 Subject: [PATCH 6/6] chore: Update changeset for release --- .changeset/kind-goats-promise.md | 1 + 1 file changed, 1 insertion(+) diff --git a/.changeset/kind-goats-promise.md b/.changeset/kind-goats-promise.md index 0630fd9..3b30e4e 100644 --- a/.changeset/kind-goats-promise.md +++ b/.changeset/kind-goats-promise.md @@ -5,3 +5,4 @@ - fix: Fetch turbo free upload limit & send repo id over github sync api call #25 - feat: Clone repo using username/repoName or repo id #26 - perf: Improve warp caching #27 +- feat: support tx subsidization #28