# 数据类型

本节为 OCAP 客户端 API 中使用的所有自定义数据结构、输入参数和响应对象提供了全面的参考。理解这些类型对于有效与 OCAP 区块链交互至关重要。


## 核心类型

这些是在各种 API 调用中使用的基本数据结构。

### Any

Protobuf 消息的通用容器，允许灵活的数据结构。

<x-field-group>
  <x-field data-name="typeUrl" data-type="string" data-desc="一个类似 URL 的字符串，用于唯一标识序列化消息的类型。"></x-field>
  <x-field data-name="value" data-type="string" data-desc="序列化后的消息内容，为字符串格式。"></x-field>
</x-field-group>

### Multisig

表示一个多重签名，常用于需要多个批准的交易。

<x-field-group>
  <x-field data-name="signer" data-type="string" data-desc="签名者的地址。"></x-field>
  <x-field data-name="pk" data-type="string" data-desc="签名者的公钥。"></x-field>
  <x-field data-name="signature" data-type="string" data-desc="由签名者生成的签名。"></x-field>
  <x-field data-name="delegator" data-type="string" data-desc="如果签名是委托的，则为委托人的地址。"></x-field>
  <x-field data-name="data" data-type="Any" data-desc="与签名相关的可选任意数据。"></x-field>
</x-field-group>

### PageInfo

包含基于列表的查询响应的分页详情。

<x-field-group>
  <x-field data-name="cursor" data-type="string" data-desc="用于获取下一页结果的游标。"></x-field>
  <x-field data-name="next" data-type="boolean" data-desc="指示是否有下一页结果可用。"></x-field>
  <x-field data-name="total" data-type="number" data-desc="与查询匹配的项目总数。"></x-field>
</x-field-group>

### StateContext

提供关于状态对象的创建和最后修改的上下文信息。

<x-field-group>
  <x-field data-name="genesisTx" data-type="TransactionInfo" data-desc="创建此状态对象的交易。"></x-field>
  <x-field data-name="renaissanceTx" data-type="TransactionInfo" data-desc="上次更新此状态对象的交易。"></x-field>
  <x-field data-name="genesisTime" data-type="string" data-desc="状态对象被创建时的时间戳。"></x-field>
  <x-field data-name="renaissanceTime" data-type="string" data-desc="状态对象上次更新时的时间戳。"></x-field>
</x-field-group>

### 钱包对象

这些类型定义了用于签署交易的钱包的结构。

#### WalletObject

<x-field-group>
  <x-field data-name="publicKey" data-type="string"></x-field>
  <x-field data-name="secretKey" data-type="string"></x-field>
  <x-field data-name="type" data-type="WalletTypeObject"></x-field>
</x-field-group>

#### WalletTypeObject

<x-field-group>
  <x-field data-name="pk" data-type="number"></x-field>
  <x-field data-name="role" data-type="number"></x-field>
  <x-field data-name="hash" data-type="number"></x-field>
  <x-field data-name="address" data-type="number" data-desc="默认为 base58btc"></x-field>
</x-field-group>

#### WalletType

<x-field-group>
  <x-field data-name="pk" data-type="KeyType"></x-field>
  <x-field data-name="hash" data-type="HashType"></x-field>
  <x-field data-name="address" data-type="EncodingType"></x-field>
  <x-field data-name="role" data-type="RoleType"></x-field>
</x-field-group>


## 输入与筛选类型

这些对象用于为 GraphQL 查询提供参数和筛选器。

### 通用筛选输入

