Skip to content

Commit

Permalink
exported superfluidInfoRetriever from package and improved types
Browse files Browse the repository at this point in the history
  • Loading branch information
KolevDarko committed Aug 26, 2022
1 parent 38c3be1 commit 11257af
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions packages/payment-detection/src/erc777/superfluid-retriever.ts
Expand Up @@ -44,7 +44,7 @@ export class SuperFluidInfoRetriever {
};
}

public async getStreamingEvents(): Promise<Partial<FlowUpdatedEvent>[]> {
public async getStreamingEvents(): Promise<PaymentTypes.ERC777StreamEventParameters[]> {
const variables = this.getGraphVariables();
const { flow, untagged } = await this.client.GetSuperFluidEvents(variables);
// Chronological sorting of events having payment reference and closing events without payment reference
Expand All @@ -70,7 +70,7 @@ export class SuperFluidInfoRetriever {
oldFlowRate: streamEvents[streamEvents.length - 1].flowRate,
flowRate: 0,
timestamp: Utils.getCurrentTimestampInSecond(),
blockNumber: parseInt(streamEvents[streamEvents.length - 1].blockNumber),
blockNumber: parseInt(streamEvents[streamEvents.length - 1].blockNumber.toString()),
transactionHash: streamEvents[streamEvents.length - 1].transactionHash,
} as FlowUpdatedEvent);
}
Expand Down Expand Up @@ -99,7 +99,7 @@ export class SuperFluidInfoRetriever {
name: this.eventName,
parameters: {
to: this.toAddress,
block: parseInt(streamEvents[index].blockNumber),
block: parseInt(streamEvents[index].blockNumber.toString()),
txHash: streamEvents[index].transactionHash,
},
timestamp: streamEvents[index].timestamp,
Expand Down
2 changes: 2 additions & 0 deletions packages/payment-detection/src/index.ts
Expand Up @@ -20,6 +20,7 @@ import { NearNativeTokenPaymentDetector } from './near-detector';
import { FeeReferenceBasedDetector } from './fee-reference-based-detector';
import { SuperFluidPaymentDetector } from './erc777/superfluid-detector';
import { EscrowERC20InfoRetriever } from './erc20/escrow-info-retriever';
import { SuperFluidInfoRetriever } from './erc777/superfluid-retriever';

export type { TheGraphClient } from './thegraph';

Expand All @@ -37,6 +38,7 @@ export {
SuperFluidPaymentDetector,
NearNativeTokenPaymentDetector,
EscrowERC20InfoRetriever,
SuperFluidInfoRetriever,
setProviderFactory,
initPaymentDetectionApiKeys,
getDefaultProvider,
Expand Down
10 changes: 10 additions & 0 deletions packages/types/src/payment-types.ts
Expand Up @@ -151,6 +151,16 @@ export type ERC777PaymentNetworkEvent = IPaymentNetworkEvent<IERC777PaymentEvent
/** ERC777 BalanceWithEvents */
export type ERC777BalanceWithEvents = IBalanceWithEvents<IERC777PaymentEventParameters>;

/** Parameters for ERC777 streaming events */
export interface ERC777StreamEventParameters {
transactionHash: string;
blockNumber: number;
timestamp: number;
sender: string;
flowRate: number;
oldFlowRate: number;
type: number;
}
/**
* ERC20 networks and events
*/
Expand Down

0 comments on commit 11257af

Please sign in to comment.