@merkl/api 0.10.184 → 0.10.186

Sign up to get free protection for your applications and to get access to all the features.
@@ -1594,6 +1594,27 @@ declare const eden: {
1594
1594
  }[];
1595
1595
  }>>;
1596
1596
  };
1597
+ engine: {
1598
+ post: (body: {
1599
+ timestamp: number;
1600
+ chainId: number;
1601
+ root: string;
1602
+ epoch: number;
1603
+ }, options: {
1604
+ headers: {
1605
+ authorization: string;
1606
+ };
1607
+ query?: Record<string, unknown> | undefined;
1608
+ fetch?: RequestInit | undefined;
1609
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
1610
+ 200: {
1611
+ timestamp: bigint;
1612
+ chainId: number;
1613
+ root: string;
1614
+ epoch: number;
1615
+ };
1616
+ }>>;
1617
+ };
1597
1618
  };
1598
1619
  interaction: {
1599
1620
  targets: {
@@ -3913,6 +3934,32 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
3913
3934
  };
3914
3935
  };
3915
3936
  };
3937
+ } & {
3938
+ roots: {
3939
+ engine: {
3940
+ post: {
3941
+ body: {
3942
+ timestamp: number;
3943
+ chainId: number;
3944
+ root: string;
3945
+ epoch: number;
3946
+ };
3947
+ params: {};
3948
+ query: unknown;
3949
+ headers: {
3950
+ authorization: string;
3951
+ };
3952
+ response: {
3953
+ 200: {
3954
+ timestamp: bigint;
3955
+ chainId: number;
3956
+ root: string;
3957
+ epoch: number;
3958
+ };
3959
+ };
3960
+ };
3961
+ };
3962
+ };
3916
3963
  };
3917
3964
  } & {
3918
3965
  v4: {
@@ -5981,6 +6028,27 @@ export declare const MerklApi: (domain: string | import("elysia").default<"", fa
5981
6028
  }[];
5982
6029
  }>>;
5983
6030
  };
6031
+ engine: {
6032
+ post: (body: {
6033
+ timestamp: number;
6034
+ chainId: number;
6035
+ root: string;
6036
+ epoch: number;
6037
+ }, options: {
6038
+ headers: {
6039
+ authorization: string;
6040
+ };
6041
+ query?: Record<string, unknown> | undefined;
6042
+ fetch?: RequestInit | undefined;
6043
+ }) => Promise<import("@elysiajs/eden").Treaty.TreatyResponse<{
6044
+ 200: {
6045
+ timestamp: bigint;
6046
+ chainId: number;
6047
+ root: string;
6048
+ epoch: number;
6049
+ };
6050
+ }>>;
6051
+ };
5984
6052
  };
5985
6053
  interaction: {
5986
6054
  targets: {
@@ -1959,6 +1959,32 @@ declare const app: Elysia<"", false, {
1959
1959
  };
1960
1960
  };
1961
1961
  };
1962
+ } & {
1963
+ roots: {
1964
+ engine: {
1965
+ post: {
1966
+ body: {
1967
+ timestamp: number;
1968
+ chainId: number;
1969
+ root: string;
1970
+ epoch: number;
1971
+ };
1972
+ params: {};
1973
+ query: unknown;
1974
+ headers: {
1975
+ authorization: string;
1976
+ };
1977
+ response: {
1978
+ 200: {
1979
+ timestamp: bigint;
1980
+ chainId: number;
1981
+ root: string;
1982
+ epoch: number;
1983
+ };
1984
+ };
1985
+ };
1986
+ };
1987
+ };
1962
1988
  };
1963
1989
  } & {
1964
1990
  v4: {
@@ -52,6 +52,32 @@ export declare const MerklRootController: Elysia<"/roots", false, {
52
52
  };
53
53
  };
54
54
  };
