@huma-finance/sdk 0.0.21 → 0.0.24

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 (131) hide show
  1. package/API.md +482 -482
  2. package/LICENSE +660 -660
  3. package/README.md +34 -34
  4. package/dist/cjs/graphql/generatedTypes.d.ts +40 -40
  5. package/dist/cjs/graphql/generatedTypes.js +8 -8
  6. package/dist/cjs/graphql/index.d.ts +1 -1
  7. package/dist/cjs/graphql/index.js +4 -4
  8. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -10
  9. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js +21 -21
  10. package/dist/cjs/helpers/PoolContractHelper.d.ts +104 -104
  11. package/dist/cjs/helpers/PoolContractHelper.js +102 -104
  12. package/dist/cjs/helpers/PoolContractHelper.js.map +1 -1
  13. package/dist/cjs/helpers/RealWorldReceivableContractHelper.d.ts +10 -10
  14. package/dist/cjs/helpers/RealWorldReceivableContractHelper.js +21 -21
  15. package/dist/cjs/helpers/index.d.ts +3 -3
  16. package/dist/cjs/helpers/index.js +6 -6
  17. package/dist/cjs/hooks/index.d.ts +4 -4
  18. package/dist/cjs/hooks/index.js +7 -7
  19. package/dist/cjs/hooks/useContract.d.ts +13 -13
  20. package/dist/cjs/hooks/useContract.js +30 -30
  21. package/dist/cjs/hooks/useERC20TransferableReceivableContract.d.ts +12 -12
  22. package/dist/cjs/hooks/useERC20TransferableReceivableContract.js +20 -20
  23. package/dist/cjs/hooks/usePoolContract.d.ts +60 -60
  24. package/dist/cjs/hooks/usePoolContract.js +53 -53
  25. package/dist/cjs/hooks/useRealWorldReceivableContract.d.ts +10 -10
  26. package/dist/cjs/hooks/useRealWorldReceivableContract.js +19 -19
  27. package/dist/cjs/index.d.ts +4 -4
  28. package/dist/cjs/index.js +7 -7
  29. package/dist/cjs/services/ARWeaveService.d.ts +81 -81
  30. package/dist/cjs/services/ARWeaveService.js +140 -145
  31. package/dist/cjs/services/ARWeaveService.js.map +1 -1
  32. package/dist/cjs/services/EAService.d.ts +18 -20
  33. package/dist/cjs/services/EAService.js +12 -33
  34. package/dist/cjs/services/EAService.js.map +1 -1
  35. package/dist/cjs/services/ReceivableService.d.ts +87 -89
  36. package/dist/cjs/services/ReceivableService.js +188 -193
  37. package/dist/cjs/services/ReceivableService.js.map +1 -1
  38. package/dist/cjs/services/SubgraphService.d.ts +53 -53
  39. package/dist/cjs/services/SubgraphService.js +100 -93
  40. package/dist/cjs/services/SubgraphService.js.map +1 -1
  41. package/dist/cjs/services/index.d.ts +4 -4
  42. package/dist/cjs/services/index.js +7 -7
  43. package/dist/cjs/utils/chain.d.ts +14 -15
  44. package/dist/cjs/utils/chain.js +33 -37
  45. package/dist/cjs/utils/chain.js.map +1 -1
  46. package/dist/cjs/utils/index.d.ts +3 -4
  47. package/dist/cjs/utils/index.js +6 -7
  48. package/dist/cjs/utils/index.js.map +1 -1
  49. package/dist/cjs/utils/poolInfo.d.ts +8 -8
  50. package/dist/cjs/utils/poolInfo.js +12 -12
  51. package/dist/cjs/utils/web3.d.ts +4 -4
  52. package/dist/cjs/utils/web3.js +28 -28
  53. package/dist/graphql/generatedTypes.d.ts +40 -40
  54. package/dist/graphql/generatedTypes.js +4 -4
  55. package/dist/graphql/index.d.ts +1 -1
  56. package/dist/graphql/index.js +1 -1
  57. package/dist/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -10
  58. package/dist/helpers/ERC20TransferableReceivableContractHelper.js +17 -17
  59. package/dist/helpers/PoolContractHelper.d.ts +104 -104
  60. package/dist/helpers/PoolContractHelper.js +94 -96
  61. package/dist/helpers/PoolContractHelper.js.map +1 -1
  62. package/dist/helpers/RealWorldReceivableContractHelper.d.ts +10 -10
  63. package/dist/helpers/RealWorldReceivableContractHelper.js +17 -17
  64. package/dist/helpers/index.d.ts +3 -3
  65. package/dist/helpers/index.js +3 -3
  66. package/dist/hooks/index.d.ts +4 -4
  67. package/dist/hooks/index.js +4 -4
  68. package/dist/hooks/useContract.d.ts +13 -13
  69. package/dist/hooks/useContract.js +26 -26
  70. package/dist/hooks/useERC20TransferableReceivableContract.d.ts +12 -12
  71. package/dist/hooks/useERC20TransferableReceivableContract.js +16 -16
  72. package/dist/hooks/usePoolContract.d.ts +60 -60
  73. package/dist/hooks/usePoolContract.js +48 -48
  74. package/dist/hooks/useRealWorldReceivableContract.d.ts +10 -10
  75. package/dist/hooks/useRealWorldReceivableContract.js +15 -15
  76. package/dist/index.d.ts +4 -4
  77. package/dist/index.js +4 -4
  78. package/dist/services/ARWeaveService.d.ts +81 -81
  79. package/dist/services/ARWeaveService.js +135 -140
  80. package/dist/services/ARWeaveService.js.map +1 -1
  81. package/dist/services/EAService.d.ts +18 -20
  82. package/dist/services/EAService.js +9 -30
  83. package/dist/services/EAService.js.map +1 -1
  84. package/dist/services/ReceivableService.d.ts +87 -89
  85. package/dist/services/ReceivableService.js +184 -189
  86. package/dist/services/ReceivableService.js.map +1 -1
  87. package/dist/services/SubgraphService.d.ts +53 -53
  88. package/dist/services/SubgraphService.js +97 -90
  89. package/dist/services/SubgraphService.js.map +1 -1
  90. package/dist/services/index.d.ts +4 -4
  91. package/dist/services/index.js +4 -4
  92. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  93. package/dist/utils/chain.d.ts +14 -15
  94. package/dist/utils/chain.js +28 -31
  95. package/dist/utils/chain.js.map +1 -1
  96. package/dist/utils/index.d.ts +3 -4
  97. package/dist/utils/index.js +3 -4
  98. package/dist/utils/index.js.map +1 -1
  99. package/dist/utils/poolInfo.d.ts +8 -8
  100. package/dist/utils/poolInfo.js +8 -8
  101. package/dist/utils/web3.d.ts +4 -4
  102. package/dist/utils/web3.js +23 -23
  103. package/getting-started.md +190 -190
  104. package/package.json +3 -3
  105. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.d.ts +0 -10
  106. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js +0 -22
  107. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js.map +0 -1
  108. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.d.ts +0 -10
  109. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js +0 -20
  110. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js.map +0 -1
  111. package/dist/cjs/hooks/useReceivableFactoringPoolContract.d.ts +0 -10
  112. package/dist/cjs/hooks/useReceivableFactoringPoolContract.js +0 -17
  113. package/dist/cjs/hooks/useReceivableFactoringPoolContract.js.map +0 -1
  114. package/dist/cjs/utils/maticGasStation.d.ts +0 -3
  115. package/dist/cjs/utils/maticGasStation.js +0 -39
  116. package/dist/cjs/utils/maticGasStation.js.map +0 -1
  117. package/dist/helpers/BaseCreditPoolReceivableContractHelper.d.ts +0 -10
  118. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js +0 -18
  119. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js.map +0 -1
  120. package/dist/hooks/useBaseCreditPoolReceivableContract.d.ts +0 -10
  121. package/dist/hooks/useBaseCreditPoolReceivableContract.js +0 -16
  122. package/dist/hooks/useBaseCreditPoolReceivableContract.js.map +0 -1
  123. package/dist/hooks/usePool.d.ts +0 -0
  124. package/dist/hooks/usePool.js +0 -2
  125. package/dist/hooks/usePool.js.map +0 -1
  126. package/dist/hooks/useReceivableFactoringPoolContract.d.ts +0 -10
  127. package/dist/hooks/useReceivableFactoringPoolContract.js +0 -13
  128. package/dist/hooks/useReceivableFactoringPoolContract.js.map +0 -1
  129. package/dist/utils/maticGasStation.d.ts +0 -3
  130. package/dist/utils/maticGasStation.js +0 -33
  131. package/dist/utils/maticGasStation.js.map +0 -1
