Skip to content

Commit

Permalink
Sdkcore updates new fields and entities changes (#837)
Browse files Browse the repository at this point in the history
* Revert "Revert "Sdkcore updates new fields and entities changes (#834)" (#836)"

This reverts commit f8cb3ec.

* require test-subgraph-on-previous-sdk-versions

add test-subgraph-on-previous-sdk-versions to needs before publish-npm-packages job is run

* remove test-subgraph-on-previous-sdk-versions job from ci.canary

Co-authored-by: 0xdavinchee <0xdavinchee@gmail.com>
  • Loading branch information
msoni89 and 0xdavinchee authored May 23, 2022
1 parent 6bb1513 commit d9c12aa
Show file tree
Hide file tree
Showing 7 changed files with 570 additions and 11 deletions.
7 changes: 0 additions & 7 deletions .github/workflows/ci.canary.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,6 @@ jobs:
name: Build and Test Subgraph (Development Branch)
if: github.repository == 'superfluid-finance/protocol-monorepo'

test-subgraph-on-previous-sdk-versions:
uses: superfluid-finance/protocol-monorepo/.github/workflows/call.test-subgraph-on-previous-sdk-core-versions.yml@dev
name: Build and Test Subgraph on Previous SDK-Core Versions (Development Branch)
if: github.repository == 'superfluid-finance/protocol-monorepo'
with:
subgraph-release: dev

ethereum-contracts-coverage:
name: Run coverage test of ethereum-contracts of dev branch

Expand Down
9 changes: 5 additions & 4 deletions packages/sdk-core/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@ import Governance from "./Governance";
import Host from "./Host";
import InstantDistributionAgreementV1 from "./InstantDistributionAgreementV1";
import Query from "./Query";
import SuperToken from "./SuperToken";
import { WrapperSuperToken } from "./SuperToken";
import { PureSuperToken } from "./SuperToken";
import { NativeAssetSuperToken } from "./SuperToken";
import SuperToken, {
NativeAssetSuperToken,
PureSuperToken,
WrapperSuperToken,
} from "./SuperToken";

export * from "./interfaces";
export * from "./utils";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export interface AccountTokenSnapshot {
totalNumberOfActiveStreams: number;
totalOutflowRate: BigNumber;
maybeCriticalAtTimestamp: BigNumber;
isLiquidationEstimateOptimistic: boolean;
totalNumberOfClosedStreams: number;
totalSubscriptionsWithUnits: number;
updatedAtBlockNumber: BlockNumber;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ query accountTokenSnapshots($first: Int = 10, $skip: Int = 0, $orderBy: AccountT
updatedAtBlockNumber
updatedAtTimestamp
maybeCriticalAtTimestamp
isLiquidationEstimateOptimistic
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
import {
Address,
BigNumber,
BlockNumber,
SubgraphId,
Timestamp,
} from "../../mappedSubgraphTypes";
import {
AccountTokenSnapshotLog_Filter,
AccountTokenSnapshotLog_OrderBy,
} from "../../schema.generated";
import {
RelevantAddressesIntermediate,
SubgraphListQuery,
SubgraphQueryHandler,
} from "../../subgraphQueryHandler";

import {
AccountTokenSnapshotLogsDocument,
AccountTokenSnapshotLogsQuery,
AccountTokenSnapshotLogsQueryVariables,
} from "./accountTokenSnapshotLogs.generated";

export interface AccountTokenSnapshotLog {
id: SubgraphId;
transactionHash: string;
order: number;
logIndex: number;
timestamp: Timestamp;
blockNumber: BlockNumber;
balance: BigNumber;
maybeCriticalAtTimestamp: BigNumber;
totalAmountStreamed: BigNumber;
totalAmountTransferred: BigNumber;
totalApprovedSubscriptions: number;
totalDeposit: BigNumber;
totalInflowRate: BigNumber;
totalNetFlowRate: BigNumber;
totalNumberOfActiveStreams: number;
totalNumberOfClosedStreams: number;
totalSubscriptionsWithUnits: number;
totalOutflowRate: BigNumber;
triggeredByEventName: string;
account: Address;
token: Address;
tokenSymbol: string;
}

export type AccountTokenSnapshotLogListQuery = SubgraphListQuery<
AccountTokenSnapshotLog_Filter,
AccountTokenSnapshotLog_OrderBy
>;

export class AccountTokenSnapshotLogQueryHandler extends SubgraphQueryHandler<
AccountTokenSnapshotLog,
AccountTokenSnapshotLogListQuery,
AccountTokenSnapshotLogsQuery,
AccountTokenSnapshotLogsQueryVariables
> {
getAddressFieldKeysFromFilter = (): {
accountKeys: (keyof AccountTokenSnapshotLog_Filter)[];
tokenKeys: (keyof AccountTokenSnapshotLog_Filter)[];
} => ({
accountKeys: ["account"],
tokenKeys: ["token"],
});

getRelevantAddressesFromResultCore = (
result: AccountTokenSnapshotLog
): RelevantAddressesIntermediate => ({
tokens: [result.token],
accounts: [result.account],
});

mapFromSubgraphResponse = (
response: AccountTokenSnapshotLogsQuery
): AccountTokenSnapshotLog[] =>
response.accountTokenSnapshotLogs.map((x) => ({
...x,
account: x.account.id,
token: x.token.id,
tokenSymbol: x.token.symbol,
blockNumber: Number(x.blockNumber),
timestamp: Number(x.timestamp),
order: Number(x.order),
logIndex: Number(x.logIndex),
}));

requestDocument = AccountTokenSnapshotLogsDocument;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
query accountTokenSnapshotLogs($first: Int = 10, $skip: Int = 0, $orderBy: AccountTokenSnapshotLog_orderBy = id, $orderDirection: OrderDirection = asc, $where: AccountTokenSnapshotLog_filter = {}, $block: Block_height) {
accountTokenSnapshotLogs(
first: $first
skip: $skip
orderBy: $orderBy
orderDirection: $orderDirection
where: $where
block: $block
) {
id
order
logIndex
timestamp
blockNumber
balance
maybeCriticalAtTimestamp
totalAmountStreamed
totalAmountTransferred
totalApprovedSubscriptions
totalDeposit
totalInflowRate
totalNetFlowRate
totalNumberOfActiveStreams
totalNumberOfClosedStreams
totalSubscriptionsWithUnits
totalOutflowRate
transactionHash
triggeredByEventName
account {
id
}
token {
id
symbol
}
}
}
Loading

0 comments on commit d9c12aa

Please sign in to comment.