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
Conversation
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.
lgtm
f923e88
to
5f90854
Compare
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.
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> |
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.
for the future, the healthcheck returns more than true/false. It also returns the node tip and other useful info.
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.
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...
{ payoutId: PayoutId | ||
, contractId: ContractId | ||
, withdrawalId : optionFromNullable(WithdrawalId) |
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.
Can you add a comment to these? Specially what is the difference between a payoutId and a withdrawalId
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.
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
export type GETHeadersByRange = (rangeOption: O.Option<ContractsRange>) | ||
=> (contractIds : ContractId[]) | ||
=> (roles : AssetId[]) | ||
=> (statusOption : O.Option<PayoutStatus>) | ||
=> TE.TaskEither<Error | DecodingError,GETByRangeResponse> |
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.
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.
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.
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 |
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.
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?
export * from './details.js' | ||
export * from './header.js' | ||
export * from './status.js' |
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.
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
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.
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...
- To be sure the API is consistent
- 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 |
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.
once again this sounds weird... should this be makeWithdrawl
or similar?
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.
it's weird on purpose :-) This is pure mechanical logic... I didn't want to add core domain naming on it
import console from "console" | ||
global.console = console |
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.
This seems weird, a little explanation on what and why you did this can go a long way.
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.
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[]> |
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 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
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.
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> |
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.
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
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.
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...
Integration of :