@huma-finance/sdk 0.0.10 → 0.0.12

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 (153) hide show
  1. package/API.md +432 -0
  2. package/LICENSE +660 -660
  3. package/README.md +35 -31
  4. package/dist/cjs/graphql/generatedTypes.d.ts +40 -0
  5. package/dist/cjs/graphql/generatedTypes.js +9 -0
  6. package/dist/cjs/graphql/generatedTypes.js.map +1 -0
  7. package/dist/cjs/graphql/index.d.ts +1 -0
  8. package/dist/cjs/graphql/index.js +5 -0
  9. package/dist/cjs/graphql/index.js.map +1 -0
  10. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.d.ts +10 -0
  11. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js +22 -0
  12. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js.map +1 -0
  13. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -0
  14. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js +22 -0
  15. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js.map +1 -0
  16. package/dist/cjs/helpers/PoolContractHelper.d.ts +15 -0
  17. package/dist/cjs/helpers/PoolContractHelper.js +39 -0
  18. package/dist/cjs/helpers/PoolContractHelper.js.map +1 -0
  19. package/dist/cjs/helpers/RealWorldReceivableContractHelper.d.ts +10 -0
  20. package/dist/cjs/helpers/RealWorldReceivableContractHelper.js +22 -0
  21. package/dist/cjs/helpers/RealWorldReceivableContractHelper.js.map +1 -0
  22. package/dist/cjs/helpers/index.d.ts +3 -0
  23. package/dist/cjs/helpers/index.js +7 -0
  24. package/dist/cjs/helpers/index.js.map +1 -0
  25. package/dist/cjs/hooks/index.d.ts +4 -0
  26. package/dist/cjs/hooks/index.js +8 -0
  27. package/dist/cjs/hooks/index.js.map +1 -0
  28. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.d.ts +10 -0
  29. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js +20 -0
  30. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js.map +1 -0
  31. package/dist/cjs/hooks/useContract.d.ts +13 -0
  32. package/dist/cjs/hooks/useContract.js +31 -0
  33. package/dist/cjs/hooks/useContract.js.map +1 -0
  34. package/dist/cjs/hooks/useERC20TransferableReceivableContract.d.ts +12 -0
  35. package/dist/cjs/hooks/useERC20TransferableReceivableContract.js +21 -0
  36. package/dist/cjs/hooks/useERC20TransferableReceivableContract.js.map +1 -0
  37. package/dist/cjs/hooks/usePoolContract.d.ts +60 -0
  38. package/dist/cjs/hooks/usePoolContract.js +54 -0
  39. package/dist/cjs/hooks/usePoolContract.js.map +1 -0
  40. package/dist/cjs/hooks/useRealWorldReceivableContract.d.ts +10 -0
  41. package/dist/cjs/hooks/useRealWorldReceivableContract.js +20 -0
  42. package/dist/cjs/hooks/useRealWorldReceivableContract.js.map +1 -0
  43. package/dist/cjs/hooks/useReceivableFactoringPoolContract.d.ts +10 -0
  44. package/dist/cjs/hooks/useReceivableFactoringPoolContract.js +17 -0
  45. package/dist/cjs/hooks/useReceivableFactoringPoolContract.js.map +1 -0
  46. package/dist/cjs/index.d.ts +4 -0
  47. package/dist/cjs/index.js +8 -0
  48. package/dist/cjs/index.js.map +1 -0
  49. package/dist/cjs/services/ARWeaveService.d.ts +81 -0
  50. package/dist/cjs/services/ARWeaveService.js +141 -0
  51. package/dist/cjs/services/ARWeaveService.js.map +1 -0
  52. package/dist/cjs/services/EAService.d.ts +18 -0
  53. package/dist/cjs/services/EAService.js +13 -0
  54. package/dist/cjs/services/EAService.js.map +1 -0
  55. package/dist/cjs/services/ReceivableService.d.ts +87 -0
  56. package/dist/cjs/services/ReceivableService.js +189 -0
  57. package/dist/cjs/services/ReceivableService.js.map +1 -0
  58. package/dist/cjs/services/SubgraphService.d.ts +53 -0
  59. package/dist/cjs/services/SubgraphService.js +101 -0
  60. package/dist/cjs/services/SubgraphService.js.map +1 -0
  61. package/dist/cjs/services/index.d.ts +4 -0
  62. package/dist/cjs/services/index.js +8 -0
  63. package/dist/cjs/services/index.js.map +1 -0
  64. package/dist/cjs/utils/chain.d.ts +14 -0
  65. package/dist/cjs/utils/chain.js +34 -0
  66. package/dist/cjs/utils/chain.js.map +1 -0
  67. package/dist/cjs/utils/index.d.ts +3 -0
  68. package/dist/cjs/utils/index.js +7 -0
  69. package/dist/cjs/utils/index.js.map +1 -0
  70. package/dist/cjs/utils/poolInfo.d.ts +9 -0
  71. package/dist/cjs/utils/poolInfo.js +14 -0
  72. package/dist/cjs/utils/poolInfo.js.map +1 -0
  73. package/dist/cjs/utils/web3.d.ts +4 -0
  74. package/dist/cjs/utils/web3.js +29 -0
  75. package/dist/cjs/utils/web3.js.map +1 -0
  76. package/dist/graphql/generatedTypes.d.ts +40 -0
  77. package/dist/graphql/generatedTypes.js +5 -0
  78. package/dist/graphql/generatedTypes.js.map +1 -0
  79. package/dist/graphql/index.d.ts +1 -0
  80. package/dist/graphql/index.js +2 -0
  81. package/dist/graphql/index.js.map +1 -0
  82. package/dist/helpers/BaseCreditPoolReceivableContractHelper.d.ts +10 -0
  83. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js +18 -0
  84. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js.map +1 -0
  85. package/dist/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -0
  86. package/dist/helpers/ERC20TransferableReceivableContractHelper.js +18 -0
  87. package/dist/helpers/ERC20TransferableReceivableContractHelper.js.map +1 -0
  88. package/dist/helpers/PoolContractHelper.d.ts +15 -0
  89. package/dist/helpers/PoolContractHelper.js +33 -0
  90. package/dist/helpers/PoolContractHelper.js.map +1 -0
  91. package/dist/helpers/RealWorldReceivableContractHelper.d.ts +10 -0
  92. package/dist/helpers/RealWorldReceivableContractHelper.js +18 -0
  93. package/dist/helpers/RealWorldReceivableContractHelper.js.map +1 -0
  94. package/dist/helpers/index.d.ts +3 -0
  95. package/dist/helpers/index.js +4 -0
  96. package/dist/helpers/index.js.map +1 -0
  97. package/dist/hooks/index.d.ts +4 -0
  98. package/dist/hooks/index.js +5 -0
  99. package/dist/hooks/index.js.map +1 -0
  100. package/dist/hooks/useBaseCreditPoolReceivableContract.d.ts +10 -0
  101. package/dist/hooks/useBaseCreditPoolReceivableContract.js +16 -0
  102. package/dist/hooks/useBaseCreditPoolReceivableContract.js.map +1 -0
  103. package/dist/hooks/useContract.d.ts +13 -0
  104. package/dist/hooks/useContract.js +27 -0
  105. package/dist/hooks/useContract.js.map +1 -0
  106. package/dist/hooks/useERC20TransferableReceivableContract.d.ts +12 -0
  107. package/dist/hooks/useERC20TransferableReceivableContract.js +17 -0
  108. package/dist/hooks/useERC20TransferableReceivableContract.js.map +1 -0
  109. package/dist/hooks/usePool.d.ts +0 -0
  110. package/dist/hooks/usePool.js +2 -0
  111. package/dist/hooks/usePool.js.map +1 -0
  112. package/dist/hooks/usePoolContract.d.ts +60 -0
  113. package/dist/hooks/usePoolContract.js +49 -0
  114. package/dist/hooks/usePoolContract.js.map +1 -0
  115. package/dist/hooks/useRealWorldReceivableContract.d.ts +10 -0
  116. package/dist/hooks/useRealWorldReceivableContract.js +16 -0
  117. package/dist/hooks/useRealWorldReceivableContract.js.map +1 -0
  118. package/dist/hooks/useReceivableFactoringPoolContract.d.ts +10 -0
  119. package/dist/hooks/useReceivableFactoringPoolContract.js +13 -0
  120. package/dist/hooks/useReceivableFactoringPoolContract.js.map +1 -0
  121. package/dist/index.d.ts +4 -0
  122. package/dist/index.js +5 -0
  123. package/dist/index.js.map +1 -0
  124. package/dist/services/ARWeaveService.d.ts +81 -0
  125. package/dist/services/ARWeaveService.js +136 -0
  126. package/dist/services/ARWeaveService.js.map +1 -0
  127. package/dist/services/EAService.d.ts +18 -0
  128. package/dist/services/EAService.js +10 -0
  129. package/dist/services/EAService.js.map +1 -0
  130. package/dist/services/ReceivableService.d.ts +87 -0
  131. package/dist/services/ReceivableService.js +185 -0
  132. package/dist/services/ReceivableService.js.map +1 -0
  133. package/dist/services/SubgraphService.d.ts +53 -0
  134. package/dist/services/SubgraphService.js +98 -0
  135. package/dist/services/SubgraphService.js.map +1 -0
  136. package/dist/services/index.d.ts +4 -0
  137. package/dist/services/index.js +5 -0
  138. package/dist/services/index.js.map +1 -0
  139. package/dist/tsconfig.cjs.tsbuildinfo +1 -0
  140. package/dist/utils/chain.d.ts +14 -0
  141. package/dist/utils/chain.js +29 -0
  142. package/dist/utils/chain.js.map +1 -0
  143. package/dist/utils/index.d.ts +3 -0
  144. package/dist/utils/index.js +4 -0
  145. package/dist/utils/index.js.map +1 -0
  146. package/dist/utils/poolInfo.d.ts +9 -0
  147. package/dist/utils/poolInfo.js +10 -0
  148. package/dist/utils/poolInfo.js.map +1 -0
  149. package/dist/utils/web3.d.ts +4 -0
  150. package/dist/utils/web3.js +24 -0
  151. package/dist/utils/web3.js.map +1 -0
  152. package/getting-started.md +191 -0
  153. package/package.json +11 -5
