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-6847] Payouts new API integration #21

Merged
merged 6 commits into from Aug 29, 2023
Merged

[PLT-6847] Payouts new API integration #21

merged 6 commits into from Aug 29, 2023

Conversation

nhenin
Copy link
Collaborator

@nhenin nhenin commented Aug 24, 2023

@nhenin nhenin marked this pull request as draft August 24, 2023 12:46
Copy link
Contributor

@bjornkihlberg bjornkihlberg left a comment

Choose a reason for hiding this comment

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

lgtm

@nhenin nhenin force-pushed the nhenin/payouts branch 2 times, most recently from f923e88 to 5f90854 Compare August 27, 2023 15:57
@nhenin nhenin changed the title payouts new API integration [PLT-6847] Payouts new API integration Aug 27, 2023
@nhenin nhenin marked this pull request as ready for review August 27, 2023 16:01
@nhenin nhenin requested a review from jhbertra August 27, 2023 16:04
Copy link
Collaborator

@hrajchert hrajchert left a comment

Choose a reason for hiding this comment

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

This PR changed too many things for me to understand, mainly because I didn't follow the development.

I've made some notes but none of them are blocking.

As an overall note, to improve the likelihood of a feature being used, and now that we have typedoc in place, all PR's should be judged by their documentation.


export * from './contract/index.js'
export * from './withdrawal/index.js'
export * from './payout/index.js'

export interface RestAPI {
healthcheck : () => TE.TaskEither<Error,Boolean>
Copy link
Collaborator

Choose a reason for hiding this comment

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

for the future, the healthcheck returns more than true/false. It also returns the node tip and other useful info.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

We need to progressively match 1-on-1 the rest api... this is not the case today... I was thinking taking care of these things when we are going to improve the overall error handling... network mismatch,runtime out of sync etc...

Comment on lines +12 to +24
{ payoutId: PayoutId
, contractId: ContractId
, withdrawalId : optionFromNullable(WithdrawalId)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you add a comment to these? Specially what is the difference between a payoutId and a withdrawalId

Copy link
Collaborator Author

@nhenin nhenin Aug 30, 2023

Choose a reason for hiding this comment

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

yeah it is not clear... I think there is an implicit priority in my head that we need to discuss.. which is external use vs internal concerns... I don't want people to use directly this rest client API, the more I use it the more I'm convinced about that... So I put my efforts first on the interfaces of the packages... This is supposed to be a 1 on 1 of the backend.. if it could be auto-generated, I would do it... I would more add comments on the backend side

Comment on lines +29 to +33
export type GETHeadersByRange = (rangeOption: O.Option<ContractsRange>)
=> (contractIds : ContractId[])
=> (roles : AssetId[])
=> (statusOption : O.Option<PayoutStatus>)
=> TE.TaskEither<Error | DecodingError,GETByRangeResponse>
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not to change now, but if this is something that a final JS user will use I'd recommend using an object instead of curried arguments.

Also, not sure what this function is supposed to do, adding comments would improve its legibility.

Copy link
Collaborator Author

@nhenin nhenin Aug 30, 2023

Choose a reason for hiding this comment

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

nope they won't use that... I'd like to use curried arguments for internal concerns and uncurried arguments on the user interfaces

type GETPayload = t.TypeOf<typeof GETPayload>
const GETPayload = t.type({ links: t.type ({}), resource: PayoutDetails})

export const getViaAxios:(axiosInstance: AxiosInstance) => GET
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure what this is supposed to do but the name is a little bit of a code smell.

Should this be called getPayoutDetails? what has Axios have to do with it?

Comment on lines +1 to +3
export * from './details.js'
export * from './header.js'
export * from './status.js'
Copy link
Collaborator

Choose a reason for hiding this comment

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

This directory is small enough that its contents could live in a single file.

As we talked in a meeting, I recommend watching this talk

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I didn't like this talk :-) ...
You see a violation of recipe/ convention and you miss the intent behind...
My Intent here is to get read of infrastructure details and extract the core domain... This is not 100% nailed... I have highlighted that there are concepts of headers and details on all the endpoints and before finding the concepts, I have duplicated logics on each of them...

  1. To be sure the API is consistent
  2. To have a few examples before making it 1 same logic..

High Cohesion / Low Coupling , Clean code , DDD etc... This talk about the life of a file is so rigid... I can't buy it :-) ... When you do little libraries, you can think that this is the case... But when you do something more complex it blows up... Inconsistencies, your dependencies are a mess, you stay monolithic forever etc...

@@ -78,10 +70,10 @@ export const PostResponse = t.type({
});

export const postViaAxios:(axiosInstance: AxiosInstance) => POST
Copy link
Collaborator

Choose a reason for hiding this comment

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

once again this sounds weird... should this be makeWithdrawl or similar?

Copy link
Collaborator Author

@nhenin nhenin Aug 30, 2023

Choose a reason for hiding this comment

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

it's weird on purpose :-) This is pure mechanical logic... I didn't want to add core domain naming on it

Comment on lines +10 to +11
import console from "console"
global.console = console
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems weird, a little explanation on what and why you did this can go a long way.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yeah Jest console logs doesn't make any sense... I did that to disable it...

applyInputs : (contractId: ContractId) => (provideInput : ProvideInput) => TE.TaskEither<Error | DecodingError,ContractId>
}
payouts :
{ available : (filtersOption : O.Option<Filters>) => TE.TaskEither<Error | DecodingError,PayoutAvailable[]>
Copy link
Collaborator

Choose a reason for hiding this comment

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

If this is the end user API, cant we use a available: (filters?: Filters) => Promise<PayoutAvailable[]>?

With typedoc we can use the throws to signal the DecodingError case

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

cool that was one my questions for a un-fp-ts interface

@@ -95,13 +95,13 @@ export class SingleAddressWallet implements WalletAPI {
, O.getOrElse(() => 0n))))


public tokenBalance : (token : Token) => TE.TaskEither<Error,bigint>
= (token) =>
public tokenBalance : (assetId : AssetId) => TE.TaskEither<Error,bigint>
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't understand this change, are you changing Token for Asset in the codebase? I would avoid that as in all the other repos Token is used. Asset is informally the Token+Value combination

Copy link
Collaborator Author

@nhenin nhenin Aug 30, 2023

Choose a reason for hiding this comment

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

Yes, I'm aligning with what Jamie has done in the runtime.... 2 core domains / Marlowe DSL & Runtime 2 different concepts around assets... when we'll do a V2 Marlowe... I have suggested we "uniformize" the naming on the language...

@nhenin nhenin merged commit 983f559 into main Aug 29, 2023
1 check failed
@nhenin nhenin deleted the nhenin/payouts branch August 29, 2023 15:49
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.

None yet

3 participants