@huma-finance/sdk 0.0.8 → 0.0.11

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 (73) hide show
  1. package/README.md +1 -1
  2. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.d.ts +2 -2
  3. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js +2 -2
  4. package/dist/cjs/helpers/RealWorldReceivableContractHelper.d.ts +10 -0
  5. package/dist/cjs/helpers/RealWorldReceivableContractHelper.js +22 -0
  6. package/dist/cjs/helpers/RealWorldReceivableContractHelper.js.map +1 -0
  7. package/dist/cjs/helpers/index.d.ts +1 -1
  8. package/dist/cjs/helpers/index.js +1 -1
  9. package/dist/cjs/helpers/index.js.map +1 -1
  10. package/dist/cjs/hooks/index.d.ts +1 -1
  11. package/dist/cjs/hooks/index.js +1 -1
  12. package/dist/cjs/hooks/index.js.map +1 -1
  13. package/dist/cjs/hooks/usePoolContract.d.ts +1 -1
  14. package/dist/cjs/hooks/usePoolContract.js +1 -1
  15. package/dist/cjs/hooks/useRealWorldReceivableContract.d.ts +10 -0
  16. package/dist/cjs/hooks/useRealWorldReceivableContract.js +20 -0
  17. package/dist/cjs/hooks/useRealWorldReceivableContract.js.map +1 -0
  18. package/dist/cjs/services/ARWeaveService.d.ts +14 -0
  19. package/dist/cjs/services/ARWeaveService.js +46 -23
  20. package/dist/cjs/services/ARWeaveService.js.map +1 -1
  21. package/dist/cjs/services/EAService.d.ts +4 -22
  22. package/dist/cjs/services/EAService.js +0 -6
  23. package/dist/cjs/services/EAService.js.map +1 -1
  24. package/dist/cjs/services/ReceivableService.d.ts +25 -44
  25. package/dist/cjs/services/ReceivableService.js +41 -75
  26. package/dist/cjs/services/ReceivableService.js.map +1 -1
  27. package/dist/cjs/services/SubgraphService.js +18 -18
  28. package/dist/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -10
  29. package/dist/helpers/ERC20TransferableReceivableContractHelper.js +17 -17
  30. package/dist/helpers/PoolContractHelper.d.ts +12 -12
  31. package/dist/helpers/PoolContractHelper.js +16 -16
  32. package/dist/helpers/RealWorldReceivableContractHelper.d.ts +10 -0
  33. package/dist/helpers/RealWorldReceivableContractHelper.js +18 -0
  34. package/dist/helpers/RealWorldReceivableContractHelper.js.map +1 -0
  35. package/dist/helpers/index.d.ts +3 -3
  36. package/dist/helpers/index.js +3 -3
  37. package/dist/helpers/index.js.map +1 -1
  38. package/dist/hooks/index.d.ts +4 -4
  39. package/dist/hooks/index.js +4 -4
  40. package/dist/hooks/index.js.map +1 -1
  41. package/dist/hooks/useContract.d.ts +13 -13
  42. package/dist/hooks/useContract.js +26 -26
  43. package/dist/hooks/useERC20TransferableReceivableContract.d.ts +12 -12
  44. package/dist/hooks/useERC20TransferableReceivableContract.js +16 -16
  45. package/dist/hooks/usePoolContract.d.ts +60 -60
  46. package/dist/hooks/usePoolContract.js +48 -48
  47. package/dist/hooks/useRealWorldReceivableContract.d.ts +10 -0
  48. package/dist/hooks/useRealWorldReceivableContract.js +16 -0
  49. package/dist/hooks/useRealWorldReceivableContract.js.map +1 -0
  50. package/dist/index.d.ts +4 -4
  51. package/dist/index.js +4 -4
  52. package/dist/services/ARWeaveService.d.ts +84 -84
  53. package/dist/services/ARWeaveService.js +144 -144
  54. package/dist/services/EAService.d.ts +18 -36
  55. package/dist/services/EAService.js +9 -15
  56. package/dist/services/EAService.js.map +1 -1
  57. package/dist/services/ReceivableService.d.ts +76 -95
  58. package/dist/services/ReceivableService.js +134 -168
  59. package/dist/services/ReceivableService.js.map +1 -1
  60. package/dist/services/SubgraphService.d.ts +53 -53
  61. package/dist/services/SubgraphService.js +95 -95
  62. package/dist/services/index.d.ts +4 -4
  63. package/dist/services/index.js +4 -4
  64. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  65. package/dist/utils/chain.d.ts +14 -14
  66. package/dist/utils/chain.js +28 -28
  67. package/dist/utils/index.d.ts +3 -3
  68. package/dist/utils/index.js +3 -3
  69. package/dist/utils/poolInfo.d.ts +9 -9
  70. package/dist/utils/poolInfo.js +9 -9
  71. package/dist/utils/web3.d.ts +4 -4
  72. package/dist/utils/web3.js +23 -23
  73. package/package.json +3 -3
