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"` } // VerificationBlock is a validator's verification of a prime block. type VerificationBlock struct { Version string `json:"version"` PrimeChainId string `json:"primeChainId"` PrimeBlockId string `json:"primeBlockId"` Timestamp string `json:"timestamp"` VerifierPublicKey string `json:"verifierPublicKey"` VerifierSignature string `json:"verifierSignature"` } // InterchainTransaction is an anchor broadcast to a public blockchain (e.g. ETH // or BTC) that bundles one or more validator blocks. ValidatorBlocks holds the // prime block ids covered; CoveredPrimeChainIds the prime chains they belong to. type InterchainTransaction struct { Id int `json:"id"` Version string `json:"version"` Timestamp string `json:"timestamp"` ChainId string `json:"chainId"` TransHash string `json:"transHash"` BlockId string `json:"blockId"` ValidatorBlocks []string `json:"validatorBlocks"` ValidatorBlockhash string `json:"validatorBlockhash"` Signature string `json:"signature"` CoveredPrimeChainIds []string `json:"coveredPrimeChainIds"` } // InterchainTrace links a prime block to the validator (verification) blocks // that validated it and the public-chain interchain anchors those validator // blocks were bundled into. Returned by Transaction.GetInterchain and // Block.GetInterchain. type InterchainTrace struct { BlockId string `json:"blockId"` ValidatorBlocks []VerificationBlock `json:"validatorBlocks"` InterchainTransactions []InterchainTransaction `json:"interchainTransactions"` } // --- proof-measure service (measured immutability / "securedBy") --- // // Decimal-valued fields are transmitted as strings (full precision); timestamps // are int64 unix seconds. // RawMeasure is a network's native cumulative security measure: cumulative // hashes for PoW, stake-seconds for PoS. type RawMeasure struct { Value string `json:"value"` // human-scaled mantissa (e.g. "484.44") Unit string `json:"unit"` // e.g. "Zettahashes", "ETH·s" Base string `json:"base"` // unscaled base amount (hashes or stake-seconds) } // SecurityResult is the security a single network accrued for a window/anchor, // exposed as the raw native measure AND a USD valuation (energy cost for PoW, // staked value for PoS), plus a normalized 0..1 score. type SecurityResult struct { Network string `json:"network"` Consensus string `json:"consensus"` // "pow" | "pos" Raw RawMeasure `json:"raw"` ValueUSD string `json:"valueUsd"` // decimal string ValueUSDFormatted string `json:"valueUsdFormatted"` // e.g. "$1,234.56" Label string `json:"label"` // e.g. "$X energy consumed" / "$X staked" NormalizedScore string `json:"normalizedScore"` // decimal string in [0,1] SinceUnix int64 `json:"since"` // window/anchor start (unix seconds) AsOfUnix int64 `json:"asOf"` // latest sample time (unix seconds) } // ReportAnchorInput is one anchor supplied in a report request. Provide either // Network ("BTC"/"ETH") or the public-chain numeric ChainID; Network wins. type ReportAnchorInput struct { Network string `json:"network,omitempty"` ChainID string `json:"chainId,omitempty"` TxHash string `json:"txHash"` Timestamp int64 `json:"timestamp"` // anchor time, unix seconds } // ReportRequest is the body of ProofMeasure.Report: a transaction's interchain // anchors. The service computes the security each anchor's network accumulated // since the anchor and returns a TransactionReport. type ReportRequest struct { TransactionID string `json:"transactionId"` PrimeID string `json:"primeId"` BlockID string `json:"blockId"` Anchors []ReportAnchorInput `json:"anchors"` } // AnchorSecurity is one interchain anchor with the security its public network // has accumulated since the anchor was placed. type AnchorSecurity struct { Network string `json:"network"` AnchorTimestamp int64 `json:"anchorTimestamp"` // unix seconds AnchorTxHash string `json:"anchorTxHash"` Security SecurityResult `json:"security"` } // HashPower is the combined raw hash power across a report's PoW anchors. type HashPower struct { Value string `json:"value"` Units string `json:"units"` } // TransactionReport is the per-transaction "securedBy" report: every public-chain // anchor covering the transaction's block with both raw and USD security, plus // combined totals. HashPower is nil when there are no PoW anchors. type TransactionReport struct { TransactionID string `json:"transactionId"` PrimeID string `json:"primeId"` BlockID string `json:"blockId"` Anchors []AnchorSecurity `json:"anchors"` TotalValueUSD string `json:"totalValueUsd"` TotalValueUSDFormatted string `json:"totalValueUsdFormatted"` HashPower *HashPower `json:"hashPower"` TotalNormalizedScore string `json:"totalNormalizedScore"` } // HealthResponse is the proof-measure liveness payload. type HealthResponse struct { Status string `json:"status"` }