@@ -1,94 +1,101 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SubgraphService = void 0;
4
- const shared_1 = require("@huma-finance/shared");
5
- /**
6
- * Returns the subgraph URL for a given chain ID.
7
- *
8
- * @memberof SubgraphService
9
- * @param {number} chainId - The ID of the chain.
10
- * @returns {string} The subgraph URL for the given chain ID.
11
- */
12
- function getSubgraphUrlForChainId(chainId) {
13
- switch (chainId) {
14
- case 5:
15
- return 'https://api.thegraph.com/subgraphs/name/00labs/huma-goerli';
16
- case 137:
17
- return 'https://api.thegraph.com/subgraphs/name/00labs/huma-polygon';
18
- case 80001:
19
- return 'https://api.thegraph.com/subgraphs/name/00labs/huma-mumbai';
20
- default:
21
- return '';
22
- }
23
- }
24
- /**
25
- * Returns the credit events for a given user.
26
- *
27
- * @memberof SubgraphService
28
- * @param {string} userAddress - The address of the user.
29
- * @param {number} chainId - The ID of the chain.
30
- * @param {POOL_NAME} poolName - The name of the pool.
31
- * @param {POOL_TYPE} poolType - The type of the pool.
32
- * @param {number[]} event - The event types to filter by.
33
- * @returns {Promise<CreditEventPayload[]>} The credit events for the given user.
34
- */
35
- function getCreditEventsForUser(userAddress, chainId, poolName, poolType, event) {
36
- var _a, _b, _c;
37
- const url = getSubgraphUrlForChainId(chainId);
38
- if (!url) {
39
- return Promise.resolve([]);
40
- }
41
- const poolAddress = (_c = (_b = (_a = shared_1.PoolContractMap[chainId]) === null || _a === void 0 ? void 0 : _a[poolType]) === null || _b === void 0 ? void 0 : _b[poolName]) === null || _c === void 0 ? void 0 : _c.pool;
42
- const query = `
43
- query {
44
- creditEvents(
45
- where: {
46
- owner: "${userAddress}",
47
- pool: "${poolAddress}",
48
- event_in: [${event.join(',')}]
49
- }
50
- orderBy: timestamp
51
- orderDirection: desc
52
- ) {
53
- amount
54
- timestamp
55
- owner
56
- pool
57
- event
58
- }
59
- }
60
- `;
61
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
62
- return (0, shared_1.requestPost)(url, JSON.stringify({ query })).then((res) => {
63
- if (res.errors) {
64
- console.error(res.errors);
65
- return [];
66
- }
67
- return res.data.creditEvents;
68
- });
69
- }
70
- /**
71
- * Returns the last factorized amount for a given user and pool.
72
- *
73
- * @memberof SubgraphService
74
- * @param {string} userAddress - The address of the user.
75
- * @param {number} chainId - The ID of the chain.
76
- * @param {POOL_NAME} poolName - The name of the pool.
77
- * @param {POOL_TYPE} poolType - The type of the pool.
78
- * @returns {Promise<number>} The last factorized amount for the given user and pool.
79
- */
80
- function getLastFactorizedAmountFromPool(userAddress, chainId, poolName, poolType) {
81
- return getCreditEventsForUser(userAddress, chainId, poolName, poolType, [
82
- shared_1.CreditEvent.DrawdownMadeWithReceivable,
83
- ]).then((events) => Number(events[0].amount));
84
- }
85
- /**
86
- * An object that contains functions to interact with Huma's Subgraph storage.
87
- * @namespace SubgraphService
88
- */
89
- exports.SubgraphService = {
90
- getSubgraphUrlForChainId,
91
- getCreditEventsForUser,
92
- getLastFactorizedAmountFromPool,
93
- };
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.SubgraphService = void 0;
4
+ const shared_1 = require("@huma-finance/shared");
5
+ /**
6
+ * Returns the subgraph URL for a given chain ID.
7
+ *
8
+ * @memberof SubgraphService
9
+ * @param {number} chainId - The ID of the chain.
10
+ * @returns {string} The subgraph URL for the given chain ID.
11
+ */
12
+ function getSubgraphUrlForChainId(chainId) {
13
+ switch (chainId) {
14
+ case 5:
15
+ return 'https://api.thegraph.com/subgraphs/name/00labs/huma-goerli';
16
+ case 137:
17
+ return 'https://api.thegraph.com/subgraphs/name/00labs/huma-polygon';
18
+ case 80001:
19
+ return 'https://api.thegraph.com/subgraphs/name/00labs/huma-mumbai';
20
+ default:
21
+ return '';
22
+ }
23
+ }
24
+ /**
25
+ * Returns the credit events for a given user.
26
+ *
27
+ * @memberof SubgraphService
28
+ * @param {string} userAddress - The address of the user.
29
+ * @param {number} chainId - The ID of the chain.
30
+ * @param {POOL_NAME} poolName - The name of the pool.
31
+ * @param {POOL_TYPE} poolType - The type of the pool.
32
+ * @param {string[]} event - The event types to filter by.
33
+ * @returns {Promise<CreditEventPayload[]>} The credit events for the given user.
34
+ */
35
+ function getCreditEventsForUser(userAddress, chainId, poolName, poolType, event) {
36
+ var _a, _b, _c;
37
+ const url = getSubgraphUrlForChainId(chainId);
38
+ if (!url) {
39
+ return Promise.resolve([]);
40
+ }
41
+ const poolAddress = (_c = (_b = (_a = shared_1.PoolContractMap[chainId]) === null || _a === void 0 ? void 0 : _a[poolType]) === null || _b === void 0 ? void 0 : _b[poolName]) === null || _c === void 0 ? void 0 : _c.pool;
42
+ const query = `
43
+ query {
44
+ creditEvents(
45
+ where: {
46
+ owner: "${userAddress}",
47
+ pool: "${poolAddress}",
48
+ event_in: "[${event.join('", "')}]"
49
+ }
50
+ orderBy: timestamp
51
+ orderDirection: desc
52
+ ) {
53
+ amount
54
+ timestamp
55
+ owner
56
+ pool
57
+ event
58
+ }
59
+ }
60
+ `;
61
+ return fetch(url, {
62
+ method: 'POST',
63
+ headers: {
64
+ 'Content-Type': 'application/json',
65
+ },
66
+ body: JSON.stringify({ query }),
67
+ })
68
+ .then((res) => res.json())
69
+ .then((res) => {
70
+ if (res.errors) {
71
+ console.error(res.errors);
72
+ return [];
73
+ }
74
+ return res.data.creditEvents;
75
+ });
76
+ }
77
+ /**
78
+ * Returns the last factorized amount for a given user and pool.
79
+ *
80
+ * @memberof SubgraphService
81
+ * @param {string} userAddress - The address of the user.
82
+ * @param {number} chainId - The ID of the chain.
83
+ * @param {POOL_NAME} poolName - The name of the pool.
84
+ * @param {POOL_TYPE} poolType - The type of the pool.
85
+ * @returns {Promise<number>} The last factorized amount for the given user and pool.
86
+ */
87
+ function getLastFactorizedAmountFromPool(userAddress, chainId, poolName, poolType) {
88
+ return getCreditEventsForUser(userAddress, chainId, poolName, poolType, [
89
+ shared_1.CreditEvent.DrawdownMadeWithReceivable.toString(),
90
+ ]).then((events) => Number(events[0].amount));
91
+ }
92
+ /**
93
+ * An object that contains functions to interact with Huma's Subgraph storage.
94
+ * @namespace SubgraphService
95
+ */
96
+ exports.SubgraphService = {
97
+ getSubgraphUrlForChainId,
98
+ getCreditEventsForUser,
99
+ getLastFactorizedAmountFromPool,
100
+ };
94
101
  //# sourceMappingURL=SubgraphService.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IAAI,CAAC,MAAM,CAAC;;;;;;;;;;;;GAYvC,CAAA;IAED,OAAO,KAAK,CAAC,GAAG,EAAE;QAChB,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC;KAChC,CAAC;SACC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;SACzB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;QACZ,IAAI,GAAG,CAAC,MAAM,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YACzB,OAAO,EAAE,CAAA;SACV;QACD,OAAO,GAAG,CAAC,IAAI,CAAC,YAAY,CAAA;IAC9B,CAAC,CAAC,CAAA;AACN,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,+BAA+B,CACtC,WAAmB,EACnB,OAAe,EACf,QAAmB,EACnB,QAAmB;IAEnB,OAAO,sBAAsB,CAAC,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE;QACtE,oBAAW,CAAC,0BAA0B,CAAC,QAAQ,EAAE;KAClD,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;AAC/C,CAAC;AAED;;;GAGG;AACU,QAAA,eAAe,GAAG;IAC7B,wBAAwB;IACxB,sBAAsB;IACtB,+BAA+B;CAChC,CAAA"}
