# 資料類型

本節為整個 OCAP Client 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>
