@huma-finance/sdk 0.0.11 → 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 (67) hide show
  1. package/API.md +432 -0
  2. package/README.md +9 -5
  3. package/dist/cjs/graphql/generatedTypes.d.ts +40 -0
  4. package/dist/cjs/graphql/generatedTypes.js +9 -0
  5. package/dist/cjs/graphql/generatedTypes.js.map +1 -0
  6. package/dist/cjs/graphql/index.d.ts +1 -0
  7. package/dist/cjs/graphql/index.js +5 -0
  8. package/dist/cjs/graphql/index.js.map +1 -0
  9. package/dist/cjs/helpers/PoolContractHelper.d.ts +4 -1
  10. package/dist/cjs/helpers/PoolContractHelper.js +19 -1
  11. package/dist/cjs/helpers/PoolContractHelper.js.map +1 -1
  12. package/dist/cjs/services/ARWeaveService.d.ts +1 -18
  13. package/dist/cjs/services/ARWeaveService.js +2 -36
  14. package/dist/cjs/services/ARWeaveService.js.map +1 -1
  15. package/dist/cjs/services/ReceivableService.d.ts +11 -0
  16. package/dist/cjs/services/ReceivableService.js +71 -20
  17. package/dist/cjs/services/ReceivableService.js.map +1 -1
  18. package/dist/graphql/generatedTypes.d.ts +40 -0
  19. package/dist/graphql/generatedTypes.js +5 -0
  20. package/dist/graphql/generatedTypes.js.map +1 -0
  21. package/dist/graphql/index.d.ts +1 -0
  22. package/dist/graphql/index.js +2 -0
  23. package/dist/graphql/index.js.map +1 -0
  24. package/dist/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -10
  25. package/dist/helpers/ERC20TransferableReceivableContractHelper.js +17 -17
  26. package/dist/helpers/PoolContractHelper.d.ts +15 -12
  27. package/dist/helpers/PoolContractHelper.js +32 -16
  28. package/dist/helpers/PoolContractHelper.js.map +1 -1
  29. package/dist/helpers/RealWorldReceivableContractHelper.d.ts +10 -10
  30. package/dist/helpers/RealWorldReceivableContractHelper.js +17 -17
  31. package/dist/helpers/index.d.ts +3 -3
  32. package/dist/helpers/index.js +3 -3
  33. package/dist/hooks/index.d.ts +4 -4
  34. package/dist/hooks/index.js +4 -4
  35. package/dist/hooks/useContract.d.ts +13 -13
  36. package/dist/hooks/useContract.js +26 -26
  37. package/dist/hooks/useERC20TransferableReceivableContract.d.ts +12 -12
  38. package/dist/hooks/useERC20TransferableReceivableContract.js +16 -16
  39. package/dist/hooks/usePoolContract.d.ts +60 -60
  40. package/dist/hooks/usePoolContract.js +48 -48
  41. package/dist/hooks/useRealWorldReceivableContract.d.ts +10 -10
  42. package/dist/hooks/useRealWorldReceivableContract.js +15 -15
  43. package/dist/index.d.ts +4 -4
  44. package/dist/index.js +4 -4
  45. package/dist/services/ARWeaveService.d.ts +81 -84
  46. package/dist/services/ARWeaveService.js +120 -131
  47. package/dist/services/ARWeaveService.js.map +1 -1
  48. package/dist/services/EAService.d.ts +18 -18
  49. package/dist/services/EAService.js +9 -9
  50. package/dist/services/ReceivableService.d.ts +87 -76
  51. package/dist/services/ReceivableService.js +184 -134
  52. package/dist/services/ReceivableService.js.map +1 -1
  53. package/dist/services/SubgraphService.d.ts +53 -53
  54. package/dist/services/SubgraphService.js +79 -79
  55. package/dist/services/index.d.ts +4 -4
  56. package/dist/services/index.js +4 -4
  57. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  58. package/dist/utils/chain.d.ts +14 -14
  59. package/dist/utils/chain.js +28 -28
  60. package/dist/utils/index.d.ts +3 -3
  61. package/dist/utils/index.js +3 -3
  62. package/dist/utils/poolInfo.d.ts +9 -9
  63. package/dist/utils/poolInfo.js +9 -9
  64. package/dist/utils/web3.d.ts +4 -4
  65. package/dist/utils/web3.js +23 -23
  66. package/getting-started.md +191 -0
  67. package/package.json +11 -5
package/API.md ADDED
@@ -0,0 +1,432 @@
1
+ ## Objects
2
+
3
+ <dl>
4
+ <dt><a href="#usePoolContract">usePoolContract</a> ⇒ <code>T</code></dt>
5
+ <dd><p>A react hook that returns a contract instance of a specific pool using an ethers provider or signer</p></dd>
6
+ <dt><a href="#ARWeaveService">ARWeaveService</a> : <code>object</code></dt>
7
+ <dd><p>An object that contains functions to interact with Huma-related data stored on ARWeave</p></dd>
8
+ <dt><a href="#EAService">EAService</a> : <code>object</code></dt>
9
+ <dd><p>An object that contains functions to interact with Huma's EAVerse service.</p></dd>
10
+ <dt><a href="#ReceivableService">ReceivableService</a> : <code>object</code></dt>
11
+ <dd><p>An object that contains functions to interact with Huma's receivables.</p></dd>
12
+ <dt><a href="#SubgraphService">SubgraphService</a> : <code>object</code></dt>
13
+ <dd><p>An object that contains functions to interact with Huma's Subgraph storage.</p></dd>
14
+ </dl>
15
+
16
+ ## Functions
17
+
18
+ <dl>
19
+ <dt><a href="#getERC20TransferableReceivableContract">getERC20TransferableReceivableContract(signerOrProvider, chainId)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
20
+ <dd><p>Returns an ethers contract instance for the ERC20TransferableReceivable contract
21
+ associated with the given pool name on the current chain.</p></dd>
22
+ <dt><a href="#getPoolContract">getPoolContract(signerOrProvider, chainId, poolName, poolType)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
23
+ <dd><p>Returns an ethers contract instance for a Huma pool contract</p></dd>
24
+ <dt><a href="#getRealWorldReceivableContract">getRealWorldReceivableContract(signerOrProvider, chainId)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
25
+ <dd><p>Returns an ethers contract instance for the RealWorldReceivable contract
26
+ associated with the given pool name on the current chain.</p></dd>
27
+ <dt><a href="#useContract">useContract(address, ABI, signerOrProvider)</a> ⇒ <code>T</code> | <code>null</code></dt>
28
+ <dd><p>Custom hook for creating an ethers instance of a smart contract.</p></dd>
29
+ <dt><a href="#useERC20TransferableReceivableContract">useERC20TransferableReceivableContract(signerOrProvider, chainId, poolName)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
30
+ <dd><p>A react hook that returns an ethers contract instance for the ERC20TransferableReceivable contract
31
+ associated with the given pool name on the current chain.</p></dd>
32
+ <dt><a href="#useRealWorldReceivableContract">useRealWorldReceivableContract(signerOrProvider, chainId)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
33
+ <dd><p>A react hook that returns an ethers contract instance for the RealWorldReceivable contract
34
+ associated with the given pool name on the current chain.</p></dd>
35
+ <dt><a href="#getChainIdFromJsonSignerOrProvider">getChainIdFromJsonSignerOrProvider(signerOrProvider)</a> ⇒ <code>number</code></dt>
36
+ <dd><p>Get the chain ID from a signer or provider object.</p></dd>
37
+ <dt><a href="#getChainIdFromSignerOrProvider">getChainIdFromSignerOrProvider(signerOrProvider)</a> ⇒ <code>number</code></dt>
38
+ <dd><p>Get the chain ID from a signer or provider object.</p></dd>
39
+ <dt><a href="#getPoolInfo">getPoolInfo(signerOrProvider, poolName, poolType)</a> ⇒ <code>PoolInfoType</code> | <code>undefined</code></dt>
40
+ <dd><p>Returns the pool info based on the provided pool name and type, using the same chain ID as the provider/signer given</p></dd>
41
+ </dl>
42
+
43
+ ## Typedefs
44
+
45
+ <dl>
46
+ <dt><a href="#ApprovalResult">ApprovalResult</a> : <code>Object</code></dt>
47
+ <dd><p>Object representing the response to the underwriting approval request.</p></dd>
48
+ <dt><a href="#EAPayload">EAPayload</a> : <code>Object</code></dt>
49
+ <dd><p>Object representing an invoice payload for underwriting approval.</p></dd>
50
+ <dt><a href="#CreditEventPayload">CreditEventPayload</a> : <code>Object</code></dt>
51
+ <dd><p>Represents the payload of a credit event.</p></dd>
52
+ </dl>
53
+
54
+ <a name="usePoolContract"></a>
55
+
56
+ ## usePoolContract ⇒ <code>T</code>
57
+ <p>A react hook that returns a contract instance of a specific pool using an ethers provider or signer</p>
58
+
59
+ **Kind**: global namespace
60
+ **Returns**: <code>T</code> - <p>A contract instance of the specific pool.</p>
61
+
62
+ | Param | Type | Description |
63
+ | --- | --- | --- |
64
+ | signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>An ethers signer or provider instance.</p> |
65
+ | chainId | <code>number</code> | <p>The chain id where the contract instance exists</p> |
66
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the pool.</p> |
67
+ | poolType | <code>POOL\_TYPE</code> | <p>The type of the pool.</p> |
68
+
69
+
70
+ * [usePoolContract](#usePoolContract) ⇒ <code>T</code>
71
+ * [.useCreditRecordDetails(userAddress, signerOrProvider, chainId, poolName, poolType)](#usePoolContract.useCreditRecordDetails) ⇒ <code>Array.&lt;(CreditRecordDetails\|undefined), function(): void&gt;</code>
72
+ * [.CreditRecordDetails](#usePoolContract.CreditRecordDetails) : <code>Object</code>
73
+
74
+ <a name="usePoolContract.useCreditRecordDetails"></a>
75
+
76
+ ### usePoolContract.useCreditRecordDetails(userAddress, signerOrProvider, chainId, poolName, poolType) ⇒ <code>Array.&lt;(CreditRecordDetails\|undefined), function(): void&gt;</code>
77
+ <p>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.</p>
78
+
79
+ **Kind**: static method of [<code>usePoolContract</code>](#usePoolContract)
80
+ **Returns**: <code>Array.&lt;(CreditRecordDetails\|undefined), function(): void&gt;</code> - <p>An array containing the credit record details and a function to refresh the data.</p>
81
+
82
+ | Param | Type | Description |
83
+ | --- | --- | --- |
84
+ | userAddress | <code>string</code> | <p>The address of the user to get the credit record details for.</p> |
85
+ | signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The signer or provider object to use for the contract.</p> |
86
+ | chainId | <code>number</code> | <p>The chain id where the contract instance exists</p> |
87
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the pool to get the credit record details for.</p> |
88
+ | poolType | <code>POOL\_TYPE</code> | <p>The type of the pool.</p> |
89
+
90
+ <a name="usePoolContract.CreditRecordDetails"></a>
91
+
92
+ ### usePoolContract.CreditRecordDetails : <code>Object</code>
93
+ <p>CreditRecordDetails type object representing the details of a credit line.</p>
94
+
95
+ **Kind**: static typedef of [<code>usePoolContract</code>](#usePoolContract)
96
+ **Properties**
97
+
98
+ | Name | Type | Description |
99
+ | --- | --- | --- |
100
+ | aprInBps | <code>number</code> | <p>The APR (annual percentage rate) in basis points.</p> |
101
+ | correction | <code>BigNumber</code> | <p>adjustment of interest over or under-counted because of drawdown or principal payment in the middle of a billing period</p> |
102
+ | creditLimit | <code>BigNumber</code> | <p>The credit limit in the pools base currency.</p> |
103
+ | defaultAmount | <code>BigNumber</code> | <p>The amount of the default, if any.</p> |
104
+ | dueDate | <code>BigNumber</code> | <p>The due date of the next payment.</p> |
105
+ | feesAndInterestDue | <code>BigNumber</code> | <p>The fees and interest due.</p> |
106
+ | intervalInDays | <code>number</code> | <p>The interval in days between payment periods.</p> |
107
+ | missedPeriods | <code>number</code> | <p>The number of missed periods.</p> |
108
+ | remainingPeriods | <code>number</code> | <p>The number of remaining periods before this credit line is considered paid off.</p> |
109
+ | state | <code>number</code> | <p>The state of the factorization. Please see the CreditState in huma-contracts for more details.</p> |
110
+ | totalDue | <code>BigNumber</code> | <p>The total due amount of this credit line.</p> |
111
+ | unbilledPrincipal | <code>BigNumber</code> | <p>The unbilled principal of the next payment.</p> |
112
+
113
+ <a name="ARWeaveService"></a>
114
+
115
+ ## ARWeaveService : <code>object</code>
116
+ <p>An object that contains functions to interact with Huma-related data stored on ARWeave</p>
117
+
118
+ **Kind**: global namespace
119
+ <a name="EAService"></a>
120
+
121
+ ## EAService : <code>object</code>
122
+ <p>An object that contains functions to interact with Huma's EAVerse service.</p>
123
+
124
+ **Kind**: global namespace
125
+ <a name="ReceivableService"></a>
126
+
127
+ ## ReceivableService : <code>object</code>
128
+ <p>An object that contains functions to interact with Huma's receivables.</p>
129
+
130
+ **Kind**: global namespace
131
+
132
+ * [ReceivableService](#ReceivableService) : <code>object</code>
133
+ * [.declareReceivablePaymentByReferenceId(signer, referenceId, paymentAmount)](#ReceivableService.declareReceivablePaymentByReferenceId) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
134
+ * [.declareReceivablePaymentByTokenId(signer, receivableTokenId, paymentAmount)](#ReceivableService.declareReceivablePaymentByTokenId) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
135
+ * [.createReceivable(signer, poolName, poolType, currencyCode, receivableAmount, maturityDate, uri, gasOpts)](#ReceivableService.createReceivable) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
136
+ * [.createReceivableWithMetadata(signerOrProvider, privateKey, chainId, recipient, poolName, poolType, currencyCode, receivableAmount, maturityDate, metadata, referenceId, extraTags, [lazyFund], [gasOpts])](#ReceivableService.createReceivableWithMetadata) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
137
+
138
+ <a name="ReceivableService.declareReceivablePaymentByReferenceId"></a>
139
+
140
+ ### ReceivableService.declareReceivablePaymentByReferenceId(signer, referenceId, paymentAmount) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
141
+ <p>Declares a payment on a RealWorldReceivable given a reference ID of the receivable, which was used as an index for ARWeave data.</p>
142
+
143
+ **Kind**: static method of [<code>ReceivableService</code>](#ReceivableService)
144
+ **Returns**: <code>Promise.&lt;TransactionResponse&gt;</code> - <ul>
145
+ <li>A Promise of the transaction receipt.</li>
146
+ </ul>
147
+
148
+ | Param | Type | Description |
149
+ | --- | --- | --- |
150
+ | signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction. Note only the receivable owner can pay the receivable.</p> |
151
+ | referenceId | <code>string</code> | <p>An internal identifier value added as a tag on ARWeave</p> |
152
+ | paymentAmount | <code>number</code> | <p>The amount to declare paid to the receivable.</p> |
153
+
154
+ <a name="ReceivableService.declareReceivablePaymentByTokenId"></a>
155
+
156
+ ### ReceivableService.declareReceivablePaymentByTokenId(signer, receivableTokenId, paymentAmount) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
157
+ <p>Declares a payment on a RealWorldReceivable given a tokenID of the receivable.</p>
158
+
159
+ **Kind**: static method of [<code>ReceivableService</code>](#ReceivableService)
160
+ **Returns**: <code>Promise.&lt;TransactionResponse&gt;</code> - <ul>
161
+ <li>A Promise of the transaction receipt.</li>
162
+ </ul>
163
+ **Throws**:
164
+
165
+ - <code>Error</code> <ul>
166
+ <li>Throws an error if the RealWorldReceivable contract is not available on the network.</li>
167
+ </ul>
168
+
169
+
170
+ | Param | Type | Description |
171
+ | --- | --- | --- |
172
+ | signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction. Note only the receivable owner can pay the receivable.</p> |
173
+ | receivableTokenId | <code>BigNumberish</code> | <p>The ID of the receivable token to pay.</p> |
174
+ | paymentAmount | <code>number</code> | <p>The amount to pay the receivable.</p> |
175
+
176
+ <a name="ReceivableService.createReceivable"></a>
177
+
178
+ ### ReceivableService.createReceivable(signer, poolName, poolType, currencyCode, receivableAmount, maturityDate, uri, gasOpts) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
179
+ <p>Creates a new RealWorldReceivable token on the given chain of the signer</p>
180
+
181
+ **Kind**: static method of [<code>ReceivableService</code>](#ReceivableService)
182
+ **Returns**: <code>Promise.&lt;TransactionResponse&gt;</code> - <ul>
183
+ <li>A Promise of the transaction response.</li>
184
+ </ul>
185
+ **Throws**:
186
+
187
+ - <code>Error</code> <ul>
188
+ <li>Throws an error if the RealWorldReceivable contract is not available on the network.</li>
189
+ </ul>
190
+
191
+
192
+ | Param | Type | Description |
193
+ | --- | --- | --- |
194
+ | signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction.</p> |
195
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool to mint the receivable token from. Used to lookup the pool address.</p> |
196
+ | poolType | <code>POOL\_TYPE</code> | <p>The type of the credit pool to mint the receivable token from. Used to lookup the pool address.</p> |
197
+ | currencyCode | <code>number</code> | <p>The ISO 4217 currency code that the receivable is denominated in</p> |
198
+ | receivableAmount | <code>number</code> | <p>The amount of the receivable token to mint.</p> |
199
+ | maturityDate | <code>number</code> | <p>The maturity date of the receivable token, in UNIX timestamp format.</p> |
200
+ | uri | <code>string</code> | <p>The URI of the receivable token metadata.</p> |
201
+ | gasOpts | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
202
+
203
+ <a name="ReceivableService.createReceivableWithMetadata"></a>
204
+
205
+ ### ReceivableService.createReceivableWithMetadata(signerOrProvider, privateKey, chainId, recipient, poolName, poolType, currencyCode, receivableAmount, maturityDate, metadata, referenceId, extraTags, [lazyFund], [gasOpts]) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
206
+ <p>Creates a RealWorldReceivable token with metadata uploaded onto ARWeave</p>
207
+
208
+ **Kind**: static method of [<code>ReceivableService</code>](#ReceivableService)
209
+ **Returns**: <code>Promise.&lt;TransactionResponse&gt;</code> - <ul>
210
+ <li>The transaction receipt.</li>
211
+ </ul>
212
+
213
+ | Param | Type | Default | Description |
214
+ | --- | --- | --- | --- |
215
+ | signerOrProvider | <code>Web3Provider</code> \| <code>ethers.Signer</code> | | <p>If calling this function from a browser, this function expects a Web3Provider. If calling this function from a server, this function expects an ethers Signer. Note that privateKey only needs to be included from server calls.</p> |
216
+ | privateKey | <code>string</code> \| <code>null</code> | | <p>Private key of the wallet used to upload metadata to ARWeave. Only required if calling this function from a server.</p> |
217
+ | chainId | <code>number</code> | | <p>The chain ID to mint the receivable token on and pay ARWeave funds from.</p> |
218
+ | recipient | <code>string</code> | | <p>The receivable token recipient.</p> |
219
+ | poolName | <code>POOL\_NAME</code> | | <p>The pool name. Used to lookup the pool address to pay to.</p> |
220
+ | poolType | <code>POOL\_TYPE</code> | | <p>The pool type. Used to lookup the pool address to pay to.</p> |
221
+ | currencyCode | <code>number</code> | | <p>The ISO 4217 currency code that the receivable is denominated in</p> |
222
+ | receivableAmount | <code>number</code> | | <p>The receivable amount.</p> |
223
+ | maturityDate | <code>number</code> | | <p>The maturity date of the receivable, in UNIX timestamp format.</p> |
224
+ | metadata | <code>JSON</code> | | <p>The metadata in JSON format. This will be uploaded onto ARWeave</p> |
225
+ | referenceId | <code>number</code> | | <p>An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.</p> |
226
+ | extraTags | <code>Array.&lt;{name: string, value: string}&gt;</code> | | <p>Any extraTags you'd like to tag your metadata with. Note that metadata on ARWeave is indexed by these tags, so make sure to include any tags that you'd like to be able to query by.</p> |
227
+ | [lazyFund] | <code>boolean</code> | <code>true</code> | <p>Whether to lazy fund the ARWeave uploads. If true, the ARWeave uploads will be paid for by the metadata uploader immediately before uploading. If false, the ARWeave node must be pre-funded before calling this function.</p> |
228
+ | [gasOpts] | <code>Overrides</code> | | <p>Optional gas overrides for the transaction.</p> |
229
+
230
+ <a name="SubgraphService"></a>
231
+
232
+ ## SubgraphService : <code>object</code>
233
+ <p>An object that contains functions to interact with Huma's Subgraph storage.</p>
234
+
235
+ **Kind**: global namespace
236
+
237
+ * [SubgraphService](#SubgraphService) : <code>object</code>
238
+ * [.getSubgraphUrlForChainId(chainId)](#SubgraphService.getSubgraphUrlForChainId) ⇒ <code>string</code>
239
+ * [.getCreditEventsForUser(userAddress, chainId, poolName, poolType, event)](#SubgraphService.getCreditEventsForUser) ⇒ <code>Promise.&lt;Array.&lt;CreditEventPayload&gt;&gt;</code>
240
+ * [.getLastFactorizedAmountFromPool(userAddress, chainId, poolName, poolType)](#SubgraphService.getLastFactorizedAmountFromPool) ⇒ <code>Promise.&lt;number&gt;</code>
241
+
242
+ <a name="SubgraphService.getSubgraphUrlForChainId"></a>
243
+
244
+ ### SubgraphService.getSubgraphUrlForChainId(chainId) ⇒ <code>string</code>
245
+ <p>Returns the subgraph URL for a given chain ID.</p>
246
+
247
+ **Kind**: static method of [<code>SubgraphService</code>](#SubgraphService)
248
+ **Returns**: <code>string</code> - <p>The subgraph URL for the given chain ID.</p>
249
+
250
+ | Param | Type | Description |
251
+ | --- | --- | --- |
252
+ | chainId | <code>number</code> | <p>The ID of the chain.</p> |
253
+
254
+ <a name="SubgraphService.getCreditEventsForUser"></a>
255
+
256
+ ### SubgraphService.getCreditEventsForUser(userAddress, chainId, poolName, poolType, event) ⇒ <code>Promise.&lt;Array.&lt;CreditEventPayload&gt;&gt;</code>
257
+ <p>Returns the credit events for a given user.</p>
258
+
259
+ **Kind**: static method of [<code>SubgraphService</code>](#SubgraphService)
260
+ **Returns**: <code>Promise.&lt;Array.&lt;CreditEventPayload&gt;&gt;</code> - <p>The credit events for the given user.</p>
261
+
262
+ | Param | Type | Description |
263
+ | --- | --- | --- |
264
+ | userAddress | <code>string</code> | <p>The address of the user.</p> |
265
+ | chainId | <code>number</code> | <p>The ID of the chain.</p> |
266
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the pool.</p> |
267
+ | poolType | <code>POOL\_TYPE</code> | <p>The type of the pool.</p> |
268
+ | event | <code>Array.&lt;string&gt;</code> | <p>The event types to filter by.</p> |
269
+
270
+ <a name="SubgraphService.getLastFactorizedAmountFromPool"></a>
271
+
272
+ ### SubgraphService.getLastFactorizedAmountFromPool(userAddress, chainId, poolName, poolType) ⇒ <code>Promise.&lt;number&gt;</code>
273
+ <p>Returns the last factorized amount for a given user and pool.</p>
274
+
275
+ **Kind**: static method of [<code>SubgraphService</code>](#SubgraphService)
276
+ **Returns**: <code>Promise.&lt;number&gt;</code> - <p>The last factorized amount for the given user and pool.</p>
277
+
278
+ | Param | Type | Description |
279
+ | --- | --- | --- |
280
+ | userAddress | <code>string</code> | <p>The address of the user.</p> |
281
+ | chainId | <code>number</code> | <p>The ID of the chain.</p> |
282
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the pool.</p> |
283
+ | poolType | <code>POOL\_TYPE</code> | <p>The type of the pool.</p> |
284
+
285
+ <a name="getERC20TransferableReceivableContract"></a>
286
+
287
+ ## getERC20TransferableReceivableContract(signerOrProvider, chainId) ⇒ <code>Contract</code> \| <code>null</code>
288
+ <p>Returns an ethers contract instance for the ERC20TransferableReceivable contract
289
+ associated with the given pool name on the current chain.</p>
290
+
291
+ **Kind**: global function
292
+ **Returns**: <code>Contract</code> \| <code>null</code> - <p>A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.</p>
293
+
294
+ | Param | Type | Description |
295
+ | --- | --- | --- |
296
+ | signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The provider or signer instance to use for the contract.</p> |
297
+ | chainId | <code>number</code> | <p>The chain id where the contract instance exists</p> |
298
+
299
+ <a name="getPoolContract"></a>
300
+
301
+ ## getPoolContract(signerOrProvider, chainId, poolName, poolType) ⇒ <code>Contract</code> \| <code>null</code>
302
+ <p>Returns an ethers contract instance for a Huma pool contract</p>
303
+
304
+ **Kind**: global function
305
+ **Returns**: <code>Contract</code> \| <code>null</code> - <p>A contract instance for the Pool contract or null if it could not be found.</p>
306
+
307
+ | Param | Type | Description |
308
+ | --- | --- | --- |
309
+ | signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The provider or signer instance to use for the contract.</p> |
310
+ | chainId | <code>number</code> | <p>The chain id where the contract instance exists</p> |
311
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the pool contract to get.</p> |
312
+ | poolType | <code>POOL\_TYPE</code> | <p>The type of the pool contract to get.</p> |
313
+
314
+ <a name="getRealWorldReceivableContract"></a>
315
+
316
+ ## getRealWorldReceivableContract(signerOrProvider, chainId) ⇒ <code>Contract</code> \| <code>null</code>
317
+ <p>Returns an ethers contract instance for the RealWorldReceivable contract
318
+ associated with the given pool name on the current chain.</p>
319
+
320
+ **Kind**: global function
321
+ **Returns**: <code>Contract</code> \| <code>null</code> - <p>A contract instance for the RealWorldReceivable contract or null if it could not be found.</p>
322
+
323
+ | Param | Type | Description |
324
+ | --- | --- | --- |
325
+ | signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The provider or signer instance to use for the contract.</p> |
326
+ | chainId | <code>number</code> | <p>The chain id where the contract instance exists</p> |
327
+
328
+ <a name="useContract"></a>
329
+
330
+ ## useContract(address, ABI, signerOrProvider) ⇒ <code>T</code> \| <code>null</code>
331
+ <p>Custom hook for creating an ethers instance of a smart contract.</p>
332
+
333
+ **Kind**: global function
334
+ **Returns**: <code>T</code> \| <code>null</code> - <p>An instance of the smart contract, or null if an error occurs.</p>
335
+
336
+ | Param | Type | Description |
337
+ | --- | --- | --- |
338
+ | address | <code>string</code> \| <code>null</code> \| <code>undefined</code> | <p>The address of the smart contract instance.</p> |
339
+ | ABI | <code>any</code> | <p>The ABI of the smart contract.</p> |
340
+ | signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The signer or provider used to sign transactions or retrieve blockchain data. Note that this signerOrProvider must be connected to the same network as the smart contract in question.</p> |
341
+
342
+ <a name="useERC20TransferableReceivableContract"></a>
343
+
344
+ ## useERC20TransferableReceivableContract(signerOrProvider, chainId, poolName) ⇒ <code>Contract</code> \| <code>null</code>
345
+ <p>A react hook that returns an ethers contract instance for the ERC20TransferableReceivable contract
346
+ associated with the given pool name on the current chain.</p>
347
+
348
+ **Kind**: global function
349
+ **Returns**: <code>Contract</code> \| <code>null</code> - <p>A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.</p>
350
+
351
+ | Param | Type | Description |
352
+ | --- | --- | --- |
353
+ | signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The provider or signer instance to use for the contract.</p> |
354
+ | chainId | <code>number</code> | <p>The chain id where the contract instance exists</p> |
355
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the pool to get the contract for.</p> |
356
+
357
+ <a name="useRealWorldReceivableContract"></a>
358
+
359
+ ## useRealWorldReceivableContract(signerOrProvider, chainId) ⇒ <code>Contract</code> \| <code>null</code>
360
+ <p>A react hook that returns an ethers contract instance for the RealWorldReceivable contract
361
+ associated with the given pool name on the current chain.</p>
362
+
363
+ **Kind**: global function
364
+ **Returns**: <code>Contract</code> \| <code>null</code> - <p>A contract instance for the RealWorldReceivable contract or null if it could not be found.</p>
365
+
366
+ | Param | Type | Description |
367
+ | --- | --- | --- |
368
+ | signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The provider or signer instance to use for the contract.</p> |
369
+ | chainId | <code>number</code> | <p>The chain id where the contract instance exists</p> |
370
+
371
+ <a name="getChainIdFromJsonSignerOrProvider"></a>
372
+
373
+ ## getChainIdFromJsonSignerOrProvider(signerOrProvider) ⇒ <code>number</code>
374
+ <p>Get the chain ID from a signer or provider object.</p>
375
+
376
+ **Kind**: global function
377
+ **Returns**: <code>number</code> - <ul>
378
+ <li>The chain ID.</li>
379
+ </ul>
380
+
381
+ | Param | Type | Description |
382
+ | --- | --- | --- |
383
+ | signerOrProvider | <code>JsonRpcProvider</code> \| <code>JsonRpcSigner</code> | <p>The signer or provider object to get the chain ID from.</p> |
384
+
385
+ <a name="getChainIdFromSignerOrProvider"></a>
386
+
387
+ ## getChainIdFromSignerOrProvider(signerOrProvider) ⇒ <code>number</code>
388
+ <p>Get the chain ID from a signer or provider object.</p>
389
+
390
+ **Kind**: global function
391
+ **Returns**: <code>number</code> - <ul>
392
+ <li>The chain ID.</li>
393
+ </ul>
394
+
395
+ | Param | Type | Description |
396
+ | --- | --- | --- |
397
+ | signerOrProvider | <code>ethers.provider.Provider</code> \| <code>ethers.Signer</code> | <p>The signer or provider object to get the chain ID from.</p> |
398
+
399
+ <a name="getPoolInfo"></a>
400
+
401
+ ## getPoolInfo(signerOrProvider, poolName, poolType) ⇒ <code>PoolInfoType</code> \| <code>undefined</code>
402
+ <p>Returns the pool info based on the provided pool name and type, using the same chain ID as the provider/signer given</p>
403
+
404
+ **Kind**: global function
405
+ **Returns**: <code>PoolInfoType</code> \| <code>undefined</code> - <ul>
406
+ <li>The pool info or undefined if the chain ID is not supported.</li>
407
+ </ul>
408
+
409
+ | Param | Type | Description |
410
+ | --- | --- | --- |
411
+ | signerOrProvider | <code>JsonRpcProvider</code> \| <code>JsonRpcSigner</code> | <p>The Web3 provider or signer.</p> |
412
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the pool.</p> |
413
+ | poolType | <code>POOL\_TYPE</code> | <p>The type of the pool.</p> |
414
+
415
+ <a name="ApprovalResult"></a>
416
+
417
+ ## ApprovalResult : <code>Object</code>
418
+ <p>Object representing the response to the underwriting approval request.</p>
419
+
420
+ **Kind**: global typedef
421
+ <a name="EAPayload"></a>
422
+
423
+ ## EAPayload : <code>Object</code>
424
+ <p>Object representing an invoice payload for underwriting approval.</p>
425
+
426
+ **Kind**: global typedef
427
+ <a name="CreditEventPayload"></a>
428
+
429
+ ## CreditEventPayload : <code>Object</code>
430
+ <p>Represents the payload of a credit event.</p>
431
+
432
+ **Kind**: global typedef
package/README.md CHANGED
@@ -20,12 +20,16 @@ For extensive documentation on the different functions offered please refer to t
20
20
  - Hooks
21
21
  - React hooks for fetching ethers.js Contract instances of Huma contracts
22
22
  - Helpers
23
- - Helper functions for fetching ethers.js Contract instances of Huma contracts
23
+ - `ERC20TransferableReceivableContractHelper` fetches ERC20TransferableReceivable contract instances, which Huma uses for its Request Network integration
24
+ - `RealWorldReceivableContractHelper` fetches RealWorldReceivable contract instances, which Huma uses to power pool loan tapes
25
+ - `PoolContractHelper` helper function for interacting with Huma's pool contracts, including drawdown and payback
24
26
 
25
27
  ## Examples
26
28
 
27
- To see how the Huma SDK can be used, feel free to use our interactive example in the huma-widgets package.
29
+ To see how the Huma SDK can be used, feel free to use our interactive example in the `huma-widgets` package.
28
30
 
29
- 1. Open up the huma-widgets package in your terminal
30
- 2. Run yarn cosmos
31
- 3. Open up localhost:8000 in your browser and navigate to the SDKTesting fixture
31
+ 1. Open up the `huma-widgets` package in your terminal
32
+ 2. Run `yarn cosmos`
33
+ 3. Open up localhost:8000 in your browser and navigate to the SDKTesting fixture
34
+
35
+ If you're looking for nodeJS script integrations, go to our `packages/examples` folder and view the examples scripts provided there.
@@ -0,0 +1,40 @@
1
+ import { GraphQLClient } from 'graphql-request';
2
+ export type Maybe<T> = T | null;
3
+ export type InputMaybe<T> = Maybe<T>;
4
+ export type Exact<T extends {
5
+ [key: string]: unknown;
6
+ }> = {
7
+ [K in keyof T]: T[K];
8
+ };
9
+ export type MakeOptional<T, K extends keyof T> = Omit<T, K> & {
10
+ [SubKey in K]?: Maybe<T[SubKey]>;
11
+ };
12
+ export type MakeMaybe<T, K extends keyof T> = Omit<T, K> & {
13
+ [SubKey in K]: Maybe<T[SubKey]>;
14
+ };
15
+ /** All built-in and custom scalars, mapped to their actual values */
16
+ export type Scalars = {
17
+ ID: string;
18
+ String: string;
19
+ Boolean: boolean;
20
+ Int: number;
21
+ Float: number;
22
+ };
23
+ export type Receivable = {
24
+ __typename?: 'Receivable';
25
+ creationDate?: Maybe<Scalars['String']>;
26
+ currencyCode?: Maybe<Scalars['String']>;
27
+ id?: Maybe<Scalars['String']>;
28
+ lastUpdate?: Maybe<Scalars['String']>;
29
+ maturityDate?: Maybe<Scalars['String']>;
30
+ owner?: Maybe<Scalars['String']>;
31
+ paidAmount?: Maybe<Scalars['String']>;
32
+ pool?: Maybe<Scalars['String']>;
33
+ receivableAmount?: Maybe<Scalars['String']>;
34
+ status?: Maybe<Scalars['String']>;
35
+ tokenId?: Maybe<Scalars['String']>;
36
+ uri?: Maybe<Scalars['String']>;
37
+ };
38
+ export type SdkFunctionWrapper = <T>(action: (requestHeaders?: Record<string, string>) => Promise<T>, operationName: string, operationType?: string) => Promise<T>;
39
+ export declare function getSdk(client: GraphQLClient, withWrapper?: SdkFunctionWrapper): {};
40
+ export type Sdk = ReturnType<typeof getSdk>;
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getSdk = void 0;
4
+ const defaultWrapper = (action, _operationName, _operationType) => action();
5
+ function getSdk(client, withWrapper = defaultWrapper) {
6
+ return {};
7
+ }
8
+ exports.getSdk = getSdk;
9
+ //# sourceMappingURL=generatedTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generatedTypes.js","sourceRoot":"","sources":["../../../src/graphql/generatedTypes.ts"],"names":[],"mappings":";;;AA8CA,MAAM,cAAc,GAAuB,CACzC,MAAM,EACN,cAAc,EACd,cAAc,EACd,EAAE,CAAC,MAAM,EAAE,CAAA;AAEb,SAAgB,MAAM,CACpB,MAAqB,EACrB,cAAkC,cAAc;IAEhD,OAAO,EAAE,CAAA;AACX,CAAC;AALD,wBAKC"}
@@ -0,0 +1 @@
1
+ export * from './generatedTypes';
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./generatedTypes"), exports);
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/graphql/index.ts"],"names":[],"mappings":";;;AAAA,2DAAgC"}
@@ -1,5 +1,6 @@
1
- import { Contract, ethers } from 'ethers';
1
+ import { BigNumberish, Contract, ethers } from 'ethers';
2
2
  import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
3
+ import { TransactionResponse } from '@ethersproject/providers';
3
4
  /**
4
5
  * Returns an ethers contract instance for a Huma pool contract
5
6
  *
@@ -10,3 +11,5 @@ import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
10
11
  * @returns {Contract | null} A contract instance for the Pool contract or null if it could not be found.
11
12
  */
12
13
  export declare function getPoolContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): Contract | null;
14
+ export declare function drawdownFromPool(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, drawdownAmount: BigNumberish): Promise<TransactionResponse>;
15
+ export declare function makePaymentToPool(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, paymentAmount: BigNumberish): Promise<TransactionResponse>;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getPoolContract = void 0;
3
+ exports.makePaymentToPool = exports.drawdownFromPool = exports.getPoolContract = void 0;
4
4
  const utils_1 = require("../utils");
5
5
  /**
6
6
  * Returns an ethers contract instance for a Huma pool contract
@@ -18,4 +18,22 @@ function getPoolContract(signerOrProvider, chainId, poolName, poolType) {
18
18
  return (0, utils_1.getContract)(poolInfo.pool, poolInfo.poolAbi, signerOrProvider);
19
19
  }
20
20
  exports.getPoolContract = getPoolContract;
21
+ function drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount) {
22
+ const poolContract = getPoolContract(signer, chainId, poolName, poolType);
23
+ if (!poolContract) {
24
+ throw new Error('Could not find pool contract');
25
+ }
26
+ // TODO: Generate typechain for pool contract
27
+ return poolContract.drawdown(drawdownAmount);
28
+ }
29
+ exports.drawdownFromPool = drawdownFromPool;
30
+ async function makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount) {
31
+ const poolContract = getPoolContract(signer, chainId, poolName, poolType);
32
+ if (!poolContract) {
33
+ throw new Error('Could not find pool contract');
34
+ }
35
+ // TODO: Generate typechain for pool contract
36
+ return poolContract.makePayment(await signer.getAddress(), paymentAmount);
37
+ }
38
+ exports.makePaymentToPool = makePaymentToPool;
21
39
  //# sourceMappingURL=PoolContractHelper.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":";;;AAIA,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;AAED,SAAgB,gBAAgB,CAC9B,MAAqB,EACrB,OAAe,EACf,QAAmB,EACnB,QAAmB,EACnB,cAA4B;IAE5B,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAEzE,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;KAChD;IAED,6CAA6C;IAC7C,OAAO,YAAY,CAAC,QAAQ,CAAC,cAAc,CAAC,CAAA;AAC9C,CAAC;AAfD,4CAeC;AAEM,KAAK,UAAU,iBAAiB,CACrC,MAAqB,EACrB,OAAe,EACf,QAAmB,EACnB,QAAmB,EACnB,aAA2B;IAE3B,MAAM,YAAY,GAAG,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAEzE,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;KAChD;IAED,6CAA6C;IAC7C,OAAO,YAAY,CAAC,WAAW,CAAC,MAAM,MAAM,CAAC,UAAU,EAAE,EAAE,aAAa,CAAC,CAAA;AAC3E,CAAC;AAfD,8CAeC"}
@@ -1,7 +1,5 @@
1
1
  import { FundResponse, UploadResponse } from '@bundlr-network/client/build/common/types';
2
2
  import { Web3Provider } from '@ethersproject/providers';
3
- import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
4
- import { BigNumber } from 'ethers';
5
3
  /**
6
4
  * The configuration for Bundlr network instances
7
5
  *
@@ -38,18 +36,6 @@ export declare function getBundlrNetworkConfig(chainId: number): BundlrConfig;
38
36
  * @returns {Promise<FundResponse>} - The fund response.
39
37
  */
40
38
  declare function prefundBundlr(config: BundlrConfig, signer: any, amount: number): Promise<FundResponse>;
41
- /**
42
- * Get the running balance on Bundlr network, in atomic units (the smallest unit of a given currency)
43
- *
44
- * @async
45
- * @function
46
- * @memberof ArweaveService
47
- * @param {BundlrConfig} config - The configuration for the Bundlr network.
48
- * @param {any} signer - The wallet to send funds from. This can be either a web3 signer or a private key string.
49
- * @param {number} amount - The amount to fund, denoted in whatever currency specified by the config.
50
- * @returns {Promise<FundResponse>} - The fund response.
51
- */
52
- declare function getBundlrBalance(config: BundlrConfig, signer: any): Promise<BigNumber>;
53
39
  /**
54
40
  * Store data on ARWeave using the Bundlr Network.
55
41
  *
@@ -77,19 +63,16 @@ declare function storeData(config: BundlrConfig, signerOrPrivateKey: Web3Provide
77
63
  * @function
78
64
  * @memberof ArweaveService
79
65
  * @param {number} chainId - The chain ID.
80
- * @param {POOL_NAME} poolName - The pool name tag to query.
81
- * @param {POOL_TYPE} poolType - The pool type tag to query.
82
66
  * @param {string} sender - The sender tag to query.
83
67
  * @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
84
68
  * @returns {Promise<any>} Promise resolving with the queried data.
85
69
  */
86
- declare function queryForMetadata(chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, sender: string, referenceId: string): Promise<string | null>;
70
+ declare function queryForMetadata(chainId: number, sender: string, referenceId: string): Promise<string | null>;
87
71
  /**
88
72
  * An object that contains functions to interact with Huma-related data stored on ARWeave
89
73
  * @namespace ARWeaveService
90
74
  */
91
75
  export declare const ARWeaveService: {
92
- getBundlrBalance: typeof getBundlrBalance;
93
76
  queryForMetadata: typeof queryForMetadata;
94
77
  storeData: typeof storeData;
95
78
  prefundBundlr: typeof prefundBundlr;