@@ -1,4 +1,4 @@
1
- export * from './ARWeaveService';
2
- export * from './EAService';
3
- export * from './SubgraphService';
4
- export * from './ReceivableService';
1
+ export * from './ARWeaveService';
2
+ export * from './EAService';
3
+ export * from './SubgraphService';
4
+ export * from './ReceivableService';
@@ -1,8 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./ARWeaveService"), exports);
5
- tslib_1.__exportStar(require("./EAService"), exports);
6
- tslib_1.__exportStar(require("./SubgraphService"), exports);
7
- tslib_1.__exportStar(require("./ReceivableService"), exports);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./ARWeaveService"), exports);
5
+ tslib_1.__exportStar(require("./EAService"), exports);
6
+ tslib_1.__exportStar(require("./SubgraphService"), exports);
7
+ tslib_1.__exportStar(require("./ReceivableService"), exports);
8
8
  //# sourceMappingURL=index.js.map
@@ -1,15 +1,14 @@
1
- import { JsonRpcProvider, JsonRpcSigner } from '@ethersproject/providers';
2
- import { ethers } from 'ethers';
3
- export declare function isPolygonNetwork(network: number): boolean;
4
- /**
5
- * Get the chain ID from a signer or provider object.
6
- * @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The signer or provider object to get the chain ID from.
7
- * @returns {number} - The chain ID.
8
- */
9
- export declare function getChainIdFromJsonSignerOrProvider(signerOrProvider: JsonRpcProvider | JsonRpcSigner): number;
10
- /**
11
- * Get the chain ID from a signer or provider object.
12
- * @param {ethers.provider.Provider | ethers.Signer} signerOrProvider - The signer or provider object to get the chain ID from.
13
- * @returns {number} - The chain ID.
14
- */
15
- export declare function getChainIdFromSignerOrProvider(signerOrProvider: ethers.providers.Provider | ethers.Signer): Promise<number | undefined>;
1
+ import { JsonRpcProvider, JsonRpcSigner } from '@ethersproject/providers';
2
+ import { ethers } from 'ethers';
3
+ /**
4
+ * Get the chain ID from a signer or provider object.
5
+ * @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The signer or provider object to get the chain ID from.
6
+ * @returns {number} - The chain ID.
7
+ */
8
+ export declare function getChainIdFromJsonSignerOrProvider(signerOrProvider: JsonRpcProvider | JsonRpcSigner): number;
9
+ /**
10
+ * Get the chain ID from a signer or provider object.
11
+ * @param {ethers.provider.Provider | ethers.Signer} signerOrProvider - The signer or provider object to get the chain ID from.
12
+ * @returns {number} - The chain ID.
13
+ */
14
+ export declare function getChainIdFromSignerOrProvider(signerOrProvider: ethers.providers.Provider | ethers.Signer): Promise<number | undefined>;
@@ -1,38 +1,34 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getChainIdFromSignerOrProvider = exports.getChainIdFromJsonSignerOrProvider = exports.isPolygonNetwork = void 0;
4
- const providers_1 = require("@ethersproject/providers");
5
- const ethers_1 = require("ethers");
6
- function isPolygonNetwork(network) {
7
- return network === 137 || network === 80001;
8
- }
9
- exports.isPolygonNetwork = isPolygonNetwork;
10
- /**
11
- * Get the chain ID from a signer or provider object.
12
- * @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The signer or provider object to get the chain ID from.
13
- * @returns {number} - The chain ID.
14
- */
15
- function getChainIdFromJsonSignerOrProvider(signerOrProvider) {
16
- return signerOrProvider instanceof providers_1.JsonRpcProvider
17
- ? signerOrProvider.network.chainId
18
- : signerOrProvider.provider.network.chainId;
19
- }
20
- exports.getChainIdFromJsonSignerOrProvider = getChainIdFromJsonSignerOrProvider;
21
- /**
22
- * Get the chain ID from a signer or provider object.
23
- * @param {ethers.provider.Provider | ethers.Signer} signerOrProvider - The signer or provider object to get the chain ID from.
24
- * @returns {number} - The chain ID.
25
- */
26
- async function getChainIdFromSignerOrProvider(signerOrProvider) {
27
- var _a;
28
- let network;
29
- if (signerOrProvider instanceof ethers_1.ethers.providers.Provider) {
30
- network = await signerOrProvider.getNetwork();
31
- }
32
- else {
33
- network = await ((_a = signerOrProvider === null || signerOrProvider === void 0 ? void 0 : signerOrProvider.provider) === null || _a === void 0 ? void 0 : _a.getNetwork());
34
- }
35
- return network === null || network === void 0 ? void 0 : network.chainId;
36
- }
37
- exports.getChainIdFromSignerOrProvider = getChainIdFromSignerOrProvider;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getChainIdFromSignerOrProvider = exports.getChainIdFromJsonSignerOrProvider = void 0;
4
+ const providers_1 = require("@ethersproject/providers");
5
+ const ethers_1 = require("ethers");
6
+ /**
7
+ * Get the chain ID from a signer or provider object.
8
+ * @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The signer or provider object to get the chain ID from.
9
+ * @returns {number} - The chain ID.
10
+ */
11
+ function getChainIdFromJsonSignerOrProvider(signerOrProvider) {
12
+ return signerOrProvider instanceof providers_1.JsonRpcProvider
13
+ ? signerOrProvider.network.chainId
14
+ : signerOrProvider.provider.network.chainId;
15
+ }
16
+ exports.getChainIdFromJsonSignerOrProvider = getChainIdFromJsonSignerOrProvider;
17
+ /**
18
+ * Get the chain ID from a signer or provider object.
19
+ * @param {ethers.provider.Provider | ethers.Signer} signerOrProvider - The signer or provider object to get the chain ID from.
20
+ * @returns {number} - The chain ID.
21
+ */
22
+ async function getChainIdFromSignerOrProvider(signerOrProvider) {
23
+ var _a;
24
+ let network;
25
+ if (signerOrProvider instanceof ethers_1.ethers.providers.Provider) {
26
+ network = await signerOrProvider.getNetwork();
27
+ }
28
+ else {
29
+ network = await ((_a = signerOrProvider === null || signerOrProvider === void 0 ? void 0 : signerOrProvider.provider) === null || _a === void 0 ? void 0 : _a.getNetwork());
30
+ }
31
+ return network === null || network === void 0 ? void 0 : network.chainId;
32
+ }
33
+ exports.getChainIdFromSignerOrProvider = getChainIdFromSignerOrProvider;
38
34
  //# sourceMappingURL=chain.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"chain.js","sourceRoot":"","sources":["../../../src/utils/chain.ts"],"names":[],"mappings":";;;AAAA,wDAAyE;AACzE,mCAA+B;AAE/B,SAAgB,gBAAgB,CAAC,OAAe;IAC9C,OAAO,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,KAAK,CAAA;AAC7C,CAAC;AAFD,4CAEC;AAED;;;;GAIG;AACH,SAAgB,kCAAkC,CAChD,gBAAiD;IAEjD,OAAO,gBAAgB,YAAY,2BAAe;Q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CAAA;KACzD;IAED,OAAO,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAA;AACzB,CAAC;AAXD,wEAWC"}
