-
Notifications
You must be signed in to change notification settings - Fork 3
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
Implement transactions by address endpoint #35
Conversation
@@ -8,7 +8,7 @@ export enum SortOrder { | |||
} | |||
|
|||
export type Sort<T> = { | |||
field: keyof T | |||
field: keyof T | string |
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.
@kpudlik I want to sort by ordinal which is nested lastTransactionRef.ordinal
I set there also a string
type but maybe you have a better idea?
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.
Typescript doesn't allow that :<
You can technically use something like lenses/path from Ramda: https://ramdajs.com/docs/#path
here you can read more: microsoft/TypeScript#12290
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.
In general you could potentially make Sort<Transaction | Transaction["lastTransactionRef"]>
But it wont give you such string:
lastTransactionRef.ordinal
:p
findAll(search), | ||
map(s => s[0]) | ||
) | ||
export const getTransactionByAddress = (es: Client) => (term: string, field: 'receiver' | 'sender' | null = null): TaskEither<ApplicationError, Transaction[]> => { |
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.
If you want to keep it type safe, you can combine keyof
and Pick
there:
field: (keyof Pick<Transaction, 'sender' | 'receiver'>) | null
Pick<Transaction, 'sender' | 'receiver'>
gives you a type:
{ sender: .., receiver: .. }
and using keyof
on this gives you 'sender' | 'receiver'
No description provided.