131 lines
5.2 KiB
Go
131 lines
5.2 KiB
Go
package state
|
|
|
|
import (
|
|
"github.com/tutus-one/tutus-chain/pkg/util"
|
|
)
|
|
|
|
// AgreementStatus represents the status of a bilateral agreement.
|
|
type AgreementStatus uint8
|
|
|
|
// Agreement status constants.
|
|
const (
|
|
AgreementPending AgreementStatus = 0
|
|
AgreementActive AgreementStatus = 1
|
|
AgreementSuspended AgreementStatus = 2
|
|
AgreementTerminated AgreementStatus = 3
|
|
)
|
|
|
|
// AgreementType represents the type of bilateral agreement.
|
|
type AgreementType uint8
|
|
|
|
// Agreement type constants.
|
|
const (
|
|
AgreementTypeGeneral AgreementType = 0 // General cooperation
|
|
AgreementTypeIdentity AgreementType = 1 // Identity verification
|
|
AgreementTypeSettlement AgreementType = 2 // VTS settlement
|
|
AgreementTypeEducation AgreementType = 3 // Education credential sharing
|
|
AgreementTypeHealthcare AgreementType = 4 // Healthcare record sharing
|
|
AgreementTypeComprehensive AgreementType = 5 // All services
|
|
)
|
|
|
|
// VerificationStatus represents the status of a verification request.
|
|
type VerificationStatus uint8
|
|
|
|
// Verification status constants.
|
|
const (
|
|
VerificationPending VerificationStatus = 0
|
|
VerificationApproved VerificationStatus = 1
|
|
VerificationRejected VerificationStatus = 2
|
|
VerificationExpired VerificationStatus = 3
|
|
)
|
|
|
|
// VerificationType represents the type of verification request.
|
|
type VerificationType uint8
|
|
|
|
// Verification type constants.
|
|
const (
|
|
VerificationTypeIdentity VerificationType = 0 // Identity verification
|
|
VerificationTypeCredential VerificationType = 1 // Education credential
|
|
VerificationTypeHealth VerificationType = 2 // Healthcare record
|
|
VerificationTypeCertificate VerificationType = 3 // Professional certificate
|
|
)
|
|
|
|
// SettlementStatus represents the status of a settlement request.
|
|
type SettlementStatus uint8
|
|
|
|
// Settlement status constants.
|
|
const (
|
|
SettlementPending SettlementStatus = 0
|
|
SettlementCompleted SettlementStatus = 1
|
|
SettlementRejected SettlementStatus = 2
|
|
SettlementCancelled SettlementStatus = 3
|
|
)
|
|
|
|
// BilateralAgreement represents an agreement between two sovereign chains.
|
|
type BilateralAgreement struct {
|
|
ID uint64 // Unique agreement ID
|
|
LocalChainID uint32 // This chain's ID
|
|
RemoteChainID uint32 // Partner chain's ID
|
|
AgreementType AgreementType // Type of agreement
|
|
Status AgreementStatus
|
|
Terms util.Uint256 // Hash of off-chain terms document
|
|
EffectiveDate uint32 // Block height when effective
|
|
ExpirationDate uint32 // Block height when expires (0 = no expiry)
|
|
CreatedAt uint32 // Block height when created
|
|
UpdatedAt uint32 // Last update block height
|
|
}
|
|
|
|
// VerificationRequest represents a cross-border verification request.
|
|
type VerificationRequest struct {
|
|
ID uint64 // Unique request ID
|
|
RequestingChain uint32 // Chain requesting verification
|
|
TargetChain uint32 // Chain being queried
|
|
Subject util.Uint160 // Subject of verification
|
|
VerificationType VerificationType
|
|
DataHash util.Uint256 // Hash of requested data
|
|
Status VerificationStatus
|
|
ResponseHash util.Uint256 // Hash of response data (if any)
|
|
Requester util.Uint160 // Who initiated request
|
|
CreatedAt uint32 // Block height
|
|
ExpiresAt uint32 // Request expiry
|
|
RespondedAt uint32 // When responded (0 = pending)
|
|
}
|
|
|
|
// SettlementRequest represents an international VTS settlement request.
|
|
type SettlementRequest struct {
|
|
ID uint64 // Unique request ID
|
|
FromChain uint32 // Originating chain
|
|
ToChain uint32 // Destination chain
|
|
Sender util.Uint160 // Sender on from chain
|
|
Receiver util.Uint160 // Receiver on to chain
|
|
Amount uint64 // VTS amount (in smallest units)
|
|
Reference string // Payment reference
|
|
Status SettlementStatus
|
|
CreatedAt uint32 // Block height
|
|
SettledAt uint32 // When settled (0 = pending)
|
|
TxHash util.Uint256 // Settlement transaction hash
|
|
}
|
|
|
|
// CredentialShare represents a shared credential between chains.
|
|
type CredentialShare struct {
|
|
ID uint64 // Unique share ID
|
|
SourceChain uint32 // Chain where credential originated
|
|
TargetChain uint32 // Chain receiving credential
|
|
Owner util.Uint160 // Credential owner
|
|
CredentialType VerificationType
|
|
CredentialID uint64 // Original credential ID on source chain
|
|
ContentHash util.Uint256 // Hash of credential content
|
|
ValidUntil uint32 // Validity period on target chain
|
|
CreatedAt uint32 // Block height
|
|
IsRevoked bool // Has been revoked
|
|
}
|
|
|
|
// PonsConfig represents configurable parameters for the Pons contract.
|
|
type PonsConfig struct {
|
|
LocalChainID uint32 // This chain's unique identifier
|
|
VerificationTimeout uint32 // Blocks until verification request expires
|
|
SettlementTimeout uint32 // Blocks until settlement request expires
|
|
MaxPendingRequests uint64 // Maximum pending requests per chain
|
|
CredentialShareExpiry uint32 // Default validity period for shared credentials
|
|
}
|