@@ -1,4 +1,3 @@
1
- export * from './chain';
2
- export * from './web3';
3
- export * from './poolInfo';
4
- export * from './maticGasStation';
1
+ export * from './chain';
2
+ export * from './web3';
3
+ export * from './poolInfo';
@@ -1,8 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./chain"), exports);
5
- tslib_1.__exportStar(require("./web3"), exports);
6
- tslib_1.__exportStar(require("./poolInfo"), exports);
7
- tslib_1.__exportStar(require("./maticGasStation"), exports);
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./chain"), exports);
5
+ tslib_1.__exportStar(require("./web3"), exports);
6
+ tslib_1.__exportStar(require("./poolInfo"), exports);
8
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,kDAAuB;AACvB,iDAAsB;AACtB,qDAA0B;AAC1B,4DAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,kDAAuB;AACvB,iDAAsB;AACtB,qDAA0B"}
@@ -1,8 +1,8 @@
1
- import { POOL_NAME, POOL_TYPE, PoolInfoType } from '@huma-finance/shared';
2
- /**
3
- * Returns the pool info based on the provided pool name and type, using the same chain ID as the provider/signer given
4
- * @param {POOL_NAME} poolName - The name of the pool.
5
- * @param {POOL_TYPE} poolType - The type of the pool.
6
- * @returns {PoolInfoType|undefined} - The pool info or undefined if the chain ID is not supported.
7
- */
8
- export declare const getPoolInfo: (chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE) => PoolInfoType | undefined;
1
+ import { POOL_NAME, POOL_TYPE, PoolInfoType } from '@huma-finance/shared';
2
+ /**
3
+ * Returns the pool info based on the provided pool name and type, using the same chain ID as the provider/signer given
4
+ * @param {POOL_NAME} poolName - The name of the pool.
5
+ * @param {POOL_TYPE} poolType - The type of the pool.
6
+ * @returns {PoolInfoType|undefined} - The pool info or undefined if the chain ID is not supported.
7
+ */
8
+ export declare const getPoolInfo: (chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE) => PoolInfoType | undefined;
@@ -1,13 +1,13 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPoolInfo = void 0;
4
- const shared_1 = require("@huma-finance/shared");
5
- /**
6
- * Returns the pool info based on the provided pool name and type, using the same chain ID as the provider/signer given
7
- * @param {POOL_NAME} poolName - The name of the pool.
8
- * @param {POOL_TYPE} poolType - The type of the pool.
9
- * @returns {PoolInfoType|undefined} - The pool info or undefined if the chain ID is not supported.
10
- */
11
- const getPoolInfo = (chainId, poolName, poolType) => { var _a, _b; return (_b = (_a = shared_1.PoolContractMap[chainId]) === null || _a === void 0 ? void 0 : _a[poolType]) === null || _b === void 0 ? void 0 : _b[poolName]; };
12
- exports.getPoolInfo = getPoolInfo;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getPoolInfo = void 0;
4
+ const shared_1 = require("@huma-finance/shared");
5
+ /**
6
+ * Returns the pool info based on the provided pool name and type, using the same chain ID as the provider/signer given
7
+ * @param {POOL_NAME} poolName - The name of the pool.
8
+ * @param {POOL_TYPE} poolType - The type of the pool.
9
+ * @returns {PoolInfoType|undefined} - The pool info or undefined if the chain ID is not supported.
10
+ */
11
+ const getPoolInfo = (chainId, poolName, poolType) => { var _a, _b; return (_b = (_a = shared_1.PoolContractMap[chainId]) === null || _a === void 0 ? void 0 : _a[poolType]) === null || _b === void 0 ? void 0 : _b[poolName]; };
12
+ exports.getPoolInfo = getPoolInfo;
13
13
  //# sourceMappingURL=poolInfo.js.map
