@huma-finance/sdk 0.0.31 → 0.0.32

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 (119) hide show
  1. package/API.md +1041 -977
  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/BaseCreditPoolReceivableContractHelper.d.ts +10 -0
  9. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js +22 -0
  10. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js.map +1 -0
  11. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -10
  12. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js +21 -21
  13. package/dist/cjs/helpers/PoolContractHelper.d.ts +119 -119
  14. package/dist/cjs/helpers/PoolContractHelper.js +142 -142
  15. package/dist/cjs/helpers/RealWorldReceivableContractHelper.d.ts +10 -10
  16. package/dist/cjs/helpers/RealWorldReceivableContractHelper.js +21 -21
  17. package/dist/cjs/helpers/index.d.ts +3 -3
  18. package/dist/cjs/helpers/index.js +6 -6
  19. package/dist/cjs/hooks/index.d.ts +4 -4
  20. package/dist/cjs/hooks/index.js +7 -7
  21. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.d.ts +10 -0
  22. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js +20 -0
  23. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js.map +1 -0
  24. package/dist/cjs/hooks/useContract.d.ts +13 -13
  25. package/dist/cjs/hooks/useContract.js +30 -30
  26. package/dist/cjs/hooks/useERC20TransferableReceivableContract.d.ts +12 -12
  27. package/dist/cjs/hooks/useERC20TransferableReceivableContract.js +20 -20
  28. package/dist/cjs/hooks/usePoolContract.d.ts +60 -60
  29. package/dist/cjs/hooks/usePoolContract.js +53 -53
  30. package/dist/cjs/hooks/useRealWorldReceivableContract.d.ts +10 -10
  31. package/dist/cjs/hooks/useRealWorldReceivableContract.js +19 -19
  32. package/dist/cjs/hooks/useReceivableFactoringPoolContract.d.ts +10 -0
  33. package/dist/cjs/hooks/useReceivableFactoringPoolContract.js +17 -0
  34. package/dist/cjs/hooks/useReceivableFactoringPoolContract.js.map +1 -0
  35. package/dist/cjs/index.d.ts +4 -4
  36. package/dist/cjs/index.js +7 -7
  37. package/dist/cjs/services/ARWeaveService.d.ts +106 -106
  38. package/dist/cjs/services/ARWeaveService.js +190 -190
  39. package/dist/cjs/services/ARWeaveService.js.map +1 -1
  40. package/dist/cjs/services/EAService.d.ts +20 -20
  41. package/dist/cjs/services/EAService.js +33 -33
  42. package/dist/cjs/services/ReceivableService.d.ts +105 -105
  43. package/dist/cjs/services/ReceivableService.js +310 -253
  44. package/dist/cjs/services/ReceivableService.js.map +1 -1
  45. package/dist/cjs/services/SubgraphService.d.ts +53 -53
  46. package/dist/cjs/services/SubgraphService.js +93 -93
  47. package/dist/cjs/services/index.d.ts +4 -4
  48. package/dist/cjs/services/index.js +7 -7
  49. package/dist/cjs/utils/chain.d.ts +15 -15
  50. package/dist/cjs/utils/chain.js +37 -37
  51. package/dist/cjs/utils/index.d.ts +4 -4
  52. package/dist/cjs/utils/index.js +7 -7
  53. package/dist/cjs/utils/maticGasStation.d.ts +3 -3
  54. package/dist/cjs/utils/maticGasStation.js +38 -38
  55. package/dist/cjs/utils/poolInfo.d.ts +8 -8
  56. package/dist/cjs/utils/poolInfo.js +12 -12
  57. package/dist/cjs/utils/web3.d.ts +5 -5
  58. package/dist/cjs/utils/web3.js +33 -33
  59. package/dist/graphql/generatedTypes.d.ts +40 -40
  60. package/dist/graphql/generatedTypes.js +4 -4
  61. package/dist/graphql/index.d.ts +1 -1
  62. package/dist/graphql/index.js +1 -1
  63. package/dist/helpers/BaseCreditPoolReceivableContractHelper.d.ts +10 -0
  64. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js +18 -0
  65. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js.map +1 -0
  66. package/dist/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -10
  67. package/dist/helpers/ERC20TransferableReceivableContractHelper.js +17 -17
  68. package/dist/helpers/PoolContractHelper.d.ts +119 -119
  69. package/dist/helpers/PoolContractHelper.js +133 -133
  70. package/dist/helpers/RealWorldReceivableContractHelper.d.ts +10 -10
  71. package/dist/helpers/RealWorldReceivableContractHelper.js +17 -17
  72. package/dist/helpers/index.d.ts +3 -3
  73. package/dist/helpers/index.js +3 -3
  74. package/dist/hooks/index.d.ts +4 -4
  75. package/dist/hooks/index.js +4 -4
  76. package/dist/hooks/useBaseCreditPoolReceivableContract.d.ts +10 -0
  77. package/dist/hooks/useBaseCreditPoolReceivableContract.js +16 -0
  78. package/dist/hooks/useBaseCreditPoolReceivableContract.js.map +1 -0
  79. package/dist/hooks/useContract.d.ts +13 -13
  80. package/dist/hooks/useContract.js +26 -26
  81. package/dist/hooks/useERC20TransferableReceivableContract.d.ts +12 -12
  82. package/dist/hooks/useERC20TransferableReceivableContract.js +16 -16
  83. package/dist/hooks/usePool.d.ts +0 -0
  84. package/dist/hooks/usePool.js +2 -0
  85. package/dist/hooks/usePool.js.map +1 -0
  86. package/dist/hooks/usePoolContract.d.ts +60 -60
  87. package/dist/hooks/usePoolContract.js +48 -48
  88. package/dist/hooks/useRealWorldReceivableContract.d.ts +10 -10
  89. package/dist/hooks/useRealWorldReceivableContract.js +15 -15
  90. package/dist/hooks/useReceivableFactoringPoolContract.d.ts +10 -0
  91. package/dist/hooks/useReceivableFactoringPoolContract.js +13 -0
  92. package/dist/hooks/useReceivableFactoringPoolContract.js.map +1 -0
  93. package/dist/index.d.ts +4 -4
  94. package/dist/index.js +4 -4
  95. package/dist/services/ARWeaveService.d.ts +106 -106
  96. package/dist/services/ARWeaveService.js +185 -185
  97. package/dist/services/ARWeaveService.js.map +1 -1
  98. package/dist/services/EAService.d.ts +20 -20
  99. package/dist/services/EAService.js +30 -30
  100. package/dist/services/ReceivableService.d.ts +105 -105
  101. package/dist/services/ReceivableService.js +306 -249
  102. package/dist/services/ReceivableService.js.map +1 -1
  103. package/dist/services/SubgraphService.d.ts +53 -53
  104. package/dist/services/SubgraphService.js +90 -90
  105. package/dist/services/index.d.ts +4 -4
  106. package/dist/services/index.js +4 -4
  107. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  108. package/dist/utils/chain.d.ts +15 -15
  109. package/dist/utils/chain.js +31 -31
  110. package/dist/utils/index.d.ts +4 -4
  111. package/dist/utils/index.js +4 -4
  112. package/dist/utils/maticGasStation.d.ts +3 -3
  113. package/dist/utils/maticGasStation.js +33 -33
  114. package/dist/utils/poolInfo.d.ts +8 -8
  115. package/dist/utils/poolInfo.js +8 -8
  116. package/dist/utils/web3.d.ts +5 -5
  117. package/dist/utils/web3.js +27 -27
  118. package/getting-started.md +190 -190
  119. package/package.json +3 -3