@@ -0,0 +1,13 @@
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;
@@ -0,0 +1,27 @@
1
+ import { useMemo } from 'react';
2
+ import { getContract } from '../utils/web3';
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 function useContract(address,
14
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
15
+ ABI, signerOrProvider) {
16
+ return useMemo(() => {
17
+ if (!address || !ABI || !signerOrProvider)
18
+ return null;
19
+ try {
20
+ return getContract(address, ABI, signerOrProvider);
21
+ }
22
+ catch (error) {
23
+ return null;
24
+ }
25
+ }, [address, ABI, signerOrProvider]);
26
+ }
27
+ //# sourceMappingURL=useContract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useContract.js","sourceRoot":"","sources":["../../src/hooks/useContract.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAG/B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CACzB,OAAkC;AAClC,8DAA8D;AAC9D,GAAQ,EACR,gBAA2D;IAE3D,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,IAAI,CAAC,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,gBAAgB;YAAE,OAAO,IAAI,CAAA;QACtD,IAAI;YACF,OAAO,WAAW,CAAC,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"}
@@ -0,0 +1,12 @@
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;
@@ -0,0 +1,17 @@
1
+ import { ERC20_TRANSFERABLE_RECEIVABLE_ABI, POOL_TYPE, PoolContractMap, } from '@huma-finance/shared';
2
+ import { useContract } from './useContract';
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 function useERC20TransferableReceivableContract(signerOrProvider, chainId, poolName) {
13
+ var _a, _b, _c;
14
+ const TransferableReceivableAddress = (_c = (_b = (_a = PoolContractMap[chainId]) === null || _a === void 0 ? void 0 : _a[POOL_TYPE.Invoice]) === null || _b === void 0 ? void 0 : _b[poolName]) === null || _c === void 0 ? void 0 : _c.assetAddress;
15
+ return useContract(TransferableReceivableAddress, ERC20_TRANSFERABLE_RECEIVABLE_ABI, signerOrProvider);
16
+ }
17
+ //# sourceMappingURL=useERC20TransferableReceivableContract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useERC20TransferableReceivableContract.js","sourceRoot":"","sources":["../../src/hooks/useERC20TransferableReceivableContract.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iCAAiC,EAGjC,SAAS,EACT,eAAe,GAChB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;;;;;GAQG;AACH,MAAM,UAAU,sCAAsC,CACpD,gBAA2D,EAC3D,OAAe,EACf,QAAmB;;IAEnB,MAAM,6BAA6B,GACjC,MAAA,MAAA,MAAA,eAAe,CAAC,OAAO,CAAC,0CAAG,SAAS,CAAC,OAAO,CAAC,0CAAG,QAAQ,CAAC,0CAAE,YAAY,CAAA;IAEzE,OAAO,WAAW,CAChB,6BAA6B,EAC7B,iCAAiC,EACjC,gBAAgB,CACjB,CAAA;AACH,CAAC"}
File without changes
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=usePool.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePool.js","sourceRoot":"","sources":["../../src/hooks/usePool.ts"],"names":[],"mappings":""}
@@ -0,0 +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];
@@ -0,0 +1,49 @@
1
+ import { useCallback, useEffect, useState } from 'react';
2
+ import { useContract } from './useContract';
3
+ import { getPoolInfo } from '../utils/poolInfo';
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 function usePoolContract(signerOrProvider, chainId, poolName, poolType) {
16
+ const poolInfo = getPoolInfo(chainId, poolName, poolType);
17
+ return useContract(poolInfo === null || poolInfo === void 0 ? void 0 : poolInfo.pool, poolInfo === null || poolInfo === void 0 ? void 0 : poolInfo.poolAbi, signerOrProvider);
18
+ }
19
+ /**
20
+ * 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.
21
+ *
22
+ * @memberof usePoolContract
23
+ * @param {string} userAddress - The address of the user to get the credit record details for.
24
+ * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider object to use for the contract.
25
+ * @param {number} chainId The chain id where the contract instance exists
26
+ * @param {POOL_NAME} poolName - The name of the pool to get the credit record details for.
27
+ * @param {POOL_TYPE} poolType - The type of the pool.
28
+ * @returns {Array<CreditRecordDetails | undefined, function():void>} An array containing the credit record details and a function to refresh the data.
29
+ */
30
+ export function useCreditRecordDetails(userAddress, signerOrProvider, chainId, poolName, poolType) {
31
+ const poolContract = usePoolContract(signerOrProvider, chainId, poolName, poolType);
32
+ const [creditRecordDetails, setCreditRecordDetails] = useState();
33
+ const [refreshCount, setRefreshCount] = useState(0);
34
+ useEffect(() => {
35
+ const fetchData = async () => {
36
+ if (poolContract && userAddress) {
37
+ const creditRecordMapping = await poolContract.creditRecordMapping(userAddress);
38
+ const creditRecordStaticMapping = await poolContract.creditRecordStaticMapping(userAddress);
39
+ setCreditRecordDetails(Object.assign(Object.assign({}, creditRecordMapping), creditRecordStaticMapping));
40
+ }
41
+ };
42
+ fetchData();
43
+ }, [userAddress, poolContract, refreshCount]);
44
+ const refresh = useCallback(() => {
45
+ setRefreshCount((pre) => pre + 1);
46
+ }, []);
47
+ return [creditRecordDetails, refresh];
48
+ }
49
+ //# sourceMappingURL=usePoolContract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"usePoolContract.js","sourceRoot":"","sources":["../../src/hooks/usePoolContract.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAC7B,gBAA2D,EAC3D,OAAe,EACf,QAAmB,EACnB,QAAmB;IAEnB,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IACzD,OAAO,WAAW,CAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,EAAE,gBAAgB,CAAC,CAAA;AAC5E,CAAC;AAoCD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,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,QAAQ,EAAuB,CAAA;IACjC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IAEnD,SAAS,CAAC,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,WAAW,CAAC,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"}
@@ -0,0 +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;
@@ -0,0 +1,16 @@
1
+ import { REAL_WORLD_RECEIVABLE_ABI, SupplementaryContracts, SupplementaryContractsMap, } from '@huma-finance/shared';
2
+ import { useContract } from './useContract';
3
+ /**
4
+ * A react hook that returns an ethers contract instance for the RealWorldReceivable 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
+ * @returns {Contract | null} A contract instance for the RealWorldReceivable contract or null if it could not be found.
10
+ */
11
+ export function useRealWorldReceivableContract(signerOrProvider, chainId) {
12
+ var _a;
13
+ const realWorldReceivable = (_a = SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[SupplementaryContracts.RealWorldReceivable];
14
+ return useContract(realWorldReceivable, REAL_WORLD_RECEIVABLE_ABI, signerOrProvider);
15
+ }
16
+ //# sourceMappingURL=useRealWorldReceivableContract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRealWorldReceivableContract.js","sourceRoot":"","sources":["../../src/hooks/useRealWorldReceivableContract.ts"],"names":[],"mappings":"AACA,OAAO,EACL,yBAAyB,EAEzB,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;;;;GAOG;AACH,MAAM,UAAU,8BAA8B,CAC5C,gBAA2D,EAC3D,OAAe;;IAEf,MAAM,mBAAmB,GACvB,MAAA,yBAAyB,CAAC,OAAO,CAAC,0CAChC,sBAAsB,CAAC,mBAAmB,CAC3C,CAAA;IAEH,OAAO,WAAW,CAChB,mBAAmB,EACnB,yBAAyB,EACzB,gBAAgB,CACjB,CAAA;AACH,CAAC"}
@@ -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,13 @@
1
+ import { POOL_TYPE, } from '@00labs/huma-shared';
2
+ import { usePoolContract } from './usePoolContract';
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 function useReceivableFactoringPoolContract(signerOrProvider, chainId, poolName) {
11
+ return usePoolContract(signerOrProvider, chainId, poolName, POOL_TYPE.Invoice);
12
+ }
13
+ //# sourceMappingURL=useReceivableFactoringPoolContract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useReceivableFactoringPoolContract.js","sourceRoot":"","sources":["../../src/hooks/useReceivableFactoringPoolContract.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,GAEV,MAAM,qBAAqB,CAAA;AAG5B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD;;;;;;GAMG;AACH,MAAM,UAAU,kCAAkC,CAChD,gBAA2D,EAC3D,OAAe,EACf,QAAmB;IAEnB,OAAO,eAAe,CACpB,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,SAAS,CAAC,OAAO,CAClB,CAAA;AACH,CAAC"}
@@ -0,0 +1,4 @@
1
+ export * from './helpers';
2
+ export * from './hooks';
3
+ export * from './services';
4
+ export * from './utils';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ export * from './helpers';
2
+ export * from './hooks';
3
+ export * from './services';
4
+ export * from './utils';
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA"}
@@ -0,0 +1,81 @@
1
+ import { FundResponse, UploadResponse } from '@bundlr-network/client/build/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
+ * Prefund the Bundlr network with the specified amount. Required if not lazy funding.
29
+ *
30
+ * @async
31
+ * @function
32
+ * @memberof ArweaveService
33
+ * @param {BundlrConfig} config - The configuration for the Bundlr network.
34
+ * @param {any} signer - The wallet to send funds from. This can be either a web3 signer or a private key string.
35
+ * @param {number} amount - The amount to fund, denoted in whatever currency specified by the config.
36
+ * @returns {Promise<FundResponse>} - The fund response.
37
+ */
38
+ declare function prefundBundlr(config: BundlrConfig, signer: any, amount: number): Promise<FundResponse>;
39
+ /**
40
+ * Store data on ARWeave using the Bundlr Network.
41
+ *
42
+ * @async
43
+ * @function
44
+ * @memberof ArweaveService
45
+ * @param {BundlrConfig} config - Configuration object for the Bundlr instance.
46
+ * @param {Web3Provider | string} signerOrPrivateKey - Wallet object used for interacting with the Bundlr instance.
47
+ * If calling from a browser, this should be a `Web3Provider` instance. If calling from a Node.js
48
+ * environment, this should be a private key string.
49
+ * @param {JSON} data - The data to store in the Bundlr instance.
50
+ * @param {Array<{ name: string, value: string }>} tags - Array of tag objects with `name` and `value` properties.
51
+ * @param {boolean} [lazyFund=true] - Optional flag to fund the Bundlr instance lazily. If set to `false`, the
52
+ * Bundlr node should already be funded or else uploads will fail.
53
+ * @returns {Promise<UploadResponse>} Promise resolving with the upload response.
54
+ */
55
+ declare function storeData(config: BundlrConfig, signerOrPrivateKey: Web3Provider | string, data: JSON, tags: {
56
+ name: string;
57
+ value: string;
58
+ }[], lazyFund?: boolean): Promise<UploadResponse>;
59
+ /**
60
+ * Helper method to query the Arweave network for receivables metadata previously uploaded.
61
+ *
62
+ * @async
63
+ * @function
64
+ * @memberof ArweaveService
65
+ * @param {number} chainId - The chain ID.
66
+ * @param {string} sender - The sender tag to query.
67
+ * @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
68
+ * @returns {Promise<any>} Promise resolving with the queried data.
69
+ */
70
+ declare function queryForMetadata(chainId: number, sender: string, referenceId: string): Promise<string | null>;
71
+ /**
72
+ * An object that contains functions to interact with Huma-related data stored on ARWeave
73
+ * @namespace ARWeaveService
74
+ */
75
+ export declare const ARWeaveService: {
76
+ queryForMetadata: typeof queryForMetadata;
77
+ storeData: typeof storeData;
78
+ prefundBundlr: typeof prefundBundlr;
79
+ getBundlrNetworkConfig: typeof getBundlrNetworkConfig;
80
+ };
81
+ export {};
@@ -0,0 +1,136 @@
1
+ import Bundlr from '@bundlr-network/client';
2
+ import request, { gql } from 'graphql-request';
3
+ /**
4
+ * Get the configuration for Bundlr network given a chain ID
5
+ *
6
+ * @function
7
+ * @memberof ArweaveService
8
+ * @param {number} chainId - The chain ID.
9
+ * @returns {BundlrConfig} - The configuration for the Bundlr network.
10
+ */
11
+ export function getBundlrNetworkConfig(chainId) {
12
+ switch (chainId) {
13
+ case 5:
14
+ return {
15
+ nodeUrl: 'https://devnet.bundlr.network',
16
+ currency: 'ethereum',
17
+ providerUrl: 'https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161',
18
+ };
19
+ case 80001:
20
+ return {
21
+ nodeUrl: 'https://devnet.bundlr.network',
22
+ currency: 'matic',
23
+ providerUrl: 'https://rpc-mumbai.matic.today',
24
+ };
25
+ default:
26
+ return {
27
+ nodeUrl: '',
28
+ currency: '',
29
+ };
30
+ }
31
+ }
32
+ /**
33
+ * Prefund the Bundlr network with the specified amount. Required if not lazy funding.
34
+ *
35
+ * @async
36
+ * @function
37
+ * @memberof ArweaveService
38
+ * @param {BundlrConfig} config - The configuration for the Bundlr network.
39
+ * @param {any} signer - The wallet to send funds from. This can be either a web3 signer or a private key string.
40
+ * @param {number} amount - The amount to fund, denoted in whatever currency specified by the config.
41
+ * @returns {Promise<FundResponse>} - The fund response.
42
+ */
43
+ async function prefundBundlr(config,
44
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
+ signer, amount) {
46
+ const bundlr = new Bundlr(config.nodeUrl, config.currency, signer, config.providerUrl
47
+ ? {
48
+ providerUrl: config.providerUrl,
49
+ }
50
+ : undefined);
51
+ await bundlr.ready();
52
+ return bundlr.fund(amount);
53
+ }
54
+ /**
55
+ * Store data on ARWeave using the Bundlr Network.
56
+ *
57
+ * @async
58
+ * @function
59
+ * @memberof ArweaveService
60
+ * @param {BundlrConfig} config - Configuration object for the Bundlr instance.
61
+ * @param {Web3Provider | string} signerOrPrivateKey - Wallet object used for interacting with the Bundlr instance.
62
+ * If calling from a browser, this should be a `Web3Provider` instance. If calling from a Node.js
63
+ * environment, this should be a private key string.
64
+ * @param {JSON} data - The data to store in the Bundlr instance.
65
+ * @param {Array<{ name: string, value: string }>} tags - Array of tag objects with `name` and `value` properties.
66
+ * @param {boolean} [lazyFund=true] - Optional flag to fund the Bundlr instance lazily. If set to `false`, the
67
+ * Bundlr node should already be funded or else uploads will fail.
68
+ * @returns {Promise<UploadResponse>} Promise resolving with the upload response.
69
+ */
70
+ async function storeData(config, signerOrPrivateKey, data, tags, lazyFund = true) {
71
+ const bundlr = new Bundlr(config.nodeUrl, config.currency, signerOrPrivateKey, config.providerUrl
72
+ ? {
73
+ providerUrl: config.providerUrl,
74
+ }
75
+ : undefined);
76
+ await bundlr.ready();
77
+ const dataStr = JSON.stringify(data);
78
+ if (lazyFund) {
79
+ const size = Buffer.byteLength(dataStr);
80
+ const price = await bundlr.getPrice(size);
81
+ // Add a buffer of 10% to account for fluctuations in the price
82
+ price.multipliedBy(1.1);
83
+ console.log(`Funding bundlr with ${price} ${config.currency} to upload data`);
84
+ await bundlr.fund(price);
85
+ }
86
+ return bundlr.upload(dataStr, { tags });
87
+ }
88
+ /**
89
+ * Helper method to query the Arweave network for receivables metadata previously uploaded.
90
+ *
91
+ * @async
92
+ * @function
93
+ * @memberof ArweaveService
94
+ * @param {number} chainId - The chain ID.
95
+ * @param {string} sender - The sender tag to query.
96
+ * @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
97
+ * @returns {Promise<any>} Promise resolving with the queried data.
98
+ */
99
+ async function queryForMetadata(chainId, sender, referenceId) {
100
+ var _a, _b, _c, _d;
101
+ const config = getBundlrNetworkConfig(chainId);
102
+ const query = gql `
103
+ query ArweaveHumaMetadataQuery($sender: String!, $referenceId: String!) {
104
+ transactions(
105
+ owners: [$sender]
106
+ tags: [
107
+ { name: "appName", values: ["HumaFinance"] }
108
+ { name: "referenceId", values: [$referenceId] }
109
+ ]
110
+ ) {
111
+ edges {
112
+ node {
113
+ id
114
+ }
115
+ }
116
+ }
117
+ }
118
+ `;
119
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
120
+ const data = await request(`${config.nodeUrl}/graphql`, query, {
121
+ sender,
122
+ referenceId,
123
+ });
124
+ return (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.transactions) === null || _a === void 0 ? void 0 : _a.edges) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.node) === null || _d === void 0 ? void 0 : _d.id;
125
+ }
126
+ /**
127
+ * An object that contains functions to interact with Huma-related data stored on ARWeave
128
+ * @namespace ARWeaveService
129
+ */
130
+ export const ARWeaveService = {
131
+ queryForMetadata,
132
+ storeData,
133
+ prefundBundlr,
134
+ getBundlrNetworkConfig,
135
+ };
136
+ //# sourceMappingURL=ARWeaveService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ARWeaveService.js","sourceRoot":"","sources":["../../src/services/ARWeaveService.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,wBAAwB,CAAA;AAM3C,OAAO,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAkB9C;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,QAAQ,OAAO,EAAE;QACf,KAAK,CAAC;YACJ,OAAO;gBACL,OAAO,EAAE,+BAA+B;gBACxC,QAAQ,EAAE,UAAU;gBACpB,WAAW,EACT,8DAA8D;aACjE,CAAA;QACH,KAAK,KAAK;YACR,OAAO;gBACL,OAAO,EAAE,+BAA+B;gBACxC,QAAQ,EAAE,OAAO;gBACjB,WAAW,EAAE,gCAAgC;aAC9C,CAAA;QACH;YACE,OAAO;gBACL,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,EAAE;aACb,CAAA;KACJ;AACH,CAAC;AAED;;;;;;;;;;GAUG;AACH,KAAK,UAAU,aAAa,CAC1B,MAAoB;AACpB,8DAA8D;AAC9D,MAAW,EACX,MAAc;IAEd,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,QAAQ,EACf,MAAM,EACN,MAAM,CAAC,WAAW;QAChB,CAAC,CAAC;YACE,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC;QACH,CAAC,CAAC,SAAS,CACd,CAAA;IACD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;IAEpB,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAC5B,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,KAAK,UAAU,SAAS,CACtB,MAAoB,EACpB,kBAAyC,EACzC,IAAU,EACV,IAAuC,EACvC,WAAoB,IAAI;IAExB,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,QAAQ,EACf,kBAAkB,EAClB,MAAM,CAAC,WAAW;QAChB,CAAC,CAAC;YACE,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC;QACH,CAAC,CAAC,SAAS,CACd,CAAA;IACD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;IAEpB,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAEpC,IAAI,QAAQ,EAAE;QACZ,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;QACvC,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAEzC,+DAA+D;QAC/D,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;QACvB,OAAO,CAAC,GAAG,CACT,uBAAuB,KAAK,IAAI,MAAM,CAAC,QAAQ,iBAAiB,CACjE,CAAA;QACD,MAAM,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;KACzB;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;AACzC,CAAC;AAED;;;;;;;;;;GAUG;AACH,KAAK,UAAU,gBAAgB,CAC7B,OAAe,EACf,MAAc,EACd,WAAmB;;IAEnB,MAAM,MAAM,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAA;IAC9C,MAAM,KAAK,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;GAgBhB,CAAA;IAED,8DAA8D;IAC9D,MAAM,IAAI,GAAQ,MAAM,OAAO,CAAC,GAAG,MAAM,CAAC,OAAO,UAAU,EAAE,KAAK,EAAE;QAClE,MAAM;QACN,WAAW;KACZ,CAAC,CAAA;IAEF,OAAO,MAAA,MAAA,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,0CAAE,KAAK,0CAAG,CAAC,CAAC,0CAAE,IAAI,0CAAE,EAAE,CAAA;AACjD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,gBAAgB;IAChB,SAAS;IACT,aAAa;IACb,sBAAsB;CACvB,CAAA"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Object representing the response to the underwriting approval request.
3
+ * @typedef {Object} ApprovalResult
4
+ */
5
+ /**
6
+ * Object representing an invoice payload for underwriting approval.
7
+ *
8
+ * @typedef {Object} EAPayload
9
+ */
10
+ export type { ApprovalResult, EAPayload } from '@huma-finance/shared';
11
+ /**
12
+ * An object that contains functions to interact with Huma's EAVerse service.
13
+ *
14
+ * @namespace EAService
15
+ */
16
+ export declare const EAService: {
17
+ approve: (payload: import("@huma-finance/shared").EAPayload, chainId: number, isDev?: boolean | undefined) => Promise<import("@huma-finance/shared").Approval>;
18
+ };
@@ -0,0 +1,10 @@
1
+ import { EAService as EAServiceInternal } from '@huma-finance/shared';
2
+ /**
3
+ * An object that contains functions to interact with Huma's EAVerse service.
4
+ *
5
+ * @namespace EAService
6
+ */
7
+ export const EAService = {
8
+ approve: EAServiceInternal.approve,
9
+ };
10
+ //# sourceMappingURL=EAService.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EAService.js","sourceRoot":"","sources":["../../src/services/EAService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAarE;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,OAAO,EAAE,iBAAiB,CAAC,OAAO;CACnC,CAAA"}
@@ -0,0 +1,87 @@
1
+ import { TransactionResponse, Web3Provider } from '@ethersproject/providers';
2
+ import { BigNumberish, ethers, Overrides } from 'ethers';
3
+ import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
4
+ /**
5
+ * Declares a payment on a RealWorldReceivable given a reference ID of the receivable, which was used as an index for ARWeave data.
6
+ *
7
+ * @async
8
+ * @function
9
+ * @memberof ReceivableService
10
+ * @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
11
+ * @param {string} referenceId - An internal identifier value added as a tag on ARWeave
12
+ * @param {number} paymentAmount - The amount to declare paid to the receivable.
13
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction receipt.
14
+ */
15
+ declare function declareReceivablePaymentByReferenceId(signer: ethers.Signer, referenceId: string, paymentAmount: number): Promise<TransactionResponse>;
16
+ /**
17
+ * Declares a payment on a RealWorldReceivable given a tokenID of the receivable.
18
+ *
19
+ * @async
20
+ * @function
21
+ * @memberof ReceivableService
22
+ * @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
23
+ * @param {BigNumberish} receivableTokenId - The ID of the receivable token to pay.
24
+ * @param {number} paymentAmount - The amount to pay the receivable.
25
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction receipt.
26
+ * @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
27
+ */
28
+ declare function declareReceivablePaymentByTokenId(signer: ethers.Signer, receivableTokenId: BigNumberish, paymentAmount: number): Promise<TransactionResponse>;
29
+ /**
30
+ * Creates a new RealWorldReceivable token on the given chain of the signer
31
+ *
32
+ * @async
33
+ * @function
34
+ * @memberof ReceivableService
35
+ * @param {ethers.Signer} signer - The signer used to send the transaction.
36
+ * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
37
+ * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
38
+ * @param {number} currencyCode - The ISO 4217 currency code that the receivable is denominated in
39
+ * @param {number} receivableAmount - The amount of the receivable token to mint.
40
+ * @param {number} maturityDate - The maturity date of the receivable token, in UNIX timestamp format.
41
+ * @param {string} uri - The URI of the receivable token metadata.
42
+ * @param {Overrides} gasOpts - The gas options to use for the transaction.
43
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
44
+ * @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
45
+ */
46
+ declare function createReceivable(signer: ethers.Signer, poolName: POOL_NAME, poolType: POOL_TYPE, currencyCode: number, receivableAmount: number, maturityDate: number, uri: string, gasOpts?: Overrides): Promise<TransactionResponse>;
47
+ /**
48
+ * Creates a RealWorldReceivable token with metadata uploaded onto ARWeave
49
+ *
50
+ * @async
51
+ * @function
52
+ * @memberof ReceivableService
53
+ * @param {Web3Provider | ethers.Signer} signerOrProvider - If calling this function from a browser, this function expects a Web3Provider.
54
+ * If calling this function from a server, this function expects an ethers Signer. Note that privateKey only needs to be included
55
+ * from server calls.
56
+ * @param {string | null} privateKey - Private key of the wallet used to upload metadata to ARWeave. Only required if calling this function from a server.
57
+ * @param {number} chainId - The chain ID to mint the receivable token on and pay ARWeave funds from.
58
+ * @param {string} recipient - The receivable token recipient.
59
+ * @param {POOL_NAME} poolName - The pool name. Used to lookup the pool address to pay to.
60
+ * @param {POOL_TYPE} poolType - The pool type. Used to lookup the pool address to pay to.
61
+ * @param {number} currencyCode - The ISO 4217 currency code that the receivable is denominated in
62
+ * @param {number} receivableAmount - The receivable amount.
63
+ * @param {number} maturityDate - The maturity date of the receivable, in UNIX timestamp format.
64
+ * @param {JSON} metadata - The metadata in JSON format. This will be uploaded onto ARWeave
65
+ * @param {number} referenceId - An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.
66
+ * @param {Array<{ name: string, value: string }>} extraTags - Any extraTags you'd like to tag your metadata with. Note that metadata on
67
+ * ARWeave is indexed by these tags, so make sure to include any tags that you'd like to be able to query by.
68
+ * @param {boolean} [lazyFund=true] - Whether to lazy fund the ARWeave uploads. If true, the ARWeave uploads will be paid for by the
69
+ * metadata uploader immediately before uploading. If false, the ARWeave node must be pre-funded before calling this function.
70
+ * @param {Overrides} [gasOpts] - Optional gas overrides for the transaction.
71
+ * @returns {Promise<TransactionResponse>} - The transaction receipt.
72
+ */
73
+ declare function createReceivableWithMetadata(signerOrProvider: Web3Provider | ethers.Signer, privateKey: string | null, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, currencyCode: number, receivableAmount: number, maturityDate: number, metadata: JSON, referenceId: string, extraTags: {
74
+ name: string;
75
+ value: string;
76
+ }[], lazyFund?: boolean, gasOpts?: Overrides): Promise<TransactionResponse>;
77
+ /**
78
+ * An object that contains functions to interact with Huma's receivables.
79
+ * @namespace ReceivableService
80
+ */
81
+ export declare const ReceivableService: {
82
+ createReceivableWithMetadata: typeof createReceivableWithMetadata;
83
+ createReceivable: typeof createReceivable;
84
+ declareReceivablePaymentByTokenId: typeof declareReceivablePaymentByTokenId;
85
+ declareReceivablePaymentByReferenceId: typeof declareReceivablePaymentByReferenceId;
86
+ };
87
+ export {};