@huma-finance/sdk 0.0.31 → 0.0.32

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 (119) hide show
  1. package/API.md +1041 -977
  2. package/LICENSE +660 -660
  3. package/README.md +34 -34
  4. package/dist/cjs/graphql/generatedTypes.d.ts +40 -40
  5. package/dist/cjs/graphql/generatedTypes.js +8 -8
  6. package/dist/cjs/graphql/index.d.ts +1 -1
  7. package/dist/cjs/graphql/index.js +4 -4
  8. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.d.ts +10 -0
  9. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js +22 -0
  10. package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js.map +1 -0
  11. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -10
  12. package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js +21 -21
  13. package/dist/cjs/helpers/PoolContractHelper.d.ts +119 -119
  14. package/dist/cjs/helpers/PoolContractHelper.js +142 -142
  15. package/dist/cjs/helpers/RealWorldReceivableContractHelper.d.ts +10 -10
  16. package/dist/cjs/helpers/RealWorldReceivableContractHelper.js +21 -21
  17. package/dist/cjs/helpers/index.d.ts +3 -3
  18. package/dist/cjs/helpers/index.js +6 -6
  19. package/dist/cjs/hooks/index.d.ts +4 -4
  20. package/dist/cjs/hooks/index.js +7 -7
  21. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.d.ts +10 -0
  22. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js +20 -0
  23. package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js.map +1 -0
  24. package/dist/cjs/hooks/useContract.d.ts +13 -13
  25. package/dist/cjs/hooks/useContract.js +30 -30
  26. package/dist/cjs/hooks/useERC20TransferableReceivableContract.d.ts +12 -12
  27. package/dist/cjs/hooks/useERC20TransferableReceivableContract.js +20 -20
  28. package/dist/cjs/hooks/usePoolContract.d.ts +60 -60
  29. package/dist/cjs/hooks/usePoolContract.js +53 -53
  30. package/dist/cjs/hooks/useRealWorldReceivableContract.d.ts +10 -10
  31. package/dist/cjs/hooks/useRealWorldReceivableContract.js +19 -19
  32. package/dist/cjs/hooks/useReceivableFactoringPoolContract.d.ts +10 -0
  33. package/dist/cjs/hooks/useReceivableFactoringPoolContract.js +17 -0
  34. package/dist/cjs/hooks/useReceivableFactoringPoolContract.js.map +1 -0
  35. package/dist/cjs/index.d.ts +4 -4
  36. package/dist/cjs/index.js +7 -7
  37. package/dist/cjs/services/ARWeaveService.d.ts +106 -106
  38. package/dist/cjs/services/ARWeaveService.js +190 -190
  39. package/dist/cjs/services/ARWeaveService.js.map +1 -1
  40. package/dist/cjs/services/EAService.d.ts +20 -20
  41. package/dist/cjs/services/EAService.js +33 -33
  42. package/dist/cjs/services/ReceivableService.d.ts +105 -105
  43. package/dist/cjs/services/ReceivableService.js +310 -253
  44. package/dist/cjs/services/ReceivableService.js.map +1 -1
  45. package/dist/cjs/services/SubgraphService.d.ts +53 -53
  46. package/dist/cjs/services/SubgraphService.js +93 -93
  47. package/dist/cjs/services/index.d.ts +4 -4
  48. package/dist/cjs/services/index.js +7 -7
  49. package/dist/cjs/utils/chain.d.ts +15 -15
  50. package/dist/cjs/utils/chain.js +37 -37
  51. package/dist/cjs/utils/index.d.ts +4 -4
  52. package/dist/cjs/utils/index.js +7 -7
  53. package/dist/cjs/utils/maticGasStation.d.ts +3 -3
  54. package/dist/cjs/utils/maticGasStation.js +38 -38
  55. package/dist/cjs/utils/poolInfo.d.ts +8 -8
  56. package/dist/cjs/utils/poolInfo.js +12 -12
  57. package/dist/cjs/utils/web3.d.ts +5 -5
  58. package/dist/cjs/utils/web3.js +33 -33
  59. package/dist/graphql/generatedTypes.d.ts +40 -40
  60. package/dist/graphql/generatedTypes.js +4 -4
  61. package/dist/graphql/index.d.ts +1 -1
  62. package/dist/graphql/index.js +1 -1
  63. package/dist/helpers/BaseCreditPoolReceivableContractHelper.d.ts +10 -0
  64. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js +18 -0
  65. package/dist/helpers/BaseCreditPoolReceivableContractHelper.js.map +1 -0
  66. package/dist/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -10
  67. package/dist/helpers/ERC20TransferableReceivableContractHelper.js +17 -17
  68. package/dist/helpers/PoolContractHelper.d.ts +119 -119
  69. package/dist/helpers/PoolContractHelper.js +133 -133
  70. package/dist/helpers/RealWorldReceivableContractHelper.d.ts +10 -10
  71. package/dist/helpers/RealWorldReceivableContractHelper.js +17 -17
  72. package/dist/helpers/index.d.ts +3 -3
  73. package/dist/helpers/index.js +3 -3
  74. package/dist/hooks/index.d.ts +4 -4
  75. package/dist/hooks/index.js +4 -4
  76. package/dist/hooks/useBaseCreditPoolReceivableContract.d.ts +10 -0
  77. package/dist/hooks/useBaseCreditPoolReceivableContract.js +16 -0
  78. package/dist/hooks/useBaseCreditPoolReceivableContract.js.map +1 -0
  79. package/dist/hooks/useContract.d.ts +13 -13
  80. package/dist/hooks/useContract.js +26 -26
  81. package/dist/hooks/useERC20TransferableReceivableContract.d.ts +12 -12
  82. package/dist/hooks/useERC20TransferableReceivableContract.js +16 -16
  83. package/dist/hooks/usePool.d.ts +0 -0
  84. package/dist/hooks/usePool.js +2 -0
  85. package/dist/hooks/usePool.js.map +1 -0
  86. package/dist/hooks/usePoolContract.d.ts +60 -60
  87. package/dist/hooks/usePoolContract.js +48 -48
  88. package/dist/hooks/useRealWorldReceivableContract.d.ts +10 -10
  89. package/dist/hooks/useRealWorldReceivableContract.js +15 -15
  90. package/dist/hooks/useReceivableFactoringPoolContract.d.ts +10 -0
  91. package/dist/hooks/useReceivableFactoringPoolContract.js +13 -0
  92. package/dist/hooks/useReceivableFactoringPoolContract.js.map +1 -0
  93. package/dist/index.d.ts +4 -4
  94. package/dist/index.js +4 -4
  95. package/dist/services/ARWeaveService.d.ts +106 -106
  96. package/dist/services/ARWeaveService.js +185 -185
  97. package/dist/services/ARWeaveService.js.map +1 -1
  98. package/dist/services/EAService.d.ts +20 -20
  99. package/dist/services/EAService.js +30 -30
  100. package/dist/services/ReceivableService.d.ts +105 -105
  101. package/dist/services/ReceivableService.js +306 -249
  102. package/dist/services/ReceivableService.js.map +1 -1
  103. package/dist/services/SubgraphService.d.ts +53 -53
  104. package/dist/services/SubgraphService.js +90 -90
  105. package/dist/services/index.d.ts +4 -4
  106. package/dist/services/index.js +4 -4
  107. package/dist/tsconfig.cjs.tsbuildinfo +1 -1
  108. package/dist/utils/chain.d.ts +15 -15
  109. package/dist/utils/chain.js +31 -31
  110. package/dist/utils/index.d.ts +4 -4
  111. package/dist/utils/index.js +4 -4
  112. package/dist/utils/maticGasStation.d.ts +3 -3
  113. package/dist/utils/maticGasStation.js +33 -33
  114. package/dist/utils/poolInfo.d.ts +8 -8
  115. package/dist/utils/poolInfo.js +8 -8
  116. package/dist/utils/web3.d.ts +5 -5
  117. package/dist/utils/web3.js +27 -27
  118. package/getting-started.md +190 -190
  119. package/package.json +3 -3
