@evergonlabs/tmi-protocol-api 0.1.1 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/dist/app.d.ts +31 -9
  2. package/dist/app.d.ts.map +1 -1
  3. package/dist/client.d.ts +39 -9
  4. package/dist/client.d.ts.map +1 -1
  5. package/dist/common/abis/erc20Whitelisted.d.ts +293 -3
  6. package/dist/common/abis/erc20Whitelisted.d.ts.map +1 -1
  7. package/dist/common/abis/erc20Whitelisted.js +943 -4
  8. package/dist/fractions/index.d.ts +25 -0
  9. package/dist/fractions/index.d.ts.map +1 -1
  10. package/dist/fractions/index.js +2 -0
  11. package/dist/fractions/purchase/v0/statistics.route.d.ts +65 -0
  12. package/dist/fractions/purchase/v0/statistics.route.d.ts.map +1 -0
  13. package/dist/fractions/purchase/v0/statistics.route.js +52 -0
  14. package/dist/general/balanceClient.d.ts +59 -0
  15. package/dist/general/balanceClient.d.ts.map +1 -0
  16. package/dist/general/balanceClient.js +28 -0
  17. package/dist/general/getBalance.d.ts +0 -4
  18. package/dist/general/getBalance.d.ts.map +1 -1
  19. package/dist/general/getBalance.js +3 -4
  20. package/dist/general/getBalancesBatch.d.ts +3 -3
  21. package/dist/general/getBalancesBatch.d.ts.map +1 -1
  22. package/dist/general/getBalancesBatch.js +1 -1
  23. package/dist/general/index.d.ts +6 -9
  24. package/dist/general/index.d.ts.map +1 -1
  25. package/dist/general/searchBalances.d.ts +15 -23
  26. package/dist/general/searchBalances.d.ts.map +1 -1
  27. package/dist/general/searchBalances.js +12 -16
  28. package/dist/general/utils/tokenBalance/tokenBalance.d.ts +28 -0
  29. package/dist/general/utils/tokenBalance/tokenBalance.d.ts.map +1 -0
  30. package/dist/general/utils/tokenBalance/tokenBalance.js +20 -0
  31. package/dist/issuance/renounceRole.d.ts.map +1 -1
  32. package/package.json +5 -5
@@ -677,6 +677,31 @@ export declare const fractionsApi: {
677
677
  status: import("hono/utils/http-status").ContentfulStatusCode;
678
678
  };
679
679
  };