55
+ } & {
56
+ roots: {
57
+ engine: {
58
+ post: {
59
+ body: {
60
+ timestamp: number;
61
+ chainId: number;
62
+ root: string;
63
+ epoch: number;
64
+ };
65
+ params: {};
66
+ query: unknown;
67
+ headers: {
68
+ authorization: string;
69
+ };
70
+ response: {
71
+ 200: {
72
+ timestamp: bigint;
73
+ chainId: number;
74
+ root: string;
75
+ epoch: number;
76
+ };
77
+ };
78
+ };
79
+ };
80
+ };
55
81
  }, {
56
82
  derive: {};
57
83
  resolve: {};
@@ -1,8 +1,9 @@
1
+ import { AuthorizationHeadersDto, EngineGuard } from "../../../guards/Engine.guard";
1
2
  import { throwOnUnsupportedChainId } from "../../../utils/throw";
2
3
  import Elysia from "elysia";
3
- import { RootByTimestampsDto } from "./merklRoot.model";
4
+ import { CreateRootDto, RootByTimestampsDto } from "./merklRoot.model";
4
5
  import { MerklRootService } from "./merklRoot.service";
5
- // ─── Merkl Roots Controller ──────────────────────────────────────────────────
6
+ // ─── Merkl Roots Controller ─────────────────────────────────────────────
6
7
  export const MerklRootController = new Elysia({ prefix: "/roots", detail: { tags: ["Roots"] } })
7
8
  // ─── Get Merkl Root By Timestamp ─────────────────────────────────────
8
9
  .get("/", async ({ query }) => await MerklRootService.rootForTimestamp(query), {
@@ -12,4 +13,16 @@ export const MerklRootController = new Elysia({ prefix: "/roots", detail: { tags
12
13
  },
13
14
  })
14
15
  // ─── Get all live Merkl Roots ─────────────────────────────────────────
15
- .get("/live", async () => await MerklRootService.fetchAll());
16
+ .get("/live", async () => await MerklRootService.fetchAll())
17
+ // ─── Create a Merkl Root Entry ────────────────────────────────────────
18
+ .post("/engine", async ({ body }) => {
19
+ return await MerklRootService.create(body);
20
+ }, {
21
+ headers: AuthorizationHeadersDto,
22
+ body: CreateRootDto,
23
+ beforeHandle: ({ headers, body }) => {
24
+ EngineGuard({ headers });
25
+ throwOnUnsupportedChainId(body.chainId);
26
+ },
27
+ detail: { hide: true },
28
+ });
@@ -3,4 +3,11 @@ export declare const RootByTimestampsDto: import("@sinclair/typebox").TObject<{
3
3
  fromTimestamp: import("@sinclair/typebox").TString;
4
4
  toTimestamp: import("@sinclair/typebox").TString;
5
5
  }>;
6
+ export declare const CreateRootDto: import("@sinclair/typebox").TObject<{
7
+ chainId: import("@sinclair/typebox").TNumber;
8
+ root: import("@sinclair/typebox").TString;
9
+ timestamp: import("@sinclair/typebox").TNumber;
10
+ epoch: import("@sinclair/typebox").TNumber;
11
+ }>;
6
12
  export type RootByTimestampModel = typeof RootByTimestampsDto.static;
13
+ export type CreateRootModel = typeof CreateRootDto.static;
@@ -4,3 +4,9 @@ export const RootByTimestampsDto = t.Object({
4
4
  fromTimestamp: t.String(),
5
5
  toTimestamp: t.String(),
6
6
  });
7
+ export const CreateRootDto = t.Object({
8
+ chainId: t.Numeric(),
9
+ root: t.String(),
10
+ timestamp: t.Numeric(),
11
+ epoch: t.Numeric(),
12
+ });
@@ -1,5 +1,5 @@
1
1
  import { type ChainId } from "@sdk";
2
- import type { RootByTimestampModel } from "./merklRoot.model";
2
+ import type { CreateRootModel, RootByTimestampModel } from "./merklRoot.model";
3
3
  export declare class MerklRootRepository {
4
4
  static firstRoot(chainId: ChainId): Promise<{
5
5
  timestamp: bigint;
@@ -18,4 +18,10 @@ export declare class MerklRootRepository {
18
18
  tree: any;
19
19
  lastTree: any;
20
20
  }>;
21
+ static create(x: CreateRootModel): Promise<{
22
+ timestamp: bigint;
23
+ chainId: number;
24
+ root: string;
25
+ epoch: number;
26
+ }>;
21
27
  }
@@ -28,4 +28,9 @@ export class MerklRootRepository {
28
28
  const [tree, lastTree] = await DistributorService(chainId).fetchTreeAndLastTreeMerklRoots();
29
29
  return { live, tree, lastTree };
30
30
  }
31
+ static async create(x) {
32
+ return await apiDbClient.merklRoot.create({
33
+ data: x,
34
+ });
35
+ }
31
36
  }
@@ -1,6 +1,6 @@
1
1
  import type { CacheKeys } from "../../../cache/keys";
2
2
  import type { ChainId } from "@sdk";
3
- import type { RootByTimestampModel } from "./merklRoot.model";
3
+ import type { CreateRootModel, RootByTimestampModel } from "./merklRoot.model";
4
4
  export declare class MerklRootService {
5
5
  static firstRoot(chainId: ChainId): Promise<{
6
6
  timestamp: bigint;
@@ -30,4 +30,10 @@ export declare class MerklRootService {
30
30
  tree: string;
31
31
  lastTree: string;
32
32
  }[]>;
33
+ static create(x: CreateRootModel): Promise<{
34
+ timestamp: bigint;
35
+ chainId: number;
36
+ root: string;
37
+ epoch: number;
38
+ }>;
33
39
  }
@@ -35,4 +35,7 @@ export class MerklRootService {
35
35
  return roots;
36
36
  });
37
37
  }
38
+ static async create(x) {
39
+ return await MerklRootRepository.create(x);
40
+ }
38
41
  }
@@ -1941,6 +1941,32 @@ export declare const v4: Elysia<"/v4", false, {
1941
1941
  };
1942
1942
  };
