Skip to content

Assets

Assets

ERC721

bytes4 ERC721

ERC1155

bytes4 ERC1155

ASSET_ID_TYPEHASH

bytes32 ASSET_ID_TYPEHASH

ASSET_TYPEHASH

bytes32 ASSET_TYPEHASH

AssetIsAlreadyRegistered

error AssetIsAlreadyRegistered(address asset)

Thrown upon attempting to register an asset twice.

Name Type Description
asset address Duplicate asset address.

AssetIsNotRegistered

error AssetIsNotRegistered(address asset)

Thrown when target for operation asset is not registered

Name Type Description
asset address Asset address, which is not registered.

AssetId

struct AssetId {
  bytes4 class;
  bytes data;
}

hash

function hash(struct Assets.AssetId assetId) internal pure returns (bytes32)

Calculates Asset ID hash

token

function token(struct Assets.AssetId self) internal pure returns (address)

Extracts token contract address from the Asset ID structure. The address is the common attribute for all assets regardless of their asset class.

hash

function hash(struct Assets.AssetId[] assetIds) internal pure returns (bytes32)

Asset

struct Asset {
  struct Assets.AssetId id;
  uint256 value;
}

hash

function hash(struct Assets.Asset asset) internal pure returns (bytes32)

Calculates Asset hash

token

function token(struct Assets.Asset self) internal pure returns (address)

Extracts token contract address from the Asset structure. The address is the common attribute for all assets regardless of their asset class.

toIds

function toIds(struct Assets.Asset[] assets) internal pure returns (struct Assets.AssetId[] result)

hashIds

function hashIds(struct Assets.Asset[] assets) internal pure returns (bytes32)

AssetConfig

struct AssetConfig {
  contract IAssetController controller;
  bytes4 assetClass;
  contract IAssetVault vault;
}

Registry

struct Registry {
  contract IAssetClassRegistry classRegistry;
  struct EnumerableSetUpgradeable.AddressSet assetIndex;
  mapping(address => struct Assets.AssetConfig) assets;
}

registerAsset

function registerAsset(struct Assets.Registry self, bytes4 assetClass, address asset) external

Registers new asset.

supportedAssets

function supportedAssets(struct Assets.Registry self, uint256 offset, uint256 limit) external view returns (address[], struct Assets.AssetConfig[])

Returns the paginated list of currently registered asset configs.

transferAssetToVault

function transferAssetToVault(struct Assets.Registry self, struct Assets.Asset asset, address from) external

Transfers an asset to the vault using associated controller.

returnAssetFromVault

function returnAssetFromVault(struct Assets.Registry self, struct Assets.Asset asset) external

Transfers an asset from the vault using associated controller.

assetCount

function assetCount(struct Assets.Registry self) internal view returns (uint256)

isRegisteredAsset

function isRegisteredAsset(struct Assets.Registry self, address asset) internal view returns (bool)

Checks asset registration by address.

assetClassController

function assetClassController(struct Assets.Registry self, bytes4 assetClass) internal view returns (address)

Returns controller for asset class.

Name Type Description
self struct Assets.Registry
assetClass bytes4 Asset class ID.