# @integraledger/lcp/sui

> The exports of @integraledger/lcp/sui.

Source: https://lcp.integraledger.com/reference/api/sui

## Interfaces

### SuiExecuted

#### Properties

| Property          | Type                       |
| ----------------- | -------------------------- |
|  `checkpoint`     | `bigint` \| `null`         |
|  `status`         | `"SUCCESS"` \| `"FAILURE"` |
|  `transactionBcs` | `Uint8Array`               |

***

### SuiPayload

The payload x402's Sui scheme defines.

#### Properties

| Property       | Type     |
| -------------- | -------- |
|  `signature`   | `string` |
|  `transaction` | `string` |

***

### SuiPaymentPayload

#### Properties

| Property       | Type                                                             |
| -------------- | ---------------------------------------------------------------- |
|  `accepted`    | [`PaymentRequirements`](https://lcp.integraledger.com/reference/api/x402#paymentrequirements) |
|  `extensions?` | `object`                                                         |
|  `payload`     | [`SuiPayload`](#suipayload)                                      |
|  `resource?`   | `object`                                                         |
| `resource.url` | `string`                                                         |
|  `x402Version` | `2`                                                              |

***

### SuiReader

Bounded, read-only calls against one network's GraphQL endpoint. Every failure rejects with `ReaderError`.
`read` is one request, so one snapshot:
`query($d:String!){transaction(digest:$d){transactionBcs effects{status checkpoint{sequenceNumber}}}
checkpoint{epoch{epochId}}}`, where the last field is the latest checkpoint's epoch.

#### Properties

| Property   | Modifier   | Type                        |
| ---------- | ---------- | --------------------------- |
|  `network` | `readonly` | [`SuiNetwork`](#suinetwork) |

#### Methods

##### read()

> **read**(`digest`): `Promise`\<\{ `epoch`: `bigint`; `tx`: [`SuiExecuted`](#suiexecuted) | `null`; }>

###### Parameters

| Parameter | Type     |
| --------- | -------- |
| `digest`  | `string` |

###### Returns

`Promise`\<\{ `epoch`: `bigint`; `tx`: [`SuiExecuted`](#suiexecuted) | `null`; }>

***

### SuiRef

#### Properties

| Property      | Type                        | Description                                                         |
| ------------- | --------------------------- | ------------------------------------------------------------------- |
|  `digest`     | `string`                    | -                                                                   |
|  `network`    | [`SuiNetwork`](#suinetwork) | -                                                                   |
|  `untilEpoch` | `string`                    | The last epoch the transaction can execute in, as a decimal string. |

***

### SuiTx

A decoded `TransactionData`: the bytes as received, their digest, the unused `Pure` inputs, and the epoch bound.

#### Properties

| Property      | Type                                         | Description                                                             |
| ------------- | -------------------------------------------- | ----------------------------------------------------------------------- |
|  `bytes`      | `Uint8Array`                                 | -                                                                       |
|  `digest`     | `string`                                     | Base58 of Blake2b-256 over `"TransactionData::"` followed by the bytes. |
|  `untilEpoch` | `bigint` \| `null`                           | -                                                                       |
|  `unusedPure` | readonly `Uint8Array`\<`ArrayBufferLike`>\[] | -                                                                       |

***

### SuiUnsigned

What `build` hands the payer's wallet, and how it checks what comes back.

#### Properties

| Property             | Type                                                             |
| -------------------- | ---------------------------------------------------------------- |
|  `request`           | `object`                                                         |
| `request.accepted`   | [`PaymentRequirements`](https://lcp.integraledger.com/reference/api/x402#paymentrequirements) |
| `request.expiration` | `"epoch-bounded"`                                                |
| `request.kind`       | `"sui-transaction"`                                              |
| `request.pureInput`  | `Uint8Array`                                                     |

#### Methods

##### complete()

> **complete**(`signed`): [`Refusal`](https://lcp.integraledger.com/reference/api#refusal) | [`SuiPaymentPayload`](#suipaymentpayload)

###### Parameters

| Parameter | Type                        |
| --------- | --------------------------- |
| `signed`  | [`SuiPayload`](#suipayload) |

###### Returns

[`Refusal`](https://lcp.integraledger.com/reference/api#refusal) | [`SuiPaymentPayload`](#suipaymentpayload)

## Type Aliases

### SuiNetwork

> **SuiNetwork** = `"sui:mainnet"` | `"sui:testnet"` | `"sui:devnet"`

***

### SuiStatus

> **SuiStatus** = \{ `checkpoint`: `bigint` | `null`; `state`: `"settled"`; } | \{ `state`: `"pending"`; `why`: `"not-found"` | `"unreadable"`; } | \{ `state`: `"failed"`; `why`: `"aborted"` | `"expired"` | `"not-this-instrument"`; }

## Variables

### exactSui

> `const` **exactSui**: `Readonly`\<\{ `advertise`: (`doc`, `h`, `link`, `offer`, `agreementUrl?`) => [`Refusal`](https://lcp.integraledger.com/reference/api#refusal) | [`PaymentRequired`](https://lcp.integraledger.com/reference/api/x402#paymentrequired); `bound`: (`presented`) => `Promise`\<`` `0x${string}` `` | [`Refusal`](https://lcp.integraledger.com/reference/api#refusal)>; `build`: (`choice`, `h`) => `Promise`\<[`Refusal`](https://lcp.integraledger.com/reference/api#refusal) | [`SuiUnsigned`](#suiunsigned)>; `carrier`: `null`; `claims`: `boolean`; `id`: `"x402/exact/sui"`; `pattern`: [`LcpPattern`](https://lcp.integraledger.com/reference/api/x402#lcppattern); `read`: (`doc`) => [`Refusal`](https://lcp.integraledger.com/reference/api#refusal) | [`X402Read`](https://lcp.integraledger.com/reference/api/x402#x402read); `recover`: (`ref`, `reader`) => `Promise`\<`` `0x${string}` `` | [`Refusal`](https://lcp.integraledger.com/reference/api#refusal)>; `reference`: (`presented`) => `Promise`\<[`Refusal`](https://lcp.integraledger.com/reference/api#refusal) | [`SuiRef`](#suiref)>; `status`: (`ref`, `reader`) => `Promise`\<[`SuiStatus`](#suistatus)>; `tie`: (`accepts`, `request`) => \[`"x402"`, \{ `accepts`: readonly [`PaymentRequirements`](https://lcp.integraledger.com/reference/api/x402#paymentrequirements)\[]; `request`: [`RequestCommitment`](https://lcp.integraledger.com/reference/api/x402#requestcommitment); }]; `unplaced`: (`option`) => [`PaymentRequirements`](https://lcp.integraledger.com/reference/api/x402#paymentrequirements); }>

## Functions

### decodeSuiTx()

> **decodeSuiTx**(`base64`): [`Refusal`](https://lcp.integraledger.com/reference/api#refusal) | [`SuiTx`](#suitx)

Decodes a base64 `TransactionData` V1 with a programmable kind.

#### Parameters

| Parameter | Type     |
| --------- | -------- |
| `base64`  | `string` |

#### Returns

[`Refusal`](https://lcp.integraledger.com/reference/api#refusal) | [`SuiTx`](#suitx)

***

### suiCarrier()

> **suiCarrier**(`tx`): `` `0x${string}` `` | [`Refusal`](https://lcp.integraledger.com/reference/api#refusal)

The hash carried by exactly one unused `Pure` input of exactly 32 bytes.

#### Parameters

| Parameter | Type              |
| --------- | ----------------- |
| `tx`      | [`SuiTx`](#suitx) |

#### Returns

`` `0x${string}` `` | [`Refusal`](https://lcp.integraledger.com/reference/api#refusal)

***

### suiOptionCheck()

> **suiOptionCheck**(`option`): [`Refusal`](https://lcp.integraledger.com/reference/api#refusal) | `undefined`

The pairing's filter: undefined for an option this pairing can pay, or the refusal naming why not.

#### Parameters

| Parameter | Type      |
| --------- | --------- |
| `option`  | `unknown` |

#### Returns

[`Refusal`](https://lcp.integraledger.com/reference/api#refusal) | `undefined`

***

### suiPairingOf()

> **suiPairingOf**(`option`): `"x402/exact/sui"` | `undefined`

This pairing's id for an option it can pay, or undefined.

#### Parameters

| Parameter | Type                                                             |
| --------- | ---------------------------------------------------------------- |
| `option`  | [`PaymentRequirements`](https://lcp.integraledger.com/reference/api/x402#paymentrequirements) |

#### Returns

`"x402/exact/sui"` | `undefined`

***

### suiRecover()

> **suiRecover**(`ref`, `reader`): `Promise`\<`` `0x${string}` `` | [`Refusal`](https://lcp.integraledger.com/reference/api#refusal)>

Reads the hash back from the executed transaction alone, by its digest. One call.

#### Parameters

| Parameter     | Type                                                             |
| ------------- | ---------------------------------------------------------------- |
| `ref`         | \{ `digest`: `string`; `network`: [`SuiNetwork`](#suinetwork); } |
| `ref.digest`  | `string`                                                         |
| `ref.network` | [`SuiNetwork`](#suinetwork)                                      |
| `reader`      | [`SuiReader`](#suireader)                                        |

#### Returns

`Promise`\<`` `0x${string}` `` | [`Refusal`](https://lcp.integraledger.com/reference/api#refusal)>

***

### suiStatus()

> **suiStatus**(`ref`, `reader`): `Promise`\<[`SuiStatus`](#suistatus)>

Reads the recorded digest. A failed read, or a reader for another network, is pending. An absent transaction is
expired once the latest epoch is past its bound; a present one must be these bytes carrying this hash, and its
effects' status decides. One call.

#### Parameters

| Parameter | Type                           |
| --------- | ------------------------------ |
| `ref`     | [`SuiRef`](#suiref) & `object` |
| `reader`  | [`SuiReader`](#suireader)      |

#### Returns

`Promise`\<[`SuiStatus`](#suistatus)>
