diff --git a/.npmignore b/.npmignore index b48e7b0..d950d82 100644 --- a/.npmignore +++ b/.npmignore @@ -2,4 +2,3 @@ node_modules .DS_Store index.ts tsconfig.json -package.json diff --git a/index.ts b/index.ts index b70d988..681bbd3 100755 --- a/index.ts +++ b/index.ts @@ -19,7 +19,7 @@ const NETWORK_RPC_URLS: { kate: string, goldberg: string, local: string } = { } program - .name('avail-cli') + .name('avail') .description('A simple CLI for Avail network utilities') .version(version) @@ -31,10 +31,8 @@ const transfer = async (to: string, value: number, options: { value: number }): Promise => { try { + if (!isValidAddress(to)) throw new Error(to + ' recipient address is invalid') const seed = options.seed - const recipient = to - - if (!isValidAddress(recipient)) throw new Error(recipient + ' recipient address is invalid') let rpcUrl: string if (typeof (NETWORK_RPC_URLS[options.network]) === 'undefined') { @@ -50,7 +48,8 @@ const transfer = async (to: string, value: number, options: { const keyring = getKeyringFromSeed(seed) const amount = formatNumberToBalance(value) - await api.tx.balances.transfer(recipient, amount).signAndSend(keyring, { nonce: -1 }) + await api.tx.balances.transfer(to, amount).signAndSend(keyring, { nonce: -1 }) + console.log(`✅ ${value} AVL successfully sent to ${to}`) process.exit(0) } catch (err) { console.error(err) @@ -81,6 +80,7 @@ const data = async (blob: string, options: { const keyring = getKeyringFromSeed(seed) await api.tx.dataAvailability.submitData(blob).signAndSend(keyring, { app_id: options.appId, nonce: -1 } as any) + console.log('✅ Data blob sent to Avail') process.exit(0) } catch (err) { console.error(err) diff --git a/package-lock.json b/package-lock.json index a873157..23b4550 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,21 +1,22 @@ { "name": "@availproject/cli", - "version": "0.1.7", + "version": "0.1.8", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@availproject/cli", - "version": "0.1.7", + "version": "0.1.8", "license": "Apache-2.0", "dependencies": { "avail-js-sdk": "^0.1.2", "commander": "^11.1.0" }, "bin": { - "avail": "build/index.js" + "avail": "index.js" }, "devDependencies": { + "@types/node": "^20.9.0", "ts-standard": "^12.0.2", "typescript": "^5.2.2" }, diff --git a/package.json b/package.json index a07f678..594a29f 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "name": "@availproject/cli", - "version": "0.1.7", + "version": "0.1.8", "description": "A simple CLI for Avail utilities", - "main": "build/index.js", + "main": "index.js", "bugs": "https://github.com/availproject/cli/issues", "homepage": "https://github.com/availproject/cli#readme", "repository": { "type": "git", - "url": "https://github.com/availproject/cli.git" + "url": "git+https://github.com/availproject/cli.git" }, "engines": { "node": ">=16" @@ -33,10 +33,11 @@ "commander": "^11.1.0" }, "devDependencies": { + "@types/node": "^20.9.0", "ts-standard": "^12.0.2", "typescript": "^5.2.2" }, "bin": { - "avail": "build/index.js" + "avail": "index.js" } } diff --git a/tsconfig.json b/tsconfig.json index c863563..aea3f62 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -55,7 +55,7 @@ // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */ - "outDir": "./build", /* Specify an output folder for all emitted files. */ + // "outDir": "./", /* Specify an output folder for all emitted files. */ // "removeComments": true, /* Disable emitting comments. */ // "noEmit": true, /* Disable emitting files from a compilation. */ // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */