@huma-finance/sdk 0.0.29 → 0.0.30

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.
package/API.md CHANGED
@@ -11,6 +11,8 @@
11
11
  <dd><p>An object that contains functions to interact with Huma's receivables.</p></dd>
12
12
  <dt><a href="#SubgraphService">SubgraphService</a> : <code>object</code></dt>
13
13
  <dd><p>An object that contains functions to interact with Huma's Subgraph storage.</p></dd>
14
+ <dt><a href="#ARWeaveService">ARWeaveService</a> : <code>object</code></dt>
15
+ <dd><p>An object that contains functions to interact with Huma-related data stored on ARWeave</p></dd>
14
16
  </dl>
15
17
 
16
18
  ## Functions
@@ -23,10 +25,17 @@
23
25
  associated with the given pool name on the current chain.</p></dd>
24
26
  <dt><a href="#getPoolContract">getPoolContract(signerOrProvider, chainId, poolName, poolType)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
25
27
  <dd><p>Returns an ethers contract instance for a Huma pool contract</p></dd>
26
- <dt><a href="#drawdownFromPool">drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, gasOpts)</a> ⇒ <code>Promise.&lt;TransactionResponse&gt;</code></dt>
27
- <dd><p>Calls drawdown on a Huma pool contract</p></dd>
28
- <dt><a href="#makePaymentToPool">makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount, gasOpts)</a> ⇒ <code>Promise.&lt;TransactionResponse&gt;</code></dt>
28
+ <dt><a href="#getCreditRecord">getCreditRecord(address, signerOrProvider, chainId, poolName, poolType)</a> ⇒ <code>Promise.&lt;CreditRecord&gt;</code></dt>
29
+ <dd><p>Gets the credit record of a wallet in a Huma pool. Denominated in the ERC20 tokens of the pool.</p></dd>
30
+ <dt><a href="#getTotalDue">getTotalDue(address, signerOrProvider, chainId, poolName, poolType)</a> ⇒ <code>Promise.&lt;BigNumber&gt;</code></dt>
31
+ <dd><p>Gets the total due for a Huma pool of the given wallet. Denominated in the ERC20 tokens of the pool.</p></dd>
32
+ <dt><a href="#drawdownFromPool">drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, [gasOpts])</a> ⇒ <code>Promise.&lt;TransactionResponse&gt;</code></dt>
29
33
  <dd><p>Calls drawdown on a Huma pool contract</p></dd>
34
+ <dt><a href="#makePaymentToPool">makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount, [gasOpts])</a> ⇒ <code>Promise.&lt;TransactionResponse&gt;</code></dt>
35
+ <dd><p>Calls makePayment on a Huma pool contract. If the pool does not have sufficient allowance to complete the operation,
36
+ attempt to first increase the allowance of the pool.</p></dd>
37
+ <dt><a href="#approvePoolAllowance">approvePoolAllowance(signer, chainId, poolName, poolType, allowanceAmount, [gasOpts])</a> ⇒ <code>Promise.&lt;TransactionResponse&gt;</code></dt>
38
+ <dd><p>Approves an allowance for a Huma pool contract, which is required to do certain actions (e.g. makePayment)</p></dd>
30
39
  <dt><a href="#getRealWorldReceivableContract">getRealWorldReceivableContract(signerOrProvider, chainId)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
31
40
  <dd><p>Returns an ethers contract instance for the RealWorldReceivable contract
32
41
  associated with the given pool name on the current chain.</p></dd>
@@ -38,11 +47,14 @@ associated with the given pool name on the current chain.</p></dd>
38
47
  <dt><a href="#useRealWorldReceivableContract">useRealWorldReceivableContract(signerOrProvider, chainId)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
39
48
  <dd><p>A react hook that returns an ethers contract instance for the RealWorldReceivable contract
40
49
  associated with the given pool name on the current chain.</p></dd>
50
+ <dt><a href="#preapprove">preapprove(payload, chainId)</a> ⇒ <code>Promise.&lt;Approval&gt;</code></dt>
51
+ <dd><p>Checks whether or not a credit underwriting request to Huma's EAVerse would be approved.
52
+ Note that this does not approve a creditline in Huma's pools and an approve call is still required.</p></dd>
41
53
  <dt><a href="#getChainIdFromJsonSignerOrProvider">getChainIdFromJsonSignerOrProvider(signerOrProvider)</a> ⇒ <code>number</code></dt>
42
54
  <dd><p>Get the chain ID from a signer or provider object.</p></dd>
