Skip to content

Commit 53650e5

Browse files
authored
feat: production release 🚀 (#260)
1 parent 4ef4c59 commit 53650e5

File tree

9 files changed

+196
-27
lines changed

9 files changed

+196
-27
lines changed

‎packages/indexer-database/src/entities/RelayHashInfo.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export enum RelayStatus {
3737
"fillDeadline",
3838
"status",
3939
])
40+
@Index("IX_rhi_status", ["status"])
4041
export class RelayHashInfo {
4142
@PrimaryGeneratedColumn()
4243
id: number;

‎packages/indexer-database/src/entities/evm/V3FundsDeposited.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import {
2323
"logIndex",
2424
])
2525
@Index("IX_v3FundsDeposited_blockTimestamp", ["blockTimestamp"])
26+
@Index("IX_v3FundsDeposited_depositor", ["depositor"])
2627
export class V3FundsDeposited {
2728
@PrimaryGeneratedColumn()
2829
id: number;
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { MigrationInterface, QueryRunner } from "typeorm";
2+
3+
export class V3FundsDeposited1744307085174 implements MigrationInterface {
4+
name = "V3FundsDeposited1744307085174";
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(
8+
`CREATE INDEX "IX_v3FundsDeposited_depositor" ON "evm"."v3_funds_deposited" ("depositor") `,
9+
);
10+
await queryRunner.query(
11+
`CREATE INDEX "IX_rhi_status" ON "relay_hash_info" ("status") `,
12+
);
13+
}
14+
15+
public async down(queryRunner: QueryRunner): Promise<void> {
16+
await queryRunner.query(`DROP INDEX "public"."IX_rhi_status"`);
17+
await queryRunner.query(`DROP INDEX "evm"."IX_v3FundsDeposited_depositor"`);
18+
}
19+
}

‎packages/indexer/package.json‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
"@across-protocol/sdk": "^4.1.30",
2727
"@repo/error-handling": "workspace:*",
2828
"@repo/webhooks": "workspace:*",
29+
"@solana/kit": "^2.1.0",
2930
"@types/express": "^4.17.21",
3031
"@types/lodash": "^4.17.7",
3132
"@types/luxon": "^3.4.2",

‎packages/indexer/src/data-indexing/service/SpokePoolIndexerDataHandler.ts‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ import { BlockRange } from "../model";
1515
import { IndexerDataHandler } from "./IndexerDataHandler";
1616

