@huma-finance/sdk 0.0.11 → 0.0.13

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 (67) hide show
  1. package/API.md +482 -0
  2. package/README.md +9 -5
  3. package/dist/cjs/graphql/generatedTypes.d.ts +40 -0
  4. package/dist/cjs/graphql/generatedTypes.js +9 -0
  5. package/dist/cjs/graphql/generatedTypes.js.map +1 -0
  6. package/dist/cjs/graphql/index.d.ts +1 -0
  7. package/dist/cjs/graphql/index.js +5 -0
  8. package/dist/cjs/graphql/index.js.map +1 -0
  9. package/dist/cjs/helpers/PoolContractHelper.d.ts +30 -1
  10. package/dist/cjs/helpers/PoolContractHelper.js +45 -1
  11. package/dist/cjs/helpers/PoolContractHelper.js.map +1 -1
  12. package/dist/cjs/services/ARWeaveService.d.ts +1 -18
  13. package/dist/cjs/services/ARWeaveService.js +17 -51
  14. package/dist/cjs/services/ARWeaveService.js.map +1 -1
  15. package/dist/cjs/services/ReceivableService.d.ts +11 -0
  16. package/dist/cjs/services/ReceivableService.js +71 -20
  17. package/dist/cjs/services/ReceivableService.js.map +1 -1
  18. package/dist/graphql/generatedTypes.d.ts +40 -0
  19. package/dist/graphql/generatedTypes.js +5 -0
  20. package/dist/graphql/generatedTypes.js.map +1 -0
  21. package/dist/graphql/index.d.ts +1 -0
  22. package/dist/graphql/index.js +2 -0
  23. package/dist/graphql/index.js.map +1 -0
  24. package/dist/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -10
  25. package/dist/helpers/ERC20TransferableReceivableContractHelper.js +17 -17
  26. package/dist/helpers/PoolContractHelper.d.ts +41 -12
  27. package/dist/helpers/PoolContractHelper.js +58 -16
  28. package/dist/helpers/PoolContractHelper.js.map +1 -1
  29. package/dist/helpers/RealWorldReceivableContractHelper.d.ts +10 -10
  30. package/dist/helpers/RealWorldReceivableContractHelper.js +17 -17
  31. package/dist/helpers/index.d.ts +3 -3
  32. package/dist/helpers/index.js +3 -3
  33. package/dist/hooks/index.d.ts +4 -4
  34. package/dist/hooks/index.js +4 -4
  35. package/dist/hooks/useContract.d.ts +13 -13
  36. package/dist/hooks/useContract.js +26 -26
  37. package/dist/hooks/useERC20TransferableReceivableContract.d.ts +12 -12
  38. package/dist/hooks/useERC20TransferableReceivableContract.js +16 -16
  39. package/dist/hooks/usePoolContract.d.ts +60 -60
  40. package/dist/hooks/usePoolContract.js +48 -48
  41. package/dist/hooks/useRealWorldReceivableContract.d.ts +10 -10
  42. package/dist/hooks/useRealWorldReceivableContract.js +15 -15
  43. package/dist/index.d.ts +4 -4
  44. package/dist/index.js +4 -4
  45. package/dist/services/ARWeaveService.d.ts +81 -84
  46. package/dist/services/ARWeaveService.js +133 -144
  47. package/dist/services/ARWeaveService.js.map +1 -1
  48. package/dist/services/EAService.d.ts +18 -18
  49. package/dist/services/EAService.js +9 -9
  50. package/dist/services/ReceivableService.d.ts +87 -76
  51. package/dist/services/ReceivableService.js +182 -132
  52. package/dist/services/ReceivableService.js.map +1 -1
  53. package/dist/services/SubgraphService.d.ts +53 -53
  54. package/dist/services/SubgraphService.js +79 -79
  55. package/dist/services/index.d.ts +4 -4
  56. package/dist/services/index.js +4 -4
  57. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  58. package/dist/utils/chain.d.ts +14 -14
  59. package/dist/utils/chain.js +28 -28
  60. package/dist/utils/index.d.ts +3 -3
  61. package/dist/utils/index.js +3 -3
  62. package/dist/utils/poolInfo.d.ts +9 -9
  63. package/dist/utils/poolInfo.js +9 -9
  64. package/dist/utils/web3.d.ts +4 -4
  65. package/dist/utils/web3.js +23 -23
  66. package/getting-started.md +191 -0
  67. package/package.json +13 -6
