import”@patchwork/contracts/PatchworkLiteRef/IPatchworkLiteRef.sol”;

Functions


registerReferenceAddress

Registers a reference address
function registerReferenceAddress(address addr) external returns (uint8 id);
Parameters
NameTypeDescription
addraddressAddress to register
Returns
NameTypeDescription
iduint8ID assigned to the address

getReferenceId

Gets the ID assigned to the address from registration
function getReferenceId(address addr) external view returns (uint8 id, bool redacted);
Parameters
NameTypeDescription
addraddressRegistered address
Returns
NameTypeDescription
iduint8ID assigned to the address
redactedboolRedacted status

getReferenceAddress

Gets the address assigned to this id
function getReferenceAddress(uint8 id) external view returns (address addr, bool redacted);
Parameters
NameTypeDescription
iduint8ID assigned to the address
Returns
NameTypeDescription
addraddressRegistered address
redactedboolRedacted status

redactReferenceAddress

Redacts a reference address
function redactReferenceAddress(uint8 id) external;
Parameters
NameTypeDescription
iduint8ID of the address to redact

unredactReferenceAddress

Unredacts a reference address
function unredactReferenceAddress(uint8 id) external;
Parameters
NameTypeDescription
iduint8ID of the address to unredact

getLiteReference

Returns a lite reference for a given address and token ID
function getLiteReference(address addr, uint256 tokenId) external view returns (uint64 liteRef, bool redacted);
Parameters
NameTypeDescription
addraddressAddress to get reference for
tokenIduint256ID of the token
Returns
NameTypeDescription
liteRefuint64Lite reference
redactedboolRedacted status

getReferenceAddressAndTokenId

Returns an address and token ID for a given lite reference
function getReferenceAddressAndTokenId(uint64 liteRef) external view returns (address addr, uint256 tokenId);
Parameters
NameTypeDescription
liteRefuint64Lite reference to get address and token ID for
Returns
NameTypeDescription
addraddressAddress
tokenIduint256Token ID

addReference

Adds a reference to a token
function addReference(uint256 tokenId, uint64 liteRef) external;
Parameters
NameTypeDescription
tokenIduint256ID of the token
liteRefuint64LiteRef to add

addReference

Adds a reference to a token
function addReference(uint256 tokenId, uint64 liteRef, uint256 targetMetadataId) external;
Parameters
NameTypeDescription
tokenIduint256ID of the token
liteRefuint64LiteRef to add
targetMetadataIduint256The metadata ID on the target to assign to

addReferenceBatch

Adds multiple references to a token
function addReferenceBatch(uint256 tokenId, uint64[] calldata liteRefs) external;
Parameters
NameTypeDescription
tokenIduint256ID of the token
liteRefsuint64[]Array of lite references to add

addReferenceBatch

Adds multiple references to a token
function addReferenceBatch(uint256 tokenId, uint64[] calldata liteRefs, uint256 targetMetadataId) external;
Parameters
NameTypeDescription
tokenIduint256ID of the token
liteRefsuint64[]Array of lite references to add
targetMetadataIduint256The metadata ID on the target to assign to

removeReference

Removes a reference from a token
function removeReference(uint256 tokenId, uint64 liteRef) external;
Parameters
NameTypeDescription
tokenIduint256ID of the token
liteRefuint64Lite reference to remove

removeReference

Removes a reference from a token
function removeReference(uint256 tokenId, uint64 liteRef, uint256 targetMetadataId) external;
Parameters
NameTypeDescription
tokenIduint256ID of the token
liteRefuint64Lite reference to remove
targetMetadataIduint256The metadata ID on the target to unassign from

loadReferenceAddressAndTokenId

Loads a reference address and token ID at a given index
function loadReferenceAddressAndTokenId(uint256 ourTokenId, uint256 idx)
    external
    view
    returns (address addr, uint256 tokenId);
Parameters
NameTypeDescription
ourTokenIduint256ID of the token
idxuint256Index to load from
Returns
NameTypeDescription
addraddressAddress
tokenIduint256Token ID

loadAllStaticReferences

Loads all static references for a given token ID
function loadAllStaticReferences(uint256 tokenId)
    external
    view
    returns (address[] memory addresses, uint256[] memory tokenIds);
Parameters
NameTypeDescription
tokenIduint256ID of the token
Returns
NameTypeDescription
addressesaddress[]Array of addresses
tokenIdsuint256[]Array of token IDs

getDynamicReferenceCount

Count all dynamic references for a given token ID
function getDynamicReferenceCount(uint256 tokenId) external view returns (uint256 count);
Parameters
NameTypeDescription
tokenIduint256ID of the token
Returns
NameTypeDescription
countuint256the number of dynamic references

loadDynamicReferencePage

Load a page of dynamic references for a given token ID
function loadDynamicReferencePage(uint256 tokenId, uint256 offset, uint256 count)
    external
    view
    returns (address[] memory addresses, uint256[] memory tokenIds);
Parameters
NameTypeDescription
tokenIduint256ID of the token
offsetuint256The starting offset 0-indexed
countuint256The maximum number of references to return
Returns
NameTypeDescription
addressesaddress[]An array of reference addresses
tokenIdsuint256[]An array of reference token IDs

Events

Redact

Emitted when a contract redacts a fragment
event Redact(address indexed target, address indexed fragment);
Parameters
NameTypeDescription
targetaddressthe contract which issued the redaction
fragmentaddressthe fragment that was redacted

Unredact

Emitted when a contract unredacts a fragment
event Unredact(address indexed target, address indexed fragment);
Parameters
NameTypeDescription
targetaddressthe contract which revoked the redaction
fragmentaddressthe fragment that was unredacted

Register

Emitted when a contract registers a fragment
event Register(address indexed target, address indexed fragment, uint8 idx);
Parameters
NameTypeDescription
targetaddressthe contract that registered the fragment
fragmentaddressthe fragment that was registered
idxuint8the idx of the literef