@@ -1,105 +1,105 @@
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 {string} recipient - The receivable token recipient.
61
- * @param {POOL_NAME} poolName - The pool name. Used to lookup the pool address to pay to.
62
- * @param {POOL_TYPE} poolType - The pool type. Used to lookup the pool address to pay to.
63
- * @param {number} currencyCode - The ISO 4217 currency code that the receivable is denominated in
64
- * @param {number} receivableAmount - The receivable amount.
65
- * @param {number} maturityDate - The maturity date of the receivable, in UNIX timestamp format.
66
- * @param {JSON} metadata - The metadata in JSON format. This will be uploaded onto ARWeave
67
- * @param {number} referenceId - An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.
68
- * @param {Array<{ name: string, value: string }>} extraTags - Any extraTags you'd like to tag your metadata with. Note that metadata on
69
- * ARWeave is indexed by these tags, so make sure to include any tags that you'd like to be able to query by.
70
- * @param {boolean} [lazyFund=true] - Whether to lazy fund the ARWeave uploads. If true, the ARWeave uploads will be paid for by the
71
- * metadata uploader immediately before uploading. If false, the ARWeave node must be pre-funded before calling this function.
72
- * @param {Overrides} [gasOpts] - Optional gas overrides for the transaction.
73
- * @returns {Promise<TransactionResponse>} - The transaction receipt.
74
- */
75
- declare function createReceivableWithMetadata(signerOrProvider: Web3Provider | ethers.Signer, privateKey: string | null, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, currencyCode: number, receivableAmount: number, maturityDate: number, metadata: JSON, referenceId: string, extraTags: {
76
- name: string;
77
- value: string;
78
- }[], lazyFund?: boolean, gasOpts?: Overrides): Promise<TransactionResponse>;
79
- /**
80
- * Creates a RealWorldReceivable token with metadata uploaded onto ARWeave
81
- *
82
- * @async
83
- * @function
84
- * @memberof ReceivableService
85
- * @param {Web3Provider | ethers.Signer} signerOrProvider - If calling this function from a browser, this function expects a Web3Provider.
86
- * If calling this function from a server, this function expects an ethers Signer. Note that privateKey only needs to be included
87
- * from server calls.
88
- * @param {string} owner - The receivable token owner to query from.
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
- * @returns {Promise<RealWorldReceivableInfo[]>} - An array of receivables owned by the owner for the pool.
92
- */
93
- declare function loadReceivablesOfOwnerWithMetadata(signerOrProvider: Web3Provider | ethers.Signer, owner: string, poolName: POOL_NAME, poolType: POOL_TYPE): Promise<RealWorldReceivableInfo[]>;
94
- /**
95
- * An object that contains functions to interact with Huma's receivables.
96
- * @namespace ReceivableService
97
- */
98
- export declare const ReceivableService: {
99
- createReceivableWithMetadata: typeof createReceivableWithMetadata;
100
- createReceivable: typeof createReceivable;
101
- declareReceivablePaymentByTokenId: typeof declareReceivablePaymentByTokenId;
102
- declareReceivablePaymentByReferenceId: typeof declareReceivablePaymentByReferenceId;
103
- loadReceivablesOfOwnerWithMetadata: typeof loadReceivablesOfOwnerWithMetadata;
104
- };
105
- export {};
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 {string} recipient - The receivable token recipient.
61
+ * @param {POOL_NAME} poolName - The pool name. Used to lookup the pool address to pay to.
62
+ * @param {POOL_TYPE} poolType - The pool type. Used to lookup the pool address to pay to.
63
+ * @param {number} currencyCode - The ISO 4217 currency code that the receivable is denominated in
64
+ * @param {number} receivableAmount - The receivable amount.
65
+ * @param {number} maturityDate - The maturity date of the receivable, in UNIX timestamp format.
66
+ * @param {Record<string, any>} metadata - The metadata in JSON format. This will be uploaded onto ARWeave
67
+ * @param {number} referenceId - An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.
68
+ * @param {Array<{ name: string, value: string }>} extraTags - Any extraTags you'd like to tag your metadata with. Note that metadata on
69
+ * ARWeave is indexed by these tags, so make sure to include any tags that you'd like to be able to query by.
70
+ * @param {boolean} [lazyFund=true] - Whether to lazy fund the ARWeave uploads. If true, the ARWeave uploads will be paid for by the
71
+ * metadata uploader immediately before uploading. If false, the ARWeave node must be pre-funded before calling this function.
72
+ * @param {Overrides} [gasOpts] - Optional gas overrides for the transaction.
73
+ * @returns {Promise<TransactionResponse>} - The transaction receipt.
74
+ */
75
+ declare function createReceivableWithMetadata(signerOrProvider: Web3Provider | ethers.Signer, privateKey: string | null, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, currencyCode: number, receivableAmount: number, maturityDate: number, metadata: Record<string, unknown>, referenceId: string, extraTags: {
76
+ name: string;
77
+ value: string;
78
+ }[], lazyFund?: boolean, gasOpts?: Overrides): Promise<TransactionResponse>;
79
+ /**
80
+ * Creates a RealWorldReceivable token with metadata uploaded onto ARWeave
81
+ *
82
+ * @async
83
+ * @function
84
+ * @memberof ReceivableService
85
+ * @param {Web3Provider | ethers.Signer} signerOrProvider - If calling this function from a browser, this function expects a Web3Provider.
86
+ * If calling this function from a server, this function expects an ethers Signer. Note that privateKey only needs to be included
87
+ * from server calls.
88
+ * @param {string} owner - The receivable token owner to query from.
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
+ * @returns {Promise<RealWorldReceivableInfo[]>} - An array of receivables owned by the owner for the pool.
92
+ */
93
+ declare function loadReceivablesOfOwnerWithMetadata(signerOrProvider: Web3Provider | ethers.Signer, owner: string, poolName: POOL_NAME, poolType: POOL_TYPE): Promise<RealWorldReceivableInfo[]>;
94
+ /**
95
+ * An object that contains functions to interact with Huma's receivables.
96
+ * @namespace ReceivableService
97
+ */
98
+ export declare const ReceivableService: {
99
+ createReceivableWithMetadata: typeof createReceivableWithMetadata;
100
+ createReceivable: typeof createReceivable;
101
+ declareReceivablePaymentByTokenId: typeof declareReceivablePaymentByTokenId;
102
+ declareReceivablePaymentByReferenceId: typeof declareReceivablePaymentByReferenceId;
103
+ loadReceivablesOfOwnerWithMetadata: typeof loadReceivablesOfOwnerWithMetadata;
104
+ };
105
+ export {};