@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
package/README.md CHANGED
@@ -4,7 +4,7 @@ The Huma SDK includes utilities and services for interacting with different laye
4
4
 
5
5
  ## Getting Started
6
6
 
7
- We recommend onboarding onto our SDK using the [Getting Started guide](docs/getting-started.md)
7
+ We recommend onboarding onto our SDK using the [Getting Started guide](getting-started.md)
8
8
 
9
9
  ## Documentation
10
10
 
@@ -1,10 +1,10 @@
1
1
  import { Contract, ethers } from 'ethers';
2
2
  /**
3
- * Returns an ethers contract instance for the BaseCreditPoolReceivable contract
3
+ * Returns an ethers contract instance for the ERC20TransferableReceivable contract
4
4
  * associated with the given pool name on the current chain.
5
5
  *
6
6
  * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
7
7
  * @param {number} chainId The chain id where the contract instance exists
8
- * @returns {Contract | null} A contract instance for the BaseCreditPoolReceivable contract or null if it could not be found.
8
+ * @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
9
9
  */
10
10
  export declare function getERC20TransferableReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
@@ -4,12 +4,12 @@ exports.getERC20TransferableReceivableContract = void 0;
4
4
  const shared_1 = require("@huma-finance/shared");
5
5
  const utils_1 = require("../utils");
6
6
  /**
7
- * Returns an ethers contract instance for the BaseCreditPoolReceivable contract
7
+ * Returns an ethers contract instance for the ERC20TransferableReceivable contract
8
8
  * associated with the given pool name on the current chain.
9
9
  *
10
10
  * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
11
11
  * @param {number} chainId The chain id where the contract instance exists
12
- * @returns {Contract | null} A contract instance for the BaseCreditPoolReceivable contract or null if it could not be found.
12
+ * @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
13
13
  */