1717
import * as utils from "../../utils";
18-
import { getIntegratorId } from "../../utils/spokePoolUtils";
1918
import { SpokePoolRepository } from "../../database/SpokePoolRepository";
2019
import { SwapBeforeBridgeRepository } from "../../database/SwapBeforeBridgeRepository";
2120
import { SpokePoolProcessor } from "../../services/spokePoolProcessor";
@@ -586,7 +585,7 @@ export class SpokePoolIndexerDataHandler implements IndexerDataHandler {
586585
deposits: entities.V3FundsDeposited[],
587586
) {
588587
await across.utils.forEachAsync(deposits, async (deposit) => {
589-
const integratorId = await getIntegratorId(
588+
const integratorId = await utils.getIntegratorId(
590589
this.provider,
591590
deposit.quoteTimestamp,
592591
deposit.transactionHash,

‎packages/indexer/src/data-indexing/service/SvmSpokePoolIndexerDataHandler.ts‎

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ import {
55
getDeployedBlockNumber,
66
SvmSpokeClient,
77
} from "@across-protocol/contracts";
8+
import { Signature, Address, UnixTimestamp } from "@solana/kit";
89

10+
import * as utils from "../../utils";
911
import { BlockRange } from "../model";
1012
import { IndexerDataHandler } from "./IndexerDataHandler";
11-
1213
import { getMaxBlockLookBack } from "../../web3/constants";
1314
import { SvmProvider } from "../../web3/RetryProvidersFactory";
1415

@@ -17,6 +18,36 @@ export type FetchEventsResult = {
1718
fillEvents: any; // TODO: fix type. Needs SDK changes
1819
};
1920

21+
// TODO: Export this type from the SDK and use it from there.
22+
export type EventData =
23+
| SvmSpokeClient.FilledRelay
24+
| SvmSpokeClient.FundsDeposited;
25+
26+
// TODO: Export this type from the SDK and use it from there.
27+
export enum SVMEventNames {
28+
FilledRelay = "FilledRelay",
29+
FundsDeposited = "FundsDeposited",
30+
}
31+
32+
// TODO: Export this type from the SDK and use it from there.
33+
export type EventName = keyof typeof SVMEventNames;
34+
35+
// TODO: Export this type from the SDK and use it from there.
36+
export type EventWithData<T extends EventData> = {
37+
confirmationStatus: string | null;
38+
blockTime: UnixTimestamp | null;
39+
signature: Signature;
40+
slot: bigint;
41+
name: EventName;
42+
data: T;
43+
program: Address;
44+
};
45+
46+
// Teach BigInt how to be represented as JSON.
47+
(BigInt.prototype as any).toJSON = function () {
48+
return this.toString();
49+
};
50+
2051
export class SvmSpokePoolIndexerDataHandler implements IndexerDataHandler {
2152
constructor(
2253
private logger: Logger,
@@ -48,6 +79,8 @@ export class SvmSpokePoolIndexerDataHandler implements IndexerDataHandler {
4879

4980
const events = await this.fetchEventsByRange(blockRange, isBackfilling);
5081

82+
await this.updateNewDepositsWithIntegratorId(events.depositEvents);
83+
5184
this.logger.debug({
5285
at: "Indexer#SpokePoolIndexerDataHandler#processBlockRange",
5386
message: `Found events for ${this.getDataIdentifier()}`,
@@ -62,7 +95,6 @@ export class SvmSpokePoolIndexerDataHandler implements IndexerDataHandler {
6295
// - store events
6396
// - get block times
6497
// - delete unfinalised events
65-
// - update new deposits with integrator id
6698
// - process events
6799
// - publish price messages
68100
}
@@ -126,4 +158,18 @@ export class SvmSpokePoolIndexerDataHandler implements IndexerDataHandler {
126158
fillEvents,
127159
};
128160
}
161+
162+
private async updateNewDepositsWithIntegratorId(
163+
deposits: EventWithData<SvmSpokeClient.FundsDeposited>[],
164+
) {
165+
await across.utils.forEachAsync(deposits, async (deposit) => {
166+
const integratorId = await utils.getSvmIntegratorId(
167+
this.provider,
168+
deposit.signature,
169+
);
170+
if (integratorId) {
171+
// TODO: update deposit with integrator id when we are storing them in the database
172+
}
173+
});
174+
}
129175
}

‎packages/indexer/src/utils/spokePoolUtils.ts‎

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { interfaces, providers } from "@across-protocol/sdk";
22
import { utils as ethersUtils } from "ethers";
3+
import { SvmProvider } from "../web3/RetryProvidersFactory";
34

45
export type V3FundsDepositedWithIntegradorId = interfaces.DepositWithBlock & {
56
integratorId?: string | undefined;
@@ -39,6 +40,28 @@ export async function getIntegratorId(
3940
return integratorId;
4041
}
4142

43+
export async function getSvmIntegratorId(
44+
provider: SvmProvider,
45+
txnRef: any, // TODO: fix, should be Signature
46+
) {
47+
const INTEGRATOR_DELIMITER = "1dc0de";
48+
const INTEGRATOR_ID_LENGTH = 4; // Integrator ids are 4 characters long
49+
const txn = await provider
50+
.getTransaction(txnRef, {
51+
maxSupportedTransactionVersion: 0,
52+
})
53+
.send();
54+
const txnLogs = txn?.meta?.logMessages;
55+
const integratorIdLog = txnLogs?.find((log) =>
56+
log.includes(INTEGRATOR_DELIMITER),
57+
);
58+
const integratorId = integratorIdLog
59+
?.split(INTEGRATOR_DELIMITER)
60+
.pop()
61+
?.substring(0, INTEGRATOR_ID_LENGTH);
62+
return integratorId;
63+
}
64+
4265
export function getInternalHash(
4366
relayData: Omit<interfaces.RelayData, "message">,
4467
messageHash: string,

‎packages/indexer/src/web3/constants.ts‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ const DEFAULT_NO_TTL_DISTANCE: { [chainId: number]: number } = {
2525
[CHAIN_IDs.WORLD_CHAIN]: 86400,
2626
[CHAIN_IDs.ZK_SYNC]: 172800,
2727
[CHAIN_IDs.ZORA]: 86400,
28+
// Testnets:
29+
[CHAIN_IDs.SOLANA_DEVNET]: 432000,
2830
};
2931

3032
export function getNoTtlBlockDistance(chainId: number) {

0 commit comments

Comments
 (0)