|
| 1 | +package aptos |
| 2 | + |
| 3 | +import ( |
| 4 | + "time" |
| 5 | + |
| 6 | + "github.com/smartcontractkit/chainlink-common/pkg/types" |
| 7 | +) |
| 8 | + |
| 9 | +type ChainReaderConfig struct { |
| 10 | + IsLoopPlugin bool |
| 11 | + Modules map[string]*ChainReaderModule |
| 12 | + |
| 13 | + EventSyncInterval time.Duration |
| 14 | + EventSyncTimeout time.Duration |
| 15 | + |
| 16 | + TxSyncInterval time.Duration |
| 17 | + TxSyncTimeout time.Duration |
| 18 | +} |
| 19 | + |
| 20 | +type ChainReaderModule struct { |
| 21 | + // The module name (optional). When not provided, the key in the map under which this module |
| 22 | + // is stored is used. |
| 23 | + Name string |
| 24 | + Functions map[string]*ChainReaderFunction |
| 25 | + Events map[string]*ChainReaderEvent |
| 26 | +} |
| 27 | + |
| 28 | +type ChainReaderFunction struct { |
| 29 | + // The function name (optional). When not provided, the key in the map under which this function |
| 30 | + // is stored is used. |
| 31 | + Name string |
| 32 | + Params []FunctionParam |
| 33 | + |
| 34 | + ResultFieldRenames map[string]RenamedField |
| 35 | + ResultTupleToStruct []string |
| 36 | + ResultUnwrapStruct []string |
| 37 | +} |
| 38 | + |
| 39 | +type FunctionParam struct { |
| 40 | + // The function parameter name. |
| 41 | + Name string |
| 42 | + // The function parameter Move type. |
| 43 | + Type string |
| 44 | + // True if this is a required parameter, false otherwise. |
| 45 | + Required bool |
| 46 | + // If this is not a required parameter and it is not provided, this default value will be used. |
| 47 | + DefaultValue any |
| 48 | +} |
| 49 | + |
| 50 | +type ChainReaderEvent struct { |
| 51 | + // The struct where the event handle is defined. |
| 52 | + EventHandleStructName string |
| 53 | + |
| 54 | + // The name of the event handle field. |
| 55 | + // This field can be defined as path to the nested |
| 56 | + // struct that stores the event, e.g. "token_pool_state.burned_events" |
| 57 | + EventHandleFieldName string |
| 58 | + |
| 59 | + // The event account address. |
| 60 | + // This field can be defined in several ways: |
| 61 | + // - Empty string, which means the event account address is the address of the bound contract. |
| 62 | + // - An exact address hex string (eg. 0x1234 or 1234) containing the events. |
| 63 | + // - A fully qualified function name (eg. 0x1234::my_contract::get_event_address) which |
| 64 | + // takes no parameters and returns the actual event account address. |
| 65 | + // - A name containing the module name and function name components |
| 66 | + // (eg. my_first_contract::get_event_address) stored at the address of the bound contract, |
| 67 | + // which takes no parameters and returns the actual event account address. |
| 68 | + EventAccountAddress string |
| 69 | + |
| 70 | + // Renames of event field names (optional). When not provided, the field names are used as-is. |
| 71 | + EventFieldRenames map[string]RenamedField |
| 72 | + |
| 73 | + // Renames provided filters to match the event field names (optional). When not provided, the filters are used as-is. |
| 74 | + EventFilterRenames map[string]string |
| 75 | +} |
| 76 | + |
| 77 | +type RenamedField struct { |
| 78 | + // The new field name (optional). This does not need to be provided if this field does not need |
| 79 | + // to be renamed. |
| 80 | + NewName string |
| 81 | + |
| 82 | + // Rename sub-fields. This assumes that the event field value is a struct or a map with string keys. |
| 83 | + SubFieldRenames map[string]RenamedField |
| 84 | +} |
| 85 | + |
| 86 | +type SequenceWithMetadata struct { |
| 87 | + Sequence types.Sequence |
| 88 | + TxVersion uint64 |
| 89 | + TxHash string |
| 90 | +} |
0 commit comments