Dynamic primitives
This primitive allows registering new extensions in runtime, without changing the configuration files. These are triggered by a generic smart contract event. A use-case for this would be a factory contract.
Currently the dynamic extensions can be one of:
Configuration
ERC721 example
# extensions.yaml
extensions:
- name: "Dynamic erc721"
type: "dynamic-primitive"
startBlockHeight: 100
contractAddress: "0x5FbDB2315678afecb367f032d93F642f64180aa3"
eventSignature: "ERC721Created(address)"
abiPath: "./FactoryERC721.json"
targetConfig:
type: "erc721"
scheduledPrefix: "nft"
burnScheduledPrefix: "nftburn"
dynamicFields:
contractAddress: nftAddress
Meaning
There are two type of fields in this configuration. The top level fields are used for the extension that have the role of monitoring the network for the trigger event. These are the following:
contractAdress
is the address of the smart contract that will emit the event that will trigger the erc721 primitive creation.abiPath
, specifying a path to a .json file describing the compiled contract – the only field required in this file is theabi
field in the top-level object;eventSignature
, specifying the signature of the event consisting only of the event name followed by parameter types (without names) in order, enclosed in parentheses and separated by commas.
The nested fields instead are used to construct the configuration for the
dynamically generated extensions. It's divided into a static part, which is in
targetConfig
. And a dynamic part which is in dynamicFields
. Dynamic in this
context means that it depends on the data included on the emitted event.
Static configuration
-
scheduledPrefix
is the prefix used for the events emitted by the dynamic extensions. This primitive won't emit events by itself. -
For the erc721 case, there is also
burnScheduledPrefix
, for which the comment above also applies. -
For the generic primitive the
targetConfig
field would look like this instead:
targetConfig:
type: "generic"
abiPath: "./abis/MyCustomContract.json"
eventSignature: "MyEvent(address,uint256)"
scheduledPrefix: "cst"