Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(dev-cli): remove unsupported bundlers. Bump deps. Update defaults to align with 0.1 cli build #1004

Merged
merged 2 commits into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3,182 changes: 244 additions & 2,938 deletions dev-cli/container/src/node/package-lock.json

Large diffs are not rendered by default.

5 changes: 2 additions & 3 deletions dev-cli/container/src/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
"test": "node --test"
},
"dependencies": {
"@irys/sdk": "^0.1.6",
"@permaweb/aoconnect": "0.0.42",
"@permaweb/aoconnect": "0.0.59",
"@permaweb/wasm-metering": "^0.2.2",
"arweave": "^1.14.4",
"arweave": "^1.15.1",
"mime-types": "^2.1.35",
"url-join": "^5.0.0",
"warp-arbundles": "^1.0.4"
Expand Down
2 changes: 1 addition & 1 deletion dev-cli/container/src/node/src/bin/bundler-balance.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ Promise.resolve()
return process.exit(1)
}
case BundlerHostNotSupportedError.code: {
console.error('The bundler host is not supported. The only currently supported bundler is Irys')
console.error('The bundler host is not supported. The only currently supported bundler is Turbo')
return process.exit(1)
}
default: {
Expand Down
2 changes: 1 addition & 1 deletion dev-cli/container/src/node/src/bin/bundler-fund.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ Promise.resolve()
return process.exit(1)
}
case BundlerHostNotSupportedError.code: {
console.error('The bundler host is not supported. The only currently supported bundler is Irys')
console.error('The bundler host is not supported. The only currently supported bundler is Turbo')
return process.exit(1)
}
case InvalidFundAmountError.code: {
Expand Down
20 changes: 4 additions & 16 deletions dev-cli/container/src/node/src/clients.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { randomBytes } from 'node:crypto'
import urlJoin from 'url-join'
import mime from 'mime-types'
import Arweave from 'arweave'
import Irys from '@irys/sdk'
import WarpArBundles from 'warp-arbundles'

import { SUPPORTED_BUNDLERS } from './main.js'
Expand All @@ -18,13 +17,6 @@ const { createData, ArweaveSigner } = WarpArBundles
* TODO implement more clients for various apis
*/
export const UPLOADERS = {
[SUPPORTED_BUNDLERS.IRYS]: ({ path, wallet, to: irysNode, ...rest }) => {
const irys = new Irys({ url: irysNode, token: 'arweave', key: wallet })
/**
* Response implements { id }
*/
return irys.uploadFile(path, rest)
},
/**
* TODO: impl could be better
*/
Expand Down Expand Up @@ -67,10 +59,6 @@ export const UPLOADERS = {
}

export const BALANCERS = {
[SUPPORTED_BUNDLERS.IRYS]: ({ wallet, to: irysNode }) => {
const irys = new Irys({ url: irysNode, token: 'arweave', key: wallet })
return irys.getLoadedBalance().then(balance => ({ balance }))
},
[SUPPORTED_BUNDLERS.UP]: async ({ wallet, to }) => {
const arweave = Arweave.init()
const address = await arweave.wallets.jwkToAddress(wallet)
Expand All @@ -82,10 +70,10 @@ export const BALANCERS = {
}

export const FUNDERS = {
[SUPPORTED_BUNDLERS.IRYS]: ({ wallet, to: irysNode, amount }) => {
const irys = new Irys({ url: irysNode, token: 'arweave', key: wallet })
return irys.fund(amount).then(res => ({ id: res.id }))
},
/**
* TODO: needs to be implemented, now that uploads >100kb are not subsidized
* See https://github.com/permaweb/ao/issues/1000
*/
[SUPPORTED_BUNDLERS.UP]: () => {
return { id: 'up.arweave.net is 100% subsidized and requires no funding' }
}
Expand Down
2 changes: 1 addition & 1 deletion dev-cli/container/src/node/src/defaults.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export const DEFAULT_MODULE_FORMAT_TAG = { name: 'Module-Format', value: 'wasm32-unknown-emscripten' }
export const DEFAULT_MODULE_FORMAT_TAG = { name: 'Module-Format', value: 'wasm64-unknown-emscripten-draft_2024_02_15' }
export const DEFAULT_INPUT_ENCODING_TAG = { name: 'Input-Encoding', value: 'JSON-1' }
export const DEFAULT_OUTPUT_ENCODING_TAG = { name: 'Output-Encoding', value: 'JSON-1' }
export const DEFAULT_VARIANT_TAG = { name: 'Variant', value: 'ao.TN.1' }
Expand Down
2 changes: 0 additions & 2 deletions dev-cli/container/src/node/src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export class InvalidFundAmountError extends Error {
}

export const SUPPORTED_BUNDLERS = {
IRYS: 'IRYS',
UP: 'UP'
}

Expand All @@ -39,7 +38,6 @@ export const SUPPORTED_BUNDLERS = {
*/

export const determineBundlerHost = (host) => {
if (host.includes('irys.xyz')) return SUPPORTED_BUNDLERS.IRYS
if (host.includes('up.arweave.net')) return SUPPORTED_BUNDLERS.UP
}

Expand Down
8 changes: 4 additions & 4 deletions dev-cli/src/commands/bundler.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global Deno */

import { Command } from '../deps.js'
import { hostArgs, walletArgs } from '../utils.js'
import { bundlerArgs, walletArgs } from '../utils.js'
import { VERSION } from '../versions.js'

function amountArgs (amount) {
Expand All @@ -14,7 +14,7 @@ function amountArgs (amount) {
export async function balance ({ wallet, host }) {
const cmdArgs = [
...walletArgs(wallet),
...hostArgs(host)
...bundlerArgs(host)
]

const p = Deno.run({
Expand All @@ -32,10 +32,10 @@ export async function balance ({ wallet, host }) {
await p.status()
}

export async function fund ({ wallet, host }, amount) {
export async function fund ({ wallet, bundler }, amount) {
const cmdArgs = [
...walletArgs(wallet),
...hostArgs(host),
...bundlerArgs(bundler),
...amountArgs(amount)
]

Expand Down
6 changes: 3 additions & 3 deletions dev-cli/src/commands/publish.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* global Deno */

import { Command, basename, resolve } from '../deps.js'
import { hostArgs, tagsArg } from '../utils.js'
import { bundlerArgs, tagsArg } from '../utils.js'
import { VERSION } from '../versions.js'

function walletArgs (wallet) {
Expand Down Expand Up @@ -49,10 +49,10 @@ function contractSourceArgs (contractWasmPath) {
* - allow using environment variables to set things like path to wallet
* - require confirmation and bypass with --yes
*/
export async function publish ({ wallet, host, tag, value }, contractWasmPath) {
export async function publish ({ wallet, bundler, tag, value }, contractWasmPath) {
const cmdArgs = [
...walletArgs(wallet),
...hostArgs(host),
...bundlerArgs(bundler),
...contractSourceArgs(contractWasmPath),
...tagsArg({ tags: tag, values: value })
]
Expand Down
6 changes: 3 additions & 3 deletions dev-cli/src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,11 @@ export function tagsArg ({ tags, values }) {
return ['-e', `TAGS=${JSON.stringify([tags, values])}`]
}

export function hostArgs (host) {
return host
export function bundlerArgs (bundler) {
return bundler
? [
'-e',
`BUNDLER_HOST=${host}`
`BUNDLER_HOST=${bundler}`
]
: []
}