-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
PLT-9368: Strict mode for runtime-lifecycle #180
Changes from 10 commits
b5ad083
3ae1a97
bc8c305
fc32fbd
4409a78
84d9aef
ae9dcf5
dd399aa
c443dbc
95c4958
e3477f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
### @marlowe.io/runtime-rest-client | ||
|
||
- `mkRestClient` provides optional `strict` parameter for performing dynamic type checking in `RestClient` methods. ([PR-180](https://github.com/input-output-hk/marlowe-ts-sdk/pull/180)) | ||
- The following `RestClient` methods uses keyword argument object instead of positional arguments. ([PR-180](https://github.com/input-output-hk/marlowe-ts-sdk/pull/180)) | ||
- `createContractSources` | ||
- `getContractById` | ||
- `submitContract` | ||
- `getTransactionsForContract` | ||
- `submitContractTransaction` | ||
- `getContractTransactionById` | ||
- `getWithdrawalById` | ||
- `submitWithdrawal` | ||
|
||
### @marlowe.io/runtime-lifecycle | ||
|
||
- `mkRuntimeLifecycle` provides optional `strict` parameter for performing dynamic type checking in `RestClient` methods. ([PR-180](https://github.com/input-output-hk/marlowe-ts-sdk/pull/180)) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -588,8 +588,9 @@ async function validateExistingContract( | |
contractId: ContractId | ||
): Promise<ValidationResults> { | ||
// First we try to fetch the contract details and the required tags | ||
const contractDetails = | ||
await lifecycle.restClient.getContractById(contractId); | ||
const contractDetails = await lifecycle.restClient.getContractById({ | ||
contractId, | ||
}); | ||
|
||
const scheme = extractSchemeFromTags(contractDetails.tags); | ||
|
||
Comment on lines
588
to
596
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Consider adding error handling for the asynchronous calls to + try {
const contractDetails = await lifecycle.restClient.getContractById({ contractId });
...
const { contractSourceId } = await lifecycle.restClient.createContractSources({ bundle: contractBundle });
...
const initialContract = await lifecycle.restClient.getContractSourceById({ contractSourceId });
+ } catch (error) {
+ console.error("Error fetching contract details or sources:", error);
+ throw error; // Rethrow or handle as appropriate for your application logic
+ } |
||
|
@@ -609,8 +610,9 @@ async function validateExistingContract( | |
// Or this option which doesn't require runtime to runtime communication, and just requires | ||
// the dapp to be able to recreate the same sources. | ||
const contractBundle = mkDelayPayment(scheme); | ||
const { contractSourceId } = | ||
await lifecycle.restClient.createContractSources(contractBundle); | ||
const { contractSourceId } = await lifecycle.restClient.createContractSources( | ||
{ bundle: contractBundle } | ||
); | ||
const initialContract = await lifecycle.restClient.getContractSourceById({ | ||
contractSourceId, | ||
}); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The use of
await
insidegetApplicableActions
without a try-catch block for error handling could lead to unhandled promise rejections ifrestClient.getContractById
fails. Consider adding error handling to improve robustness.Committable suggestion