Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(payment-detection): blockFilter should not be empty #1265

Merged
merged 2 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,15 @@ export class TheGraphConversionInfoRetriever extends TheGraphInfoRetriever<Conve
): Promise<PaymentTypes.AllNetworkEvents<PaymentTypes.IERC20FeePaymentEventParameters>> {
const { payments } = params.acceptedTokens
? await this.client.GetAnyToFungiblePayments({
blockFilter: this.client.options?.minIndexedBlock
? { number_gte: this.client.options.minIndexedBlock }
: undefined,
blockFilter: { number_gte: this.client.options?.minIndexedBlock || 0 },
reference: utils.keccak256(`0x${params.paymentReference}`),
to: params.toAddress.toLowerCase(),
currency: params.requestCurrency.hash.toLowerCase(),
acceptedTokens: params.acceptedTokens.map((t) => t.toLowerCase()),
contractAddress: params.contractAddress.toLowerCase(),
})
: await this.client.GetAnyToNativePayments({
blockFilter: this.client.options?.minIndexedBlock
? { number_gte: this.client.options.minIndexedBlock }
: undefined,
blockFilter: { number_gte: this.client.options?.minIndexedBlock || 0 },
reference: utils.keccak256(`0x${params.paymentReference}`),
to: params.toAddress.toLowerCase(),
currency: params.requestCurrency.hash.toLowerCase(),
Expand Down
8 changes: 2 additions & 6 deletions packages/payment-detection/src/thegraph/info-retriever.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,7 @@ export class TheGraphInfoRetriever<TGraphQuery extends TransferEventsParams = Tr
throw new Error('TheGraphInfoRetriever only supports no or 1 acceptedToken.');
}
const { payments, escrowEvents } = await this.client.GetPaymentsAndEscrowState({
blockFilter: this.client.options?.minIndexedBlock
? { number_gte: this.client.options.minIndexedBlock }
: undefined,
blockFilter: { number_gte: this.client.options?.minIndexedBlock || 0 },
reference: utils.keccak256(`0x${params.paymentReference}`),
to: params.toAddress.toLowerCase(),
tokenAddress: params.acceptedTokens ? params.acceptedTokens[0].toLowerCase() : null,
Expand All @@ -48,9 +46,7 @@ export class TheGraphInfoRetriever<TGraphQuery extends TransferEventsParams = Tr
throw new Error('TheGraphInfoRetriever only supports no or 1 acceptedToken.');
}
const { payments, escrowEvents } = await this.client.GetPaymentsAndEscrowStateForReceivables({
blockFilter: this.client.options?.minIndexedBlock
? { number_gte: this.client.options.minIndexedBlock }
: undefined,
blockFilter: { number_gte: this.client.options?.minIndexedBlock || 0 },
reference: utils.keccak256(`0x${params.paymentReference}`),
tokenAddress: params.acceptedTokens ? params.acceptedTokens[0].toLowerCase() : null,
contractAddress: params.contractAddress.toLowerCase(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ fragment EscrowEventResult on EscrowEvent {
}

query GetPaymentsAndEscrowState(
$blockFilter: Block_height
$blockFilter: Block_height!
$reference: Bytes!
$to: Bytes!
$tokenAddress: Bytes
Expand Down Expand Up @@ -60,7 +60,7 @@ query GetPaymentsAndEscrowState(

# AnyToErc20 payments: denominated in request $currency payable with many token addresses
query GetAnyToFungiblePayments(
$blockFilter: Block_height
$blockFilter: Block_height!
$reference: Bytes!
$to: Bytes!
$currency: Bytes!
Expand All @@ -85,7 +85,7 @@ query GetAnyToFungiblePayments(

# AnyToETH payments: denominated in request $currency payable with the EVM native token
query GetAnyToNativePayments(
$blockFilter: Block_height
$blockFilter: Block_height!
$reference: Bytes!
$to: Bytes!
$currency: Bytes!
Expand All @@ -109,7 +109,7 @@ query GetAnyToNativePayments(

# Receivables can be transferred to different owners, so searching by to could drop balance events.
query GetPaymentsAndEscrowStateForReceivables(
$blockFilter: Block_height
$blockFilter: Block_height!
$reference: Bytes!
$tokenAddress: Bytes!
$contractAddress: Bytes!
Expand Down