-
Notifications
You must be signed in to change notification settings - Fork 238
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SDK-CORE] Added FlowOperator Query and its Entity (#1396)
* Added, account token settings and query required for Permission and Allowance feature (Dashboard). * fixed review comments * fixed lint issue * added flowOperator as filter option * change entity name * fix getRelevantAddressesFromResultCore * undo sdk-redux version --------- Co-authored-by: Kaspar Kallas <kaspar@superfluid.finance>
- Loading branch information
1 parent
81b5e89
commit 719b259
Showing
8 changed files
with
1,458 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
packages/sdk-core/src/subgraph/entities/flowOperator/flowOperators.graphql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
query flowOperators( | ||
$first: Int = 10 | ||
$orderBy: FlowOperator_orderBy = id | ||
$orderDirection: OrderDirection = asc | ||
$skip: Int = 0 | ||
$where: FlowOperator_filter = {} | ||
$block: Block_height | ||
) { | ||
flowOperators( | ||
first: $first | ||
orderBy: $orderBy | ||
orderDirection: $orderDirection | ||
skip: $skip | ||
where: $where | ||
block: $block | ||
) { | ||
id | ||
createdAtTimestamp | ||
createdAtBlockNumber | ||
updatedAtBlockNumber | ||
updatedAtTimestamp | ||
flowOperator | ||
sender { | ||
id | ||
} | ||
token { | ||
id | ||
} | ||
flowRateAllowanceRemaining | ||
permissions | ||
allowance | ||
} | ||
} |
74 changes: 74 additions & 0 deletions
74
packages/sdk-core/src/subgraph/entities/flowOperator/flowOperators.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { | ||
Address, | ||
BigNumber, | ||
BlockNumber, | ||
Timestamp, | ||
} from "../../mappedSubgraphTypes"; | ||
import { | ||
FlowOperator_Filter, | ||
FlowOperator_OrderBy, | ||
} from "../../schema.generated"; | ||
import { | ||
RelevantAddressesIntermediate, | ||
SubgraphListQuery, | ||
SubgraphQueryHandler, | ||
} from "../../subgraphQueryHandler"; | ||
|
||
import { | ||
FlowOperatorsDocument, | ||
FlowOperatorsQuery, | ||
FlowOperatorsQueryVariables, | ||
} from "./flowOperators.generated"; | ||
|
||
export interface FlowOperator { | ||
id: string; | ||
createdAtBlockNumber: BlockNumber; | ||
createdAtTimestamp: Timestamp; | ||
updatedAtBlockNumber: BlockNumber; | ||
updatedAtTimestamp: Timestamp; | ||
flowOperator: Address; | ||
sender: Address; | ||
token: Address; | ||
flowRateAllowanceRemaining: BigNumber; | ||
allowance: BigNumber; | ||
permissions: number; | ||
} | ||
|
||
export type FlowOperatorListQuery = SubgraphListQuery< | ||
FlowOperator_Filter, | ||
FlowOperator_OrderBy | ||
>; | ||
|
||
export class FlowOperatorQueryHandler extends SubgraphQueryHandler< | ||
FlowOperator, | ||
FlowOperatorListQuery, | ||
FlowOperatorsQuery, | ||
FlowOperatorsQueryVariables | ||
> { | ||
getAddressFieldKeysFromFilter = (): { | ||
accountKeys: (keyof FlowOperator_Filter)[]; | ||
tokenKeys: (keyof FlowOperator_Filter)[]; | ||
} => ({ | ||
accountKeys: ["sender", "flowOperator"], | ||
tokenKeys: ["token"], | ||
}); | ||
|
||
getRelevantAddressesFromResultCore = ( | ||
result: FlowOperator | ||
): RelevantAddressesIntermediate => ({ | ||
accounts: [result.sender, result.flowOperator], | ||
tokens: [result.token], | ||
}); | ||
|
||
mapFromSubgraphResponse = (response: FlowOperatorsQuery): FlowOperator[] => | ||
response.flowOperators.map((x) => ({ | ||
...x, | ||
sender: x.sender.id, | ||
token: x.token.id, | ||
createdAtTimestamp: Number(x.createdAtTimestamp), | ||
createdAtBlockNumber: Number(x.createdAtBlockNumber), | ||
updatedAtTimestamp: Number(x.updatedAtTimestamp), | ||
updatedAtBlockNumber: Number(x.updatedAtBlockNumber), | ||
})); | ||
requestDocument = FlowOperatorsDocument; | ||
} |
Oops, something went wrong.