@huma-finance/sdk 0.0.12 → 0.0.13

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
@@ -16,11 +16,17 @@
16
16
  ## Functions
17
17
 
18
18
  <dl>
19
+ <dt><a href="#defaultWrapper">defaultWrapper()</a></dt>
20
+ <dd><p>All built-in and custom scalars, mapped to their actual values</p></dd>
19
21
  <dt><a href="#getERC20TransferableReceivableContract">getERC20TransferableReceivableContract(signerOrProvider, chainId)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
20
22
  <dd><p>Returns an ethers contract instance for the ERC20TransferableReceivable contract
21
23
  associated with the given pool name on the current chain.</p></dd>
22
24
  <dt><a href="#getPoolContract">getPoolContract(signerOrProvider, chainId, poolName, poolType)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
23
25
  <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>
29
+ <dd><p>Calls drawdown on a Huma pool contract</p></dd>
24
30
  <dt><a href="#getRealWorldReceivableContract">getRealWorldReceivableContract(signerOrProvider, chainId)</a> ⇒ <code>Contract</code> | <code>null</code></dt>
25
31
  <dd><p>Returns an ethers contract instance for the RealWorldReceivable contract
26
32
  associated with the given pool name on the current chain.</p></dd>
@@ -282,6 +288,12 @@ associated with the given pool name on the current chain.</p></dd>
282
288
  | poolName | <code>POOL\_NAME</code> | <p>The name of the pool.</p> |
283
289
  | poolType | <code>POOL\_TYPE</code> | <p>The type of the pool.</p> |
284
290
 
291
+ <a name="defaultWrapper"></a>
292
+
293
+ ## defaultWrapper()
294
+ <p>All built-in and custom scalars, mapped to their actual values</p>
295
+
296
+ **Kind**: global function
285
297
  <a name="getERC20TransferableReceivableContract"></a>
286
298
 
287
299
  ## getERC20TransferableReceivableContract(signerOrProvider, chainId) ⇒ <code>Contract</code> \| <code>null</code>
@@ -311,6 +323,44 @@ associated with the given pool name on the current chain.</p>
311
323
  | poolName | <code>POOL\_NAME</code> | <p>The name of the pool contract to get.</p> |
312
324
  | poolType | <code>POOL\_TYPE</code> | <p>The type of the pool contract to get.</p> |
313
325
 
326
+ <a name="drawdownFromPool"></a>
327
+
328
+ ## drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, gasOpts) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
329
+ <p>Calls drawdown on a Huma pool contract</p>
330
+
331
+ **Kind**: global function
332
+ **Returns**: <code>Promise.&lt;TransactionResponse&gt;</code> - <ul>
333
+ <li>A Promise of the transaction response.</li>
334
+ </ul>
335
+
336
+ | Param | Type | Description |
337
+ | --- | --- | --- |
338
+ | signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction.</p> |
339
+ | chainId | <code>number</code> | <p>The chain ID of the pool to call drawdown on. Used to lookup the pool address.</p> |
340
+ | 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
+ | 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
+ | 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> |
344
+
345
+ <a name="makePaymentToPool"></a>
346
+
347
+ ## makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount, gasOpts) ⇒ <code>Promise.&lt;TransactionResponse&gt;</code>
348
+ <p>Calls drawdown on a Huma pool contract</p>
349
+
350
+ **Kind**: global function
351
+ **Returns**: <code>Promise.&lt;TransactionResponse&gt;</code> - <ul>
352
+ <li>A Promise of the transaction response.</li>
353
+ </ul>
354
+
355
+ | Param | Type | Description |
356
+ | --- | --- | --- |
357
+ | signer | <code>ethers.Signer</code> | <p>The signer used to send the transaction.</p> |
358
+ | chainId | <code>number</code> | <p>The chain ID of the pool to call drawdown on. Used to lookup the pool address.</p> |
359
+ | 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
+ | 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
+ | 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> |
363
+
314
364
  <a name="getRealWorldReceivableContract"></a>
315
365
 
316
366
  ## getRealWorldReceivableContract(signerOrProvider, chainId) ⇒ <code>Contract</code> \| <code>null</code>
@@ -1,4 +1,4 @@
1
- import { BigNumberish, Contract, ethers } from 'ethers';
1
+ import { BigNumberish, Contract, Overrides, ethers } from 'ethers';
2
2
  import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
3
3
  import { TransactionResponse } from '@ethersproject/providers';
4
4
  /**
@@ -11,5 +11,31 @@ import { TransactionResponse } from '@ethersproject/providers';
11
11
  * @returns {Contract | null} A contract instance for the Pool contract or null if it could not be found.
12
12
  */
