diff --git a/.changeset/early-carrots-glow.md b/.changeset/early-carrots-glow.md new file mode 100644 index 0000000..9f53a9e --- /dev/null +++ b/.changeset/early-carrots-glow.md @@ -0,0 +1,5 @@ +--- +'@protocol.land/sync': minor +--- + +remove repo subsidization diff --git a/README.md b/README.md index db9caf9..a670416 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ The Protocol Land Sync package simplifies the process of syncing Git repositorie To sync a repository with Protocol Land, you can either run it manually from your local Git repository's root folder or set up a GitHub Action if your repository is hosted on GitHub. -For both methods, **you need an Arweave wallet with some $AR** to pay for the upload, unless your repository uses less than 100KB of data. +For both methods, **you need an Arweave wallet with some $AR** to pay for the upload. ### GitHub Actions @@ -60,24 +60,9 @@ jobs: REPO_TITLE: ${{ github.event.repository.name }} REPO_DESCRIPTION: ${{ github.event.repository.description }} WALLET: ${{ secrets.WALLET }} - # Optional Environment variables for ArSeeding strategy - STRATEGY: "ARSEEDING" - ARSEEDING_TOKEN_SYMBOL: "AR" - # Use personal funds in case of transaction subsidization failure - HANDLE_SUBSIDY_ERROR: "true" ``` - -> [!NOTE] -> Currently all Sync transactions are subsidized by Protocol Land. In case of subsidizing service failure, Sync program will exit unless `HANDLE_SUBSIDY_ERROR` env is set which lets you pay for the transaction from your wallet and continue. - - -> [!NOTE] -> Only include `STRATEGY` and `ARSEEDING_TOKEN_SYMBOL` environment variables for using [ArSeeding](https://web3infra.dev/docs/arseeding/introduction/lightNode/) to sync your repositories to Protocol Land. -> Supported Arweave tokens for ArSeeding strategy are: `['XYZ', 'ARDRIVE', 'PIA', 'VRT', 'U', 'STAMP', 'AR']`. -> You need [EverPay](https://app.everpay.io/) balances for these tokens to use ArSeeding strategy. - > [!NOTE] > This GitHub Action **will run on every push to the 'main' branch**. > If you want to run it manually, comment the lines after `on:` and uncomment the `workflow_dispatch:` line. @@ -107,25 +92,12 @@ Follow `1.` and `2.` from the previous section to set up a GitHub Secret. WALLET='YOUR_WALLET_JWK_HERE' REPO_TITLE='Your Repo Name Here' REPO_DESCRIPTION='Your Repo Description Here' - - # Optional Environment variables for ArSeeding strategy - - STRATEGY='ARSEEDING' - ARSEEDING_TOKEN_SYMBOL='AR' - - # Use personal funds in case of transaction subsidization failure - - HANDLE_SUBSIDY_ERROR='true' ``` Replace `'YOUR_WALLET_JWK_HERE'` with your Arweave wallet's JWK (JSON Web Key). - - Currently Sync transaction costs are subsidized by Protocol Land and in case of subsidization failure, Sync program will exit unless `HANDLE_SUBSIDY_ERROR` env is set which lets you pay for the transaction from your wallet and continue. - If the compressed size of your repository exceeds 100kb, ensure your wallet has enough $AR to cover the transaction fees. These environment variables (`WALLET`, `REPO_TITLE`, and `REPO_DESCRIPTION`) are crucial for setting up your repository and providing a meaningful description. - `STRATEGY` and `ARSEEDING_TOKEN_SYMBOL` are needed for using [ArSeeding](https://web3infra.dev/docs/arseeding/introduction/lightNode/) to sync repositories to Protocol Land. Supported Arweave tokens for ArSeeding strategy are: `['XYZ', 'ARDRIVE', 'PIA', 'VRT', 'U', 'STAMP', 'AR']`. 4. **(optional)** Checkout locally all the branches you want synced. The tool uploads all the branches you have checked out locally with Git. Run this bash command to checkout all the remote branches: diff --git a/package.json b/package.json index c73f739..0ca87ee 100644 --- a/package.json +++ b/package.json @@ -37,10 +37,8 @@ "@amplitude/analytics-node": "^1.3.4", "@permaweb/aoconnect": "^0.0.52", "arbundles": "^0.9.11", - "arseeding-js": "^0.0.30", "arweave": "^1.14.4", "dotenv": "^16.4.1", - "everpay": "^1.2.2", "jszip": "^3.10.1", "uuid": "^9.0.1" }, diff --git a/src/lib/arseeding.ts b/src/lib/arseeding.ts deleted file mode 100644 index 684ad94..0000000 --- a/src/lib/arseeding.ts +++ /dev/null @@ -1,85 +0,0 @@ -import { ArweaveSigner, getTokenTagByEver } from 'arseeding-js'; -import { createAndSubmitItem } from 'arseeding-js/cjs/submitOrder'; -import { payOrder } from 'arseeding-js/cjs/payOrder'; -import { Config } from 'arseeding-js/cjs/types'; -import { Tag } from 'arweave/node/lib/transaction'; -import { getWallet, initArweave } from './common'; -import Everpay, { ChainType } from 'everpay'; - -const newEverpayByRSA = (arJWK: any, arAddress: string): Everpay => { - const everpay = new Everpay({ - account: arAddress, - chainType: 'arweave' as ChainType, - arJWK: arJWK, - }); - return everpay; -}; - -function getSigner() { - const wallet = getWallet(); - const signer = new ArweaveSigner(wallet); - return signer; -} - -async function paymentSigner() { - const wallet = getWallet(); - const arAddress = await initArweave().wallets.jwkToAddress(wallet); - const signer = newEverpayByRSA(wallet, arAddress); - return signer; -} - -async function getSupportedTokens() { - try { - const info = await new Everpay().info(); - const supportedTokens = info.tokenList - .filter((token) => token.chainType.includes('arweave')) - .map((token) => token.symbol.toLowerCase()); - return supportedTokens; - } catch (err) {} - - return ['xyz', 'ardrive', 'pia', 'vrt', 'u', 'stamp', 'ar']; -} - -export async function arseedingUpload(zipBuffer: Buffer, tags: Tag[]) { - try { - const signer = getSigner(); - - const options = { tags }; - const arseedUrl = 'https://arseed.web3infra.dev'; - const tokenSymbol = process.env.ARSEEDING_TOKEN_SYMBOL ?? 'AR'; - const supportedTokens = await getSupportedTokens(); - if (!supportedTokens.includes(tokenSymbol.toLowerCase())) { - throw new Error( - `[ arseeding ] Arseeding Token ${tokenSymbol} not supported currently.` - ); - } - const tokenTags = await getTokenTagByEver(tokenSymbol); - const config: Config = { - signer, - path: '', - arseedUrl, - tag: tokenTags[0]!, - }; - - const order = await createAndSubmitItem(zipBuffer, options, config); - - const paySigner = await paymentSigner(); - // @ts-ignore - const everHash = await payOrder(paySigner, order); - - if (!everHash || !everHash.startsWith('0x')) { - throw new Error( - `[ arseeding ] Posting repo with ArSeeding failed. ${everHash}` - ); - } - - return order.itemId as string; - } catch (error: any) { - if ((error?.message || '').includes('[ arseeding ]')) { - throw error; - } - throw new Error( - `[ arseeding ] Posting repo with ArSeeding failed. ${error}` - ); - } -} diff --git a/src/lib/arweaveHelper.ts b/src/lib/arweaveHelper.ts index 0d9d273..639ed6c 100644 --- a/src/lib/arweaveHelper.ts +++ b/src/lib/arweaveHelper.ts @@ -1,7 +1,6 @@ import { getWallet, initArweave } from './common'; import { Tag } from 'arweave/node/lib/transaction'; -import { ArweaveSigner, bundleAndSignData, createData } from 'arbundles'; -import { arseedingUpload } from './arseeding'; +import { ArweaveSigner, createData } from 'arbundles'; const jwk = getWallet(); @@ -15,44 +14,9 @@ export function getActivePublicKey() { } export async function uploadRepo(zipBuffer: Buffer, tags: Tag[]) { - //Subsidized Upload - try { - const uploadedTx = await subsidizedUpload(zipBuffer, tags); - const serviceUsed = uploadedTx.bundled ? 'Turbo' : 'Arweave'; - - console.log( - `[ PL SUBSIDIZE ] Posted Tx to ${serviceUsed}: ${uploadedTx.data.repoTxId}` - ); - - return uploadedTx.data.repoTxId; - } catch (error) { - const userWantsToPay = process.env.HANDLE_SUBSIDY_ERROR === 'true'; - - if (!userWantsToPay) { - throw '[ PL SUBSIDIZE ] Failed to subsidize this transaction.'; - } - //continue - } - - const isArSeedingStrategy = process.env.STRATEGY === 'ARSEEDING'; - if (isArSeedingStrategy) { - const arweaveTxId = await arseedingUpload(zipBuffer, tags); - console.log('Posted Tx to Arseeding: ', arweaveTxId); - return arweaveTxId; - } else { - try { - // upload compressed repo using turbo - const turboTxId = await turboUpload(zipBuffer, tags); - console.log('Posted Tx to Turbo: ', turboTxId); - return turboTxId; - } catch (error) { - console.log('Error uploading using turbo, trying with Arweave...'); - // let Arweave throw if it encounters errors - const arweaveTxId = await arweaveUpload(zipBuffer, tags); - console.log('Posted Tx to Arweave: ', arweaveTxId); - return arweaveTxId; - } - } + const arweaveTxId = await arweaveUpload(zipBuffer, tags); + console.log('Posted Tx to Arweave: ', arweaveTxId); + return arweaveTxId; } async function arweaveUpload(zipBuffer: Buffer, tags: Tag[]) { @@ -116,46 +80,3 @@ export async function turboUpload(zipBuffer: Buffer, tags: Tag[]) { return dataItem.id; } - -export async function subsidizedUpload(zipBuffer: Buffer, tags: Tag[]) { - if (!jwk) throw '[ turbo ] No jwk wallet supplied'; - - const node = 'https://subsidize.saikranthi.dev/api/v1/postrepobuffer'; - const uint8ArrayZip = new Uint8Array(zipBuffer); - const signer = new ArweaveSigner(jwk); - const address = await getAddress(); - - const dataItem = createData(uint8ArrayZip, signer, { tags }); - await dataItem.sign(signer); - - const bundle = await bundleAndSignData([dataItem], signer); - const bundleBuffer = bundle.getRaw(); - - const formData = new FormData(); - formData.append('txBundle', new Blob([bundleBuffer])); - formData.append('platform', 'CLI'); - formData.append('owner', address); - - const res = await fetch(`${node}`, { - method: 'POST', - headers: { - Accept: 'application/json', - }, - body: formData, - }); - const upload = (await res.json()) as SubsidizedUploadJsonResponse; - - if (!upload || !upload.success) - throw new Error( - `[ turbo ] Posting repo with turbo failed. Error: ${res.status} - ${res.statusText}` - ); - - return upload; -} - -export type SubsidizedUploadJsonResponse = { - success: boolean; - bundled: boolean; - data: { repoTxId: string }; - error?: string; -};