From 339b8eb0f52d178719905b46d4a1166e9533172d Mon Sep 17 00:00:00 2001 From: Tony Lee Date: Thu, 29 Aug 2024 10:22:20 -0400 Subject: [PATCH] Try Catch in SDK (#19143) ## Description Try catch in SDK ## Test plan How did you test the new or updated feature? Testnet ## 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: --- .changeset/lucky-cobras-dance.md | 5 +++++ sdk/deepbook-v3/src/client.ts | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 .changeset/lucky-cobras-dance.md diff --git a/.changeset/lucky-cobras-dance.md b/.changeset/lucky-cobras-dance.md new file mode 100644 index 0000000000000..002ff46e17973 --- /dev/null +++ b/.changeset/lucky-cobras-dance.md @@ -0,0 +1,5 @@ +--- +'@mysten/deepbook-v3': patch +--- + +Try catch for getOrder function diff --git a/sdk/deepbook-v3/src/client.ts b/sdk/deepbook-v3/src/client.ts index 4049d5f068613..9b151308ece86 100644 --- a/sdk/deepbook-v3/src/client.ts +++ b/sdk/deepbook-v3/src/client.ts @@ -270,8 +270,12 @@ export class DeepBookClient { expire_timestamp: bcs.u64(), }); - const orderInformation = res.results![0].returnValues![0][0]; - return Order.parse(new Uint8Array(orderInformation)); + try { + const orderInformation = res.results![0].returnValues![0][0]; + return Order.parse(new Uint8Array(orderInformation)); + } catch (e) { + return null; + } } /**