@@ -1,76 +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
- declare function declareReceivablePaymentByReferenceId(signer: ethers.Signer, referenceId: string, paymentAmount: number): Promise<TransactionResponse>;
5
- /**
6
- * Declares a payment on a RealWorldReceivable given a tokenID of the receivable.
7
- *
8
- * @async
9
- * @function
10
- * @memberof ReceivableService
11
- * @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
12
- * @param {BigNumberish} receivableTokenId - The ID of the receivable token to pay.
13
- * @param {number} paymentAmount - The amount to pay the receivable.
14
- * @returns {Promise<TransactionResponse>} - A Promise of the transaction receipt.
15
- * @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
16
- */
17
- declare function declareReceivablePaymentByTokenId(signer: ethers.Signer, receivableTokenId: BigNumberish, paymentAmount: number): Promise<TransactionResponse>;
18
- /**
19
- * Creates a new RealWorldReceivable token on the given chain of the signer
20
- *
21
- * @async
22
- * @function
23
- * @memberof ReceivableService
24
- * @param {ethers.Signer} signer - The signer used to send the transaction.
25
- * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
26
- * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
27
- * @param {number} currencyCode - The ISO 4217 currency code that the receivable is denominated in
28
- * @param {number} receivableAmount - The amount of the receivable token to mint.
29
- * @param {number} maturityDate - The maturity date of the receivable token, in UNIX timestamp format.
30
- * @param {string} uri - The URI of the receivable token metadata.
31
- * @param {Overrides} gasOpts - The gas options to use for the transaction.
32
- * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
33
- * @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
34
- */
35
- declare function createReceivable(signer: ethers.Signer, poolName: POOL_NAME, poolType: POOL_TYPE, currencyCode: number, receivableAmount: number, maturityDate: number, uri: string, gasOpts?: Overrides): Promise<TransactionResponse>;
36
- /**
37
- * Creates a RealWorldReceivable token with metadata uploaded onto ARWeave
38
- *
39
- * @async
40
- * @function
41
- * @memberof ReceivableService
42
- * @param {Web3Provider | ethers.Signer} signerOrProvider - If calling this function from a browser, this function expects a Web3Provider.
43
- * If calling this function from a server, this function expects an ethers Signer. Note that privateKey only needs to be included
44
- * from server calls.
45
- * @param {string | null} privateKey - Private key of the wallet used to upload metadata to ARWeave. Only required if calling this function from a server.
46
- * @param {number} chainId - The chain ID to mint the receivable token on and pay ARWeave funds from.
47
- * @param {string} recipient - The receivable token recipient.
48
- * @param {POOL_NAME} poolName - The pool name. Used to lookup the pool address to pay to.
49
- * @param {POOL_TYPE} poolType - The pool type. Used to lookup the pool address to pay to.
50
- * @param {number} currencyCode - The ISO 4217 currency code that the receivable is denominated in
51
- * @param {number} receivableAmount - The receivable amount.
52
- * @param {number} maturityDate - The maturity date of the receivable, in UNIX timestamp format.
53
- * @param {JSON} metadata - The metadata in JSON format. This will be uploaded onto ARWeave
54
- * @param {number} referenceId - An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.
55
- * @param {Array<{ name: string, value: string }>} extraTags - Any extraTags you'd like to tag your metadata with. Note that metadata on
56
- * ARWeave is indexed by these tags, so make sure to include any tags that you'd like to be able to query by.
57
- * @param {boolean} [lazyFund=true] - Whether to lazy fund the ARWeave uploads. If true, the ARWeave uploads will be paid for by the
58
- * metadata uploader immediately before uploading. If false, the ARWeave node must be pre-funded before calling this function.
59
- * @param {Overrides} [gasOpts] - Optional gas overrides for the transaction.
60
- * @returns {Promise<TransactionResponse>} - The transaction receipt.
61
- */
62
- declare function createReceivableWithMetadata(signerOrProvider: Web3Provider | ethers.Signer, privateKey: string | null, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, currencyCode: number, receivableAmount: number, maturityDate: number, metadata: JSON, referenceId: string, extraTags: {
63
- name: string;
64
- value: string;
65
- }[], lazyFund?: boolean, gasOpts?: Overrides): Promise<TransactionResponse>;
66
- /**
67
- * An object that contains functions to interact with Huma's receivables.
68
- * @namespace ReceivableService
69
- */
70
- export declare const ReceivableService: {
71
- createReceivableWithMetadata: typeof createReceivableWithMetadata;
72
- createReceivable: typeof createReceivable;
73
- declareReceivablePaymentByTokenId: typeof declareReceivablePaymentByTokenId;
74
- declareReceivablePaymentByReferenceId: typeof declareReceivablePaymentByReferenceId;
75
- };
76
- export {};
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 {};
@@ -1,135 +1,185 @@
1
- import { Web3Provider } from '@ethersproject/providers';
2
- import { REAL_WORLD_RECEIVABLE_ABI, PoolContractMap, SupplementaryContracts, SupplementaryContractsMap, } from '@huma-finance/shared';
3
- import { getContract } from '../utils';
4
- import { ARWeaveService } from './ARWeaveService';
5
- import { getChainIdFromSignerOrProvider } from '../utils/chain';
6
- async function declareReceivablePaymentByReferenceId(
7
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
8
- signer,
9
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
10
- referenceId,
11
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
12
- paymentAmount) {
13
- throw new Error('Not implemented');
14
- }
15
- /**
16
- * Declares a payment on a RealWorldReceivable given a tokenID of the receivable.
17
- *
18
- * @async
19
- * @function
20
- * @memberof ReceivableService
21
- * @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
22
- * @param {BigNumberish} receivableTokenId - The ID of the receivable token to pay.
23
- * @param {number} paymentAmount - The amount to pay the receivable.
24
- * @returns {Promise<TransactionResponse>} - A Promise of the transaction receipt.
25
- * @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
26
- */
27
- async function declareReceivablePaymentByTokenId(signer, receivableTokenId, paymentAmount) {
28
- var _a;
29
- const chainId = await getChainIdFromSignerOrProvider(signer);
30
- const realWorldReceivable = chainId
31
- ? (_a = SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[SupplementaryContracts.RealWorldReceivable]
32
- : null;
33
- if (!realWorldReceivable) {
34
- throw new Error('RealWorldReceivable is not available on this network');
1
+ import { Web3Provider } from '@ethersproject/providers';
2
+ import { ChainEnum, PoolContractMap, SupplementaryContracts, SupplementaryContractsMap, } from '@huma-finance/shared';
3
+ import request, { gql } from 'graphql-request';
4
+ import { ARWeaveService } from './ARWeaveService';
5
+ import { getRealWorldReceivableContract } from '../helpers';
6
+ import { getChainIdFromSignerOrProvider } from '../utils/chain';
7
+ /**
8
+ * Declares a payment on a RealWorldReceivable given a reference ID of the receivable, which was used as an index for ARWeave data.
9
+ *
10
+ * @async
11
+ * @function
12
+ * @memberof ReceivableService
13
+ * @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
14
+ * @param {string} referenceId - An internal identifier value added as a tag on ARWeave
15
+ * @param {number} paymentAmount - The amount to declare paid to the receivable.
16
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction receipt.
17
+ */
18
+ async function declareReceivablePaymentByReferenceId(signer, referenceId, paymentAmount) {
19
+ var _a, _b, _c;
20
+ const chainId = await getChainIdFromSignerOrProvider(signer);
21
+ const signerAddress = await signer.getAddress();
22
+ if (!chainId) {
23
+ throw new Error('No Chain ID found');
24
+ }
25
+ // Get ARWeave ID
26
+ const dataID = await ARWeaveService.queryForMetadata(chainId, signerAddress, referenceId);
27
+ // Fetch receivables with the same ARWeave ID
28
+ const receivablesQuery = gql `
29
+ query ReceivablesByURIQuery($owner: String!, $uri: String!) {
30
+ receivables(where: { owner: $owner, uri: $uri }) {
31
+ ...ReceivableFields
32
+ }
35
33
  }
36
- const contract = getContract(realWorldReceivable, REAL_WORLD_RECEIVABLE_ABI, signer);
37
- if (!contract) {
38
- throw new Error('Could not find RealWorldReceivable contract');
34
+
35
+ fragment ReceivableFields on Receivable {
36
+ tokenId
39
37
  }
40
- return contract.declarePayment(receivableTokenId, paymentAmount);
41
- }
42
- /**
43
- * Creates a new RealWorldReceivable token on the given chain of the signer
44
- *
45
- * @async
46
- * @function
47
- * @memberof ReceivableService
48
- * @param {ethers.Signer} signer - The signer used to send the transaction.
49
- * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
50
- * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
51
- * @param {number} currencyCode - The ISO 4217 currency code that the receivable is denominated in
52
- * @param {number} receivableAmount - The amount of the receivable token to mint.
53
- * @param {number} maturityDate - The maturity date of the receivable token, in UNIX timestamp format.
54
- * @param {string} uri - The URI of the receivable token metadata.
55
- * @param {Overrides} gasOpts - The gas options to use for the transaction.
56
- * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
57
- * @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
58
- */
59
- async function createReceivable(signer, poolName, poolType, currencyCode, receivableAmount, maturityDate, uri, gasOpts = {}) {
60
- var _a, _b, _c;
61
- const chainId = await getChainIdFromSignerOrProvider(signer);
62
- const realWorldReceivable = chainId
63
- ? (_a = SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[SupplementaryContracts.RealWorldReceivable]
64
- : null;
65
- const poolInfo = chainId
66
- ? (_c = (_b = PoolContractMap[chainId]) === null || _b === void 0 ? void 0 : _b[poolType]) === null || _c === void 0 ? void 0 : _c[poolName]
67
- : undefined;
68
- if (!realWorldReceivable || !poolInfo) {
69
- throw new Error('RealWorldReceivable is not available on this network');
70
- }
71
- const contract = getContract(realWorldReceivable, REAL_WORLD_RECEIVABLE_ABI, signer);
72
- if (!contract) {
73
- throw new Error('Could not find RealWorldReceivable contract');
74
- }
75
- return contract.createRealWorldReceivable(poolInfo.pool, currencyCode, receivableAmount, maturityDate, uri, gasOpts);
76
- }
77
- /**
78
- * Creates a RealWorldReceivable token with metadata uploaded onto ARWeave
79
- *
80
- * @async
81
- * @function
82
- * @memberof ReceivableService
83
- * @param {Web3Provider | ethers.Signer} signerOrProvider - If calling this function from a browser, this function expects a Web3Provider.
84
- * If calling this function from a server, this function expects an ethers Signer. Note that privateKey only needs to be included
85
- * from server calls.
86
- * @param {string | null} privateKey - Private key of the wallet used to upload metadata to ARWeave. Only required if calling this function from a server.
87
- * @param {number} chainId - The chain ID to mint the receivable token on and pay ARWeave funds from.
88
- * @param {string} recipient - The receivable token recipient.
89
- * @param {POOL_NAME} poolName - The pool name. Used to lookup the pool address to pay to.
90
- * @param {POOL_TYPE} poolType - The pool type. Used to lookup the pool address to pay to.
91
- * @param {number} currencyCode - The ISO 4217 currency code that the receivable is denominated in
92
- * @param {number} receivableAmount - The receivable amount.
93
- * @param {number} maturityDate - The maturity date of the receivable, in UNIX timestamp format.
94
- * @param {JSON} metadata - The metadata in JSON format. This will be uploaded onto ARWeave
95
- * @param {number} referenceId - An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.
96
- * @param {Array<{ name: string, value: string }>} extraTags - Any extraTags you'd like to tag your metadata with. Note that metadata on
97
- * ARWeave is indexed by these tags, so make sure to include any tags that you'd like to be able to query by.
98
- * @param {boolean} [lazyFund=true] - Whether to lazy fund the ARWeave uploads. If true, the ARWeave uploads will be paid for by the
99
- * metadata uploader immediately before uploading. If false, the ARWeave node must be pre-funded before calling this function.
100
- * @param {Overrides} [gasOpts] - Optional gas overrides for the transaction.
101
- * @returns {Promise<TransactionResponse>} - The transaction receipt.
102
- */
103
- async function createReceivableWithMetadata(signerOrProvider, privateKey, chainId, poolName, poolType, currencyCode, receivableAmount, maturityDate, metadata, referenceId, extraTags, lazyFund = true, gasOpts) {
104
- const config = ARWeaveService.getBundlrNetworkConfig(chainId);
105
- try {
106
- const tags = [
107
- { name: 'Content-Type', value: 'application/json' },
108
- { name: 'appName', value: 'HumaFinance' },
109
- { name: 'poolName', value: poolName },
110
- { name: 'poolType', value: poolType },
111
- { name: 'referenceId', value: referenceId },
112
- ...extraTags,
113
- ];
114
- const response = await ARWeaveService.storeData(config, signerOrProvider instanceof Web3Provider ? signerOrProvider : privateKey, metadata, tags, lazyFund);
115
- console.log(`Data uploaded ==> https://arweave.net/${response.id}`);
116
- return await createReceivable(signerOrProvider instanceof Web3Provider
117
- ? signerOrProvider.getSigner()
118
- : signerOrProvider, poolName, poolType, currencyCode, receivableAmount, maturityDate, `https://arweave.net/${response.id}`, gasOpts);
119
- }
120
- catch (e) {
121
- console.error(e);
122
- throw e;
123
- }
124
- }
125
- /**
126
- * An object that contains functions to interact with Huma's receivables.
127
- * @namespace ReceivableService
128
- */
129
- export const ReceivableService = {
130
- createReceivableWithMetadata,
131
- createReceivable,
132
- declareReceivablePaymentByTokenId,
133
- declareReceivablePaymentByReferenceId,
134
- };
38
+ `;
39
+ let receivableSubgraph;
40
+ switch (chainId) {
41
+ case ChainEnum.Goerli:
42
+ receivableSubgraph = `https://api.thegraph.com/subgraphs/name/00labs/huma-receivables-goerli`;
43
+ break;
44
+ default:
45
+ throw new Error('No receivable subgraph exists for this chain');
46
+ }
47
+ const receivablesData = await request(receivableSubgraph, receivablesQuery, {
48
+ owner: signerAddress,
49
+ uri: `https://arweave.net/${dataID}`,
50
+ });
51
+ if (!(receivablesData === null || receivablesData === void 0 ? void 0 : receivablesData.receivables) || !((_a = receivablesData === null || receivablesData === void 0 ? void 0 : receivablesData.receivables) === null || _a === void 0 ? void 0 : _a.length)) {
52
+ throw new Error('No receivables found with this ARWeave ID.');
53
+ }
54
+ else if (((_b = receivablesData === null || receivablesData === void 0 ? void 0 : receivablesData.receivables) === null || _b === void 0 ? void 0 : _b.length) > 1) {
55
+ throw new Error(`This owner has multiple receivables with the same URI. Please burn
56
+ unnecessary receivables or pay the correct token manually using declareReceivablePaymentByTokenId`);
57
+ }
58
+ const contract = getRealWorldReceivableContract(signer, chainId);
59
+ if (!contract) {
60
+ throw new Error('Could not find RealWorldReceivable contract');
61
+ }
62
+ return contract.declarePayment((_c = receivablesData === null || receivablesData === void 0 ? void 0 : receivablesData.receivables[0]) === null || _c === void 0 ? void 0 : _c.tokenId, paymentAmount);
63
+ }
64
+ /**
65
+ * Declares a payment on a RealWorldReceivable given a tokenID of the receivable.
66
+ *
67
+ * @async
68
+ * @function
69
+ * @memberof ReceivableService
70
+ * @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
71
+ * @param {BigNumberish} receivableTokenId - The ID of the receivable token to pay.
72
+ * @param {number} paymentAmount - The amount to pay the receivable.
73
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction receipt.
74
+ * @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
75
+ */
76
+ async function declareReceivablePaymentByTokenId(signer, receivableTokenId, paymentAmount) {
77
+ var _a;
78
+ const chainId = await getChainIdFromSignerOrProvider(signer);
79
+ if (!chainId) {
80
+ throw new Error('No Chain ID found');
81
+ }
82
+ const realWorldReceivable = (_a = SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[SupplementaryContracts.RealWorldReceivable];
83
+ if (!realWorldReceivable) {
84
+ throw new Error('RealWorldReceivable is not available on this network');
85
+ }
86
+ const contract = getRealWorldReceivableContract(signer, chainId);
87
+ if (!contract) {
88
+ throw new Error('Could not find RealWorldReceivable contract');
89
+ }
90
+ return contract.declarePayment(receivableTokenId, paymentAmount);
91
+ }
92
+ /**
93
+ * Creates a new RealWorldReceivable token on the given chain of the signer
94
+ *
95
+ * @async
96
+ * @function
97
+ * @memberof ReceivableService
98
+ * @param {ethers.Signer} signer - The signer used to send the transaction.
99
+ * @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
100
+ * @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
101
+ * @param {number} currencyCode - The ISO 4217 currency code that the receivable is denominated in
102
+ * @param {number} receivableAmount - The amount of the receivable token to mint.
103
+ * @param {number} maturityDate - The maturity date of the receivable token, in UNIX timestamp format.
104
+ * @param {string} uri - The URI of the receivable token metadata.
105
+ * @param {Overrides} gasOpts - The gas options to use for the transaction.
106
+ * @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
107
+ * @throws {Error} - Throws an error if the RealWorldReceivable contract is not available on the network.
108
+ */
109
+ async function createReceivable(signer, poolName, poolType, currencyCode, receivableAmount, maturityDate, uri, gasOpts = {}) {
110
+ var _a, _b;
111
+ const chainId = await getChainIdFromSignerOrProvider(signer);
112
+ if (!chainId) {
113
+ throw new Error('No Chain ID found');
114
+ }
115
+ const poolInfo = chainId
116
+ ? (_b = (_a = PoolContractMap[chainId]) === null || _a === void 0 ? void 0 : _a[poolType]) === null || _b === void 0 ? void 0 : _b[poolName]
117
+ : undefined;
118
+ if (!poolInfo) {
119
+ throw new Error('RealWorldReceivable is not available on this network');
120
+ }
121
+ const contract = getRealWorldReceivableContract(signer, chainId);
122
+ if (!contract) {
123
+ throw new Error('Could not find RealWorldReceivable contract');
124
+ }
125
+ return contract.createRealWorldReceivable(poolInfo.pool, currencyCode, receivableAmount, maturityDate, uri, gasOpts);
126
+ }
127
+ /**
128
+ * Creates a RealWorldReceivable token with metadata uploaded onto ARWeave
129
+ *
130
+ * @async
131
+ * @function
132
+ * @memberof ReceivableService
133
+ * @param {Web3Provider | ethers.Signer} signerOrProvider - If calling this function from a browser, this function expects a Web3Provider.
134
+ * If calling this function from a server, this function expects an ethers Signer. Note that privateKey only needs to be included
135
+ * from server calls.
136
+ * @param {string | null} privateKey - Private key of the wallet used to upload metadata to ARWeave. Only required if calling this function from a server.
137
+ * @param {number} chainId - The chain ID to mint the receivable token on and pay ARWeave funds from.
138
+ * @param {string} recipient - The receivable token recipient.
139
+ * @param {POOL_NAME} poolName - The pool name. Used to lookup the pool address to pay to.
140
+ * @param {POOL_TYPE} poolType - The pool type. Used to lookup the pool address to pay to.
141
+ * @param {number} currencyCode - The ISO 4217 currency code that the receivable is denominated in
142
+ * @param {number} receivableAmount - The receivable amount.
143
+ * @param {number} maturityDate - The maturity date of the receivable, in UNIX timestamp format.
144
+ * @param {JSON} metadata - The metadata in JSON format. This will be uploaded onto ARWeave
145
+ * @param {number} referenceId - An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.
146
+ * @param {Array<{ name: string, value: string }>} extraTags - Any extraTags you'd like to tag your metadata with. Note that metadata on
147
+ * ARWeave is indexed by these tags, so make sure to include any tags that you'd like to be able to query by.
148
+ * @param {boolean} [lazyFund=true] - Whether to lazy fund the ARWeave uploads. If true, the ARWeave uploads will be paid for by the
149
+ * metadata uploader immediately before uploading. If false, the ARWeave node must be pre-funded before calling this function.
150
+ * @param {Overrides} [gasOpts] - Optional gas overrides for the transaction.
151
+ * @returns {Promise<TransactionResponse>} - The transaction receipt.
152
+ */
153
+ async function createReceivableWithMetadata(signerOrProvider, privateKey, chainId, poolName, poolType, currencyCode, receivableAmount, maturityDate, metadata, referenceId, extraTags, lazyFund = true, gasOpts) {
154
+ const config = ARWeaveService.getBundlrNetworkConfig(chainId);
155
+ try {
156
+ const tags = [
157
+ { name: 'Content-Type', value: 'application/json' },
158
+ { name: 'appName', value: 'HumaFinance' },
159
+ { name: 'poolName', value: poolName },
160
+ { name: 'poolType', value: poolType },
161
+ { name: 'referenceId', value: referenceId },
162
+ ...extraTags,
163
+ ];
164
+ const response = await ARWeaveService.storeData(config, signerOrProvider instanceof Web3Provider ? signerOrProvider : privateKey, metadata, tags, lazyFund);
165
+ console.log(`Data uploaded ==> https://arweave.net/${response.id}`);
166
+ return await createReceivable(signerOrProvider instanceof Web3Provider
167
+ ? signerOrProvider.getSigner()
168
+ : signerOrProvider, poolName, poolType, currencyCode, receivableAmount, maturityDate, `https://arweave.net/${response.id}`, gasOpts);
169
+ }
170
+ catch (e) {
171
+ console.error(e);
172
+ throw e;
173
+ }
174
+ }
175
+ /**
176
+ * An object that contains functions to interact with Huma's receivables.
177
+ * @namespace ReceivableService
178
+ */
179
+ export const ReceivableService = {
180
+ createReceivableWithMetadata,
181
+ createReceivable,
182
+ declareReceivablePaymentByTokenId,
183
+ declareReceivablePaymentByReferenceId,
184
+ };
135
185
  //# sourceMappingURL=ReceivableService.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ReceivableService.js","sourceRoot":"","sources":["../../src/services/ReceivableService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAE5E,OAAO,EACL,yBAAyB,EAGzB,eAAe,EACf,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AACtC,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAA;AAE/D,KAAK,UAAU,qCAAqC;AAClD,6DAA6D;AAC7D,MAAqB;AACrB,6DAA6D;AAC7D,WAAmB;AACnB,6DAA6D;AAC7D,aAAqB;IAErB,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAA;AACpC,CAAC;AAED;;;;;;;;;;;GAWG;AACH,KAAK,UAAU,iCAAiC,CAC9C,MAAqB,EACrB,iBAA+B,EAC/B,aAAqB;;IAErB,MAAM,OAAO,GAAG,MAAM,8BAA8B,CAAC,MAAM,CAAC,CAAA;IAE5D,MAAM,mBAAmB,GAAG,OAAO;QACjC,CAAC,CAAC,MAAA,yBAAyB,CAAC,OAAO,CAAC,0CAChC,sBAAsB,CAAC,mBAAmB,CAC3C;QACH,CAAC,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Q,CAAC,EAAE,EAAE,EACpC,OAAO,CACR,CAAA;KACF;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAA;QAChB,MAAM,CAAC,CAAA;KACR;AACH,CAAC;AAED;;;GAGG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG;IAC/B,4BAA4B;IAC5B,gBAAgB;IAChB,iCAAiC;IACjC,qCAAqC;CACtC,CAAA"}
1
+ {"version":3,"file":"ReceivableService.js","sourceRoot":"","sources":["../../src/services/ReceivableService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAuB,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAE5E,OAAO,EACL,SAAS,EAGT,eAAe,EACf,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAA;AAC7B,OAAO,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAE9C,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AACjD,OAAO,EAAE,8BAA8B,EAAE,MAAM,YAAY,CAAA;AAC3D,OAAO,EAAE,8BAA8B,EAAE,MAAM,gBAAgB,CAAA;AAG/D;;;;;;;;;;GAUG;AACH,KAAK,UAAU,qCAAqC,CAClD,MAAqB,EACrB,WAAmB,EACnB,aAAqB;;IAErB,MAAM,OAAO,GAAG,MAAM,8BAA8B,CAAC,MAAM,CAAC,CAAA;IAC5D,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAA;IAE/C,IAAI,CAAC,OAAO,EAAE;QACZ,MAAM,IAAI,KAAK,CAAC,mBAAmB,CAAC,CAAA;KACrC;IAED,iBAAiB;IACjB,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,gBAAgB,CAClD,OAAO,EACP,aAAa,EACb,WAAW,CACZ,CAAA;IAED,6CAA6C;IAC7C,MAAM,gBAAgB,GAAG,GAAG,CAAA;;;;;;;;;;GAU3B,CAAA;IAED,IAAI,kBAAkB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