Skip to content

sui_v0.28.0_1678354289_ci

@666lcz 666lcz tagged this 09 Mar 06:01
## Description 

- Update the schema of `SuiTransactionResponse` to make all fields
optional and add a new `digest` field
- Add `SuiTransactionResponseOptions`
- Update the `sui_getTransaction` and `sui_multiGetTransaction` to take
in `SuiTransactionResponseOptions`
- rewrite the `sui_multiGetTransaction` logic

Here's the new interface

```
pub struct SuiTransactionResponseOptions {
    /// Whether to show transaction input data. Default to be False
    pub show_input: bool,
    /// Whether to show transaction effects. Default to be False
    pub show_effects: bool,
    /// Whether to show transaction events. Default to be False
    pub show_events: bool,
    /// Whether to show checkpoint sequence number. Default to be False
    pub show_checkpoint: bool,
    /// Whether to show timestamp. Default to be False
    pub show_timestamp: bool,
}

#[derive(Serialize, Deserialize, Debug, JsonSchema, Clone, Default)]
#[serde(rename_all = "camelCase", rename = "TransactionResponse")]
pub struct SuiTransactionResponse {
    pub digest: TransactionDigest,
    /// Transaction input data
    #[serde(skip_serializing_if = "Option::is_none")]
    pub transaction: Option<SuiTransaction>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub effects: Option<SuiTransactionEffects>,
    #[serde(skip_serializing_if = "Option::is_none")]
    pub events: Option<SuiTransactionEvents>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
    pub timestamp_ms: Option<u64>,
    #[serde(default, skip_serializing_if = "Option::is_none")]
	@@ -49,6 +114,17 @@ pub struct SuiTransactionResponse {
    /// This is only returned in the read api, not in the transaction execution api.
    #[serde(skip_serializing_if = "Option::is_none")]
    pub checkpoint: Option<CheckpointSequenceNumber>,
    #[serde(skip_serializing_if = "Vec::is_empty", default)]
    pub errors: Vec<String>,
}

#[method(name = "getTransaction")]
    async fn get_transaction_with_options(
        &self,
        /// the digest of the queried transaction
        digest: TransactionDigest,
        /// options for specifying the content to be returned
        options: Option<SuiTransactionResponseOptions>,
    ) -> RpcResult<SuiTransactionResponse>;

    /// Return the object information for a specified object
	@@ -139,10 +142,16 @@ pub trait ReadApi {
        descending_order: Option<bool>,
    ) -> RpcResult<TransactionsPage>;

    /// Returns an ordered list of transaction responses
    /// The method will throw an error if the input contains any duplicate or
    /// the input size exceeds [QUERY_MAX_RESULT_LIMIT]
    #[method(name = "multiGetTransactions")]
    async fn multi_get_transactions_with_options(
        &self,
        /// A list of transaction digests.
        digests: Vec<TransactionDigest>,
        /// config options to control which fields to fetch
        options: Option<SuiTransactionResponseOptions>,
    ) -> RpcResult<Vec<SuiTransactionResponse>>;
```

# Follow up items ( in separate PRs)

- [ ] rename `sui_getTransactions` to `sui_queryTransactions(query:
TransactionQuery, options: Option<SuiTransactionResponseOptions>) ->
Page<SuiTransactionResponse>`
- [ ] Add `SuiTransactionResponseOptions` as a parameter for
`sui_executeTransaction`
- [ ] remove existing ``sui_submitTransaction` and
`sui_executeTransactionSig`
- [ ] support options in the Indexer implementation
- [ ] Support more option variants such as `showRawBcs` and
`showLatestObjectData`


## Test Plan 


1. TS-SDK e2e tests `pnpm sdk prepare:e2e` `pnpm sdk test:e2e`

2. Test Explorer with the following steps

a. In root sui directory, run `pnpm sdk prepare:e2e`
b. In root sui directory, run `pnpm explorer dev` 
c. in root sui directory, run `pnpm sdk test:e2e` to generate some data
d. open localhost:3000 to check on a few transactions with different
kinds

Address page
![CleanShot 2023-03-08 at 03 23
38](https://user-images.githubusercontent.com/76067158/223660921-abbf7269-de6b-47c2-ac96-45226c46094b.png)
Transaction Details page(Events tab)
![CleanShot 2023-03-08 at 03 23
31](https://user-images.githubusercontent.com/76067158/223660952-c858b13f-be63-4939-809f-f7c06429dadd.png)
Transaction Details page (main)
![CleanShot 2023-03-08 at 03 23
24](https://user-images.githubusercontent.com/76067158/223660969-d4499b15-b9d6-402d-b9f0-a201813be75a.png)
Home page
![CleanShot 2023-03-08 at 03 23
12](https://user-images.githubusercontent.com/76067158/223660991-775c4f75-53ad-4522-9a8d-4ba75f568be3.png)

3. Test wallet with the following steps

a. In root sui directory, run `pnpm sdk prepare:e2e`
b. Duplicate this
[file](https://github.com/MystenLabs/sui/blob/main/apps/wallet/configs/environment/.env.defaults#L4)
and rename it to .env,
c. In root sui directory, run `pnpm wallet start`
d. follow
https://github.com/MystenLabs/sui/tree/main/apps/wallet#install-the-extension-to-chrome
to install the wallet
e. make some transactions(staking, transfer, nft mint)
f. verify that the activity tab looks good

Send NFT
![CleanShot 2023-03-08 at 03 21
18](https://user-images.githubusercontent.com/76067158/223660208-9bb93beb-25fd-4a58-8842-fa79a93c4c28.png)

Activity Tab
![CleanShot 2023-03-08 at 03 20
53](https://user-images.githubusercontent.com/76067158/223660227-95f66f2f-6a55-469d-9f9c-472517d73263.png)

Transfer Coin
![CleanShot 2023-03-08 at 03 20
40](https://user-images.githubusercontent.com/76067158/223660241-03d07e34-b0e4-4f4e-97f3-0f813e00800d.png)


---
If your changes are not user-facing and not a breaking change, you can
skip the following section. Otherwise, please indicate what changed, and
then add to the Release Notes section as highlighted during the release
process.

### Type of Change (Check all that apply)

- [x] user-visible impact
- [x] breaking change for a client SDKs
- [x] breaking change for FNs (FN binary must upgrade)
- [ ] breaking change for validators or node operators (must upgrade
binaries)
- [ ] breaking change for on-chain data layout
- [ ] necessitate either a data wipe or data migration

### Release notes
- [RPC] `sui_getTransaction` and `sui_multiGetTransaction` now take in
an additional optional parameter called `options` which is used to
specify which fields to fetch (e.g., transaction, effects, events, etc).
By default, only the transaction digest will be returned.
- [TS SDK] Rename `provider.getTransactionWithEffects` to
`provider.getTransactionResponse`. The new method takes in an additional
parameter `SuiTransactionResponseOptions` to configure which fields to
fetch (e.g., transaction, effects, events, etc). By default, only the
transaction digest will be returned.
Assets 2
Loading