@@ -1,147 +1,147 @@
1
- import Bundlr from '@bundlr-network/client';
2
- import request, { gql } from 'graphql-request';
3
- /**
4
- * Get the configuration for Bundlr network given a chain ID
5
- *
6
- * @function
7
- * @memberof ArweaveService
8
- * @param {number} chainId - The chain ID.
9
- * @returns {BundlrConfig} - The configuration for the Bundlr network.
10
- */
11
- export function getBundlrNetworkConfig(chainId) {
12
- switch (chainId) {
13
- case 5:
14
- return {
15
- nodeUrl: 'https://devnet.bundlr.network',
16
- currency: 'ethereum',
17
- providerUrl: 'https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161',
18
- };
19
- case 80001:
20
- return {
21
- nodeUrl: 'https://devnet.bundlr.network',
22
- currency: 'matic',
23
- providerUrl: 'https://rpc-mumbai.matic.today',
24
- };
25
- default:
26
- return {
27
- nodeUrl: '',
28
- currency: '',
29
- };
30
- }
31
- }
32
- /**
33
- * Prefund the Bundlr network with the specified amount. Required if not lazy funding.
34
- *
35
- * @async
36
- * @function
37
- * @memberof ArweaveService
38
- * @param {BundlrConfig} config - The configuration for the Bundlr network.
39
- * @param {any} signer - The wallet to send funds from. This can be either a web3 signer or a private key string.
40
- * @param {number} amount - The amount to fund, denoted in whatever currency specified by the config.
41
- * @returns {Promise<FundResponse>} - The fund response.
42
- */
43
- async function prefundBundlr(config,
44
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
- signer, amount) {
46
- const bundlr = new Bundlr(config.nodeUrl, config.currency, signer, config.providerUrl
47
- ? {
48
- providerUrl: config.providerUrl,
49
- }
50
- : undefined);
51
- await bundlr.ready();
52
- return bundlr.fund(amount);
53
- }
54
- /**
55
- * Store data on ARWeave using the Bundlr Network.
56
- *
57
- * @async
58
- * @function
59
- * @memberof ArweaveService
60
- * @param {BundlrConfig} config - Configuration object for the Bundlr instance.
61
- * @param {Web3Provider | string} signerOrPrivateKey - Wallet object used for interacting with the Bundlr instance.
62
- * If calling from a browser, this should be a `Web3Provider` instance. If calling from a Node.js
63
- * environment, this should be a private key string.
64
- * @param {JSON} data - The data to store in the Bundlr instance.
65
- * @param {Array<{ name: string, value: string }>} tags - Array of tag objects with `name` and `value` properties.
66
- * @param {boolean} [lazyFund=true] - Optional flag to fund the Bundlr instance lazily. If set to `false`, the
67
- * Bundlr node should already be funded or else uploads will fail.
68
- * @returns {Promise<UploadResponse>} Promise resolving with the upload response.
69
- */
70
- async function storeData(config, signerOrPrivateKey, data, tags, lazyFund = true) {
71
- const bundlr = new Bundlr(config.nodeUrl, config.currency, signerOrPrivateKey, config.providerUrl
72
- ? {
73
- providerUrl: config.providerUrl,
74
- }
75
- : undefined);
76
- await bundlr.ready();
77
- const dataStr = JSON.stringify(data);
78
- if (lazyFund) {
79
- const size = Buffer.byteLength(dataStr);
80
- const price = await bundlr.getPrice(size);
81
- // Add a buffer of 10% to account for fluctuations in the price
82
- price.multipliedBy(1.1);
83
- console.log(`Funding bundlr with ${price} ${config.currency} to upload data`);
84
- await bundlr.fund(price);
85
- }
86
- return bundlr.upload(dataStr, { tags });
87
- }
88
- /**
89
- * Helper method to query the Arweave network for receivables metadata previously uploaded.
90
- *
91
- * @async
92
- * @function
93
- * @memberof ArweaveService
94
- * @param {number} chainId - The chain ID.
95
- * @param {POOL_NAME} poolName - The pool name tag to query.
96
- * @param {POOL_TYPE} poolType - The pool type tag to query.
97
- * @param {string} sender - The sender tag to query.
98
- * @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
99
- * @returns {Promise<any>} Promise resolving with the queried data.
100
- */
101
- async function queryForMetadata(chainId, poolName, poolType, sender, referenceId) {
102
- var _a, _b, _c, _d;
103
- const config = getBundlrNetworkConfig(chainId);
104
- const query = gql `
105
- query ArweaveHumaMetadataQuery(
106
- $poolName: String!
107
- $poolType: String!
108
- $sender: String!
109
- $referenceId: String!
110
- ) {
111
- transactions(
112
- owners: [$sender]
113
- tags: [
114
- { name: "appName", values: ["HumaFinance"] }
115
- { name: "poolName", values: [$poolName] }
116
- { name: "poolType", values: [$poolType] }
117
- { name: "referenceId", values: [$referenceId] }
118
- ]
119
- ) {
120
- edges {
121
- node {
122
- id
123
- }
1
+ import Bundlr from '@bundlr-network/client';
2
+ import request, { gql } from 'graphql-request';
3
+ /**
4
+ * Get the configuration for Bundlr network given a chain ID
5
+ *
6
+ * @function
7
+ * @memberof ArweaveService
8
+ * @param {number} chainId - The chain ID.
9
+ * @returns {BundlrConfig} - The configuration for the Bundlr network.
10
+ */
11
+ export function getBundlrNetworkConfig(chainId) {
12
+ switch (chainId) {
13
+ case 5:
14
+ return {
15
+ nodeUrl: 'https://devnet.bundlr.network',
16
+ currency: 'ethereum',
17
+ providerUrl: 'https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161',
18
+ };
19
+ case 80001:
20
+ return {
21
+ nodeUrl: 'https://devnet.bundlr.network',
22
+ currency: 'matic',
23
+ providerUrl: 'https://rpc-mumbai.matic.today',
24
+ };
25
+ default:
26
+ return {
27
+ nodeUrl: '',
28
+ currency: '',
29
+ };
30
+ }
31
+ }
32
+ /**
33
+ * Prefund the Bundlr network with the specified amount. Required if not lazy funding.
34
+ *
35
+ * @async
36
+ * @function
37
+ * @memberof ArweaveService
38
+ * @param {BundlrConfig} config - The configuration for the Bundlr network.
39
+ * @param {any} signer - The wallet to send funds from. This can be either a web3 signer or a private key string.
40
+ * @param {number} amount - The amount to fund, denoted in whatever currency specified by the config.
41
+ * @returns {Promise<FundResponse>} - The fund response.
42
+ */
43
+ async function prefundBundlr(config,
44
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
45
+ signer, amount) {
46
+ const bundlr = new Bundlr(config.nodeUrl, config.currency, signer, config.providerUrl
47
+ ? {
48
+ providerUrl: config.providerUrl,
49
+ }
50
+ : undefined);
51
+ await bundlr.ready();
52
+ return bundlr.fund(amount);
53
+ }
54
+ /**
55
+ * Store data on ARWeave using the Bundlr Network.
56
+ *
57
+ * @async
58
+ * @function
59
+ * @memberof ArweaveService
60
+ * @param {BundlrConfig} config - Configuration object for the Bundlr instance.
61
+ * @param {Web3Provider | string} signerOrPrivateKey - Wallet object used for interacting with the Bundlr instance.
62
+ * If calling from a browser, this should be a `Web3Provider` instance. If calling from a Node.js
63
+ * environment, this should be a private key string.
64
+ * @param {JSON} data - The data to store in the Bundlr instance.
65
+ * @param {Array<{ name: string, value: string }>} tags - Array of tag objects with `name` and `value` properties.
66
+ * @param {boolean} [lazyFund=true] - Optional flag to fund the Bundlr instance lazily. If set to `false`, the
67
+ * Bundlr node should already be funded or else uploads will fail.
68
+ * @returns {Promise<UploadResponse>} Promise resolving with the upload response.
69
+ */
70
+ async function storeData(config, signerOrPrivateKey, data, tags, lazyFund = true) {
71
+ const bundlr = new Bundlr(config.nodeUrl, config.currency, signerOrPrivateKey, config.providerUrl
72
+ ? {
73
+ providerUrl: config.providerUrl,
124
74
  }
125
- }
75
+ : undefined);
76
+ await bundlr.ready();
77
+ const dataStr = JSON.stringify(data);
78
+ if (lazyFund) {
79
+ const size = Buffer.byteLength(dataStr);
80
+ const price = await bundlr.getPrice(size);
81
+ // Add a buffer of 10% to account for fluctuations in the price
82
+ price.multipliedBy(1.1);
83
+ console.log(`Funding bundlr with ${price} ${config.currency} to upload data`);
84
+ await bundlr.fund(price);
126
85
  }
127
- `;
128
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
129
- const data = await request(`${config.nodeUrl}/graphql`, query, {
130
- poolName,
131
- poolType,
132
- sender,
133
- referenceId,
134
- });
135
- 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;
136
- }
137
- /**
138
- * An object that contains functions to interact with Huma-related data stored on ARWeave
139
- * @namespace ARWeaveService
140
- */
141
- export const ARWeaveService = {
142
- queryForMetadata,
143
- storeData,
144
- prefundBundlr,
145
- getBundlrNetworkConfig,
146
- };
86
+ return bundlr.upload(dataStr, { tags });
87
+ }
88
+ /**
89
+ * Helper method to query the Arweave network for receivables metadata previously uploaded.
90
+ *
91
+ * @async
92
+ * @function
93
+ * @memberof ArweaveService
94
+ * @param {number} chainId - The chain ID.
95
+ * @param {POOL_NAME} poolName - The pool name tag to query.
96
+ * @param {POOL_TYPE} poolType - The pool type tag to query.
97
+ * @param {string} sender - The sender tag to query.
98
+ * @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
99
+ * @returns {Promise<any>} Promise resolving with the queried data.
100
+ */
101
+ async function queryForMetadata(chainId, poolName, poolType, sender, referenceId) {
102
+ var _a, _b, _c, _d;
103
+ const config = getBundlrNetworkConfig(chainId);
104
+ const query = gql `
105
+ query ArweaveHumaMetadataQuery(
106
+ $poolName: String!
107
+ $poolType: String!
108
+ $sender: String!
109
+ $referenceId: String!
110
+ ) {
111
+ transactions(
112
+ owners: [$sender]
113
+ tags: [
114
+ { name: "appName", values: ["HumaFinance"] }
115
+ { name: "poolName", values: [$poolName] }
116
+ { name: "poolType", values: [$poolType] }
117
+ { name: "referenceId", values: [$referenceId] }
118
+ ]
119
+ ) {
120
+ edges {
121
+ node {
122
+ id
123
+ }
124
+ }
125
+ }
126
+ }
127
+ `;
128
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
129
+ const data = await request(`${config.nodeUrl}/graphql`, query, {
130
+ poolName,
131
+ poolType,
132
+ sender,
133
+ referenceId,
134
+ });
135
+ 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;
136
+ }
137
+ /**
138
+ * An object that contains functions to interact with Huma-related data stored on ARWeave
139
+ * @namespace ARWeaveService
140
+ */
141
+ export const ARWeaveService = {
142
+ queryForMetadata,
143
+ storeData,
144
+ prefundBundlr,
145
+ getBundlrNetworkConfig,
146
+ };
147
147
  //# sourceMappingURL=ARWeaveService.js.map
