@huma-finance/sdk 0.0.8 → 0.0.10

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 (127) hide show
  1. package/LICENSE +660 -660
  2. package/README.md +30 -30
  3. package/package.json +3 -3
  4. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.d.ts +0 -10
  5. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js +0 -22
  6. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js.map +0 -1
  7. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.d.ts +0 -10
  8. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js +0 -22
  9. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js.map +0 -1
  10. package/dist/cjs/helpers/PoolContractHelper.d.ts +0 -12
  11. package/dist/cjs/helpers/PoolContractHelper.js +0 -21
  12. package/dist/cjs/helpers/PoolContractHelper.js.map +0 -1
  13. package/dist/cjs/helpers/index.d.ts +0 -3
  14. package/dist/cjs/helpers/index.js +0 -7
  15. package/dist/cjs/helpers/index.js.map +0 -1
  16. package/dist/cjs/hooks/index.d.ts +0 -4
  17. package/dist/cjs/hooks/index.js +0 -8
  18. package/dist/cjs/hooks/index.js.map +0 -1
  19. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.d.ts +0 -10
  20. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js +0 -20
  21. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js.map +0 -1
  22. package/dist/cjs/hooks/useContract.d.ts +0 -13
  23. package/dist/cjs/hooks/useContract.js +0 -31
  24. package/dist/cjs/hooks/useContract.js.map +0 -1
  25. package/dist/cjs/hooks/useERC20TransferableReceivableContract.d.ts +0 -12
  26. package/dist/cjs/hooks/useERC20TransferableReceivableContract.js +0 -21
  27. package/dist/cjs/hooks/useERC20TransferableReceivableContract.js.map +0 -1
  28. package/dist/cjs/hooks/usePoolContract.d.ts +0 -60
  29. package/dist/cjs/hooks/usePoolContract.js +0 -54
  30. package/dist/cjs/hooks/usePoolContract.js.map +0 -1
  31. package/dist/cjs/hooks/useReceivableFactoringPoolContract.d.ts +0 -10
  32. package/dist/cjs/hooks/useReceivableFactoringPoolContract.js +0 -17
  33. package/dist/cjs/hooks/useReceivableFactoringPoolContract.js.map +0 -1
  34. package/dist/cjs/index.d.ts +0 -4
  35. package/dist/cjs/index.js +0 -8
  36. package/dist/cjs/index.js.map +0 -1
  37. package/dist/cjs/services/ARWeaveService.d.ts +0 -84
  38. package/dist/cjs/services/ARWeaveService.js +0 -152
  39. package/dist/cjs/services/ARWeaveService.js.map +0 -1
  40. package/dist/cjs/services/EAService.d.ts +0 -36
  41. package/dist/cjs/services/EAService.js +0 -19
  42. package/dist/cjs/services/EAService.js.map +0 -1
  43. package/dist/cjs/services/ReceivableService.d.ts +0 -95
  44. package/dist/cjs/services/ReceivableService.js +0 -172
  45. package/dist/cjs/services/ReceivableService.js.map +0 -1
  46. package/dist/cjs/services/SubgraphService.d.ts +0 -53
  47. package/dist/cjs/services/SubgraphService.js +0 -101
  48. package/dist/cjs/services/SubgraphService.js.map +0 -1
  49. package/dist/cjs/services/index.d.ts +0 -4
  50. package/dist/cjs/services/index.js +0 -8
  51. package/dist/cjs/services/index.js.map +0 -1
  52. package/dist/cjs/utils/chain.d.ts +0 -14
  53. package/dist/cjs/utils/chain.js +0 -34
  54. package/dist/cjs/utils/chain.js.map +0 -1
  55. package/dist/cjs/utils/index.d.ts +0 -3
  56. package/dist/cjs/utils/index.js +0 -7
  57. package/dist/cjs/utils/index.js.map +0 -1
  58. package/dist/cjs/utils/poolInfo.d.ts +0 -9
  59. package/dist/cjs/utils/poolInfo.js +0 -14
  60. package/dist/cjs/utils/poolInfo.js.map +0 -1
  61. package/dist/cjs/utils/web3.d.ts +0 -4
  62. package/dist/cjs/utils/web3.js +0 -29
  63. package/dist/cjs/utils/web3.js.map +0 -1
  64. package/dist/helpers/BaseCreditPoolReceivableContractHelper.d.ts +0 -10
  65. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js +0 -18
  66. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js.map +0 -1
  67. package/dist/helpers/ERC20TransferableReceivableContractHelper.d.ts +0 -10
  68. package/dist/helpers/ERC20TransferableReceivableContractHelper.js +0 -18
  69. package/dist/helpers/ERC20TransferableReceivableContractHelper.js.map +0 -1
  70. package/dist/helpers/PoolContractHelper.d.ts +0 -12
  71. package/dist/helpers/PoolContractHelper.js +0 -17
  72. package/dist/helpers/PoolContractHelper.js.map +0 -1
  73. package/dist/helpers/index.d.ts +0 -3
  74. package/dist/helpers/index.js +0 -4
  75. package/dist/helpers/index.js.map +0 -1
  76. package/dist/hooks/index.d.ts +0 -4
  77. package/dist/hooks/index.js +0 -5
  78. package/dist/hooks/index.js.map +0 -1
  79. package/dist/hooks/useBaseCreditPoolReceivableContract.d.ts +0 -10
  80. package/dist/hooks/useBaseCreditPoolReceivableContract.js +0 -16
  81. package/dist/hooks/useBaseCreditPoolReceivableContract.js.map +0 -1
  82. package/dist/hooks/useContract.d.ts +0 -13
  83. package/dist/hooks/useContract.js +0 -27
  84. package/dist/hooks/useContract.js.map +0 -1
  85. package/dist/hooks/useERC20TransferableReceivableContract.d.ts +0 -12
  86. package/dist/hooks/useERC20TransferableReceivableContract.js +0 -17
  87. package/dist/hooks/useERC20TransferableReceivableContract.js.map +0 -1
  88. package/dist/hooks/usePool.d.ts +0 -0
  89. package/dist/hooks/usePool.js +0 -2
  90. package/dist/hooks/usePool.js.map +0 -1
  91. package/dist/hooks/usePoolContract.d.ts +0 -60
  92. package/dist/hooks/usePoolContract.js +0 -49
  93. package/dist/hooks/usePoolContract.js.map +0 -1
  94. package/dist/hooks/useReceivableFactoringPoolContract.d.ts +0 -10
  95. package/dist/hooks/useReceivableFactoringPoolContract.js +0 -13
  96. package/dist/hooks/useReceivableFactoringPoolContract.js.map +0 -1
  97. package/dist/index.d.ts +0 -4
  98. package/dist/index.js +0 -5
  99. package/dist/index.js.map +0 -1
  100. package/dist/services/ARWeaveService.d.ts +0 -84
  101. package/dist/services/ARWeaveService.js +0 -147
  102. package/dist/services/ARWeaveService.js.map +0 -1
  103. package/dist/services/EAService.d.ts +0 -36
  104. package/dist/services/EAService.js +0 -16
  105. package/dist/services/EAService.js.map +0 -1
  106. package/dist/services/ReceivableService.d.ts +0 -95
  107. package/dist/services/ReceivableService.js +0 -169
  108. package/dist/services/ReceivableService.js.map +0 -1
  109. package/dist/services/SubgraphService.d.ts +0 -53
  110. package/dist/services/SubgraphService.js +0 -98
  111. package/dist/services/SubgraphService.js.map +0 -1
  112. package/dist/services/index.d.ts +0 -4
  113. package/dist/services/index.js +0 -5
  114. package/dist/services/index.js.map +0 -1
  115. package/dist/tsconfig.cjs.tsbuildinfo +0 -1
  116. package/dist/utils/chain.d.ts +0 -14
  117. package/dist/utils/chain.js +0 -29
  118. package/dist/utils/chain.js.map +0 -1
  119. package/dist/utils/index.d.ts +0 -3
  120. package/dist/utils/index.js +0 -4
  121. package/dist/utils/index.js.map +0 -1
  122. package/dist/utils/poolInfo.d.ts +0 -9
  123. package/dist/utils/poolInfo.js +0 -10
  124. package/dist/utils/poolInfo.js.map +0 -1
  125. package/dist/utils/web3.d.ts +0 -4
  126. package/dist/utils/web3.js +0 -24
  127. package/dist/utils/web3.js.map +0 -1
