Skip to content

Commit

Permalink
fix(payment-detection): blockFilter should not be empty (#1265)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandre-abrioux authored Nov 27, 2023
1 parent 6981bc1 commit fc215bf
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
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

0 comments on commit fc215bf

Please sign in to comment.