From a6fc62019d2175ed27e9f82693b6d3c8e6f25b4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gergely=20B=C3=A9k=C3=A9si?= Date: Wed, 19 Aug 2026 11:29:39 +0200 Subject: [PATCH 1/7] chore: update to published core-sdk --- package-lock.json | 81 ++++++++++++++++++------------------ package.json | 2 +- src/command/manifest/sync.ts | 2 +- 3 files changed, 43 insertions(+), 42 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1b1f804c..7d58d1e5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "dependencies": { "@ethereumjs/wallet": "^2.0.4", "@ethersphere/bee-js": "^12.0.0", - "@upcoming/swarm-core": "^0.0.8", + "@ethersphere/core-sdk": "^0.1.1", "cafe-utility": "^33.3.1", "chalk": "^2.4.2", "cli-progress": "^3.11.2", @@ -1139,6 +1139,46 @@ "integrity": "sha512-4gxiVyngFbRa1G10+DIDUjk/Qu8OMxgK5bnNXMj4y80Tc+RLdZlk+pE7scgediQS2cxn8L+3XauS8tE62EfsTg==", "license": "MIT" }, + "node_modules/@ethersphere/core-sdk": { + "version": "0.1.1", + "resolved": "https://registry.npmjs.org/@ethersphere/core-sdk/-/core-sdk-0.1.1.tgz", + "integrity": "sha512-qnDZleD2YK3s5PN/tXc8LnEtzh6BdcPTBjv7baoKSPMQPLeZ9wN/9qH1Zr2FNwhMgAIhgsqV7fB65LlzQ/a7oQ==", + "license": "BSD-3-Clause", + "dependencies": { + "@noble/curves": "^1.9.7", + "@noble/hashes": "^1.8.0" + }, + "engines": { + "node": ">=22" + } + }, + "node_modules/@ethersphere/core-sdk/node_modules/@noble/curves": { + "version": "1.9.7", + "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.7.tgz", + "integrity": "sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw==", + "license": "MIT", + "dependencies": { + "@noble/hashes": "1.8.0" + }, + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, + "node_modules/@ethersphere/core-sdk/node_modules/@noble/hashes": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", + "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", + "license": "MIT", + "engines": { + "node": "^14.21.3 || >=16" + }, + "funding": { + "url": "https://paulmillr.com/funding/" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.11.7", "resolved": "https://registry.npmjs.org/@humanwhocodes/config-array/-/config-array-0.11.7.tgz", @@ -2535,45 +2575,6 @@ "node": "^12.22.0 || ^14.17.0 || >=16.0.0" } }, - "node_modules/@upcoming/swarm-core": { - "version": "0.0.8", - "resolved": "https://registry.npmjs.org/@upcoming/swarm-core/-/swarm-core-0.0.8.tgz", - "integrity": "sha512-gLiHUAUib7dDSM1KqHzKSTWIBx/8zXDOU1K6kXXft3R9tAGCahK/uLYnVbPOu28UKkY49Wfon9fQbnyf7dusxQ==", - "dependencies": { - "@noble/curves": "^1.9.7", - "@noble/hashes": "^1.8.0" - }, - "engines": { - "node": ">=22" - } - }, - "node_modules/@upcoming/swarm-core/node_modules/@noble/curves": { - "version": "1.9.7", - "resolved": "https://registry.npmjs.org/@noble/curves/-/curves-1.9.7.tgz", - "integrity": "sha512-gbKGcRUYIjA3/zCCNaWDciTMFI0dCkvou3TL8Zmy5Nc7sJ47a0jtOeZoTaMxkuqRo9cRhjOdZJXegxYE5FN/xw==", - "license": "MIT", - "dependencies": { - "@noble/hashes": "1.8.0" - }, - "engines": { - "node": "^14.21.3 || >=16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, - "node_modules/@upcoming/swarm-core/node_modules/@noble/hashes": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.8.0.tgz", - "integrity": "sha512-jCs9ldd7NwzpgXDIf6P3+NrHh9/sD6CQdxHyjQI+h/6rDNo88ypBxxz45UDuZHz9r3tNz7N/VInSVoVdtXEI4A==", - "license": "MIT", - "engines": { - "node": "^14.21.3 || >=16" - }, - "funding": { - "url": "https://paulmillr.com/funding/" - } - }, "node_modules/acorn": { "version": "8.8.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-8.8.1.tgz", diff --git a/package.json b/package.json index eed614b8..ef5b5248 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "dependencies": { "@ethereumjs/wallet": "^2.0.4", "@ethersphere/bee-js": "^12.0.0", - "@upcoming/swarm-core": "^0.0.8", + "@ethersphere/core-sdk": "^0.1.1", "cafe-utility": "^33.3.1", "chalk": "^2.4.2", "cli-progress": "^3.11.2", diff --git a/src/command/manifest/sync.ts b/src/command/manifest/sync.ts index ff55b8c2..419c556c 100644 --- a/src/command/manifest/sync.ts +++ b/src/command/manifest/sync.ts @@ -1,5 +1,5 @@ import { MantarayNode, RedundancyLevel } from '@ethersphere/bee-js' -import { ChunkSplitter, makeErasureBatch, makeIntermediateChunkHandler } from '@upcoming/swarm-core' +import { ChunkSplitter, makeErasureBatch, makeIntermediateChunkHandler } from '@ethersphere/core-sdk' import { Binary, Optional } from 'cafe-utility' import chalk from 'chalk' import { readFileSync } from 'fs' From 031a08419b821d940b59a1ffbb5dc361fd3d0f1a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gergely=20B=C3=A9k=C3=A9si?= Date: Wed, 19 Aug 2026 11:38:37 +0200 Subject: [PATCH 2/7] chore: update bee-js --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ef5b5248..daf2496d 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ }, "dependencies": { "@ethereumjs/wallet": "^2.0.4", - "@ethersphere/bee-js": "^12.0.0", + "@ethersphere/bee-js": "^13.0.0", "@ethersphere/core-sdk": "^0.1.1", "cafe-utility": "^33.3.1", "chalk": "^2.4.2", From 97992b5e2928547e7a40806046b32fa102fbcf78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gergely=20B=C3=A9k=C3=A9si?= Date: Mon, 24 Aug 2026 11:43:29 +0200 Subject: [PATCH 3/7] chore: run bee-js codemod --- jest.config.ts | 4 ++-- package-lock.json | 20 ++++++++++++-------- package.json | 2 +- src/command/access/grant.ts | 2 +- src/command/access/init.ts | 2 +- src/command/access/revoke.ts | 2 +- src/command/access/show.ts | 2 +- src/command/addresses.ts | 6 +++--- src/command/cheque/cashout.ts | 2 +- src/command/cheque/cheque-command.ts | 4 ++-- src/command/cheque/deposit.ts | 2 +- src/command/cheque/withdraw-all.ts | 4 ++-- src/command/cheque/withdraw.ts | 2 +- src/command/download.ts | 6 +++--- src/command/feed/feed-command.ts | 10 +++++----- src/command/feed/print.ts | 12 ++++++------ src/command/feed/upload.ts | 2 +- src/command/hash.ts | 4 ++-- src/command/manifest/add.ts | 2 +- src/command/manifest/download.ts | 7 ++++--- src/command/manifest/sync.ts | 13 +++++++++---- src/command/pinning/list.ts | 2 +- src/command/pinning/pin.ts | 2 +- src/command/pinning/pinning-command.ts | 2 +- src/command/pinning/reupload-all.ts | 4 ++-- src/command/pinning/unpin.ts | 2 +- src/command/pss/receive.ts | 2 +- src/command/pss/send.ts | 2 +- src/command/pss/subscribe.ts | 2 +- src/command/reupload.ts | 2 +- src/command/stake/deposit.ts | 6 +++--- src/command/stake/status.ts | 4 ++-- src/command/stake/withdraw.ts | 4 ++-- src/command/stamp/buy.ts | 6 +++--- src/command/stamp/create.ts | 6 +++--- src/command/stamp/dilute.ts | 4 ++-- src/command/stamp/extend.ts | 12 ++++++------ src/command/stamp/list.ts | 2 +- src/command/stamp/rename.ts | 2 +- src/command/stamp/show.ts | 2 +- src/command/stamp/stamp-command.ts | 2 +- src/command/stamp/topup.ts | 2 +- src/command/status.ts | 24 ++++++++++++------------ src/command/upload.ts | 22 +++++++++++----------- src/command/utility/rchash.ts | 4 ++-- src/command/utility/redeem.ts | 2 +- src/command/wallet/status.ts | 2 +- src/command/wallet/withdraw-bzz.ts | 2 +- src/command/wallet/withdraw-dai.ts | 2 +- src/service/stamp/index.ts | 2 +- src/utils/bzz-address.ts | 6 +++--- src/utils/chainsync.ts | 2 +- test/command/cheque.spec.ts | 12 ++++-------- test/command/rchash.spec.ts | 4 ++-- test/command/stamp.spec.ts | 12 ++++++------ test/command/upload.spec.ts | 6 +++--- test/utility/stamp.ts | 4 ++-- 57 files changed, 147 insertions(+), 141 deletions(-) diff --git a/jest.config.ts b/jest.config.ts index 2e0a207f..a714e585 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -34,7 +34,7 @@ export default async (): Promise => { const startedAt = Date.now() console.log('Waiting for Bee node to warm up on port', port) - await System.waitFor(async () => (await bee.getStatus()).isWarmingUp === false, { + await System.waitFor(async () => (await bee.status.get()).isWarmingUp === false, { attempts: 300, waitMillis: Dates.seconds(1), requiredConsecutivePasses: 3, @@ -48,7 +48,7 @@ export default async (): Promise => { const bee = new Bee(`http://localhost:${port}`) console.log('Asserting chequebook balance on port', port) - const chequebookBalance = await bee.getChequebookBalance() + const chequebookBalance = await bee.chequebook.getBalance() if (!chequebookBalance.totalBalance.eq(BZZ.fromDecimalString('10'))) { throw Error('Chequebook total balance is not 10 xBZZ: ' + chequebookBalance.totalBalance.toDecimalString()) diff --git a/package-lock.json b/package-lock.json index 7d58d1e5..0ef4fa02 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "BSD-3-Clause", "dependencies": { "@ethereumjs/wallet": "^2.0.4", - "@ethersphere/bee-js": "^12.0.0", + "@ethersphere/bee-js": "13.0.0-upcoming.gf9d33e6", "@ethersphere/core-sdk": "^0.1.1", "cafe-utility": "^33.3.1", "chalk": "^2.4.2", @@ -1116,18 +1116,22 @@ } }, "node_modules/@ethersphere/bee-js": { - "version": "12.3.1", - "resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-12.3.1.tgz", - "integrity": "sha512-NkTNCF0qejfpHtUM5vt6OeEbCpf72zlllgvdNMvcmWQO9r6gmhS9SuRAeUABQ+BaTJx5uff5RjQmAzNHUJMPtw==", + "version": "13.0.0-upcoming.gf9d33e6", + "resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-13.0.0-upcoming.gf9d33e6.tgz", + "integrity": "sha512-QVkRoG+Pil45Gk/CYH68u8hHd34eVVx4B8wNrxRJgVWiKDsPlY7aWs8Clu2VNCKKiaB1tnOVxg/av6eRuiTB7w==", "license": "BSD-3-Clause", "dependencies": { + "@ethersphere/core-sdk": "^0.1.1", "cafe-utility": "^34.0.0", "debug": "^4.4.3", - "isomorphic-ws": "^4.0.1", + "isomorphic-ws": "^5.0.0", "semver": "^7.3.5", "ws": "^8.21.0", "zod": "^4.4.3" }, + "bin": { + "bee-js-codemod": "dist/codemod/index.js" + }, "engines": { "bee": "2.8.1-7cf53193", "beeApiVersion": "8.1.0" @@ -5198,9 +5202,9 @@ "dev": true }, "node_modules/isomorphic-ws": { - "version": "4.0.1", - "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz", - "integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==", + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-5.0.0.tgz", + "integrity": "sha512-muId7Zzn9ywDsyXgTIafTry2sV3nySZeUDe6YedVd1Hvuuep5AsIlqK+XefWpYTyJG5e503F2xIuT2lcU6rCSw==", "license": "MIT", "peerDependencies": { "ws": "*" diff --git a/package.json b/package.json index daf2496d..755c6b34 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ }, "dependencies": { "@ethereumjs/wallet": "^2.0.4", - "@ethersphere/bee-js": "^13.0.0", + "@ethersphere/bee-js": "13.0.0-upcoming.gf9d33e6", "@ethersphere/core-sdk": "^0.1.1", "cafe-utility": "^33.3.1", "chalk": "^2.4.2", diff --git a/src/command/access/grant.ts b/src/command/access/grant.ts index 81b94e3c..060df38a 100644 --- a/src/command/access/grant.ts +++ b/src/command/access/grant.ts @@ -37,7 +37,7 @@ export class Grant extends AccessCommand implements LeafCommand { const stampId = lastHistoryEvent.stampId const granteeListRef = lastHistoryEvent.granteeListRef const historyAddress = lastHistoryEvent.historyAddress - const response = await this.bee.patchGrantees(stampId, granteeListRef, historyAddress, { add: this.grantees }) + const response = await this.bee.grantee.patch(stampId, granteeListRef, historyAddress, { add: this.grantees }) if (response.status === 200) { this.console.log(successText(`Access granted to ${this.grantees.join(', ')}`)) diff --git a/src/command/access/init.ts b/src/command/access/init.ts index c339c160..52e83f2b 100644 --- a/src/command/access/init.ts +++ b/src/command/access/init.ts @@ -36,7 +36,7 @@ export class Init extends AccessCommand implements LeafCommand { exit(1) } - const response = await this.bee.createGrantees(this.stamp, this.grantees) + const response = await this.bee.grantee.create(this.stamp, this.grantees) this.console.log(`Grantee list '${this.listName}' initialized successfully!`) accessHistory.addEvent(this.listName, { diff --git a/src/command/access/revoke.ts b/src/command/access/revoke.ts index 53cac3a8..104da9ac 100644 --- a/src/command/access/revoke.ts +++ b/src/command/access/revoke.ts @@ -37,7 +37,7 @@ export class Revoke extends AccessCommand implements LeafCommand { const stampId = lastHistoryEvent.stampId const granteeListRef = lastHistoryEvent.granteeListRef const historyAddress = lastHistoryEvent.historyAddress - const response = await this.bee.patchGrantees(stampId, granteeListRef, historyAddress, { revoke: this.grantees }) + const response = await this.bee.grantee.patch(stampId, granteeListRef, historyAddress, { revoke: this.grantees }) if (response.status === 200) { this.console.log(successText(`Access revoked from ${this.grantees.join(', ')}`)) diff --git a/src/command/access/show.ts b/src/command/access/show.ts index 1f5e38a7..5d0d5b55 100644 --- a/src/command/access/show.ts +++ b/src/command/access/show.ts @@ -25,7 +25,7 @@ export class Show extends AccessCommand implements LeafCommand { exit(1) } - const response = await this.bee.getGrantees(lastHistoryEvent.granteeListRef) + const response = await this.bee.grantee.get(lastHistoryEvent.granteeListRef) if (response.grantees.length === 0) { this.console.log(`Grantee list '${this.listName}' has no grantees.`) diff --git a/src/command/addresses.ts b/src/command/addresses.ts index 4556eb17..e5e7f1e3 100644 --- a/src/command/addresses.ts +++ b/src/command/addresses.ts @@ -15,9 +15,9 @@ export class Addresses extends RootCommand implements LeafCommand { public async run(): Promise { super.init() - this.nodeAddresses = await this.bee.getNodeAddresses() - const wrappedChequebookAddress = await this.bee - .getChequebookAddress() + this.nodeAddresses = await this.bee.connectivity.getNodeAddresses() + const wrappedChequebookAddress = await this.bee.chequebook + .getAddress() .then(x => { return Optional.of(x) }) diff --git a/src/command/cheque/cashout.ts b/src/command/cheque/cashout.ts index 12f704c9..087ae5bf 100644 --- a/src/command/cheque/cashout.ts +++ b/src/command/cheque/cashout.ts @@ -74,7 +74,7 @@ export class Cashout extends ChequeCommand implements LeafCommand { try { this.console.log(chalk.green('Cashing out:')) this.printCheque({ address, amount }) - const transaction = await this.bee.cashoutLastCheque(address, { + const transaction = await this.bee.cheque.cashoutLast(address, { gasLimit: this.gasLimit, gasPrice: this.gasPrice, }) diff --git a/src/command/cheque/cheque-command.ts b/src/command/cheque/cheque-command.ts index 33856028..fe6c0154 100644 --- a/src/command/cheque/cheque-command.ts +++ b/src/command/cheque/cheque-command.ts @@ -16,7 +16,7 @@ export class ChequeCommand extends RootCommand { } protected async getCashableCheques(): Promise { - const { lastcheques } = await this.bee.getLastCheques() + const { lastcheques } = await this.bee.cheque.getAllLatest() const results: Cashable[] = [] for (const cheque of lastcheques) { @@ -42,7 +42,7 @@ export class ChequeCommand extends RootCommand { protected async getUncashedAmount(address: string): Promise { try { - const lastCashout = await this.bee.getLastCashoutAction(address) + const lastCashout = await this.bee.cheque.getLastCashoutAction(address) return lastCashout.uncashedAmount } catch (error) { diff --git a/src/command/cheque/deposit.ts b/src/command/cheque/deposit.ts index 9fae968f..c22b579c 100644 --- a/src/command/cheque/deposit.ts +++ b/src/command/cheque/deposit.ts @@ -34,7 +34,7 @@ export class Deposit extends ChequeCommand implements LeafCommand { const amountBzz = this.unit === 'bzz' ? BZZ.fromDecimalString(this.amount) : BZZ.fromPLUR(this.amount) - const response = await this.bee.depositBZZToChequebook(amountBzz) + const response = await this.bee.chequebook.deposit(amountBzz) this.console.log(createKeyValue('Tx', response.toHex())) this.console.quiet(response.toHex()) } diff --git a/src/command/cheque/withdraw-all.ts b/src/command/cheque/withdraw-all.ts index 9d68947d..daa99cfa 100644 --- a/src/command/cheque/withdraw-all.ts +++ b/src/command/cheque/withdraw-all.ts @@ -12,7 +12,7 @@ export class WithdrawAll extends ChequeCommand implements LeafCommand { public async run(): Promise { super.init() - const balance = await this.bee.getChequebookBalance() + const balance = await this.bee.chequebook.getBalance() if (balance.availableBalance.toPLURBigInt() === BigInt(0)) { this.console.error('No tokens to withdraw.') @@ -20,7 +20,7 @@ export class WithdrawAll extends ChequeCommand implements LeafCommand { return } this.console.log(`Withdrawing ${balance.availableBalance.toDecimalString()} xBZZ from the chequebook`) - const response = await this.bee.withdrawTokens(balance.availableBalance.toPLURString()) + const response = await this.bee.chequebook.withdraw(balance.availableBalance.toPLURString()) this.console.log(createKeyValue('Tx', response.toHex())) this.console.quiet(response.toHex()) } diff --git a/src/command/cheque/withdraw.ts b/src/command/cheque/withdraw.ts index f404efbd..418fa5aa 100644 --- a/src/command/cheque/withdraw.ts +++ b/src/command/cheque/withdraw.ts @@ -34,7 +34,7 @@ export class Withdraw extends ChequeCommand implements LeafCommand { const amountBzz = this.unit === 'bzz' ? BZZ.fromDecimalString(this.amount) : BZZ.fromPLUR(this.amount) - const response = await this.bee.withdrawBZZFromChequebook(amountBzz) + const response = await this.bee.chequebook.withdraw(amountBzz) this.console.log(createKeyValue('Tx', response.toHex())) this.console.quiet(response.toHex()) } diff --git a/src/command/download.ts b/src/command/download.ts index 6c2d115e..932dc553 100644 --- a/src/command/download.ts +++ b/src/command/download.ts @@ -38,18 +38,18 @@ export class Download extends RootCommand implements LeafCommand { this.console.error('Invalid access format. Expected format: publisher:historyAddress') process.exit(1) } - const responseAct = await this.bee.downloadFile(this.address.hash, this.manifestDownload.destination, { + const responseAct = await this.bee.file.download(this.address.hash, this.manifestDownload.destination, { actPublisher: publisher, actHistoryAddress: historyAddress, }) response = responseAct.data } else { if (this.address.hash.length === 128) { - const fileData = await this.bee.downloadFile(this.address.hash, undefined) + const fileData = await this.bee.file.download(this.address.hash, undefined) nameOverride = fileData.name response = fileData.data } else { - response = await this.bee.downloadData(this.address.hash, undefined) + response = await this.bee.data.download(this.address.hash, undefined) } } diff --git a/src/command/feed/feed-command.ts b/src/command/feed/feed-command.ts index 34274a42..99676e69 100644 --- a/src/command/feed/feed-command.ts +++ b/src/command/feed/feed-command.ts @@ -63,8 +63,8 @@ export class FeedCommand extends RootCommand { this.console.quiet(manifest.toHex()) - if (!this.quiet && !(await this.bee.isGateway())) { - printStamp(await this.bee.getPostageBatch(stamp), this.console, { shortenBatchId: true }) + if (!this.quiet && !(await this.bee.connectivity.isGateway())) { + printStamp(await this.bee.stamp.get(stamp), this.console, { shortenBatchId: true }) } return manifest @@ -110,9 +110,9 @@ export class FeedCommand extends RootCommand { } try { - const writer = this.bee.makeFeedWriter(topic, wallet.getPrivateKey()) - const feedManifestResult = await this.bee.createFeedManifest(stamp, topic, wallet.getAddressString()) - const data = await this.bee.downloadData(chunkReference) + const writer = this.bee.feed.makeWriter(topic, wallet.getPrivateKey()) + const feedManifestResult = await this.bee.feed.createManifest(stamp, topic, wallet.getAddressString()) + const data = await this.bee.data.download(chunkReference) const { reference } = await writer.uploadPayload(stamp, data.toUint8Array()) return { reference, manifest: feedManifestResult } diff --git a/src/command/feed/print.ts b/src/command/feed/print.ts index 96c406cd..b7a402f3 100644 --- a/src/command/feed/print.ts +++ b/src/command/feed/print.ts @@ -1,5 +1,5 @@ import { Wallet } from '@ethereumjs/wallet' -import { MerkleTree, Topic } from '@ethersphere/bee-js' +import { ChunkSplitter, Topic } from '@ethersphere/bee-js' import { Binary } from 'cafe-utility' import { LeafCommand, Option } from 'furious-commander' import { exit } from 'process' @@ -63,7 +63,7 @@ export class Print extends FeedCommand implements LeafCommand { new Uint8Array(12).fill(0x0a), ) - const root = (await MerkleTree.root(body)).hash() + const root = (await ChunkSplitter.root(body)).hash().toUint8Array() const manifest = Binary.uint8ArrayToHex(root) this.console.quiet(manifest) @@ -78,7 +78,7 @@ export class Print extends FeedCommand implements LeafCommand { try { const addressString = this.address || (await this.getAddressString()) - const reader = this.bee.makeFeedReader(topic, addressString) + const reader = this.bee.feed.makeReader(topic, addressString) const { payload, feedIndex, feedIndexNext } = await reader.download() // TODO: verify this const reference = payload @@ -96,10 +96,10 @@ export class Print extends FeedCommand implements LeafCommand { if (this.list) { for (let i = 0; i < numberOfUpdates; i++) { const owner = Binary.hexToUint8Array(this.address) - const reader = this.bee.makeFeedReader(topic, owner) + const reader = this.bee.feed.makeReader(topic, owner) const socPayload = await reader.downloadPayload({ index: i }) - const merkleTree = await MerkleTree.root(socPayload.payload.toUint8Array()) - const cacAddress = Binary.uint8ArrayToHex(merkleTree.hash()) + const merkleTree = await ChunkSplitter.root(socPayload.payload.toUint8Array()) + const cacAddress = Binary.uint8ArrayToHex(merkleTree.hash().toUint8Array()) this.console.log('') this.console.log(createKeyValue(`Update ${i}`, cacAddress)) this.console.log(`${this.bee.url}/bzz/${cacAddress}/`) diff --git a/src/command/feed/upload.ts b/src/command/feed/upload.ts index 768a2d8d..c219f6d0 100644 --- a/src/command/feed/upload.ts +++ b/src/command/feed/upload.ts @@ -23,7 +23,7 @@ export class Upload extends FeedCommand implements LeafCommand { super.init() if (!this.stamp) { - if (await this.bee.isGateway()) { + if (await this.bee.connectivity.isGateway()) { this.stamp = '0'.repeat(64) this.fileUpload.stamp = '0'.repeat(64) } else { diff --git a/src/command/hash.ts b/src/command/hash.ts index f7bb039d..9e1421f5 100644 --- a/src/command/hash.ts +++ b/src/command/hash.ts @@ -1,4 +1,4 @@ -import { MerkleTree, Reference } from '@ethersphere/bee-js' +import { ChunkSplitter, Reference } from '@ethersphere/bee-js' import { readFileSync } from 'fs' import { Argument, LeafCommand } from 'furious-commander' import { RootCommand } from './root-command' @@ -17,6 +17,6 @@ export class Hash extends RootCommand implements LeafCommand { public async run(): Promise { super.init() - this.console.all(new Reference((await MerkleTree.root(readFileSync(this.path))).hash()).toHex()) + this.console.all(new Reference((await ChunkSplitter.root(readFileSync(this.path))).hash().toUint8Array()).toHex()) } } diff --git a/src/command/manifest/add.ts b/src/command/manifest/add.ts index 52513bab..c74e50c8 100644 --- a/src/command/manifest/add.ts +++ b/src/command/manifest/add.ts @@ -40,7 +40,7 @@ export class Add extends RootCommand implements LeafCommand { const files = await getFiles(this.path) for (const file of files) { const path = stat.isDirectory() ? join(this.path, file) : this.path - const { reference } = await this.bee.uploadData(this.stamp, readFileSync(path)) + const { reference } = await this.bee.data.upload(this.stamp, readFileSync(path)) const remotePath = this.getForkPath(address.path, files, file) node.addFork(remotePath, reference) diff --git a/src/command/manifest/download.ts b/src/command/manifest/download.ts index c7b76fde..1458cba7 100644 --- a/src/command/manifest/download.ts +++ b/src/command/manifest/download.ts @@ -1,4 +1,5 @@ import { MantarayNode } from '@ethersphere/bee-js' +import { MantarayNode as CoreMantarayNode } from '@ethersphere/core-sdk' import chalk from 'chalk' import { mkdir, writeFile } from 'fs/promises' import { Argument, LeafCommand, Option } from 'furious-commander' @@ -53,7 +54,7 @@ export class Download extends RootCommand implements LeafCommand { } } - private async downloadNode(node: MantarayNode, address: BzzAddress): Promise { + private async downloadNode(node: CoreMantarayNode, address: BzzAddress): Promise { if (!this.stdout && !this.quiet) { if (this.curl) { this.console.log(chalk.dim(node.fullPathString)) @@ -64,7 +65,7 @@ export class Download extends RootCommand implements LeafCommand { const parsedForkPath = parse(node.fullPathString) if (this.stdout) { - const data = await this.bee.downloadData(node.targetAddress) + const data = await this.bee.data.download(node.targetAddress) process.stdout.write(data.toUtf8()) return @@ -77,7 +78,7 @@ export class Download extends RootCommand implements LeafCommand { await mkdir(destinationFolder, { recursive: true }) } - const readStream = await this.bee.downloadReadableData(node.targetAddress) + const readStream = await this.bee.data.downloadReadable(node.targetAddress) await writeFile(join(destination, node.fullPathString), readStream) if (!this.stdout && !this.quiet && !this.curl) { diff --git a/src/command/manifest/sync.ts b/src/command/manifest/sync.ts index 419c556c..efa20bd3 100644 --- a/src/command/manifest/sync.ts +++ b/src/command/manifest/sync.ts @@ -1,5 +1,10 @@ import { MantarayNode, RedundancyLevel } from '@ethersphere/bee-js' -import { ChunkSplitter, makeErasureBatch, makeIntermediateChunkHandler } from '@ethersphere/core-sdk' +import { + ChunkSplitter, + makeErasureBatch, + makeIntermediateChunkHandler, + MantarayNode as CoreMantarayNode, +} from '@ethersphere/core-sdk' import { Binary, Optional } from 'cafe-utility' import chalk from 'chalk' import { readFileSync } from 'fs' @@ -72,7 +77,7 @@ export class Sync extends RootCommand implements LeafCommand { const node = await MantarayNode.unmarshal(this.bee, address.hash) await node.loadRecursively(this.bee) - const map = new Map() + const map = new Map() const nodes = node.collect() for (const node of nodes) { map.set(node.fullPathString, node) @@ -90,12 +95,12 @@ export class Sync extends RootCommand implements LeafCommand { if (Binary.equals(expected, existing.targetAddress)) { this.console.log(chalk.gray(file) + ' ' + chalk.blue('UNCHANGED')) } else { - const { reference } = await this.bee.uploadData(this.stamp, localData, undefined, uploadOptions) + const { reference } = await this.bee.data.upload(this.stamp, localData, undefined, uploadOptions) node.addFork(file, reference) this.console.log(chalk.gray(file) + ' ' + chalk.yellow('CHANGED')) } } else { - const { reference } = await this.bee.uploadData( + const { reference } = await this.bee.data.upload( this.stamp, readFileSync(join(this.folder, file)), undefined, diff --git a/src/command/pinning/list.ts b/src/command/pinning/list.ts index 678f989f..392e5179 100644 --- a/src/command/pinning/list.ts +++ b/src/command/pinning/list.ts @@ -13,7 +13,7 @@ export class List extends PinningCommand implements LeafCommand { await super.init() this.console.info('Getting pinned root hashes...') - const pins = await this.bee.getAllPins() + const pins = await this.bee.pin.getAll() this.console.log(chalk.bold(`Found ${pins.length} pinned root hashes`)) this.console.log('') diff --git a/src/command/pinning/pin.ts b/src/command/pinning/pin.ts index 69761393..10884515 100644 --- a/src/command/pinning/pin.ts +++ b/src/command/pinning/pin.ts @@ -15,7 +15,7 @@ export class Pin extends PinningCommand implements LeafCommand { await super.init() try { - await this.bee.pin(this.address) + await this.bee.pin.add(this.address) this.console.log('Pinned successfully') } catch (error) { this.console.printBeeError(error, { notFoundMessage: `No root chunk found with address ${this.address}` }) diff --git a/src/command/pinning/pinning-command.ts b/src/command/pinning/pinning-command.ts index 0dffbd2e..ad117dcf 100644 --- a/src/command/pinning/pinning-command.ts +++ b/src/command/pinning/pinning-command.ts @@ -5,7 +5,7 @@ export class PinningCommand extends RootCommand { protected override async init(): Promise { super.init() - if (await this.bee.isGateway()) { + if (await this.bee.connectivity.isGateway()) { this.console.error('Pinning is currently not supported on the gateway node.') this.console.error('You can use the pinning API with your local Bee node.') diff --git a/src/command/pinning/reupload-all.ts b/src/command/pinning/reupload-all.ts index a2782909..e0ab5f0e 100644 --- a/src/command/pinning/reupload-all.ts +++ b/src/command/pinning/reupload-all.ts @@ -13,7 +13,7 @@ export class ReuploadAll extends PinningCommand implements LeafCommand { public async run(): Promise { await super.init() - const chunks = await this.bee.getAllPins() + const chunks = await this.bee.pin.getAll() const total = chunks.length let successful = 0 @@ -36,7 +36,7 @@ export class ReuploadAll extends PinningCommand implements LeafCommand { private async reuploadOne(chunk: string): Promise { this.console.log('Reuploading ' + chunk + '...') - await this.bee.reuploadPinnedData(this.stamp, chunk) + await this.bee.pin.reuploadData(this.stamp, chunk) this.console.log('Reuploaded successfully.') } } diff --git a/src/command/pinning/unpin.ts b/src/command/pinning/unpin.ts index 3bb8363e..0a84b288 100644 --- a/src/command/pinning/unpin.ts +++ b/src/command/pinning/unpin.ts @@ -15,7 +15,7 @@ export class Unpin extends PinningCommand implements LeafCommand { await super.init() try { - await this.bee.unpin(this.address) + await this.bee.pin.remove(this.address) this.console.log('Unpinned successfully') } catch (error) { this.console.printBeeError(error, { notFoundMessage: `No root chunk found with address ${this.address}` }) diff --git a/src/command/pss/receive.ts b/src/command/pss/receive.ts index 80159d1b..d80235f9 100644 --- a/src/command/pss/receive.ts +++ b/src/command/pss/receive.ts @@ -36,7 +36,7 @@ export class Receive extends PssCommand implements LeafCommand { const stream = this.outFile ? createWriteStream(this.outFile, { encoding: 'binary' }) : null try { - const data = await this.bee.pssReceive(new Topic(this.topic), this.timeout) + const data = await this.bee.messaging.pssReceive(new Topic(this.topic), this.timeout) this.receivedMessage = data.toUtf8() diff --git a/src/command/pss/send.ts b/src/command/pss/send.ts index 80f1107c..ecfce3ae 100644 --- a/src/command/pss/send.ts +++ b/src/command/pss/send.ts @@ -75,7 +75,7 @@ export class Send extends PssCommand implements LeafCommand { this.console.log('Sending PSS message on topic ' + this.topic) - await this.bee.pssSend(this.stamp, new Topic(this.topic), this.target, this.sendable, this.recipient) + await this.bee.messaging.pssSend(this.stamp, new Topic(this.topic), this.target, this.sendable, this.recipient) this.console.log('Message sent successfully.') } } diff --git a/src/command/pss/subscribe.ts b/src/command/pss/subscribe.ts index f00206d9..57cacafa 100644 --- a/src/command/pss/subscribe.ts +++ b/src/command/pss/subscribe.ts @@ -22,7 +22,7 @@ export class Subscribe extends PssCommand implements LeafCommand { const stream = this.outFile ? createWriteStream(this.outFile) : null - this.bee.pssSubscribe(new Topic(this.topic), { + this.bee.messaging.pssSubscribe(new Topic(this.topic), { onMessage: data => { if (stream) { stream.write(data) diff --git a/src/command/reupload.ts b/src/command/reupload.ts index 648131b7..11cf2171 100644 --- a/src/command/reupload.ts +++ b/src/command/reupload.ts @@ -32,7 +32,7 @@ export class Reupload extends RootCommand implements LeafCommand { this.console.log('Reuploading ' + this.address + '...') try { - await this.bee.reuploadPinnedData(this.stamp, this.address) + await this.bee.pin.reuploadData(this.stamp, this.address) this.console.log('Reuploaded successfully.') if (this.commandConfig.config.historyEnabled) { diff --git a/src/command/stake/deposit.ts b/src/command/stake/deposit.ts index 8c31fc17..542f6b9d 100644 --- a/src/command/stake/deposit.ts +++ b/src/command/stake/deposit.ts @@ -44,7 +44,7 @@ export class Deposit extends RootCommand implements LeafCommand { } private async deposit(amount: BZZ): Promise { - const currentStake = await this.bee.getStake() + const currentStake = await this.bee.stake.get() if (currentStake.lt(MIN_DEPOSIT) && amount.lt(MIN_DEPOSIT)) { if (this.quiet) { @@ -69,7 +69,7 @@ export class Deposit extends RootCommand implements LeafCommand { } if (!this.quiet && !this.yes) { - const reserveState = await this.bee.getReserveState() + const reserveState = await this.bee.status.getReserveState() const reserveCapacityDoubling = reserveState.reserveCapacityDoubling if (amount.eq(BZZ.fromDecimalString('10')) && reserveCapacityDoubling > 0) { @@ -99,7 +99,7 @@ export class Deposit extends RootCommand implements LeafCommand { } try { - await this.bee.depositStake(amount) + await this.bee.stake.deposit(amount) spinner.stop() } catch (e) { spinner.stop() diff --git a/src/command/stake/status.ts b/src/command/stake/status.ts index 47d853c0..d6d51748 100644 --- a/src/command/stake/status.ts +++ b/src/command/stake/status.ts @@ -10,8 +10,8 @@ export class Status extends RootCommand implements LeafCommand { public async run(): Promise { super.init() - const stake = await this.bee.getStake() - const surplusStake = await this.bee.getWithdrawableStake() + const stake = await this.bee.stake.get() + const surplusStake = await this.bee.stake.getWithdrawable() this.console.log(createKeyValue('Staked xBZZ', stake.toDecimalString())) this.console.log(createKeyValue('Withdrawable staked xBZZ', surplusStake.toDecimalString())) diff --git a/src/command/stake/withdraw.ts b/src/command/stake/withdraw.ts index 5aa5f2fc..5171ea65 100644 --- a/src/command/stake/withdraw.ts +++ b/src/command/stake/withdraw.ts @@ -12,7 +12,7 @@ export class Withdraw extends RootCommand implements LeafCommand { public async run(): Promise { super.init() - const surplusStake = await this.bee.getWithdrawableStake() + const surplusStake = await this.bee.stake.getWithdrawable() if (surplusStake.eq(BZZ.fromDecimalString('0'))) { this.console.log('There is no surplus stake to withdraw.') @@ -36,7 +36,7 @@ export class Withdraw extends RootCommand implements LeafCommand { spinner.start() } try { - await this.bee.withdrawSurplusStake() + await this.bee.stake.withdrawSurplus() spinner.stop() this.console.log( diff --git a/src/command/stamp/buy.ts b/src/command/stamp/buy.ts index 321ce57b..7a67189b 100644 --- a/src/command/stamp/buy.ts +++ b/src/command/stamp/buy.ts @@ -69,7 +69,7 @@ export class Buy extends StampCommand implements LeafCommand { return } - const chainState = await this.bee.getChainState() + const chainState = await this.bee.status.getChainState() const minimumAmount = BigInt(chainState.currentPrice) * 17280n if (minimumAmount >= this.amount) { @@ -79,7 +79,7 @@ export class Buy extends StampCommand implements LeafCommand { } const estimatedCost = Utils.getStampCost(this.depth, BigInt(this.amount)) - const { bzzBalance } = await this.bee.getWalletBalance() + const { bzzBalance } = await this.bee.wallet.getBalance() if (estimatedCost.gt(bzzBalance)) { this.console.error('You do not have enough BZZ to create this postage stamp.') @@ -122,7 +122,7 @@ export class Buy extends StampCommand implements LeafCommand { } try { - const batchId = await this.bee.createPostageBatch(this.amount.toString(), this.depth, { + const batchId = await this.bee.stamp.create(this.amount.toString(), this.depth, { label: this.label, gasPrice: this.gasPrice?.toString(), immutableFlag: this.immutable, diff --git a/src/command/stamp/create.ts b/src/command/stamp/create.ts index 7a826ad3..136cd053 100644 --- a/src/command/stamp/create.ts +++ b/src/command/stamp/create.ts @@ -84,8 +84,8 @@ export class Create extends StampCommand implements LeafCommand { this.console.log(createKeyValue('Capacity', size.toFormattedString())) this.console.log(createKeyValue('TTL', Dates.secondsToHumanTime(duration.toSeconds()))) - const estimatedCost = await this.bee.getStorageCost(size, duration) - const { bzzBalance } = await this.bee.getWalletBalance() + const estimatedCost = await this.bee.storage.getCost(size, duration) + const { bzzBalance } = await this.bee.wallet.getBalance() if (estimatedCost.gt(bzzBalance)) { this.console.error('You do not have enough BZZ to create this postage stamp.') @@ -119,7 +119,7 @@ export class Create extends StampCommand implements LeafCommand { } try { - const batchId = await this.bee.buyStorage(size, duration, { + const batchId = await this.bee.storage.buy(size, duration, { label: this.label, immutableFlag: this.immutable, waitForUsable: true, diff --git a/src/command/stamp/dilute.ts b/src/command/stamp/dilute.ts index dc5cfbb0..3cbff3c7 100644 --- a/src/command/stamp/dilute.ts +++ b/src/command/stamp/dilute.ts @@ -31,7 +31,7 @@ export class Dilute extends StampCommand implements LeafCommand { this.stamp = await pickStamp(this.bee, this.console) } - const details = await this.bee.getPostageBatch(this.stamp) + const details = await this.bee.stamp.get(this.stamp) if (this.depth <= details.depth) { throw new CommandLineError(`This postage stamp already has depth ${details.depth}. The new value must be higher.`) @@ -44,7 +44,7 @@ export class Dilute extends StampCommand implements LeafCommand { } try { - await this.bee.diluteBatch(this.stamp, this.depth) + await this.bee.stamp.dilute(this.stamp, this.depth) } finally { spinner.stop() } diff --git a/src/command/stamp/extend.ts b/src/command/stamp/extend.ts index ef23a6d1..0de92f23 100644 --- a/src/command/stamp/extend.ts +++ b/src/command/stamp/extend.ts @@ -15,7 +15,7 @@ export class Extend extends StampCommand implements LeafCommand { public async run(): Promise { super.init() - const batches = await this.bee.getAllPostageBatch() + const batches = await this.bee.stamp.getAll() const batchId = await pickStamp(this.bee, this.console) const batch = batches.find(b => b.batchID.toHex() === batchId) @@ -23,7 +23,7 @@ export class Extend extends StampCommand implements LeafCommand { throw Error(`Batch with ID ${batchId} not found`) } - const { bzzBalance } = await this.bee.getWalletBalance() + const { bzzBalance } = await this.bee.wallet.getBalance() const mode = await this.console.promptList(['Size', 'Duration'], 'What do you want to extend?') this.console.log(`Current balance is ${bzzBalance.toDecimalString()} BZZ`) @@ -32,7 +32,7 @@ export class Extend extends StampCommand implements LeafCommand { this.console.log(`Current size is ${batch.size.toFormattedString()}`) const wantedSize = await this.console.askForValue('New size') const size = Size.fromBytes(Numbers.makeStorage(wantedSize)) - const cost = await this.bee.getSizeExtensionCost(batchId, size) + const cost = await this.bee.storage.getSizeExtensionCost(batchId, size) if (cost.gt(bzzBalance)) { this.console.error(`Need ${cost.toDecimalString()} BZZ to extend the size to ${size.toFormattedString()}`) @@ -51,7 +51,7 @@ export class Extend extends StampCommand implements LeafCommand { } try { - await this.bee.extendStorageSize(batchId, size) + await this.bee.storage.extendSize(batchId, size) } finally { spinner.stop() } @@ -61,7 +61,7 @@ export class Extend extends StampCommand implements LeafCommand { const wantedLength = await this.console.askForValue('Add duration') const addedDuration = Duration.fromMilliseconds(Dates.make(wantedLength)) const totalDuration = Duration.fromMilliseconds(Dates.make(wantedLength) + batch.duration.toSeconds() * 1000) - const cost = await this.bee.getDurationExtensionCost(batchId, addedDuration) + const cost = await this.bee.storage.getDurationExtensionCost(batchId, addedDuration) if (cost.gt(bzzBalance)) { this.console.error( @@ -84,7 +84,7 @@ export class Extend extends StampCommand implements LeafCommand { } try { - await this.bee.extendStorageDuration(batchId, addedDuration) + await this.bee.storage.extendDuration(batchId, addedDuration) } finally { spinner.stop() } diff --git a/src/command/stamp/list.ts b/src/command/stamp/list.ts index 57c2a91b..7ba4731e 100644 --- a/src/command/stamp/list.ts +++ b/src/command/stamp/list.ts @@ -46,7 +46,7 @@ export class List extends StampCommand implements LeafCommand { super.init() this.console.verbose(`Listing postage stamps...`) - const stamps = (await this.bee.getPostageBatches()) || [] + const stamps = (await this.bee.stamp.getAll()) || [] if (stamps.length === 0) { this.console.error('You do not have any stamps.') diff --git a/src/command/stamp/rename.ts b/src/command/stamp/rename.ts index 5434f8f8..17508de0 100644 --- a/src/command/stamp/rename.ts +++ b/src/command/stamp/rename.ts @@ -25,7 +25,7 @@ export class Rename extends StampCommand implements LeafCommand { this.label = await this.console.askForValue('Please provide a new label for the postage stamp:') } - await this.bee.updatePostageBatchLabel(this.stamp, this.label) + await this.bee.stamp.updateLabel(this.stamp, this.label) this.console.log(`Postage stamp ${this.stamp} has been successfully renamed to '${this.label}'`) this.console.log(`Check it later with swarm-cli stamp show ${this.stamp}`) diff --git a/src/command/stamp/show.ts b/src/command/stamp/show.ts index f09b9669..40fdb266 100644 --- a/src/command/stamp/show.ts +++ b/src/command/stamp/show.ts @@ -20,7 +20,7 @@ export class Show extends StampCommand implements LeafCommand { this.console.verbose(`Looking up postage stamp ${this.stamp}...`) - const stamp = await this.bee.getPostageBatch(this.stamp) + const stamp = await this.bee.stamp.get(this.stamp) printStamp(stamp, this.console, { printUsageInQuiet: true, showTtl: true }) } diff --git a/src/command/stamp/stamp-command.ts b/src/command/stamp/stamp-command.ts index 72ff9135..f0725a4a 100644 --- a/src/command/stamp/stamp-command.ts +++ b/src/command/stamp/stamp-command.ts @@ -3,7 +3,7 @@ import { RootCommand } from '../root-command' export class StampCommand extends RootCommand { protected async printDepthAndAmount(id: string): Promise { - const stamp = await this.bee.getPostageBatch(id) + const stamp = await this.bee.stamp.get(id) this.console.log(createKeyValue('Stamp ID', stamp.batchID.toHex())) this.console.log(createKeyValue('Depth', stamp.depth)) this.console.log(createKeyValue('Amount', stamp.amount)) diff --git a/src/command/stamp/topup.ts b/src/command/stamp/topup.ts index c7245d4c..918d5861 100644 --- a/src/command/stamp/topup.ts +++ b/src/command/stamp/topup.ts @@ -36,7 +36,7 @@ export class Topup extends StampCommand implements LeafCommand { } try { - await this.bee.topUpBatch(this.stamp, this.amount.toString()) + await this.bee.stamp.topUp(this.stamp, this.amount.toString()) } finally { spinner.stop() } diff --git a/src/command/status.ts b/src/command/status.ts index 91d8f4c7..e4229d66 100644 --- a/src/command/status.ts +++ b/src/command/status.ts @@ -16,22 +16,22 @@ export class Status extends RootCommand implements LeafCommand { this.console.all(chalk.bold('Bee')) process.stdout.write(createKeyValue('API', this.beeApiUrl)) try { - await this.bee.checkConnection() + await this.bee.connectivity.checkConnection() process.stdout.write(chalk.bold.green(' [OK]') + '\n') } catch { process.stdout.write(chalk.bold.red(' [FAILED]') + '\n') process.stdout.write('\nIs your Bee node running?\n') exit(1) } - const versions = await this.bee.getVersions() + const versions = await this.bee.status.getVersions() this.console.all(createKeyValue('Version', versions.beeVersion)) - const nodeInfo = await this.bee.getNodeInfo() + const nodeInfo = await this.bee.status.getNodeInfo() this.console.all(createKeyValue('Mode', nodeInfo.beeMode)) if (nodeInfo.beeMode !== BeeModes.ULTRA_LIGHT) { this.console.all('') this.console.all(chalk.bold('Chainsync')) - const { block, chainTip, currentPrice } = await this.bee.getChainState() + const { block, chainTip, currentPrice } = await this.bee.status.getChainState() this.console.all( createKeyValue( 'Block', @@ -43,7 +43,7 @@ export class Status extends RootCommand implements LeafCommand { this.console.all('') this.console.all(chalk.bold('Topology')) - const topology = await this.bee.getTopology() + const topology = await this.bee.connectivity.getTopology() this.console.all(createKeyValue('Connected Peers', topology.connected)) this.console.all(createKeyValue('Population', topology.population)) this.console.all(createKeyValue('Depth', topology.depth)) @@ -52,7 +52,7 @@ export class Status extends RootCommand implements LeafCommand { this.console.all('') this.console.all(chalk.bold('Wallet')) try { - const { bzzBalance, nativeTokenBalance } = await this.bee.getWalletBalance() + const { bzzBalance, nativeTokenBalance } = await this.bee.wallet.getBalance() this.console.all(createKeyValue('xBZZ', bzzBalance.toDecimalString())) this.console.all(createKeyValue('xDAI', nativeTokenBalance.toDecimalString())) } catch { @@ -65,7 +65,7 @@ export class Status extends RootCommand implements LeafCommand { this.console.all('') this.console.all(chalk.bold('Chequebook')) try { - const { totalBalance, availableBalance } = await this.bee.getChequebookBalance() + const { totalBalance, availableBalance } = await this.bee.chequebook.getBalance() this.console.all(createKeyValue('Available xBZZ', availableBalance.toDecimalString())) this.console.all(createKeyValue('Total xBZZ', totalBalance.toDecimalString())) } catch { @@ -77,12 +77,12 @@ export class Status extends RootCommand implements LeafCommand { if (nodeInfo.beeMode === BeeModes.FULL) { this.console.all('') this.console.all(chalk.bold('Staking')) - const stake = await this.bee.getStake() - const surplusStake = await this.bee.getWithdrawableStake() + const stake = await this.bee.stake.get() + const surplusStake = await this.bee.stake.getWithdrawable() this.console.all(createKeyValue('Staked xBZZ', stake.toDecimalString())) this.console.all(createKeyValue('Withdrawable staked xBZZ', surplusStake.toDecimalString())) - const reserveStatus = await this.bee.getStatus() + const reserveStatus = await this.bee.status.get() this.console.all('') this.console.all(chalk.bold('Reserve')) this.console.all( @@ -113,7 +113,7 @@ export class Status extends RootCommand implements LeafCommand { ' GB)', ), ) - const reserveState = await this.bee.getReserveState() + const reserveState = await this.bee.status.getReserveState() const reserveCapacityDoubling = reserveState.reserveCapacityDoubling this.console.all( createKeyValue( @@ -125,7 +125,7 @@ export class Status extends RootCommand implements LeafCommand { ) this.console.all('') this.console.all(chalk.bold('Redistribution')) - const redistributionState = await this.bee.getRedistributionState() + const redistributionState = await this.bee.stake.getRedistributionState() const currentRound = redistributionState.round this.console.all(createKeyValue('Reward', redistributionState.reward.toDecimalString() + ' xBZZ')) this.console.all(createKeyValue('Has sufficient funds', redistributionState.hasSufficientFunds)) diff --git a/src/command/upload.ts b/src/command/upload.ts index 10e455b1..9cbb6903 100644 --- a/src/command/upload.ts +++ b/src/command/upload.ts @@ -148,7 +148,7 @@ export class Upload extends RootCommand implements LeafCommand { throw new CommandLineError(`Given filepath '${this.path}' doesn't exist`) } - const isGateway = await this.bee.isGateway() + const isGateway = await this.bee.connectivity.isGateway() if (this.stdin) { if (!this.stamp && !isGateway) { @@ -167,7 +167,7 @@ export class Upload extends RootCommand implements LeafCommand { await this.maybePrintRedundancyStats() - const tag = this.sync ? await this.bee.createTag() : undefined + const tag = this.sync ? await this.bee.tag.create() : undefined const uploadingFolder = !this.stdin && FS.statSync(this.path).isDirectory() @@ -209,7 +209,7 @@ export class Upload extends RootCommand implements LeafCommand { this.console.quiet(this.result.getOrThrow().toHex()) if (!isGateway && !this.quiet) { - printStamp(await this.bee.getPostageBatch(this.stamp), this.console, { shortenBatchId: true }) + printStamp(await this.bee.stamp.get(this.stamp), this.console, { shortenBatchId: true }) } } @@ -266,7 +266,7 @@ export class Upload extends RootCommand implements LeafCommand { uploadOptions = this.prepareACTUploadOptions(uploadOptions) - const { reference, historyAddress } = await this.bee.uploadFile( + const { reference, historyAddress } = await this.bee.file.upload( this.stamp, this.stdinData, this.fileName, @@ -288,7 +288,7 @@ export class Upload extends RootCommand implements LeafCommand { } as FileUploadOptions uploadOptions = this.prepareACTUploadOptions(uploadOptions) - const { reference, historyAddress } = await this.bee.uploadData( + const { reference, historyAddress } = await this.bee.data.upload( this.stamp, this.stdinData, uploadOptions, @@ -319,7 +319,7 @@ export class Upload extends RootCommand implements LeafCommand { deferred: this.deferred, } as FileUploadOptions uploadOptions = this.prepareACTUploadOptions(uploadOptions) - const { reference, historyAddress } = await this.bee.uploadFilesFromDirectory( + const { reference, historyAddress } = await this.bee.collection.uploadFromDirectory( this.stamp, this.path, uploadOptions, @@ -351,7 +351,7 @@ export class Upload extends RootCommand implements LeafCommand { deferred: this.deferred, } as FileUploadOptions uploadOptions = this.prepareACTUploadOptions(uploadOptions) - const { reference, historyAddress } = await this.bee.uploadFile( + const { reference, historyAddress } = await this.bee.file.upload( this.stamp, readable, this.determineFileName(parsedPath.base), @@ -386,7 +386,7 @@ export class Upload extends RootCommand implements LeafCommand { progressBar.start(tag.split, 0) } for (let i = 0; i < pollingTrials; i++) { - tag = await this.bee.retrieveTag(tagUid) + tag = await this.bee.tag.get(tagUid) const newSyncProgress = tag.seen + tag.synced if (newSyncProgress > syncProgress) { @@ -483,7 +483,7 @@ export class Upload extends RootCommand implements LeafCommand { } private async hasUnsupportedGatewayOptions(): Promise { - if (!(await this.bee.isGateway())) { + if (!(await this.bee.connectivity.isGateway())) { return false } @@ -538,7 +538,7 @@ export class Upload extends RootCommand implements LeafCommand { private async getConnectedPeers(): Promise { try { - const { connected } = await this.bee.getTopology() + const { connected } = await this.bee.connectivity.getTopology() return connected } catch { @@ -605,7 +605,7 @@ export class Upload extends RootCommand implements LeafCommand { } private async printShareInstructions() { - const { publicKey } = await this.bee.getNodeAddresses() + const { publicKey } = await this.bee.connectivity.getNodeAddresses() this.console.log( '\nTo share the uploaded content with your grantees, please provide them with the following information:\n', ) diff --git a/src/command/utility/rchash.ts b/src/command/utility/rchash.ts index be47d345..9d34cdee 100644 --- a/src/command/utility/rchash.ts +++ b/src/command/utility/rchash.ts @@ -20,8 +20,8 @@ export class Rchash extends RootCommand implements LeafCommand { public async run(): Promise { super.init() - const addresses = await this.bee.getNodeAddresses() - const status = await this.bee.getStatus() + const addresses = await this.bee.connectivity.getNodeAddresses() + const status = await this.bee.status.get() const depth = this.depth ?? status.committedDepth const anchor = addresses.overlay.toHex().slice(0, Math.max(2, Math.ceil(depth / 8) * 2)) let stillRunning = true diff --git a/src/command/utility/redeem.ts b/src/command/utility/redeem.ts index ae4c99dc..2caab339 100644 --- a/src/command/utility/redeem.ts +++ b/src/command/utility/redeem.ts @@ -45,7 +45,7 @@ export class Redeem extends RootCommand implements LeafCommand { if (!this.target) { this.console.log('Fetching Bee wallet address...') - const { ethereum } = await this.bee.getNodeAddresses() + const { ethereum } = await this.bee.connectivity.getNodeAddresses() this.target = ethereum.toHex() } diff --git a/src/command/wallet/status.ts b/src/command/wallet/status.ts index b2bda0e1..2e9912fa 100644 --- a/src/command/wallet/status.ts +++ b/src/command/wallet/status.ts @@ -11,7 +11,7 @@ export class Status extends RootCommand implements LeafCommand { public async run(): Promise { super.init() - const { bzzBalance, nativeTokenBalance } = await this.bee.getWalletBalance() + const { bzzBalance, nativeTokenBalance } = await this.bee.wallet.getBalance() this.console.all(chalk.bold('Wallet')) this.console.all(createKeyValue('xBZZ', bzzBalance.toDecimalString())) diff --git a/src/command/wallet/withdraw-bzz.ts b/src/command/wallet/withdraw-bzz.ts index fd88fabe..1dfd2d51 100644 --- a/src/command/wallet/withdraw-bzz.ts +++ b/src/command/wallet/withdraw-bzz.ts @@ -45,7 +45,7 @@ export class WithdrawBZZ extends RootCommand implements LeafCommand { return } - const transaction = await this.bee.withdrawBZZToExternalWallet(amount, this.address) + const transaction = await this.bee.wallet.withdrawBZZ(amount, this.address) this.console.log(createKeyValue('Transaction', transaction.represent())) this.console.log(createKeyValue('URL', `https://gnosisscan.io/tx/0x${transaction.represent()}`)) } diff --git a/src/command/wallet/withdraw-dai.ts b/src/command/wallet/withdraw-dai.ts index 0b8ca0ab..71dccfb1 100644 --- a/src/command/wallet/withdraw-dai.ts +++ b/src/command/wallet/withdraw-dai.ts @@ -45,7 +45,7 @@ export class WithdrawDAI extends RootCommand implements LeafCommand { return } - const transaction = await this.bee.withdrawDAIToExternalWallet(amount, this.address) + const transaction = await this.bee.wallet.withdrawDAI(amount, this.address) this.console.log(createKeyValue('Transaction', transaction.represent())) this.console.log(createKeyValue('URL', `https://gnosisscan.io/tx/0x${transaction.represent()}`)) } diff --git a/src/service/stamp/index.ts b/src/service/stamp/index.ts index 6d707144..0810b701 100644 --- a/src/service/stamp/index.ts +++ b/src/service/stamp/index.ts @@ -15,7 +15,7 @@ import { createKeyValue, formatDate } from '../../utils/text' * @returns {Promise} Hex representation of the Stamp ID. */ export async function pickStamp(bee: Bee, console: CommandLog): Promise { - const stamps = await bee.getAllPostageBatch() + const stamps = await bee.stamp.getAll() const choices = stamps .filter(stamp => stamp.usable || stamp.duration.toSeconds() > 1) diff --git a/src/utils/bzz-address.ts b/src/utils/bzz-address.ts index a210bfb4..649c0148 100644 --- a/src/utils/bzz-address.ts +++ b/src/utils/bzz-address.ts @@ -1,4 +1,4 @@ -import { Bee, MantarayNode, MerkleTree } from '@ethersphere/bee-js' +import { Bee, MantarayNode, ChunkSplitter } from '@ethersphere/bee-js' import { Binary } from 'cafe-utility' import { CommandLineError } from './error' @@ -39,8 +39,8 @@ export async function makeBzzAddress(bee: Bee, url: string): Promise const resolvedFeed = await manifest.resolveFeed(bee) await resolvedFeed.ifPresentAsync(async feed => { - const merkleTree = await MerkleTree.root(feed.payload.toUint8Array()) - const cacAddress = Binary.uint8ArrayToHex(merkleTree.hash()) + const merkleTree = await ChunkSplitter.root(feed.payload.toUint8Array()) + const cacAddress = Binary.uint8ArrayToHex(merkleTree.hash().toUint8Array()) address.hash = cacAddress }) diff --git a/src/utils/chainsync.ts b/src/utils/chainsync.ts index 05e3cbd5..7c43b1c3 100644 --- a/src/utils/chainsync.ts +++ b/src/utils/chainsync.ts @@ -3,7 +3,7 @@ import { Bee } from '@ethersphere/bee-js' const THRESHOLD = 10_000 export async function isChainStateReady(bee: Bee): Promise { - const chainState = await bee.getChainState() + const chainState = await bee.status.getChainState() return chainState.chainTip > chainState.block - THRESHOLD } diff --git a/test/command/cheque.spec.ts b/test/command/cheque.spec.ts index 4693c872..d8f8ea1d 100644 --- a/test/command/cheque.spec.ts +++ b/test/command/cheque.spec.ts @@ -112,7 +112,7 @@ describeCommand( const fakeTxHash = 'a'.repeat(64) it('should deposit {amount} of BZZ to chequebook', async () => { - const spy = jest.spyOn(Bee.prototype, 'depositBZZToChequebook').mockResolvedValue(new TransactionId(fakeTxHash)) + const spy = jest.spyOn(Bee.prototype.chequebook, 'deposit').mockResolvedValue(new TransactionId(fakeTxHash)) await invokeTestCli(['cheque', 'deposit', '20']) expect(spy).toHaveBeenCalledWith(BZZ.fromDecimalString('20')) expect(getLastMessage()).toContain('Tx:') @@ -120,7 +120,7 @@ describeCommand( }) it('should deposit {amount} of PLUR to chequebook', async () => { - const spy = jest.spyOn(Bee.prototype, 'depositBZZToChequebook').mockResolvedValue(new TransactionId(fakeTxHash)) + const spy = jest.spyOn(Bee.prototype.chequebook, 'deposit').mockResolvedValue(new TransactionId(fakeTxHash)) await invokeTestCli(['cheque', 'deposit', '15', '--unit', 'plur']) expect(spy).toHaveBeenCalledWith(BZZ.fromPLUR('15')) expect(getLastMessage()).toContain('Tx:') @@ -132,9 +132,7 @@ describeCommand( const fakeTxHash = 'a'.repeat(64) it('should withdraw {amount} of BZZ from chequebook', async () => { - const spy = jest - .spyOn(Bee.prototype, 'withdrawBZZFromChequebook') - .mockResolvedValue(new TransactionId(fakeTxHash)) + const spy = jest.spyOn(Bee.prototype.chequebook, 'withdraw').mockResolvedValue(new TransactionId(fakeTxHash)) await invokeTestCli(['cheque', 'withdraw', '20']) expect(spy).toHaveBeenCalledWith(BZZ.fromDecimalString('20')) expect(getLastMessage()).toContain('Tx:') @@ -142,9 +140,7 @@ describeCommand( }) it('should withdraw {amount} of PLUR from chequebook', async () => { - const spy = jest - .spyOn(Bee.prototype, 'withdrawBZZFromChequebook') - .mockResolvedValue(new TransactionId(fakeTxHash)) + const spy = jest.spyOn(Bee.prototype.chequebook, 'withdraw').mockResolvedValue(new TransactionId(fakeTxHash)) await invokeTestCli(['cheque', 'withdraw', '15', '--unit', 'plur']) expect(spy).toHaveBeenCalledWith(BZZ.fromPLUR('15')) expect(getLastMessage()).toContain('Tx:') diff --git a/test/command/rchash.spec.ts b/test/command/rchash.spec.ts index a4af9962..a3324390 100644 --- a/test/command/rchash.spec.ts +++ b/test/command/rchash.spec.ts @@ -12,7 +12,7 @@ describeCommand('Test Utility rchash command', ({ consoleMessages }) => { await System.waitFor( async () => { const bee = new Bee('http://localhost:1633') - const status = await bee.getStatus() + const status = await bee.status.get() return status.isWarmingUp === false }, @@ -26,7 +26,7 @@ describeCommand('Test Utility rchash command', ({ consoleMessages }) => { await System.waitFor( async () => { const bee = new Bee('http://localhost:1633') - const status = await bee.getStatus() + const status = await bee.status.get() return status.isWarmingUp === false }, diff --git a/test/command/stamp.spec.ts b/test/command/stamp.spec.ts index bc3f77e5..278b9bcd 100644 --- a/test/command/stamp.spec.ts +++ b/test/command/stamp.spec.ts @@ -75,7 +75,7 @@ describeCommand( it('should buy stamp', async () => { const createPostageBatch = jest - .spyOn(Bee.prototype, 'createPostageBatch') + .spyOn(Bee.prototype.stamp, 'create') .mockResolvedValue(new BatchId(fakeBatchIdHash)) await invokeTestCli(['stamp', 'buy', '--amount', '600_000_000', '--depth', '20', '--yes']) expect(createPostageBatch).toHaveBeenCalledWith('600000000', 20, expect.objectContaining({ immutableFlag: true })) @@ -85,7 +85,7 @@ describeCommand( it('should buy stamp with immutable flag', async () => { const createPostageBatch = jest - .spyOn(Bee.prototype, 'createPostageBatch') + .spyOn(Bee.prototype.stamp, 'create') .mockResolvedValue(new BatchId(fakeBatchIdHash)) await invokeTestCli([ 'stamp', @@ -117,7 +117,7 @@ describeCommand( it('should wait until stamp is usable', async () => { const createPostageBatch = jest - .spyOn(Bee.prototype, 'createPostageBatch') + .spyOn(Bee.prototype.stamp, 'create') .mockResolvedValue(new BatchId(fakeBatchIdHash)) await invokeTestCli([ 'stamp', @@ -142,7 +142,7 @@ describeCommand( it('should accept estimate cost prompt', async () => { jest.spyOn(inquirer, 'prompt').mockResolvedValueOnce({ value: true }) const createPostageBatch = jest - .spyOn(Bee.prototype, 'createPostageBatch') + .spyOn(Bee.prototype.stamp, 'create') .mockResolvedValue(new BatchId(fakeBatchIdHash)) const execution = await invokeTestCli(['stamp', 'buy', '--depth', '20', '--amount', '1b']) const command = execution.runnable as Buy @@ -154,7 +154,7 @@ describeCommand( it('should reject estimate cost prompt', async () => { jest.spyOn(inquirer, 'prompt').mockResolvedValueOnce({ value: false }) const createPostageBatch = jest - .spyOn(Bee.prototype, 'createPostageBatch') + .spyOn(Bee.prototype.stamp, 'create') .mockResolvedValue(new BatchId(fakeBatchIdHash)) const execution = await invokeTestCli(['stamp', 'buy', '--depth', '20', '--amount', '1b']) const command = execution.runnable as Buy @@ -165,7 +165,7 @@ describeCommand( it('should be possible to buy with underscores and units', async () => { const createPostageBatch = jest - .spyOn(Bee.prototype, 'createPostageBatch') + .spyOn(Bee.prototype.stamp, 'create') .mockResolvedValue(new BatchId(fakeBatchIdHash)) await invokeTestCli([ 'stamp', diff --git a/test/command/upload.spec.ts b/test/command/upload.spec.ts index 4f9ecb63..88115574 100644 --- a/test/command/upload.spec.ts +++ b/test/command/upload.spec.ts @@ -1,4 +1,4 @@ -import { MerkleTree } from '@ethersphere/bee-js' +import { ChunkSplitter } from '@ethersphere/bee-js' import { System } from 'cafe-utility' import { existsSync, readFileSync, unlinkSync, writeFileSync } from 'fs' import { LeafCommand } from 'furious-commander' @@ -123,8 +123,8 @@ describeCommand( ) const uploadCommand = commandBuilder.runnable as Upload - const bareRootChunk = await MerkleTree.root(new Uint8Array(data)) - const bareReference = Buffer.from(bareRootChunk.hash()).toString('hex') + const bareRootChunk = await ChunkSplitter.root(new Uint8Array(data)) + const bareReference = Buffer.from(bareRootChunk.hash().toUint8Array()).toString('hex') expect(uploadCommand.result.getOrThrow().toHex()).toBe(bareReference) }) diff --git a/test/utility/stamp.ts b/test/utility/stamp.ts index 4be58693..01a20636 100644 --- a/test/utility/stamp.ts +++ b/test/utility/stamp.ts @@ -4,7 +4,7 @@ import { Numbers } from 'cafe-utility' export const getOrBuyStamp = async (): Promise => { const bee = new Bee('http://localhost:1633') - const availableStamps = await bee.getAllPostageBatch() + const availableStamps = await bee.stamp.getAll() const [existingStamp] = availableStamps @@ -16,7 +16,7 @@ export const getOrBuyStamp = async (): Promise => { } console.log('Buying new stamp.') - const newStamp = await bee.createPostageBatch(Numbers.make('2b').toString(), 22, { waitForUsable: true }) + const newStamp = await bee.stamp.create(Numbers.make('2b').toString(), 22, { waitForUsable: true }) console.log('Bought stamp: ', newStamp.toHex()) return newStamp From d86be4177c62c4ed8c6ac970b6fdba0c3af252ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gergely=20B=C3=A9k=C3=A9si?= Date: Mon, 24 Aug 2026 14:22:22 +0200 Subject: [PATCH 4/7] fix: update spy statements --- test/command/cheque.spec.ts | 10 ++++++---- test/command/stamp.spec.ts | 25 +++++++------------------ 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/test/command/cheque.spec.ts b/test/command/cheque.spec.ts index d8f8ea1d..d3528ead 100644 --- a/test/command/cheque.spec.ts +++ b/test/command/cheque.spec.ts @@ -110,9 +110,10 @@ describeCommand( describe('deposit', () => { const fakeTxHash = 'a'.repeat(64) + const chequebookPrototype = Object.getPrototypeOf(new Bee('http://localhost:1633').chequebook) it('should deposit {amount} of BZZ to chequebook', async () => { - const spy = jest.spyOn(Bee.prototype.chequebook, 'deposit').mockResolvedValue(new TransactionId(fakeTxHash)) + const spy = jest.spyOn(chequebookPrototype, 'deposit').mockResolvedValue(new TransactionId(fakeTxHash)) await invokeTestCli(['cheque', 'deposit', '20']) expect(spy).toHaveBeenCalledWith(BZZ.fromDecimalString('20')) expect(getLastMessage()).toContain('Tx:') @@ -120,7 +121,7 @@ describeCommand( }) it('should deposit {amount} of PLUR to chequebook', async () => { - const spy = jest.spyOn(Bee.prototype.chequebook, 'deposit').mockResolvedValue(new TransactionId(fakeTxHash)) + const spy = jest.spyOn(chequebookPrototype, 'deposit').mockResolvedValue(new TransactionId(fakeTxHash)) await invokeTestCli(['cheque', 'deposit', '15', '--unit', 'plur']) expect(spy).toHaveBeenCalledWith(BZZ.fromPLUR('15')) expect(getLastMessage()).toContain('Tx:') @@ -130,9 +131,10 @@ describeCommand( describe('withdraw', () => { const fakeTxHash = 'a'.repeat(64) + const chequebookPrototype = Object.getPrototypeOf(new Bee('http://localhost:1633').chequebook) it('should withdraw {amount} of BZZ from chequebook', async () => { - const spy = jest.spyOn(Bee.prototype.chequebook, 'withdraw').mockResolvedValue(new TransactionId(fakeTxHash)) + const spy = jest.spyOn(chequebookPrototype, 'withdraw').mockResolvedValue(new TransactionId(fakeTxHash)) await invokeTestCli(['cheque', 'withdraw', '20']) expect(spy).toHaveBeenCalledWith(BZZ.fromDecimalString('20')) expect(getLastMessage()).toContain('Tx:') @@ -140,7 +142,7 @@ describeCommand( }) it('should withdraw {amount} of PLUR from chequebook', async () => { - const spy = jest.spyOn(Bee.prototype.chequebook, 'withdraw').mockResolvedValue(new TransactionId(fakeTxHash)) + const spy = jest.spyOn(chequebookPrototype, 'withdraw').mockResolvedValue(new TransactionId(fakeTxHash)) await invokeTestCli(['cheque', 'withdraw', '15', '--unit', 'plur']) expect(spy).toHaveBeenCalledWith(BZZ.fromPLUR('15')) expect(getLastMessage()).toContain('Tx:') diff --git a/test/command/stamp.spec.ts b/test/command/stamp.spec.ts index 278b9bcd..0ccaa1f4 100644 --- a/test/command/stamp.spec.ts +++ b/test/command/stamp.spec.ts @@ -14,6 +14,7 @@ describeCommand( 'Test Stamp command', ({ consoleMessages, getLastMessage, getNthLastMessage, hasMessageContaining }) => { const fakeBatchIdHash = randomBytes(32).toString('hex') + const stampPrototype = Object.getPrototypeOf(new Bee('http://localhost:1633').stamp) afterEach(() => { jest.clearAllMocks() @@ -74,9 +75,7 @@ describeCommand( }) it('should buy stamp', async () => { - const createPostageBatch = jest - .spyOn(Bee.prototype.stamp, 'create') - .mockResolvedValue(new BatchId(fakeBatchIdHash)) + const createPostageBatch = jest.spyOn(stampPrototype, 'create').mockResolvedValue(new BatchId(fakeBatchIdHash)) await invokeTestCli(['stamp', 'buy', '--amount', '600_000_000', '--depth', '20', '--yes']) expect(createPostageBatch).toHaveBeenCalledWith('600000000', 20, expect.objectContaining({ immutableFlag: true })) expect(getLastMessage()).toContain('Stamp ID:') @@ -84,9 +83,7 @@ describeCommand( }) it('should buy stamp with immutable flag', async () => { - const createPostageBatch = jest - .spyOn(Bee.prototype.stamp, 'create') - .mockResolvedValue(new BatchId(fakeBatchIdHash)) + const createPostageBatch = jest.spyOn(stampPrototype, 'create').mockResolvedValue(new BatchId(fakeBatchIdHash)) await invokeTestCli([ 'stamp', 'buy', @@ -116,9 +113,7 @@ describeCommand( }) it('should wait until stamp is usable', async () => { - const createPostageBatch = jest - .spyOn(Bee.prototype.stamp, 'create') - .mockResolvedValue(new BatchId(fakeBatchIdHash)) + const createPostageBatch = jest.spyOn(stampPrototype, 'create').mockResolvedValue(new BatchId(fakeBatchIdHash)) await invokeTestCli([ 'stamp', 'buy', @@ -141,9 +136,7 @@ describeCommand( it('should accept estimate cost prompt', async () => { jest.spyOn(inquirer, 'prompt').mockResolvedValueOnce({ value: true }) - const createPostageBatch = jest - .spyOn(Bee.prototype.stamp, 'create') - .mockResolvedValue(new BatchId(fakeBatchIdHash)) + const createPostageBatch = jest.spyOn(stampPrototype, 'create').mockResolvedValue(new BatchId(fakeBatchIdHash)) const execution = await invokeTestCli(['stamp', 'buy', '--depth', '20', '--amount', '1b']) const command = execution.runnable as Buy expect(command.yes).toBe(true) @@ -153,9 +146,7 @@ describeCommand( it('should reject estimate cost prompt', async () => { jest.spyOn(inquirer, 'prompt').mockResolvedValueOnce({ value: false }) - const createPostageBatch = jest - .spyOn(Bee.prototype.stamp, 'create') - .mockResolvedValue(new BatchId(fakeBatchIdHash)) + const createPostageBatch = jest.spyOn(stampPrototype, 'create').mockResolvedValue(new BatchId(fakeBatchIdHash)) const execution = await invokeTestCli(['stamp', 'buy', '--depth', '20', '--amount', '1b']) const command = execution.runnable as Buy expect(command.yes).toBe(false) @@ -164,9 +155,7 @@ describeCommand( }) it('should be possible to buy with underscores and units', async () => { - const createPostageBatch = jest - .spyOn(Bee.prototype.stamp, 'create') - .mockResolvedValue(new BatchId(fakeBatchIdHash)) + const createPostageBatch = jest.spyOn(stampPrototype, 'create').mockResolvedValue(new BatchId(fakeBatchIdHash)) await invokeTestCli([ 'stamp', 'buy', From 9e111581df4bf2650b0ca2ebb86f6b0f2bd54d02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gergely=20B=C3=A9k=C3=A9si?= Date: Mon, 24 Aug 2026 14:48:23 +0200 Subject: [PATCH 5/7] chore: update bee-js --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 0ef4fa02..993f217b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "BSD-3-Clause", "dependencies": { "@ethereumjs/wallet": "^2.0.4", - "@ethersphere/bee-js": "13.0.0-upcoming.gf9d33e6", + "@ethersphere/bee-js": "13.0.0-upcoming.ga89553d", "@ethersphere/core-sdk": "^0.1.1", "cafe-utility": "^33.3.1", "chalk": "^2.4.2", @@ -1116,9 +1116,9 @@ } }, "node_modules/@ethersphere/bee-js": { - "version": "13.0.0-upcoming.gf9d33e6", - "resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-13.0.0-upcoming.gf9d33e6.tgz", - "integrity": "sha512-QVkRoG+Pil45Gk/CYH68u8hHd34eVVx4B8wNrxRJgVWiKDsPlY7aWs8Clu2VNCKKiaB1tnOVxg/av6eRuiTB7w==", + "version": "13.0.0-upcoming.ga89553d", + "resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-13.0.0-upcoming.ga89553d.tgz", + "integrity": "sha512-s6uMhr75sIqcO+D4JqhwtM+bg1RFpGNYMpbkcIrEuMS1PLfFy244V1daPJSxvaiD3GLpNvsyoyFctDQgYWjlaQ==", "license": "BSD-3-Clause", "dependencies": { "@ethersphere/core-sdk": "^0.1.1", diff --git a/package.json b/package.json index 755c6b34..2e1ad200 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ }, "dependencies": { "@ethereumjs/wallet": "^2.0.4", - "@ethersphere/bee-js": "13.0.0-upcoming.gf9d33e6", + "@ethersphere/bee-js": "13.0.0-upcoming.ga89553d", "@ethersphere/core-sdk": "^0.1.1", "cafe-utility": "^33.3.1", "chalk": "^2.4.2", From 0eecda9d79896f707ad38b213c253602472610a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gergely=20B=C3=A9k=C3=A9si?= Date: Mon, 24 Aug 2026 15:08:41 +0200 Subject: [PATCH 6/7] fix: update spec --- test/command/manifest.spec.ts | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/test/command/manifest.spec.ts b/test/command/manifest.spec.ts index c7676827..a077e9d5 100644 --- a/test/command/manifest.spec.ts +++ b/test/command/manifest.spec.ts @@ -305,18 +305,12 @@ describeCommand('Test Manifest command', ({ consoleMessages, hasMessageContainin it('should handle error for invalid download hash', async () => { await invokeTestCli(['manifest', 'download', 'g'.repeat(64)]) - expect(consoleMessages[0]).toContain( - FORMATTED_ERROR + - ' expected hex string (origin=string, code=invalid_format, format=regex, pattern=/^(?:0x)?[0-9a-fA-F]*$/i)', - ) + expect(consoleMessages[0]).toContain(FORMATTED_ERROR + ` Bytes#constructor: invalid hex string: ${'g'.repeat(64)}`) }) it('should handle error for invalid list hash', async () => { await invokeTestCli(['manifest', 'list', 'g'.repeat(64)]) - expect(consoleMessages[0]).toContain( - FORMATTED_ERROR + - ' expected hex string (origin=string, code=invalid_format, format=regex, pattern=/^(?:0x)?[0-9a-fA-F]*$/i)', - ) + expect(consoleMessages[0]).toContain(FORMATTED_ERROR + ` Bytes#constructor: invalid hex string: ${'g'.repeat(64)}`) }) it('should handle error for 404 download hash', async () => { From 78f3f1e21d6ba5f725730783b36ce42befc9de69 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gergely=20B=C3=A9k=C3=A9si?= Date: Mon, 24 Aug 2026 16:42:46 +0200 Subject: [PATCH 7/7] chore: update bee-js --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 993f217b..10c017a4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,7 +10,7 @@ "license": "BSD-3-Clause", "dependencies": { "@ethereumjs/wallet": "^2.0.4", - "@ethersphere/bee-js": "13.0.0-upcoming.ga89553d", + "@ethersphere/bee-js": "13.0.0-upcoming.gbab2b2e", "@ethersphere/core-sdk": "^0.1.1", "cafe-utility": "^33.3.1", "chalk": "^2.4.2", @@ -1116,9 +1116,9 @@ } }, "node_modules/@ethersphere/bee-js": { - "version": "13.0.0-upcoming.ga89553d", - "resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-13.0.0-upcoming.ga89553d.tgz", - "integrity": "sha512-s6uMhr75sIqcO+D4JqhwtM+bg1RFpGNYMpbkcIrEuMS1PLfFy244V1daPJSxvaiD3GLpNvsyoyFctDQgYWjlaQ==", + "version": "13.0.0-upcoming.gbab2b2e", + "resolved": "https://registry.npmjs.org/@ethersphere/bee-js/-/bee-js-13.0.0-upcoming.gbab2b2e.tgz", + "integrity": "sha512-SH3haY1f9Bo0gGgZ6BgBOKcCYeWAZroCVhvEzXp/3wj80EkFoXn2+1x6CiltCWvxHLZRAxW7qHRjH3uuvFEMBQ==", "license": "BSD-3-Clause", "dependencies": { "@ethersphere/core-sdk": "^0.1.1", diff --git a/package.json b/package.json index 2e1ad200..59fad5e2 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ }, "dependencies": { "@ethereumjs/wallet": "^2.0.4", - "@ethersphere/bee-js": "13.0.0-upcoming.ga89553d", + "@ethersphere/bee-js": "13.0.0-upcoming.gbab2b2e", "@ethersphere/core-sdk": "^0.1.1", "cafe-utility": "^33.3.1", "chalk": "^2.4.2",