Options
All
  • Public
  • Public/Protected
  • All
Menu

Class DripsSubgraphClient

A client for querying the Drips Subgraph.

Hierarchy

  • DripsSubgraphClient

Index

Constructors

Properties

#apiUrl: string
#chainId: number

Accessors

  • get apiUrl(): string
  • get chainId(): number

Methods

  • filterSqueezableSenders(receiverId: string): Promise<Record<string, string[]>>
  • Returns a list of senders for which drips can potentially be squeezed, for the given receiver.

    The returned senders have set up a configuration that drips to the given receiver but it's not guaranteed that the sender is still dripping to this sender. The sender might be out of funds, for example.

    throws

    {DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • receiverId: string

      The receiver's user ID.

    Returns Promise<Record<string, string[]>>

    A Promise which resolves to a Record with keys being the sender IDs and values the asset (ERC20 token) IDs.

  • getAllUserAssetConfigsByUserId(userId: string, skip?: number, first?: number): Promise<UserAssetConfig[]>
  • Returns a list of drips configurations for the given user.

    throws

    {@link DripsErrors.argumentMissingError} if the userId is missing.

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • userId: string

      The user ID.

    • skip: number = 0

      The number of database entries to skip. Defaults to 0.

    • first: number = 100

      The number of database entries to take. Defaults to 100.

    Returns Promise<UserAssetConfig[]>

    A Promise which resolves to the user's drips configurations.

  • getArgsForSqueezingAllDrips(userId: string, senderId: string, tokenAddress: string): Promise<SqueezeArgs>
  • Calculates the arguments for squeezing all Drips up to "now" for the given sender and token.

    Important: This method might fail if two Drips updates were performed in a single block. because the order of the Drips configurations returned by the Subgraph is not guaranteed for such cases. The transaction will fail in the gas estimation phase, so no gas will be wasted.

    see

    DripsHubClient.squeezeDrips method for more.

    Parameters

    • userId: string

      The ID of the user receiving drips to squeeze funds for.

    • senderId: string

      The ID of the user sending drips to squeeze funds from.

    • tokenAddress: string

      The ERC20 token address.

    Returns Promise<SqueezeArgs>

    A Promise which resolves to the DripsHubClient.squeezeDrips arguments.

  • getCollectedEventsByUserId(userId: string, skip?: number, first?: number): Promise<CollectedEvent[]>
  • Returns a list of Collected events for the given user.

    throws

    {@link DripsErrors.argumentMissingError} if the userId is missing.

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • userId: string

      The user ID.

    • skip: number = 0

      The number of database entries to skip. Defaults to 0.

    • first: number = 100

      The number of database entries to take. Defaults to 100.

    Returns Promise<CollectedEvent[]>

    A Promise which resolves to the user's Collected events.

  • Returns the current Drips receivers for the given configuration.

    throws

    {@link DripsErrors.argumentMissingError} if the current Drips receivers.

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • userId: string

      The user ID.

    • tokenAddress: string

      The ERC20 token address.

    Returns Promise<DripsReceiverStruct[]>

    A Promise which resolves to the user's Collected events.

  • getDripsReceiverSeenEventsByReceiverId(receiverUserId: string, skip?: number, first?: number): Promise<DripsReceiverSeenEvent[]>
  • Returns a list of DripsReceiverSeen events for the given receiver.

    throws

    {@link DripsErrors.argumentMissingError} if the receiverUserId is missing.

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • receiverUserId: string

      The receiver's user ID.

    • skip: number = 0

      The number of database entries to skip. Defaults to 0.

    • first: number = 100

      The number of database entries to take. Defaults to 100.

    Returns Promise<DripsReceiverSeenEvent[]>

    A Promise which resolves to the receivers's DripsReceiverSeen events.

  • getDripsSetEventsByUserId(userId: string, skip?: number, first?: number): Promise<DripsSetEvent[]>
  • Returns a list of DripsSet events for the given user.

    throws

    {@link DripsErrors.argumentMissingError} if the userId is missing.

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • userId: string

      The user ID.

    • skip: number = 0

      The number of database entries to skip. Defaults to 0.

    • first: number = 100

      The number of database entries to take. Defaults to 100.

    Returns Promise<DripsSetEvent[]>

    A Promise which resolves to the user's DripsSet events.

  • getGivenEventsByReceiverUserId(receiverUserId: string, skip?: number, first?: number): Promise<GivenEvent[]>
  • Returns a list of Given events for the given receiver.

    throws

    {@link DripsErrors.argumentMissingError} if the receiverId is missing.

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • receiverUserId: string

      The receiver user ID.

    • skip: number = 0

      The number of database entries to skip. Defaults to 0.

    • first: number = 100

      The number of database entries to take. Defaults to 100.

    Returns Promise<GivenEvent[]>

    A Promise which resolves to the receiver's Given events.

  • getGivenEventsByUserId(userId: string, skip?: number, first?: number): Promise<GivenEvent[]>
  • Returns a list of Given events for the given user.

    throws

    {@link DripsErrors.argumentMissingError} if the userId is missing.

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • userId: string

      The user ID.

    • skip: number = 0

      The number of database entries to skip. Defaults to 0.

    • first: number = 100

      The number of database entries to take. Defaults to 100.

    Returns Promise<GivenEvent[]>

    A Promise which resolves to the user's Given events.

  • getLatestUserMetadata(userId: string, key: string): Promise<null | UserMetadataEntry>
  • Returns the latest metadata update for the given userId-key pair.

    throws

    {@link DripsErrors.argumentMissingError} if any of the required parameter is missing.

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • userId: string

      The user ID.

    • key: string

      The metadata key.

    Returns Promise<null | UserMetadataEntry>

    A Promise which resolves to the user's metadata, or null if not found.

  • getMetadataHistory(userId: string, key?: string, skip?: number, first?: number): Promise<UserMetadataEntry[]>
  • Returns the history of user metadata updates for the given user.

    throws

    {@link DripsErrors.argumentMissingError} if the userId is missing.

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • userId: string

      The user ID.

    • Optional key: string

      The metadata key.

    • skip: number = 0

      The number of database entries to skip. Defaults to 0.

    • first: number = 100

      The number of database entries to take. Defaults to 100.

    Returns Promise<UserMetadataEntry[]>

    A Promise which resolves to the user's metadata.

  • getNftSubAccountIdsByApp(associatedApp: string, skip?: number, first?: number): Promise<string[]>
  • Returns a list of token IDs that are associated with the given app.

    throws

    {@link DripsErrors.argumentError} if the associatedApp is missing.

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • associatedApp: string

      The name/ID of the app to retrieve accounts for.

      Tip: you might want to use Utils.UserMetadata.valueFromString to create your associatedApp argument from a string.

    • skip: number = 0

      The number of database entries to skip. Defaults to 0.

    • first: number = 100

      The number of database entries to take. Defaults to 100.

    Returns Promise<string[]>

    A Promise which resolves to the account IDs.

  • getNftSubAccountsByOwner(ownerAddress: string, skip?: number, first?: number): Promise<NftSubAccount[]>
  • Returns a list of NFT sub accounts for the given owner.

    throws

    {@link DripsErrors.addressError} if the ownerAddress is not valid.

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • ownerAddress: string

      The owner's address.

    • skip: number = 0

      The number of database entries to skip. Defaults to 0.

    • first: number = 100

      The number of database entries to take. Defaults to 100.

    Returns Promise<NftSubAccount[]>

    A Promise which resolves to the owner's NFT sub accounts.

  • getReceivedDripsEventsByUserId(userId: string, skip?: number, first?: number): Promise<ReceivedDripsEvent[]>
  • Returns a list of ReceivedDrips events for the given user.

    throws

    {@link DripsErrors.argumentMissingError} if the userId is missing.

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • userId: string

      The user ID.

    • skip: number = 0

      The number of database entries to skip. Defaults to 0.

    • first: number = 100

      The number of database entries to take. Defaults to 100.

    Returns Promise<ReceivedDripsEvent[]>

    A Promise which resolves to the user's ReceivedDrips events.

  • getSplitEntriesByReceiverUserId(receiverUserId: string, skip?: number, first?: number): Promise<SplitsEntry[]>
  • Returns a list of Split entries for the given user.

    throws

    {@link DripsErrors.argumentMissingError} if the receiverUserId is missing.

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • receiverUserId: string

      The receiver's user ID.

    • skip: number = 0

      The number of database entries to skip. Defaults to 0.

    • first: number = 100

      The number of database entries to take. Defaults to 100.

    Returns Promise<SplitsEntry[]>

    A Promise which resolves to the receivers's Split events.

  • getSplitEventsByReceiverUserId(receiverUserId: string, skip?: number, first?: number): Promise<SplitEvent[]>
  • Returns a list of Split events for the given receiver.

    throws

    {@link DripsErrors.argumentMissingError} if the receiverUserId is missing.

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • receiverUserId: string

      The receiver user ID.

    • skip: number = 0

      The number of database entries to skip. Defaults to 0.

    • first: number = 100

      The number of database entries to take. Defaults to 100.

    Returns Promise<SplitEvent[]>

    A Promise which resolves to the receiver's Split events.

  • getSplitEventsByUserId(userId: string, skip?: number, first?: number): Promise<SplitEvent[]>
  • Returns a list of Split events for the given user.

    throws

    {@link DripsErrors.argumentMissingError} if the userId is missing.

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • userId: string

      The user ID.

    • skip: number = 0

      The number of database entries to skip. Defaults to 0.

    • first: number = 100

      The number of database entries to take. Defaults to 100.

    Returns Promise<SplitEvent[]>

    A Promise which resolves to the user's Split events.

  • getSplitsConfigByUserId(userId: string, skip?: number, first?: number): Promise<SplitsEntry[]>
  • Returns the splits configuration for the give user.

    throws

    {@link DripsErrors.argumentMissingError} if the userId is missing.

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • userId: string

      The user ID.

    • skip: number = 0

      The number of database entries to skip. Defaults to 0.

    • first: number = 100

      The number of database entries to take. Defaults to 100.

    Returns Promise<SplitsEntry[]>

    A Promise which resolves to the user's splits configuration.

  • getSqueezedDripsEventsByUserId(userId: string, skip?: number, first?: number): Promise<SqueezedDripsEvent[]>
  • Returns the user's SqueezedDrips events.

    throws

    {@link DripsErrors.argumentMissingError} if the userId is missing.

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • userId: string

      The user ID.

    • skip: number = 0

      The number of database entries to skip. Defaults to 0.

    • first: number = 100

      The number of database entries to take. Defaults to 100.

    Returns Promise<SqueezedDripsEvent[]>

    A Promise which resolves to the user's SqueezedDrips events.

  • getUserAssetConfigById(userId: string, assetId: BigNumberish): Promise<null | UserAssetConfig>
  • Returns the drips configuration for the given user and asset.

    throws

    {@link DripsErrors.argumentMissingError} if any of the required parameters is missing.

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • userId: string

      The user ID.

    • assetId: BigNumberish

      The asset ID.

    Returns Promise<null | UserAssetConfig>

    A Promise which resolves to the user's drips configuration, or null if the configuration is not found.

  • getUsersStreamingToUser(receiverUserId: string, skip?: number, first?: number): Promise<bigint[]>
  • Returns the users that stream funds to the given receiver.

    throws

    {@link DripsErrors.argumentMissingError} if the receiverUserId is missing.

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Parameters

    • receiverUserId: string

      The receiver's user ID.

    • skip: number = 0

      The number of database entries to skip. Defaults to 0.

    • first: number = 100

      The number of database entries to take. Defaults to 100.

    Returns Promise<bigint[]>

    A Promise which resolves to the users that stream funds to the given receiver.

  • query<T>(query: string, variables: unknown): Promise<{ data: T }>
  • Executes the given query against the Drips Subgraph.

    example

    Example usage for querying Split events. type SplitEvent = { id: string; amount: bigint; assetId: bigint; blockTimestamp: bigint; receiverId: string; userId: string; }

    type QueryResponse = { splitEvents: SplitEvent[]; };

    export const getSplitEventsByUserId = #graphql query getSplitEventsByUserId($userId: String!, $skip: Int, $first: Int) { splitEvents(where: {userId: $userId}, skip: $skip, first: $first) { id userId receiverId assetId amt blockTimestamp } } ;

    const userId = "1"; const skip = 0; const first = 100;

    const response = await dripsSubgraphClient.query(getSplitEventsByUserId, { userId, skip, first });

    const events = response?.data?.splitEvents?.map(mapSplitEventToDto) || [];

    throws

    {@link DripsErrors.subgraphQueryError} if the query fails.

    Type Parameters

    • T = unknown

    Parameters

    • query: string

      The GraphQL query.

    • variables: unknown

      The GraphQL query variables.

    Returns Promise<{ data: T }>

    A Promise which resolves to the expected data.

  • Creates a new immutable DripsSubgraphClient instance.

    throws

    {@link DripsErrors.argumentMissingError} if the chainId is missing.

    throws

    {@link DripsErrors.unsupportedNetworkError} if the chainId is not supported.

    Parameters

    • chainId: number

      The chain ID.

    • Optional customApiUrl: string

      Overrides the subgraph's apiUrl. If it's undefined (default value), the apiUrl will be automatically selected based on the chainId.

    Returns DripsSubgraphClient

    The new DripsSubgraphClient instance.

Generated using TypeDoc