@huma-finance/sdk 0.0.37 → 0.0.38-beta.0

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 (159) hide show
  1. package/API.md +633 -650
  2. package/LICENSE +660 -660
  3. package/README.md +37 -37
  4. package/getting-started.md +190 -190
  5. package/package.json +3 -3
  6. package/dist/cjs/graphql/generatedTypes.d.ts +0 -40
  7. package/dist/cjs/graphql/generatedTypes.js +0 -9
  8. package/dist/cjs/graphql/generatedTypes.js.map +0 -1
  9. package/dist/cjs/graphql/index.d.ts +0 -1
  10. package/dist/cjs/graphql/index.js +0 -5
  11. package/dist/cjs/graphql/index.js.map +0 -1
  12. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.d.ts +0 -10
  13. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js +0 -22
  14. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js.map +0 -1
  15. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.d.ts +0 -10
  16. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js +0 -22
  17. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js.map +0 -1
  18. package/dist/cjs/helpers/PoolContractHelper.d.ts +0 -119
  19. package/dist/cjs/helpers/PoolContractHelper.js +0 -144
  20. package/dist/cjs/helpers/PoolContractHelper.js.map +0 -1
  21. package/dist/cjs/helpers/RealWorldReceivableContractHelper.d.ts +0 -10
  22. package/dist/cjs/helpers/RealWorldReceivableContractHelper.js +0 -22
  23. package/dist/cjs/helpers/RealWorldReceivableContractHelper.js.map +0 -1
  24. package/dist/cjs/helpers/index.d.ts +0 -3
  25. package/dist/cjs/helpers/index.js +0 -7
  26. package/dist/cjs/helpers/index.js.map +0 -1
  27. package/dist/cjs/hooks/index.d.ts +0 -4
  28. package/dist/cjs/hooks/index.js +0 -8
  29. package/dist/cjs/hooks/index.js.map +0 -1
  30. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.d.ts +0 -10
  31. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js +0 -20
  32. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js.map +0 -1
  33. package/dist/cjs/hooks/useContract.d.ts +0 -13
  34. package/dist/cjs/hooks/useContract.js +0 -31
  35. package/dist/cjs/hooks/useContract.js.map +0 -1
  36. package/dist/cjs/hooks/useERC20TransferableReceivableContract.d.ts +0 -12
  37. package/dist/cjs/hooks/useERC20TransferableReceivableContract.js +0 -21
  38. package/dist/cjs/hooks/useERC20TransferableReceivableContract.js.map +0 -1
  39. package/dist/cjs/hooks/usePoolContract.d.ts +0 -60
  40. package/dist/cjs/hooks/usePoolContract.js +0 -54
  41. package/dist/cjs/hooks/usePoolContract.js.map +0 -1
  42. package/dist/cjs/hooks/useRealWorldReceivableContract.d.ts +0 -10
  43. package/dist/cjs/hooks/useRealWorldReceivableContract.js +0 -20
  44. package/dist/cjs/hooks/useRealWorldReceivableContract.js.map +0 -1
  45. package/dist/cjs/hooks/useReceivableFactoringPoolContract.d.ts +0 -10
  46. package/dist/cjs/hooks/useReceivableFactoringPoolContract.js +0 -17
  47. package/dist/cjs/hooks/useReceivableFactoringPoolContract.js.map +0 -1
  48. package/dist/cjs/index.d.ts +0 -4
  49. package/dist/cjs/index.js +0 -8
  50. package/dist/cjs/index.js.map +0 -1
  51. package/dist/cjs/services/ARWeaveService.d.ts +0 -106
  52. package/dist/cjs/services/ARWeaveService.js +0 -191
  53. package/dist/cjs/services/ARWeaveService.js.map +0 -1
  54. package/dist/cjs/services/EAService.d.ts +0 -20
  55. package/dist/cjs/services/EAService.js +0 -34
  56. package/dist/cjs/services/EAService.js.map +0 -1
  57. package/dist/cjs/services/ReceivableService.d.ts +0 -104
  58. package/dist/cjs/services/ReceivableService.js +0 -309
  59. package/dist/cjs/services/ReceivableService.js.map +0 -1
  60. package/dist/cjs/services/SubgraphService.d.ts +0 -53
  61. package/dist/cjs/services/SubgraphService.js +0 -94
  62. package/dist/cjs/services/SubgraphService.js.map +0 -1
  63. package/dist/cjs/services/index.d.ts +0 -4
  64. package/dist/cjs/services/index.js +0 -8
  65. package/dist/cjs/services/index.js.map +0 -1
  66. package/dist/cjs/utils/chain.d.ts +0 -15
  67. package/dist/cjs/utils/chain.js +0 -38
  68. package/dist/cjs/utils/chain.js.map +0 -1
  69. package/dist/cjs/utils/index.d.ts +0 -4
  70. package/dist/cjs/utils/index.js +0 -8
  71. package/dist/cjs/utils/index.js.map +0 -1
  72. package/dist/cjs/utils/maticGasStation.d.ts +0 -3
  73. package/dist/cjs/utils/maticGasStation.js +0 -39
  74. package/dist/cjs/utils/maticGasStation.js.map +0 -1
  75. package/dist/cjs/utils/poolInfo.d.ts +0 -8
  76. package/dist/cjs/utils/poolInfo.js +0 -13
  77. package/dist/cjs/utils/poolInfo.js.map +0 -1
  78. package/dist/cjs/utils/web3.d.ts +0 -5
  79. package/dist/cjs/utils/web3.js +0 -34
  80. package/dist/cjs/utils/web3.js.map +0 -1
  81. package/dist/graphql/generatedTypes.d.ts +0 -40
  82. package/dist/graphql/generatedTypes.js +0 -5
  83. package/dist/graphql/generatedTypes.js.map +0 -1
  84. package/dist/graphql/index.d.ts +0 -1
  85. package/dist/graphql/index.js +0 -2
  86. package/dist/graphql/index.js.map +0 -1
  87. package/dist/helpers/BaseCreditPoolReceivableContractHelper.d.ts +0 -10
  88. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js +0 -18
  89. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js.map +0 -1
  90. package/dist/helpers/ERC20TransferableReceivableContractHelper.d.ts +0 -10
  91. package/dist/helpers/ERC20TransferableReceivableContractHelper.js +0 -18
  92. package/dist/helpers/ERC20TransferableReceivableContractHelper.js.map +0 -1
  93. package/dist/helpers/PoolContractHelper.d.ts +0 -119
  94. package/dist/helpers/PoolContractHelper.js +0 -135
  95. package/dist/helpers/PoolContractHelper.js.map +0 -1
  96. package/dist/helpers/RealWorldReceivableContractHelper.d.ts +0 -10
  97. package/dist/helpers/RealWorldReceivableContractHelper.js +0 -18
  98. package/dist/helpers/RealWorldReceivableContractHelper.js.map +0 -1
  99. package/dist/helpers/index.d.ts +0 -3
  100. package/dist/helpers/index.js +0 -4
  101. package/dist/helpers/index.js.map +0 -1
  102. package/dist/hooks/index.d.ts +0 -4
  103. package/dist/hooks/index.js +0 -5
  104. package/dist/hooks/index.js.map +0 -1
  105. package/dist/hooks/useBaseCreditPoolReceivableContract.d.ts +0 -10
  106. package/dist/hooks/useBaseCreditPoolReceivableContract.js +0 -16
  107. package/dist/hooks/useBaseCreditPoolReceivableContract.js.map +0 -1
  108. package/dist/hooks/useContract.d.ts +0 -13
  109. package/dist/hooks/useContract.js +0 -27
  110. package/dist/hooks/useContract.js.map +0 -1
  111. package/dist/hooks/useERC20TransferableReceivableContract.d.ts +0 -12
  112. package/dist/hooks/useERC20TransferableReceivableContract.js +0 -17
  113. package/dist/hooks/useERC20TransferableReceivableContract.js.map +0 -1
  114. package/dist/hooks/usePool.d.ts +0 -0
  115. package/dist/hooks/usePool.js +0 -2
  116. package/dist/hooks/usePool.js.map +0 -1
  117. package/dist/hooks/usePoolContract.d.ts +0 -60
  118. package/dist/hooks/usePoolContract.js +0 -49
  119. package/dist/hooks/usePoolContract.js.map +0 -1
  120. package/dist/hooks/useRealWorldReceivableContract.d.ts +0 -10
  121. package/dist/hooks/useRealWorldReceivableContract.js +0 -16
  122. package/dist/hooks/useRealWorldReceivableContract.js.map +0 -1
  123. package/dist/hooks/useReceivableFactoringPoolContract.d.ts +0 -10
  124. package/dist/hooks/useReceivableFactoringPoolContract.js +0 -13
  125. package/dist/hooks/useReceivableFactoringPoolContract.js.map +0 -1
  126. package/dist/index.d.ts +0 -4
  127. package/dist/index.js +0 -5
  128. package/dist/index.js.map +0 -1
  129. package/dist/services/ARWeaveService.d.ts +0 -106
  130. package/dist/services/ARWeaveService.js +0 -186
  131. package/dist/services/ARWeaveService.js.map +0 -1
  132. package/dist/services/EAService.d.ts +0 -20
  133. package/dist/services/EAService.js +0 -31
  134. package/dist/services/EAService.js.map +0 -1
  135. package/dist/services/ReceivableService.d.ts +0 -104
  136. package/dist/services/ReceivableService.js +0 -306
  137. package/dist/services/ReceivableService.js.map +0 -1
  138. package/dist/services/SubgraphService.d.ts +0 -53
  139. package/dist/services/SubgraphService.js +0 -91
  140. package/dist/services/SubgraphService.js.map +0 -1
  141. package/dist/services/index.d.ts +0 -4
  142. package/dist/services/index.js +0 -5
  143. package/dist/services/index.js.map +0 -1
  144. package/dist/tsconfig.cjs.tsbuildinfo +0 -1
  145. package/dist/utils/chain.d.ts +0 -15
  146. package/dist/utils/chain.js +0 -32
  147. package/dist/utils/chain.js.map +0 -1
  148. package/dist/utils/index.d.ts +0 -4
  149. package/dist/utils/index.js +0 -5
  150. package/dist/utils/index.js.map +0 -1
  151. package/dist/utils/maticGasStation.d.ts +0 -3
  152. package/dist/utils/maticGasStation.js +0 -34
  153. package/dist/utils/maticGasStation.js.map +0 -1
  154. package/dist/utils/poolInfo.d.ts +0 -8
  155. package/dist/utils/poolInfo.js +0 -9
  156. package/dist/utils/poolInfo.js.map +0 -1
  157. package/dist/utils/web3.d.ts +0 -5
  158. package/dist/utils/web3.js +0 -28
  159. package/dist/utils/web3.js.map +0 -1
