Stream Manager Contract
Stream Manager manages the stream approval and creation, validator list, and refunds when necessary.
Per contract creation, contract version is added by constructor.

Validator related functions

Add Validator

1
function addValidator(address v) public onlyOwner
Copied!
Manager can add validators. Function requires that the address was not already added and that it's non-zero address.
Emits event ValidatorAdded

Remove Validator

1
function removeValidator(address v) public onlyOwner
Copied!
Manager can remove validators. Function requires that the address was previously added and that it's non-zero address.
Emits event ValidatorRemoved

Is Validator

1
function isValidator(address v) public view returns (bool)
Copied!
Query whether a certain address is a validator

Stream related functions

Request Stream

1
function requestStream(uint256 streamId, string[] memory profileNames) public returns (uint256)
Copied!
Users can request new streams.
Function requires that the client account has not made a request with the same stream id before and that the array of profiles is non empty.
Upon completion function emits event StreamRequestedand returns Stream ID

Approve stream creation

1
function approveStreamCreation(uint256 streamId) public onlyOwner
Copied!
Manager can review stream requests, add extra data and approve them. Function requires that the request has been registered before.
Emits event StreamApproved

Create Stream

1
function createStream(uint256 streamId) public payable returns (address)
Copied!
After approval the client can create the stream. Also the client needs to fund the stream contract upon creation.
Function requires that the request is approved. Caller is the same account that registered the request and that the stream has not already been created.
Emit event StreamCreated

Add Input Chunk Id

1
function addInputChunkId(uint256 streamId, uint256 chunkId, uint256[] memory wattages) public onlyOwner
Copied!
Registers a new input chunk id with the given stream. Called by manager for now. Method is called as input chunk ids are created.
Function requires that the stream corresponding to this id was already created. The array of wattages/rewards should be non-empty
Emit event InputChunkAdded

End Stream

1
function endStream(uint256 streamId) public
Copied!
Signals that a stream has ended and no more input chunks are available. Can be called by manager or client(owner of the stream).
Function requires that the stream was not already ended.
Emits event StreamEnded

Refunds

Refund Allowed

1
function refundAllowed(uint256 streamId) public view returns (bool)
Copied!
Can query whether a client can refund the coins from a stream contract.

Allow refund

1
function allowRefund(uint256 streamId) public onlyOwner
Copied!
Manager can allow client refunds. Requested stream id must be available.
Emits event RefundAllowed

Revoke Refund

1
function revokeRefund(uint256 streamId) public onlyOwner
Copied!
Manager can revoke refund permission.
Emits event RefundRevoked
Last modified 2yr ago