@@ -1,4 +1,4 @@
1
- import { Contract } from '@ethersproject/contracts';
2
- import { ethers } from 'ethers';
3
- export declare function isAddress(value: any): string | false;
4
- export declare function getContract(address: string, ABI: any, signerOrProvider: ethers.providers.Provider | ethers.Signer): Contract;
1
+ import { Contract } from '@ethersproject/contracts';
2
+ import { ethers } from 'ethers';
3
+ export declare function isAddress(value: any): string | false;
4
+ export declare function getContract(address: string, ABI: any, signerOrProvider: ethers.providers.Provider | ethers.Signer): Contract;
@@ -1,29 +1,29 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getContract = exports.isAddress = void 0;
4
- const contracts_1 = require("@ethersproject/contracts");
5
- const constants_1 = require("@ethersproject/constants");
6
- const address_1 = require("@ethersproject/address");
7
- // returns the checksummed address if the address is valid, otherwise returns false
8
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
- function isAddress(value) {
10
- try {
11
- // Alphabetical letters must be made lowercase for getAddress to work.
12
- // See documentation here: https://docs.ethers.io/v5/api/utils/address/
13
- return (0, address_1.getAddress)(value.toLowerCase());
14
- }
15
- catch (_a) {
16
- return false;
17
- }
18
- }
19
- exports.isAddress = isAddress;
20
- function getContract(address,
21
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
- ABI, signerOrProvider) {
23
- if (!isAddress(address) || address === constants_1.AddressZero) {
24
- throw Error(`Invalid 'address' parameter '${address}'.`);
25
- }
26
- return new contracts_1.Contract(address, ABI, signerOrProvider);
27
- }
28
- exports.getContract = getContract;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getContract = exports.isAddress = void 0;
4
+ const contracts_1 = require("@ethersproject/contracts");
5
+ const constants_1 = require("@ethersproject/constants");
6
+ const address_1 = require("@ethersproject/address");
7
+ // returns the checksummed address if the address is valid, otherwise returns false
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ function isAddress(value) {
10
+ try {
11
+ // Alphabetical letters must be made lowercase for getAddress to work.
12
+ // See documentation here: https://docs.ethers.io/v5/api/utils/address/
13
+ return (0, address_1.getAddress)(value.toLowerCase());
14
+ }
15
+ catch (_a) {
16
+ return false;
17
+ }
18
+ }
19
+ exports.isAddress = isAddress;
20
+ function getContract(address,
21
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
22
+ ABI, signerOrProvider) {
23
+ if (!isAddress(address) || address === constants_1.AddressZero) {
24
+ throw Error(`Invalid 'address' parameter '${address}'.`);
25
+ }
26
+ return new contracts_1.Contract(address, ABI, signerOrProvider);
27
+ }
28
+ exports.getContract = getContract;
29
29
  //# sourceMappingURL=web3.js.map