@@ -1 +0,0 @@
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,10 +0,0 @@
1
- import { POOL_NAME, ReceivableFactoringPool } from '@00labs/huma-shared';
2
- import { ethers } from 'ethers';
3
- /**
4
- * A react hook that returns the instance of the ReceivableFactoringPool contract for a given signer or provider and pool name.
5
- *
6
- * @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The signer or provider object to use for the contract.
7
- * @param {POOL_NAME} poolName - The name of the pool to get the contract for. Check the type for more details.
8
- * @returns {ReceivableFactoringPool} An ethers instance of the ReceivableFactoringPool contract.
9
- */
10
- export declare function useReceivableFactoringPoolContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME): ReceivableFactoringPool | null;
@@ -1,17 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.useReceivableFactoringPoolContract = void 0;
4
- const huma_shared_1 = require("@00labs/huma-shared");
5
- const usePoolContract_1 = require("./usePoolContract");
6
- /**
7
- * A react hook that returns the instance of the ReceivableFactoringPool contract for a given signer or provider and pool name.
8
- *
9
- * @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The signer or provider object to use for the contract.
10
- * @param {POOL_NAME} poolName - The name of the pool to get the contract for. Check the type for more details.
11
- * @returns {ReceivableFactoringPool} An ethers instance of the ReceivableFactoringPool contract.
12
- */
13
- function useReceivableFactoringPoolContract(signerOrProvider, chainId, poolName) {
14
- return (0, usePoolContract_1.usePoolContract)(signerOrProvider, chainId, poolName, huma_shared_1.POOL_TYPE.Invoice);
15
- }
16
- exports.useReceivableFactoringPoolContract = useReceivableFactoringPoolContract;
17
- //# sourceMappingURL=useReceivableFactoringPoolContract.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useReceivableFactoringPoolContract.js","sourceRoot":"","sources":["../../../src/hooks/useReceivableFactoringPoolContract.ts"],"names":[],"mappings":";;;AAAA,qDAI4B;AAG5B,uDAAmD;AAEnD;;;;;;GAMG;AACH,SAAgB,kCAAkC,CAChD,gBAA2D,EAC3D,OAAe,EACf,QAAmB;IAEnB,OAAO,IAAA,iCAAe,EACpB,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,uBAAS,CAAC,OAAO,CAClB,CAAA;AACH,CAAC;AAXD,gFAWC"}
@@ -1,4 +0,0 @@
1
- export * from './helpers';
2
- export * from './hooks';
3
- export * from './services';
4
- export * from './utils';
package/dist/cjs/index.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./helpers"), exports);
5
- tslib_1.__exportStar(require("./hooks"), exports);
6
- tslib_1.__exportStar(require("./services"), exports);
7
- tslib_1.__exportStar(require("./utils"), exports);
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB;AACzB,kDAAuB;AACvB,qDAA0B;AAC1B,kDAAuB"}
@@ -1,106 +0,0 @@
1
- import type { FundResponse, UploadResponse } from '@bundlr-network/client/build/cjs/common/types';
2
- import { Web3Provider } from '@ethersproject/providers';
3
- /**
4
- * The configuration for Bundlr network instances
5
- *
6
- * @typedef {Object} BundlrConfig
7
- * @memberof ArweaveService
8
- * @property {string} nodeUrl - The Bundlr node URL to use.
9
- * @property {string} currency - The currency to pay for uploads with.
10
- * Please see https://docs.bundlr.network/sdk/using-other-currencies for all the supported currencies
11
- * @property {string} [providerUrl] - The provider URL, required for devnets.
12
- */
13
- export type BundlrConfig = {
14
- nodeUrl: string;
15
- currency: string;
16
- providerUrl?: string;
17
- };
18
- /**
19
- * Get the configuration for Bundlr network given a chain ID
20
- *
21
- * @function
22
- * @memberof ArweaveService
23
- * @param {number} chainId - The chain ID.
24
- * @returns {BundlrConfig} - The configuration for the Bundlr network.
25
- */
26
- export declare function getBundlrNetworkConfig(chainId: number): BundlrConfig;
27
- /**
28
- * Get a Bundlr instance for a specific network
29
- *
30
- * @async
31
- * @function
32
- * @memberof ArweaveService
33
- * @param {BundlrConfig} config - The configuration for the Bundlr network.
34
- * @param {string} signer - The private key of the wallet to use Bundlr with.
35
- * @returns The Bundlr instance
36
- */
37
- declare function getBundlrInstance(config: BundlrConfig, signer: string): Promise<import("@bundlr-network/client/build/cjs/node/bundlr").default>;
38
- /**
39
- * Prefund the Bundlr network with the specified amount. Required if not lazy funding.
40
- * Important note: The amount is denominated in the base unit of currency for that network.
41
- * If you want to upload 5 Matic to the Bundlr node, pass in an amount of 5.
42
- *
43
- * @async
44
- * @function
45
- * @memberof ArweaveService
46
- * @param {BundlrConfig} config - The configuration for the Bundlr network.
47
- * @param {string} signer - The private key of the wallet to send funds from.
48
- * @param {number} amount - The amount to fund, denoted in whatever currency specified by the config (e.g. MATIC, ETH)
49
- * @returns {Promise<FundResponse>} - The fund response.
50
- */
51
- declare function prefundBundlr(config: BundlrConfig, signer: string, amount: number): Promise<FundResponse>;
52
- /**
53
- * Store data on ARWeave using the Bundlr Network.
54
- *
55
- * @async
56
- * @function
57
- * @memberof ArweaveService
58
- * @param {BundlrConfig} config - Configuration object for the Bundlr instance.
59
- * @param {Web3Provider | string} signerOrPrivateKey - Wallet object used for interacting with the Bundlr instance.
60
- * If calling from a browser, this should be a `Web3Provider` instance. If calling from a Node.js
61
- * environment, this should be a private key string.
62
- * @param {Record<string, unknown>} data - The data to store in the Bundlr instance.
63
- * @param {Array<{ name: string, value: string }>} tags - Array of tag objects with `name` and `value` properties.
64
- * @param {boolean} [lazyFund=true] - Optional flag to fund the Bundlr instance lazily. If set to `false`, the
65
- * Bundlr node should already be funded or else uploads will fail.
66
- * @returns {Promise<UploadResponse>} Promise resolving with the upload response.
67
- */
68
- declare function storeData(config: BundlrConfig, signerOrPrivateKey: Web3Provider | string, data: Record<string, unknown>, tags: {
69
- name: string;
70
- value: string;
71
- }[], lazyFund?: boolean): Promise<UploadResponse>;
72
- /**
73
- * Helper method to query the Arweave network for receivables metadata previously uploaded.
74
- *
75
- * @async
76
- * @function
77
- * @memberof ArweaveService
78
- * @param {number} chainId - The chain ID.
79
- * @param {string} sender - The sender tag to query.
80
- * @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
81
- * @returns {Promise<any>} Promise resolving with the queried data.
82
- */
83
- declare function queryForMetadata(chainId: number, sender: string, referenceId: string): Promise<string | null>;
84
- /**
85
- * Helper method to fetch data from an ARWeave URL.
86
- *
87
- * @async
88
- * @function
89
- * @memberof ArweaveService
90
- * @param {string} url - The ARWeave metadata URL to query.
91
- * @returns {Promise<JSON>} Promise resolving with the queried data.
92
- */
93
- declare function fetchMetadataFromUrl(url: string): Promise<JSON | null>;
94
- /**
95
- * An object that contains functions to interact with Huma-related data stored on ARWeave
96
- * @namespace ARWeaveService
97
- */
98
- export declare const ARWeaveService: {
99
- queryForMetadata: typeof queryForMetadata;
100
- storeData: typeof storeData;
101
- prefundBundlr: typeof prefundBundlr;
102
- getBundlrNetworkConfig: typeof getBundlrNetworkConfig;
103
- getBundlrInstance: typeof getBundlrInstance;
104
- fetchMetadataFromUrl: typeof fetchMetadataFromUrl;
105
- };
106
- export {};
@@ -1,191 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ARWeaveService = exports.getBundlrNetworkConfig = void 0;
4
- const tslib_1 = require("tslib");
5
- const client_1 = tslib_1.__importDefault(require("@bundlr-network/client"));
6
- const axios_1 = tslib_1.__importDefault(require("axios"));
7
- const graphql_request_1 = tslib_1.__importStar(require("graphql-request"));
8
- /**
9
- * Get the configuration for Bundlr network given a chain ID
10
- *
11
- * @function
12
- * @memberof ArweaveService
13
- * @param {number} chainId - The chain ID.
14
- * @returns {BundlrConfig} - The configuration for the Bundlr network.
15
- */
16
- function getBundlrNetworkConfig(chainId) {
17
- switch (chainId) {
18
- case 5: // Goerli
19
- return {
20
- nodeUrl: 'https://devnet.bundlr.network',
21
- currency: 'ethereum',
22
- providerUrl: 'https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161',
23
- };
24
- case 80001: // Mumbai
25
- return {
26
- nodeUrl: 'https://devnet.bundlr.network',
27
- currency: 'matic',
28
- providerUrl: 'https://rpc.ankr.com/polygon_mumbai',
29
- };
30
- case 137: // Matic
31
- return {
32
- nodeUrl: 'https://node1.bundlr.network',
33
- currency: 'matic',
34
- };
35
- default:
36
- return {
37
- nodeUrl: '',
38
- currency: '',
39
- };
40
- }
41
- }
42
- exports.getBundlrNetworkConfig = getBundlrNetworkConfig;
43
- /**
44
- * Get a Bundlr instance for a specific network
45
- *
46
- * @async
47
- * @function
48
- * @memberof ArweaveService
49
- * @param {BundlrConfig} config - The configuration for the Bundlr network.
50
- * @param {string} signer - The private key of the wallet to use Bundlr with.
51
- * @returns The Bundlr instance
52
- */
53
- async function getBundlrInstance(config, signer) {
54
- const bundlr = new client_1.default(config.nodeUrl, config.currency, signer, config.providerUrl
55
- ? {
56
- providerUrl: config.providerUrl,
57
- }
58
- : undefined);
59
- await bundlr.ready();
60
- return bundlr;
61
- }
62
- /**
63
- * Prefund the Bundlr network with the specified amount. Required if not lazy funding.
64
- * Important note: The amount is denominated in the base unit of currency for that network.
65
- * If you want to upload 5 Matic to the Bundlr node, pass in an amount of 5.
66
- *
67
- * @async
68
- * @function
69
- * @memberof ArweaveService
70
- * @param {BundlrConfig} config - The configuration for the Bundlr network.
71
- * @param {string} signer - The private key of the wallet to send funds from.
72
- * @param {number} amount - The amount to fund, denoted in whatever currency specified by the config (e.g. MATIC, ETH)
73
- * @returns {Promise<FundResponse>} - The fund response.
74
- */
75
- async function prefundBundlr(config,
76
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
77
- signer, amount) {
78
- const bundlr = new client_1.default(config.nodeUrl, config.currency, signer, config.providerUrl
79
- ? {
80
- providerUrl: config.providerUrl,
81
- }
82
- : undefined);
83
- await bundlr.ready();
84
- // Convert currency to its atomic units (e.g. MATIC -> wei)
85
- const atomicAmount = bundlr.utils.toAtomic(amount);
86
- return bundlr.fund(atomicAmount);
87
- }
88
- /**
89
- * Store data on ARWeave using the Bundlr Network.
90
- *
91
- * @async
92
- * @function
93
- * @memberof ArweaveService
94
- * @param {BundlrConfig} config - Configuration object for the Bundlr instance.
95
- * @param {Web3Provider | string} signerOrPrivateKey - Wallet object used for interacting with the Bundlr instance.
96
- * If calling from a browser, this should be a `Web3Provider` instance. If calling from a Node.js
97
- * environment, this should be a private key string.
98
- * @param {Record<string, unknown>} data - The data to store in the Bundlr instance.
99
- * @param {Array<{ name: string, value: string }>} tags - Array of tag objects with `name` and `value` properties.
100
- * @param {boolean} [lazyFund=true] - Optional flag to fund the Bundlr instance lazily. If set to `false`, the
101
- * Bundlr node should already be funded or else uploads will fail.
102
- * @returns {Promise<UploadResponse>} Promise resolving with the upload response.
103
- */
104
- async function storeData(config, signerOrPrivateKey, data, tags, lazyFund = true) {
105
- const bundlr = new client_1.default(config.nodeUrl, config.currency, signerOrPrivateKey, config.providerUrl
106
- ? {
107
- providerUrl: config.providerUrl,
108
- }
109
- : undefined);
110
- await bundlr.ready();
111
- const dataStr = JSON.stringify(data);
112
- if (lazyFund) {
113
- const size = Buffer.byteLength(dataStr);
114
- const price = await bundlr.getPrice(size);
115
- // Add a buffer of 20% to account for fluctuations in the price
116
- const priceWithBuffer = price.multipliedBy(1.2).integerValue();
117
- console.log(`Funding bundlr with ${priceWithBuffer} ${config.currency} to upload data`);
118
- await bundlr.fund(priceWithBuffer);
119
- }
120
- return bundlr.upload(dataStr, { tags });
121
- }
122
- /**
123
- * Helper method to query the Arweave network for receivables metadata previously uploaded.
124
- *
125
- * @async
126
- * @function
127
- * @memberof ArweaveService
128
- * @param {number} chainId - The chain ID.
129
- * @param {string} sender - The sender tag to query.
130
- * @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
131
- * @returns {Promise<any>} Promise resolving with the queried data.
132
- */
133
- async function queryForMetadata(chainId, sender, referenceId) {
134
- var _a, _b, _c, _d;
135
- const config = getBundlrNetworkConfig(chainId);
136
- const query = (0, graphql_request_1.gql) `
137
- query ArweaveHumaMetadataQuery($sender: String!, $referenceId: String!) {
138
- transactions(
139
- owners: [$sender]
140
- tags: [
141
- { name: "appName", values: ["HumaFinance"] }
142
- { name: "referenceId", values: [$referenceId] }
143
- ]
144
- ) {
145
- edges {
146
- node {
147
- id
148
- }
149
- }
150
- }
151
- }
152
- `;
153
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
154
- const data = await (0, graphql_request_1.default)(`${config.nodeUrl}/graphql`, query, {
155
- sender,
156
- referenceId,
157
- });
158
- 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;
159
- }
160
- /**
161
- * Helper method to fetch data from an ARWeave URL.
162
- *
163
- * @async
164
- * @function
165
- * @memberof ArweaveService
166
- * @param {string} url - The ARWeave metadata URL to query.
167
- * @returns {Promise<JSON>} Promise resolving with the queried data.
168
- */
169
- async function fetchMetadataFromUrl(url) {
170
- try {
171
- const response = await axios_1.default.get(url);
172
- return response.data;
173
- }
174
- catch (error) {
175
- console.error('Error fetching data:', error);
176
- return null;
177
- }
178
- }
179
- /**
180
- * An object that contains functions to interact with Huma-related data stored on ARWeave
181
- * @namespace ARWeaveService
182
- */
183
- exports.ARWeaveService = {
184
- queryForMetadata,
185
- storeData,
186
- prefundBundlr,
187
- getBundlrNetworkConfig,
188
- getBundlrInstance,
189
- fetchMetadataFromUrl,
190
- };
191
- //# sourceMappingURL=ARWeaveService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ARWeaveService.js","sourceRoot":"","sources":["../../../src/services/ARWeaveService.ts"],"names":[],"mappings":";;;;AAAA,4EAA2C;AAM3C,0DAAyB;AACzB,2EAA8C;AAkB9C;;;;;;;GAOG;AACH,SAAgB,sBAAsB,CAAC,OAAe;IACpD,QAAQ,OAAO,EAAE;QACf,KAAK,CAAC,EAAE,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G,EAAA;;;;;;;;;;;;;;;;GAgBhB,CAAA;IAED,8DAA8D;IAC9D,MAAM,IAAI,GAAQ,MAAM,IAAA,yBAAO,EAAC,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;;;;;;;;GAQG;AACH,KAAK,UAAU,oBAAoB,CAAC,GAAW;IAC7C,IAAI;QACF,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACrC,OAAO,QAAQ,CAAC,IAAI,CAAA;KACrB;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAA;QAC5C,OAAO,IAAI,CAAA;KACZ;AACH,CAAC;AAED;;;GAGG;AACU,QAAA,cAAc,GAAG;IAC5B,gBAAgB;IAChB,SAAS;IACT,aAAa;IACb,sBAAsB;IACtB,iBAAiB;IACjB,oBAAoB;CACrB,CAAA"}
@@ -1,20 +0,0 @@
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,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.EAService = void 0;
4
- const shared_1 = require("@huma-finance/shared");
5
- /**
6
- * Submits a credit underwriting request to Huma's EAVerse. This approves a creditline
7
- * in Huma's pools that can be drawn down by the borrower.
8
- *
9
- * @memberof EAService
10
- * @param {EAPayload} payload The payload for the underwrite approval.
11
- * @param {number} chainId The chain ID.
12
- * @returns {Promise<Approval>} Promise that returns the approval on success.
13
- * @throws {EARejectionError} If the underwrite approval is rejected.
14
- */
15
- const approve = async (payload, chainId) => shared_1.EAService.approve(payload, chainId);
16
- /**
17
- * Checks whether or not a credit underwriting request to Huma's EAVerse would be approved.
18
- * Note that this does not approve a creditline in Huma's pools and an approve call is still required.
19
- *
20
- * @param {EAPreapprovalPayload} payload The payload for the underwrite approval.
21
- * @param {number} chainId The chain ID.
22
- * @returns {Promise<Approval>} Promise that returns the approval on success.
23
- */
24
- const preapprove = async (payload, chainId) => shared_1.EAService.preapprove(payload, chainId);
25
- /**
26
- * An object that contains functions to interact with Huma's EAVerse service.
27
- *
28
- * @namespace EAService
29
- */
30
- exports.EAService = {
31
- approve,
32
- preapprove,
33
- };
34
- //# sourceMappingURL=EAService.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EAService.js","sourceRoot":"","sources":["../../../src/services/EAService.ts"],"names":[],"mappings":";;;AAAA,iDAI6B;AAa7B;;;;;;;;;GASG;AACH,MAAM,OAAO,GAAG,KAAK,EAAE,OAAkB,EAAE,OAAe,EAAE,EAAE,CAC5D,kBAAiB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AAE7C;;;;;;;GAOG;AACH,MAAM,UAAU,GAAG,KAAK,EAAE,OAA6B,EAAE,OAAe,EAAE,EAAE,CAC1E,kBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AAEhD;;;;GAIG;AACU,QAAA,SAAS,GAAG;IACvB,OAAO;IACP,UAAU;CACX,CAAA"}
@@ -1,104 +0,0 @@
1
- import { TransactionResponse, Web3Provider } from '@ethersproject/providers';
2
- import { BigNumberish, ethers, Overrides } from 'ethers';
3
- import { POOL_NAME, POOL_TYPE, RealWorldReceivableInfo } 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 {POOL_NAME} poolName - The pool name. Used to lookup the pool address to pay to.
61
- * @param {POOL_TYPE} poolType - The pool type. Used to lookup the pool address to pay to.
62
- * @param {number} currencyCode - The ISO 4217 currency code that the receivable is denominated in
63
- * @param {number} receivableAmount - The receivable amount.
64
- * @param {number} maturityDate - The maturity date of the receivable, in UNIX timestamp format.
65
- * @param {Record<string, any>} metadata - The metadata in JSON format. This will be uploaded onto ARWeave
66
- * @param {number} referenceId - An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.
67
- * @param {Array<{ name: string, value: string }>} extraTags - Any extraTags you'd like to tag your metadata with. Note that metadata on
68
- * ARWeave is indexed by these tags, so make sure to include any tags that you'd like to be able to query by.
69
- * @param {boolean} [lazyFund=true] - Whether to lazy fund the ARWeave uploads. If true, the ARWeave uploads will be paid for by the
70
- * metadata uploader immediately before uploading. If false, the ARWeave node must be pre-funded before calling this function.
71
- * @param {Overrides} [gasOpts] - Optional gas overrides for the transaction.
72
- * @returns {Promise<TransactionResponse>} - The transaction receipt.
73
- */
74
- 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: Record<string, unknown>, referenceId: string, extraTags: {
75
- name: string;
76
- value: string;
77
- }[], lazyFund?: boolean, gasOpts?: Overrides): Promise<TransactionResponse>;
78
- /**
79
- * Loads all RWRs belonging to the specified owner, including the RWR metadata
80
- *
81
- * @async
82
- * @function
83
- * @memberof ReceivableService
84
- * @param {Web3Provider | ethers.Signer} signerOrProvider - If calling this function from a browser, this function expects a Web3Provider.
85
- * If calling this function from a server, this function expects an ethers Signer. Note that privateKey only needs to be included
86
- * from server calls.
87
- * @param {string} owner - The receivable token owner to query from.
88
- * @param {POOL_NAME} poolName - The pool name. Used to lookup the pool address to pay to.
89
- * @param {POOL_TYPE} poolType - The pool type. Used to lookup the pool address to pay to.
90
- * @returns {Promise<RealWorldReceivableInfo[]>} - An array of receivables owned by the owner for the pool.
91
- */
92
- declare function loadReceivablesOfOwnerWithMetadata<T>(signerOrProvider: Web3Provider | ethers.Signer, owner: string, poolName: POOL_NAME, poolType: POOL_TYPE): Promise<RealWorldReceivableInfo<T>[]>;
93
- /**
94
- * An object that contains functions to interact with Huma's receivables.
95
- * @namespace ReceivableService
96
- */
97
- export declare const ReceivableService: {
98
- createReceivableWithMetadata: typeof createReceivableWithMetadata;
99
- createReceivable: typeof createReceivable;
100
- declareReceivablePaymentByTokenId: typeof declareReceivablePaymentByTokenId;
101
- declareReceivablePaymentByReferenceId: typeof declareReceivablePaymentByReferenceId;
102
- loadReceivablesOfOwnerWithMetadata: typeof loadReceivablesOfOwnerWithMetadata;
103
- };
104
- export {};