43
55
  <dt><a href="#getChainIdFromSignerOrProvider">getChainIdFromSignerOrProvider(signerOrProvider)</a> ⇒ <code>number</code></dt>
44
56
  <dd><p>Get the chain ID from a signer or provider object.</p></dd>
45
- <dt><a href="#getPoolInfo">getPoolInfo(signerOrProvider, poolName, poolType)</a> ⇒ <code>PoolInfoType</code> | <code>undefined</code></dt>
57
+ <dt><a href="#getPoolInfo">getPoolInfo(poolName, poolType)</a> ⇒ <code>PoolInfoType</code> | <code>undefined</code></dt>
46
58
  <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>
47
59
  </dl>
48
60
 
@@ -128,6 +140,24 @@ associated with the given pool name on the current chain.</p></dd>
128
140
  <p>An object that contains functions to interact with Huma's EAVerse service.</p>
129
141
 
130
142
  **Kind**: global namespace
143
+ <a name="EAService.approve"></a>
144
+
145
+ ### EAService.approve(payload, chainId) ⇒ <code>Promise.&lt;Approval&gt;</code>
146
+ <p>Submits a credit underwriting request to Huma's EAVerse. This approves a creditline
147
+ in Huma's pools that can be drawn down by the borrower.</p>
148
+
149
+ **Kind**: static method of [<code>EAService</code>](#EAService)
150
+ **Returns**: <code>Promise.&lt;Approval&gt;</code> - <p>Promise that returns the approval on success.</p>
151
+ **Throws**:
152
+
153
+ - <code>EARejectionError</code> <p>If the underwrite approval is rejected.</p>
154
+
155
+
156
+ | Param | Type | Description |
157
+ | --- | --- | --- |
158
+ | payload | [<code>EAPayload</code>](#EAPayload) | <p>The payload for the underwrite approval.</p> |
159
+ | chainId | <code>number</code> | <p>The chain ID.</p> |
160
+
131
161
  <a name="ReceivableService"></a>
132
162
 
133
163
  ## ReceivableService : <code>object</code>
@@ -136,14 +166,14 @@ associated with the given pool name on the current chain.</p></dd>
136
166
  **Kind**: global namespace
137
167
 
138
168
  * [ReceivableService](#ReceivableService) : <code>object</code>
139
- * [.declareReceivablePaymentByReferenceId(signer, referenceId, paymentAmount)](#ReceivableService.declareReceivablePaymentByReferenceId) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
140
- * [.declareReceivablePaymentByTokenId(signer, receivableTokenId, paymentAmount)](#ReceivableService.declareReceivablePaymentByTokenId) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
141
- * [.createReceivable(signer, poolName, poolType, currencyCode, receivableAmount, maturityDate, uri, gasOpts)](#ReceivableService.createReceivable) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
169
+ * [.declareReceivablePaymentByReferenceId(signer, referenceId, paymentAmount, [gasOpts])](#ReceivableService.declareReceivablePaymentByReferenceId) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
170
+ * [.declareReceivablePaymentByTokenId(signer, receivableTokenId, paymentAmount, [gasOpts])](#ReceivableService.declareReceivablePaymentByTokenId) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
171
+ * [.createReceivable(signer, poolName, poolType, currencyCode, receivableAmount, maturityDate, uri, [gasOpts])](#ReceivableService.createReceivable) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
142
172
  * [.createReceivableWithMetadata(signerOrProvider, privateKey, chainId, recipient, poolName, poolType, currencyCode, receivableAmount, maturityDate, metadata, referenceId, extraTags, [lazyFund], [gasOpts])](#ReceivableService.createReceivableWithMetadata) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
143
173
 
144
174
  <a name="ReceivableService.declareReceivablePaymentByReferenceId"></a>
145
175
 
146
- ### ReceivableService.declareReceivablePaymentByReferenceId(signer, referenceId, paymentAmount) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
176
+ ### ReceivableService.declareReceivablePaymentByReferenceId(signer, referenceId, paymentAmount, [gasOpts]) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
147
177
  <p>Declares a payment on a RealWorldReceivable given a reference ID of the receivable, which was used as an index for ARWeave data.</p>
148
178
 
149
179
  **Kind**: static method of [<code>ReceivableService</code>](#ReceivableService)
@@ -156,10 +186,11 @@ associated with the given pool name on the current chain.</p></dd>
156
186
  | signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction. Note only the receivable owner can pay the receivable.</p> |
157
187
  | referenceId | <code>string</code> | <p>An internal identifier value added as a tag on ARWeave</p> |
158
188
  | paymentAmount | <code>number</code> | <p>The amount to declare paid to the receivable.</p> |
189
+ | [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
159
190
 
160
191
  <a name="ReceivableService.declareReceivablePaymentByTokenId"></a>
161
192
 
162
- ### ReceivableService.declareReceivablePaymentByTokenId(signer, receivableTokenId, paymentAmount) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
193
+ ### ReceivableService.declareReceivablePaymentByTokenId(signer, receivableTokenId, paymentAmount, [gasOpts]) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
163
194
  <p>Declares a payment on a RealWorldReceivable given a tokenID of the receivable.</p>
164
195
 
165
196
  **Kind**: static method of [<code>ReceivableService</code>](#ReceivableService)
@@ -178,10 +209,11 @@ associated with the given pool name on the current chain.</p></dd>
178
209
  | signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction. Note only the receivable owner can pay the receivable.</p> |
179
210
  | receivableTokenId | <code>BigNumberish</code> | <p>The ID of the receivable token to pay.</p> |
180
211
  | paymentAmount | <code>number</code> | <p>The amount to pay the receivable.</p> |
212
+ | [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
181
213
 
182
214
  <a name="ReceivableService.createReceivable"></a>
183
215
 
184
- ### ReceivableService.createReceivable(signer, poolName, poolType, currencyCode, receivableAmount, maturityDate, uri, gasOpts) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
216
+ ### ReceivableService.createReceivable(signer, poolName, poolType, currencyCode, receivableAmount, maturityDate, uri, [gasOpts]) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
185
217
  <p>Creates a new RealWorldReceivable token on the given chain of the signer</p>
186
218
 
187
219
  **Kind**: static method of [<code>ReceivableService</code>](#ReceivableService)
@@ -204,7 +236,7 @@ associated with the given pool name on the current chain.</p></dd>
204
236
  | receivableAmount | <code>number</code> | <p>The amount of the receivable token to mint.</p> |
205
237
  | maturityDate | <code>number</code> | <p>The maturity date of the receivable token, in UNIX timestamp format.</p> |
206
238
  | uri | <code>string</code> | <p>The URI of the receivable token metadata.</p> |
207
- | gasOpts | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
239
+ | [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
208
240
 
209
241
  <a name="ReceivableService.createReceivableWithMetadata"></a>
210
242
 
@@ -271,7 +303,7 @@ associated with the given pool name on the current chain.</p></dd>
271
303
  | chainId | <code>number</code> | <p>The ID of the chain.</p> |
272
304
  | poolName | <code>POOL\_NAME</code> | <p>The name of the pool.</p> |
273
305
  | poolType | <code>POOL\_TYPE</code> | <p>The type of the pool.</p> |
274
- | event | <code>Array.&lt;string&gt;</code> | <p>The event types to filter by.</p> |
306
+ | event | <code>Array.&lt;number&gt;</code> | <p>The event types to filter by.</p> |
275
307
 
276
308
  <a name="SubgraphService.getLastFactorizedAmountFromPool"></a>
277
309
 
@@ -288,6 +320,12 @@ associated with the given pool name on the current chain.</p></dd>
288
320
  | poolName | <code>POOL\_NAME</code> | <p>The name of the pool.</p> |
289
321
  | poolType | <code>POOL\_TYPE</code> | <p>The type of the pool.</p> |
290
322
 
323
+ <a name="ARWeaveService"></a>
324
+
325
+ ## ARWeaveService : <code>object</code>
326
+ <p>An object that contains functions to interact with Huma-related data stored on ARWeave</p>
327
+
328
+ **Kind**: global namespace
291
329
  <a name="defaultWrapper"></a>
292
330
 
293
331
  ## defaultWrapper()
@@ -323,9 +361,64 @@ associated with the given pool name on the current chain.</p>
323
361
  | poolName | <code>POOL\_NAME</code> | <p>The name of the pool contract to get.</p> |
324
362
  | poolType | <code>POOL\_TYPE</code> | <p>The type of the pool contract to get.</p> |
325
363
 
364
+ <a name="getCreditRecord"></a>
365
+
366
+ ## getCreditRecord(address, signerOrProvider, chainId, poolName, poolType) ⇒ <code>Promise.&lt;CreditRecord&gt;</code>
367
+ <p>Gets the credit record of a wallet in a Huma pool. Denominated in the ERC20 tokens of the pool.</p>
368
+
369
+ **Kind**: global function
370
+ **Returns**: <code>Promise.&lt;CreditRecord&gt;</code> - <ul>
371
+ <li>A Promise of the transaction response.</li>
372
+ </ul>
373
+
374
+ | Param | Type | Description |
375
+ | --- | --- | --- |
376
+ | address | <code>string</code> | <p>The address to lookup.</p> |
377
+ | signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The signer or provider used to read data.</p> |
378
+ | chainId | <code>number</code> | <p>The chain ID of the pool. Used to lookup the pool address.</p> |
379
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool. Used to lookup the pool address.</p> |
380
+ | poolType | <code>POOL\_TYPE</code> | <p>The type of the credit pool. Used to lookup the pool address.</p> |
381
+
382
+ <a name="getCreditRecord.CreditRecord"></a>
383
+
384
+ ### getCreditRecord.CreditRecord : <code>Object</code>
385
+ <p>Return type of getCreditRecord</p>
386
+
387
+ **Kind**: static typedef of [<code>getCreditRecord</code>](#getCreditRecord)
388
+ **Properties**
389
+
390
+ | Name | Type | Description |
391
+ | --- | --- | --- |
392
+ | unbilledPrincipal | <code>BigNumber</code> | <p>The amount of principal not included in the bill</p> |
393
+ | dueDate | <code>BigNumber</code> | <p>Unix timestamp due date of the next payment</p> |
394
+ | correction | <code>BigNumber</code> | <p>the adjustment of interest over or under-counted because of drawdown or principal payment in the middle of a billing period</p> |
395
+ | totalDue | <code>BigNumber</code> | <p>The due amount of the next payment</p> |
396
+ | feesAndInterestDue | <code>BigNumber</code> | <p>Interest and fees due for the next payment</p> |
397
+ | missedPeriods | <code>number</code> | <h1>of consecutive missed payments, for default processing</h1> |
398
+ | remainingPeriods | <code>number</code> | <h1>of payment periods until the maturity of the credit line</h1> |
399
+ | state | <code>number</code> | <p>status of the credit line. For more info: https://github.com/00labs/huma-contracts/blob/b075a8f957de281e0885e37dbd72a422b6a54a38/contracts/libraries/BaseStructs.sol#L49</p> |
400
+
401
+ <a name="getTotalDue"></a>
402
+
403
+ ## getTotalDue(address, signerOrProvider, chainId, poolName, poolType) ⇒ <code>Promise.&lt;BigNumber&gt;</code>
404
+ <p>Gets the total due for a Huma pool of the given wallet. Denominated in the ERC20 tokens of the pool.</p>
405
+
406
+ **Kind**: global function
407
+ **Returns**: <code>Promise.&lt;BigNumber&gt;</code> - <ul>
408
+ <li>A Promise of the transaction response.</li>
409
+ </ul>
410
+
411
+ | Param | Type | Description |
412
+ | --- | --- | --- |
413
+ | address | <code>string</code> | <p>The address to lookup.</p> |
414
+ | signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The signer or provider used to read data.</p> |
415
+ | chainId | <code>number</code> | <p>The chain ID of the pool. Used to lookup the pool address.</p> |
416
+ | poolName | <code>POOL\_NAME</code> | <p>The name of the credit pool. Used to lookup the pool address.</p> |
417
+ | poolType | <code>POOL\_TYPE</code> | <p>The type of the credit pool. Used to lookup the pool address.</p> |
418
+
326
419
  <a name="drawdownFromPool"></a>
327
420
 
328
- ## drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, gasOpts) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
421
+ ## drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, [gasOpts]) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
329
422
  <p>Calls drawdown on a Huma pool contract</p>
330
423
 
331
424
  **Kind**: global function
@@ -340,12 +433,13 @@ associated with the given pool name on the current chain.</p>
340
433
  | 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> |
341
434
  | 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> |
342
435
  | drawdownAmount | <code>BigNumberish</code> | <p>The amount of tokens to withdraw, denominated in the ERC20 tokens of the pool.</p> |
343
- | gasOpts | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
436
+ | [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
344
437
 
345
438
  <a name="makePaymentToPool"></a>
346
439
 
347
- ## makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount, gasOpts) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
348
- <p>Calls drawdown on a Huma pool contract</p>
440
+ ## makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount, [gasOpts]) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
441
+ <p>Calls makePayment on a Huma pool contract. If the pool does not have sufficient allowance to complete the operation,
442
+ attempt to first increase the allowance of the pool.</p>
349
443
 
350
444
  **Kind**: global function
351
445
  **Returns**: <code>Promise.&lt;TransactionResponse&gt;</code> - <ul>
@@ -359,7 +453,26 @@ associated with the given pool name on the current chain.</p>
359
453
  | 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> |
360
454
  | 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> |
361
455
  | paymentAmount | <code>BigNumberish</code> | <p>The amount of tokens to payback, denominated in the ERC20 tokens of the pool.</p> |
362
- | gasOpts | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
456
+ | [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
457
+
458
+ <a name="approvePoolAllowance"></a>
459
+
460
+ ## approvePoolAllowance(signer, chainId, poolName, poolType, allowanceAmount, [gasOpts]) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
461
+ <p>Approves an allowance for a Huma pool contract, which is required to do certain actions (e.g. makePayment)</p>
462
+
463
+ **Kind**: global function
464
+ **Returns**: <code>Promise.&lt;TransactionResponse&gt;</code> - <ul>
465
+ <li>A Promise of the transaction response.</li>
466
+ </ul>
467
+
468
+ | Param | Type | Description |
469
+ | --- | --- | --- |
470
+ | signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction.</p> |
471
+ | chainId | <code>number</code> | <p>The chain ID of the pool to call drawdown on. Used to lookup the pool address.</p> |
472
+ | 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> |
473
+ | 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> |
474
+ | allowanceAmount | <code>BigNumberish</code> | <p>The amount of tokens to payback, denominated in the ERC20 tokens of the pool.</p> |
475
+ | [gasOpts] | <code>Overrides</code> | <p>The gas options to use for the transaction.</p> |
363
476
 
364
477
  <a name="getRealWorldReceivableContract"></a>
365
478
 
@@ -418,6 +531,20 @@ associated with the given pool name on the current chain.</p>
418
531
  | signerOrProvider | <code>ethers.providers.Provider</code> \| <code>ethers.Signer</code> | <p>The provider or signer instance to use for the contract.</p> |
419
532
  | chainId | <code>number</code> | <p>The chain id where the contract instance exists</p> |
420
533
 
534
+ <a name="preapprove"></a>
535
+
536
+ ## preapprove(payload, chainId) ⇒ <code>Promise.&lt;Approval&gt;</code>
537
+ <p>Checks whether or not a credit underwriting request to Huma's EAVerse would be approved.
538
+ Note that this does not approve a creditline in Huma's pools and an approve call is still required.</p>
539
+
540
+ **Kind**: global function
541
+ **Returns**: <code>Promise.&lt;Approval&gt;</code> - <p>Promise that returns the approval on success.</p>
542
+
543
+ | Param | Type | Description |
544
+ | --- | --- | --- |
545
+ | payload | <code>EAPreapprovalPayload</code> | <p>The payload for the underwrite approval.</p> |
546
+ | chainId | <code>number</code> | <p>The chain ID.</p> |
547
+
421
548
  <a name="getChainIdFromJsonSignerOrProvider"></a>
422
549
 
423
550
  ## getChainIdFromJsonSignerOrProvider(signerOrProvider) ⇒ <code>number</code>
@@ -448,7 +575,7 @@ associated with the given pool name on the current chain.</p>
448
575
 
449
576
  <a name="getPoolInfo"></a>
450
577
 
451
- ## getPoolInfo(signerOrProvider, poolName, poolType) ⇒ <code>PoolInfoType</code> \| <code>undefined</code>
578
+ ## getPoolInfo(poolName, poolType) ⇒ <code>PoolInfoType</code> \| <code>undefined</code>
452
579
  <p>Returns the pool info based on the provided pool name and type, using the same chain ID as the provider/signer given</p>
453
580
 
454
581
  **Kind**: global function
@@ -458,7 +585,6 @@ associated with the given pool name on the current chain.</p>
458
585
 
459
586
  | Param | Type | Description |
460
587
  | --- | --- | --- |
461
- | signerOrProvider | <code>JsonRpcProvider</code> \| <code>JsonRpcSigner</code> | <p>The Web3 provider or signer.</p> |
462
588
  | poolName | <code>POOL\_NAME</code> | <p>The name of the pool.</p> |
463
589
  | poolType | <code>POOL\_TYPE</code> | <p>The type of the pool.</p> |
464
590
 
@@ -1,4 +1,4 @@
1
- import { FundResponse, UploadResponse } from '@bundlr-network/client/build/common/types';
1
+ import type { FundResponse, UploadResponse } from '@bundlr-network/client/build/cjs/common/types';
2
2
  import { Web3Provider } from '@ethersproject/providers';
3
3
  /**
4
4
  * The configuration for Bundlr network instances
@@ -24,18 +24,31 @@ export type BundlrConfig = {
24
24
  * @returns {BundlrConfig} - The configuration for the Bundlr network.
25
25
  */
26
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>;
27
38
  /**
28
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.
29
42
  *
30
43
  * @async
31
44
  * @function
32
45
  * @memberof ArweaveService
33
46
  * @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.
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)
36
49
  * @returns {Promise<FundResponse>} - The fund response.
37
50
  */
38
- declare function prefundBundlr(config: BundlrConfig, signer: any, amount: number): Promise<FundResponse>;
51
+ declare function prefundBundlr(config: BundlrConfig, signer: string, amount: number): Promise<FundResponse>;
39
52
  /**
40
53
  * Store data on ARWeave using the Bundlr Network.
41
54
  *
@@ -77,5 +90,6 @@ export declare const ARWeaveService: {
77
90
  storeData: typeof storeData;
78
91
  prefundBundlr: typeof prefundBundlr;
79
92
  getBundlrNetworkConfig: typeof getBundlrNetworkConfig;
93
+ getBundlrInstance: typeof getBundlrInstance;
80
94
  };
81
95
  export {};
@@ -24,7 +24,7 @@ function getBundlrNetworkConfig(chainId) {
24
24
  return {
25
25
  nodeUrl: 'https://devnet.bundlr.network',
26
26
  currency: 'matic',
27
- providerUrl: 'https://rpc-mumbai.matic.today',
27
+ providerUrl: 'https://rpc.ankr.com/polygon_mumbai',
28
28
  };
29
29
  case 137: // Matic
30
30
  return {
@@ -39,15 +39,36 @@ function getBundlrNetworkConfig(chainId) {
39
39
  }
40
40
  }
41
41
  exports.getBundlrNetworkConfig = getBundlrNetworkConfig;
42
+ /**
43
+ * Get a Bundlr instance for a specific network
44
+ *
45
+ * @async
46
+ * @function
47
+ * @memberof ArweaveService
48
+ * @param {BundlrConfig} config - The configuration for the Bundlr network.
49
+ * @param {string} signer - The private key of the wallet to use Bundlr with.
50
+ * @returns The Bundlr instance
51
+ */
52
+ async function getBundlrInstance(config, signer) {
53
+ const bundlr = new client_1.default(config.nodeUrl, config.currency, signer, config.providerUrl
54
+ ? {
55
+ providerUrl: config.providerUrl,
56
+ }
57
+ : undefined);
58
+ await bundlr.ready();
59
+ return bundlr;
60
+ }
42
61
  /**
43
62
  * Prefund the Bundlr network with the specified amount. Required if not lazy funding.
63
+ * Important note: The amount is denominated in the base unit of currency for that network.
64
+ * If you want to upload 5 Matic to the Bundlr node, pass in an amount of 5.
44
65
  *
45
66
  * @async
46
67
  * @function
47
68
  * @memberof ArweaveService
48
69
  * @param {BundlrConfig} config - The configuration for the Bundlr network.
49
- * @param {any} signer - The wallet to send funds from. This can be either a web3 signer or a private key string.
50
- * @param {number} amount - The amount to fund, denoted in whatever currency specified by the config.
70
+ * @param {string} signer - The private key of the wallet to send funds from.
71
+ * @param {number} amount - The amount to fund, denoted in whatever currency specified by the config (e.g. MATIC, ETH)
51
72
  * @returns {Promise<FundResponse>} - The fund response.
52
73
  */
53
74
  async function prefundBundlr(config,
@@ -59,7 +80,9 @@ signer, amount) {
59
80
  }
60
81
  : undefined);
61
82
  await bundlr.ready();
62
- return bundlr.fund(amount);
83
+ // Convert currency to its atomic units (e.g. MATIC -> wei)
84
+ const atomicAmount = bundlr.utils.toAtomic(amount);
85
+ return bundlr.fund(atomicAmount);
63
86
  }
64
87
  /**
65
88
  * Store data on ARWeave using the Bundlr Network.
@@ -88,10 +111,10 @@ async function storeData(config, signerOrPrivateKey, data, tags, lazyFund = true
88
111
  if (lazyFund) {
89
112
  const size = Buffer.byteLength(dataStr);
90
113
  const price = await bundlr.getPrice(size);
91
- // Add a buffer of 10% to account for fluctuations in the price
92
- price.multipliedBy(1.1);
93
- console.log(`Funding bundlr with ${price} ${config.currency} to upload data`);
94
- await bundlr.fund(price);
114
+ // Add a buffer of 20% to account for fluctuations in the price
115
+ const priceWithBuffer = price.multipliedBy(1.2).integerValue();
116
+ console.log(`Funding bundlr with ${priceWithBuffer} ${config.currency} to upload data`);
117
+ await bundlr.fund(priceWithBuffer);
95
118
  }
96
119
  return bundlr.upload(dataStr, { tags });
97
120
  }
@@ -142,5 +165,6 @@ exports.ARWeaveService = {
142
165
  storeData,
143
166
  prefundBundlr,
144
167
  getBundlrNetworkConfig,
168
+ getBundlrInstance,
145
169
  };
146
170
  //# sourceMappingURL=ARWeaveService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ARWeaveService.js","s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0CAAE,IAAI,0CAAE,EAAE,CAAA;AACjD,CAAC;AAED;;;GAGG;AACU,QAAA,cAAc,GAAG;IAC5B,gBAAgB;IAChB,SAAS;IACT,aAAa;IACb,sBAAsB;CACvB,CAAA"}
1
+ {"version":3,"file":"ARWeaveService.js","sourceRoot":"","sources":["../../../src/services/ARWeaveService.ts"],"names":[],"mappings":";;;;AAAA,4EAA2C;AAM3C,2EAA8C;AAkB9C;;;;;;;GAOG;AACH,SAAgB,sBAAsB,CAAC,OAAe;IACpD,QAAQ,OAAO,EAAE;QACf,KAAK,CAAC,EAAE,SAAS;YACf,OAAO;gBACL,OAAO,EAAE,+BAA+B;gBACxC,QAAQ,EAAE,UAAU;gBACpB,WAAW,EACT,8DAA8D;aACjE,CAAA;QACH,KAAK,KAAK,EAAE,SAAS;YACnB,OAAO;gBACL,OAAO,EAAE,+BAA+B;gBACxC,QAAQ,EAAE,OAAO;gBACjB,WAAW,EAAE,qCAAqC;aACnD,CAAA;QACH,KAAK,GAAG,EAAE,QAAQ;YAChB,OAAO;gBACL,OAAO,EAAE,8BAA8B;gBACvC,QAAQ,EAAE,OAAO;aAClB,CAAA;QACH;YACE,OAAO;gBACL,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,EAAE;aACb,CAAA;KACJ;AACH,CAAC;AA1BD,wDA0BC;AAED;;;;;;;;;GASG;AACH,KAAK,UAAU,iBAAiB,CAAC,MAAoB,EAAE,MAAc;IACnE,MAAM,MAAM,GAAG,IAAI,gBAAM,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,CAAA;AACf,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,KAAK,UAAU,aAAa,CAC1B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AAC,QAAQ,iBAAiB,CAC3E,CAAA;QACD,MAAM,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;KACnC;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,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;GAgBhB,CAAA;IAED,8DAA8D;IAC9D,MAAM,IAAI,GAAQ,MAAM,IAAA,yBAAO,EAAC,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;AACU,QAAA,cAAc,GAAG;IAC5B,gBAAgB;IAChB,SAAS;IACT,aAAa;IACb,sBAAsB;IACtB,iBAAiB;CAClB,CAAA"}
@@ -1,4 +1,4 @@
1
- import { FundResponse, UploadResponse } from '@bundlr-network/client/build/common/types';
1
+ import type { FundResponse, UploadResponse } from '@bundlr-network/client/build/cjs/common/types';
2
2
  import { Web3Provider } from '@ethersproject/providers';
3
3
  /**
4
4
  * The configuration for Bundlr network instances
@@ -24,18 +24,31 @@ export type BundlrConfig = {
24
24
  * @returns {BundlrConfig} - The configuration for the Bundlr network.
25
25
  */
26
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>;
27
38
  /**
28
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.
29
42
  *
30
43
  * @async
31
44
  * @function
32
45
  * @memberof ArweaveService
33
46
  * @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.
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)
36
49
  * @returns {Promise<FundResponse>} - The fund response.
37
50
  */
38
- declare function prefundBundlr(config: BundlrConfig, signer: any, amount: number): Promise<FundResponse>;
51
+ declare function prefundBundlr(config: BundlrConfig, signer: string, amount: number): Promise<FundResponse>;
39
52
  /**
40
53
  * Store data on ARWeave using the Bundlr Network.
41
54
  *
@@ -77,5 +90,6 @@ export declare const ARWeaveService: {
77
90
  storeData: typeof storeData;
78
91
  prefundBundlr: typeof prefundBundlr;
79
92
  getBundlrNetworkConfig: typeof getBundlrNetworkConfig;
93
+ getBundlrInstance: typeof getBundlrInstance;
80
94
  };
81
95
  export {};
@@ -20,7 +20,7 @@ export function getBundlrNetworkConfig(chainId) {
20
20
  return {
21
21
  nodeUrl: 'https://devnet.bundlr.network',
22
22
  currency: 'matic',
23
- providerUrl: 'https://rpc-mumbai.matic.today',
23
+ providerUrl: 'https://rpc.ankr.com/polygon_mumbai',
24
24
  };
25
25
  case 137: // Matic
26
26
  return {
@@ -34,15 +34,36 @@ export function getBundlrNetworkConfig(chainId) {
34
34
  };
35
35
  }
36
36
  }
37
+ /**
38
+ * Get a Bundlr instance for a specific network
39
+ *
40
+ * @async
41
+ * @function
42
+ * @memberof ArweaveService
43
+ * @param {BundlrConfig} config - The configuration for the Bundlr network.
44
+ * @param {string} signer - The private key of the wallet to use Bundlr with.
45
+ * @returns The Bundlr instance
46
+ */
47
+ async function getBundlrInstance(config, signer) {
48
+ const bundlr = new Bundlr(config.nodeUrl, config.currency, signer, config.providerUrl
49
+ ? {
50
+ providerUrl: config.providerUrl,
51
+ }
52
+ : undefined);
53
+ await bundlr.ready();
54
+ return bundlr;
55
+ }
37
56
  /**
38
57
  * Prefund the Bundlr network with the specified amount. Required if not lazy funding.
58
+ * Important note: The amount is denominated in the base unit of currency for that network.
59
+ * If you want to upload 5 Matic to the Bundlr node, pass in an amount of 5.
39
60
  *
40
61
  * @async
41
62
  * @function
42
63
  * @memberof ArweaveService
43
64
  * @param {BundlrConfig} config - The configuration for the Bundlr network.
44
- * @param {any} signer - The wallet to send funds from. This can be either a web3 signer or a private key string.
45
- * @param {number} amount - The amount to fund, denoted in whatever currency specified by the config.
65
+ * @param {string} signer - The private key of the wallet to send funds from.
66
+ * @param {number} amount - The amount to fund, denoted in whatever currency specified by the config (e.g. MATIC, ETH)
46
67
  * @returns {Promise<FundResponse>} - The fund response.
47
68
  */
48
69
  async function prefundBundlr(config,
@@ -54,7 +75,9 @@ signer, amount) {
54
75
  }
55
76
  : undefined);
56
77
  await bundlr.ready();
57
- return bundlr.fund(amount);
78
+ // Convert currency to its atomic units (e.g. MATIC -> wei)
79
+ const atomicAmount = bundlr.utils.toAtomic(amount);
80
+ return bundlr.fund(atomicAmount);
58
81
  }
59
82
  /**
60
83
  * Store data on ARWeave using the Bundlr Network.
@@ -83,10 +106,10 @@ async function storeData(config, signerOrPrivateKey, data, tags, lazyFund = true
83
106
  if (lazyFund) {
84
107
  const size = Buffer.byteLength(dataStr);
85
108
  const price = await bundlr.getPrice(size);
86
- // Add a buffer of 10% to account for fluctuations in the price
87
- price.multipliedBy(1.1);
88
- console.log(`Funding bundlr with ${price} ${config.currency} to upload data`);
89
- await bundlr.fund(price);
109
+ // Add a buffer of 20% to account for fluctuations in the price
110
+ const priceWithBuffer = price.multipliedBy(1.2).integerValue();
111
+ console.log(`Funding bundlr with ${priceWithBuffer} ${config.currency} to upload data`);
112
+ await bundlr.fund(priceWithBuffer);
90
113
  }
91
114
  return bundlr.upload(dataStr, { tags });
92
115
  }
@@ -137,5 +160,6 @@ export const ARWeaveService = {
137
160
  storeData,
138
161
  prefundBundlr,
139
162
  getBundlrNetworkConfig,
163
+ getBundlrInstance,
140
164
  };
141
165
  //# sourceMappingURL=ARWeaveService.js.map
@@ -1 +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,EAAE,SAAS;YACf,OAAO;gBACL,OAAO,EAAE,+BAA+B;gBACxC,QAAQ,EAAE,UAAU;gBACpB,WAAW,EACT,8DAA8D;aACjE,CAAA;QACH,KAAK,KAAK,EAAE,SAAS;YACnB,OAAO;gBACL,OAAO,EAAE,+BAA+B;gBACxC,QAAQ,EAAE,OAAO;gBACjB,WAAW,EAAE,gCAAgC;aAC9C,CAAA;QACH,KAAK,GAAG,EAAE,QAAQ;YAChB,OAAO;gBACL,OAAO,EAAE,8BAA8B;gBACvC,QAAQ,EAAE,OAAO;aAClB,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,M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