1943
1943
  };
1944
+ } & {
1945
+ roots: {
1946
+ engine: {
1947
+ post: {
1948
+ body: {
1949
+ timestamp: number;
1950
+ chainId: number;
1951
+ root: string;
1952
+ epoch: number;
1953
+ };
1954
+ params: {};
1955
+ query: unknown;
1956
+ headers: {
1957
+ authorization: string;
1958
+ };
1959
+ response: {
1960
+ 200: {
1961
+ timestamp: bigint;
1962
+ chainId: number;
1963
+ root: string;
1964
+ epoch: number;
1965
+ };
1966
+ };
1967
+ };
1968
+ };
1969
+ };
1944
1970
  };
1945
1971
  } & {
1946
1972
  v4: {
@@ -1965,6 +1965,32 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
1965
1965
  };
1966
1966
  };
1967
1967
  };
1968
+ } & {
1969
+ roots: {
1970
+ engine: {
1971
+ post: {
1972
+ body: {
1973
+ timestamp: number;
1974
+ chainId: number;
1975
+ root: string;
1976
+ epoch: number;
1977
+ };
1978
+ params: {};
1979
+ query: unknown;
1980
+ headers: {
1981
+ authorization: string;
1982
+ };
1983
+ response: {
1984
+ 200: {
1985
+ timestamp: bigint;
1986
+ chainId: number;
1987
+ root: string;
1988
+ epoch: number;
1989
+ };
1990
+ };
1991
+ };
1992
+ };
1993
+ };
1968
1994
  };
1969
1995
  } & {
1970
1996
  v4: {
@@ -1968,6 +1968,32 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
1968
1968
  };
1969
1969
  };
1970
1970
  };
1971
+ } & {
1972
+ roots: {
1973
+ engine: {
1974
+ post: {
1975
+ body: {
1976
+ timestamp: number;
1977
+ chainId: number;
1978
+ root: string;
1979
+ epoch: number;
1980
+ };
1981
+ params: {};
1982
+ query: unknown;
1983
+ headers: {
1984
+ authorization: string;
1985
+ };
1986
+ response: {
1987
+ 200: {
1988
+ timestamp: bigint;
1989
+ chainId: number;
1990
+ root: string;
1991
+ epoch: number;
1992
+ };
1993
+ };
1994
+ };
1995
+ };
1996
+ };
1971
1997
  };
1972
1998
  } & {
1973
1999
  v4: {
@@ -1959,6 +1959,32 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
1959
1959
  };
1960
1960
  };
1961
1961
  };
1962
+ } & {
1963
+ roots: {
1964
+ engine: {
1965
+ post: {
1966
+ body: {
1967
+ timestamp: number;
1968
+ chainId: number;
1969
+ root: string;
1970
+ epoch: number;
1971
+ };
1972
+ params: {};
1973
+ query: unknown;
1974
+ headers: {
1975
+ authorization: string;
1976
+ };
1977
+ response: {
1978
+ 200: {
1979
+ timestamp: bigint;
1980
+ chainId: number;
1981
+ root: string;
1982
+ epoch: number;
1983
+ };
1984
+ };
1985
+ };
1986
+ };
1987
+ };
1962
1988
  };
1963
1989
  } & {
1964
1990
  v4: {
@@ -1964,6 +1964,32 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
1964
1964
  };
1965
1965
  };
1966
1966
  };
1967
+ } & {
1968
+ roots: {
1969
+ engine: {
1970
+ post: {
1971
+ body: {
1972
+ timestamp: number;
1973
+ chainId: number;
1974
+ root: string;
1975
+ epoch: number;
1976
+ };
1977
+ params: {};
1978
+ query: unknown;
1979
+ headers: {
1980
+ authorization: string;
1981
+ };
1982
+ response: {
1983
+ 200: {
1984
+ timestamp: bigint;
1985
+ chainId: number;
1986
+ root: string;
1987
+ epoch: number;
1988
+ };
1989
+ };
1990
+ };
1991
+ };
1992
+ };
1967
1993
  };