13
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>;
14
+ /**
15
+ * Calls drawdown on a Huma pool contract
16
+ *
17
+ * @async
18
+ * @function
19
+ * @param {ethers.Signer} signer - The signer used to send the transaction.
20
+ * @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
21
+ * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
22
+ * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
23
+ * @param {BigNumberish} drawdownAmount - The amount of tokens to withdraw, denominated in the ERC20 tokens of the pool.
24
+ * @param {Overrides} gasOpts - The gas options to use for the transaction.
25
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
26
+ */
27
+ export declare function drawdownFromPool(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, drawdownAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
28
+ /**
29
+ * Calls drawdown on a Huma pool contract
30
+ *
31
+ * @async
32
+ * @function
33
+ * @param {ethers.Signer} signer - The signer used to send the transaction.
34
+ * @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
35
+ * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
36
+ * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
37
+ * @param {BigNumberish} paymentAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
38
+ * @param {Overrides} gasOpts - The gas options to use for the transaction.
39
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
40
+ */
41
+ export declare function makePaymentToPool(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, paymentAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
@@ -18,22 +18,48 @@ 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) {
21
+ /**
22
+ * Calls drawdown on a Huma pool contract
23
+ *
24
+ * @async
25
+ * @function
26
+ * @param {ethers.Signer} signer - The signer used to send the transaction.
27
+ * @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
28
+ * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
29
+ * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
30
+ * @param {BigNumberish} drawdownAmount - The amount of tokens to withdraw, denominated in the ERC20 tokens of the pool.
31
+ * @param {Overrides} gasOpts - The gas options to use for the transaction.
32
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
33
+ */
34
+ function drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, gasOpts = {}) {
22
35
  const poolContract = getPoolContract(signer, chainId, poolName, poolType);
23
36
  if (!poolContract) {
24
37
  throw new Error('Could not find pool contract');
25
38
  }
26
39
  // TODO: Generate typechain for pool contract
27
- return poolContract.drawdown(drawdownAmount);
40
+ return poolContract.drawdown(drawdownAmount, gasOpts);
28
41
  }
29
42
  exports.drawdownFromPool = drawdownFromPool;
30
- async function makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount) {
43
+ /**
44
+ * Calls drawdown on a Huma pool contract
45
+ *
46
+ * @async
47
+ * @function
48
+ * @param {ethers.Signer} signer - The signer used to send the transaction.
49
+ * @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
50
+ * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
51
+ * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
52
+ * @param {BigNumberish} paymentAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
53
+ * @param {Overrides} gasOpts - The gas options to use for the transaction.
54
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
55
+ */
56
+ async function makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount, gasOpts = {}) {
31
57
  const poolContract = getPoolContract(signer, chainId, poolName, poolType);
32
58
  if (!poolContract) {
33
59
  throw new Error('Could not find pool contract');
34
60
  }
35
61
  // TODO: Generate typechain for pool contract
36
- return poolContract.makePayment(await signer.getAddress(), paymentAmount);
62
+ return poolContract.makePayment(await signer.getAddress(), paymentAmount, gasOpts);
37
63
  }
38
64
  exports.makePaymentToPool = makePaymentToPool;
39
65
  //# sourceMappingURL=PoolContractHelper.js.map
