Skip to content

Commit 1d271aa

Browse files
authored
pkg/types/aptos: move CR/CW types from aptos repo (#1307)
1 parent 99c1fc5 commit 1d271aa

File tree

2 files changed

+115
-0
lines changed

2 files changed

+115
-0
lines changed

pkg/types/aptos/contract_reader.go

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

pkg/types/aptos/contract_writer.go

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package aptos
2+
3+
type FeeStrategy int
4+
5+
const (
6+
DeprioritizedFeeStrategy FeeStrategy = -1
7+
DefaultFeeStrategy FeeStrategy = 0
8+
PrioritizedFeeStrategy FeeStrategy = 1
9+
)
10+
11+
type ContractWriterConfig struct {
12+
Modules map[string]*ContractWriterModule
13+
FeeStrategy FeeStrategy
14+
}
15+
16+
type ContractWriterModule struct {
17+
// The module name (optional). When not provided, the key in the map under which this module
18+
// is stored is used.
19+
Name string
20+
Functions map[string]*ContractWriterFunction
21+
}
22+
23+
type ContractWriterFunction struct {
24+
// The function name (optional). When not provided, the key in the map under which this function
25+
// is stored is used.
26+
Name string
27+
// The public key of the sending account.
28+
PublicKey string
29+
// The account address (optional). When not provided, the address is calculated
30+
// from the public key.
31+
FromAddress string
32+
Params []FunctionParam
33+
}

0 commit comments

Comments
 (0)