Skip to content

Commit

Permalink
Align tests with Route changes
Browse files Browse the repository at this point in the history
  • Loading branch information
mj52951 committed Dec 16, 2024
1 parent f95671f commit 8600e12
Show file tree
Hide file tree
Showing 7 changed files with 136 additions and 88 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type Transfer @entity @index(fields: ["routeID", "depositNonce"], unique: true){
feeID: String
fee: Fee @unique
routeID: String
route: Route
route: Route!
amount: String
}

Expand Down Expand Up @@ -90,5 +90,6 @@ type Route @entity @index(fields: ["fromDomainID", "toDomainID", "resourceID"],
toDomain: Domain

resourceID: String
resource: Resource
transfers: [Transfer!] @derivedFrom(field: "route")
}
28 changes: 22 additions & 6 deletions src/api/schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,27 +152,43 @@ export const executionSchema = {
},
};

export const transferSchema = {
type: "object",
export const routeSchema = {
properties: {
id: {
type: "string",
format: "ObjectId",
example: "2-1-2",
example: "1ffe10e3-c16c-4fdb-a357-380accf1eb66",
},
amount: { type: "string", example: "0.0001" },
fromDomainID: { type: "string", example: "1" },
fromDomain: { ...domainSchema },
toDomainID: { type: "string", nullable: true, example: "2" },
toDomain: { ...domainSchema },
depositNonce: { type: "string", example: "2" },
resource: { ...resourceSchema },
resourceID: {
type: "string",
format: "ObjectId",
example:
"0x0000000000000000000000000000000000000000000000000000000000000300",
},
resource: { ...resourceSchema },
},
};

export const transferSchema = {
type: "object",
properties: {
id: {
type: "string",
format: "ObjectId",
example: "2-1-2",
},
amount: { type: "string", example: "0.0001" },
depositNonce: { type: "string", example: "2" },
routeID: {
type: "string",
format: "ObjectId",
example: "1ffe10e3-c16c-4fdb-a357-380accf1eb66",
},
route: { ...routeSchema },
status: { ...transferStatusSchema },
deposit: { ...depositSchema },
execution: { ...executionSchema },
Expand Down
2 changes: 1 addition & 1 deletion src/api/services/dataAccess/transfers.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class TransfersService {
relations: {
deposit: true,
execution: true,
route: true,
route: { resource: true, fromDomain: true, toDomain: true },
fee: { token: true },
},
});
Expand Down
13 changes: 9 additions & 4 deletions src/model/generated/route.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
The Licensed Work is (c) 2024 Sygma
SPDX-License-Identifier: LGPL-3.0-only
*/
import {Entity as Entity_, PrimaryColumn as PrimaryColumn_, Index as Index_, StringColumn as StringColumn_, ManyToOne as ManyToOne_} from "@subsquid/typeorm-store"
import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_, StringColumn as StringColumn_, ManyToOne as ManyToOne_, OneToMany as OneToMany_} from "@subsquid/typeorm-store"
import {Domain} from "./domain.model"
import { OneToMany, PrimaryGeneratedColumn } from "typeorm"
import { Transfer } from "./transfer.model"
import {Resource} from "./resource.model"
import {Transfer} from "./transfer.model"
import { PrimaryGeneratedColumn } from "typeorm"

@Index_(["fromDomainID", "toDomainID", "resourceID"], {unique: true})
@Entity_()
Expand Down Expand Up @@ -34,6 +35,10 @@ export class Route {
@StringColumn_({nullable: true})
resourceID!: string | undefined | null

@OneToMany(() => Transfer, e => e.route)
@Index_()
@ManyToOne_(() => Resource, {nullable: true})
resource!: Resource | undefined | null

@OneToMany_(() => Transfer, e => e.route)
transfers!: Transfer[]
}
4 changes: 2 additions & 2 deletions src/model/generated/transfer.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
The Licensed Work is (c) 2024 Sygma
SPDX-License-Identifier: LGPL-3.0-only
*/
import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, StringColumn as StringColumn_, OneToOne as OneToOne_, Index as Index_, JoinColumn as JoinColumn_, ManyToOne as ManyToOne_} from "@subsquid/typeorm-store"
import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, Index as Index_, StringColumn as StringColumn_, OneToOne as OneToOne_, JoinColumn as JoinColumn_, ManyToOne as ManyToOne_} from "@subsquid/typeorm-store"
import {TransferStatus} from "./_transferStatus"
import {Deposit} from "./deposit.model"
import {Execution} from "./execution.model"
Expand Down Expand Up @@ -48,7 +48,7 @@ export class Transfer {

@Index_()
@ManyToOne_(() => Route, {nullable: true})
route!: Route | undefined | null
route!: Route

@StringColumn_({nullable: true})
amount!: string | undefined | null
Expand Down
Loading

0 comments on commit 8600e12

Please sign in to comment.