@requestnetwork/payment-detection 0.56.0 → 0.57.0

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 (45) hide show
  1. package/README.md +93 -0
  2. package/dist/erc20/fee-proxy-contract.d.ts +2 -1
  3. package/dist/erc20/fee-proxy-contract.d.ts.map +1 -1
  4. package/dist/erc20/fee-proxy-contract.js +4 -1
  5. package/dist/erc20/fee-proxy-contract.js.map +1 -1
  6. package/dist/index.d.ts +4 -2
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +7 -1
  9. package/dist/index.js.map +1 -1
  10. package/dist/payment-network-factory.d.ts.map +1 -1
  11. package/dist/payment-network-factory.js +8 -0
  12. package/dist/payment-network-factory.js.map +1 -1
  13. package/dist/thegraph/client.d.ts +5 -3
  14. package/dist/thegraph/client.d.ts.map +1 -1
  15. package/dist/thegraph/client.js +19 -1
  16. package/dist/thegraph/client.js.map +1 -1
  17. package/dist/thegraph/generated/graphql-tron.d.ts +156 -0
  18. package/dist/thegraph/generated/graphql-tron.d.ts.map +1 -0
  19. package/dist/thegraph/generated/graphql-tron.js +101 -0
  20. package/dist/thegraph/generated/graphql-tron.js.map +1 -0
  21. package/dist/tron/index.d.ts +7 -0
  22. package/dist/tron/index.d.ts.map +1 -0
  23. package/dist/tron/index.js +13 -0
  24. package/dist/tron/index.js.map +1 -0
  25. package/dist/tron/retrievers/hasura-client.d.ts +62 -0
  26. package/dist/tron/retrievers/hasura-client.d.ts.map +1 -0
  27. package/dist/tron/retrievers/hasura-client.js +106 -0
  28. package/dist/tron/retrievers/hasura-client.js.map +1 -0
  29. package/dist/tron/retrievers/index.d.ts +3 -0
  30. package/dist/tron/retrievers/index.d.ts.map +1 -0
  31. package/dist/tron/retrievers/index.js +6 -0
  32. package/dist/tron/retrievers/index.js.map +1 -0
  33. package/dist/tron/retrievers/tron-info-retriever.d.ts +24 -0
  34. package/dist/tron/retrievers/tron-info-retriever.d.ts.map +1 -0
  35. package/dist/tron/retrievers/tron-info-retriever.js +71 -0
  36. package/dist/tron/retrievers/tron-info-retriever.js.map +1 -0
  37. package/dist/tron/retrievers/tron-thegraph-info-retriever.d.ts +20 -0
  38. package/dist/tron/retrievers/tron-thegraph-info-retriever.d.ts.map +1 -0
  39. package/dist/tron/retrievers/tron-thegraph-info-retriever.js +57 -0
  40. package/dist/tron/retrievers/tron-thegraph-info-retriever.js.map +1 -0
  41. package/dist/tron/tron-fee-proxy-detector.d.ts +29 -0
  42. package/dist/tron/tron-fee-proxy-detector.d.ts.map +1 -0
  43. package/dist/tron/tron-fee-proxy-detector.js +76 -0
  44. package/dist/tron/tron-fee-proxy-detector.js.map +1 -0
  45. package/package.json +8 -8
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GetTronPaymentsAnyToken = exports.GetTronPayments = exports.GetTronPaymentsAnyTokenDocument = exports.GetTronPaymentsDocument = exports.Payment_OrderBy = exports.OrderDirection = void 0;
4
+ exports.getSdk = getSdk;
5
+ const tslib_1 = require("tslib");
6
+ const graphql_tag_1 = tslib_1.__importDefault(require("graphql-tag"));
7
+ var OrderDirection;
8
+ (function (OrderDirection) {
9
+ OrderDirection["Asc"] = "asc";
10
+ OrderDirection["Desc"] = "desc";
11
+ })(OrderDirection || (exports.OrderDirection = OrderDirection = {}));
12
+ var Payment_OrderBy;
13
+ (function (Payment_OrderBy) {
14
+ Payment_OrderBy["Amount"] = "amount";
15
+ Payment_OrderBy["Block"] = "block";
16
+ Payment_OrderBy["Timestamp"] = "timestamp";
17
+ })(Payment_OrderBy || (exports.Payment_OrderBy = Payment_OrderBy = {}));
18
+ exports.GetTronPaymentsDocument = (0, graphql_tag_1.default) `
19
+ query GetTronPayments($reference: Bytes!, $to: String!, $tokenAddress: String!, $contractAddress: String!) {
20
+ payments(
21
+ where: {reference: $reference, to: $to, tokenAddress: $tokenAddress, contractAddress: $contractAddress}
22
+ orderBy: timestamp
23
+ orderDirection: asc
24
+ ) {
25
+ amount
26
+ block
27
+ txHash
28
+ feeAmount
29
+ feeAddress
30
+ from
31
+ timestamp
32
+ tokenAddress
33
+ }
34
+ }
35
+ `;
36
+ exports.GetTronPaymentsAnyTokenDocument = (0, graphql_tag_1.default) `
37
+ query GetTronPaymentsAnyToken($reference: Bytes!, $to: String!, $contractAddress: String!) {
38
+ payments(
39
+ where: {reference: $reference, to: $to, contractAddress: $contractAddress}
40
+ orderBy: timestamp
41
+ orderDirection: asc
42
+ ) {
43
+ amount
44
+ block
45
+ txHash
46
+ feeAmount
47
+ feeAddress
48
+ from
49
+ timestamp
50
+ tokenAddress
51
+ }
52
+ }
53
+ `;
54
+ const defaultWrapper = (action, _operationName, _operationType, _variables) => action();
55
+ function getSdk(client, withWrapper = defaultWrapper) {
56
+ return {
57
+ GetTronPayments(variables, requestHeaders) {
58
+ return withWrapper((wrappedRequestHeaders) => client.request(exports.GetTronPaymentsDocument, variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'GetTronPayments', 'query', variables);
59
+ },
60
+ GetTronPaymentsAnyToken(variables, requestHeaders) {
61
+ return withWrapper((wrappedRequestHeaders) => client.request(exports.GetTronPaymentsAnyTokenDocument, variables, Object.assign(Object.assign({}, requestHeaders), wrappedRequestHeaders)), 'GetTronPaymentsAnyToken', 'query', variables);
62
+ }
63
+ };
64
+ }
65
+ exports.GetTronPayments = (0, graphql_tag_1.default) `
66
+ query GetTronPayments($reference: Bytes!, $to: String!, $tokenAddress: String!, $contractAddress: String!) {
67
+ payments(
68
+ where: {reference: $reference, to: $to, tokenAddress: $tokenAddress, contractAddress: $contractAddress}
69
+ orderBy: timestamp
70
+ orderDirection: asc
71
+ ) {
72
+ amount
73
+ block
74
+ txHash
75
+ feeAmount
76
+ feeAddress
77
+ from
78
+ timestamp
79
+ tokenAddress
80
+ }
81
+ }
82
+ `;
83
+ exports.GetTronPaymentsAnyToken = (0, graphql_tag_1.default) `
84
+ query GetTronPaymentsAnyToken($reference: Bytes!, $to: String!, $contractAddress: String!) {
85
+ payments(
86
+ where: {reference: $reference, to: $to, contractAddress: $contractAddress}
87
+ orderBy: timestamp
88
+ orderDirection: asc
89
+ ) {
90
+ amount
91
+ block
92
+ txHash
93
+ feeAmount
94
+ feeAddress
95
+ from
96
+ timestamp
97
+ tokenAddress
98
+ }
99
+ }
100
+ `;
101
+ //# sourceMappingURL=graphql-tron.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"graphql-tron.js","sourceRoot":"","sources":["../../../src/thegraph/generated/graphql-tron.ts"],"names":[],"mappings":";;;AA6IA,wBASC;;AArJD,sEAA8B;AAoB9B,IAAY,cAGX;AAHD,WAAY,cAAc;IACxB,6BAAW,CAAA;IACX,+BAAa,CAAA;AACf,CAAC,EAHW,cAAc,8BAAd,cAAc,QAGzB;AAqCD,IAAY,eAIX;AAJD,WAAY,eAAe;IACzB,oCAAiB,CAAA;IACjB,kCAAe,CAAA;IACf,0CAAuB,CAAA;AACzB,CAAC,EAJW,eAAe,+BAAf,eAAe,QAI1B;AAkCY,QAAA,uBAAuB,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;;KAiBrC,CAAC;AACO,QAAA,+BAA+B,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;;KAiB7C,CAAC;AAKN,MAAM,cAAc,GAAuB,CAAC,MAAM,EAAE,cAAc,EAAE,cAAc,EAAE,UAAU,EAAE,EAAE,CAAC,MAAM,EAAE,CAAC;AAE5G,SAAgB,MAAM,CAAC,MAAqB,EAAE,cAAkC,cAAc;IAC5F,OAAO;QACL,eAAe,CAAC,SAAwC,EAAE,cAA4C;YACpG,OAAO,WAAW,CAAC,CAAC,qBAAqB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAAuB,+BAAuB,EAAE,SAAS,kCAAM,cAAc,GAAK,qBAAqB,EAAE,EAAE,iBAAiB,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QAChN,CAAC;QACD,uBAAuB,CAAC,SAAgD,EAAE,cAA4C;YACpH,OAAO,WAAW,CAAC,CAAC,qBAAqB,EAAE,EAAE,CAAC,MAAM,CAAC,OAAO,CAA+B,uCAA+B,EAAE,SAAS,kCAAM,cAAc,GAAK,qBAAqB,EAAE,EAAE,yBAAyB,EAAE,OAAO,EAAE,SAAS,CAAC,CAAC;QACxO,CAAC;KACF,CAAC;AACJ,CAAC;AAGY,QAAA,eAAe,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;;KAiB7B,CAAC;AACO,QAAA,uBAAuB,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;;KAiBrC,CAAC"}
@@ -0,0 +1,7 @@
1
+ export { TronERC20FeeProxyPaymentDetector as TronFeeProxyPaymentDetector } from './tron-fee-proxy-detector';
2
+ export { TronInfoRetriever } from './retrievers/tron-info-retriever';
3
+ export type { TronPaymentEvent } from './retrievers/tron-info-retriever';
4
+ export { TronTheGraphInfoRetriever } from './retrievers/tron-thegraph-info-retriever';
5
+ export type { TronTheGraphPaymentEvent } from './retrievers/tron-thegraph-info-retriever';
6
+ export { HasuraClient, getHasuraClient } from './retrievers/hasura-client';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tron/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,IAAI,2BAA2B,EAAE,MAAM,2BAA2B,CAAC;AAC5G,OAAO,EAAE,iBAAiB,EAAE,MAAM,kCAAkC,CAAC;AACrE,YAAY,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AACzE,OAAO,EAAE,yBAAyB,EAAE,MAAM,2CAA2C,CAAC;AACtF,YAAY,EAAE,wBAAwB,EAAE,MAAM,2CAA2C,CAAC;AAC1F,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC"}
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getHasuraClient = exports.HasuraClient = exports.TronTheGraphInfoRetriever = exports.TronInfoRetriever = exports.TronFeeProxyPaymentDetector = void 0;
4
+ var tron_fee_proxy_detector_1 = require("./tron-fee-proxy-detector");
5
+ Object.defineProperty(exports, "TronFeeProxyPaymentDetector", { enumerable: true, get: function () { return tron_fee_proxy_detector_1.TronERC20FeeProxyPaymentDetector; } });
6
+ var tron_info_retriever_1 = require("./retrievers/tron-info-retriever");
7
+ Object.defineProperty(exports, "TronInfoRetriever", { enumerable: true, get: function () { return tron_info_retriever_1.TronInfoRetriever; } });
8
+ var tron_thegraph_info_retriever_1 = require("./retrievers/tron-thegraph-info-retriever");
9
+ Object.defineProperty(exports, "TronTheGraphInfoRetriever", { enumerable: true, get: function () { return tron_thegraph_info_retriever_1.TronTheGraphInfoRetriever; } });
10
+ var hasura_client_1 = require("./retrievers/hasura-client");
11
+ Object.defineProperty(exports, "HasuraClient", { enumerable: true, get: function () { return hasura_client_1.HasuraClient; } });
12
+ Object.defineProperty(exports, "getHasuraClient", { enumerable: true, get: function () { return hasura_client_1.getHasuraClient; } });
13
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tron/index.ts"],"names":[],"mappings":";;;AAAA,qEAA4G;AAAnG,sIAAA,gCAAgC,OAA+B;AACxE,wEAAqE;AAA5D,wHAAA,iBAAiB,OAAA;AAE1B,0FAAsF;AAA7E,yIAAA,yBAAyB,OAAA;AAElC,4DAA2E;AAAlE,6GAAA,YAAY,OAAA;AAAE,gHAAA,eAAe,OAAA"}
@@ -0,0 +1,62 @@
1
+ import { CurrencyTypes } from '@requestnetwork/types';
2
+ /**
3
+ * Hasura payment response type matching the database schema.
4
+ * Note: amount and fee_amount use NUMERIC in PostgreSQL, which Hasura may
5
+ * return as JSON numbers (when they fit) or strings (for very large values).
6
+ */
7
+ export interface HasuraPayment {
8
+ id: string;
9
+ chain: string;
10
+ tx_hash: string;
11
+ block_number: number;
12
+ timestamp: number;
13
+ contract_address: string;
14
+ token_address: string;
15
+ from_address: string;
16
+ to_address: string;
17
+ amount: string | number;
18
+ fee_amount: string | number;
19
+ fee_address: string;
20
+ payment_reference: string;
21
+ energy_used?: string;
22
+ energy_fee?: string;
23
+ net_fee?: string;
24
+ }
25
+ export interface HasuraPaymentsResponse {
26
+ payments: HasuraPayment[];
27
+ }
28
+ export interface HasuraClientOptions {
29
+ /** Hasura GraphQL endpoint URL */
30
+ url: string;
31
+ /** Optional admin secret for authentication (x-hasura-admin-secret header) */
32
+ adminSecret?: string;
33
+ /** Optional JWT token for authentication (Authorization: Bearer header) */
34
+ jwtToken?: string;
35
+ /** Optional Hasura role to use with JWT auth (x-hasura-role header) */
36
+ hasuraRole?: string;
37
+ /** Optional custom headers */
38
+ headers?: Record<string, string>;
39
+ }
40
+ /**
41
+ * Client for querying payment data from Hasura GraphQL API
42
+ */
43
+ export declare class HasuraClient {
44
+ private readonly url;
45
+ private readonly headers;
46
+ constructor(options: HasuraClientOptions);
47
+ /**
48
+ * Query payments by payment reference
49
+ */
50
+ getPaymentsByReference(params: {
51
+ paymentReference: string;
52
+ toAddress: string;
53
+ chain?: string;
54
+ tokenAddress?: string;
55
+ contractAddress?: string;
56
+ }): Promise<HasuraPayment[]>;
57
+ }
58
+ /**
59
+ * Factory function to create a Hasura client
60
+ */
61
+ export declare function getHasuraClient(network: CurrencyTypes.ChainName, options?: Partial<HasuraClientOptions>): HasuraClient | undefined;
62
+ //# sourceMappingURL=hasura-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasura-client.d.ts","sourceRoot":"","sources":["../../../src/tron/retrievers/hasura-client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,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KAC1B,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;CAyE7B;AAKD;;GAEG;AACH,wBAAgB,eAAe,CAC7B,OAAO,EAAE,aAAa,CAAC,SAAS,EAChC,OAAO,CAAC,EAAE,OAAO,CAAC,mBAAmB,CAAC,GACrC,YAAY,GAAG,SAAS,CAiB1B"}
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.HasuraClient = void 0;
4
+ exports.getHasuraClient = getHasuraClient;
5
+ const tslib_1 = require("tslib");
6
+ /**
7
+ * Client for querying payment data from Hasura GraphQL API
8
+ */
9
+ class HasuraClient {
10
+ constructor(options) {
11
+ this.url = options.url;
12
+ this.headers = Object.assign(Object.assign(Object.assign(Object.assign({ 'Content-Type': 'application/json' }, (options.adminSecret && { 'x-hasura-admin-secret': options.adminSecret })), (options.jwtToken && { Authorization: `Bearer ${options.jwtToken}` })), (options.hasuraRole && { 'x-hasura-role': options.hasuraRole })), options.headers);
13
+ }
14
+ /**
15
+ * Query payments by payment reference
16
+ */
17
+ getPaymentsByReference(params) {
18
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
19
+ const variableDefinitions = ['$paymentReference: String!', '$toAddress: String!'];
20
+ const whereConditions = [
21
+ 'payment_reference: { _eq: $paymentReference }',
22
+ 'to_address: { _ilike: $toAddress }',
23
+ ];
24
+ const variables = {
25
+ paymentReference: params.paymentReference,
26
+ toAddress: params.toAddress,
27
+ };
28
+ if (params.chain) {
29
+ variableDefinitions.push('$chain: String!');
30
+ whereConditions.push('chain: { _eq: $chain }');
31
+ variables.chain = params.chain;
32
+ }
33
+ if (params.tokenAddress) {
34
+ variableDefinitions.push('$tokenAddress: String!');
35
+ whereConditions.push('token_address: { _ilike: $tokenAddress }');
36
+ variables.tokenAddress = params.tokenAddress;
37
+ }
38
+ if (params.contractAddress) {
39
+ variableDefinitions.push('$contractAddress: String!');
40
+ whereConditions.push('contract_address: { _ilike: $contractAddress }');
41
+ variables.contractAddress = params.contractAddress;
42
+ }
43
+ const query = `
44
+ query GetPayments(${variableDefinitions.join(', ')}) {
45
+ payments(
46
+ where: { ${whereConditions.join(', ')} }
47
+ order_by: { block_number: asc }
48
+ ) {
49
+ id
50
+ chain
51
+ tx_hash
52
+ block_number
53
+ timestamp
54
+ contract_address
55
+ token_address
56
+ from_address
57
+ to_address
58
+ amount
59
+ fee_amount
60
+ fee_address
61
+ payment_reference
62
+ energy_used
63
+ energy_fee
64
+ net_fee
65
+ }
66
+ }
67
+ `;
68
+ const response = yield fetch(this.url, {
69
+ method: 'POST',
70
+ headers: this.headers,
71
+ body: JSON.stringify({ query, variables }),
72
+ });
73
+ if (!response.ok) {
74
+ throw new Error(`Hasura request failed: ${response.statusText}`);
75
+ }
76
+ const result = yield response.json();
77
+ if (result.errors) {
78
+ throw new Error(`Hasura query error: ${JSON.stringify(result.errors)}`);
79
+ }
80
+ return result.data.payments;
81
+ });
82
+ }
83
+ }
84
+ exports.HasuraClient = HasuraClient;
85
+ /** TRON network identifiers supported by the Hasura client */
86
+ const SUPPORTED_TRON_NETWORKS = ['tron', 'nile'];
87
+ /**
88
+ * Factory function to create a Hasura client
89
+ */
90
+ function getHasuraClient(network, options) {
91
+ // Only return a client for TRON networks (mainnet and Nile testnet)
92
+ if (!SUPPORTED_TRON_NETWORKS.includes(network.toLowerCase())) {
93
+ return undefined;
94
+ }
95
+ const defaultUrl = process.env.HASURA_GRAPHQL_URL || 'https://graphql.request.network/v1/graphql';
96
+ const adminSecret = process.env.HASURA_ADMIN_SECRET;
97
+ const jwtToken = process.env.HASURA_GRAPHQL_JWT_TOKEN;
98
+ return new HasuraClient({
99
+ url: (options === null || options === void 0 ? void 0 : options.url) || defaultUrl,
100
+ adminSecret: (options === null || options === void 0 ? void 0 : options.adminSecret) || adminSecret,
101
+ jwtToken: (options === null || options === void 0 ? void 0 : options.jwtToken) || jwtToken,
102
+ hasuraRole: options === null || options === void 0 ? void 0 : options.hasuraRole,
103
+ headers: options === null || options === void 0 ? void 0 : options.headers,
104
+ });
105
+ }
106
+ //# sourceMappingURL=hasura-client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hasura-client.js","sourceRoot":"","sources":["../../../src/tron/retrievers/hasura-client.ts"],"names":[],"mappings":";;;AAwJA,0CAoBC;;AAhID;;GAEG;AACH,MAAa,YAAY;IAIvB,YAAY,OAA4B;QACtC,IAAI,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,CAAC;QACvB,IAAI,CAAC,OAAO,6DACV,cAAc,EAAE,kBAAkB,IAC/B,CAAC,OAAO,CAAC,WAAW,IAAI,EAAE,uBAAuB,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC,GACzE,CAAC,OAAO,CAAC,QAAQ,IAAI,EAAE,aAAa,EAAE,UAAU,OAAO,CAAC,QAAQ,EAAE,EAAE,CAAC,GACrE,CAAC,OAAO,CAAC,UAAU,IAAI,EAAE,eAAe,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,GAC/D,OAAO,CAAC,OAAO,CACnB,CAAC;IACJ,CAAC;IAED;;OAEG;IACG,sBAAsB,CAAC,MAM5B;;YACC,MAAM,mBAAmB,GAAa,CAAC,4BAA4B,EAAE,qBAAqB,CAAC,CAAC;YAC5F,MAAM,eAAe,GAAa;gBAChC,+CAA+C;gBAC/C,oCAAoC;aACrC,CAAC;YACF,MAAM,SAAS,GAA2B;gBACxC,gBAAgB,EAAE,MAAM,CAAC,gBAAgB;gBACzC,SAAS,EAAE,MAAM,CAAC,SAAS;aAC5B,CAAC;YAEF,IAAI,MAAM,CAAC,KAAK,EAAE,CAAC;gBACjB,mBAAmB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;gBAC5C,eAAe,CAAC,IAAI,CAAC,wBAAwB,CAAC,CAAC;gBAC/C,SAAS,CAAC,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC;YACjC,CAAC;YAED,IAAI,MAAM,CAAC,YAAY,EAAE,CAAC;gBACxB,mBAAm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BAAuB,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;AAEjD;;GAEG;AACH,SAAgB,eAAe,CAC7B,OAAgC,EAChC,OAAsC;IAEtC,oEAAoE;IACpE,IAAI,CAAC,uBAAuB,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,EAAE,CAAC;QAC7D,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,4CAA4C,CAAC;IAClG,MAAM,WAAW,GAAG,OAAO,CAAC,GAAG,CAAC,mBAAmB,CAAC;IACpD,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,wBAAwB,CAAC;IAEtD,OAAO,IAAI,YAAY,CAAC;QACtB,GAAG,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,GAAG,KAAI,UAAU;QAC/B,WAAW,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,WAAW,KAAI,WAAW;QAChD,QAAQ,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,QAAQ,KAAI,QAAQ;QACvC,UAAU,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,UAAU;QAC/B,OAAO,EAAE,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO;KAC1B,CAAC,CAAC;AACL,CAAC"}
@@ -0,0 +1,3 @@
1
+ export * from './tron-info-retriever';
2
+ export * from './hasura-client';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/tron/retrievers/index.ts"],"names":[],"mappings":"AAAA,cAAc,uBAAuB,CAAC;AACtC,cAAc,iBAAiB,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./tron-info-retriever"), exports);
5
+ tslib_1.__exportStar(require("./hasura-client"), exports);
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/tron/retrievers/index.ts"],"names":[],"mappings":";;;AAAA,gEAAsC;AACtC,0DAAgC"}
@@ -0,0 +1,24 @@
1
+ import { PaymentTypes } from '@requestnetwork/types';
2
+ import { ITheGraphBaseInfoRetriever, TransferEventsParams } from '../../types';
3
+ import { HasuraClient } from './hasura-client';
4
+ /**
5
+ * TRON-specific payment event parameters
6
+ */
7
+ export interface TronPaymentEvent extends PaymentTypes.IERC20FeePaymentEventParameters {
8
+ txHash: string;
9
+ energyUsed?: string;
10
+ energyFee?: string;
11
+ netFee?: string;
12
+ }
13
+ /**
14
+ * Gets a list of transfer events for TRON payments via Hasura
15
+ * Retriever for ERC20 Fee Proxy payments on TRON blockchain.
16
+ */
17
+ export declare class TronInfoRetriever implements ITheGraphBaseInfoRetriever<TronPaymentEvent> {
18
+ protected readonly client: HasuraClient;
19
+ constructor(client: HasuraClient);
20
+ getTransferEvents(params: TransferEventsParams): Promise<PaymentTypes.AllNetworkEvents<TronPaymentEvent>>;
21
+ private getChainIdentifier;
22
+ private mapPaymentEvent;
23
+ }
24
+ //# sourceMappingURL=tron-info-retriever.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tron-info-retriever.d.ts","sourceRoot":"","sources":["../../../src/tron/retrievers/tron-info-retriever.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAC/E,OAAO,EAAE,YAAY,EAAiB,MAAM,iBAAiB,CAAC;AAE9D;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,YAAY,CAAC,+BAA+B;IACpF,MAAM,EAAE,MAAM,CAAC;IAEf,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;;GAGG;AACH,qBAAa,iBAAkB,YAAW,0BAA0B,CAAC,gBAAgB,CAAC;IACxE,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,YAAY;gBAApB,MAAM,EAAE,YAAY;IAEtC,iBAAiB,CAC5B,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IA2B3D,OAAO,CAAC,kBAAkB;IAU1B,OAAO,CAAC,eAAe;CA2BxB"}
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TronInfoRetriever = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const ethers_1 = require("ethers");
6
+ /**
7
+ * Gets a list of transfer events for TRON payments via Hasura
8
+ * Retriever for ERC20 Fee Proxy payments on TRON blockchain.
9
+ */
10
+ class TronInfoRetriever {
11
+ constructor(client) {
12
+ this.client = client;
13
+ }
14
+ getTransferEvents(params) {
15
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
16
+ const { paymentReference, toAddress, contractAddress, acceptedTokens, paymentChain } = params;
17
+ if (acceptedTokens && acceptedTokens.length > 1) {
18
+ throw new Error(`TronInfoRetriever does not support multiple accepted tokens.`);
19
+ }
20
+ // Map chain name to the chain identifier used in the database
21
+ const chainIdentifier = this.getChainIdentifier(paymentChain);
22
+ // The substream stores the keccak256 hash of the payment reference (from the indexed event topic)
23
+ // so we must hash the raw reference before querying, matching the TheGraph-based retriever behavior
24
+ const hashedReference = ethers_1.utils.keccak256(`0x${paymentReference}`);
25
+ const payments = yield this.client.getPaymentsByReference({
26
+ paymentReference: hashedReference,
27
+ toAddress,
28
+ chain: chainIdentifier,
29
+ tokenAddress: acceptedTokens === null || acceptedTokens === void 0 ? void 0 : acceptedTokens[0],
30
+ contractAddress,
31
+ });
32
+ return {
33
+ paymentEvents: payments.map((p) => this.mapPaymentEvent(p, params)),
34
+ };
35
+ });
36
+ }
37
+ getChainIdentifier(paymentChain) {
38
+ // Map SDK chain names to the chain identifiers stored in Hasura
39
+ const chainMap = {
40
+ tron: 'tron',
41
+ nile: 'tron-nile',
42
+ };
43
+ return chainMap[paymentChain.toLowerCase()] || paymentChain.toLowerCase();
44
+ }
45
+ mapPaymentEvent(payment, params) {
46
+ // Note: TRON addresses use Base58 format, not Ethereum checksum format
47
+ // So we don't use formatAddress which expects EVM addresses
48
+ // Hasura returns NUMERIC fields as JSON numbers; we must coerce to strings
49
+ // since IPaymentNetworkEvent.amount and feeAmount expect string types
50
+ return {
51
+ amount: String(payment.amount),
52
+ name: params.eventName,
53
+ timestamp: payment.timestamp,
54
+ parameters: {
55
+ txHash: payment.tx_hash,
56
+ feeAmount: String(payment.fee_amount),
57
+ block: payment.block_number,
58
+ to: payment.to_address,
59
+ from: payment.from_address,
60
+ feeAddress: payment.fee_address || undefined,
61
+ tokenAddress: payment.token_address || undefined,
62
+ // TRON-specific resource fields
63
+ energyUsed: payment.energy_used || undefined,
64
+ energyFee: payment.energy_fee || undefined,
65
+ netFee: payment.net_fee || undefined,
66
+ },
67
+ };
68
+ }
69
+ }
70
+ exports.TronInfoRetriever = TronInfoRetriever;
71
+ //# sourceMappingURL=tron-info-retriever.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tron-info-retriever.js","sourceRoot":"","sources":["../../../src/tron/retrievers/tron-info-retriever.ts"],"names":[],"mappings":";;;;AACA,mCAA+B;AAe/B;;;GAGG;AACH,MAAa,iBAAiB;IAC5B,YAA+B,MAAoB;QAApB,WAAM,GAAN,MAAM,CAAc;IAAG,CAAC;IAE1C,iBAAiB,CAC5B,MAA4B;;YAE5B,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;YAE9F,IAAI,cAAc,IAAI,c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BACvB,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC;gBACrC,KAAK,EAAE,OAAO,CAAC,YAAY;gBAC3B,EAAE,EAAE,OAAO,CAAC,UAAU;gBACtB,IAAI,EAAE,OAAO,CAAC,YAAY;gBAC1B,UAAU,EAAE,OAAO,CAAC,WAAW,IAAI,SAAS;gBAC5C,YAAY,EAAE,OAAO,CAAC,aAAa,IAAI,SAAS;gBAChD,gCAAgC;gBAChC,UAAU,EAAE,OAAO,CAAC,WAAW,IAAI,SAAS;gBAC5C,SAAS,EAAE,OAAO,CAAC,UAAU,IAAI,SAAS;gBAC1C,MAAM,EAAE,OAAO,CAAC,OAAO,IAAI,SAAS;aACrC;SACF,CAAC;IACJ,CAAC;CACF;AArED,8CAqEC"}
@@ -0,0 +1,20 @@
1
+ import { CurrencyTypes, PaymentTypes } from '@requestnetwork/types';
2
+ import { TheGraphClient } from '../../thegraph';
3
+ import { ITheGraphBaseInfoRetriever, TransferEventsParams } from '../../types';
4
+ /**
5
+ * TRON-specific payment event parameters (TheGraph-based)
6
+ */
7
+ export interface TronTheGraphPaymentEvent extends PaymentTypes.IERC20FeePaymentEventParameters {
8
+ txHash: string;
9
+ }
10
+ /**
11
+ * TheGraph-based info retriever for ERC20 Fee Proxy payments on TRON.
12
+ * Uses the TRON subgraph (Substreams-powered) via TheGraphClient.
13
+ */
14
+ export declare class TronTheGraphInfoRetriever implements ITheGraphBaseInfoRetriever<TronTheGraphPaymentEvent> {
15
+ protected readonly client: TheGraphClient<CurrencyTypes.TronChainName>;
16
+ constructor(client: TheGraphClient<CurrencyTypes.TronChainName>);
17
+ getTransferEvents(params: TransferEventsParams): Promise<PaymentTypes.AllNetworkEvents<TronTheGraphPaymentEvent>>;
18
+ private mapPaymentEvent;
19
+ }
20
+ //# sourceMappingURL=tron-thegraph-info-retriever.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tron-thegraph-info-retriever.d.ts","sourceRoot":"","sources":["../../../src/tron/retrievers/tron-thegraph-info-retriever.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAEpE,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD,OAAO,EAAE,0BAA0B,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAE/E;;GAEG;AACH,MAAM,WAAW,wBAAyB,SAAQ,YAAY,CAAC,+BAA+B;IAC5F,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;GAGG;AACH,qBAAa,yBACX,YAAW,0BAA0B,CAAC,wBAAwB,CAAC;IAEnD,SAAS,CAAC,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,aAAa,CAAC,aAAa,CAAC;gBAAnD,MAAM,EAAE,cAAc,CAAC,aAAa,CAAC,aAAa,CAAC;IAErE,iBAAiB,CAC5B,MAAM,EAAE,oBAAoB,GAC3B,OAAO,CAAC,YAAY,CAAC,gBAAgB,CAAC,wBAAwB,CAAC,CAAC;IA4BnE,OAAO,CAAC,eAAe;CAmBxB"}
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TronTheGraphInfoRetriever = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const ethers_1 = require("ethers");
6
+ /**
7
+ * TheGraph-based info retriever for ERC20 Fee Proxy payments on TRON.
8
+ * Uses the TRON subgraph (Substreams-powered) via TheGraphClient.
9
+ */
10
+ class TronTheGraphInfoRetriever {
11
+ constructor(client) {
12
+ this.client = client;
13
+ }
14
+ getTransferEvents(params) {
15
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
16
+ const { paymentReference, toAddress, contractAddress, acceptedTokens } = params;
17
+ if (acceptedTokens && acceptedTokens.length > 1) {
18
+ throw new Error('TronTheGraphInfoRetriever does not support multiple accepted tokens.');
19
+ }
20
+ const reference = ethers_1.utils.keccak256(`0x${paymentReference}`);
21
+ const payments = (acceptedTokens === null || acceptedTokens === void 0 ? void 0 : acceptedTokens.length) === 1
22
+ ? yield this.client.GetTronPayments({
23
+ reference,
24
+ to: toAddress,
25
+ tokenAddress: acceptedTokens[0],
26
+ contractAddress,
27
+ })
28
+ : yield this.client.GetTronPaymentsAnyToken({
29
+ reference,
30
+ to: toAddress,
31
+ contractAddress,
32
+ });
33
+ return {
34
+ paymentEvents: payments.payments.map((p) => this.mapPaymentEvent(p, params)),
35
+ };
36
+ });
37
+ }
38
+ mapPaymentEvent(payment, params) {
39
+ var _a, _b;
40
+ return {
41
+ amount: payment.amount,
42
+ name: params.eventName,
43
+ timestamp: payment.timestamp,
44
+ parameters: {
45
+ txHash: payment.txHash,
46
+ feeAmount: payment.feeAmount,
47
+ block: payment.block,
48
+ to: params.toAddress,
49
+ from: payment.from,
50
+ feeAddress: (_a = payment.feeAddress) !== null && _a !== void 0 ? _a : undefined,
51
+ tokenAddress: (_b = payment.tokenAddress) !== null && _b !== void 0 ? _b : undefined,
52
+ },
53
+ };
54
+ }
55
+ }
56
+ exports.TronTheGraphInfoRetriever = TronTheGraphInfoRetriever;
57
+ //# sourceMappingURL=tron-thegraph-info-retriever.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tron-thegraph-info-retriever.js","sourceRoot":"","sources":["../../../src/tron/retrievers/tron-thegraph-info-retriever.ts"],"names":[],"mappings":";;;;AACA,mCAA+B;AAY/B;;;GAGG;AACH,MAAa,yBAAyB;IAGpC,YAA+B,MAAmD;QAAnD,WAAM,GAAN,MAAM,CAA6C;IAAG,CAAC;IAEzE,iBAAiB,CAC5B,MAA4B;;YAE5B,MAAM,EAAE,gBAAgB,EAAE,SAAS,EAAE,eAAe,EAAE,cAAc,EAAE,GAAG,MAAM,CAAC;YAEhF,IAAI,cAAc,IAAI,cAAc,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAChD,MAAM,IAAI,KAAK,CAAC,sEAAsE,CAAC,CAAC;YAC1F,CAAC;YAED,MAAM,SAAS,GAA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es } from '@requestnetwork/types';
2
+ import { ERC20FeeProxyPaymentDetectorBase } from '../erc20/fee-proxy-contract';
3
+ import { ReferenceBasedDetectorOptions } from '../types';
4
+ import { TronPaymentEvent } from './retrievers/tron-info-retriever';
5
+ import { HasuraClientOptions } from './retrievers/hasura-client';
6
+ /**
7
+ * Handle payment networks with ERC20 fee proxy contract extension on TRON chains
8
+ */
9
+ export declare class TronERC20FeeProxyPaymentDetector extends ERC20FeeProxyPaymentDetectorBase<ExtensionTypes.PnFeeReferenceBased.IFeeReferenceBased, TronPaymentEvent> {
10
+ private readonly hasuraClientOptions?;
11
+ protected readonly network: CurrencyTypes.TronChainName | undefined;
12
+ constructor({ advancedLogic, currencyManager, network, hasuraClientOptions, }: ReferenceBasedDetectorOptions & {
13
+ network?: CurrencyTypes.TronChainName;
14
+ hasuraClientOptions?: Partial<HasuraClientOptions>;
15
+ });
16
+ /**
17
+ * Gets the deployment information for the ERC20FeeProxy contract on TRON
18
+ */
19
+ static getDeploymentInformation(network: CurrencyTypes.VMChainName, _paymentNetworkVersion?: string): {
20
+ address: string;
21
+ creationBlockNumber: number;
22
+ contractVersion: string;
23
+ };
24
+ /**
25
+ * Extracts the payment events of a request on TRON
26
+ */
27
+ protected extractEvents(eventName: PaymentTypes.EVENTS_NAMES, toAddress: string | undefined, paymentReference: string, requestCurrency: RequestLogicTypes.ICurrency, paymentChain: CurrencyTypes.TronChainName, _paymentNetwork: ExtensionTypes.IState): Promise<PaymentTypes.AllNetworkEvents<TronPaymentEvent>>;
28
+ }
29
+ //# sourceMappingURL=tron-fee-proxy-detector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tron-fee-proxy-detector.d.ts","sourceRoot":"","sources":["../../src/tron/tron-fee-proxy-detector.ts"],"names":[],"mappings":"AACA,OAAO,EACL,aAAa,EACb,cAAc,EACd,YAAY,EACZ,iBAAiB,EAClB,MAAM,uBAAuB,CAAC;AAG/B,OAAO,EAAE,gCAAgC,EAAE,MAAM,6BAA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_1 = require("tslib");
5
+ const smart_contracts_1 = require("@requestnetwork/smart-contracts");
6
+ const types_1 = require("@requestnetwork/types");
7
+ const currency_1 = require("@requestnetwork/currency");
8
+ const fee_proxy_contract_1 = require("../erc20/fee-proxy-contract");
9
+ const balance_error_1 = require("../balance-error");
10
+ const tron_info_retriever_1 = require("./retrievers/tron-info-retriever");
11
+ const hasura_client_1 = require("./retrievers/hasura-client");
12
+ /**
13
+ * Handle payment networks with ERC20 fee proxy contract extension on TRON chains
14
+ */
15
+ class TronERC20FeeProxyPaymentDetector extends fee_proxy_contract_1.ERC20FeeProxyPaymentDetectorBase {
16
+ constructor({ advancedLogic, currencyManager, network, hasuraClientOptions, }) {
17
+ var _a;
18
+ super(types_1.ExtensionTypes.PAYMENT_NETWORK_ID.ERC20_FEE_PROXY_CONTRACT, (_a = advancedLogic.getFeeProxyContractErc20ForNetwork(network)) !== null && _a !== void 0 ? _a : advancedLogic.extensions.feeProxyContractErc20, currencyManager);
19
+ this.hasuraClientOptions = hasuraClientOptions;
20
+ this.network = network;
21
+ }
22
+ /**
23
+ * Gets the deployment information for the ERC20FeeProxy contract on TRON
24
+ */
25
+ static getDeploymentInformation(network, _paymentNetworkVersion) {
26
+ void _paymentNetworkVersion; // Parameter kept for API compatibility
27
+ // Validate that the network is a TRON chain
28
+ if (network !== 'tron' && network !== 'nile') {
29
+ throw new Error(`TronERC20FeeProxyPaymentDetector only supports TRON networks, got: ${network}`);
30
+ }
31
+ // For TRON, we use the 'tron' version of the artifact
32
+ const tronNetwork = network;
33
+ const address = smart_contracts_1.erc20FeeProxyArtifact.getAddress(tronNetwork, 'tron');
34
+ const creationBlockNumber = tronNetwork === 'tron'
35
+ ? 79216121 // TRON mainnet
36
+ : 63208782; // Nile testnet
37
+ return { address, creationBlockNumber, contractVersion: 'tron' };
38
+ }
39
+ /**
40
+ * Extracts the payment events of a request on TRON
41
+ */
42
+ extractEvents(eventName, toAddress, paymentReference, requestCurrency, paymentChain, _paymentNetwork) {
43
+ return tslib_1.__awaiter(this, void 0, void 0, function* () {
44
+ void _paymentNetwork; // Parameter required by parent class signature
45
+ // Validate that the payment chain is a supported TRON chain
46
+ if (!currency_1.TronChains.isChainSupported(paymentChain)) {
47
+ throw new balance_error_1.NetworkNotSupported(`Unsupported TRON network '${paymentChain}' for TRON payment detector`);
48
+ }
49
+ if (this.network && !(0, currency_1.isSameChain)(paymentChain, this.network)) {
50
+ throw new balance_error_1.NetworkNotSupported(`Unsupported network '${paymentChain}' for payment detector instantiated with '${this.network}'`);
51
+ }
52
+ if (!toAddress) {
53
+ return {
54
+ paymentEvents: [],
55
+ };
56
+ }
57
+ const { address: proxyContractAddress } = TronERC20FeeProxyPaymentDetector.getDeploymentInformation(paymentChain);
58
+ const hasuraClient = (0, hasura_client_1.getHasuraClient)(paymentChain, this.hasuraClientOptions);
59
+ if (!hasuraClient) {
60
+ throw new Error(`Could not get a Hasura client for TRON chain ${paymentChain}. ` +
61
+ `Ensure HASURA_GRAPHQL_URL is configured or the network is supported.`);
62
+ }
63
+ const infoRetriever = new tron_info_retriever_1.TronInfoRetriever(hasuraClient);
64
+ return infoRetriever.getTransferEvents({
65
+ eventName,
66
+ paymentReference,
67
+ toAddress,
68
+ contractAddress: proxyContractAddress,
69
+ paymentChain,
70
+ acceptedTokens: [requestCurrency.value],
71
+ });
72
+ });
73
+ }
74
+ }
75
+ exports.TronERC20FeeProxyPaymentDetector = TronERC20FeeProxyPaymentDetector;
76
+ //# sourceMappingURL=tron-fee-proxy-detector.js.map