<x-field-group>
  <x-field data-name="AccountFilterInput" data-type="object">
    <x-field data-name="accounts" data-type="array<string>"></x-field>
  </x-field>
  <x-field data-name="AddressFilterInput" data-type="object">
    <x-field data-name="sender" data-type="string"></x-field>
    <x-field data-name="receiver" data-type="string"></x-field>
    <x-field data-name="direction" data-type="Direction"></x-field>
  </x-field>
  <x-field data-name="AssetFilterInput" data-type="object">
    <x-field data-name="assets" data-type="array<string>"></x-field>
  </x-field>
  <x-field data-name="DelegationFilterInput" data-type="object">
    <x-field data-name="delegations" data-type="array<string>"></x-field>
  </x-field>
  <x-field data-name="FactoryFilterInput" data-type="object">
    <x-field data-name="factories" data-type="array<string>"></x-field>
  </x-field>
  <x-field data-name="RangeFilterInput" data-type="object">
    <x-field data-name="from" data-type="string"></x-field>
    <x-field data-name="to" data-type="string"></x-field>
  </x-field>
  <x-field data-name="RollupFilterInput" data-type="object">
    <x-field data-name="rollups" data-type="array<string>"></x-field>
  </x-field>
  <x-field data-name="StakeFilterInput" data-type="object">
    <x-field data-name="stakes" data-type="array<string>"></x-field>
  </x-field>
  <x-field data-name="TimeFilterInput" data-type="object">
    <x-field data-name="startDateTime" data-type="string"></x-field>
    <x-field data-name="endDateTime" data-type="string"></x-field>
    <x-field data-name="field" data-type="string"></x-field>
  </x-field>
  <x-field data-name="TokenFactoryFilterInput" data-type="object">
    <x-field data-name="tokenFactories" data-type="array<string>"></x-field>
  </x-field>
  <x-field data-name="TokenFilterInput" data-type="object">
    <x-field data-name="tokens" data-type="array<string>"></x-field>
  </x-field>
  <x-field data-name="TxFilterInput" data-type="object">
    <x-field data-name="txs" data-type="array<string>"></x-field>
  </x-field>
  <x-field data-name="TypeFilterInput" data-type="object">
    <x-field data-name="types" data-type="array<string>"></x-field>
  </x-field>
  <x-field data-name="ValidatorFilterInput" data-type="object">
    <x-field data-name="validators" data-type="array<string>"></x-field>
  </x-field>
  <x-field data-name="ValidityFilterInput" data-type="object">
    <x-field data-name="validity" data-type="Validity"></x-field>
  </x-field>
</x-field-group>

### 分页输入

#### PageInput

<x-field-group>
  <x-field data-name="cursor" data-type="string"></x-field>
  <x-field data-name="size" data-type="number"></x-field>
  <x-field data-name="order" data-type="array<PageOrderInput>"></x-field>
</x-field-group>

#### PageOrderInput

<x-field-group>
  <x-field data-name="field" data-type="string"></x-field>
  <x-field data-name="type" data-type="string"></x-field>
</x-field-group>

### 特定请求的输入

这些对象被用作特定查询和变更方法的参数。

<x-field-group>
  <x-field data-name="RequestEstimateGasInput" data-type="object">
    <x-field data-name="typeUrl" data-type="string"></x-field>
    <x-field data-name="tx" data-type="string"></x-field>
  </x-field>
  <x-field data-name="RequestGetAccountStateInput" data-type="object">
    <x-field data-name="address" data-type="string"></x-field>
    <x-field data-name="keys" data-type="array<string>"></x-field>
    <x-field data-name="height" data-type="number"></x-field>
    <x-field data-name="traceMigration" data-type="boolean"></x-field>
  </x-field>
  <x-field data-name="RequestGetAccountTokensInput" data-type="object">
    <x-field data-name="address" data-type="string"></x-field>
    <x-field data-name="token" data-type="string"></x-field>
  </x-field>
  <x-field data-name="RequestGetBlockInput" data-type="object">
    <x-field data-name="height" data-type="number"></x-field>
  </x-field>
  <x-field data-name="RequestGetBlocksInput" data-type="object">
    <x-field data-name="paging" data-type="PageInput"></x-field>
    <x-field data-name="heightFilter" data-type="RangeFilterInput"></x-field>
    <x-field data-name="emptyExcluded" data-type="boolean"></x-field>
  </x-field>
  <x-field data-name="RequestListTransactionsInput" data-type="object">
    <x-field data-name="paging" data-type="PageInput"></x-field>
    <x-field data-name="timeFilter" data-type="TimeFilterInput"></x-field>
    <x-field data-name="addressFilter" data-type="AddressFilterInput"></x-field>
    <x-field data-name="typeFilter" data-type="TypeFilterInput"></x-field>
    <x-field data-name="validityFilter" data-type="ValidityFilterInput"></x-field>
    <x-field data-name="factoryFilter" data-type="FactoryFilterInput"></x-field>
    <x-field data-name="tokenFilter" data-type="TokenFilterInput"></x-field>
    <x-field data-name="assetFilter" data-type="AssetFilterInput"></x-field>
    <x-field data-name="accountFilter" data-type="AccountFilterInput"></x-field>
    <x-field data-name="txFilter" data-type="TxFilterInput"></x-field>
    <x-field data-name="rollupFilter" data-type="RollupFilterInput"></x-field>
    <x-field data-name="stakeFilter" data-type="StakeFilterInput"></x-field>
    <x-field data-name="delegationFilter" data-type="DelegationFilterInput"></x-field>
    <x-field data-name="tokenFactoryFilter" data-type="TokenFactoryFilterInput"></x-field>
  </x-field>
