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

Implement transactions by address endpoint #35

Merged
merged 1 commit into from
Aug 19, 2020
Merged

Implement transactions by address endpoint #35

merged 1 commit into from
Aug 19, 2020

Conversation

mwadon
Copy link
Contributor

@mwadon mwadon commented Aug 18, 2020

No description provided.

@@ -8,7 +8,7 @@ export enum SortOrder {
}

export type Sort<T> = {
field: keyof T
field: keyof T | string
Copy link
Contributor Author

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?

Copy link
Contributor

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

Copy link
Contributor

@kpudlik kpudlik Aug 18, 2020

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[]> => {
Copy link
Member

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'

marcinwadon
marcinwadon previously approved these changes Aug 18, 2020
@marcinwadon marcinwadon merged commit b8d5511 into master Aug 19, 2020
@marcinwadon marcinwadon deleted the api branch August 19, 2020 13:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants