Skip to content
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
4 changes: 2 additions & 2 deletions jest.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default async (): Promise<Config.InitialOptions> => {
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,
Expand All @@ -48,7 +48,7 @@ export default async (): Promise<Config.InitialOptions> => {
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())
Expand Down
101 changes: 53 additions & 48 deletions package-lock.json

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

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@
},
"dependencies": {
"@ethereumjs/wallet": "^2.0.4",
"@ethersphere/bee-js": "^12.0.0",
"@upcoming/swarm-core": "^0.0.8",
"@ethersphere/bee-js": "^13.0.0",
"@ethersphere/core-sdk": "^0.1.1",
"cafe-utility": "^33.3.1",
"chalk": "^2.4.2",
"cli-progress": "^3.11.2",
Expand Down
2 changes: 1 addition & 1 deletion src/command/access/grant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(', ')}`))
Expand Down
2 changes: 1 addition & 1 deletion src/command/access/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
2 changes: 1 addition & 1 deletion src/command/access/revoke.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(', ')}`))
Expand Down
2 changes: 1 addition & 1 deletion src/command/access/show.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.`)
Expand Down
6 changes: 3 additions & 3 deletions src/command/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export class Addresses extends RootCommand implements LeafCommand {
public async run(): Promise<void> {
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)
})
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 @@ -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,
})
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 @@ -16,7 +16,7 @@ export class ChequeCommand extends RootCommand {
}

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

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

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

return 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 @@ -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())
}
Expand Down
4 changes: 2 additions & 2 deletions src/command/cheque/withdraw-all.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ export class WithdrawAll extends ChequeCommand implements LeafCommand {
public async run(): Promise<void> {
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.')

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())
}
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 @@ -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())
}
Expand Down
6 changes: 3 additions & 3 deletions src/command/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}

Expand Down
10 changes: 5 additions & 5 deletions src/command/feed/feed-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 }
Expand Down
12 changes: 6 additions & 6 deletions src/command/feed/print.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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}/`)
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 @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions src/command/hash.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand All @@ -17,6 +17,6 @@ export class Hash extends RootCommand implements LeafCommand {

public async run(): Promise<void> {
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())
}
}
Loading
Loading