@huma-finance/sdk 0.0.21 → 0.0.24

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 (131) hide show
  1. package/API.md +482 -482
  2. package/LICENSE +660 -660
  3. package/README.md +34 -34
  4. package/dist/cjs/graphql/generatedTypes.d.ts +40 -40
  5. package/dist/cjs/graphql/generatedTypes.js +8 -8
  6. package/dist/cjs/graphql/index.d.ts +1 -1
  7. package/dist/cjs/graphql/index.js +4 -4
  8. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -10
  9. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js +21 -21
  10. package/dist/cjs/helpers/PoolContractHelper.d.ts +104 -104
  11. package/dist/cjs/helpers/PoolContractHelper.js +102 -104
  12. package/dist/cjs/helpers/PoolContractHelper.js.map +1 -1
  13. package/dist/cjs/helpers/RealWorldReceivableContractHelper.d.ts +10 -10
  14. package/dist/cjs/helpers/RealWorldReceivableContractHelper.js +21 -21
  15. package/dist/cjs/helpers/index.d.ts +3 -3
  16. package/dist/cjs/helpers/index.js +6 -6
  17. package/dist/cjs/hooks/index.d.ts +4 -4
  18. package/dist/cjs/hooks/index.js +7 -7
  19. package/dist/cjs/hooks/useContract.d.ts +13 -13
  20. package/dist/cjs/hooks/useContract.js +30 -30
  21. package/dist/cjs/hooks/useERC20TransferableReceivableContract.d.ts +12 -12
  22. package/dist/cjs/hooks/useERC20TransferableReceivableContract.js +20 -20
  23. package/dist/cjs/hooks/usePoolContract.d.ts +60 -60
  24. package/dist/cjs/hooks/usePoolContract.js +53 -53
  25. package/dist/cjs/hooks/useRealWorldReceivableContract.d.ts +10 -10
  26. package/dist/cjs/hooks/useRealWorldReceivableContract.js +19 -19
  27. package/dist/cjs/index.d.ts +4 -4
  28. package/dist/cjs/index.js +7 -7
  29. package/dist/cjs/services/ARWeaveService.d.ts +81 -81
  30. package/dist/cjs/services/ARWeaveService.js +140 -145
  31. package/dist/cjs/services/ARWeaveService.js.map +1 -1
  32. package/dist/cjs/services/EAService.d.ts +18 -20
  33. package/dist/cjs/services/EAService.js +12 -33
  34. package/dist/cjs/services/EAService.js.map +1 -1
  35. package/dist/cjs/services/ReceivableService.d.ts +87 -89
  36. package/dist/cjs/services/ReceivableService.js +188 -193
  37. package/dist/cjs/services/ReceivableService.js.map +1 -1
  38. package/dist/cjs/services/SubgraphService.d.ts +53 -53
  39. package/dist/cjs/services/SubgraphService.js +100 -93
  40. package/dist/cjs/services/SubgraphService.js.map +1 -1
  41. package/dist/cjs/services/index.d.ts +4 -4
  42. package/dist/cjs/services/index.js +7 -7
  43. package/dist/cjs/utils/chain.d.ts +14 -15
  44. package/dist/cjs/utils/chain.js +33 -37
  45. package/dist/cjs/utils/chain.js.map +1 -1
  46. package/dist/cjs/utils/index.d.ts +3 -4
  47. package/dist/cjs/utils/index.js +6 -7
  48. package/dist/cjs/utils/index.js.map +1 -1
  49. package/dist/cjs/utils/poolInfo.d.ts +8 -8
  50. package/dist/cjs/utils/poolInfo.js +12 -12
  51. package/dist/cjs/utils/web3.d.ts +4 -4
  52. package/dist/cjs/utils/web3.js +28 -28
  53. package/dist/graphql/generatedTypes.d.ts +40 -40
  54. package/dist/graphql/generatedTypes.js +4 -4
  55. package/dist/graphql/index.d.ts +1 -1
  56. package/dist/graphql/index.js +1 -1
  57. package/dist/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -10
  58. package/dist/helpers/ERC20TransferableReceivableContractHelper.js +17 -17
  59. package/dist/helpers/PoolContractHelper.d.ts +104 -104
  60. package/dist/helpers/PoolContractHelper.js +94 -96
  61. package/dist/helpers/PoolContractHelper.js.map +1 -1
  62. package/dist/helpers/RealWorldReceivableContractHelper.d.ts +10 -10
  63. package/dist/helpers/RealWorldReceivableContractHelper.js +17 -17
  64. package/dist/helpers/index.d.ts +3 -3
  65. package/dist/helpers/index.js +3 -3
  66. package/dist/hooks/index.d.ts +4 -4
  67. package/dist/hooks/index.js +4 -4
  68. package/dist/hooks/useContract.d.ts +13 -13
  69. package/dist/hooks/useContract.js +26 -26
  70. package/dist/hooks/useERC20TransferableReceivableContract.d.ts +12 -12
  71. package/dist/hooks/useERC20TransferableReceivableContract.js +16 -16
  72. package/dist/hooks/usePoolContract.d.ts +60 -60
  73. package/dist/hooks/usePoolContract.js +48 -48
  74. package/dist/hooks/useRealWorldReceivableContract.d.ts +10 -10
  75. package/dist/hooks/useRealWorldReceivableContract.js +15 -15
  76. package/dist/index.d.ts +4 -4
  77. package/dist/index.js +4 -4
  78. package/dist/services/ARWeaveService.d.ts +81 -81
  79. package/dist/services/ARWeaveService.js +135 -140
  80. package/dist/services/ARWeaveService.js.map +1 -1
  81. package/dist/services/EAService.d.ts +18 -20
  82. package/dist/services/EAService.js +9 -30
  83. package/dist/services/EAService.js.map +1 -1
  84. package/dist/services/ReceivableService.d.ts +87 -89
  85. package/dist/services/ReceivableService.js +184 -189
  86. package/dist/services/ReceivableService.js.map +1 -1
  87. package/dist/services/SubgraphService.d.ts +53 -53
  88. package/dist/services/SubgraphService.js +97 -90
  89. package/dist/services/SubgraphService.js.map +1 -1
  90. package/dist/services/index.d.ts +4 -4
  91. package/dist/services/index.js +4 -4
  92. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  93. package/dist/utils/chain.d.ts +14 -15
  94. package/dist/utils/chain.js +28 -31
  95. package/dist/utils/chain.js.map +1 -1
  96. package/dist/utils/index.d.ts +3 -4
  97. package/dist/utils/index.js +3 -4
  98. package/dist/utils/index.js.map +1 -1
  99. package/dist/utils/poolInfo.d.ts +8 -8
  100. package/dist/utils/poolInfo.js +8 -8
  101. package/dist/utils/web3.d.ts +4 -4
  102. package/dist/utils/web3.js +23 -23
  103. package/getting-started.md +190 -190
  104. package/package.json +3 -3
  105. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.d.ts +0 -10
  106. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js +0 -22
  107. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js.map +0 -1
  108. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.d.ts +0 -10
  109. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js +0 -20
  110. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js.map +0 -1
  111. package/dist/cjs/hooks/useReceivableFactoringPoolContract.d.ts +0 -10
  112. package/dist/cjs/hooks/useReceivableFactoringPoolContract.js +0 -17
  113. package/dist/cjs/hooks/useReceivableFactoringPoolContract.js.map +0 -1
  114. package/dist/cjs/utils/maticGasStation.d.ts +0 -3
  115. package/dist/cjs/utils/maticGasStation.js +0 -39
  116. package/dist/cjs/utils/maticGasStation.js.map +0 -1
  117. package/dist/helpers/BaseCreditPoolReceivableContractHelper.d.ts +0 -10
  118. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js +0 -18
  119. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js.map +0 -1
  120. package/dist/hooks/useBaseCreditPoolReceivableContract.d.ts +0 -10
  121. package/dist/hooks/useBaseCreditPoolReceivableContract.js +0 -16
  122. package/dist/hooks/useBaseCreditPoolReceivableContract.js.map +0 -1
  123. package/dist/hooks/usePool.d.ts +0 -0
  124. package/dist/hooks/usePool.js +0 -2
  125. package/dist/hooks/usePool.js.map +0 -1
  126. package/dist/hooks/useReceivableFactoringPoolContract.d.ts +0 -10
  127. package/dist/hooks/useReceivableFactoringPoolContract.js +0 -13
  128. package/dist/hooks/useReceivableFactoringPoolContract.js.map +0 -1
  129. package/dist/utils/maticGasStation.d.ts +0 -3
  130. package/dist/utils/maticGasStation.js +0 -33
  131. package/dist/utils/maticGasStation.js.map +0 -1
@@ -1,141 +1,136 @@
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: // Goerli
14
- return {
15
- nodeUrl: 'https://devnet.bundlr.network',
16
- currency: 'ethereum',
17
- providerUrl: 'https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161',
18
- };
19
- case 80001: // Mumbai
20
- return {
21
- nodeUrl: 'https://devnet.bundlr.network',
22
- currency: 'matic',
23
- providerUrl: 'https://rpc-mumbai.matic.today',
24
- };
25
- case 137: // Matic
26
- return {
27
- nodeUrl: 'https://node1.bundlr.network',
28
- currency: 'matic',
29
- };
30
- default:
31
- return {
32
- nodeUrl: '',
33
- currency: '',
34
- };
35
- }
36
- }
37
- /**
38
- * Prefund the Bundlr network with the specified amount. Required if not lazy funding.
39
- *
40
- * @async
41
- * @function
42
- * @memberof ArweaveService
43
- * @param {BundlrConfig} config - The configuration for the Bundlr network.
44
- * @param {any} signer - The wallet to send funds from. This can be either a web3 signer or a private key string.
45
- * @param {number} amount - The amount to fund, denoted in whatever currency specified by the config.
46
- * @returns {Promise<FundResponse>} - The fund response.
47
- */
48
- async function prefundBundlr(config,
49
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
- signer, amount) {
51
- const bundlr = new Bundlr(config.nodeUrl, config.currency, signer, config.providerUrl
52
- ? {
53
- providerUrl: config.providerUrl,
54
- }
55
- : undefined);
56
- await bundlr.ready();
57
- return bundlr.fund(amount);
58
- }
59
- /**
60
- * Store data on ARWeave using the Bundlr Network.
61
- *
62
- * @async
63
- * @function
64
- * @memberof ArweaveService
65
- * @param {BundlrConfig} config - Configuration object for the Bundlr instance.
66
- * @param {Web3Provider | string} signerOrPrivateKey - Wallet object used for interacting with the Bundlr instance.
67
- * If calling from a browser, this should be a `Web3Provider` instance. If calling from a Node.js
68
- * environment, this should be a private key string.
69
- * @param {JSON} data - The data to store in the Bundlr instance.
70
- * @param {Array<{ name: string, value: string }>} tags - Array of tag objects with `name` and `value` properties.
71
- * @param {boolean} [lazyFund=true] - Optional flag to fund the Bundlr instance lazily. If set to `false`, the
72
- * Bundlr node should already be funded or else uploads will fail.
73
- * @returns {Promise<UploadResponse>} Promise resolving with the upload response.
74
- */
75
- async function storeData(config, signerOrPrivateKey, data, tags, lazyFund = true) {
76
- const bundlr = new Bundlr(config.nodeUrl, config.currency, signerOrPrivateKey, config.providerUrl
77
- ? {
78
- providerUrl: config.providerUrl,
79
- }
80
- : undefined);
81
- await bundlr.ready();
82
- const dataStr = JSON.stringify(data);
83
- if (lazyFund) {
84
- const size = Buffer.byteLength(dataStr);
85
- const price = await bundlr.getPrice(size);
86
- // Add a buffer of 10% to account for fluctuations in the price
87
- price.multipliedBy(1.1);
88
- console.log(`Funding bundlr with ${price} ${config.currency} to upload data`);
89
- await bundlr.fund(price);
90
- }
91
- return bundlr.upload(dataStr, { tags });
92
- }
93
- /**
94
- * Helper method to query the Arweave network for receivables metadata previously uploaded.
95
- *
96
- * @async
97
- * @function
98
- * @memberof ArweaveService
99
- * @param {number} chainId - The chain ID.
100
- * @param {string} sender - The sender tag to query.
101
- * @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
102
- * @returns {Promise<any>} Promise resolving with the queried data.
103
- */
104
- async function queryForMetadata(chainId, sender, referenceId) {
105
- var _a, _b, _c, _d;
106
- const config = getBundlrNetworkConfig(chainId);
107
- const query = 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
- `;
124
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
125
- const data = await request(`${config.nodeUrl}/graphql`, query, {
126
- sender,
127
- referenceId,
128
- });
129
- 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;
130
- }
131
- /**
132
- * An object that contains functions to interact with Huma-related data stored on ARWeave
133
- * @namespace ARWeaveService
134
- */
135
- export const ARWeaveService = {
136
- queryForMetadata,
137
- storeData,
138
- prefundBundlr,
139
- getBundlrNetworkConfig,
140
- };
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 {string} sender - The sender tag to query.
96
+ * @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
97
+ * @returns {Promise<any>} Promise resolving with the queried data.
98
+ */
99
+ async function queryForMetadata(chainId, sender, referenceId) {
100
+ var _a, _b, _c, _d;
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
+ }
118
+ `;
119
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
120
+ const data = await request(`${config.nodeUrl}/graphql`, query, {
121
+ sender,
122
+ referenceId,
123
+ });
124
+ 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;
125
+ }
126
+ /**
127
+ * An object that contains functions to interact with Huma-related data stored on ARWeave
128
+ * @namespace ARWeaveService
129
+ */
130
+ export const ARWeaveService = {
131
+ queryForMetadata,
132
+ storeData,
133
+ prefundBundlr,
134
+ getBundlrNetworkConfig,
135
+ };
141
136
  //# sourceMappingURL=ARWeaveService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ARWeaveService.js","sourceRoot":"","sources":["../../src/services/ARWeaveService.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,wBAAwB,CAAA;AAM3C,OAAO,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAkB9C;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,QAAQ,OAAO,EAAE;QACf,KAAK,CAAC,EAAE,SAAS;YACf,OAAO;gBACL,OAAO,EAAE,+BAA+B;gBACxC,QAAQ,EAAE,UAAU;gBACpB,WAAW,EACT,8DAA8D;aACjE,CAAA;QACH,KAAK,KAAK,EAAE,SAAS;YACnB,OAAO;gBACL,OAAO,EAAE,+BAA+B;gBACxC,QAAQ,EAAE,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QACZ,MAAM,IAAI,GAAG,MAAM,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;;;;;;;;;;GAUG;AACH,KAAK,UAAU,gBAAgB,CAC7B,OAAe,EACf,MAAc,EACd,WAAmB;;IAEnB,MAAM,MAAM,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAA;IAC9C,MAAM,KAAK,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;GAgBhB,CAAA;IAED,8DAA8D;IAC9D,MAAM,IAAI,GAAQ,MAAM,OAAO,CAAC,GAAG,MAAM,CAAC,OAAO,UAAU,EAAE,KAAK,EAAE;QAClE,MAAM;QACN,WAAW;KACZ,CAAC,CAAA;IAEF,OAAO,MAAA,MAAA,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,0CAAE,KAAK,0CAAG,CAAC,CAAC,0CAAE,IAAI,0CAAE,EAAE,CAAA;AACjD,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG;IAC5B,gBAAgB;IAChB,SAAS;IACT,aAAa;IACb,sBAAsB;CACvB,CAAA"}
@@ -1,20 +1,18 @@
1
- import { EAPayload, EAPreapprovalPayload } from '@huma-finance/shared';
2
- /**
3
- * Object representing the response to the underwriting approval request.
4
- * @typedef {Object} ApprovalResult
5
- */
6
- /**
7
- * Object representing an invoice payload for underwriting approval.
8
- *
9
- * @typedef {Object} EAPayload
10
- */
11
- export type { ApprovalResult, EAPayload } from '@huma-finance/shared';
12
- /**
13
- * An object that contains functions to interact with Huma's EAVerse service.
14
- *
15
- * @namespace EAService
16
- */
17
- export declare const EAService: {
18
- approve: (payload: EAPayload, chainId: number) => Promise<import("@huma-finance/shared").Approval>;
19
- preapprove: (payload: EAPreapprovalPayload, chainId: number) => Promise<import("@huma-finance/shared").PreapprovalResult>;
20
- };
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,31 +1,10 @@
1
- import { EAService as EAServiceInternal, } from '@huma-finance/shared';
2
- /**
3
- * Submits a credit underwriting request to Huma's EAVerse. This approves a creditline
4
- * in Huma's pools that can be drawn down by the borrower.
5
- *
6
- * @memberof EAService
7
- * @param {EAPayload} payload The payload for the underwrite approval.
8
- * @param {number} chainId The chain ID.
9
- * @returns {Promise<Approval>} Promise that returns the approval on success.
10
- * @throws {EARejectionError} If the underwrite approval is rejected.
11
- */
12
- const approve = async (payload, chainId) => EAServiceInternal.approve(payload, chainId);
13
- /**
14
- * Checks whether or not a credit underwriting request to Huma's EAVerse would be approved.
15
- * Note that this does not approve a creditline in Huma's pools and an approve call is still required.
16
- *
17
- * @param {EAPreapprovalPayload} payload The payload for the underwrite approval.
18
- * @param {number} chainId The chain ID.
19
- * @returns {Promise<Approval>} Promise that returns the approval on success.
20
- */
21
- const preapprove = async (payload, chainId) => EAServiceInternal.preapprove(payload, chainId);
22
- /**
23
- * An object that contains functions to interact with Huma's EAVerse service.
24
- *
25
- * @namespace EAService
26
- */
27
- export const EAService = {
28
- approve,
29
- preapprove,
30
- };
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
+ };
31
10
  //# sourceMappingURL=EAService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EAService.js","sourceRoot":"","sources":["../../src/services/EAService.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,SAAS,IAAI,iBAAiB,GAC/B,MAAM,sBAAsB,CAAA;AAa7B;;;;;;;;;GASG;AACH,MAAM,OAAO,GAAG,KAAK,EAAE,OAAkB,EAAE,OAAe,EAAE,EAAE,CAC5D,iBAAiB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AAE7C;;;;;;;GAOG;AACH,MAAM,UAAU,GAAG,KAAK,EAAE,OAA6B,EAAE,OAAe,EAAE,EAAE,CAC1E,iBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AAEhD;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,OAAO;IACP,UAAU;CACX,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,89 +1,87 @@
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
- /**
5
- * Declares a payment on a RealWorldReceivable given a reference ID of the receivable, which was used as an index for ARWeave data.
6
- *
7
- * @async
8
- * @function
9
- * @memberof ReceivableService
10
- * @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
11
- * @param {string} referenceId - An internal identifier value added as a tag on ARWeave
12
- * @param {number} paymentAmount - The amount to declare paid to the receivable.
13
- * @param {Overrides} [gasOpts] - The gas options to use for the transaction.
14
- * @returns {Promise<TransactionResponse>} - A Promise of the transaction receipt.
15
- */
16
- declare function declareReceivablePaymentByReferenceId(signer: ethers.Signer, referenceId: string, paymentAmount: number, gasOpts?: Overrides): Promise<TransactionResponse>;
17
- /**
18
- * Declares a payment on a RealWorldReceivable given a tokenID of the receivable.
19
- *
20
- * @async
21
- * @function
22
- * @memberof ReceivableService
23
- * @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
24
- * @param {BigNumberish} receivableTokenId - The ID of the receivable token to pay.
25
- * @param {number} paymentAmount - The amount to pay the receivable.
26
- * @param {Overrides} [gasOpts] - The gas options to use for the transaction.
27
- * @returns {Promise<TransactionResponse>} - A Promise of the transaction receipt.
28
- * @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
29
- */
30
- declare function declareReceivablePaymentByTokenId(signer: ethers.Signer, receivableTokenId: BigNumberish, paymentAmount: number, gasOpts?: Overrides): Promise<TransactionResponse>;
31
- /**
32
- * Creates a new RealWorldReceivable token on the given chain of the signer
33
- *
34
- * @async
35
- * @function
36
- * @memberof ReceivableService
37
- * @param {ethers.Signer} signer - The signer used to send the transaction.
38
- * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
39
- * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
40
- * @param {number} currencyCode - The ISO 4217 currency code that the receivable is denominated in
41
- * @param {number} receivableAmount - The amount of the receivable token to mint.
42
- * @param {number} maturityDate - The maturity date of the receivable token, in UNIX timestamp format.
43
- * @param {string} uri - The URI of the receivable token metadata.
44
- * @param {Overrides} [gasOpts] - The gas options to use for the transaction.
45
- * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
46
- * @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
47
- */
48
- declare function createReceivable(signer: ethers.Signer, poolName: POOL_NAME, poolType: POOL_TYPE, currencyCode: number, receivableAmount: number, maturityDate: number, uri: string, gasOpts?: Overrides): Promise<TransactionResponse>;
49
- /**
50
- * Creates a RealWorldReceivable token with metadata uploaded onto ARWeave
51
- *
52
- * @async
53
- * @function
54
- * @memberof ReceivableService
55
- * @param {Web3Provider | ethers.Signer} signerOrProvider - If calling this function from a browser, this function expects a Web3Provider.
56
- * If calling this function from a server, this function expects an ethers Signer. Note that privateKey only needs to be included
57
- * from server calls.
58
- * @param {string | null} privateKey - Private key of the wallet used to upload metadata to ARWeave. Only required if calling this function from a server.
59
- * @param {number} chainId - The chain ID to mint the receivable token on and pay ARWeave funds from.
60
- * @param {string} recipient - The receivable token recipient.
61
- * @param {POOL_NAME} poolName - The pool name. Used to lookup the pool address to pay to.
62
- * @param {POOL_TYPE} poolType - The pool type. Used to lookup the pool address to pay to.
63
- * @param {number} currencyCode - The ISO 4217 currency code that the receivable is denominated in
64
- * @param {number} receivableAmount - The receivable amount.
65
- * @param {number} maturityDate - The maturity date of the receivable, in UNIX timestamp format.
66
- * @param {JSON} metadata - The metadata in JSON format. This will be uploaded onto ARWeave
67
- * @param {number} referenceId - An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.
68
- * @param {Array<{ name: string, value: string }>} extraTags - Any extraTags you'd like to tag your metadata with. Note that metadata on
69
- * ARWeave is indexed by these tags, so make sure to include any tags that you'd like to be able to query by.
70
- * @param {boolean} [lazyFund=true] - Whether to lazy fund the ARWeave uploads. If true, the ARWeave uploads will be paid for by the
71
- * metadata uploader immediately before uploading. If false, the ARWeave node must be pre-funded before calling this function.
72
- * @param {Overrides} [gasOpts] - Optional gas overrides for the transaction.
73
- * @returns {Promise<TransactionResponse>} - The transaction receipt.
74
- */
75
- 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: {
76
- name: string;
77
- value: string;
78
- }[], lazyFund?: boolean, gasOpts?: Overrides): Promise<TransactionResponse>;
79
- /**
80
- * An object that contains functions to interact with Huma's receivables.
81
- * @namespace ReceivableService
82
- */
83
- export declare const ReceivableService: {
84
- createReceivableWithMetadata: typeof createReceivableWithMetadata;
85
- createReceivable: typeof createReceivable;
86
- declareReceivablePaymentByTokenId: typeof declareReceivablePaymentByTokenId;
87
- declareReceivablePaymentByReferenceId: typeof declareReceivablePaymentByReferenceId;
88
- };
89
- 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
+ /**
5
+ * Declares a payment on a RealWorldReceivable given a reference ID of the receivable, which was used as an index for ARWeave data.
6
+ *
7
+ * @async
8
+ * @function
9
+ * @memberof ReceivableService
10
+ * @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
11
+ * @param {string} referenceId - An internal identifier value added as a tag on ARWeave
12
+ * @param {number} paymentAmount - The amount to declare paid to the receivable.
13
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction receipt.
14
+ */
15
+ declare function declareReceivablePaymentByReferenceId(signer: ethers.Signer, referenceId: string, paymentAmount: number): Promise<TransactionResponse>;
16
+ /**
17
+ * Declares a payment on a RealWorldReceivable given a tokenID of the receivable.
18
+ *
19
+ * @async
20
+ * @function
21
+ * @memberof ReceivableService
22
+ * @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
23
+ * @param {BigNumberish} receivableTokenId - The ID of the receivable token to pay.
24
+ * @param {number} paymentAmount - The amount to pay the receivable.
25
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction receipt.
26
+ * @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
27
+ */
28
+ declare function declareReceivablePaymentByTokenId(signer: ethers.Signer, receivableTokenId: BigNumberish, paymentAmount: number): Promise<TransactionResponse>;
29
+ /**
30
+ * Creates a new RealWorldReceivable token on the given chain of the signer
31
+ *
32
+ * @async
33
+ * @function
34
+ * @memberof ReceivableService
35
+ * @param {ethers.Signer} signer - The signer used to send the transaction.
36
+ * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
37
+ * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
38
+ * @param {number} currencyCode - The ISO 4217 currency code that the receivable is denominated in
39
+ * @param {number} receivableAmount - The amount of the receivable token to mint.
40
+ * @param {number} maturityDate - The maturity date of the receivable token, in UNIX timestamp format.
41
+ * @param {string} uri - The URI of the receivable token metadata.
42
+ * @param {Overrides} gasOpts - The gas options to use for the transaction.
43
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
44
+ * @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
45
+ */
46
+ declare function createReceivable(signer: ethers.Signer, poolName: POOL_NAME, poolType: POOL_TYPE, currencyCode: number, receivableAmount: number, maturityDate: number, uri: string, gasOpts?: Overrides): Promise<TransactionResponse>;
47
+ /**
48
+ * Creates a RealWorldReceivable token with metadata uploaded onto ARWeave
49
+ *
50
+ * @async
51
+ * @function
52
+ * @memberof ReceivableService
53
+ * @param {Web3Provider | ethers.Signer} signerOrProvider - If calling this function from a browser, this function expects a Web3Provider.
54
+ * If calling this function from a server, this function expects an ethers Signer. Note that privateKey only needs to be included
55
+ * from server calls.
56
+ * @param {string | null} privateKey - Private key of the wallet used to upload metadata to ARWeave. Only required if calling this function from a server.
57
+ * @param {number} chainId - The chain ID to mint the receivable token on and pay ARWeave funds from.
58
+ * @param {string} recipient - The receivable token recipient.
59
+ * @param {POOL_NAME} poolName - The pool name. Used to lookup the pool address to pay to.
60
+ * @param {POOL_TYPE} poolType - The pool type. Used to lookup the pool address to pay to.
61
+ * @param {number} currencyCode - The ISO 4217 currency code that the receivable is denominated in
62
+ * @param {number} receivableAmount - The receivable amount.
63
+ * @param {number} maturityDate - The maturity date of the receivable, in UNIX timestamp format.
64
+ * @param {JSON} metadata - The metadata in JSON format. This will be uploaded onto ARWeave
65
+ * @param {number} referenceId - An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.
66
+ * @param {Array<{ name: string, value: string }>} extraTags - Any extraTags you'd like to tag your metadata with. Note that metadata on
67
+ * ARWeave is indexed by these tags, so make sure to include any tags that you'd like to be able to query by.
68
+ * @param {boolean} [lazyFund=true] - Whether to lazy fund the ARWeave uploads. If true, the ARWeave uploads will be paid for by the
69
+ * metadata uploader immediately before uploading. If false, the ARWeave node must be pre-funded before calling this function.
70
+ * @param {Overrides} [gasOpts] - Optional gas overrides for the transaction.
71
+ * @returns {Promise<TransactionResponse>} - The transaction receipt.
72
+ */
73
+ 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: {
74
+ name: string;
75
+ value: string;
76
+ }[], lazyFund?: boolean, gasOpts?: Overrides): Promise<TransactionResponse>;
77
+ /**
78
+ * An object that contains functions to interact with Huma's receivables.
79
+ * @namespace ReceivableService
80
+ */
81
+ export declare const ReceivableService: {
82
+ createReceivableWithMetadata: typeof createReceivableWithMetadata;
83
+ createReceivable: typeof createReceivable;
84
+ declareReceivablePaymentByTokenId: typeof declareReceivablePaymentByTokenId;
85
+ declareReceivablePaymentByReferenceId: typeof declareReceivablePaymentByReferenceId;
86
+ };
87
+ export {};