package/README.md CHANGED
@@ -1,31 +1,31 @@
1
- # Huma SDK
2
-
3
- The Huma SDK includes utilities and services for interacting with different layers of our protocol including contracts, our evaluation agent underwriting service, and data storage hosted on ARWeave, Subgraph, on-chain, etc. It's currently offered just as a Javascript NPM package at https://www.npmjs.com/package/@huma-finance/sdk.
4
-
5
- ## Getting Started
6
-
7
- We recommend onboarding onto our SDK using the [Getting Started guide](docs/getting-started.md)
8
-
9
- ## Documentation
10
-
11
- For extensive documentation on the different functions offered please refer to the [API documentation](API.md)
12
-
13
- ## Features
14
-
15
- - Services
16
- - `ARWeaveService` contains helper methods for storing data on ARWeave conforming to Huma data standards, querying for metadata, and prefunding ARWeave nodes to pay for data uploading.
17
- - `EAService` contains helper methods to request credit approvals from Huma's Evaluation Agent layer.
18
- - `ReceivableService` contains helper methods to manage minting and paying Receivable tokens
19
- - `SubgraphService` contains helper methods for querying Huma's subgraphs
20
- - Hooks
21
- - React hooks for fetching ethers.js Contract instances of Huma contracts
22
- - Helpers
23
- - Helper functions for fetching ethers.js Contract instances of Huma contracts
24
-
25
- ## Examples
26
-
27
- To see how the Huma SDK can be used, feel free to use our interactive example in the huma-widgets package.
28
-
29
- 1. Open up the huma-widgets package in your terminal
30
- 2. Run yarn cosmos
1
+ # Huma SDK
2
+
3
+ The Huma SDK includes utilities and services for interacting with different layers of our protocol including contracts, our evaluation agent underwriting service, and data storage hosted on ARWeave, Subgraph, on-chain, etc. It's currently offered just as a Javascript NPM package at https://www.npmjs.com/package/@huma-finance/sdk.
4
+
5
+ ## Getting Started
6
+
7
+ We recommend onboarding onto our SDK using the [Getting Started guide](getting-started.md)
8
+
9
+ ## Documentation
10
+
11
+ For extensive documentation on the different functions offered please refer to the [API documentation](API.md)
12
+
13
+ ## Features
14
+
15
+ - Services
16
+ - `ARWeaveService` contains helper methods for storing data on ARWeave conforming to Huma data standards, querying for metadata, and prefunding ARWeave nodes to pay for data uploading.
17
+ - `EAService` contains helper methods to request credit approvals from Huma's Evaluation Agent layer.
18
+ - `ReceivableService` contains helper methods to manage minting and paying Receivable tokens
19
+ - `SubgraphService` contains helper methods for querying Huma's subgraphs
20
+ - Hooks
21
+ - React hooks for fetching ethers.js Contract instances of Huma contracts
22
+ - Helpers
23
+ - Helper functions for fetching ethers.js Contract instances of Huma contracts
24
+
25
+ ## Examples
26
+
27
+ To see how the Huma SDK can be used, feel free to use our interactive example in the huma-widgets package.
28
+
29
+ 1. Open up the huma-widgets package in your terminal
30
+ 2. Run yarn cosmos
31
31
  3. Open up localhost:8000 in your browser and navigate to the SDKTesting fixture
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@huma-finance/sdk",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "types": "./dist/index.d.ts",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/index.js",
@@ -20,7 +20,7 @@
20
20
  "@ethersproject/constants": "^5.7.0",