@@ -1,36 +1,18 @@
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';
23
- /**
24
- * An object that contains functions to interact with Huma's EAVerse service.
25
- *
26
- * @namespace EAService
27
- *
28
- * approve: Submits a credit underwriting request to Huma's EAVerse.
29
- * @param {EAPayload} payload The payload for the underwrite approval.
30
- * @param {number} chainId The chain ID.
31
- * @returns {Promise<ApproveInfo>} Promise that returns approval info on success.
32
- * @throws {EARejectionError} If the underwrite approval is rejected.
33
- */
34
- export declare const EAService: {
35
- approve: (payload: import("@huma-finance/shared").EAPayload, chainId: number, isDev?: boolean | undefined) => Promise<import("@huma-finance/shared").ApproveInfo>;
36
- };
1
+ /**
2
+ * Object representing the response to the underwriting approval request.
3
+ * @typedef {Object} ApprovalResult
4
+ */
5
+ /**
6
+ * Object representing an invoice payload for underwriting approval.
7
+ *
8
+ * @typedef {Object} EAPayload
9
+ */
10
+ export type { ApprovalResult, EAPayload } from '@huma-finance/shared';
11
+ /**
12
+ * An object that contains functions to interact with Huma's EAVerse service.
13
+ *
14
+ * @namespace EAService
15
+ */
16
+ export declare const EAService: {
17
+ approve: (payload: import("@huma-finance/shared").EAPayload, chainId: number, isDev?: boolean | undefined) => Promise<import("@huma-finance/shared").Approval>;
18
+ };
@@ -1,16 +1,10 @@
1
- import { EAService as EAServiceInternal } from '@huma-finance/shared';
2
- /**
3
- * An object that contains functions to interact with Huma's EAVerse service.
4
- *
5
- * @namespace EAService
6
- *
7
- * approve: Submits a credit underwriting request to Huma's EAVerse.
8
- * @param {EAPayload} payload The payload for the underwrite approval.
9
- * @param {number} chainId The chain ID.
10
- * @returns {Promise<ApproveInfo>} Promise that returns approval info on success.
11
- * @throws {EARejectionError} If the underwrite approval is rejected.
12
- */
13
- export const EAService = {
14
- approve: EAServiceInternal.approve,
15
- };
1
+ import { EAService as EAServiceInternal } from '@huma-finance/shared';
2
+ /**
3
+ * An object that contains functions to interact with Huma's EAVerse service.
4
+ *
5
+ * @namespace EAService
6
+ */
7
+ export const EAService = {
8
+ approve: EAServiceInternal.approve,
9
+ };
16
10
  //# sourceMappingURL=EAService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EAService.js","sourceRoot":"","sources":["../../src/services/EAService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAyBrE;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,OAAO,EAAE,iBAAiB,CAAC,OAAO;CACnC,CAAA"}