@@ -1,60 +1,60 @@
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
- * @memberof 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
+ 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
+ * @memberof 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 +1,54 @@
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
- * @memberof 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;
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
+ * @memberof 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
54
  //# sourceMappingURL=usePoolContract.js.map
@@ -1,10 +1,10 @@
1
- import { Contract, ethers } from 'ethers';
2
- /**
3
- * A react hook that returns an ethers contract instance for the RealWorldReceivable 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 RealWorldReceivable contract or null if it could not be found.
9
- */
10
- export declare function useRealWorldReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
1
+ import { Contract, ethers } from 'ethers';
2
+ /**
3
+ * A react hook that returns an ethers contract instance for the RealWorldReceivable 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 RealWorldReceivable contract or null if it could not be found.
9
+ */
10
+ export declare function useRealWorldReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
@@ -1,20 +1,20 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useRealWorldReceivableContract = 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 RealWorldReceivable 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 RealWorldReceivable contract or null if it could not be found.
13
- */
14
- function useRealWorldReceivableContract(signerOrProvider, chainId) {
15
- var _a;
16
- const realWorldReceivable = (_a = shared_1.SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[shared_1.SupplementaryContracts.RealWorldReceivable];
17
- return (0, useContract_1.useContract)(realWorldReceivable, shared_1.REAL_WORLD_RECEIVABLE_ABI, signerOrProvider);
18
- }
19
- exports.useRealWorldReceivableContract = useRealWorldReceivableContract;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useRealWorldReceivableContract = 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 RealWorldReceivable 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 RealWorldReceivable contract or null if it could not be found.
13
+ */
14
+ function useRealWorldReceivableContract(signerOrProvider, chainId) {
15
+ var _a;
16
+ const realWorldReceivable = (_a = shared_1.SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[shared_1.SupplementaryContracts.RealWorldReceivable];
17
+ return (0, useContract_1.useContract)(realWorldReceivable, shared_1.REAL_WORLD_RECEIVABLE_ABI, signerOrProvider);
18
+ }
19
+ exports.useRealWorldReceivableContract = useRealWorldReceivableContract;
20
20
  //# sourceMappingURL=useRealWorldReceivableContract.js.map
@@ -0,0 +1,10 @@
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;
@@ -0,0 +1,17 @@
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
@@ -0,0 +1 @@
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 +1,4 @@
1
- export * from './helpers';
2
- export * from './hooks';
3
- export * from './services';
4
- export * from './utils';
1
+ export * from './helpers';
2
+ export * from './hooks';
3
+ export * from './services';
4
+ export * from './utils';
package/dist/cjs/index.js CHANGED
@@ -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("./helpers"), exports);
5
- tslib_1.__exportStar(require("./hooks"), exports);
6
- tslib_1.__exportStar(require("./services"), exports);
7
- tslib_1.__exportStar(require("./utils"), exports);
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
8
  //# sourceMappingURL=index.js.map
@@ -1,106 +1,106 @@
1
- import type { FundResponse, UploadResponse } from '@bundlr-network/client/build/cjs/common/types';
2
- import { Web3Provider } from '@ethersproject/providers';
3
- /**
4
- * The configuration for Bundlr network instances
5
- *
6
- * @typedef {Object} BundlrConfig
7
- * @memberof ArweaveService
8
- * @property {string} nodeUrl - The Bundlr node URL to use.
9
- * @property {string} currency - The currency to pay for uploads with.
10
- * Please see https://docs.bundlr.network/sdk/using-other-currencies for all the supported currencies
11
- * @property {string} [providerUrl] - The provider URL, required for devnets.
12
- */
13
- export type BundlrConfig = {
14
- nodeUrl: string;
15
- currency: string;
16
- providerUrl?: string;
17
- };
18
- /**
19
- * Get the configuration for Bundlr network given a chain ID
20
- *
21
- * @function
22
- * @memberof ArweaveService
23
- * @param {number} chainId - The chain ID.
24
- * @returns {BundlrConfig} - The configuration for the Bundlr network.
25
- */
26
- export declare function getBundlrNetworkConfig(chainId: number): BundlrConfig;
27
- /**
28
- * Get a Bundlr instance for a specific network
29
- *
30
- * @async
31
- * @function
32
- * @memberof ArweaveService
33
- * @param {BundlrConfig} config - The configuration for the Bundlr network.
34
- * @param {string} signer - The private key of the wallet to use Bundlr with.
35
- * @returns The Bundlr instance
36
- */
37
- declare function getBundlrInstance(config: BundlrConfig, signer: string): Promise<import("@bundlr-network/client/build/cjs/node/bundlr").default>;
38
- /**
39
- * Prefund the Bundlr network with the specified amount. Required if not lazy funding.
40
- * Important note: The amount is denominated in the base unit of currency for that network.
41
- * If you want to upload 5 Matic to the Bundlr node, pass in an amount of 5.
42
- *
43
- * @async
44
- * @function
45
- * @memberof ArweaveService
46
- * @param {BundlrConfig} config - The configuration for the Bundlr network.
47
- * @param {string} signer - The private key of the wallet to send funds from.
48
- * @param {number} amount - The amount to fund, denoted in whatever currency specified by the config (e.g. MATIC, ETH)
49
- * @returns {Promise<FundResponse>} - The fund response.
50
- */
51
- declare function prefundBundlr(config: BundlrConfig, signer: string, amount: number): Promise<FundResponse>;
52
- /**
53
- * Store data on ARWeave using the Bundlr Network.
54
- *
55
- * @async
56
- * @function
57
- * @memberof ArweaveService
58
- * @param {BundlrConfig} config - Configuration object for the Bundlr instance.
59
- * @param {Web3Provider | string} signerOrPrivateKey - Wallet object used for interacting with the Bundlr instance.
60
- * If calling from a browser, this should be a `Web3Provider` instance. If calling from a Node.js
61
- * environment, this should be a private key string.
62
- * @param {JSON} data - The data to store in the Bundlr instance.
63
- * @param {Array<{ name: string, value: string }>} tags - Array of tag objects with `name` and `value` properties.
64
- * @param {boolean} [lazyFund=true] - Optional flag to fund the Bundlr instance lazily. If set to `false`, the
65
- * Bundlr node should already be funded or else uploads will fail.
66
- * @returns {Promise<UploadResponse>} Promise resolving with the upload response.
67
- */
68
- declare function storeData(config: BundlrConfig, signerOrPrivateKey: Web3Provider | string, data: JSON, tags: {
69
- name: string;
70
- value: string;
71
- }[], lazyFund?: boolean): Promise<UploadResponse>;
72
- /**
73
- * Helper method to query the Arweave network for receivables metadata previously uploaded.
74
- *
75
- * @async
76
- * @function
77
- * @memberof ArweaveService
78
- * @param {number} chainId - The chain ID.
79
- * @param {string} sender - The sender tag to query.
80
- * @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
81
- * @returns {Promise<any>} Promise resolving with the queried data.
82
- */
83
- declare function queryForMetadata(chainId: number, sender: string, referenceId: string): Promise<string | null>;
84
- /**
85
- * Helper method to fetch data from an ARWeave URL.
86
- *
87
- * @async
88
- * @function
89
- * @memberof ArweaveService
90
- * @param {string} url - The ARWeave metadata URL to query.
91
- * @returns {Promise<JSON>} Promise resolving with the queried data.
92
- */
93
- declare function fetchMetadataFromUrl(url: string): Promise<JSON | null>;
94
- /**
95
- * An object that contains functions to interact with Huma-related data stored on ARWeave
96
- * @namespace ARWeaveService
97
- */
98
- export declare const ARWeaveService: {
99
- queryForMetadata: typeof queryForMetadata;
100
- storeData: typeof storeData;
101
- prefundBundlr: typeof prefundBundlr;
102
- getBundlrNetworkConfig: typeof getBundlrNetworkConfig;
103
- getBundlrInstance: typeof getBundlrInstance;
104
- fetchMetadataFromUrl: typeof fetchMetadataFromUrl;
105
- };
106
- export {};
1
+ import type { FundResponse, UploadResponse } from '@bundlr-network/client/build/cjs/common/types';
2
+ import { Web3Provider } from '@ethersproject/providers';
3
+ /**
4
+ * The configuration for Bundlr network instances
5
+ *
6
+ * @typedef {Object} BundlrConfig
7
+ * @memberof ArweaveService
8
+ * @property {string} nodeUrl - The Bundlr node URL to use.
9
+ * @property {string} currency - The currency to pay for uploads with.
10
+ * Please see https://docs.bundlr.network/sdk/using-other-currencies for all the supported currencies
11
+ * @property {string} [providerUrl] - The provider URL, required for devnets.
12
+ */
13
+ export type BundlrConfig = {
14
+ nodeUrl: string;
15
+ currency: string;
16
+ providerUrl?: string;
17
+ };
18
+ /**
19
+ * Get the configuration for Bundlr network given a chain ID
20
+ *
21
+ * @function
22
+ * @memberof ArweaveService
23
+ * @param {number} chainId - The chain ID.
24
+ * @returns {BundlrConfig} - The configuration for the Bundlr network.
25
+ */
26
+ export declare function getBundlrNetworkConfig(chainId: number): BundlrConfig;
27
+ /**
28
+ * Get a Bundlr instance for a specific network
29
+ *
30
+ * @async
31
+ * @function
32
+ * @memberof ArweaveService
33
+ * @param {BundlrConfig} config - The configuration for the Bundlr network.
34
+ * @param {string} signer - The private key of the wallet to use Bundlr with.
35
+ * @returns The Bundlr instance
36
+ */
37
+ declare function getBundlrInstance(config: BundlrConfig, signer: string): Promise<import("@bundlr-network/client/build/cjs/node/bundlr").default>;
38
+ /**
39
+ * Prefund the Bundlr network with the specified amount. Required if not lazy funding.
40
+ * Important note: The amount is denominated in the base unit of currency for that network.
41
+ * If you want to upload 5 Matic to the Bundlr node, pass in an amount of 5.
42
+ *
43
+ * @async
44
+ * @function
45
+ * @memberof ArweaveService
46
+ * @param {BundlrConfig} config - The configuration for the Bundlr network.
47
+ * @param {string} signer - The private key of the wallet to send funds from.
48
+ * @param {number} amount - The amount to fund, denoted in whatever currency specified by the config (e.g. MATIC, ETH)
49
+ * @returns {Promise<FundResponse>} - The fund response.
50
+ */
51
+ declare function prefundBundlr(config: BundlrConfig, signer: string, amount: number): Promise<FundResponse>;
52
+ /**
53
+ * Store data on ARWeave using the Bundlr Network.
54
+ *
55
+ * @async
56
+ * @function
57
+ * @memberof ArweaveService
58
+ * @param {BundlrConfig} config - Configuration object for the Bundlr instance.
59
+ * @param {Web3Provider | string} signerOrPrivateKey - Wallet object used for interacting with the Bundlr instance.
60
+ * If calling from a browser, this should be a `Web3Provider` instance. If calling from a Node.js
61
+ * environment, this should be a private key string.
62
+ * @param {Record<string, unknown>} data - The data to store in the Bundlr instance.
63
+ * @param {Array<{ name: string, value: string }>} tags - Array of tag objects with `name` and `value` properties.
64
+ * @param {boolean} [lazyFund=true] - Optional flag to fund the Bundlr instance lazily. If set to `false`, the
65
+ * Bundlr node should already be funded or else uploads will fail.
66
+ * @returns {Promise<UploadResponse>} Promise resolving with the upload response.
67
+ */
68
+ declare function storeData(config: BundlrConfig, signerOrPrivateKey: Web3Provider | string, data: Record<string, unknown>, tags: {
69
+ name: string;
70
+ value: string;
71
+ }[], lazyFund?: boolean): Promise<UploadResponse>;
72
+ /**
73
+ * Helper method to query the Arweave network for receivables metadata previously uploaded.
74
+ *
75
+ * @async
76
+ * @function
77
+ * @memberof ArweaveService
78
+ * @param {number} chainId - The chain ID.
79
+ * @param {string} sender - The sender tag to query.
80
+ * @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
81
+ * @returns {Promise<any>} Promise resolving with the queried data.
82
+ */
83
+ declare function queryForMetadata(chainId: number, sender: string, referenceId: string): Promise<string | null>;
84
+ /**
85
+ * Helper method to fetch data from an ARWeave URL.
86
+ *
87
+ * @async
88
+ * @function
89
+ * @memberof ArweaveService
90
+ * @param {string} url - The ARWeave metadata URL to query.
91
+ * @returns {Promise<JSON>} Promise resolving with the queried data.
92
+ */
93
+ declare function fetchMetadataFromUrl(url: string): Promise<JSON | null>;
94
+ /**
95
+ * An object that contains functions to interact with Huma-related data stored on ARWeave
96
+ * @namespace ARWeaveService
97
+ */
98
+ export declare const ARWeaveService: {
99
+ queryForMetadata: typeof queryForMetadata;
100
+ storeData: typeof storeData;
101
+ prefundBundlr: typeof prefundBundlr;
102
+ getBundlrNetworkConfig: typeof getBundlrNetworkConfig;
103
+ getBundlrInstance: typeof getBundlrInstance;
104
+ fetchMetadataFromUrl: typeof fetchMetadataFromUrl;
105
+ };
106
+ export {};