Skip to content

Commit

Permalink
[ts sdk] Add PerEpochConfig and Cancelled to UnchangedSharedKind (Mys…
Browse files Browse the repository at this point in the history
…tenLabs#18909)

## Description 

Describe the changes or additions included in this PR.

## Test plan 

How did you test the new or updated feature?

---

## Release notes

Check each box that your changes affect. If none of the boxes relate to
your changes, release notes aren't required.

For each box you select, include information after the relevant heading
that describes the impact of your changes that a user might notice and
any actions they must take to implement updates.

- [ ] Protocol: 
- [ ] Nodes (Validators and Full nodes): 
- [ ] Indexer: 
- [ ] JSON-RPC: 
- [ ] GraphQL: 
- [ ] CLI: 
- [ ] Rust SDK:
- [ ] REST API:
  • Loading branch information
hayes-mysten authored Aug 6, 2024
1 parent aa54e5a commit f37b3c2
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .changeset/breezy-dragons-sing.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@mysten/sui': patch
---

Add PerEpochConfig and Cancelled to UnchangedSharedKind
5 changes: 5 additions & 0 deletions .changeset/two-toes-watch.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@mysten/bcs': patch
---

Improve error message when bcs enum contains unknown value
13 changes: 10 additions & 3 deletions sdk/bcs/src/bcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -481,10 +481,17 @@ export const bcs = {
name,
read: (reader) => {
const index = reader.readULEB();
const [name, type] = canonicalOrder[index];

const enumEntry = canonicalOrder[index];
if (!enumEntry) {
throw new TypeError(`Unknown value ${index} for enum ${name}`);
}

const [kind, type] = enumEntry;

return {
[name]: type?.read(reader) ?? true,
$kind: name,
[kind]: type?.read(reader) ?? true,
$kind: kind,
} as never;
},
write: (value, writer) => {
Expand Down
2 changes: 2 additions & 0 deletions sdk/typescript/src/bcs/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,8 @@ const UnchangedSharedKind = bcs.enum('UnchangedSharedKind', {
ReadOnlyRoot: VersionDigest,
MutateDeleted: bcs.u64(),
ReadDeleted: bcs.u64(),
Cancelled: bcs.u64(),
PerEpochConfig: null,
});

const TransactionEffectsV2 = bcs.struct('TransactionEffectsV2', {
Expand Down
5 changes: 5 additions & 0 deletions sdk/typescript/test/e2e/object-cache.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,8 @@ describe('CachingTransactionExecutor', async () => {

expect(toolbox.client.multiGetObjects).toHaveBeenCalledTimes(0);

await toolbox.client.waitForTransaction({ digest: result.digest });

const result2 = await executor.signAndExecuteTransaction({
transaction: txb2,
signer: toolbox.keypair,
Expand All @@ -192,6 +194,8 @@ describe('CachingTransactionExecutor', async () => {
expect(toolbox.client.multiGetObjects).toHaveBeenCalledTimes(0);
expect(result2.effects?.status.status).toBe('success');

await toolbox.client.waitForTransaction({ digest: result2.digest });

await executor.reset();

const txb3 = new Transaction();
Expand All @@ -209,6 +213,7 @@ describe('CachingTransactionExecutor', async () => {
});
expect(toolbox.client.multiGetObjects).toHaveBeenCalledTimes(1);
expect(result3.effects?.status.status).toBe('success');
await toolbox.client.waitForTransaction({ digest: result3.digest });
});
});

Expand Down

0 comments on commit f37b3c2

Please sign in to comment.