</x-field-group>


## 状态对象

这些类型表示区块链上各种实体（如账户、资产和通证）的状态。

### AccountState

表示用户账户的状态。

<x-field-group>
  <x-field data-name="balance" data-type="string"></x-field>
  <x-field data-name="nonce" data-type="string"></x-field>
  <x-field data-name="numTxs" data-type="string"></x-field>
  <x-field data-name="address" data-type="string"></x-field>
  <x-field data-name="pk" data-type="string"></x-field>
  <x-field data-name="type" data-type="WalletType"></x-field>
  <x-field data-name="moniker" data-type="string"></x-field>
  <x-field data-name="context" data-type="StateContext"></x-field>
  <x-field data-name="issuer" data-type="string"></x-field>
  <x-field data-name="gasBalance" data-type="string"></x-field>
  <x-field data-name="migratedTo" data-type="array<string>"></x-field>
  <x-field data-name="migratedFrom" data-type="array<string>"></x-field>
  <x-field data-name="numAssets" data-type="string"></x-field>
  <x-field data-name="tokens" data-type="array<IndexedTokenInput>"></x-field>
  <x-field data-name="data" data-type="Any"></x-field>
</x-field-group>

### AssetState

表示一个非同质化资产（NFT）的状态。

<x-field-group>
  <x-field data-name="address" data-type="string"></x-field>
  <x-field data-name="owner" data-type="string"></x-field>
  <x-field data-name="moniker" data-type="string"></x-field>
  <x-field data-name="readonly" data-type="boolean"></x-field>
  <x-field data-name="transferrable" data-type="boolean"></x-field>
  <x-field data-name="ttl" data-type="number"></x-field>
  <x-field data-name="consumedTime" data-type="string"></x-field>
  <x-field data-name="issuer" data-type="string"></x-field>
  <x-field data-name="parent" data-type="string"></x-field>
  <x-field data-name="endpoint" data-type="NFTEndpoint"></x-field>
  <x-field data-name="display" data-type="NFTDisplay"></x-field>
  <x-field data-name="tags" data-type="array<string>"></x-field>
  <x-field data-name="context" data-type="StateContext"></x-field>
  <x-field data-name="data" data-type="Any"></x-field>
</x-field-group>

### AssetFactoryState

表示资产工厂的状态，该工厂用于铸造新资产。

<x-field-group>
  <x-field data-name="address" data-type="string"></x-field>
  <x-field data-name="owner" data-type="string"></x-field>
  <x-field data-name="name" data-type="string"></x-field>
  <x-field data-name="description" data-type="string"></x-field>
  <x-field data-name="settlement" data-type="string"></x-field>
  <x-field data-name="limit" data-type="number"></x-field>
  <x-field data-name="trustedIssuers" data-type="array<string>"></x-field>
  <x-field data-name="input" data-type="IndexedFactoryInput"></x-field>
  <x-field data-name="output" data-type="CreateAssetTx"></x-field>
  <x-field data-name="hooks" data-type="array<AssetFactoryHook>"></x-field>
  <x-field data-name="data" data-type="Any"></x-field>
  <x-field data-name="context" data-type="StateContext"></x-field>
  <x-field data-name="balance" data-type="string"></x-field>
  <x-field data-name="tokens" data-type="array<IndexedTokenInput>"></x-field>
  <x-field data-name="numMinted" data-type="number"></x-field>
  <x-field data-name="display" data-type="NFTDisplay"></x-field>
  <x-field data-name="lastSettlement" data-type="string"></x-field>
</x-field-group>

### DelegateState

