@hiveio/workerbee / IWorkerBee
Interface: IWorkerBee
Properties
chain?
readonly
optional
chain:Readonly
<IHiveChainInterface
>
Exposed hive chain interface we are using. May be undefined if you have not already started our bot.
Remember that chain property will be initialized during start call and uninitialized during delete
Defined in
configuration
readonly
configuration:Readonly
<IStartConfiguration
>
Bot configuration
Defined in
running
readonly
running:boolean
Indicates if the bot is running
Defined in
Accessors
observe
Get Signature
get observe():
QueenBee
<object
>
Allows you to iterate over blocks in live mode
Example
workerbee.observe.onBlock().subscribe({
next: (data) => {
console.log(data);
},
error: console.error
});
Returns
QueenBee
<object
>
Defined in
Methods
[asyncIterator]()
[asyncIterator]():
AsyncIterator
<IBlockData
&IBlockHeaderData
,any
,any
>
Allows you to iterate over blocks indefinitely
Ignores errors
Returns
AsyncIterator
<IBlockData
& IBlockHeaderData
, any
, any
>
Example
for await (const block of workerbee) {
console.log(block);
}
Defined in
broadcast()
broadcast(
tx
,options
?):Promise
<void
>
Broadcast given transaction to the remote and returns a promise resolved when transaction has been successfully applied on chain. You can also optionally provide verifySignatures option if you want to ensure that the signatures in the transaction, applied on chain match the local ones.
Requires signed transaction
Parameters
tx
Protobuf transactoin to broadcast
ApiTransaction
| ITransaction
options?
Options for broadcasting
Returns
Promise
<void
>
Defined in
delete()
delete():
void
Deletes the current bot instance and underlying wax and beekepeer objects. wax chain object is deleted only when its instance was managed by workerbee itself.
Returns
void
Defined in
iterate()
Call Signature
iterate():
AsyncIterator
<IBlockData
&IBlockHeaderData
,any
,any
>
Allows you to iterate over blocks indefinitely - alias to async iterator
Ignores errors
Returns
AsyncIterator
<IBlockData
& IBlockHeaderData
, any
, any
>
Example
for await (const block of workerbee.iterate()) {
console.log(block);
}
Defined in
Call Signature
iterate(
throwOnError
):AsyncIterator
<IBlockData
&IBlockHeaderData
,any
,any
>
Allows you to iterate over blocks indefinitely - alias to async iterator
Allows to handle errors via try/catch clause around the async iterator
Parameters
throwOnError
boolean
If true, the error will be thrown
Returns
AsyncIterator
<IBlockData
& IBlockHeaderData
, any
, any
>
Example
try {
for await (const block of workerbee.iterate(true)) {
console.log(block);
}
} catch (error) {
console.error("Error while iterating:", error);
}
Defined in
Call Signature
iterate(
errorHandler
):AsyncIterator
<IBlockData
&IBlockHeaderData
,any
,any
>
Allows you to iterate over blocks indefinitely - alias to async iterator
Allows to handle errors via callback
Parameters
errorHandler
(error
) => void
Callback function to handle errors
Returns
AsyncIterator
<IBlockData
& IBlockHeaderData
, any
, any
>
Example
for await (const block of workerbee.iterate(console.error))
console.log(block);
Defined in
providePastOperations()
Call Signature
providePastOperations(
fromBlock
,toBlock
):TPastQueen
Allows you to iterate over blocks in the past from a given range
Parameters
fromBlock
number
toBlock
number
Returns
TPastQueen
Example
await new Promise((resolve, reject) => {
workerbee.providePastOperations(10_000, 10_500).onBlock().subscribe({
next: (data) => {
console.log(data);
},
error: reject,
complete: resolve
});
});
Throws
if called before start
Defined in
Call Signature
providePastOperations(
relativeTime
):Promise
<TPastQueen
>
Allows you to iterate over blocks in the past from a given range
Parameters
relativeTime
string
Returns
Promise
<TPastQueen
>
Example
workerbee.providePastOperations('-7d').then((provider) => {
provider.onBlock().subscribe({
next: (data) => {
console.log(data);
},
error: console.error,
complete: () => {
console.log('Completed');
}
});
});
Throws
if called before start
Defined in
start()
start(
wallet
?):Promise
<void
>
Starts the automation with given configuration
Parameters
wallet?
IBeekeeperUnlockedWallet
optional unlocked beekeper wallet for bot operations
Returns
Promise
<void
>
Defined in
stop()
stop():
void
Request automation stop
Returns
void