Skip to content

Commit

Permalink
Add types for PoRTokenAddress
Browse files Browse the repository at this point in the history
  • Loading branch information
mxiao-cll committed Nov 13, 2024
1 parent 121b5eb commit c4a1c70
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/adapter/por.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,26 +21,49 @@ export type PoRAddress = Record<string, unknown> & {
address: string
}

export type PoRTokenAddress = Record<string, unknown> & {
network: string
contractAddress: string
wallets: string[]
balanceOfSignature?: string
decimalsSignature?: string
}

export type PoRAddressResponse = {
Result: null
Data: {
result: PoRAddress[]
}
}

export type PoRTokenAddressResponse = {
Result: null
Data: {
result: PoRAddress[]
}
}

/**
* Helper type structure that contains the Response type passed to the generic parameters of an AddressEndpoint
*/
export type PoRAddressEndpointGenerics = TransportGenerics & {
Response: PoRAddressResponse
}

export type PoRTokenAddressEndpointGenerics = TransportGenerics & {
Response: PoRTokenAddressResponse
}

/**
* A PoRAddressEndpoint is a specific type of AdapterEndpoint. Meant to comply with standard practices for
* Data Feeds, its response type must be `PoRAddressResponse`
*/
export class PoRAddressEndpoint<T extends PoRAddressEndpointGenerics> extends AdapterEndpoint<T> {}

export class PoRTokenAddressEndpoint<
T extends PoRTokenAddressEndpointGenerics,
> extends AdapterEndpoint<T> {}

export type PoRBalance = Record<string, unknown> & {
balance: string
}
Expand Down Expand Up @@ -140,7 +163,7 @@ export class PoRProviderEndpoint<

/**
* A PoRAdapter is a specific kind of Adapter that includes at least one PoRTotalBalanceEndpoint,
* PoRBalanceEndpoint, PoRAddressEndpoint or PoRProviderEndpoint.
* PoRBalanceEndpoint, PoRAddressEndpoint, PoRTokenAddressEndpoint or PoRProviderEndpoint.
*/
export class PoRAdapter<T extends SettingsDefinitionMap> extends Adapter<T> {
constructor(params: AdapterParams<T>) {
Expand Down Expand Up @@ -174,6 +197,7 @@ export class PoRAdapter<T extends SettingsDefinitionMap> extends Adapter<T> {
e instanceof PoRBalanceEndpoint ||
e instanceof PoRTotalBalanceEndpoint ||
e instanceof PoRAddressEndpoint ||
e instanceof PoRTokenAddressEndpoint ||
e instanceof PoRProviderEndpoint,
)
if (!porEndpoints.length) {
Expand Down

0 comments on commit c4a1c70

Please sign in to comment.