@@ -1 +1 @@
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;IAE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,UAAU,iBAAiB,CACrC,MAAqB,EACrB,OAAe,EACf,QAAmB,EACnB,QAAmB,EACnB,aAA2B,EAC3B,UAAqB,EAAE;IAEvB,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,CAC7B,MAAM,MAAM,CAAC,UAAU,EAAE,EACzB,aAAa,EACb,OAAO,CACR,CAAA;AACH,CAAC;AApBD,8CAoBC"}
@@ -104,22 +104,22 @@ async function storeData(config, signerOrPrivateKey, data, tags, lazyFund = true
104
104
  async function queryForMetadata(chainId, sender, referenceId) {
105
105
  var _a, _b, _c, _d;
106
106
  const config = getBundlrNetworkConfig(chainId);
107
- const query = (0, graphql_request_1.gql) `
108
- query ArweaveHumaMetadataQuery($sender: String!, $referenceId: String!) {
109
- transactions(
110
- owners: [$sender]
111
- tags: [
112
- { name: "appName", values: ["HumaFinance"] }
113
- { name: "referenceId", values: [$referenceId] }
114
- ]
115
- ) {
116
- edges {
117
- node {
118
- id
119
- }
120
- }
121
- }
122
- }
107
+ const query = (0, graphql_request_1.gql) `
108
+ query ArweaveHumaMetadataQuery($sender: String!, $referenceId: String!) {
109
+ transactions(
110
+ owners: [$sender]
111
+ tags: [
112
+ { name: "appName", values: ["HumaFinance"] }
113
+ { name: "referenceId", values: [$referenceId] }
114
+ ]
115
+ ) {
116
+ edges {
117
+ node {
118
+ id
119
+ }
120
+ }
121
+ }
122
+ }
123
123
  `;
124
124
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
125
125
  const data = await (0, graphql_request_1.default)(`${config.nodeUrl}/graphql`, query, {
@@ -29,16 +29,16 @@ async function declareReceivablePaymentByReferenceId(signer, referenceId, paymen
29
29
  // Get ARWeave ID
30
30
  const dataID = await ARWeaveService_1.ARWeaveService.queryForMetadata(chainId, signerAddress, referenceId);
31
31
  // Fetch receivables with the same ARWeave ID
32
- const receivablesQuery = (0, graphql_request_1.gql) `
33
- query ReceivablesByURIQuery($owner: String!, $uri: String!) {
34
- receivables(where: { owner: $owner, uri: $uri }) {
35
- ...ReceivableFields
36
- }
37
- }
38
-
39
- fragment ReceivableFields on Receivable {
40
- tokenId
41
- }
32
+ const receivablesQuery = (0, graphql_request_1.gql) `
33
+ query ReceivablesByURIQuery($owner: String!, $uri: String!) {
34
+ receivables(where: { owner: $owner, uri: $uri }) {
35
+ ...ReceivableFields
36
+ }
37
+ }
38
+
39
+ fragment ReceivableFields on Receivable {
40
+ tokenId
41
+ }
42
42
  `;
43
43
  let receivableSubgraph;
44
44
  switch (chainId) {
@@ -56,7 +56,7 @@ async function declareReceivablePaymentByReferenceId(signer, referenceId, paymen
56
56
  throw new Error('No receivables found with this ARWeave ID.');
57
57
  }
58
58
  else if (((_b = receivablesData === null || receivablesData === void 0 ? void 0 : receivablesData.receivables) === null || _b === void 0 ? void 0 : _b.length) > 1) {
59
- throw new Error(`This owner has multiple receivables with the same URI. Please burn
59
+ throw new Error(`This owner has multiple receivables with the same URI. Please burn
60
60
  unnecessary receivables or pay the correct token manually using declareReceivablePaymentByTokenId`);
61
61
  }
62
62
  const contract = (0, helpers_1.getRealWorldReceivableContract)(signer, chainId);
@@ -1,4 +1,4 @@
1
- import { BigNumberish, Contract, ethers } from 'ethers';
1
+ import { BigNumberish, Contract, Overrides, ethers } from 'ethers';
2
2
  import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
3
3
  import { TransactionResponse } from '@ethersproject/providers';
4
4
  /**
@@ -11,5 +11,31 @@ import { TransactionResponse } from '@ethersproject/providers';
11
11
  * @returns {Contract | null} A contract instance for the Pool contract or null if it could not be found.
12
12
  */
13
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>;
14
+ /**
15
+ * Calls drawdown on a Huma pool contract
16
+ *
17
+ * @async
18
+ * @function
19
+ * @param {ethers.Signer} signer - The signer used to send the transaction.
20
+ * @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
21
+ * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
22
+ * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
23
+ * @param {BigNumberish} drawdownAmount - The amount of tokens to withdraw, denominated in the ERC20 tokens of the pool.
24
+ * @param {Overrides} gasOpts - The gas options to use for the transaction.
25
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
26
+ */
27
+ export declare function drawdownFromPool(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, drawdownAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
28
+ /**
29
+ * Calls drawdown on a Huma pool contract
30
+ *
31
+ * @async
32
+ * @function
33
+ * @param {ethers.Signer} signer - The signer used to send the transaction.
34
+ * @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
35
+ * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
36
+ * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
37
+ * @param {BigNumberish} paymentAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
38
+ * @param {Overrides} gasOpts - The gas options to use for the transaction.
39
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
40
+ */
41
+ export declare function makePaymentToPool(signer: ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, paymentAmount: BigNumberish, gasOpts?: Overrides): Promise<TransactionResponse>;
@@ -14,20 +14,46 @@ export function getPoolContract(signerOrProvider, chainId, poolName, poolType) {
14
14
  return null;
15
15
  return getContract(poolInfo.pool, poolInfo.poolAbi, signerOrProvider);
16
16
  }
17
- export function drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount) {
17
+ /**
18
+ * Calls drawdown on a Huma pool contract
19
+ *
20
+ * @async
21
+ * @function
22
+ * @param {ethers.Signer} signer - The signer used to send the transaction.
23
+ * @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
24
+ * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
25
+ * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
26
+ * @param {BigNumberish} drawdownAmount - The amount of tokens to withdraw, denominated in the ERC20 tokens of the pool.
27
+ * @param {Overrides} gasOpts - The gas options to use for the transaction.
28
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
29
+ */
30
+ export function drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, gasOpts = {}) {
18
31
  const poolContract = getPoolContract(signer, chainId, poolName, poolType);
19
32
  if (!poolContract) {
20
33
  throw new Error('Could not find pool contract');
21
34
  }
22
35
  // TODO: Generate typechain for pool contract
23
- return poolContract.drawdown(drawdownAmount);
36
+ return poolContract.drawdown(drawdownAmount, gasOpts);
24
37
  }
25
- export async function makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount) {
38
+ /**
39
+ * Calls drawdown on a Huma pool contract
40
+ *
41
+ * @async
42
+ * @function
43
+ * @param {ethers.Signer} signer - The signer used to send the transaction.
44
+ * @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
45
+ * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
46
+ * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
47
+ * @param {BigNumberish} paymentAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
48
+ * @param {Overrides} gasOpts - The gas options to use for the transaction.
49
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
50
+ */
51
+ export async function makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount, gasOpts = {}) {
26
52
  const poolContract = getPoolContract(signer, chainId, poolName, poolType);
27
53
  if (!poolContract) {
28
54
  throw new Error('Could not find pool contract');
29
55
  }
30
56
  // TODO: Generate typechain for pool contract
31
- return poolContract.makePayment(await signer.getAddress(), paymentAmount);
57
+ return poolContract.makePayment(await signer.getAddress(), paymentAmount, gasOpts);
32
58
  }
33
59
  //# sourceMappingURL=PoolContractHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEnD;;;;;;;;GAQG;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;IAEzD,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAA;IAE1B,OAAO,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;AACvE,CAAC;AAED,MAAM,UAAU,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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,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAA;KAChD;IAED,6CAA6C;IAC7C,OAAO,YAAY,CAAC,QAAQ,CAAC,cAAc,EAAE,OAAO,CAAC,CAAA;AACvD,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,MAAqB,EACrB,OAAe,EACf,QAAmB,EACnB,QAAmB,EACnB,aAA2B,EAC3B,UAAqB,EAAE;IAEvB,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,CAC7B,MAAM,MAAM,CAAC,UAAU,EAAE,EACzB,aAAa,EACb,OAAO,CACR,CAAA;AACH,CAAC"}
@@ -99,22 +99,22 @@ async function storeData(config, signerOrPrivateKey, data, tags, lazyFund = true
99
99
  async function queryForMetadata(chainId, sender, referenceId) {
100
100
  var _a, _b, _c, _d;
101
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
- }
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
118
  `;
119
119
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
120
120
  const data = await request(`${config.nodeUrl}/graphql`, query, {
@@ -25,16 +25,16 @@ async function declareReceivablePaymentByReferenceId(signer, referenceId, paymen
25
25
  // Get ARWeave ID
26
26
  const dataID = await ARWeaveService.queryForMetadata(chainId, signerAddress, referenceId);
27
27
  // Fetch receivables with the same ARWeave ID
28
- const receivablesQuery = gql `
29
- query ReceivablesByURIQuery($owner: String!, $uri: String!) {
30
- receivables(where: { owner: $owner, uri: $uri }) {
31
- ...ReceivableFields
32
- }
33
- }
34
-
35
- fragment ReceivableFields on Receivable {
36
- tokenId
37
- }
28
+ const receivablesQuery = gql `
29
+ query ReceivablesByURIQuery($owner: String!, $uri: String!) {
30
+ receivables(where: { owner: $owner, uri: $uri }) {
31
+ ...ReceivableFields
32
+ }
33
+ }
34
+
35
+ fragment ReceivableFields on Receivable {
36
+ tokenId
37
+ }
38
38
  `;
39
39
  let receivableSubgraph;
40
40
  switch (chainId) {
@@ -52,7 +52,7 @@ async function declareReceivablePaymentByReferenceId(signer, referenceId, paymen
52
52
  throw new Error('No receivables found with this ARWeave ID.');
53
53
  }
54
54
  else if (((_b = receivablesData === null || receivablesData === void 0 ? void 0 : receivablesData.receivables) === null || _b === void 0 ? void 0 : _b.length) > 1) {
55
- throw new Error(`This owner has multiple receivables with the same URI. Please burn
55
+ throw new Error(`This owner has multiple receivables with the same URI. Please burn
56
56
  unnecessary receivables or pay the correct token manually using declareReceivablePaymentByTokenId`);
57
57
  }
58
58
  const contract = getRealWorldReceivableContract(signer, chainId);