21
21
  "@ethersproject/contracts": "^5.7.0",
22
22
  "@ethersproject/providers": "^5.6.0",
23
- "@huma-finance/shared": "^0.0.8",
23
+ "@huma-finance/shared": "^0.0.10",
24
24
  "arweave": "^1.13.5",
25
25
  "ethers": "^5.7.2",
26
26
  "graphql-request": "^6.0.0",
@@ -83,5 +83,5 @@
83
83
  "optionalDependencies": {
84
84
  "encoding": "^0.1.13"
85
85
  },
86
- "gitHead": "d9e7878a7b163ccc5b29959eb8a0fbb73c988244"
86
+ "gitHead": "61b1485097a4e7e6d2f1c2825454b9d2283c2a6c"
87
87
  }
@@ -1,10 +0,0 @@
1
- import { Contract, ethers } from 'ethers';
2
- /**
3
- * Returns an ethers contract instance for the BaseCreditPoolReceivable 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 BaseCreditPoolReceivable contract or null if it could not be found.
9
- */
10
- export declare function getBaseCreditPoolReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
@@ -1,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getBaseCreditPoolReceivableContract = void 0;
4
- const shared_1 = require("@huma-finance/shared");
5
- const utils_1 = require("../utils");
6
- /**
7
- * Returns an ethers contract instance for the BaseCreditPoolReceivable contract
8
- * associated with the given pool name on the current chain.
9
- *
10
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
11
- * @param {number} chainId The chain id where the contract instance exists
12
- * @returns {Contract | null} A contract instance for the BaseCreditPoolReceivable contract or null if it could not be found.
13
- */
14
- function getBaseCreditPoolReceivableContract(signerOrProvider, chainId) {
15
- var _a;
16
- const baseCreditPoolReceivable = (_a = shared_1.SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[shared_1.SupplementaryContracts.BaseCreditPoolReceivable];
17
- if (!baseCreditPoolReceivable)
18
- return null;
19
- return (0, utils_1.getContract)(baseCreditPoolReceivable, shared_1.BASE_CREDIT_POOL_RECEIVABLE_ABI, signerOrProvider);
20
- }
21
- exports.getBaseCreditPoolReceivableContract = getBaseCreditPoolReceivableContract;
22
- //# sourceMappingURL=BaseCreditPoolReceivableContractHelper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"BaseCreditPoolReceivableContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/BaseCreditPoolReceivableContractHelper.ts"],"names":[],"mappings":";;;AACA,iDAI6B;AAE7B,oCAAsC;AAEtC;;;;;;;GAOG;AACH,SAAgB,mCAAmC,CACjD,gBAA2D,EAC3D,OAAe;;IAEf,MAAM,wBAAwB,GAC5B,MAAA,kCAAyB,CAAC,OAAO,CAAC,0CAChC,+BAAsB,CAAC,wBAAwB,CAChD,CAAA;IAEH,IAAI,CAAC,wBAAwB;QAAE,OAAO,IAAI,CAAA;IAE1C,OAAO,IAAA,mBAAW,EAChB,wBAAwB,EACxB,wCAA+B,EAC/B,gBAAgB,CACjB,CAAA;AACH,CAAC;AAhBD,kFAgBC"}
@@ -1,10 +0,0 @@
1
- import { Contract, ethers } from 'ethers';
2
- /**
3
- * Returns an ethers contract instance for the BaseCreditPoolReceivable 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 BaseCreditPoolReceivable 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,22 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getERC20TransferableReceivableContract = void 0;
4
- const shared_1 = require("@huma-finance/shared");
5
- const utils_1 = require("../utils");
6
- /**
7
- * Returns an ethers contract instance for the BaseCreditPoolReceivable contract
8
- * associated with the given pool name on the current chain.
9
- *
10
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
11
- * @param {number} chainId The chain id where the contract instance exists
12
- * @returns {Contract | null} A contract instance for the BaseCreditPoolReceivable contract or null if it could not be found.
13
- */
14
- function getERC20TransferableReceivableContract(signerOrProvider, chainId) {
15
- var _a;
16
- const erc20TransferableReceiable = (_a = shared_1.SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[shared_1.SupplementaryContracts.ERC20TransferableReceivable];
17
- if (!erc20TransferableReceiable)
18
- return null;
19
- return (0, utils_1.getContract)(erc20TransferableReceiable, shared_1.ERC20_TRANSFERABLE_RECEIVABLE_ABI, signerOrProvider);
20
- }
21
- exports.getERC20TransferableReceivableContract = getERC20TransferableReceivableContract;
22
- //# sourceMappingURL=ERC20TransferableReceivableContractHelper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ERC20TransferableReceivableContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/ERC20TransferableReceivableContractHelper.ts"],"names":[],"mappings":";;;AACA,iDAI6B;AAE7B,oCAAsC;AAEtC;;;;;;;GAOG;AACH,SAAgB,sCAAsC,CACpD,gBAA2D,EAC3D,OAAe;;IAEf,MAAM,0BAA0B,GAC9B,MAAA,kCAAyB,CAAC,OAAO,CAAC,0CAChC,+BAAsB,CAAC,2BAA2B,CACnD,CAAA;IAEH,IAAI,CAAC,0BAA0B;QAAE,OAAO,IAAI,CAAA;IAE5C,OAAO,IAAA,mBAAW,EAChB,0BAA0B,EAC1B,0CAAiC,EACjC,gBAAgB,CACjB,CAAA;AACH,CAAC;AAhBD,wFAgBC"}
@@ -1,12 +0,0 @@
1
- import { Contract, ethers } from 'ethers';
2
- import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
3
- /**
4
- * Returns an ethers contract instance for a Huma pool contract
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
- * @param {POOL_NAME} poolName The name of the pool contract to get.
9
- * @param {POOL_TYPE} poolType The type of the pool contract to get.
10
- * @returns {Contract | null} A contract instance for the Pool contract or null if it could not be found.
11
- */
12
- export declare function getPoolContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): Contract | null;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPoolContract = void 0;
4
- const utils_1 = require("../utils");
5
- /**
6
- * Returns an ethers contract instance for a Huma pool contract
7
- *
8
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
9
- * @param {number} chainId The chain id where the contract instance exists
10
- * @param {POOL_NAME} poolName The name of the pool contract to get.
11
- * @param {POOL_TYPE} poolType The type of the pool contract to get.
12
- * @returns {Contract | null} A contract instance for the Pool contract or null if it could not be found.
13
- */
14
- function getPoolContract(signerOrProvider, chainId, poolName, poolType) {
15
- const poolInfo = (0, utils_1.getPoolInfo)(chainId, poolName, poolType);
16
- if (!poolInfo)
17
- return null;
18
- return (0, utils_1.getContract)(poolInfo.pool, poolInfo.poolAbi, signerOrProvider);
19
- }
20
- exports.getPoolContract = getPoolContract;
21
- //# sourceMappingURL=PoolContractHelper.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":";;;AAGA,oCAAmD;AAEnD;;;;;;;;GAQG;AACH,SAAgB,eAAe,CAC7B,gBAA2D,EAC3D,OAAe,EACf,QAAmB,EACnB,QAAmB;IAEnB,MAAM,QAAQ,GAAG,IAAA,mBAAW,EAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAEzD,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAA;IAE1B,OAAO,IAAA,mBAAW,EAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;AACvE,CAAC;AAXD,0CAWC"}
@@ -1,3 +0,0 @@
1
- export * from './BaseCreditPoolReceivableContractHelper';
2
- export * from './ERC20TransferableReceivableContractHelper';
3
- export * from './PoolContractHelper';
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./BaseCreditPoolReceivableContractHelper"), exports);
5
- tslib_1.__exportStar(require("./ERC20TransferableReceivableContractHelper"), exports);
6
- tslib_1.__exportStar(require("./PoolContractHelper"), exports);
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":";;;AAAA,mFAAwD;AACxD,sFAA2D;AAC3D,+DAAoC"}
@@ -1,4 +0,0 @@
1
- export * from './useContract';
2
- export * from './useBaseCreditPoolReceivableContract';
3
- export * from './useERC20TransferableReceivableContract';
4
- export * from './usePoolContract';
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./useContract"), exports);
5
- tslib_1.__exportStar(require("./useBaseCreditPoolReceivableContract"), exports);
6
- tslib_1.__exportStar(require("./useERC20TransferableReceivableContract"), exports);
7
- tslib_1.__exportStar(require("./usePoolContract"), exports);
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":";;;AAAA,wDAA6B;AAC7B,gFAAqD;AACrD,mFAAwD;AACxD,4DAAiC"}
@@ -1,10 +0,0 @@
1
- import { Contract, ethers } from 'ethers';
2
- /**
3
- * A react hook that returns an ethers contract instance for the BaseCreditPoolReceivable 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 BaseCreditPoolReceivable contract or null if it could not be found.
9
- */
10
- export declare function useBaseCreditPoolReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
@@ -1,20 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useBaseCreditPoolReceivableContract = void 0;
4
- const shared_1 = require("@huma-finance/shared");
5
- const useContract_1 = require("./useContract");
6
- /**
7
- * A react hook that returns an ethers contract instance for the BaseCreditPoolReceivable contract
8
- * associated with the given pool name on the current chain.
9
- *
10
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
11
- * @param {number} chainId The chain id where the contract instance exists
12
- * @returns {Contract | null} A contract instance for the BaseCreditPoolReceivable contract or null if it could not be found.
13
- */
14
- function useBaseCreditPoolReceivableContract(signerOrProvider, chainId) {
15
- var _a;
16
- const baseCreditPoolReceivable = (_a = shared_1.SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[shared_1.SupplementaryContracts.BaseCreditPoolReceivable];
17
- return (0, useContract_1.useContract)(baseCreditPoolReceivable, shared_1.BASE_CREDIT_POOL_RECEIVABLE_ABI, signerOrProvider);
18
- }
19
- exports.useBaseCreditPoolReceivableContract = useBaseCreditPoolReceivableContract;
20
- //# sourceMappingURL=useBaseCreditPoolReceivableContract.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useBaseCreditPoolReceivableContract.js","sourceRoot":"","sources":["../../../src/hooks/useBaseCreditPoolReceivableContract.ts"],"names":[],"mappings":";;;AACA,iDAK6B;AAE7B,+CAA2C;AAE3C;;;;;;;GAOG;AACH,SAAgB,mCAAmC,CACjD,gBAA2D,EAC3D,OAAe;;IAEf,MAAM,wBAAwB,GAC5B,MAAA,kCAAyB,CAAC,OAAO,CAAC,0CAChC,+BAAsB,CAAC,wBAAwB,CAChD,CAAA;IAEH,OAAO,IAAA,yBAAW,EAChB,wBAAwB,EACxB,wCAA+B,EAC/B,gBAAgB,CACjB,CAAA;AACH,CAAC;AAdD,kFAcC"}
@@ -1,13 +0,0 @@
1
- import { Contract } from '@ethersproject/contracts';
2
- import { ethers } from 'ethers';
3
- /**
4
- * Custom hook for creating an ethers instance of a smart contract.
5
- *
6
- * @template T - The type of the contract.
7
- * @param {string | null | undefined} address - The address of the smart contract instance.
8
- * @param {any} ABI - The ABI of the smart contract.
9
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to sign transactions or retrieve blockchain data.
10
- * Note that this signerOrProvider must be connected to the same network as the smart contract in question.
11
- * @returns {T | null} An instance of the smart contract, or null if an error occurs.
12
- */
13
- export declare function useContract<T extends Contract = Contract>(address: string | null | undefined, ABI: any, signerOrProvider: ethers.providers.Provider | ethers.Signer): T | null;
@@ -1,31 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useContract = void 0;
4
- const react_1 = require("react");
5
- const web3_1 = require("../utils/web3");
6
- /**
7
- * Custom hook for creating an ethers instance of a smart contract.
8
- *
9
- * @template T - The type of the contract.
10
- * @param {string | null | undefined} address - The address of the smart contract instance.
11
- * @param {any} ABI - The ABI of the smart contract.
12
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to sign transactions or retrieve blockchain data.
13
- * Note that this signerOrProvider must be connected to the same network as the smart contract in question.
14
- * @returns {T | null} An instance of the smart contract, or null if an error occurs.
15
- */
16
- function useContract(address,
17
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
18
- ABI, signerOrProvider) {
19
- return (0, react_1.useMemo)(() => {
20
- if (!address || !ABI || !signerOrProvider)
21
- return null;
22
- try {
23
- return (0, web3_1.getContract)(address, ABI, signerOrProvider);
24
- }
25
- catch (error) {
26
- return null;
27
- }
28
- }, [address, ABI, signerOrProvider]);
29
- }
30
- exports.useContract = useContract;
31
- //# sourceMappingURL=useContract.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useContract.js","sourceRoot":"","sources":["../../../src/hooks/useContract.ts"],"names":[],"mappings":";;;AACA,iCAA+B;AAG/B,wCAA2C;AAE3C;;;;;;;;;GASG;AACH,SAAgB,WAAW,CACzB,OAAkC;AAClC,8DAA8D;AAC9D,GAAQ,EACR,gBAA2D;IAE3D,OAAO,IAAA,eAAO,EAAC,GAAG,EAAE;QAClB,IAAI,CAAC,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,gBAAgB;YAAE,OAAO,IAAI,CAAA;QACtD,IAAI;YACF,OAAO,IAAA,kBAAW,EAAC,OAAO,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAA;SACnD;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,IAAI,CAAA;SACZ;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAM,CAAA;AAC3C,CAAC;AAdD,kCAcC"}
@@ -1,12 +0,0 @@
1
- import { Contract, ethers } from 'ethers';
2
- import { POOL_NAME } from '@huma-finance/shared';
3
- /**
4
- * A react hook that returns an ethers contract instance for the ERC20TransferableReceivable contract
5
- * associated with the given pool name on the current chain.
6
- *
7
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
8
- * @param {number} chainId The chain id where the contract instance exists
9
- * @param {POOL_NAME} poolName The name of the pool to get the contract for.
10
- * @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
11
- */
12
- export declare function useERC20TransferableReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME): Contract | null;
@@ -1,21 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useERC20TransferableReceivableContract = void 0;
4
- const shared_1 = require("@huma-finance/shared");
5
- const useContract_1 = require("./useContract");
6
- /**
7
- * A react hook that returns an ethers contract instance for the ERC20TransferableReceivable contract
8
- * associated with the given pool name on the current chain.
9
- *
10
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
11
- * @param {number} chainId The chain id where the contract instance exists
12
- * @param {POOL_NAME} poolName The name of the pool to get the contract for.
13
- * @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
14
- */
15
- function useERC20TransferableReceivableContract(signerOrProvider, chainId, poolName) {
16
- var _a, _b, _c;
17
- const TransferableReceivableAddress = (_c = (_b = (_a = shared_1.PoolContractMap[chainId]) === null || _a === void 0 ? void 0 : _a[shared_1.POOL_TYPE.Invoice]) === null || _b === void 0 ? void 0 : _b[poolName]) === null || _c === void 0 ? void 0 : _c.assetAddress;
18
- return (0, useContract_1.useContract)(TransferableReceivableAddress, shared_1.ERC20_TRANSFERABLE_RECEIVABLE_ABI, signerOrProvider);
19
- }
20
- exports.useERC20TransferableReceivableContract = useERC20TransferableReceivableContract;
21
- //# sourceMappingURL=useERC20TransferableReceivableContract.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useERC20TransferableReceivableContract.js","sourceRoot":"","sources":["../../../src/hooks/useERC20TransferableReceivableContract.ts"],"names":[],"mappings":";;;AACA,iDAM6B;AAE7B,+CAA2C;AAE3C;;;;;;;;GAQG;AACH,SAAgB,sCAAsC,CACpD,gBAA2D,EAC3D,OAAe,EACf,QAAmB;;IAEnB,MAAM,6BAA6B,GACjC,MAAA,MAAA,MAAA,wBAAe,CAAC,OAAO,CAAC,0CAAG,kBAAS,CAAC,OAAO,CAAC,0CAAG,QAAQ,CAAC,0CAAE,YAAY,CAAA;IAEzE,OAAO,IAAA,yBAAW,EAChB,6BAA6B,EAC7B,0CAAiC,EACjC,gBAAgB,CACjB,CAAA;AACH,CAAC;AAbD,wFAaC"}
@@ -1,60 +0,0 @@
1
- import { BigNumber } from '@ethersproject/bignumber';
2
- import { Contract, ethers } from 'ethers';
3
- import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
4
- /**
5
- * A react hook that returns a contract instance of a specific pool using an ethers provider or signer
6
- *
7
- * @namespace usePoolContract
8
- * @template T - The type of the contract.
9
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - An ethers signer or provider instance.
10
- * @param {number} chainId The chain id where the contract instance exists
11
- * @param {POOL_NAME} poolName - The name of the pool.
12
- * @param {POOL_TYPE} poolType - The type of the pool.
13
- * @returns {T} A contract instance of the specific pool.
14
- */
15
- export declare function usePoolContract<T extends Contract>(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): T | null;
16
- /**
17
- * CreditRecordDetails type object representing the details of a credit line.
18
- *
19
- * @memberof usePoolContract
20
- * @typedef {Object} CreditRecordDetails
21
- * @property {number} aprInBps - The APR (annual percentage rate) in basis points.
22
- * @property {BigNumber} correction - adjustment of interest over or under-counted because of drawdown
23
- * or principal payment in the middle of a billing period
24
- * @property {BigNumber} creditLimit - The credit limit in the pools base currency.
25
- * @property {BigNumber} defaultAmount - The amount of the default, if any.
26
- * @property {BigNumber} dueDate - The due date of the next payment.
27
- * @property {BigNumber} feesAndInterestDue - The fees and interest due.
28
- * @property {number} intervalInDays - The interval in days between payment periods.
29
- * @property {number} missedPeriods - The number of missed periods.
30
- * @property {number} remainingPeriods - The number of remaining periods before this credit line is considered paid off.
31
- * @property {number} state - The state of the factorization. Please see the CreditState in huma-contracts for more details.
32
- * @property {BigNumber} totalDue - The total due amount of this credit line.
33
- * @property {BigNumber} unbilledPrincipal - The unbilled principal of the next payment.
34
- */
35
- export type CreditRecordDetails = {
36
- aprInBps: number;
37
- correction: BigNumber;
38
- creditLimit: BigNumber;
39
- defaultAmount: BigNumber;
40
- dueDate: BigNumber;
41
- feesAndInterestDue: BigNumber;
42
- intervalInDays: number;
43
- missedPeriods: number;
44
- remainingPeriods: number;
45
- state: number;
46
- totalDue: BigNumber;
47
- unbilledPrincipal: BigNumber;
48
- };
49
- /**
50
- * A react hook that returns the credit record details for a user in a given pool, as well as a function to refresh the data.
51
- *
52
- * @namespace usePoolContract
53
- * @param {string} userAddress - The address of the user to get the credit record details for.
54
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider object to use for the contract.
55
- * @param {number} chainId The chain id where the contract instance exists
56
- * @param {POOL_NAME} poolName - The name of the pool to get the credit record details for.
57
- * @param {POOL_TYPE} poolType - The type of the pool.
58
- * @returns {Array<CreditRecordDetails | undefined, function():void>} An array containing the credit record details and a function to refresh the data.
59
- */
60
- export declare function useCreditRecordDetails(userAddress: string, signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): [CreditRecordDetails | undefined, () => void];
@@ -1,54 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useCreditRecordDetails = exports.usePoolContract = void 0;
4
- const react_1 = require("react");
5
- const useContract_1 = require("./useContract");
6
- const poolInfo_1 = require("../utils/poolInfo");
7
- /**
8
- * A react hook that returns a contract instance of a specific pool using an ethers provider or signer
9
- *
10
- * @namespace usePoolContract
11
- * @template T - The type of the contract.
12
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - An ethers signer or provider instance.
13
- * @param {number} chainId The chain id where the contract instance exists
14
- * @param {POOL_NAME} poolName - The name of the pool.
15
- * @param {POOL_TYPE} poolType - The type of the pool.
16
- * @returns {T} A contract instance of the specific pool.
17
- */
18
- function usePoolContract(signerOrProvider, chainId, poolName, poolType) {
19
- const poolInfo = (0, poolInfo_1.getPoolInfo)(chainId, poolName, poolType);
20
- return (0, useContract_1.useContract)(poolInfo === null || poolInfo === void 0 ? void 0 : poolInfo.pool, poolInfo === null || poolInfo === void 0 ? void 0 : poolInfo.poolAbi, signerOrProvider);
21
- }
22
- exports.usePoolContract = usePoolContract;
23
- /**
24
- * A react hook that returns the credit record details for a user in a given pool, as well as a function to refresh the data.
25
- *
26
- * @namespace usePoolContract
27
- * @param {string} userAddress - The address of the user to get the credit record details for.
28
- * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider object to use for the contract.
29
- * @param {number} chainId The chain id where the contract instance exists
30
- * @param {POOL_NAME} poolName - The name of the pool to get the credit record details for.
31
- * @param {POOL_TYPE} poolType - The type of the pool.
32
- * @returns {Array<CreditRecordDetails | undefined, function():void>} An array containing the credit record details and a function to refresh the data.
33
- */
34
- function useCreditRecordDetails(userAddress, signerOrProvider, chainId, poolName, poolType) {
35
- const poolContract = usePoolContract(signerOrProvider, chainId, poolName, poolType);
36
- const [creditRecordDetails, setCreditRecordDetails] = (0, react_1.useState)();
37
- const [refreshCount, setRefreshCount] = (0, react_1.useState)(0);
38
- (0, react_1.useEffect)(() => {
39
- const fetchData = async () => {
40
- if (poolContract && userAddress) {
41
- const creditRecordMapping = await poolContract.creditRecordMapping(userAddress);
42
- const creditRecordStaticMapping = await poolContract.creditRecordStaticMapping(userAddress);
43
- setCreditRecordDetails(Object.assign(Object.assign({}, creditRecordMapping), creditRecordStaticMapping));
44
- }
45
- };
46
- fetchData();
47
- }, [userAddress, poolContract, refreshCount]);
48
- const refresh = (0, react_1.useCallback)(() => {
49
- setRefreshCount((pre) => pre + 1);
50
- }, []);
51
- return [creditRecordDetails, refresh];
52
- }
53
- exports.useCreditRecordDetails = useCreditRecordDetails;
54
- //# sourceMappingURL=usePoolContract.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"usePoolContract.js","sourceRoot":"","sources":["../../../src/hooks/usePoolContract.ts"],"names":[],"mappings":";;;AAEA,iCAAwD;AAGxD,+CAA2C;AAC3C,gDAA+C;AAE/C;;;;;;;;;;GAUG;AACH,SAAgB,eAAe,CAC7B,gBAA2D,EAC3D,OAAe,EACf,QAAmB,EACnB,QAAmB;IAEnB,MAAM,QAAQ,GAAG,IAAA,sBAAW,EAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IACzD,OAAO,IAAA,yBAAW,EAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,EAAE,gBAAgB,CAAC,CAAA;AAC5E,CAAC;AARD,0CAQC;AAoCD;;;;;;;;;;GAUG;AACH,SAAgB,sBAAsB,CACpC,WAAmB,EACnB,gBAA2D,EAC3D,OAAe,EACf,QAAmB,EACnB,QAAmB;IAEnB,MAAM,YAAY,GAAG,eAAe,CAClC,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,QAAQ,CACT,CAAA;IACD,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GACjD,IAAA,gBAAQ,GAAuB,CAAA;IACjC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAA;IAEnD,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;YAC3B,IAAI,YAAY,IAAI,WAAW,EAAE;gBAC/B,MAAM,mBAAmB,GAAG,MAAM,YAAY,CAAC,mBAAmB,CAChE,WAAW,CACZ,CAAA;gBACD,MAAM,yBAAyB,GAC7B,MAAM,YAAY,CAAC,yBAAyB,CAAC,WAAW,CAAC,CAAA;gBAC3D,sBAAsB,iCACjB,mBAAmB,GACnB,yBAAyB,EAC5B,CAAA;aACH;QACH,CAAC,CAAA;QACD,SAAS,EAAE,CAAA;IACb,CAAC,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAA;IAE7C,MAAM,OAAO,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAC/B,eAAe,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;IACnC,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAA;AACvC,CAAC;AAvCD,wDAuCC"}
@@ -1,10 +0,0 @@
1
- import { POOL_NAME, ReceivableFactoringPool } from '@00labs/huma-shared';
2
- import { ethers } from 'ethers';
3
- /**
4
- * A react hook that returns the instance of the ReceivableFactoringPool contract for a given signer or provider and pool name.
5
- *
6
- * @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The signer or provider object to use for the contract.
7
- * @param {POOL_NAME} poolName - The name of the pool to get the contract for. Check the type for more details.
8
- * @returns {ReceivableFactoringPool} An ethers instance of the ReceivableFactoringPool contract.
9
- */
10
- export declare function useReceivableFactoringPoolContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME): ReceivableFactoringPool | null;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useReceivableFactoringPoolContract = void 0;
4
- const huma_shared_1 = require("@00labs/huma-shared");
5
- const usePoolContract_1 = require("./usePoolContract");
6
- /**
7
- * A react hook that returns the instance of the ReceivableFactoringPool contract for a given signer or provider and pool name.
8
- *
9
- * @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The signer or provider object to use for the contract.
10
- * @param {POOL_NAME} poolName - The name of the pool to get the contract for. Check the type for more details.
11
- * @returns {ReceivableFactoringPool} An ethers instance of the ReceivableFactoringPool contract.
12
- */
13
- function useReceivableFactoringPoolContract(signerOrProvider, chainId, poolName) {
14
- return (0, usePoolContract_1.usePoolContract)(signerOrProvider, chainId, poolName, huma_shared_1.POOL_TYPE.Invoice);
15
- }
16
- exports.useReceivableFactoringPoolContract = useReceivableFactoringPoolContract;
17
- //# sourceMappingURL=useReceivableFactoringPoolContract.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useReceivableFactoringPoolContract.js","sourceRoot":"","sources":["../../../src/hooks/useReceivableFactoringPoolContract.ts"],"names":[],"mappings":";;;AAAA,qDAI4B;AAG5B,uDAAmD;AAEnD;;;;;;GAMG;AACH,SAAgB,kCAAkC,CAChD,gBAA2D,EAC3D,OAAe,EACf,QAAmB;IAEnB,OAAO,IAAA,iCAAe,EACpB,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,uBAAS,CAAC,OAAO,CAClB,CAAA;AACH,CAAC;AAXD,gFAWC"}
@@ -1,4 +0,0 @@
1
- export * from './helpers';
2
- export * from './hooks';
3
- export * from './services';
4
- export * from './utils';
package/dist/cjs/index.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./helpers"), exports);
5
- tslib_1.__exportStar(require("./hooks"), exports);
6
- tslib_1.__exportStar(require("./services"), exports);
7
- tslib_1.__exportStar(require("./utils"), exports);
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB;AACzB,kDAAuB;AACvB,qDAA0B;AAC1B,kDAAuB"}