@huma-finance/sdk 0.0.7 → 0.0.8

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 (87) hide show
  1. package/README.md +23 -7
  2. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.d.ts +2 -1
  3. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js +5 -4
  4. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js.map +1 -1
  5. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -0
  6. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js +22 -0
  7. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js.map +1 -0
  8. package/dist/cjs/helpers/PoolContractHelper.d.ts +12 -0
  9. package/dist/cjs/helpers/PoolContractHelper.js +21 -0
  10. package/dist/cjs/helpers/PoolContractHelper.js.map +1 -0
  11. package/dist/cjs/helpers/index.d.ts +2 -0
  12. package/dist/cjs/helpers/index.js +2 -0
  13. package/dist/cjs/helpers/index.js.map +1 -1
  14. package/dist/cjs/hooks/index.d.ts +0 -1
  15. package/dist/cjs/hooks/index.js +0 -1
  16. package/dist/cjs/hooks/index.js.map +1 -1
  17. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.d.ts +2 -1
  18. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js +5 -4
  19. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js.map +1 -1
  20. package/dist/cjs/hooks/useContract.d.ts +6 -4
  21. package/dist/cjs/hooks/useContract.js +6 -4
  22. package/dist/cjs/hooks/useContract.js.map +1 -1
  23. package/dist/cjs/hooks/useERC20TransferableReceivableContract.d.ts +5 -5
  24. package/dist/cjs/hooks/useERC20TransferableReceivableContract.js +6 -9
  25. package/dist/cjs/hooks/useERC20TransferableReceivableContract.js.map +1 -1
  26. package/dist/cjs/hooks/usePoolContract.d.ts +11 -4
  27. package/dist/cjs/hooks/usePoolContract.js +8 -3
  28. package/dist/cjs/hooks/usePoolContract.js.map +1 -1
  29. package/dist/cjs/services/ARWeaveService.d.ts +36 -14
  30. package/dist/cjs/services/ARWeaveService.js +33 -22
  31. package/dist/cjs/services/ARWeaveService.js.map +1 -1
  32. package/dist/cjs/services/EAService.d.ts +25 -2
  33. package/dist/cjs/services/EAService.js +4 -2
  34. package/dist/cjs/services/EAService.js.map +1 -1
  35. package/dist/cjs/services/ReceivableService.d.ts +30 -11
  36. package/dist/cjs/services/ReceivableService.js +40 -24
  37. package/dist/cjs/services/ReceivableService.js.map +1 -1
  38. package/dist/cjs/services/SubgraphService.d.ts +18 -4
  39. package/dist/cjs/services/SubgraphService.js +34 -25
  40. package/dist/cjs/services/SubgraphService.js.map +1 -1
  41. package/dist/cjs/utils/poolInfo.d.ts +1 -1
  42. package/dist/cjs/utils/poolInfo.js +2 -2
  43. package/dist/cjs/utils/poolInfo.js.map +1 -1
  44. package/dist/helpers/BaseCreditPoolReceivableContractHelper.d.ts +2 -1
  45. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js +3 -2
  46. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js.map +1 -1
  47. package/dist/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -0
  48. package/dist/helpers/ERC20TransferableReceivableContractHelper.js +18 -0
  49. package/dist/helpers/ERC20TransferableReceivableContractHelper.js.map +1 -0
  50. package/dist/helpers/PoolContractHelper.d.ts +12 -0
  51. package/dist/helpers/PoolContractHelper.js +17 -0
  52. package/dist/helpers/PoolContractHelper.js.map +1 -0
  53. package/dist/helpers/index.d.ts +2 -0
  54. package/dist/helpers/index.js +2 -0
  55. package/dist/helpers/index.js.map +1 -1
  56. package/dist/hooks/index.d.ts +0 -1
  57. package/dist/hooks/index.js +0 -1
  58. package/dist/hooks/index.js.map +1 -1
  59. package/dist/hooks/useBaseCreditPoolReceivableContract.d.ts +2 -1
  60. package/dist/hooks/useBaseCreditPoolReceivableContract.js +3 -2
  61. package/dist/hooks/useBaseCreditPoolReceivableContract.js.map +1 -1
  62. package/dist/hooks/useContract.d.ts +6 -4
  63. package/dist/hooks/useContract.js +6 -4
  64. package/dist/hooks/useContract.js.map +1 -1
  65. package/dist/hooks/useERC20TransferableReceivableContract.d.ts +5 -5
  66. package/dist/hooks/useERC20TransferableReceivableContract.js +5 -8
  67. package/dist/hooks/useERC20TransferableReceivableContract.js.map +1 -1
  68. package/dist/hooks/usePoolContract.d.ts +11 -4
  69. package/dist/hooks/usePoolContract.js +8 -3
  70. package/dist/hooks/usePoolContract.js.map +1 -1
  71. package/dist/services/ARWeaveService.d.ts +36 -14
  72. package/dist/services/ARWeaveService.js +33 -19
  73. package/dist/services/ARWeaveService.js.map +1 -1
  74. package/dist/services/EAService.d.ts +25 -2
  75. package/dist/services/EAService.js +3 -1
  76. package/dist/services/EAService.js.map +1 -1
  77. package/dist/services/ReceivableService.d.ts +30 -11
  78. package/dist/services/ReceivableService.js +36 -16
  79. package/dist/services/ReceivableService.js.map +1 -1
  80. package/dist/services/SubgraphService.d.ts +18 -4
  81. package/dist/services/SubgraphService.js +34 -22
  82. package/dist/services/SubgraphService.js.map +1 -1
  83. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  84. package/dist/utils/poolInfo.d.ts +1 -1
  85. package/dist/utils/poolInfo.js +1 -1
  86. package/dist/utils/poolInfo.js.map +1 -1
  87. package/package.json +3 -3
