Skip to content

Commit

Permalink
feat: merge api (#503)
Browse files Browse the repository at this point in the history
  • Loading branch information
Cafe137 authored Jun 3, 2024
1 parent ca86f01 commit 0106e4d
Show file tree
Hide file tree
Showing 43 changed files with 212 additions and 398 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ on:
env:
BEE_API_URL: 'http://localhost:1633'
BEE_PEER_API_URL: 'http://localhost:11633'
BEE_DEBUG_API_URL: 'http://localhost:1635'
BEE_PEER_DEBUG_API_URL: 'http://localhost:11635'

jobs:
node-tests:
Expand Down
171 changes: 106 additions & 65 deletions README.md

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default async (): Promise<Config.InitialOptions> => {
* only consists a single queen node as well
*/
if (!process.env.SKIP_WORKER) {
process.env.WORKER_PSS_ADDRESS = await getPssAddress('http://localhost:11635')
process.env.WORKER_PSS_ADDRESS = await getPssAddress('http://localhost:11633')
}

if (!process.env.STAMP) {
Expand Down
84 changes: 31 additions & 53 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"typescript": "^4.8.4"
},
"dependencies": {
"@ethersphere/bee-js": "^6.9.0",
"@ethersphere/bee-js": "^7.0.0",
"@fairdatasociety/bmt-js": "^2.1.0",
"bignumber.js": "^9.1.0",
"chalk": "^2.4.2",
Expand Down
4 changes: 2 additions & 2 deletions src/command/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ export class Addresses extends RootCommand implements LeafCommand {
public async run(): Promise<void> {
await super.init()

this.nodeAddresses = await this.beeDebug.getNodeAddresses()
this.chequebookAddress = (await this.beeDebug.getChequebookAddress()).chequebookAddress
this.nodeAddresses = await this.bee.getNodeAddresses()
this.chequebookAddress = (await this.bee.getChequebookAddress()).chequebookAddress

const longest = 'PSS Public Key'.length
this.console.log(chalk.bold('Node Addresses'))
Expand Down
2 changes: 1 addition & 1 deletion src/command/cheque/cashout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export class Cashout extends ChequeCommand implements LeafCommand {
try {
this.console.log(chalk.green('Cashing out:'))
this.printCheque({ address, amount })
const transaction = await this.beeDebug.cashoutLastCheque(address, {
const transaction = await this.bee.cashoutLastCheque(address, {
gasLimit: this.gasLimit?.toString(),
gasPrice: this.gasPrice?.toString(),
})
Expand Down
4 changes: 2 additions & 2 deletions src/command/cheque/cheque-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class ChequeCommand extends RootCommand {
}

protected async getCashableCheques(): Promise<Cashable[]> {
const { lastcheques } = await this.beeDebug.getLastCheques()
const { lastcheques } = await this.bee.getLastCheques()

const results: Cashable[] = []
for (const cheque of lastcheques) {
Expand All @@ -41,7 +41,7 @@ export class ChequeCommand extends RootCommand {

protected async getUncashedAmount(address: string): Promise<bigint> {
try {
const lastCashout = await this.beeDebug.getLastCashoutAction(address)
const lastCashout = await this.bee.getLastCashoutAction(address)

return BigInt(lastCashout.uncashedAmount)
} catch (error) {
Expand Down
2 changes: 1 addition & 1 deletion src/command/cheque/deposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class Deposit extends ChequeCommand implements LeafCommand {
public async run(): Promise<void> {
await super.init()

const response = await this.beeDebug.depositTokens(this.amount.toString())
const response = await this.bee.depositTokens(this.amount.toString())
this.console.log(createKeyValue('Tx', response))
this.console.quiet(response)
}
Expand Down
2 changes: 1 addition & 1 deletion src/command/cheque/withdraw.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class Withdraw extends ChequeCommand implements LeafCommand {
public async run(): Promise<void> {
await super.init()

const response = await this.beeDebug.withdrawTokens(this.amount.toString())
const response = await this.bee.withdrawTokens(this.amount.toString())
this.console.log(createKeyValue('Tx', response))
this.console.quiet(response)
}
Expand Down
4 changes: 2 additions & 2 deletions src/command/feed/feed-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ export class FeedCommand extends RootCommand {

this.console.quiet(manifest)

if (!this.quiet && this.debugApiIsUsable()) {
printStamp(await this.beeDebug.getPostageBatch(this.stamp), this.console, { shortenBatchId: true })
if (!this.quiet) {
printStamp(await this.bee.getPostageBatch(this.stamp), this.console, { shortenBatchId: true })
}

return manifest
Expand Down
2 changes: 1 addition & 1 deletion src/command/feed/print.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class Print extends FeedCommand implements LeafCommand {

if (!this.stamp) {
spinner.stop()
this.stamp = await pickStamp(this.beeDebug, this.console)
this.stamp = await pickStamp(this.bee, this.console)
spinner.start()
}

Expand Down
2 changes: 1 addition & 1 deletion src/command/feed/update.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class Update extends FeedCommand implements LeafCommand {
await super.init()

if (!this.stamp) {
this.stamp = await pickStamp(this.beeDebug, this.console)
this.stamp = await pickStamp(this.bee, this.console)
}

await this.updateFeedAndPrint(this.reference)
Expand Down
2 changes: 1 addition & 1 deletion src/command/feed/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export class Upload extends FeedCommand implements LeafCommand {
await super.init()

if (!this.stamp) {
const stamp = await pickStamp(this.beeDebug, this.console)
const stamp = await pickStamp(this.bee, this.console)
this.stamp = stamp
this.fileUpload.stamp = stamp
}
Expand Down
2 changes: 1 addition & 1 deletion src/command/manifest/add.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class Add extends ManifestCommand implements LeafCommand {
await super.init()

if (!this.stamp) {
this.stamp = await pickStamp(this.beeDebug, this.console)
this.stamp = await pickStamp(this.bee, this.console)
}
const address = new BzzAddress(this.bzzUrl)
const { node } = await this.initializeNode(address.hash)
Expand Down
2 changes: 1 addition & 1 deletion src/command/manifest/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class Create extends ManifestCommand implements LeafCommand {
await super.init()

if (!this.stamp) {
this.stamp = await pickStamp(this.beeDebug, this.console)
this.stamp = await pickStamp(this.bee, this.console)
}
const node = new MantarayNode()
await this.saveAndPrintNode(node, this.stamp)
Expand Down
2 changes: 1 addition & 1 deletion src/command/manifest/merge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export class Merge extends ManifestCommand implements LeafCommand {
await super.init()

if (!this.stamp) {
this.stamp = await pickStamp(this.beeDebug, this.console)
this.stamp = await pickStamp(this.bee, this.console)
}
const destinationNode = (await this.initializeNode(this.destination)).node
const sourceNode = (await this.initializeNode(this.source)).node
Expand Down
2 changes: 1 addition & 1 deletion src/command/manifest/remove.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class Remove extends ManifestCommand implements LeafCommand {
await super.init()

if (!this.stamp) {
this.stamp = await pickStamp(this.beeDebug, this.console)
this.stamp = await pickStamp(this.bee, this.console)
}

const address = new BzzAddress(this.bzzUrl)
Expand Down
2 changes: 1 addition & 1 deletion src/command/manifest/sync.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class Sync extends ManifestCommand implements LeafCommand {
await super.init()

if (!this.stamp) {
this.stamp = await pickStamp(this.beeDebug, this.console)
this.stamp = await pickStamp(this.bee, this.console)
}
const address = new BzzAddress(this.bzzUrl)
const { node } = await this.initializeNode(address.hash)
Expand Down
2 changes: 1 addition & 1 deletion src/command/pss/send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export class Send extends PssCommand implements LeafCommand {
}

if (!this.stamp) {
this.stamp = await pickStamp(this.beeDebug, this.console)
this.stamp = await pickStamp(this.bee, this.console)
}

this.console.log('Sending PSS message on topic ' + this.topic)
Expand Down
10 changes: 2 additions & 8 deletions src/command/root-command/command-config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs'
import { homedir, platform } from 'os'
import { join } from 'path'
import { exit } from 'process'
import { beeApiUrl, beeDebugApiUrl } from '../../config'
import { beeApiUrl } from '../../config'
import { Identity } from '../../service/identity/types'
import { ConfigOption } from '../../utils/types/config-option'
import { CommandLog } from './command-log'
Expand All @@ -14,16 +14,11 @@ import { CommandLog } from './command-log'
* `optionKey` is the kebab-case variant of the argument used in the parser, a.k.a. the key,
* `propertyKey` is the camelCase variant used in TypeScript command classes, a.k.a. the property.
*/
export const CONFIG_OPTIONS: ConfigOption[] = [
{ optionKey: 'bee-api-url', propertyKey: 'beeApiUrl' },
{ optionKey: 'bee-debug-api-url', propertyKey: 'beeDebugApiUrl' },
]
export const CONFIG_OPTIONS: ConfigOption[] = [{ optionKey: 'bee-api-url', propertyKey: 'beeApiUrl' }]

export interface Config {
beeApiUrl: string

beeDebugApiUrl: string

identities: { [name: string]: Identity }
}

Expand All @@ -40,7 +35,6 @@ export class CommandConfig {
this.console = console
this.config = {
beeApiUrl: beeApiUrl.default || '',
beeDebugApiUrl: beeDebugApiUrl.default || '',
identities: {},
}
this.configFolderPath = this.getConfigFolderPath(appName, configFolder)
Expand Down
Loading

0 comments on commit 0106e4d

Please sign in to comment.