1968
1994
  } & {
1969
1995
  v4: {
@@ -1982,6 +1982,32 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
1982
1982
  };
1983
1983
  };
1984
1984
  };
1985
+ } & {
1986
+ roots: {
1987
+ engine: {
1988
+ post: {
1989
+ body: {
1990
+ timestamp: number;
1991
+ chainId: number;
1992
+ root: string;
1993
+ epoch: number;
1994
+ };
1995
+ params: {};
1996
+ query: unknown;
1997
+ headers: {
1998
+ authorization: string;
1999
+ };
2000
+ response: {
2001
+ 200: {
2002
+ timestamp: bigint;
2003
+ chainId: number;
2004
+ root: string;
2005
+ epoch: number;
2006
+ };
2007
+ };
2008
+ };
2009
+ };
2010
+ };
1985
2011
  };
1986
2012
  } & {
1987
2013
  v4: {
@@ -1983,6 +1983,32 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
1983
1983
  };
1984
1984
  };
1985
1985
  };
1986
+ } & {
1987
+ roots: {
1988
+ engine: {
1989
+ post: {
1990
+ body: {
1991
+ timestamp: number;
1992
+ chainId: number;
1993
+ root: string;
1994
+ epoch: number;
1995
+ };
1996
+ params: {};
1997
+ query: unknown;
1998
+ headers: {
1999
+ authorization: string;
2000
+ };
2001
+ response: {
2002
+ 200: {
2003
+ timestamp: bigint;
2004
+ chainId: number;
2005
+ root: string;
2006
+ epoch: number;
2007
+ };
2008
+ };
2009
+ };
2010
+ };
2011
+ };
1986
2012
  };
1987
2013
  } & {
1988
2014
  v4: {
@@ -1965,6 +1965,32 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
1965
1965
  };
1966
1966
  };
1967
1967
  };
1968
+ } & {
1969
+ roots: {
1970
+ engine: {
1971
+ post: {
1972
+ body: {
1973
+ timestamp: number;
1974
+ chainId: number;
1975
+ root: string;
1976
+ epoch: number;
1977
+ };
1978
+ params: {};
1979
+ query: unknown;
1980
+ headers: {
1981
+ authorization: string;
1982
+ };
1983
+ response: {
1984
+ 200: {
1985
+ timestamp: bigint;
1986
+ chainId: number;
1987
+ root: string;
1988
+ epoch: number;
1989
+ };
1990
+ };
1991
+ };
1992
+ };
1993
+ };
1968
1994
  };
1969
1995
  } & {
1970
1996
  v4: {
@@ -1966,6 +1966,32 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
1966
1966
  };
1967
1967
  };
1968
1968
  };
1969
+ } & {
1970
+ roots: {
1971
+ engine: {
1972
+ post: {
1973
+ body: {
1974
+ timestamp: number;
1975
+ chainId: number;
1976
+ root: string;
1977
+ epoch: number;
1978
+ };
1979
+ params: {};
1980
+ query: unknown;
1981
+ headers: {
1982
+ authorization: string;
1983
+ };
1984
+ response: {
1985
+ 200: {
1986
+ timestamp: bigint;
1987
+ chainId: number;
1988
+ root: string;
1989
+ epoch: number;
1990
+ };
1991
+ };
1992
+ };
1993
+ };
1994
+ };
1969
1995
  };
1970
1996
  } & {
1971
1997
  v4: {
@@ -1968,6 +1968,32 @@ declare const _default: (app: App) => import("elysia").default<"", false, {
1968
1968
  };
1969
1969
  };
1970
1970
  };
1971
+ } & {
1972
+ roots: {
1973
+ engine: {
1974
+ post: {
1975
+ body: {
1976
+ timestamp: number;
1977
+ chainId: number;
1978
+ root: string;
1979
+ epoch: number;
1980
+ };
1981
+ params: {};
1982
+ query: unknown;
1983
+ headers: {
1984
+ authorization: string;
1985
+ };
1986
+ response: {
1987
+ 200: {
1988
+ timestamp: bigint;
1989
+ chainId: number;
1990
+ root: string;
1991
+ epoch: number;
1992
+ };
1993
+ };
1994
+ };
1995
+ };
1996
+ };
1971
1997
  };
1972
1998
  } & {
1973
1999
  v4: {