@@ -1,40 +1,40 @@
1
- import { GraphQLClient } from 'graphql-request';
2
- export type Maybe<T> = T | null;
3
- export type InputMaybe<T> = Maybe<T>;
4
- export type Exact<T extends {
5
- [key: string]: unknown;
6
- }> = {
7
- [K in keyof T]: T[K];
8
- };
9
- export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
10
- [SubKey in K]?: Maybe<T[SubKey]>;
11
- };
12
- export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
13
- [SubKey in K]: Maybe<T[SubKey]>;
14
- };
15
- /** All built-in and custom scalars, mapped to their actual values */
16
- export type Scalars = {
17
- ID: string;
18
- String: string;
19
- Boolean: boolean;
20
- Int: number;
21
- Float: number;
22
- };
23
- export type Receivable = {
24
- __typename?: 'Receivable';
25
- creationDate?: Maybe<Scalars['String']>;
26
- currencyCode?: Maybe<Scalars['String']>;
27
- id?: Maybe<Scalars['String']>;
28
- lastUpdate?: Maybe<Scalars['String']>;
29
- maturityDate?: Maybe<Scalars['String']>;
30
- owner?: Maybe<Scalars['String']>;
31
- paidAmount?: Maybe<Scalars['String']>;
32
- pool?: Maybe<Scalars['String']>;
33
- receivableAmount?: Maybe<Scalars['String']>;
34
- status?: Maybe<Scalars['String']>;
35
- tokenId?: Maybe<Scalars['String']>;
36
- uri?: Maybe<Scalars['String']>;
37
- };
38
- export type SdkFunctionWrapper = <T>(action: (requestHeaders?: Record<string, string>) => Promise<T>, operationName: string, operationType?: string) => Promise<T>;
39
- export declare function getSdk(client: GraphQLClient, withWrapper?: SdkFunctionWrapper): {};
40
- export type Sdk = ReturnType<typeof getSdk>;
1
+ import { GraphQLClient } from 'graphql-request';
2
+ export type Maybe<T> = T | null;
3
+ export type InputMaybe<T> = Maybe<T>;
4
+ export type Exact<T extends {
5
+ [key: string]: unknown;
6
+ }> = {
7
+ [K in keyof T]: T[K];
8
+ };
9
+ export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
10
+ [SubKey in K]?: Maybe<T[SubKey]>;
11
+ };
12
+ export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
13
+ [SubKey in K]: Maybe<T[SubKey]>;
14
+ };
15
+ /** All built-in and custom scalars, mapped to their actual values */
16
+ export type Scalars = {
17
+ ID: string;
18
+ String: string;
19
+ Boolean: boolean;
20
+ Int: number;
21
+ Float: number;
22
+ };
23
+ export type Receivable = {
24
+ __typename?: 'Receivable';
25
+ creationDate?: Maybe<Scalars['String']>;
26
+ currencyCode?: Maybe<Scalars['String']>;
27
+ id?: Maybe<Scalars['String']>;
28
+ lastUpdate?: Maybe<Scalars['String']>;
29
+ maturityDate?: Maybe<Scalars['String']>;
30
+ owner?: Maybe<Scalars['String']>;
31
+ paidAmount?: Maybe<Scalars['String']>;
32
+ pool?: Maybe<Scalars['String']>;
33
+ receivableAmount?: Maybe<Scalars['String']>;
34
+ status?: Maybe<Scalars['String']>;
35
+ tokenId?: Maybe<Scalars['String']>;
36
+ uri?: Maybe<Scalars['String']>;
37
+ };
38
+ export type SdkFunctionWrapper = <T>(action: (requestHeaders?: Record<string, string>) => Promise<T>, operationName: string, operationType?: string) => Promise<T>;
39
+ export declare function getSdk(client: GraphQLClient, withWrapper?: SdkFunctionWrapper): {};
40
+ export type Sdk = ReturnType<typeof getSdk>;
@@ -1,5 +1,5 @@
1
- const defaultWrapper = (action, _operationName, _operationType) => action();
2
- export function getSdk(client, withWrapper = defaultWrapper) {
3
- return {};
4
- }
1
+ const defaultWrapper = (action, _operationName, _operationType) => action();
2
+ export function getSdk(client, withWrapper = defaultWrapper) {
3
+ return {};
4
+ }
5
5
  //# sourceMappingURL=generatedTypes.js.map
@@ -1 +1 @@
1
- export * from './generatedTypes';
1
+ export * from './generatedTypes';
@@ -1,2 +1,2 @@
1
- export * from './generatedTypes';
1
+ export * from './generatedTypes';
2
2
  //# sourceMappingURL=index.js.map
@@ -1,10 +1,10 @@
1
- import { Contract, ethers } from 'ethers';
2
- /**
3
- * Returns an ethers contract instance for the ERC20TransferableReceivable contract
4
- * associated with the given pool name on the current chain.
5
- *
6
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
7
- * @param {number} chainId The chain id where the contract instance exists
8
- * @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
9
- */
10
- export declare function getERC20TransferableReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
1
+ import { Contract, ethers } from 'ethers';
2
+ /**
3
+ * Returns an ethers contract instance for the ERC20TransferableReceivable contract
4
+ * associated with the given pool name on the current chain.
5
+ *
6
+ * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
7
+ * @param {number} chainId The chain id where the contract instance exists
8
+ * @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
9
+ */
10
+ export declare function getERC20TransferableReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;