1
+ {"version":3,"file":"EAService.js","sourceRoot":"","sources":["../../src/services/EAService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,iBAAiB,EAAE,MAAM,sBAAsB,CAAA;AAarE;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,OAAO,EAAE,iBAAiB,CAAC,OAAO;CACnC,CAAA"}
@@ -1,95 +1,76 @@
1
- import { TransactionReceipt, TransactionResponse, Web3Provider } from '@ethersproject/providers';
2
- import { BigNumberish, ethers, Overrides } from 'ethers';
3
- import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
4
- /**
5
- * Enumeration of payment methods. Maps to the PaymentMethod enum in the BaseCreditPoolReceivable contract.
6
- * Declarative payment methods are those that do not actually send ERC20 funds. Payable payment methods are those that
7
- * do by calling makePayment on the BaseCreditPool contract.
8
- *
9
- * @enum {number}
10
- * @memberof ReceivableService
11
- */
12
- export declare enum PaymentMethod {
13
- Declarative = 0,
14
- Payable = 1
15
- }
16
- /**
17
- * Pays a BaseCreditPoolReceivable using the specified payment method, given an referenceId mapping to the receivable's metadata
18
- *
19
- * @memberof ReceivableService
20
- * @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
21
- * @param {BigNumberish} receivableTokenId - The ID of the receivable token to pay.
22
- * @param {number} paymentAmount - The amount to pay the receivable.
23
- * @param {PaymentMethod} paymentMethod - The payment method to use. See PaymentMethod for more details.
24
- * @returns {Promise<TransactionReceipt>} - A Promise of the transaction receipt.
25
- * @throws {Error} - Throws an error if the BaseCreditPoolReceivable contract is not available on the network.
26
- */
27
- declare function payReceivableByReferenceId(signer: ethers.Signer, referenceId: string, paymentAmount: number, paymentMethod: PaymentMethod): Promise<TransactionReceipt>;
28
- /**
29
- * Pays a BaseCreditPoolReceivable using the specified payment method, given a tokenID of the receivable.
30
- *
31
- * @memberof ReceivableService
32
- * @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
33
- * @param {BigNumberish} receivableTokenId - The ID of the receivable token to pay.
34
- * @param {number} paymentAmount - The amount to pay the receivable.
35
- * @param {PaymentMethod} paymentMethod - The payment method to use. See PaymentMethod for more details.
36
- * @returns {Promise<TransactionReceipt>} - A Promise of the transaction receipt.
37
- * @throws {Error} - Throws an error if the BaseCreditPoolReceivable contract is not available on the network.
38
- */
39
- declare function payReceivableByTokenId(signer: ethers.Signer, receivableTokenId: BigNumberish, paymentAmount: number, paymentMethod: PaymentMethod): Promise<TransactionReceipt>;
40
- /**
41
- * Mints a new BaseCreditPoolReceivable token on the given chain of the signer
42
- *
43
- * @memberof ReceivableService
44
- * @param {ethers.Signer} signer - The signer used to send the transaction.
45
- * @param {string} recipient - The address of the recipient of the receivable token.
46
- * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
47
- * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
48
- * @param {number} receivableAmount - The amount of the receivable token to mint.
49
- * @param {number} maturityDate - The maturity date of the receivable token, in UNIX timestamp format.
50
- * @param {PaymentMethod} paymentMethod - The payment method to use. See PaymentMethod for more details.
51
- * @param {string} uri - The URI of the receivable token metadata.
52
- * @param {Overrides} gasOpts - The gas options to use for the transaction.
53
- * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
54
- * @throws {Error} - Throws an error if the BaseCreditPoolReceivable contract is not available on the network.
55
- */
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>;
57
- /**
58
- * Mints a BaseCreditPoolReceivable token with metadata uploaded onto ARWeave
59
- *
60
- * @memberof ReceivableService
61
- * @param {Web3Provider | ethers.Signer} signerOrProvider - If calling this function from a browser, this function expects a Web3Provider.
62
- * If calling this function from a server, this function expects an ethers Signer. Note that privateKey only needs to be included
63
- * from server calls.
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.
65
- * @param {number} chainId - The chain ID to mint the receivable token on and pay ARWeave funds from.
66
- * @param {string} recipient - The receivable token recipient.
67
- * @param {POOL_NAME} poolName - The pool name. Used to lookup the pool address to pay to.
68
- * @param {POOL_TYPE} poolType - The pool type. Used to lookup the pool address to pay to.
69
- * @param {number} receivableAmount - The receivable amount.
70
- * @param {number} maturityDate - The maturity date of the receivable, in UNIX timestamp format.
71
- * @param {PaymentMethod} paymentMethod - The payment method to use. See PaymentMethod for more details.
72
- * @param {JSON} metadata - The metadata in JSON format. This will be uploaded onto ARWeave
73
- * @param {number} referenceId - An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.
74
- * @param {Array<{ name: string, value: string }>} extraTags - Any extraTags you'd like to tag your metadata with. Note that metadata on
75
- * ARWeave is indexed by these tags, so make sure to include any tags that you'd like to be able to query by.
76
- * @param {boolean} [lazyFund=true] - Whether to lazy fund the ARWeave uploads. If true, the ARWeave uploads will be paid for by the
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.
79
- * @returns {Promise<TransactionReceipt>} - The transaction receipt.
80
- */
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: {
82
- name: string;
83
- value: string;
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
+ import { TransactionResponse, Web3Provider } from '@ethersproject/providers';
2
+ import { BigNumberish, ethers, Overrides } from 'ethers';
3
+ import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
4
+ declare function declareReceivablePaymentByReferenceId(signer: ethers.Signer, referenceId: string, paymentAmount: number): Promise<TransactionResponse>;
5
+ /**
6
+ * Declares a payment on a RealWorldReceivable given a tokenID of the receivable.
7
+ *
8
+ * @async
9
+ * @function
10
+ * @memberof ReceivableService
11
+ * @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
12
+ * @param {BigNumberish} receivableTokenId - The ID of the receivable token to pay.
13
+ * @param {number} paymentAmount - The amount to pay the receivable.
14
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction receipt.
15
+ * @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
16
+ */
17
+ declare function declareReceivablePaymentByTokenId(signer: ethers.Signer, receivableTokenId: BigNumberish, paymentAmount: number): Promise<TransactionResponse>;
18
+ /**
19
+ * Creates a new RealWorldReceivable token on the given chain of the signer
20
+ *
21
+ * @async
22
+ * @function
23
+ * @memberof ReceivableService
24
+ * @param {ethers.Signer} signer - The signer used to send the transaction.
25
+ * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
26
+ * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
27
+ * @param {number} currencyCode - The ISO 4217 currency code that the receivable is denominated in
28
+ * @param {number} receivableAmount - The amount of the receivable token to mint.
29
+ * @param {number} maturityDate - The maturity date of the receivable token, in UNIX timestamp format.
30
+ * @param {string} uri - The URI of the receivable token metadata.
31
+ * @param {Overrides} gasOpts - The gas options to use for the transaction.
32
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
33
+ * @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
34
+ */
35
+ declare function createReceivable(signer: ethers.Signer, poolName: POOL_NAME, poolType: POOL_TYPE, currencyCode: number, receivableAmount: number, maturityDate: number, uri: string, gasOpts?: Overrides): Promise<TransactionResponse>;
36
+ /**
37
+ * Creates a RealWorldReceivable token with metadata uploaded onto ARWeave
38
+ *
39
+ * @async
40
+ * @function
41
+ * @memberof ReceivableService
42
+ * @param {Web3Provider | ethers.Signer} signerOrProvider - If calling this function from a browser, this function expects a Web3Provider.
43
+ * If calling this function from a server, this function expects an ethers Signer. Note that privateKey only needs to be included
44
+ * from server calls.
45
+ * @param {string | null} privateKey - Private key of the wallet used to upload metadata to ARWeave. Only required if calling this function from a server.
46
+ * @param {number} chainId - The chain ID to mint the receivable token on and pay ARWeave funds from.
47
+ * @param {string} recipient - The receivable token recipient.
48
+ * @param {POOL_NAME} poolName - The pool name. Used to lookup the pool address to pay to.
49
+ * @param {POOL_TYPE} poolType - The pool type. Used to lookup the pool address to pay to.
50
+ * @param {number} currencyCode - The ISO 4217 currency code that the receivable is denominated in
51
+ * @param {number} receivableAmount - The receivable amount.
52
+ * @param {number} maturityDate - The maturity date of the receivable, in UNIX timestamp format.
53
+ * @param {JSON} metadata - The metadata in JSON format. This will be uploaded onto ARWeave
54
+ * @param {number} referenceId - An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.
55
+ * @param {Array<{ name: string, value: string }>} extraTags - Any extraTags you'd like to tag your metadata with. Note that metadata on
56
+ * ARWeave is indexed by these tags, so make sure to include any tags that you'd like to be able to query by.
57
+ * @param {boolean} [lazyFund=true] - Whether to lazy fund the ARWeave uploads. If true, the ARWeave uploads will be paid for by the
58
+ * metadata uploader immediately before uploading. If false, the ARWeave node must be pre-funded before calling this function.
59
+ * @param {Overrides} [gasOpts] - Optional gas overrides for the transaction.
60
+ * @returns {Promise<TransactionResponse>} - The transaction receipt.
61
+ */
62
+ declare function createReceivableWithMetadata(signerOrProvider: Web3Provider | ethers.Signer, privateKey: string | null, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, currencyCode: number, receivableAmount: number, maturityDate: number, metadata: JSON, referenceId: string, extraTags: {
63
+ name: string;
64
+ value: string;
65
+ }[], lazyFund?: boolean, gasOpts?: Overrides): Promise<TransactionResponse>;
66
+ /**
67
+ * An object that contains functions to interact with Huma's receivables.
68
+ * @namespace ReceivableService
69
+ */
70
+ export declare const ReceivableService: {
71
+ createReceivableWithMetadata: typeof createReceivableWithMetadata;
72
+ createReceivable: typeof createReceivable;
73
+ declareReceivablePaymentByTokenId: typeof declareReceivablePaymentByTokenId;
74
+ declareReceivablePaymentByReferenceId: typeof declareReceivablePaymentByReferenceId;
75
+ };
76
+ export {};