Skip to content
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-7693 get transaction by id #42

Merged
merged 9 commits into from
Oct 19, 2023

Conversation

hrajchert
Copy link
Collaborator

This PR:

  • Adds the runtime-rest-client endpoint: getTransactionById
  • Improves the generated documentation of related runtime-rest-client endpoint
  • Simplifies rest-client-flow.html to avoid repetition and add error handling

@hrajchert hrajchert changed the title PLT-7693 get transaction by PLT-7693 get transaction by id Oct 16, 2023
Comment on lines +60 to +62
export function proxy<A = never>(): A {
return null as any;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

After making this I realized that I should probably try to make a Proxy<T> type that is unusable instead of casting to A. For the purpose that is being used it shouldn't matter, but it would be better of course

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming this is missing functionality in fp-ts and io-ts and that it corresponds to data Proxy (t :: k) from Haskell.

Can we live without this? It looks like growing tech debt. Is there an alternate solution where we cut out some fp-ts code instead which makes this unecessary?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not missing functionality from fp-ts/io-ts in the sense that this is not required for "normal use". It is required by us for the reason I wrote at the beginning of the file.

If you use TypeScript (or any statically typed language) you'll eventually need some sort of dynamic checks or you are bound to have runtime errors.

For TS as far as I know you have:

and possible others...

Back in the day I created parmenides with a friend before the other libraries existed/got traction.

Knowing that we need runtime validation, and we already have io-ts in place (which has all the features we need and more), I don't believe this is adding to the technical debt. We just need to be judicious on what and how we expose things. See this exported doc as an example and note the difference between the types and the dynamic guards.

* @see {@link @marlowe.io/wallet!api.WalletAPI#signTx}
* @see {@link index.RestAPI#submitContract}
*/
// QUESTION: Should we rename the property or the type to indicate that is unsigned?
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we should imo

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc: @jhbertra if you agree we can schedule this for 0.0.6

Comment on lines +33 to +35
* @experimental
* This type is experimental and subject to change. See current DISCUSSIONS in the source code.
*/
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @nhenin , we should probably add this note to any experimental endpoint or attribute

Comment on lines +64 to +90
// DISCUSSION: @Jamie, @N.H. The optional part is because this is only present if the transaction is confirmed?
// If so, we should maybe include the Block Header as part of the confirmed constructor to avoid
// impossible states?
block: O.Option<BlockHeader>;
/**
* The UTXO that was used as input for the transaction.
*/
inputUtxo: TxOutRef;
/**
* The list of Marlowe inputs that were applied in this transaction
*/
inputs: Input[];
// DISCUSSION: @Jamie, @N.H. Similar discussion as the block one. Are these Options part of a confirmed
// transaction?
// Looking for this contractid and txid it has None for these fields in preprod
// contractID "19a90f8db56fab54d5e4fc4a4c0fd5084bb280a07841f2182b22305962285ad1#1",
// txId "b733caef6a21526b98586112d2090d0e1373654bf17ad85240fb12f08fb58802"
outputUtxo: O.Option<TxOutRef>;
outputContract: O.Option<Contract>;
outputState: O.Option<MarloweState>;
// QUESTION: @Jamie, @N.H, what is this?
consumingTx: O.Option<TxId>;
// DISCUSSION: @Jamie, @N.H. Should this be a TimeInterval instead?
invalidBefore: ISO8601;
invalidHereafter: ISO8601;
// QUESTION: @Jamie, what is this? The signed txbody?
txBody: O.Option<TextEnvelope>;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are some states behind these Options that are not explicit... I would prefer have a notion of state instead of these pieces of information flatten...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*/
// DISCUSSION: @N.H: Should we rename this to RestClient?
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @nhenin

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we should

* @see {@link @marlowe.io/wallet!api.WalletAPI#signTx}
* @see {@link index.RestAPI#submitContract}
*/
// QUESTION: Should we rename the property or the type to indicate that is unsigned?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we should imo

Comment on lines +64 to +90
// DISCUSSION: @Jamie, @N.H. The optional part is because this is only present if the transaction is confirmed?
// If so, we should maybe include the Block Header as part of the confirmed constructor to avoid
// impossible states?
block: O.Option<BlockHeader>;
/**
* The UTXO that was used as input for the transaction.
*/
inputUtxo: TxOutRef;
/**
* The list of Marlowe inputs that were applied in this transaction
*/
inputs: Input[];
// DISCUSSION: @Jamie, @N.H. Similar discussion as the block one. Are these Options part of a confirmed
// transaction?
// Looking for this contractid and txid it has None for these fields in preprod
// contractID "19a90f8db56fab54d5e4fc4a4c0fd5084bb280a07841f2182b22305962285ad1#1",
// txId "b733caef6a21526b98586112d2090d0e1373654bf17ad85240fb12f08fb58802"
outputUtxo: O.Option<TxOutRef>;
outputContract: O.Option<Contract>;
outputState: O.Option<MarloweState>;
// QUESTION: @Jamie, @N.H, what is this?
consumingTx: O.Option<TxId>;
// DISCUSSION: @Jamie, @N.H. Should this be a TimeInterval instead?
invalidBefore: ISO8601;
invalidHereafter: ISO8601;
// QUESTION: @Jamie, what is this? The signed txbody?
txBody: O.Option<TextEnvelope>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there are some states behind these Options that are not explicit... I would prefer have a notion of state instead of these pieces of information flatten...

Comment on lines +64 to +90
// DISCUSSION: @Jamie, @N.H. The optional part is because this is only present if the transaction is confirmed?
// If so, we should maybe include the Block Header as part of the confirmed constructor to avoid
// impossible states?
block: O.Option<BlockHeader>;
/**
* The UTXO that was used as input for the transaction.
*/
inputUtxo: TxOutRef;
/**
* The list of Marlowe inputs that were applied in this transaction
*/
inputs: Input[];
// DISCUSSION: @Jamie, @N.H. Similar discussion as the block one. Are these Options part of a confirmed
// transaction?
// Looking for this contractid and txid it has None for these fields in preprod
// contractID "19a90f8db56fab54d5e4fc4a4c0fd5084bb280a07841f2182b22305962285ad1#1",
// txId "b733caef6a21526b98586112d2090d0e1373654bf17ad85240fb12f08fb58802"
outputUtxo: O.Option<TxOutRef>;
outputContract: O.Option<Contract>;
outputState: O.Option<MarloweState>;
// QUESTION: @Jamie, @N.H, what is this?
consumingTx: O.Option<TxId>;
// DISCUSSION: @Jamie, @N.H. Should this be a TimeInterval instead?
invalidBefore: ISO8601;
invalidHereafter: ISO8601;
// QUESTION: @Jamie, what is this? The signed txbody?
txBody: O.Option<TextEnvelope>;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

*/
// DISCUSSION: @N.H: Should we rename this to RestClient?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes we should

@nhenin
Copy link
Collaborator

nhenin commented Oct 19, 2023

@hrajchert can you resolve the conflicts ? and we can merge it

@bjornkihlberg bjornkihlberg force-pushed the hrajchert/PLT-7693-get-transaction-by-id branch from a7c30b5 to 0894555 Compare October 19, 2023 09:14
@nhenin nhenin merged commit 0d881ef into main Oct 19, 2023
1 check passed
@nhenin nhenin deleted the hrajchert/PLT-7693-get-transaction-by-id branch October 19, 2023 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants