Files
prime-sdk-go/models/models.go
Andrew Miller 621e359817 Fix Block model to match server: nest header with camelCase keys
The block endpoint returns block id / prev / timestamp nested under a
"header" object with camelCase keys (blockId, dcId, prevId, prevProof,
timestamp) and a proof of just {proof}. The previous flat snake_case
Block fields never matched the response and always deserialized empty.
Add a BlockHeader struct, nest it in Block, and make Proof.Scheme
omitempty. Verified live against a dev chain.
2026-05-29 17:08:47 -04:00

173 lines
4.9 KiB
Go
Executable File

package models
const (
ContentTypeJSON = "application/json"
)
type TransactionCreateRequest struct {
Version string `json:"version,omitempty"`
TxnType string `json:"txn_type"`
Payload string `json:"payload"`
Tag string `json:"tag,omitempty"`
}
type TransactionCreateResponse struct {
TransactionID string `json:"transaction_id"`
}
type TransactionBulkRequest struct {
Transactions []TransactionCreateRequest `json:"transactions"`
}
type TransactionBulkResponse struct {
TransactionIDs []string `json:"transaction_ids"`
}
type TransactionListResponse struct {
TransactionTypes []*TransactionType `json:"transactionTypes"`
}
type Transaction struct {
Version string `json:"version"`
Header TransactionHeader `json:"header"`
Proof TransactionProof `json:"proof"`
Payload string `json:"payload"`
}
type TransactionHeader struct {
Tag string `json:"tag"`
DcId string `json:"dc_id"`
TxnId string `json:"txn_id"`
Invoker string `json:"invoker"`
BlockId string `json:"block_id"`
TxnType string `json:"txn_type"`
Timestamp string `json:"timestamp"`
}
type TransactionProof struct {
Full string `json:"full"`
Stripped string `json:"stripped"`
}
type ListTransactionsResponse struct {
Transactions []Transaction `json:"transactions"`
}
type TransactionTypeCreateRequest struct {
Version string `json:"version,omitempty"`
TxnType string `json:"txn_type"`
}
type TransactionTypeCreateResponse struct {
Success bool `json:"success"`
}
type TransactionType struct {
Version string `json:"version"`
Created int64 `json:"created"`
Modified int64 `json:"modified"`
TxnType string `json:"txn_type"`
ContractID string `json:"contract_id,omitempty"`
CustomIndexes []interface{} `json:"custom_indexes"`
ActiveSinceBlock string `json:"active_since_block"`
}
type SmartContractCreateRequest struct {
Environment string `json:"environment"`
TransactionType string `json:"transactionType"`
ExecutionOrder string `json:"executionOrder"`
EnvironmentVariables map[string]string `json:"environmentVariables,omitempty"`
Secrets map[string]string `json:"secret,omitempty"`
Remote bool `json:"remote,omitempty"`
}
type SmartContractUpdateRequest struct {
Version string `json:"version,omitempty"`
Enabled bool `json:"enabled"`
EnvironmentVariables map[string]string `json:"environmentVariables,omitempty"`
Secrets map[string]string `json:"secret,omitempty"`
}
type SmartContract struct {
Id string `json:"id"`
Created uint64 `json:"created"`
Modified uint64 `json:"modified"`
Version string `json:"version"`
Environment string `json:"environment"`
TransactionType string `json:"transactionType"`
ExecutionOrder string `json:"executionOrder"`
ExecutionInfo *SmartContractExecutionInfo `json:"executionInfo"`
EnvVars map[string]string `json:"envVars"`
Secrets []string `json:"secrets"`
GrpcConnectionInfo *GrpcConnectionInfo `json:"grpcConnectionInfo,omitempty"`
}
type GrpcConnectionInfo struct {
Address string `json:"address"`
ApiKey string `json:"apiKey,omitempty"`
}
type SmartContractExecutionInfo struct {
Type string `json:"type"`
// LocalExecutable type
ExecutablePath string `json:"executablePath"`
ExecutableWorkingDirectory string `json:"executableWorkingDirectory"`
ExecutableHash string `json:"executableHash"`
}
type Block struct {
Version string `json:"version"`
Header BlockHeader `json:"header"`
Transactions []string `json:"transactions"`
Proof BlockProof `json:"proof"`
}
type BlockHeader struct {
BlockId string `json:"blockId"`
DcId string `json:"dcId"`
PrevId string `json:"prevId"`
PrevProof string `json:"prevProof"`
Timestamp string `json:"timestamp"`
}
type BlockProof struct {
Proof string `json:"proof"`
Scheme string `json:"scheme,omitempty"`
Nonce int64 `json:"nonce,omitempty"`
}
type SystemStatus struct {
ID string `json:"id"`
Level int `json:"level"`
URL string `json:"url"`
HashAlgo string `json:"hashAlgo"`
Scheme string `json:"scheme"`
Version string `json:"version"`
EncryptionAlgo string `json:"encryptionAlgo"`
IndexingEnabled bool `json:"indexingEnabled"`
// Level 5 Node
Funded string `json:"funded,omitempty"`
BroadcastInterval string `json:"broadcastInterval,omitempty"`
Network string `json:"network,omitempty"`
InterchainWallet string `json:"interchainWallet,omitempty"`
}
type SuccessResponse struct {
Success bool `json:"success"`
}
type ErrorResponse struct {
Error string `json:"error"`
}
type ListResponse struct {
Items []interface{} `json:"items"`
TotalCount int `json:"total_count"`
}