14
14
  function getERC20TransferableReceivableContract(signerOrProvider, chainId) {
15
15
  var _a;
@@ -0,0 +1,10 @@
1
+ import { Contract, ethers } from 'ethers';
2
+ /**
3
+ * Returns an ethers contract instance for the RealWorldReceivable contract
4
+ * associated with the given pool name on the current chain.
5
+ *
6
+ * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
7
+ * @param {number} chainId The chain id where the contract instance exists
8
+ * @returns {Contract | null} A contract instance for the RealWorldReceivable contract or null if it could not be found.
9
+ */
10
+ export declare function getRealWorldReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getRealWorldReceivableContract = void 0;
4
+ const shared_1 = require("@huma-finance/shared");
5
+ const utils_1 = require("../utils");
6
+ /**
7
+ * Returns an ethers contract instance for the RealWorldReceivable contract
8
+ * associated with the given pool name on the current chain.
9
+ *
10
+ * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
11
+ * @param {number} chainId The chain id where the contract instance exists
12
+ * @returns {Contract | null} A contract instance for the RealWorldReceivable contract or null if it could not be found.
13
+ */
14
+ function getRealWorldReceivableContract(signerOrProvider, chainId) {
15
+ var _a;
16
+ const realWorldReceivable = (_a = shared_1.SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[shared_1.SupplementaryContracts.RealWorldReceivable];
17
+ if (!realWorldReceivable)
18
+ return null;
19
+ return (0, utils_1.getContract)(realWorldReceivable, shared_1.REAL_WORLD_RECEIVABLE_ABI, signerOrProvider);
20
+ }
21
+ exports.getRealWorldReceivableContract = getRealWorldReceivableContract;
22
+ //# sourceMappingURL=RealWorldReceivableContractHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"RealWorldReceivableContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/RealWorldReceivableContractHelper.ts"],"names":[],"mappings":";;;AACA,iDAI6B;AAE7B,oCAAsC;AAEtC;;;;;;;GAOG;AACH,SAAgB,8BAA8B,CAC5C,gBAA2D,EAC3D,OAAe;;IAEf,MAAM,mBAAmB,GACvB,MAAA,kCAAyB,CAAC,OAAO,CAAC,0CAChC,+BAAsB,CAAC,mBAAmB,CAC3C,CAAA;IAEH,IAAI,CAAC,mBAAmB;QAAE,OAAO,IAAI,CAAA;IAErC,OAAO,IAAA,mBAAW,EAChB,mBAAmB,EACnB,kCAAyB,EACzB,gBAAgB,CACjB,CAAA;AACH,CAAC;AAhBD,wEAgBC"}
@@ -1,3 +1,3 @@
1
- export * from './BaseCreditPoolReceivableContractHelper';
1
+ export * from './RealWorldReceivableContractHelper';
2
2
  export * from './ERC20TransferableReceivableContractHelper';
3
3
  export * from './PoolContractHelper';
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./BaseCreditPoolReceivableContractHelper"), exports);
4
+ tslib_1.__exportStar(require("./RealWorldReceivableContractHelper"), exports);
5
5
  tslib_1.__exportStar(require("./ERC20TransferableReceivableContractHelper"), exports);
6
6
  tslib_1.__exportStar(require("./PoolContractHelper"), exports);
7
7
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":";;;AAAA,mFAAwD;AACxD,sFAA2D;AAC3D,+DAAoC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/helpers/index.ts"],"names":[],"mappings":";;;AAAA,8EAAmD;AACnD,sFAA2D;AAC3D,+DAAoC"}
@@ -1,4 +1,4 @@
1
1
  export * from './useContract';
2
- export * from './useBaseCreditPoolReceivableContract';
2
+ export * from './useRealWorldReceivableContract';
3
3
  export * from './useERC20TransferableReceivableContract';
4
4
  export * from './usePoolContract';
@@ -2,7 +2,7 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const tslib_1 = require("tslib");
4
4
  tslib_1.__exportStar(require("./useContract"), exports);
5
- tslib_1.__exportStar(require("./useBaseCreditPoolReceivableContract"), exports);
5
+ tslib_1.__exportStar(require("./useRealWorldReceivableContract"), exports);
6
6
  tslib_1.__exportStar(require("./useERC20TransferableReceivableContract"), exports);
7
7
  tslib_1.__exportStar(require("./usePoolContract"), exports);
8
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":";;;AAAA,wDAA6B;AAC7B,gFAAqD;AACrD,mFAAwD;AACxD,4DAAiC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/index.ts"],"names":[],"mappings":";;;AAAA,wDAA6B;AAC7B,2EAAgD;AAChD,mFAAwD;AACxD,4DAAiC"}
@@ -49,7 +49,7 @@ export type CreditRecordDetails = {
49
49
  /**
50
50
  * A react hook that returns the credit record details for a user in a given pool, as well as a function to refresh the data.
51
51
  *
52
- * @namespace usePoolContract
52
+ * @memberof usePoolContract
53
53
  * @param {string} userAddress - The address of the user to get the credit record details for.
54
54
  * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider object to use for the contract.
55
55
  * @param {number} chainId The chain id where the contract instance exists
@@ -23,7 +23,7 @@ exports.usePoolContract = usePoolContract;
23
23
  /**
24
24
  * A react hook that returns the credit record details for a user in a given pool, as well as a function to refresh the data.
25
25
  *
26
- * @namespace usePoolContract
26
+ * @memberof usePoolContract
27
27
  * @param {string} userAddress - The address of the user to get the credit record details for.
28
28
  * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider object to use for the contract.
29
29
  * @param {number} chainId The chain id where the contract instance exists
@@ -0,0 +1,10 @@
1
+ import { Contract, ethers } from 'ethers';
2
+ /**
3
+ * A react hook that returns an ethers contract instance for the RealWorldReceivable contract
4
+ * associated with the given pool name on the current chain.
5
+ *
6
+ * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
7
+ * @param {number} chainId The chain id where the contract instance exists
8
+ * @returns {Contract | null} A contract instance for the RealWorldReceivable contract or null if it could not be found.
9
+ */
10
+ export declare function useRealWorldReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useRealWorldReceivableContract = void 0;
4
+ const shared_1 = require("@huma-finance/shared");
5
+ const useContract_1 = require("./useContract");
6
+ /**
7
+ * A react hook that returns an ethers contract instance for the RealWorldReceivable contract
8
+ * associated with the given pool name on the current chain.
9
+ *
10
+ * @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
11
+ * @param {number} chainId The chain id where the contract instance exists
12
+ * @returns {Contract | null} A contract instance for the RealWorldReceivable contract or null if it could not be found.
13
+ */
14
+ function useRealWorldReceivableContract(signerOrProvider, chainId) {
15
+ var _a;
16
+ const realWorldReceivable = (_a = shared_1.SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[shared_1.SupplementaryContracts.RealWorldReceivable];
17
+ return (0, useContract_1.useContract)(realWorldReceivable, shared_1.REAL_WORLD_RECEIVABLE_ABI, signerOrProvider);
18
+ }
19
+ exports.useRealWorldReceivableContract = useRealWorldReceivableContract;
20
+ //# sourceMappingURL=useRealWorldReceivableContract.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useRealWorldReceivableContract.js","sourceRoot":"","sources":["../../../src/hooks/useRealWorldReceivableContract.ts"],"names":[],"mappings":";;;AACA,iDAK6B;AAE7B,+CAA2C;AAE3C;;;;;;;GAOG;AACH,SAAgB,8BAA8B,CAC5C,gBAA2D,EAC3D,OAAe;;IAEf,MAAM,mBAAmB,GACvB,MAAA,kCAAyB,CAAC,OAAO,CAAC,0CAChC,+BAAsB,CAAC,mBAAmB,CAC3C,CAAA;IAEH,OAAO,IAAA,yBAAW,EAChB,mBAAmB,EACnB,kCAAyB,EACzB,gBAAgB,CACjB,CAAA;AACH,CAAC;AAdD,wEAcC"}
@@ -1,6 +1,7 @@
1
1
  import { FundResponse, UploadResponse } from '@bundlr-network/client/build/common/types';
2
2
  import { Web3Provider } from '@ethersproject/providers';
3
3
  import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
4
+ import { BigNumber } from 'ethers';
4
5
  /**
5
6
  * The configuration for Bundlr network instances
6
7
  *
@@ -37,6 +38,18 @@ export declare function getBundlrNetworkConfig(chainId: number): BundlrConfig;
37
38
  * @returns {Promise<FundResponse>} - The fund response.
38
39
  */
39
40
  declare function prefundBundlr(config: BundlrConfig, signer: any, amount: number): Promise<FundResponse>;
41
+ /**
42
+ * Get the running balance on Bundlr network, in atomic units (the smallest unit of a given currency)
43
+ *
44
+ * @async
45
+ * @function
46
+ * @memberof ArweaveService
47
+ * @param {BundlrConfig} config - The configuration for the Bundlr network.
48
+ * @param {any} signer - The wallet to send funds from. This can be either a web3 signer or a private key string.
49
+ * @param {number} amount - The amount to fund, denoted in whatever currency specified by the config.
50
+ * @returns {Promise<FundResponse>} - The fund response.
51
+ */
52
+ declare function getBundlrBalance(config: BundlrConfig, signer: any): Promise<BigNumber>;
40
53
  /**
41
54
  * Store data on ARWeave using the Bundlr Network.
42
55
  *
@@ -76,6 +89,7 @@ declare function queryForMetadata(chainId: number, poolName: POOL_NAME, poolType
76
89
  * @namespace ARWeaveService
77
90
  */
78
91
  export declare const ARWeaveService: {
92
+ getBundlrBalance: typeof getBundlrBalance;
79
93
  queryForMetadata: typeof queryForMetadata;
80
94
  storeData: typeof storeData;
81
95
  prefundBundlr: typeof prefundBundlr;
@@ -4,6 +4,7 @@ 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
+ const ethers_1 = require("ethers");
7
8
  /**
8
9
  * Get the configuration for Bundlr network given a chain ID
9
10
  *
@@ -56,6 +57,27 @@ signer, amount) {
56
57
  await bundlr.ready();
57
58
  return bundlr.fund(amount);
58
59
  }
60
+ /**
61
+ * Get the running balance on Bundlr network, in atomic units (the smallest unit of a given currency)
62
+ *
63
+ * @async
64
+ * @function
65
+ * @memberof ArweaveService
66
+ * @param {BundlrConfig} config - The configuration for the Bundlr network.
67
+ * @param {any} signer - The wallet to send funds from. This can be either a web3 signer or a private key string.
68
+ * @param {number} amount - The amount to fund, denoted in whatever currency specified by the config.
69
+ * @returns {Promise<FundResponse>} - The fund response.
70
+ */
71
+ async function getBundlrBalance(config,
72
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
73
+ signer) {
74
+ const bundlr = new client_1.default(config.nodeUrl, config.currency, signer, config.providerUrl
75
+ ? {
76
+ providerUrl: config.providerUrl,
77
+ }
78
+ : undefined);
79
+ return ethers_1.BigNumber.from(await bundlr.getLoadedBalance());
80
+ }
59
81
  /**
60
82
  * Store data on ARWeave using the Bundlr Network.
61
83
  *
@@ -106,29 +128,29 @@ async function storeData(config, signerOrPrivateKey, data, tags, lazyFund = true
106
128
  async function queryForMetadata(chainId, poolName, poolType, sender, referenceId) {
107
129
  var _a, _b, _c, _d;
108
130
  const config = getBundlrNetworkConfig(chainId);
109
- const query = (0, graphql_request_1.gql) `
110
- query ArweaveHumaMetadataQuery(
111
- $poolName: String!
112
- $poolType: String!
113
- $sender: String!
114
- $referenceId: String!
115
- ) {
116
- transactions(
117
- owners: [$sender]
118
- tags: [
119
- { name: "appName", values: ["HumaFinance"] }
120
- { name: "poolName", values: [$poolName] }
121
- { name: "poolType", values: [$poolType] }
122
- { name: "referenceId", values: [$referenceId] }
123
- ]
124
- ) {
125
- edges {
126
- node {
127
- id
128
- }
129
- }
130
- }
131
- }
131
+ const query = (0, graphql_request_1.gql) `
132
+ query ArweaveHumaMetadataQuery(
133
+ $poolName: String!
134
+ $poolType: String!
135
+ $sender: String!
136
+ $referenceId: String!
137
+ ) {
138
+ transactions(
139
+ owners: [$sender]
140
+ tags: [
141
+ { name: "appName", values: ["HumaFinance"] }
142
+ { name: "poolName", values: [$poolName] }
143
+ { name: "poolType", values: [$poolType] }
144
+ { name: "referenceId", values: [$referenceId] }
145
+ ]
146
+ ) {
147
+ edges {
148
+ node {
149
+ id
150
+ }
151
+ }
152
+ }
153
+ }
132
154
  `;
133
155
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
134
156
  const data = await (0, graphql_request_1.default)(`${config.nodeUrl}/graphql`, query, {
@@ -144,6 +166,7 @@ async function queryForMetadata(chainId, poolName, poolType, sender, referenceId
144
166
  * @namespace ARWeaveService
145
167
  */
146
168
  exports.ARWeaveService = {
169
+ getBundlrBalance,
147
170
  queryForMetadata,
148
171
  storeData,
149
172
  prefundBundlr,
@@ -1 +1 @@
1
- {"version":3,"file":"ARWeaveService.js","sourceRoot":"","sources":["../../../src/services/ARWeaveService.ts"],"names":[],"mappings":";;;;AAAA,4EAA2C;AAM3C,2EAA8C;AAmB9C;;;;;;;GAOG;AACH,SAAgB,sBAAsB,CAAC,OAAe;IACpD,QAAQ,OAAO,EAAE;QACf,KAAK,CAAC;YACJ,OAAO;gBACL,OAAO,EAAE,+BAA+B;gBACxC,QAAQ,EAAE,UAAU;gBACpB,WAAW,EACT,8DAA8D;aACjE,CAAA;QACH,KAAK,KAAK;YACR,OAAO;gBACL,OAAO,EAAE,+BAA+B;gBACxC,QAAQ,EAAE,OAAO;gBACjB,WAAW,EAAE,gCAAgC;aAC9C,CAAA;QACH;YACE,OAAO;gBACL,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,EAAE;aACb,CAAA;KACJ;AACH,CAAC;AArBD,wDAqBC;AAED;;;;;;;;;;GAUG;AACH,KAAK,UAAU,aAAa,CAC1B,MAAoB;AACpB,8DAA8D;AAC9D,MAAW,EACX,MAAc;IAEd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+1,18 @@
1
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.
2
+ * Object representing the response to the underwriting approval request.
3
+ * @typedef {Object} ApprovalResult
16
4
  */
17
5
  /**
18
6
  * Object representing an invoice payload for underwriting approval.
19
7
  *
20
8
  * @typedef {Object} EAPayload
21
9
  */
22
- export type { ApproveInfo, EAPayload } from '@huma-finance/shared';
10
+ export type { ApprovalResult, EAPayload } from '@huma-finance/shared';
23
11
  /**
24
12
  * An object that contains functions to interact with Huma's EAVerse service.
25
13
  *
26
14
  * @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
15
  */
34
16
  export declare const EAService: {
35
- approve: (payload: import("@huma-finance/shared").EAPayload, chainId: number, isDev?: boolean | undefined) => Promise<import("@huma-finance/shared").ApproveInfo>;
17
+ approve: (payload: import("@huma-finance/shared").EAPayload, chainId: number, isDev?: boolean | undefined) => Promise<import("@huma-finance/shared").Approval>;
36
18
  };
@@ -6,12 +6,6 @@ const shared_1 = require("@huma-finance/shared");
6
6
  * An object that contains functions to interact with Huma's EAVerse service.
7
7
  *
8
8
  * @namespace EAService
9
- *
10
- * approve: Submits a credit underwriting request to Huma's EAVerse.
11
- * @param {EAPayload} payload The payload for the underwrite approval.
12
- * @param {number} chainId The chain ID.
13
- * @returns {Promise<ApproveInfo>} Promise that returns approval info on success.
14
- * @throws {EARejectionError} If the underwrite approval is rejected.
15
9
  */
16
10
  exports.EAService = {
17
11
  approve: shared_1.EAService.approve,
@@ -1 +1 @@
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
+ {"version":3,"file":"EAService.js","sourceRoot":"","sources":["../../../src/services/EAService.ts"],"names":[],"mappings":";;;AAAA,iDAAqE;AAarE;;;;GAIG;AACU,QAAA,SAAS,GAAG;IACvB,OAAO,EAAE,kBAAiB,CAAC,OAAO;CACnC,CAAA"}
@@ -1,62 +1,43 @@
1
- import { TransactionReceipt, TransactionResponse, Web3Provider } from '@ethersproject/providers';
1
+ import { TransactionResponse, Web3Provider } from '@ethersproject/providers';
2
2
  import { BigNumberish, ethers, Overrides } from 'ethers';
3
3
  import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
4
+ declare function declareReceivablePaymentByReferenceId(signer: ethers.Signer, referenceId: string, paymentAmount: number): Promise<TransactionResponse>;
4
5
  /**
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.
6
+ * Declares a payment on a RealWorldReceivable given a tokenID of the receivable.
30
7
  *
8
+ * @async
9
+ * @function
31
10
  * @memberof ReceivableService
32
11
  * @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
33
12
  * @param {BigNumberish} receivableTokenId - The ID of the receivable token to pay.
34
13
  * @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.
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.
38
16
  */
39
- declare function payReceivableByTokenId(signer: ethers.Signer, receivableTokenId: BigNumberish, paymentAmount: number, paymentMethod: PaymentMethod): Promise<TransactionReceipt>;
17
+ declare function declareReceivablePaymentByTokenId(signer: ethers.Signer, receivableTokenId: BigNumberish, paymentAmount: number): Promise<TransactionResponse>;
40
18
  /**
41
- * Mints a new BaseCreditPoolReceivable token on the given chain of the signer
19
+ * Creates a new RealWorldReceivable token on the given chain of the signer
42
20
  *
21
+ * @async
22
+ * @function
43
23
  * @memberof ReceivableService
44
24
  * @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
25
  * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
47
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
48
28
  * @param {number} receivableAmount - The amount of the receivable token to mint.
49
29
  * @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
30
  * @param {string} uri - The URI of the receivable token metadata.
52
31
  * @param {Overrides} gasOpts - The gas options to use for the transaction.
53
32
  * @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.
33
+ * @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
55
34
  */
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>;
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>;
57
36
  /**
58
- * Mints a BaseCreditPoolReceivable token with metadata uploaded onto ARWeave
37
+ * Creates a RealWorldReceivable token with metadata uploaded onto ARWeave
59
38
  *
39
+ * @async
40
+ * @function
60
41
  * @memberof ReceivableService
61
42
  * @param {Web3Provider | ethers.Signer} signerOrProvider - If calling this function from a browser, this function expects a Web3Provider.
62
43
  * If calling this function from a server, this function expects an ethers Signer. Note that privateKey only needs to be included
@@ -66,9 +47,9 @@ declare function mintReceivable(signer: ethers.Signer, poolName: POOL_NAME, pool
66
47
  * @param {string} recipient - The receivable token recipient.
67
48
  * @param {POOL_NAME} poolName - The pool name. Used to lookup the pool address to pay to.
68
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
69
51
  * @param {number} receivableAmount - The receivable amount.
70
52
  * @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
53
  * @param {JSON} metadata - The metadata in JSON format. This will be uploaded onto ARWeave
73
54
  * @param {number} referenceId - An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.
74
55
  * @param {Array<{ name: string, value: string }>} extraTags - Any extraTags you'd like to tag your metadata with. Note that metadata on
@@ -76,20 +57,20 @@ declare function mintReceivable(signer: ethers.Signer, poolName: POOL_NAME, pool
76
57
  * @param {boolean} [lazyFund=true] - Whether to lazy fund the ARWeave uploads. If true, the ARWeave uploads will be paid for by the
77
58
  * metadata uploader immediately before uploading. If false, the ARWeave node must be pre-funded before calling this function.
78
59
  * @param {Overrides} [gasOpts] - Optional gas overrides for the transaction.
79
- * @returns {Promise<TransactionReceipt>} - The transaction receipt.
60
+ * @returns {Promise<TransactionResponse>} - The transaction receipt.
80
61
  */
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: {
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: {
82
63
  name: string;
83
64
  value: string;
84
- }[], lazyFund?: boolean, gasOpts?: Overrides): Promise<TransactionReceipt>;
65
+ }[], lazyFund?: boolean, gasOpts?: Overrides): Promise<TransactionResponse>;
85
66
  /**
86
67
  * An object that contains functions to interact with Huma's receivables.
87
68
  * @namespace ReceivableService
88
69
  */
89
70
  export declare const ReceivableService: {
90
- mintReceivableWithMetadata: typeof mintReceivableWithMetadata;
91
- mintReceivable: typeof mintReceivable;
92
- payReceivableByTokenId: typeof payReceivableByTokenId;
93
- payReceivableByReferenceId: typeof payReceivableByReferenceId;
71
+ createReceivableWithMetadata: typeof createReceivableWithMetadata;
72
+ createReceivable: typeof createReceivable;
73
+ declareReceivablePaymentByTokenId: typeof declareReceivablePaymentByTokenId;
74
+ declareReceivablePaymentByReferenceId: typeof declareReceivablePaymentByReferenceId;
94
75
  };
95
76
  export {};