表示委托的状态，即一个账户授权另一个账户代表其执行操作。

<x-field-group>
  <x-field data-name="address" data-type="string"></x-field>
  <x-field data-name="ops" data-type="array<DelegateState_OpsEntry>"></x-field>
  <x-field data-name="from" data-type="string"></x-field>
  <x-field data-name="to" data-type="string"></x-field>
  <x-field data-name="context" data-type="StateContext"></x-field>
  <x-field data-name="data" data-type="Any"></x-field>
</x-field-group>

### StakeState

表示质押的状态，可能涉及通证或资产。

<x-field-group>
  <x-field data-name="address" data-type="string"></x-field>
  <x-field data-name="sender" data-type="string"></x-field>
  <x-field data-name="receiver" data-type="string"></x-field>
  <x-field data-name="tokens" data-type="array<IndexedTokenInput>"></x-field>
  <x-field data-name="assets" data-type="array<string>"></x-field>
  <x-field data-name="revocable" data-type="boolean"></x-field>
  <x-field data-name="message" data-type="string"></x-field>
  <x-field data-name="revokeWaitingPeriod" data-type="number"></x-field>
  <x-field data-name="revokedTokens" data-type="array<IndexedTokenInput>"></x-field>
  <x-field data-name="revokedAssets" data-type="array<string>"></x-field>
  <x-field data-name="slashers" data-type="array<string>"></x-field>
  <x-field data-name="nonce" data-type="string"></x-field>
  <x-field data-name="context" data-type="StateContext"></x-field>
  <x-field data-name="data" data-type="Any"></x-field>
</x-field-group>

### TokenState

表示同质化通证的状态。

<x-field-group>
  <x-field data-name="address" data-type="string"></x-field>
  <x-field data-name="issuer" data-type="string"></x-field>
  <x-field data-name="name" data-type="string"></x-field>
  <x-field data-name="description" data-type="string"></x-field>
  <x-field data-name="symbol" data-type="string"></x-field>
  <x-field data-name="unit" data-type="string"></x-field>
  <x-field data-name="decimal" data-type="number"></x-field>
  <x-field data-name="icon" data-type="string"></x-field>
  <x-field data-name="totalSupply" data-type="string"></x-field>
  <x-field data-name="initialSupply" data-type="string"></x-field>
  <x-field data-name="maxTotalSupply" data-type="string"></x-field>
  <x-field data-name="foreignToken" data-type="ForeignToken"></x-field>
  <x-field data-name="tokenFactoryAddress" data-type="string"></x-field>
  <x-field data-name="context" data-type="StateContext"></x-field>
  <x-field data-name="data" data-type="Any"></x-field>
</x-field-group>

### TokenFactoryState

表示通证工厂的状态，用于铸造和销毁通证。

<x-field-group>
  <x-field data-name="address" data-type="string"></x-field>
  <x-field data-name="tokenAddress" data-type="string"></x-field>
  <x-field data-name="reserveAddress" data-type="string"></x-field>
  <x-field data-name="currentSupply" data-type="string"></x-field>
  <x-field data-name="reserveBalance" data-type="string"></x-field>
  <x-field data-name="owner" data-type="string"></x-field>
  <x-field data-name="feeRate" data-type="number"></x-field>
  <x-field data-name="curve" data-type="CurveConfig"></x-field>
  <x-field data-name="context" data-type="StateContext"></x-field>
  <x-field data-name="token" data-type="TokenState"></x-field>
  <x-field data-name="reserveToken" data-type="TokenState"></x-field>
  <x-field data-name="data" data-type="Any"></x-field>
</x-field-group>


## 交易负载 (ITX)

这些类型定义了各种交易类型的 `itx` (内部交易) 对象。

### AccountMigrateTx

<x-field-group>
  <x-field data-name="pk" data-type="string"></x-field>
  <x-field data-name="type" data-type="WalletType"></x-field>
  <x-field data-name="address" data-type="string"></x-field>
  <x-field data-name="data" data-type="Any"></x-field>
</x-field-group>

### AcquireAssetV2Tx

<x-field-group>
  <x-field data-name="factory" data-type="string"></x-field>
  <x-field data-name="address" data-type="string"></x-field>
  <x-field data-name="assets" data-type="array<string>"></x-field>
  <x-field data-name="variables" data-type="array<VariableInput>"></x-field>
  <x-field data-name="issuer" data-type="NFTIssuer"></x-field>
  <x-field data-name="data" data-type="Any"></x-field>