@@ -1,18 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.queryForMetadata = exports.storeData = exports.prefundBundlr = exports.getBundlrNetworkConfig = void 0;
3
+ exports.ARWeaveService = exports.getBundlrNetworkConfig = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const client_1 = tslib_1.__importDefault(require("@bundlr-network/client"));
6
6
  const graphql_request_1 = tslib_1.__importStar(require("graphql-request"));
7
7
  /**
8
- * Get the configuration for Bundlr network given a chain ID.
8
+ * Get the configuration for Bundlr network given a chain ID
9
9
  *
10
10
  * @function
11
+ * @memberof ArweaveService
11
12
  * @param {number} chainId - The chain ID.
12
13
  * @returns {BundlrConfig} - The configuration for the Bundlr network.
13
- * nodeUrl - The node URL of the Bundlr network to use.
14
- * currency - The currency to pay for uploads with, if lazy funding.
15
- * providerUrl - The provider URL, required for devnets.
16
14
  */
17
15
  function getBundlrNetworkConfig(chainId) {
18
16
  switch (chainId) {
@@ -37,19 +35,20 @@ function getBundlrNetworkConfig(chainId) {
37
35
  }
38
36
  exports.getBundlrNetworkConfig = getBundlrNetworkConfig;
39
37
  /**
40
- * Prefund the Bundlr network with the specified amount. Useful if not lazy funding.
38
+ * Prefund the Bundlr network with the specified amount. Required if not lazy funding.
41
39
  *
42
40
  * @async
43
41
  * @function
42
+ * @memberof ArweaveService
44
43
  * @param {BundlrConfig} config - The configuration for the Bundlr network.
45
- * @param {any} wallet - The wallet to send funds from
46
- * @param {number} amount - The amount to fund.
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.
47
46
  * @returns {Promise<FundResponse>} - The fund response.
48
47
  */
49
48
  async function prefundBundlr(config,
50
49
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
51
- wallet, amount) {
52
- const bundlr = new client_1.default(config.nodeUrl, config.currency, wallet, config.providerUrl
50
+ signer, amount) {
51
+ const bundlr = new client_1.default(config.nodeUrl, config.currency, signer, config.providerUrl
53
52
  ? {
54
53
  providerUrl: config.providerUrl,
55
54
  }
@@ -57,23 +56,24 @@ wallet, amount) {
57
56
  await bundlr.ready();
58
57
  return bundlr.fund(amount);
59
58
  }
60
- exports.prefundBundlr = prefundBundlr;
61
59
  /**
62
60
  * Store data on ARWeave using the Bundlr Network.
61
+ *
63
62
  * @async
64
63
  * @function
64
+ * @memberof ArweaveService
65
65
  * @param {BundlrConfig} config - Configuration object for the Bundlr instance.
66
- * @param {Web3Provider | ethers.Signer} wallet - Wallet object used for interacting with the Bundlr instance.
66
+ * @param {Web3Provider | string} signerOrPrivateKey - Wallet object used for interacting with the Bundlr instance.
67
67
  * If calling from a browser, this should be a `Web3Provider` instance. If calling from a Node.js
68
- * environment, this should be an `ethers.Signer` instance.
68
+ * environment, this should be a private key string.
69
69
  * @param {JSON} data - The data to store in the Bundlr instance.
70
70
  * @param {Array<{ name: string, value: string }>} tags - Array of tag objects with `name` and `value` properties.
71
71
  * @param {boolean} [lazyFund=true] - Optional flag to fund the Bundlr instance lazily. If set to `false`, the
72
72
  * Bundlr node should already be funded or else uploads will fail.
73
73
  * @returns {Promise<UploadResponse>} Promise resolving with the upload response.
74
74
  */
75
- async function storeData(config, wallet, data, tags, lazyFund = true) {
76
- const bundlr = new client_1.default(config.nodeUrl, config.currency, wallet, config.providerUrl
75
+ async function storeData(config, signerOrPrivateKey, data, tags, lazyFund = true) {
76
+ const bundlr = new client_1.default(config.nodeUrl, config.currency, signerOrPrivateKey, config.providerUrl
77
77
  ? {
78
78
  providerUrl: config.providerUrl,
79
79
  }
@@ -90,18 +90,20 @@ async function storeData(config, wallet, data, tags, lazyFund = true) {
90
90
  }
91
91
  return bundlr.upload(dataStr, { tags });
92
92
  }
93
- exports.storeData = storeData;
94
93
  /**
95
94
  * Helper method to query the Arweave network for receivables metadata previously uploaded.
95
+ *
96
96
  * @async
97
97
  * @function
98
+ * @memberof ArweaveService
99
+ * @param {number} chainId - The chain ID.
98
100
  * @param {POOL_NAME} poolName - The pool name tag to query.
99
101
  * @param {POOL_TYPE} poolType - The pool type tag to query.
100
102
  * @param {string} sender - The sender tag to query.
101
- * @param {string} internalID - The internal ID tag to query, whatever was used when uploading the metadata.
103
+ * @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
102
104
  * @returns {Promise<any>} Promise resolving with the queried data.
103
105
  */
104
- async function queryForMetadata(chainId, poolName, poolType, sender, internalId) {
106
+ async function queryForMetadata(chainId, poolName, poolType, sender, referenceId) {
105
107
  var _a, _b, _c, _d;
106
108
  const config = getBundlrNetworkConfig(chainId);
107
109
  const query = (0, graphql_request_1.gql) `
@@ -109,7 +111,7 @@ async function queryForMetadata(chainId, poolName, poolType, sender, internalId)
109
111
  $poolName: String!
110
112
  $poolType: String!
111
113
  $sender: String!
112
- $internalId: String!
114
+ $referenceId: String!
113
115
  ) {
114
116
  transactions(
115
117
  owners: [$sender]
@@ -117,7 +119,7 @@ async function queryForMetadata(chainId, poolName, poolType, sender, internalId)
117
119
  { name: "appName", values: ["HumaFinance"] }
118
120
  { name: "poolName", values: [$poolName] }
119
121
  { name: "poolType", values: [$poolType] }
120
- { name: "internalId", values: [$internalId] }
122
+ { name: "referenceId", values: [$referenceId] }
121
123
  ]
122
124
  ) {
123
125
  edges {
@@ -133,9 +135,18 @@ async function queryForMetadata(chainId, poolName, poolType, sender, internalId)
133
135
  poolName,
134
136
  poolType,
135
137
  sender,
136
- internalId,
138
+ referenceId,
137
139
  });
138
140
  return (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.transactions) === null || _a === void 0 ? void 0 : _a.edges) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.node) === null || _d === void 0 ? void 0 : _d.id;
139
141
  }
140
- exports.queryForMetadata = queryForMetadata;
142
+ /**
143
+ * An object that contains functions to interact with Huma-related data stored on ARWeave
144
+ * @namespace ARWeaveService
145
+ */
146
+ exports.ARWeaveService = {
147
+ queryForMetadata,
148
+ storeData,
149
+ prefundBundlr,
150
+ getBundlrNetworkConfig,
151
+ };
141
152
  //# sourceMappingURL=ARWeaveService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ARWeaveService.js","sourceRoot":"","sources":["../../../src/services/ARWeaveService.ts"],"names":[],"mappings":";;;;AAAA,4EAA2C;AAM3C,2EAA8C;AAY9C;;;;;;;;;GASG;AACH,SAAgB,sBAAsB,CAAC,OAAe;IACpD,QAAQ,OAAO,EAAE;QACf,KAAK,CAAC;YACJ,OAAO;gBACL,OAAO,EAAE,+BAA+B;gBACxC,QAAQ,E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AM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;QACvC,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAEzC,+DAA+D;QAC/D,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;QACvB,OAAO,CAAC,GAAG,CACT,uBAAuB,KAAK,IAAI,MAAM,CAAC,QAAQ,iBAAiB,CACjE,CAAA;QACD,MAAM,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;KACzB;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;AACzC,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,KAAK,UAAU,gBAAgB,CAC7B,OAAe,EACf,QAAmB,EACnB,QAAmB,EACnB,MAAc,EACd,WAAmB;;IAGnB,MAAM,MAAM,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAA;IAC9C,MAAM,KAAK,GAAG,IAAA,qBAAG,EAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBhB,CAAA;IAED,8DAA8D;IAC9D,MAAM,IAAI,GAAQ,MAAM,IAAA,yBAAO,EAAC,GAAG,MAAM,CAAC,OAAO,UAAU,EAAE,KAAK,EAAE;QAClE,QAAQ;QACR,QAAQ;QACR,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;CACvB,CAAA"}
@@ -1,7 +1,30 @@
1
- export type { ApproveInfo, EAPayload } from '@00labs/huma-shared';
1
+ /**
2
+ * Object representing the information returned from a successful evaluation agent approve operation.
3
+ *
4
+ * @typedef {Object} ApproveInfo
5
+ * @memberof EAService
6
+ * @property {number} aprInBps The annual percentage rate in basis points.
7
+ * @property {number|string} creditLimit The credit limit for the borrower in the pool's base currency.
8
+ * @property {number} intervalInDays The interval in days for credit line rebalancing.
9
+ * @property {number|string} receivableAmount The expected payment amount of the receivable asset.
10
+ * @property {string} receivableAsset The address of the receivable asset contract.
11
+ * @property {number|string} receivableParam The identifying parameter for the receivable asset, often the token ID of an ERC721.
12
+ * @property {number} remainingPeriods The number of remaining payback periods in the credit line.
13
+ * @property {number} tokenDecimal The number of decimals for the base token of the pool.
14
+ * @property {string} tokenName The name of the base token of the pool.
15
+ * @property {string} tokenSymbol The symbol of the base token of the pool.
16
+ */
17
+ /**
18
+ * Object representing an invoice payload for underwriting approval.
19
+ *
20
+ * @typedef {Object} EAPayload
21
+ */
22
+ export type { ApproveInfo, EAPayload } from '@huma-finance/shared';
2
23
  /**
3
24
  * An object that contains functions to interact with Huma's EAVerse service.
4
25
  *
26
+ * @namespace EAService
27
+ *
5
28
  * approve: Submits a credit underwriting request to Huma's EAVerse.
6
29
  * @param {EAPayload} payload The payload for the underwrite approval.
7
30
  * @param {number} chainId The chain ID.
@@ -9,5 +32,5 @@ export type { ApproveInfo, EAPayload } from '@00labs/huma-shared';
9
32
  * @throws {EARejectionError} If the underwrite approval is rejected.
10
33
  */
11
34
  export declare const EAService: {
12
- approve: (payload: import("@00labs/huma-shared").EAPayload, chainId: number, isDev?: boolean | undefined) => Promise<import("@00labs/huma-shared").ApproveInfo>;
35
+ approve: (payload: import("@huma-finance/shared").EAPayload, chainId: number, isDev?: boolean | undefined) => Promise<import("@huma-finance/shared").ApproveInfo>;
13
36
  };
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EAService = void 0;
4
- const huma_shared_1 = require("@00labs/huma-shared");
4
+ const shared_1 = require("@huma-finance/shared");
5
5
  /**
6
6
  * An object that contains functions to interact with Huma's EAVerse service.
7
7
  *
8
+ * @namespace EAService
9
+ *
8
10
  * approve: Submits a credit underwriting request to Huma's EAVerse.
9
11
  * @param {EAPayload} payload The payload for the underwrite approval.
10
12
  * @param {number} chainId The chain ID.
@@ -12,6 +14,6 @@ const huma_shared_1 = require("@00labs/huma-shared");
12
14
  * @throws {EARejectionError} If the underwrite approval is rejected.
13
15
  */
14
16
  exports.EAService = {
15
- approve: huma_shared_1.EAService.approve,
17
+ approve: shared_1.EAService.approve,
16
18
  };
17
19
  //# sourceMappingURL=EAService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EAService.js","sourceRoot":"","sources":["../../../src/services/EAService.ts"],"names":[],"mappings":";;;AAAA,qDAAoE;AAIpE;;;;;;;;GAQG;AACU,QAAA,SAAS,GAAG;IACvB,OAAO,EAAE,uBAAiB,CAAC,OAAO;CACnC,CAAA"}
1
+ {"version":3,"file":"EAService.js","sourceRoot":"","sources":["../../../src/services/EAService.ts"],"names":[],"mappings":";;;AAAA,iDAAqE;AAyBrE;;;;;;;;;;GAUG;AACU,QAAA,SAAS,GAAG;IACvB,OAAO,EAAE,kBAAiB,CAAC,OAAO;CACnC,CAAA"}
@@ -1,19 +1,22 @@
1
1
  import { TransactionReceipt, TransactionResponse, Web3Provider } from '@ethersproject/providers';
2
- import { BigNumberish, ethers } from 'ethers';
3
- import { POOL_NAME, POOL_TYPE } from '@00labs/huma-shared';
2
+ import { BigNumberish, ethers, Overrides } from 'ethers';
3
+ import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
4
4
  /**
5
5
  * Enumeration of payment methods. Maps to the PaymentMethod enum in the BaseCreditPoolReceivable contract.
6
6
  * Declarative payment methods are those that do not actually send ERC20 funds. Payable payment methods are those that
7
7
  * do by calling makePayment on the BaseCreditPool contract.
8
+ *
8
9
  * @enum {number}
10
+ * @memberof ReceivableService
9
11
  */
10
12
  export declare enum PaymentMethod {
11
13
  Declarative = 0,
12
14
  Payable = 1
13
15
  }
14
16
  /**
15
- * Pays a BaseCreditPoolReceivable using the specified payment method, given an internalId mapping to the receivable's metadata
17
+ * Pays a BaseCreditPoolReceivable using the specified payment method, given an referenceId mapping to the receivable's metadata
16
18
  *
19
+ * @memberof ReceivableService
17
20
  * @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
18
21
  * @param {BigNumberish} receivableTokenId - The ID of the receivable token to pay.
19
22
  * @param {number} paymentAmount - The amount to pay the receivable.
@@ -21,10 +24,11 @@ export declare enum PaymentMethod {
21
24
  * @returns {Promise<TransactionReceipt>} - A Promise of the transaction receipt.
22
25
  * @throws {Error} - Throws an error if the BaseCreditPoolReceivable contract is not available on the network.
23
26
  */
24
- export declare function payReceivableByInternalId(signer: ethers.Signer, internalId: string, paymentAmount: number, paymentMethod: PaymentMethod): Promise<TransactionReceipt>;
27
+ declare function payReceivableByReferenceId(signer: ethers.Signer, referenceId: string, paymentAmount: number, paymentMethod: PaymentMethod): Promise<TransactionReceipt>;
25
28
  /**
26
29
  * Pays a BaseCreditPoolReceivable using the specified payment method, given a tokenID of the receivable.
27
30
  *
31
+ * @memberof ReceivableService
28
32
  * @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
29
33
  * @param {BigNumberish} receivableTokenId - The ID of the receivable token to pay.
30
34
  * @param {number} paymentAmount - The amount to pay the receivable.
@@ -32,10 +36,11 @@ export declare function payReceivableByInternalId(signer: ethers.Signer, interna
32
36
  * @returns {Promise<TransactionReceipt>} - A Promise of the transaction receipt.
33
37
  * @throws {Error} - Throws an error if the BaseCreditPoolReceivable contract is not available on the network.
34
38
  */
35
- export declare function payReceivableByTokenId(signer: ethers.Signer, receivableTokenId: BigNumberish, paymentAmount: number, paymentMethod: PaymentMethod): Promise<TransactionReceipt>;
39
+ declare function payReceivableByTokenId(signer: ethers.Signer, receivableTokenId: BigNumberish, paymentAmount: number, paymentMethod: PaymentMethod): Promise<TransactionReceipt>;
36
40
  /**
37
41
  * Mints a new BaseCreditPoolReceivable token on the given chain of the signer
38
42
  *
43
+ * @memberof ReceivableService
39
44
  * @param {ethers.Signer} signer - The signer used to send the transaction.
40
45
  * @param {string} recipient - The address of the recipient of the receivable token.
41
46
  * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
@@ -44,17 +49,19 @@ export declare function payReceivableByTokenId(signer: ethers.Signer, receivable
44
49
  * @param {number} maturityDate - The maturity date of the receivable token, in UNIX timestamp format.
45
50
  * @param {PaymentMethod} paymentMethod - The payment method to use. See PaymentMethod for more details.
46
51
  * @param {string} uri - The URI of the receivable token metadata.
52
+ * @param {Overrides} gasOpts - The gas options to use for the transaction.
47
53
  * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
48
54
  * @throws {Error} - Throws an error if the BaseCreditPoolReceivable contract is not available on the network.
49
55
  */
50
- export declare function mintReceivable(signer: ethers.Signer, recipient: string, poolName: POOL_NAME, poolType: POOL_TYPE, receivableAmount: number, maturityDate: number, paymentMethod: PaymentMethod, uri: string): Promise<TransactionResponse>;
56
+ declare function mintReceivable(signer: ethers.Signer, poolName: POOL_NAME, poolType: POOL_TYPE, receivableAmount: number, maturityDate: number, paymentMethod: PaymentMethod, uri: string, gasOpts?: Overrides): Promise<TransactionResponse>;
51
57
  /**
52
58
  * Mints a BaseCreditPoolReceivable token with metadata uploaded onto ARWeave
53
59
  *
54
- * @param {Web3Provider | ethers.Signer} wallet - If calling this function from a browser, this function expects a Web3Provider.
60
+ * @memberof ReceivableService
61
+ * @param {Web3Provider | ethers.Signer} signerOrProvider - If calling this function from a browser, this function expects a Web3Provider.
55
62
  * If calling this function from a server, this function expects an ethers Signer. Note that privateKey only needs to be included
56
63
  * from server calls.
57
- * @param {string} privateKey - Private key of the wallet used to upload metadata to ARWeave. Only required if calling this function from a server.
64
+ * @param {string | null} privateKey - Private key of the wallet used to upload metadata to ARWeave. Only required if calling this function from a server.
58
65
  * @param {number} chainId - The chain ID to mint the receivable token on and pay ARWeave funds from.
59
66
  * @param {string} recipient - The receivable token recipient.
60
67
  * @param {POOL_NAME} poolName - The pool name. Used to lookup the pool address to pay to.
@@ -63,14 +70,26 @@ export declare function mintReceivable(signer: ethers.Signer, recipient: string,
63
70
  * @param {number} maturityDate - The maturity date of the receivable, in UNIX timestamp format.
64
71
  * @param {PaymentMethod} paymentMethod - The payment method to use. See PaymentMethod for more details.
65
72
  * @param {JSON} metadata - The metadata in JSON format. This will be uploaded onto ARWeave
66
- * @param {number} internalId - An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.
73
+ * @param {number} referenceId - An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.
67
74
  * @param {Array<{ name: string, value: string }>} extraTags - Any extraTags you'd like to tag your metadata with. Note that metadata on
68
75
  * ARWeave is indexed by these tags, so make sure to include any tags that you'd like to be able to query by.
69
76
  * @param {boolean} [lazyFund=true] - Whether to lazy fund the ARWeave uploads. If true, the ARWeave uploads will be paid for by the
70
77
  * metadata uploader immediately before uploading. If false, the ARWeave node must be pre-funded before calling this function.
78
+ * @param {Overrides} [gasOpts] - Optional gas overrides for the transaction.
71
79
  * @returns {Promise<TransactionReceipt>} - The transaction receipt.
72
80
  */
73
- export declare function mintReceivableWithMetadata(wallet: Web3Provider | ethers.Signer, privateKey: string, chainId: number, recipient: string, poolName: POOL_NAME, poolType: POOL_TYPE, receivableAmount: number, maturityDate: number, paymentMethod: PaymentMethod, metadata: JSON, internalId: string, extraTags: {
81
+ declare function mintReceivableWithMetadata(signerOrProvider: Web3Provider | ethers.Signer, privateKey: string | null, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, receivableAmount: number, maturityDate: number, paymentMethod: PaymentMethod, metadata: JSON, referenceId: string, extraTags: {
74
82
  name: string;
75
83
  value: string;
76
- }[], lazyFund?: boolean): Promise<TransactionReceipt>;
84
+ }[], lazyFund?: boolean, gasOpts?: Overrides): Promise<TransactionReceipt>;
85
+ /**
86
+ * An object that contains functions to interact with Huma's receivables.
87
+ * @namespace ReceivableService
88
+ */
89
+ export declare const ReceivableService: {
90
+ mintReceivableWithMetadata: typeof mintReceivableWithMetadata;
91
+ mintReceivable: typeof mintReceivable;
92
+ payReceivableByTokenId: typeof payReceivableByTokenId;
93
+ payReceivableByReferenceId: typeof payReceivableByReferenceId;
94
+ };
95
+ export {};
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.mintReceivableWithMetadata = exports.mintReceivable = exports.payReceivableByTokenId = exports.payReceivableByInternalId = exports.PaymentMethod = void 0;
3
+ exports.ReceivableService = exports.PaymentMethod = void 0;
4
4
  const providers_1 = require("@ethersproject/providers");
5
- const huma_shared_1 = require("@00labs/huma-shared");
5
+ const shared_1 = require("@huma-finance/shared");
6
6
  const utils_1 = require("../utils");
7
7
  const ARWeaveService_1 = require("./ARWeaveService");
8
8
  const chain_1 = require("../utils/chain");
@@ -10,7 +10,9 @@ const chain_1 = require("../utils/chain");
10
10
  * Enumeration of payment methods. Maps to the PaymentMethod enum in the BaseCreditPoolReceivable contract.
11
11
  * Declarative payment methods are those that do not actually send ERC20 funds. Payable payment methods are those that
12
12
  * do by calling makePayment on the BaseCreditPool contract.
13
+ *
13
14
  * @enum {number}
15
+ * @memberof ReceivableService
14
16
  */
15
17
  var PaymentMethod;
16
18
  (function (PaymentMethod) {
@@ -18,8 +20,9 @@ var PaymentMethod;
18
20
  PaymentMethod[PaymentMethod["Payable"] = 1] = "Payable";
19
21
  })(PaymentMethod = exports.PaymentMethod || (exports.PaymentMethod = {}));
20
22
  /**
21
- * Pays a BaseCreditPoolReceivable using the specified payment method, given an internalId mapping to the receivable's metadata
23
+ * Pays a BaseCreditPoolReceivable using the specified payment method, given an referenceId mapping to the receivable's metadata
22
24
  *
25
+ * @memberof ReceivableService
23
26
  * @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
24
27
  * @param {BigNumberish} receivableTokenId - The ID of the receivable token to pay.
25
28
  * @param {number} paymentAmount - The amount to pay the receivable.
@@ -27,21 +30,21 @@ var PaymentMethod;
27
30
  * @returns {Promise<TransactionReceipt>} - A Promise of the transaction receipt.
28
31
  * @throws {Error} - Throws an error if the BaseCreditPoolReceivable contract is not available on the network.
29
32
  */
30
- async function payReceivableByInternalId(
33
+ async function payReceivableByReferenceId(
31
34
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
32
35
  signer,
33
36
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
34
- internalId,
37
+ referenceId,
35
38
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
36
39
  paymentAmount,
37
40
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
38
41
  paymentMethod) {
39
42
  throw new Error('Not implemented');
40
43
  }
41
- exports.payReceivableByInternalId = payReceivableByInternalId;
42
44
  /**
43
45
  * Pays a BaseCreditPoolReceivable using the specified payment method, given a tokenID of the receivable.
44
46
  *
47
+ * @memberof ReceivableService
45
48
  * @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
46
49
  * @param {BigNumberish} receivableTokenId - The ID of the receivable token to pay.
47
50
  * @param {number} paymentAmount - The amount to pay the receivable.
@@ -53,12 +56,12 @@ async function payReceivableByTokenId(signer, receivableTokenId, paymentAmount,
53
56
  var _a;
54
57
  const chainId = await (0, chain_1.getChainIdFromSignerOrProvider)(signer);
55
58
  const baseCreditPoolReceivable = chainId
56
- ? (_a = huma_shared_1.SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[huma_shared_1.SupplementaryContracts.BaseCreditPoolReceivable]
59
+ ? (_a = shared_1.SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[shared_1.SupplementaryContracts.BaseCreditPoolReceivable]
57
60
  : null;
58
61
  if (!baseCreditPoolReceivable) {
59
62
  throw new Error('BaseCreditPoolReceivable is not available on this network');
60
63
  }
61
- const contract = (0, utils_1.getContract)(baseCreditPoolReceivable, huma_shared_1.BASE_CREDIT_POOL_RECEIVABLE_ABI, signer);
64
+ const contract = (0, utils_1.getContract)(baseCreditPoolReceivable, shared_1.BASE_CREDIT_POOL_RECEIVABLE_ABI, signer);
62
65
  if (!contract) {
63
66
  throw new Error('Could not find BaseCreditPoolReceivable contract');
64
67
  }
@@ -75,10 +78,10 @@ async function payReceivableByTokenId(signer, receivableTokenId, paymentAmount,
75
78
  }
76
79
  return tx.wait();
77
80
  }
78
- exports.payReceivableByTokenId = payReceivableByTokenId;
79
81
  /**
80
82
  * Mints a new BaseCreditPoolReceivable token on the given chain of the signer
81
83
  *
84
+ * @memberof ReceivableService
82
85
  * @param {ethers.Signer} signer - The signer used to send the transaction.
83
86
  * @param {string} recipient - The address of the recipient of the receivable token.
84
87
  * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
@@ -87,35 +90,36 @@ exports.payReceivableByTokenId = payReceivableByTokenId;
87
90
  * @param {number} maturityDate - The maturity date of the receivable token, in UNIX timestamp format.
88
91
  * @param {PaymentMethod} paymentMethod - The payment method to use. See PaymentMethod for more details.
89
92
  * @param {string} uri - The URI of the receivable token metadata.
93
+ * @param {Overrides} gasOpts - The gas options to use for the transaction.
90
94
  * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
91
95
  * @throws {Error} - Throws an error if the BaseCreditPoolReceivable contract is not available on the network.
92
96
  */
93
- async function mintReceivable(signer, recipient, poolName, poolType, receivableAmount, maturityDate, paymentMethod, uri) {
97
+ async function mintReceivable(signer, poolName, poolType, receivableAmount, maturityDate, paymentMethod, uri, gasOpts = {}) {
94
98
  var _a, _b, _c;
95
99
  const chainId = await (0, chain_1.getChainIdFromSignerOrProvider)(signer);
96
100
  const baseCreditPoolReceivable = chainId
97
- ? (_a = huma_shared_1.SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[huma_shared_1.SupplementaryContracts.BaseCreditPoolReceivable]
101
+ ? (_a = shared_1.SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[shared_1.SupplementaryContracts.BaseCreditPoolReceivable]
98
102
  : null;
99
103
  const poolInfo = chainId
100
- ? (_c = (_b = huma_shared_1.PoolContractMap[chainId]) === null || _b === void 0 ? void 0 : _b[poolType]) === null || _c === void 0 ? void 0 : _c[poolName]
104
+ ? (_c = (_b = shared_1.PoolContractMap[chainId]) === null || _b === void 0 ? void 0 : _b[poolType]) === null || _c === void 0 ? void 0 : _c[poolName]
101
105
  : undefined;
102
106
  if (!baseCreditPoolReceivable || !poolInfo) {
103
107
  throw new Error('BaseCreditPoolReceivable is not available on this network');
104
108
  }
105
- const contract = (0, utils_1.getContract)(baseCreditPoolReceivable, huma_shared_1.BASE_CREDIT_POOL_RECEIVABLE_ABI, signer);
109
+ const contract = (0, utils_1.getContract)(baseCreditPoolReceivable, shared_1.BASE_CREDIT_POOL_RECEIVABLE_ABI, signer);
106
110
  if (!contract) {
107
111
  throw new Error('Could not find BaseCreditPoolReceivable contract');
108
112
  }
109
- return contract.safeMint(recipient, poolInfo.pool, poolInfo.poolUnderlyingToken.address, receivableAmount, maturityDate, paymentMethod, uri);
113
+ return contract.safeMint(await signer.getAddress(), poolInfo.pool, poolInfo.poolUnderlyingToken.address, receivableAmount, maturityDate, paymentMethod, uri, gasOpts);
110
114
  }
111
- exports.mintReceivable = mintReceivable;
112
115
  /**
113
116
  * Mints a BaseCreditPoolReceivable token with metadata uploaded onto ARWeave
114
117
  *
115
- * @param {Web3Provider | ethers.Signer} wallet - If calling this function from a browser, this function expects a Web3Provider.
118
+ * @memberof ReceivableService
119
+ * @param {Web3Provider | ethers.Signer} signerOrProvider - If calling this function from a browser, this function expects a Web3Provider.
116
120
  * If calling this function from a server, this function expects an ethers Signer. Note that privateKey only needs to be included
117
121
  * from server calls.
118
- * @param {string} privateKey - Private key of the wallet used to upload metadata to ARWeave. Only required if calling this function from a server.
122
+ * @param {string | null} privateKey - Private key of the wallet used to upload metadata to ARWeave. Only required if calling this function from a server.
119
123
  * @param {number} chainId - The chain ID to mint the receivable token on and pay ARWeave funds from.
120
124
  * @param {string} recipient - The receivable token recipient.
121
125
  * @param {POOL_NAME} poolName - The pool name. Used to lookup the pool address to pay to.
@@ -124,27 +128,30 @@ exports.mintReceivable = mintReceivable;
124
128
  * @param {number} maturityDate - The maturity date of the receivable, in UNIX timestamp format.
125
129
  * @param {PaymentMethod} paymentMethod - The payment method to use. See PaymentMethod for more details.
126
130
  * @param {JSON} metadata - The metadata in JSON format. This will be uploaded onto ARWeave
127
- * @param {number} internalId - An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.
131
+ * @param {number} referenceId - An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.
128
132
  * @param {Array<{ name: string, value: string }>} extraTags - Any extraTags you'd like to tag your metadata with. Note that metadata on
129
133
  * ARWeave is indexed by these tags, so make sure to include any tags that you'd like to be able to query by.
130
134
  * @param {boolean} [lazyFund=true] - Whether to lazy fund the ARWeave uploads. If true, the ARWeave uploads will be paid for by the
131
135
  * metadata uploader immediately before uploading. If false, the ARWeave node must be pre-funded before calling this function.
136
+ * @param {Overrides} [gasOpts] - Optional gas overrides for the transaction.
132
137
  * @returns {Promise<TransactionReceipt>} - The transaction receipt.
133
138
  */
134
- async function mintReceivableWithMetadata(wallet, privateKey, chainId, recipient, poolName, poolType, receivableAmount, maturityDate, paymentMethod, metadata, internalId, extraTags, lazyFund = true) {
135
- const config = (0, ARWeaveService_1.getBundlrNetworkConfig)(chainId);
139
+ async function mintReceivableWithMetadata(signerOrProvider, privateKey, chainId, poolName, poolType, receivableAmount, maturityDate, paymentMethod, metadata, referenceId, extraTags, lazyFund = true, gasOpts) {
140
+ const config = ARWeaveService_1.ARWeaveService.getBundlrNetworkConfig(chainId);
136
141
  try {
137
142
  const tags = [
138
143
  { name: 'Content-Type', value: 'application/json' },
139
144
  { name: 'appName', value: 'HumaFinance' },
140
145
  { name: 'poolName', value: poolName },
141
146
  { name: 'poolType', value: poolType },
142
- { name: 'internalId', value: internalId },
147
+ { name: 'referenceId', value: referenceId },
143
148
  ...extraTags,
144
149
  ];
145
- const response = await (0, ARWeaveService_1.storeData)(config, wallet instanceof providers_1.Web3Provider ? wallet : privateKey, metadata, tags, lazyFund);
150
+ const response = await ARWeaveService_1.ARWeaveService.storeData(config, signerOrProvider instanceof providers_1.Web3Provider ? signerOrProvider : privateKey, metadata, tags, lazyFund);
146
151
  console.log(`Data uploaded ==> https://arweave.net/${response.id}`);
147
- const tx = await mintReceivable(wallet instanceof providers_1.Web3Provider ? wallet.getSigner() : wallet, recipient, poolName, poolType, receivableAmount, maturityDate, paymentMethod, `https://arweave.net/${response.id}`);
152
+ const tx = await mintReceivable(signerOrProvider instanceof providers_1.Web3Provider
153
+ ? signerOrProvider.getSigner()
154
+ : signerOrProvider, poolName, poolType, receivableAmount, maturityDate, paymentMethod, `https://arweave.net/${response.id}`, gasOpts);
148
155
  return await tx.wait();
149
156
  }
150
157
  catch (e) {
@@ -152,5 +159,14 @@ async function mintReceivableWithMetadata(wallet, privateKey, chainId, recipient
152
159
  throw e;
153
160
  }
154
161
  }
155
- exports.mintReceivableWithMetadata = mintReceivableWithMetadata;
162
+ /**
163
+ * An object that contains functions to interact with Huma's receivables.
164
+ * @namespace ReceivableService
165
+ */
166
+ exports.ReceivableService = {
167
+ mintReceivableWithMetadata,
168
+ mintReceivable,
169
+ payReceivableByTokenId,
170
+ payReceivableByReferenceId,
171
+ };
156
172
  //# sourceMappingURL=ReceivableService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReceivableService.js","sourceRoot":"","sources":["../../../src/services/ReceivableService.ts"],"names":[],"mappings":";;;AAAA,wDAIiC;AAEjC,qDAO4B;AAE5B,oCAAsC;AACtC,qDAAoE;AACpE,0CAA+D;AAE/D;;;;;GAKG;AACH,IAAY,aAGX;AAHD,WAAY,aAAa;IACvB,+DAAe,CAAA;IACf,uDAAW,CAAA;AACb,CAAC,EAHW,aAAa,GAAb,qBAAa,KAAb,qBAAa,QAGxB;AAED;;;;;;;;;GASG;AACI,KAAK,UAAU,yBAAyB;AAC7C,6DAA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ACvB;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAChB,MAAM,CAAC,CAAA;KACR;AACH,CAAC;AAED;;;GAGG;AACU,QAAA,iBAAiB,GAAG;IAC/B,0BAA0B;IAC1B,cAAc;IACd,sBAAsB;IACtB,0BAA0B;CAC3B,CAAA"}
@@ -1,13 +1,15 @@
1
- import { POOL_NAME, POOL_TYPE } from '@00labs/huma-shared';
1
+ import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
2
2
  /**
3
3
  * Returns the subgraph URL for a given chain ID.
4
4
  *
5
+ * @memberof SubgraphService
5
6
  * @param {number} chainId - The ID of the chain.
6
7
  * @returns {string} The subgraph URL for the given chain ID.
7
8
  */
8
- export declare function getSubgraphUrlForChainId(chainId: number): string;
9
+ declare function getSubgraphUrlForChainId(chainId: number): string;
9
10
  /**
10
11
  * Represents the payload of a credit event.
12
+ * @typedef {Object} CreditEventPayload
11
13
  */
12
14
  export type CreditEventPayload = {
13
15
  amount?: string;
@@ -19,6 +21,7 @@ export type CreditEventPayload = {
19
21
  /**
20
22
  * Returns the credit events for a given user.
21
23
  *
24
+ * @memberof SubgraphService
22
25
  * @param {string} userAddress - The address of the user.
23
26
  * @param {number} chainId - The ID of the chain.
24
27
  * @param {POOL_NAME} poolName - The name of the pool.
@@ -26,14 +29,25 @@ export type CreditEventPayload = {
26
29
  * @param {string[]} event - The event types to filter by.
27
30
  * @returns {Promise<CreditEventPayload[]>} The credit events for the given user.
28
31
  */
29
- export declare function getCreditEventsForUser(userAddress: string, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, event: string[]): Promise<CreditEventPayload[]>;
32
+ declare function getCreditEventsForUser(userAddress: string, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, event: string[]): Promise<CreditEventPayload[]>;
30
33
  /**
31
34
  * Returns the last factorized amount for a given user and pool.
32
35
  *
36
+ * @memberof SubgraphService
33
37
  * @param {string} userAddress - The address of the user.
34
38
  * @param {number} chainId - The ID of the chain.
35
39
  * @param {POOL_NAME} poolName - The name of the pool.
36
40
  * @param {POOL_TYPE} poolType - The type of the pool.
37
41
  * @returns {Promise<number>} The last factorized amount for the given user and pool.
38
42
  */
39
- export declare function getLastFactorizedAmountFromPool(userAddress: string, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): Promise<number>;
43
+ declare function getLastFactorizedAmountFromPool(userAddress: string, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): Promise<number>;
44
+ /**
45
+ * An object that contains functions to interact with Huma's Subgraph storage.
46
+ * @namespace SubgraphService
47
+ */
48
+ export declare const SubgraphService: {
49
+ getSubgraphUrlForChainId: typeof getSubgraphUrlForChainId;
50
+ getCreditEventsForUser: typeof getCreditEventsForUser;
51
+ getLastFactorizedAmountFromPool: typeof getLastFactorizedAmountFromPool;
52
+ };
53
+ export {};