AssetHolder.sol

View Source: contracts/AssetHolder.sol

โ†— Extends: IAssetHolder โ†˜ Derived Contracts: ERC20AssetHolder, ETHAssetHolder, TESTAssetHolder

An implementation of the IAssetHolder interface. The AssetHolder contract escrows ETH or tokens against state channels. It allows assets to be internally accounted for, and ultimately prepared for transfer from one channel to other channel and/or external destinations, as well as for guarantees to be claimed. Note there is no deposit function and the _transferAsset function is unimplemented; inheriting contracts should implement these functions in a manner appropriate to the asset type (e.g. ETH or ERC20 tokens).


Contract Members

Constants & Variables

address public AdjudicatorAddress;
mapping(bytes32 => uint256) public holdings;
mapping(bytes32 => bytes32) public assetOutcomeHashes;

Modifiers

AdjudicatorOnly

modifier AdjudicatorOnly() internal

Arguments

NameTypeDescription

Functions


_transferAll

Transfers the funds escrowed against channelId to the beneficiaries of that channel. No checks performed.

function _transferAll(bytes32 channelId, bytes allocationBytes) internal nonpayable

Arguments

NameTypeDescription
channelIdbytes32Unique identifier for a state channel.
allocationBytesbytesThe abi.encode of AssetOutcome.Allocation

transferAll

Transfers the funds escrowed against channelId to the beneficiaries of that channel. Checks against the storage in this contract.

function transferAll(bytes32 channelId, bytes allocationBytes) public nonpayable

Arguments

NameTypeDescription
channelIdbytes32Unique identifier for a state channel.
allocationBytesbytesThe abi.encode of AssetOutcome.Allocation

transferAllAdjudicatorOnly

Transfers the funds escrowed against channelId to the beneficiaries of that channel. No checks performed against storage in this contract. Permissioned.

function transferAllAdjudicatorOnly(bytes32 channelId, bytes allocationBytes) external nonpayable AdjudicatorOnly

Arguments

NameTypeDescription
channelIdbytes32Unique identifier for a state channel.
allocationBytesbytesThe abi.encode of AssetOutcome.Allocation

claimAll

Transfers the funds escrowed against guarantorChannelId to the beneficiaries of the target of that channel.

function claimAll(bytes32 guarantorChannelId, bytes guaranteeBytes, bytes allocationBytes) public nonpayable

Arguments

NameTypeDescription
guarantorChannelIdbytes32Unique identifier for a guarantor state channel.
guaranteeBytesbytesThe abi.encode of Outcome.Guarantee
allocationBytesbytesThe abi.encode of AssetOutcome.Allocation for the target

_setAssetOutcomeHash

Sets the given assetOutcomeHash for the given channelId in the assetOutcomeHashes storage mapping

function _setAssetOutcomeHash(bytes32 channelId, bytes32 assetOutcomeHash) internal nonpayable

Arguments

NameTypeDescription
channelIdbytes32Unique identifier for a state channel.
assetOutcomeHashbytes32The keccak256 of the abi.encode of the Outcome.

setAssetOutcomeHash

Sets the given assetOutcomeHash for the given channelId in the assetOutcomeHashes storage mapping.

function setAssetOutcomeHash(bytes32 channelId, bytes32 assetOutcomeHash) external nonpayable AdjudicatorOnly
returns(success bool)

Arguments

NameTypeDescription
channelIdbytes32Unique identifier for a state channel.
assetOutcomeHashbytes32The keccak256 of the abi.encode of the Outcome.

_transferAsset

Transfers the given amount of this AssetHolders's asset type to a supplied ethereum address.

function _transferAsset(address payable destination, uint256 amount) internal nonpayable

Arguments

NameTypeDescription
destinationaddress payableethereum address to be credited.
amountuint256Quantity of assets to be transferred.

_isExternalDestination

Checks if a given destination is external (and can therefore have assets transferred to it) or not.

function _isExternalDestination(bytes32 destination) internal pure
returns(bool)

Returns

True if the destination is external, false otherwise.

Arguments

NameTypeDescription
destinationbytes32Destination to be checked.

_addressToBytes32

Converts an ethereum address to a nitro external destination.

function _addressToBytes32(address participant) internal pure
returns(bytes32)

Returns

The input address left-padded with zeros.

Arguments

NameTypeDescription
participantaddressThe address to be converted.

_bytes32ToAddress

Converts a nitro destination to an ethereum address.

function _bytes32ToAddress(bytes32 destination) internal pure
returns(address payable)

Returns

The rightmost 160 bits of the input string.

Arguments

NameTypeDescription
destinationbytes32The destination to be converted.
Last updated on by geoknee