</x-field-group>

### CreateAssetTx

<x-field-group>
  <x-field data-name="moniker" data-type="string"></x-field>
  <x-field data-name="data" data-type="Any"></x-field>
  <x-field data-name="readonly" data-type="boolean"></x-field>
  <x-field data-name="transferrable" data-type="boolean"></x-field>
  <x-field data-name="ttl" data-type="number"></x-field>
  <x-field data-name="parent" data-type="string"></x-field>
  <x-field data-name="address" data-type="string"></x-field>
  <x-field data-name="issuer" data-type="string"></x-field>
  <x-field data-name="endpoint" data-type="NFTEndpoint"></x-field>
  <x-field data-name="display" data-type="NFTDisplay"></x-field>
  <x-field data-name="tags" data-type="array<string>"></x-field>
</x-field-group>

### DelegateTx

<x-field-group>
  <x-field data-name="address" data-type="string"></x-field>
  <x-field data-name="to" data-type="string"></x-field>
  <x-field data-name="ops" data-type="array<DelegateOp>"></x-field>
  <x-field data-name="data" data-type="Any"></x-field>
</x-field-group>

### ExchangeTx

<x-field-group>
  <x-field data-name="to" data-type="string"></x-field>
  <x-field data-name="sender" data-type="ExchangeInfo"></x-field>
  <x-field data-name="receiver" data-type="ExchangeInfo"></x-field>
  <x-field data-name="expiredAt" data-type="string"></x-field>
  <x-field data-name="data" data-type="Any"></x-field>
</x-field-group>

### StakeTx

<x-field-group>
  <x-field data-name="address" data-type="string"></x-field>
  <x-field data-name="receiver" data-type="string"></x-field>
  <x-field data-name="inputs" data-type="array<TransactionInput>"></x-field>
  <x-field data-name="locked" data-type="boolean"></x-field>
  <x-field data-name="message" data-type="string"></x-field>
  <x-field data-name="revokeWaitingPeriod" data-type="number"></x-field>
  <x-field data-name="slashers" data-type="array<string>"></x-field>
  <x-field data-name="nonce" data-type="string"></x-field>
  <x-field data-name="data" data-type="Any"></x-field>
</x-field-group>

### TransferTx

<x-field-group>
  <x-field data-name="to" data-type="string"></x-field>
  <x-field data-name="value" data-type="string"></x-field>
  <x-field data-name="assets" data-type="array<string>"></x-field>
  <x-field data-name="data" data-type="Any"></x-field>
</x-field-group>


## 响应包装器

这些类型是由 API 查询返回的顶层对象，包含一个状态码和请求的数据。

### ResponseGetAccountState

<x-field-group>
  <x-field data-name="code" data-type="string"></x-field>
  <x-field data-name="state" data-type="AccountState"></x-field>
</x-field-group>

### ResponseGetAssetState

<x-field-group>
  <x-field data-name="code" data-type="string"></x-field>
  <x-field data-name="state" data-type="AssetState"></x-field>
</x-field-group>

### ResponseGetBlock

<x-field-group>
  <x-field data-name="code" data-type="string"></x-field>
  <x-field data-name="block" data-type="BlockInfo"></x-field>
</x-field-group>

### ResponseGetChainInfo

<x-field-group>
  <x-field data-name="code" data-type="string"></x-field>
  <x-field data-name="info" data-type="ChainInfo"></x-field>
</x-field-group>

### ResponseGetTx

<x-field-group>
  <x-field data-name="code" data-type="string"></x-field>
  <x-field data-name="info" data-type="TransactionInfo"></x-field>
</x-field-group>

### ResponseListTransactions

<x-field-group>
  <x-field data-name="code" data-type="string"></x-field>
  <x-field data-name="page" data-type="PageInfo"></x-field>
  <x-field data-name="transactions" data-type="array<IndexedTransaction>"></x-field>
</x-field-group>

### ResponseSendTx

<x-field-group>
  <x-field data-name="code" data-type="string"></x-field>
  <x-field data-name="hash" data-type="string"></x-field>
</x-field-group>