680
+ } & {
681
+ "/purchase/statistics": {
682
+ $post: {
683
+ input: {
684
+ json: {
685
+ platform: `0x${string}`;
686
+ campaignId: string | number | bigint;
687
+ walletAddress: `0x${string}`;
688
+ chainId?: import("@evergonlabs/tmi-protocol-fractions-sdk").TmiChainId | undefined;
689
+ };
690
+ };
691
+ output: {
692
+ chainId: import("@evergonlabs/tmi-protocol-fractions-sdk").TmiChainId;
693
+ platform: `0x${string}`;
694
+ campaignId: string;
695
+ statistics: {
696
+ priceId: string;
697
+ purchases: number;
698
+ fractionsSold: string;
699
+ }[];
700
+ };
701
+ outputFormat: "json";
702
+ status: 200;
703
+ };
704
+ };
680
705
  } & {
681
706
  "/withdraw/search": {
682
707
  $post: {
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/fractions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAsGvC,eAAO,MAAM,YAAY;;gBAEX,CAAC,SAAS,GAAG,WAAW,OAAO,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAkB/C,CAAC"}
@@ -27,6 +27,7 @@ import { createInitNidTransaction } from "./deployMarket/v0/initNid.route.js";
27
27
  import { createSearchWithdrawalV0App } from "./sales/searchWithdrawal.route.js";
28
28
  import { createSaleStatisticsV0App } from "./sales/getFractionSaleStatistics.route.js";
29
29
  import { createSearchActivityV0App } from "./activity/searchActivity.route.js";
30
+ import { createPurchaseSalesStatisticsV0 } from "./purchase/v0/statistics.route.js";
30
31
  function createPlatformsApp(factory) {
31
32
  return factory
32
33
  .createApp()
@@ -60,6 +61,7 @@ function createSalesApp(factory) {
60
61
  .post("/complete", ...createCompleteSalesTransactionV0(factory))
61
62
  .post("/unlockWrappedAssets", ...createUnlockWrappedAssetsTransactionV0(factory))
62
63
  .post("/purchase", ...createPurchaseSalesTransactionV0(factory))
64
+ .post("/purchase/statistics", ...createPurchaseSalesStatisticsV0(factory))
63
65
  .post("/withdraw/search", ...createSearchWithdrawalV0App(factory))
64
66
  .post("/withdrawPaymentToken", ...createWithdrawPaymentFromSaleTransactionV0(factory))
65
67
  .post("/receiveFundsAfterNonFunded", ...createReceiveFundsAfterNonFundedTransaction(factory))
@@ -0,0 +1,65 @@
1
+ import { Env } from "hono";
2
+ import { Factory } from "hono/factory";
3
+ export declare function createPurchaseSalesStatisticsV0<E extends Env>(factory: Factory<E>): [import("hono/types").H<any, string, {}, Promise<Response & import("hono").TypedResponse<{
4
+ chainId: import("@evergonlabs/tmi-protocol-fractions-sdk").TmiChainId;
5
+ platform: `0x${string}`;
6
+ campaignId: string;
7
+ statistics: {
8
+ priceId: string;
9
+ purchases: number;
10
+ fractionsSold: string;
11
+ }[];
12
+ }, 200, "json">>>, import("hono/types").H<Env, string, {
13
+ in: {
14
+ json: {
15
+ platform: `0x${string}`;
16
+ campaignId: string | number | bigint;
17
+ walletAddress: `0x${string}`;
18
+ chainId?: import("@evergonlabs/tmi-protocol-fractions-sdk").TmiChainId | undefined;
19
+ };
20
+ };
21
+ out: {
22
+ json: {
23
+ platform: `0x${string}`;
24
+ campaignId: bigint;
25
+ walletAddress: `0x${string}`;
26
+ chainId?: import("@evergonlabs/tmi-protocol-fractions-sdk").TmiChainId | undefined;
27
+ };
28
+ };
29
+ }, Promise<Response & import("hono").TypedResponse<{
30
+ chainId: import("@evergonlabs/tmi-protocol-fractions-sdk").TmiChainId;
31
+ platform: `0x${string}`;
32
+ campaignId: string;
33
+ statistics: {
34
+ priceId: string;
35
+ purchases: number;
36
+ fractionsSold: string;
37
+ }[];
38
+ }, 200, "json">>>, import("hono/types").H<import("hono/utils/types").IfAnyThenEmptyObject<E extends Env ? Env extends E ? {} : E : E> & {}, string, {
39
+ in: {
40
+ json: {
41
+ platform: `0x${string}`;
42
+ campaignId: string | number | bigint;
43
+ walletAddress: `0x${string}`;
44
+ chainId?: import("@evergonlabs/tmi-protocol-fractions-sdk").TmiChainId | undefined;
45
+ };
46
+ };
47
+ out: {
48
+ json: {
49
+ platform: `0x${string}`;
50
+ campaignId: bigint;
51
+ walletAddress: `0x${string}`;
52
+ chainId?: import("@evergonlabs/tmi-protocol-fractions-sdk").TmiChainId | undefined;
53
+ };
54
+ };
55
+ }, Promise<Response & import("hono").TypedResponse<{
56
+ chainId: import("@evergonlabs/tmi-protocol-fractions-sdk").TmiChainId;
57
+ platform: `0x${string}`;
58
+ campaignId: string;
59
+ statistics: {
60
+ priceId: string;
61
+ purchases: number;
62
+ fractionsSold: string;
63
+ }[];
64
+ }, 200, "json">>>];
65
+ //# sourceMappingURL=statistics.route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"statistics.route.d.ts","sourceRoot":"","sources":["../../../../src/fractions/purchase/v0/statistics.route.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAUvC,wBAAgB,+BAA+B,CAAC,CAAC,SAAS,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAiEjF"}
@@ -0,0 +1,52 @@
1
+ import { describeRoute } from "hono-openapi";
2
+ import { resolver, validator } from "hono-openapi/zod";
3
+ import { and, count, eq, sum } from "@ponder/client";
4
+ import { FractionsSaleStatisticSchema } from "../../sales/getFractionSaleStatistics.route.js";
5
+ import { AddressSchema, CampaignIdSchema, PlatformContractAddress, TmiChainIdSchema } from "../../../common/index.js";
6
+ import { z } from "../../../common/zod.js";
7
+ import { indexerSchemas } from "../../../common/indexer/schemas.js";
8
+ import { indexerClient } from "../../../common/indexer/index.js";
9
+ export function createPurchaseSalesStatisticsV0(factory) {
10
+ return factory.createHandlers(describeRoute({
11
+ summary: "Aggregate investor statistics for certain campaign",
12
+ description: "Returns aggregated statistics about investor purchases for a specific campaign, grouped by price ID. Statistics include the number of purchases and the total number of fractions sold.",
13
+ tags: ["Fractions"],
14
+ responses: {
15
+ 200: {
16
+ description: "Aggregated purchase statistics for the specified campaign and investor.",
17
+ content: {
18
+ "application/json": {
19
+ schema: resolver(FractionsSaleStatisticSchema),
20
+ },
21
+ },
22
+ },
23
+ },
24
+ }), validator("json", z.object({
25
+ chainId: TmiChainIdSchema.optional(),
26
+ platform: PlatformContractAddress,
27
+ campaignId: CampaignIdSchema,
28
+ walletAddress: AddressSchema,
29
+ })), async (c) => {
30
+ const { chainId, platform, campaignId, walletAddress } = c.req.valid("json");
31
+ const { fractions: { fractionsPurchases }, } = indexerSchemas;
32
+ const rows = await indexerClient.db
33
+ .select({
34
+ purchases: count(fractionsPurchases.transactionHash),
35
+ fractionsSold: sum(fractionsPurchases.amountOfFractions),
36
+ priceId: fractionsPurchases.priceId,
37
+ })
38
+ .from(fractionsPurchases)
39
+ .where(and(eq(fractionsPurchases.chainId, Number(chainId)), eq(fractionsPurchases.diamondAddress, platform), eq(fractionsPurchases.saleId, BigInt(campaignId)), eq(fractionsPurchases.buyerAddress, walletAddress)))
40
+ .groupBy(fractionsPurchases.priceId);
41
+ const statistics = rows.map((r) => ({
42
+ ...r,
43
+ fractionsSold: r.fractionsSold || "0",
44
+ }));
45
+ return c.json(FractionsSaleStatisticSchema.parse({
46
+ chainId: chainId,
47
+ platform: platform,
48
+ campaignId: campaignId,
49
+ statistics,
50
+ }), 200);
51
+ });
52
+ }
@@ -0,0 +1,59 @@
1
+ import { Address } from "viem";
2
+ import { TmiChainId } from "@evergonlabs/tmi-protocol-fractions-sdk";
3
+ import { TokenBalance } from "./utils/tokenBalance/tokenBalance.js";
4
+ import { z } from "../common/zod.js";
5
+ export declare const AccountBalancesResponse: z.ZodObject<{
6
+ message: z.ZodString;
7
+ status: z.ZodString;
8
+ result: z.ZodArray<z.ZodObject<{
9
+ balance: z.ZodPipeline<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBigInt]>, z.ZodString>;
10
+ tokenAddress: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
11
+ decimals: z.ZodEffects<z.ZodPipeline<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBigInt]>, z.ZodNumber>, number, string | number | bigint>;
12
+ tokenId: z.ZodOptional<z.ZodPipeline<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBigInt]>, z.ZodString>>;
13
+ name: z.ZodString;
14
+ symbol: z.ZodString;
15
+ type: z.ZodEffects<z.ZodString, import("@evergonlabs/tmi-protocol-types/evm").TokenTypeEnum | null, string>;
16
+ }, "strip", z.ZodTypeAny, {
17
+ symbol: string;
18
+ type: import("@evergonlabs/tmi-protocol-types/evm").TokenTypeEnum | null;
19
+ name: string;
20
+ decimals: number;
21
+ tokenAddress: `0x${string}`;
22
+ balance: string;
23
+ tokenId?: string | undefined;
24
+ }, {
25
+ symbol: string;
26
+ type: string;
27
+ name: string;
28
+ decimals: string | number | bigint;
29
+ tokenAddress: `0x${string}`;
30
+ balance: string | number | bigint;
31
+ tokenId?: string | number | bigint | undefined;
32
+ }>, "many">;
33
+ }, "strip", z.ZodTypeAny, {
34
+ status: string;
35
+ message: string;
36
+ result: {
37
+ symbol: string;
38
+ type: import("@evergonlabs/tmi-protocol-types/evm").TokenTypeEnum | null;
39
+ name: string;
40
+ decimals: number;
41
+ tokenAddress: `0x${string}`;
42
+ balance: string;
43
+ tokenId?: string | undefined;
44
+ }[];
45
+ }, {
46
+ status: string;
47
+ message: string;
48
+ result: {
49
+ symbol: string;
50
+ type: string;
51
+ name: string;
52
+ decimals: string | number | bigint;
53
+ tokenAddress: `0x${string}`;
54
+ balance: string | number | bigint;
55
+ tokenId?: string | number | bigint | undefined;
56
+ }[];
57
+ }>;
58
+ export declare function getAccountBalances(wallet: Address, chainId: TmiChainId): Promise<z.infer<typeof TokenBalance>[]>;
59
+ //# sourceMappingURL=balanceClient.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"balanceClient.d.ts","sourceRoot":"","sources":["../../src/general/balanceClient.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAE,MAAM,yCAAyC,CAAC;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,sCAAsC,CAAC;AACpE,OAAO,EAAE,CAAC,EAAE,MAAM,kBAAkB,CAAC;AAErC,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAIlC,CAAC;AAEH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,OAAO,EACf,OAAO,EAAE,UAAU,GAClB,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,YAAY,CAAC,EAAE,CAAC,CAkBzC"}
@@ -0,0 +1,28 @@
1
+ import axios from "axios";
2
+ import { getBalancesApi } from "../common/blockchain.js";
3
+ import { TokenBalance } from "./utils/tokenBalance/tokenBalance.js";
4
+ import { z } from "../common/zod.js";
5
+ export const AccountBalancesResponse = z.object({
6
+ message: z.string(),
7
+ status: z.string(),
8
+ result: z.array(TokenBalance),
9
+ });
10
+ export async function getAccountBalances(wallet, chainId) {
11
+ const url = getBalancesApi(chainId);
12
+ try {
13
+ const result = await axios.get(url, {
14
+ params: {
15
+ module: "account",
16
+ action: "tokenlist",
17
+ address: wallet,
18
+ },
19
+ });
20
+ return result.data.result.map((x) => TokenBalance.parse(x));
21
+ }
22
+ catch (error) {
23
+ if (axios.isAxiosError(error)) {
24
+ throw new Error(`Network error: ${error.message}`);
25
+ }
26
+ throw error;
27
+ }
28
+ }
@@ -9,14 +9,12 @@ export declare function createGetBalanceV0<E extends Env, TTag extends ITag>(fac
9
9
  query: {
10
10
  address: string | string[];
11
11
  chainId: string | string[];
12
- contract: string | string[];
13
12
  };
14
13
  };
15
14
  out: {
16
15
  query: {
17
16
  address: `0x${string}`;
18
17
  chainId: import("@evergonlabs/tmi-protocol-fractions-sdk").TmiChainId;
19
- contract: `0x${string}`;
20
18
  };
21
19
  };
22
20
  }, Promise<Response & import("hono").TypedResponse<{
@@ -27,14 +25,12 @@ export declare function createGetBalanceV0<E extends Env, TTag extends ITag>(fac
27
25
  query: {
28
26
  address: string | string[];
29
27
  chainId: string | string[];
30
- contract: string | string[];
31
28
  };
32
29
  };
33
30
  out: {
34
31
  query: {
35
32
  address: `0x${string}`;
36
33
  chainId: import("@evergonlabs/tmi-protocol-fractions-sdk").TmiChainId;
37
- contract: `0x${string}`;
38
34
  };
39
35
  };
40
36
  }, Promise<Response & import("hono").TypedResponse<{
@@ -1 +1 @@
1
- {"version":3,"file":"getBalance.d.ts","sourceRoot":"","sources":["../../src/general/getBalance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAKvC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGxC,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,GAAG,EAAE,IAAI,SAAS,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qEA+ClG"}
1
+ {"version":3,"file":"getBalance.d.ts","sourceRoot":"","sources":["../../src/general/getBalance.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAKvC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGxC,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,GAAG,EAAE,IAAI,SAAS,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qEA8ClG"}
@@ -7,17 +7,17 @@ import { getQuicknode } from "./common.js";
7
7
  export function createGetBalanceV0(factory, tag) {
8
8
  return factory.createHandlers(describeRoute({
9
9
  summary: "Get balance",
10
- description: "Returns ERC20 balance of a wallet for specific token",
10
+ description: "Returns native balance of a wallet for specific token",
11
11
  tags: [tag.tag],
12
12
  responses: {
13
13
  200: {
14
- description: "Returns ERC20 balances of a wallet",
14
+ description: "Returns native balance of a wallet",
15
15
  content: {
16
16
  "application/json": {
17
17
  schema: resolver(z.object({
18
18
  address: AddressSchema,
19
19
  balance: Int256.openapi({
20
- description: "Amount of tokens in WEI",
20
+ description: "Native tokens in WEI",
21
21
  }),
22
22
  })),
23
23
  },
@@ -27,7 +27,6 @@ export function createGetBalanceV0(factory, tag) {
27
27
  }), validator("query", z.object({
28
28
  chainId: TmiChainIdSchema,
29
29
  address: AddressSchema,
30
- contract: AddressSchema,
31
30
  })), async (c) => {
32
31
  const { chainId, address } = c.req.valid("query");
33
32
  const quicknode = getQuicknode(chainId);
@@ -9,7 +9,7 @@ export declare function createGetBalancesBatchV0<E extends Env, TTag extends ITa
9
9
  decimals: string | null;
10
10
  address: string;
11
11
  totalBalance: string;
12
- }[], 200, "json">>>, import("hono/types").H<Env, string, {
12
+ }[], import("hono/utils/http-status").ContentfulStatusCode, "json">>>, import("hono/types").H<Env, string, {
13
13
  in: {
14
14
  json: {
15
15
  address: `0x${string}`;
@@ -32,7 +32,7 @@ export declare function createGetBalancesBatchV0<E extends Env, TTag extends ITa
32
32
  decimals: string | null;
33
33
  address: string;
34
34
  totalBalance: string;
35
- }[], 200, "json">>>, import("hono/types").H<import("hono/utils/types").IfAnyThenEmptyObject<E extends Env ? Env extends E ? {} : E : E> & {}, string, {
35
+ }[], import("hono/utils/http-status").ContentfulStatusCode, "json">>>, import("hono/types").H<import("hono/utils/types").IfAnyThenEmptyObject<E extends Env ? Env extends E ? {} : E : E> & {}, string, {
36
36
  in: {
37
37
  json: {
38
38
  address: `0x${string}`;
@@ -55,5 +55,5 @@ export declare function createGetBalancesBatchV0<E extends Env, TTag extends ITa
55
55
  decimals: string | null;
56
56
  address: string;
57
57
  totalBalance: string;
58
- }[], 200, "json">>>];
58
+ }[], import("hono/utils/http-status").ContentfulStatusCode, "json">>>];
59
59
  //# sourceMappingURL=getBalancesBatch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"getBalancesBatch.d.ts","sourceRoot":"","sources":["../../src/general/getBalancesBatch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIvC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGxC,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,GAAG,EAAE,IAAI,SAAS,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAqCxG"}
1
+ {"version":3,"file":"getBalancesBatch.d.ts","sourceRoot":"","sources":["../../src/general/getBalancesBatch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIvC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAGxC,wBAAgB,wBAAwB,CAAC,CAAC,SAAS,GAAG,EAAE,IAAI,SAAS,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;uEAqCxG"}
@@ -29,6 +29,6 @@ export function createGetBalancesBatchV0(factory, tag) {
29
29
  wallet: address,
30
30
  contracts: contracts,
31
31
  });
32
- return c.json(result.result, 200);
32
+ return c.json(result.result);
33
33
  });
34
34
  }
@@ -28,7 +28,6 @@ export declare const generalApis: {
28
28
  query: {
29
29
  address: string | string[];
30
30
  chainId: string | string[];
31
- contract: string | string[];
32
31
  };
33
32
  };
34
33
  output: {
@@ -59,7 +58,7 @@ export declare const generalApis: {
59
58
  totalBalance: string;
60
59
  }[];
61
60
  outputFormat: "json";
62
- status: 200;
61
+ status: import("hono/utils/http-status").ContentfulStatusCode;
63
62
  };
64
63
  };
65
64
  } & {
@@ -69,26 +68,24 @@ export declare const generalApis: {
69
68
  json: {
70
69
  address: `0x${string}`;
71
70
  chainId: import("@evergonlabs/tmi-protocol-fractions-sdk").TmiChainId;
72
- page?: number | undefined;
73
- perPage?: number | undefined;
74
71
  };
75
72
  };
76
73
  output: {
77
74
  balances: {
78
75
  tokenAddress: `0x${string}`;
79
- balance: never;
80
- decimals: number | undefined;
76
+ balance: string;
77
+ decimals: number;
81
78
  symbol: string;
82
79
  name: string;
83
- tokenId: undefined;
84
- type: "ERC-20" | "ERC-721" | "ERC-1155";
80
+ tokenId: string | null;
81
+ type: import("@evergonlabs/tmi-protocol-types/evm").TokenTypeEnum | null;
85
82
  }[];
86
83
  totalItems: number;
87
84
  totalPages: number;
88
85
  pageNumber: number;
89
86
  };
90
87
  outputFormat: "json";
91
- status: 200;
88
+ status: import("hono/utils/http-status").ContentfulStatusCode;
92
89
  };
93
90
  };
94
91
  }, "/general">, "/">;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/general/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AASvC,eAAO,MAAM,WAAW;;gBAEV,CAAC,SAAS,GAAG,WAAW,OAAO,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAc/C,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/general/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AASvC,eAAO,MAAM,WAAW;;gBAEV,CAAC,SAAS,GAAG,WAAW,OAAO,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAc/C,CAAC"}
@@ -4,75 +4,67 @@ import { ITag } from "../common/tag.js";
4
4
  export declare function createSearchBalancesV0<E extends Env, TTag extends ITag>(factory: Factory<E>, tag: TTag): [import("hono/types").H<any, string, {}, Promise<Response & import("hono").TypedResponse<{
5
5
  balances: {
6
6
  tokenAddress: `0x${string}`;
7
- balance: never;
8
- decimals: number | undefined;
7
+ balance: string;
8
+ decimals: number;
9
9
  symbol: string;
10
10
  name: string;
11
- tokenId: undefined;
12
- type: "ERC-20" | "ERC-721" | "ERC-1155";
11
+ tokenId: string | null;
12
+ type: import("@evergonlabs/tmi-protocol-types/evm").TokenTypeEnum | null;
13
13
  }[];
14
14
  totalItems: number;
15
15
  totalPages: number;
16
16
  pageNumber: number;
17
- }, 200, "json">>>, import("hono/types").H<Env, string, {
17
+ }, import("hono/utils/http-status").ContentfulStatusCode, "json">>>, import("hono/types").H<Env, string, {
18
18
  in: {
19
19
  json: {
20
20
  address: `0x${string}`;
21
21
  chainId: import("@evergonlabs/tmi-protocol-fractions-sdk").TmiChainId;
22
- page?: number | undefined;
23
- perPage?: number | undefined;
24
22
  };
25
23
  };
26
24
  out: {
27
25
  json: {
28
26
  address: `0x${string}`;
29
27
  chainId: import("@evergonlabs/tmi-protocol-fractions-sdk").TmiChainId;
30
- page?: number | undefined;
31
- perPage?: number | undefined;
32
28
  };
33
29
  };
34
30
  }, Promise<Response & import("hono").TypedResponse<{
35
31
  balances: {
36
32
  tokenAddress: `0x${string}`;
37
- balance: never;
38
- decimals: number | undefined;
33
+ balance: string;
34
+ decimals: number;
39
35
  symbol: string;
40
36
  name: string;
41
- tokenId: undefined;
42
- type: "ERC-20" | "ERC-721" | "ERC-1155";
37
+ tokenId: string | null;
38
+ type: import("@evergonlabs/tmi-protocol-types/evm").TokenTypeEnum | null;
43
39
  }[];
44
40
  totalItems: number;
45
41
  totalPages: number;
46
42
  pageNumber: number;
47
- }, 200, "json">>>, import("hono/types").H<import("hono/utils/types").IfAnyThenEmptyObject<E extends Env ? Env extends E ? {} : E : E> & {}, string, {
43
+ }, import("hono/utils/http-status").ContentfulStatusCode, "json">>>, import("hono/types").H<import("hono/utils/types").IfAnyThenEmptyObject<E extends Env ? Env extends E ? {} : E : E> & {}, string, {
48
44
  in: {
49
45
  json: {
50
46
  address: `0x${string}`;
51
47
  chainId: import("@evergonlabs/tmi-protocol-fractions-sdk").TmiChainId;
52
- page?: number | undefined;
53
- perPage?: number | undefined;
54
48
  };
55
49
  };
56
50
  out: {
57
51
  json: {
58
52
  address: `0x${string}`;
59
53
  chainId: import("@evergonlabs/tmi-protocol-fractions-sdk").TmiChainId;
60
- page?: number | undefined;
61
- perPage?: number | undefined;
62
54
  };
63
55
  };
64
56
  }, Promise<Response & import("hono").TypedResponse<{
65
57
  balances: {
66
58
  tokenAddress: `0x${string}`;
67
- balance: never;
68
- decimals: number | undefined;
59
+ balance: string;
60
+ decimals: number;
69
61
  symbol: string;
70
62
  name: string;
71
- tokenId: undefined;
72
- type: "ERC-20" | "ERC-721" | "ERC-1155";
63
+ tokenId: string | null;
64
+ type: import("@evergonlabs/tmi-protocol-types/evm").TokenTypeEnum | null;
73
65
  }[];
74
66
  totalItems: number;
75
67
  totalPages: number;
76
68
  pageNumber: number;
77
- }, 200, "json">>>];
69
+ }, import("hono/utils/http-status").ContentfulStatusCode, "json">>>];
78
70
  //# sourceMappingURL=searchBalances.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"searchBalances.d.ts","sourceRoot":"","sources":["../../src/general/searchBalances.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIvC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAIxC,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,GAAG,EAAE,IAAI,SAAS,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAsDtG"}
1
+ {"version":3,"file":"searchBalances.d.ts","sourceRoot":"","sources":["../../src/general/searchBalances.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAIvC,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AAIxC,wBAAgB,sBAAsB,CAAC,CAAC,SAAS,GAAG,EAAE,IAAI,SAAS,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,IAAI;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qEA8CtG"}
@@ -3,7 +3,7 @@ import { describeRoute } from "hono-openapi";
3
3
  import { resolver, validator } from "hono-openapi/zod";
4
4
  import { AddressSchema, TmiChainIdSchema } from "../common/index.js";
5
5
  import { BalancesResponseSchema } from "./common.js";
6
- import { getTokenBalance } from "./balance-client.js";
6
+ import { getAccountBalances } from "./balanceClient.js";
7
7
  export function createSearchBalancesV0(factory, tag) {
8
8
  return factory.createHandlers(describeRoute({
9
9
  summary: "Search balances",
@@ -24,26 +24,22 @@ export function createSearchBalancesV0(factory, tag) {
24
24
  address: AddressSchema.openapi({
25
25
  description: "The address to get the balance for.",
26
26
  }),
27
- page: z.optional(z.number()),
28
- perPage: z.optional(z.number()),
29
27
  })), async (c) => {
30
28
  const { chainId, address } = c.req.valid("json");
31
- const result = await getTokenBalance(address, chainId);
29
+ const result = await getAccountBalances(address, chainId);
32
30
  return c.json({
33
- balances: result.map((it) => {
34
- return {
35
- tokenAddress: it.contractAddress,
36
- balance: it.balance,
37
- decimals: it.decimals,
38
- symbol: it.symbol,
39
- name: it.name,
40
- tokenId: it.id,
41
- type: it.type,
42
- };
43
- }),
31
+ balances: result.map((x) => ({
32
+ tokenAddress: x.tokenAddress,
33
+ balance: x.balance,
34
+ decimals: x.decimals,
35
+ symbol: x.symbol,
36
+ name: x.name,
37
+ tokenId: x.tokenId ?? null,
38
+ type: x.type,
39
+ })),
44
40
  totalItems: result.length,
45
41
  totalPages: 1,
46
42
  pageNumber: 1,
47
- }, 200);
43
+ });
48
44
  });
49
45
  }
@@ -0,0 +1,28 @@
1
+ import { TokenTypeEnum } from "@evergonlabs/tmi-protocol-types/evm";
2
+ import { z } from "../../../common/zod.js";
3
+ export declare const TokenBalance: z.ZodObject<{
4
+ balance: z.ZodPipeline<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBigInt]>, z.ZodString>;
5
+ tokenAddress: z.ZodType<`0x${string}`, z.ZodTypeDef, `0x${string}`>;
6
+ decimals: z.ZodEffects<z.ZodPipeline<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBigInt]>, z.ZodNumber>, number, string | number | bigint>;
7
+ tokenId: z.ZodOptional<z.ZodPipeline<z.ZodUnion<[z.ZodString, z.ZodNumber, z.ZodBigInt]>, z.ZodString>>;
8
+ name: z.ZodString;
9
+ symbol: z.ZodString;
10
+ type: z.ZodEffects<z.ZodString, TokenTypeEnum | null, string>;
11
+ }, "strip", z.ZodTypeAny, {
12
+ symbol: string;
13
+ type: TokenTypeEnum | null;
14
+ name: string;
15
+ decimals: number;
16
+ tokenAddress: `0x${string}`;
17
+ balance: string;
18
+ tokenId?: string | undefined;
19
+ }, {
20
+ symbol: string;
21
+ type: string;
22
+ name: string;
23
+ decimals: string | number | bigint;
24
+ tokenAddress: `0x${string}`;
25
+ balance: string | number | bigint;
26
+ tokenId?: string | number | bigint | undefined;
27
+ }>;
28
+ //# sourceMappingURL=tokenBalance.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tokenBalance.d.ts","sourceRoot":"","sources":["../../../../src/general/utils/tokenBalance/tokenBalance.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AAEpE,OAAO,EAAE,CAAC,EAAE,MAAM,wBAAwB,CAAC;AAW3C,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;EASvB,CAAC"}
@@ -0,0 +1,20 @@
1
+ import { TokenTypeEnum } from "@evergonlabs/tmi-protocol-types/evm";
2
+ import { AddressSchema } from "../../../common/index.js";
3
+ import { z } from "../../../common/zod.js";
4
+ import { NumberishSchema } from "@evergonlabs/tmi-protocol-types/common";
5
+ const tokenTypeDict = {
6
+ "ERC-721": TokenTypeEnum.ERC721,
7
+ "ERC-1155": TokenTypeEnum.ERC1155,
8
+ "ERC-20": TokenTypeEnum.ERC20,
9
+ };
10
+ // @see definitions here https://docs.blockscout.com/devs/apis/rpc/account#get-list-of-tokens-owned-by-address
11
+ export const TokenBalance = z.object({
12
+ balance: NumberishSchema.pipe(z.string()),
13
+ tokenAddress: AddressSchema,
14
+ // ERC-721 and ERC-1155 has no decimals but for interoperability we return 1
15
+ decimals: NumberishSchema.pipe(z.coerce.number()).transform((x) => x || 1),
16
+ tokenId: z.optional(NumberishSchema.pipe(z.string())),
17
+ name: z.string(),
18
+ symbol: z.string(),
19
+ type: z.string().transform((x) => (x in tokenTypeDict ? tokenTypeDict[x] : null)),
20
+ });
@@ -1 +1 @@
1
- {"version":3,"file":"renounceRole.d.ts","sourceRoot":"","sources":["../../src/issuance/renounceRole.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EAAqB,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAIzF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAO7B,CAAC;AAkBH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qEAepE"}
1
+ {"version":3,"file":"renounceRole.d.ts","sourceRoot":"","sources":["../../src/issuance/renounceRole.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAC3B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGvC,OAAO,EAAqB,cAAc,EAAE,MAAM,sCAAsC,CAAC;AAGzF,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAO7B,CAAC;AAkBH,wBAAgB,kBAAkB,CAAC,CAAC,SAAS,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qEAepE"}