|
1 | 1 | package humatypes |
2 | 2 |
|
3 | | -import "github.com/Cogwheel-Validator/spectra-gnoland-indexer/pkgs/database" |
| 3 | +import ( |
| 4 | + "time" |
| 5 | + |
| 6 | + "github.com/Cogwheel-Validator/spectra-gnoland-indexer/pkgs/database" |
| 7 | +) |
4 | 8 |
|
5 | 9 | type TransactionGetInput struct { |
6 | | - TxHash string `path:"tx_hash" doc:"Transaction hash (base64url encoded)" required:"true"` |
| 10 | + // tx hash needs to be exactly 44 characters long |
| 11 | + TxHash string `path:"tx_hash" minLength:"44" maxLength:"44" doc:"Transaction hash (base64url encoded)" required:"true"` |
7 | 12 | } |
8 | 13 |
|
9 | 14 | type TransactionBasicGetOutput struct { |
10 | 15 | Body database.Transaction |
11 | 16 | } |
12 | 17 |
|
| 18 | +// TransactionMessage represents a unified transaction message type that can be one of: |
| 19 | +// bank_msg_send, vm_msg_call, vm_msg_add_package, or vm_msg_run |
| 20 | +// not maybe the best implementation, but this one works for now |
| 21 | +// to future me, if you figure out a better way to do this, please do so |
| 22 | +// for now this is good enough |
| 23 | +type TransactionMessage struct { |
| 24 | + // Common fields (always present) |
| 25 | + MessageType string `json:"message_type" doc:"Type of message: bank_msg_send, vm_msg_call, vm_msg_add_package, or vm_msg_run" enum:"bank_msg_send,vm_msg_call,vm_msg_add_package,vm_msg_run"` |
| 26 | + TxHash string `json:"tx_hash" doc:"Transaction hash (base64 encoded)"` |
| 27 | + Timestamp time.Time `json:"timestamp" doc:"Transaction timestamp"` |
| 28 | + Signers []string `json:"signers" doc:"Signers (addresses)"` |
| 29 | + |
| 30 | + // BankSend specific fields |
| 31 | + FromAddress string `json:"from_address,omitempty" doc:"From address (only for bank_msg_send)"` |
| 32 | + ToAddress string `json:"to_address,omitempty" doc:"To address (only for bank_msg_send)"` |
| 33 | + Amount []database.Amount `json:"amount,omitempty" doc:"Amount (only for bank_msg_send)"` |
| 34 | + |
| 35 | + // MsgCall specific fields |
| 36 | + Caller string `json:"caller,omitempty" doc:"Caller address (for vm_msg_call and vm_msg_run)"` |
| 37 | + FuncName string `json:"func_name,omitempty" doc:"Function name (only for vm_msg_call)"` |
| 38 | + Args string `json:"args,omitempty" doc:"Arguments (only for vm_msg_call)"` |
| 39 | + |
| 40 | + // MsgAddPackage and MsgRun specific fields |
| 41 | + Creator string `json:"creator,omitempty" doc:"Creator address (only for vm_msg_add_package)"` |
| 42 | + PkgName string `json:"pkg_name,omitempty" doc:"Package name (for vm_msg_add_package and vm_msg_run)"` |
| 43 | + PkgFileNames []string `json:"pkg_file_names,omitempty" doc:"Package file names (for vm_msg_add_package and vm_msg_run)"` |
| 44 | + |
| 45 | + // Shared fields for vm_* messages |
| 46 | + PkgPath string `json:"pkg_path,omitempty" doc:"Package path (for vm_msg_call, vm_msg_add_package, and vm_msg_run)"` |
| 47 | + Send []database.Amount `json:"send,omitempty" doc:"Send amount (for vm_msg_call, vm_msg_add_package, and vm_msg_run)"` |
| 48 | + MaxDeposit []database.Amount `json:"max_deposit,omitempty" doc:"Max deposit (for vm_msg_call, vm_msg_add_package, and vm_msg_run)"` |
| 49 | +} |
| 50 | + |
13 | 51 | type TransactionMessageGetOutput struct { |
14 | | - Body any // database.MsgRun | database.MsgCall | database.MsgAddPackage | database.BankSend |
| 52 | + Body TransactionMessage |
15 | 53 | } |
0 commit comments