@huma-finance/sdk 0.0.7 → 0.0.8
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.
- package/README.md +23 -7
- package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.d.ts +2 -1
- package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js +5 -4
- package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js.map +1 -1
- package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -0
- package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js +22 -0
- package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js.map +1 -0
- package/dist/cjs/helpers/PoolContractHelper.d.ts +12 -0
- package/dist/cjs/helpers/PoolContractHelper.js +21 -0
- package/dist/cjs/helpers/PoolContractHelper.js.map +1 -0
- package/dist/cjs/helpers/index.d.ts +2 -0
- package/dist/cjs/helpers/index.js +2 -0
- package/dist/cjs/helpers/index.js.map +1 -1
- package/dist/cjs/hooks/index.d.ts +0 -1
- package/dist/cjs/hooks/index.js +0 -1
- package/dist/cjs/hooks/index.js.map +1 -1
- package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.d.ts +2 -1
- package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js +5 -4
- package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js.map +1 -1
- package/dist/cjs/hooks/useContract.d.ts +6 -4
- package/dist/cjs/hooks/useContract.js +6 -4
- package/dist/cjs/hooks/useContract.js.map +1 -1
- package/dist/cjs/hooks/useERC20TransferableReceivableContract.d.ts +5 -5
- package/dist/cjs/hooks/useERC20TransferableReceivableContract.js +6 -9
- package/dist/cjs/hooks/useERC20TransferableReceivableContract.js.map +1 -1
- package/dist/cjs/hooks/usePoolContract.d.ts +11 -4
- package/dist/cjs/hooks/usePoolContract.js +8 -3
- package/dist/cjs/hooks/usePoolContract.js.map +1 -1
- package/dist/cjs/services/ARWeaveService.d.ts +36 -14
- package/dist/cjs/services/ARWeaveService.js +33 -22
- package/dist/cjs/services/ARWeaveService.js.map +1 -1
- package/dist/cjs/services/EAService.d.ts +25 -2
- package/dist/cjs/services/EAService.js +4 -2
- package/dist/cjs/services/EAService.js.map +1 -1
- package/dist/cjs/services/ReceivableService.d.ts +30 -11
- package/dist/cjs/services/ReceivableService.js +40 -24
- package/dist/cjs/services/ReceivableService.js.map +1 -1
- package/dist/cjs/services/SubgraphService.d.ts +18 -4
- package/dist/cjs/services/SubgraphService.js +34 -25
- package/dist/cjs/services/SubgraphService.js.map +1 -1
- package/dist/cjs/utils/poolInfo.d.ts +1 -1
- package/dist/cjs/utils/poolInfo.js +2 -2
- package/dist/cjs/utils/poolInfo.js.map +1 -1
- package/dist/helpers/BaseCreditPoolReceivableContractHelper.d.ts +2 -1
- package/dist/helpers/BaseCreditPoolReceivableContractHelper.js +3 -2
- package/dist/helpers/BaseCreditPoolReceivableContractHelper.js.map +1 -1
- package/dist/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -0
- package/dist/helpers/ERC20TransferableReceivableContractHelper.js +18 -0
- package/dist/helpers/ERC20TransferableReceivableContractHelper.js.map +1 -0
- package/dist/helpers/PoolContractHelper.d.ts +12 -0
- package/dist/helpers/PoolContractHelper.js +17 -0
- package/dist/helpers/PoolContractHelper.js.map +1 -0
- package/dist/helpers/index.d.ts +2 -0
- package/dist/helpers/index.js +2 -0
- package/dist/helpers/index.js.map +1 -1
- package/dist/hooks/index.d.ts +0 -1
- package/dist/hooks/index.js +0 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useBaseCreditPoolReceivableContract.d.ts +2 -1
- package/dist/hooks/useBaseCreditPoolReceivableContract.js +3 -2
- package/dist/hooks/useBaseCreditPoolReceivableContract.js.map +1 -1
- package/dist/hooks/useContract.d.ts +6 -4
- package/dist/hooks/useContract.js +6 -4
- package/dist/hooks/useContract.js.map +1 -1
- package/dist/hooks/useERC20TransferableReceivableContract.d.ts +5 -5
- package/dist/hooks/useERC20TransferableReceivableContract.js +5 -8
- package/dist/hooks/useERC20TransferableReceivableContract.js.map +1 -1
- package/dist/hooks/usePoolContract.d.ts +11 -4
- package/dist/hooks/usePoolContract.js +8 -3
- package/dist/hooks/usePoolContract.js.map +1 -1
- package/dist/services/ARWeaveService.d.ts +36 -14
- package/dist/services/ARWeaveService.js +33 -19
- package/dist/services/ARWeaveService.js.map +1 -1
- package/dist/services/EAService.d.ts +25 -2
- package/dist/services/EAService.js +3 -1
- package/dist/services/EAService.js.map +1 -1
- package/dist/services/ReceivableService.d.ts +30 -11
- package/dist/services/ReceivableService.js +36 -16
- package/dist/services/ReceivableService.js.map +1 -1
- package/dist/services/SubgraphService.d.ts +18 -4
- package/dist/services/SubgraphService.js +34 -22
- package/dist/services/SubgraphService.js.map +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/utils/poolInfo.d.ts +1 -1
- package/dist/utils/poolInfo.js +1 -1
- package/dist/utils/poolInfo.js.map +1 -1
- package/package.json +3 -3
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
3
|
+
exports.SubgraphService = void 0;
|
|
4
|
+
const shared_1 = require("@huma-finance/shared");
|
|
5
5
|
/**
|
|
6
6
|
* Returns the subgraph URL for a given chain ID.
|
|
7
7
|
*
|
|
8
|
+
* @memberof SubgraphService
|
|
8
9
|
* @param {number} chainId - The ID of the chain.
|
|
9
10
|
* @returns {string} The subgraph URL for the given chain ID.
|
|
10
11
|
*/
|
|
@@ -20,10 +21,10 @@ function getSubgraphUrlForChainId(chainId) {
|
|
|
20
21
|
return '';
|
|
21
22
|
}
|
|
22
23
|
}
|
|
23
|
-
exports.getSubgraphUrlForChainId = getSubgraphUrlForChainId;
|
|
24
24
|
/**
|
|
25
25
|
* Returns the credit events for a given user.
|
|
26
26
|
*
|
|
27
|
+
* @memberof SubgraphService
|
|
27
28
|
* @param {string} userAddress - The address of the user.
|
|
28
29
|
* @param {number} chainId - The ID of the chain.
|
|
29
30
|
* @param {POOL_NAME} poolName - The name of the pool.
|
|
@@ -37,25 +38,25 @@ function getCreditEventsForUser(userAddress, chainId, poolName, poolType, event)
|
|
|
37
38
|
if (!url) {
|
|
38
39
|
return Promise.resolve([]);
|
|
39
40
|
}
|
|
40
|
-
const poolAddress = (_c = (_b = (_a =
|
|
41
|
-
const query = `
|
|
42
|
-
query {
|
|
43
|
-
creditEvents(
|
|
44
|
-
where: {
|
|
45
|
-
owner: "${userAddress}",
|
|
46
|
-
pool: "${poolAddress}",
|
|
47
|
-
event_in: "[${event.join('", "')}]"
|
|
48
|
-
}
|
|
49
|
-
orderBy: timestamp
|
|
50
|
-
orderDirection: desc
|
|
51
|
-
) {
|
|
52
|
-
amount
|
|
53
|
-
timestamp
|
|
54
|
-
owner
|
|
55
|
-
pool
|
|
56
|
-
event
|
|
57
|
-
}
|
|
58
|
-
}
|
|
41
|
+
const poolAddress = (_c = (_b = (_a = shared_1.PoolContractMap[chainId]) === null || _a === void 0 ? void 0 : _a[poolType]) === null || _b === void 0 ? void 0 : _b[poolName]) === null || _c === void 0 ? void 0 : _c.pool;
|
|
42
|
+
const query = `
|
|
43
|
+
query {
|
|
44
|
+
creditEvents(
|
|
45
|
+
where: {
|
|
46
|
+
owner: "${userAddress}",
|
|
47
|
+
pool: "${poolAddress}",
|
|
48
|
+
event_in: "[${event.join('", "')}]"
|
|
49
|
+
}
|
|
50
|
+
orderBy: timestamp
|
|
51
|
+
orderDirection: desc
|
|
52
|
+
) {
|
|
53
|
+
amount
|
|
54
|
+
timestamp
|
|
55
|
+
owner
|
|
56
|
+
pool
|
|
57
|
+
event
|
|
58
|
+
}
|
|
59
|
+
}
|
|
59
60
|
`;
|
|
60
61
|
return fetch(url, {
|
|
61
62
|
method: 'POST',
|
|
@@ -73,10 +74,10 @@ function getCreditEventsForUser(userAddress, chainId, poolName, poolType, event)
|
|
|
73
74
|
return res.data.creditEvents;
|
|
74
75
|
});
|
|
75
76
|
}
|
|
76
|
-
exports.getCreditEventsForUser = getCreditEventsForUser;
|
|
77
77
|
/**
|
|
78
78
|
* Returns the last factorized amount for a given user and pool.
|
|
79
79
|
*
|
|
80
|
+
* @memberof SubgraphService
|
|
80
81
|
* @param {string} userAddress - The address of the user.
|
|
81
82
|
* @param {number} chainId - The ID of the chain.
|
|
82
83
|
* @param {POOL_NAME} poolName - The name of the pool.
|
|
@@ -85,8 +86,16 @@ exports.getCreditEventsForUser = getCreditEventsForUser;
|
|
|
85
86
|
*/
|
|
86
87
|
function getLastFactorizedAmountFromPool(userAddress, chainId, poolName, poolType) {
|
|
87
88
|
return getCreditEventsForUser(userAddress, chainId, poolName, poolType, [
|
|
88
|
-
|
|
89
|
+
shared_1.CreditEvent.DrawdownMadeWithReceivable.toString(),
|
|
89
90
|
]).then((events) => Number(events[0].amount));
|
|
90
91
|
}
|
|
91
|
-
|
|
92
|
+
/**
|
|
93
|
+
* An object that contains functions to interact with Huma's Subgraph storage.
|
|
94
|
+
* @namespace SubgraphService
|
|
95
|
+
*/
|
|
96
|
+
exports.SubgraphService = {
|
|
97
|
+
getSubgraphUrlForChainId,
|
|
98
|
+
getCreditEventsForUser,
|
|
99
|
+
getLastFactorizedAmountFromPool,
|
|
100
|
+
};
|
|
92
101
|
//# sourceMappingURL=SubgraphService.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SubgraphService.js","sourceRoot":"","sources":["../../../src/services/SubgraphService.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"SubgraphService.js","sourceRoot":"","sources":["../../../src/services/SubgraphService.ts"],"names":[],"mappings":";;;AAAA,iDAK6B;AAE7B;;;;;;GAMG;AACH,SAAS,wBAAwB,CAAC,OAAe;IAC/C,QAAQ,OAAO,EAAE;QACf,KAAK,CAAC;YACJ,OAAO,4DAA4D,CAAA;QACrE,KAAK,GAAG;YACN,OAAO,6DAA6D,CAAA;QACtE,KAAK,KAAK;YACR,OAAO,4DAA4D,CAAA;QACrE;YACE,OAAO,EAAE,CAAA;KACZ;AACH,CAAC;AAcD;;;;;;;;;;GAUG;AACH,SAAS,sBAAsB,CAC7B,WAAmB,EACnB,OAAe,EACf,QAAmB,EACnB,QAAmB,EACnB,KAAe;;IAEf,MAAM,GAAG,GAAG,wBAAwB,CAAC,OAAO,CAAC,CAAA;IAC7C,IAAI,CAAC,GAAG,EAAE;QACR,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAA;KAC3B;IAED,MAAM,WAAW,GAAG,MAAA,MAAA,MAAA,wBAAe,CAAC,OAAO,CAAC,0CAAG,QAAQ,CAAC,0CAAG,QAAQ,CAAC,0CAAE,IAAI,CAAA;IAE1E,MAAM,KAAK,GAAG;;;;oBAII,WAAW;mBACZ,WAAW;wBACN,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC;;;;;;;;;;;;GAYvC,CAAA;IAED,OAAO,KAAK,CAAC,GAAG,EAAE;QAChB,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,CAAC;KAChC,CAAC;SACC,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;SACzB,IAAI,CAAC,CAAC,GAAG,EAAE,EAAE;QACZ,IAAI,GAAG,CAAC,MAAM,EAAE;YACd,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,MAAM,CAAC,CAAA;YACzB,OAAO,EAAE,CAAA;SACV;QACD,OAAO,GAAG,CAAC,IAAI,CAAC,YAAY,CAAA;IAC9B,CAAC,CAAC,CAAA;AACN,CAAC;AAED;;;;;;;;;GASG;AACH,SAAS,+BAA+B,CACtC,WAAmB,EACnB,OAAe,EACf,QAAmB,EACnB,QAAmB;IAEnB,OAAO,sBAAsB,CAAC,WAAW,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE;QACtE,oBAAW,CAAC,0BAA0B,CAAC,QAAQ,EAAE;KAClD,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAA;AAC/C,CAAC;AAED;;;GAGG;AACU,QAAA,eAAe,GAAG;IAC7B,wBAAwB;IACxB,sBAAsB;IACtB,+BAA+B;CAChC,CAAA"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { POOL_NAME, POOL_TYPE, PoolInfoType } from '@
|
|
1
|
+
import { POOL_NAME, POOL_TYPE, PoolInfoType } from '@huma-finance/shared';
|
|
2
2
|
/**
|
|
3
3
|
* Returns the pool info based on the provided pool name and type, using the same chain ID as the provider/signer given
|
|
4
4
|
* @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The Web3 provider or signer.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getPoolInfo = void 0;
|
|
4
|
-
const
|
|
4
|
+
const shared_1 = require("@huma-finance/shared");
|
|
5
5
|
/**
|
|
6
6
|
* Returns the pool info based on the provided pool name and type, using the same chain ID as the provider/signer given
|
|
7
7
|
* @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The Web3 provider or signer.
|
|
@@ -9,6 +9,6 @@ const huma_shared_1 = require("@00labs/huma-shared");
|
|
|
9
9
|
* @param {POOL_TYPE} poolType - The type of the pool.
|
|
10
10
|
* @returns {PoolInfoType|undefined} - The pool info or undefined if the chain ID is not supported.
|
|
11
11
|
*/
|
|
12
|
-
const getPoolInfo = (chainId, poolName, poolType) => { var _a, _b; return (_b = (_a =
|
|
12
|
+
const getPoolInfo = (chainId, poolName, poolType) => { var _a, _b; return (_b = (_a = shared_1.PoolContractMap[chainId]) === null || _a === void 0 ? void 0 : _a[poolType]) === null || _b === void 0 ? void 0 : _b[poolName]; };
|
|
13
13
|
exports.getPoolInfo = getPoolInfo;
|
|
14
14
|
//# sourceMappingURL=poolInfo.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"poolInfo.js","sourceRoot":"","sources":["../../../src/utils/poolInfo.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"poolInfo.js","sourceRoot":"","sources":["../../../src/utils/poolInfo.ts"],"names":[],"mappings":";;;AAAA,iDAK6B;AAE7B;;;;;;GAMG;AACI,MAAM,WAAW,GAAG,CACzB,OAAe,EACf,QAAmB,EACnB,QAAmB,EACO,EAAE,eAAC,OAAA,MAAA,MAAA,wBAAe,CAAC,OAAO,CAAC,0CAAG,QAAQ,CAAC,0CAAG,QAAQ,CAAC,CAAA,EAAA,CAAA;AAJlE,QAAA,WAAW,eAIuD"}
|
|
@@ -3,7 +3,8 @@ import { Contract, ethers } from 'ethers';
|
|
|
3
3
|
* Returns an ethers contract instance for the BaseCreditPoolReceivable contract
|
|
4
4
|
* associated with the given pool name on the current chain.
|
|
5
5
|
*
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
7
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
7
8
|
* @returns {Contract | null} A contract instance for the BaseCreditPoolReceivable contract or null if it could not be found.
|
|
8
9
|
*/
|
|
9
10
|
export declare function getBaseCreditPoolReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { BASE_CREDIT_POOL_RECEIVABLE_ABI, SupplementaryContracts, SupplementaryContractsMap, } from '@
|
|
1
|
+
import { BASE_CREDIT_POOL_RECEIVABLE_ABI, SupplementaryContracts, SupplementaryContractsMap, } from '@huma-finance/shared';
|
|
2
2
|
import { getContract } from '../utils';
|
|
3
3
|
/**
|
|
4
4
|
* Returns an ethers contract instance for the BaseCreditPoolReceivable contract
|
|
5
5
|
* associated with the given pool name on the current chain.
|
|
6
6
|
*
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
8
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
8
9
|
* @returns {Contract | null} A contract instance for the BaseCreditPoolReceivable contract or null if it could not be found.
|
|
9
10
|
*/
|
|
10
11
|
export function getBaseCreditPoolReceivableContract(signerOrProvider, chainId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BaseCreditPoolReceivableContractHelper.js","sourceRoot":"","sources":["../../src/helpers/BaseCreditPoolReceivableContractHelper.ts"],"names":[],"mappings":"AACA,OAAO,EACL,+BAA+B,EAC/B,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,
|
|
1
|
+
{"version":3,"file":"BaseCreditPoolReceivableContractHelper.js","sourceRoot":"","sources":["../../src/helpers/BaseCreditPoolReceivableContractHelper.ts"],"names":[],"mappings":"AACA,OAAO,EACL,+BAA+B,EAC/B,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEtC;;;;;;;GAOG;AACH,MAAM,UAAU,mCAAmC,CACjD,gBAA2D,EAC3D,OAAe;;IAEf,MAAM,wBAAwB,GAC5B,MAAA,yBAAyB,CAAC,OAAO,CAAC,0CAChC,sBAAsB,CAAC,wBAAwB,CAChD,CAAA;IAEH,IAAI,CAAC,wBAAwB;QAAE,OAAO,IAAI,CAAA;IAE1C,OAAO,WAAW,CAChB,wBAAwB,EACxB,+BAA+B,EAC/B,gBAAgB,CACjB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Contract, ethers } from 'ethers';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an ethers contract instance for the BaseCreditPoolReceivable contract
|
|
4
|
+
* associated with the given pool name on the current chain.
|
|
5
|
+
*
|
|
6
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
7
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
8
|
+
* @returns {Contract | null} A contract instance for the BaseCreditPoolReceivable contract or null if it could not be found.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getERC20TransferableReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { ERC20_TRANSFERABLE_RECEIVABLE_ABI, SupplementaryContracts, SupplementaryContractsMap, } from '@huma-finance/shared';
|
|
2
|
+
import { getContract } from '../utils';
|
|
3
|
+
/**
|
|
4
|
+
* Returns an ethers contract instance for the BaseCreditPoolReceivable contract
|
|
5
|
+
* associated with the given pool name on the current chain.
|
|
6
|
+
*
|
|
7
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
8
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
9
|
+
* @returns {Contract | null} A contract instance for the BaseCreditPoolReceivable contract or null if it could not be found.
|
|
10
|
+
*/
|
|
11
|
+
export function getERC20TransferableReceivableContract(signerOrProvider, chainId) {
|
|
12
|
+
var _a;
|
|
13
|
+
const erc20TransferableReceiable = (_a = SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[SupplementaryContracts.ERC20TransferableReceivable];
|
|
14
|
+
if (!erc20TransferableReceiable)
|
|
15
|
+
return null;
|
|
16
|
+
return getContract(erc20TransferableReceiable, ERC20_TRANSFERABLE_RECEIVABLE_ABI, signerOrProvider);
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=ERC20TransferableReceivableContractHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ERC20TransferableReceivableContractHelper.js","sourceRoot":"","sources":["../../src/helpers/ERC20TransferableReceivableContractHelper.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iCAAiC,EACjC,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEtC;;;;;;;GAOG;AACH,MAAM,UAAU,sCAAsC,CACpD,gBAA2D,EAC3D,OAAe;;IAEf,MAAM,0BAA0B,GAC9B,MAAA,yBAAyB,CAAC,OAAO,CAAC,0CAChC,sBAAsB,CAAC,2BAA2B,CACnD,CAAA;IAEH,IAAI,CAAC,0BAA0B;QAAE,OAAO,IAAI,CAAA;IAE5C,OAAO,WAAW,CAChB,0BAA0B,EAC1B,iCAAiC,EACjC,gBAAgB,CACjB,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Contract, ethers } from 'ethers';
|
|
2
|
+
import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
|
|
3
|
+
/**
|
|
4
|
+
* Returns an ethers contract instance for a Huma pool contract
|
|
5
|
+
*
|
|
6
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
7
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
8
|
+
* @param {POOL_NAME} poolName The name of the pool contract to get.
|
|
9
|
+
* @param {POOL_TYPE} poolType The type of the pool contract to get.
|
|
10
|
+
* @returns {Contract | null} A contract instance for the Pool contract or null if it could not be found.
|
|
11
|
+
*/
|
|
12
|
+
export declare function getPoolContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): Contract | null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { getContract, getPoolInfo } from '../utils';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an ethers contract instance for a Huma pool contract
|
|
4
|
+
*
|
|
5
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
6
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
7
|
+
* @param {POOL_NAME} poolName The name of the pool contract to get.
|
|
8
|
+
* @param {POOL_TYPE} poolType The type of the pool contract to get.
|
|
9
|
+
* @returns {Contract | null} A contract instance for the Pool contract or null if it could not be found.
|
|
10
|
+
*/
|
|
11
|
+
export function getPoolContract(signerOrProvider, chainId, poolName, poolType) {
|
|
12
|
+
const poolInfo = getPoolInfo(chainId, poolName, poolType);
|
|
13
|
+
if (!poolInfo)
|
|
14
|
+
return null;
|
|
15
|
+
return getContract(poolInfo.pool, poolInfo.poolAbi, signerOrProvider);
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=PoolContractHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAA;AAEnD;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,gBAA2D,EAC3D,OAAe,EACf,QAAmB,EACnB,QAAmB;IAEnB,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IAEzD,IAAI,CAAC,QAAQ;QAAE,OAAO,IAAI,CAAA;IAE1B,OAAO,WAAW,CAAC,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC,OAAO,EAAE,gBAAgB,CAAC,CAAA;AACvE,CAAC"}
|
package/dist/helpers/index.d.ts
CHANGED
package/dist/helpers/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,0CAA0C,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/helpers/index.ts"],"names":[],"mappings":"AAAA,cAAc,0CAA0C,CAAA;AACxD,cAAc,6CAA6C,CAAA;AAC3D,cAAc,sBAAsB,CAAA"}
|
package/dist/hooks/index.d.ts
CHANGED
package/dist/hooks/index.js
CHANGED
|
@@ -2,5 +2,4 @@ export * from './useContract';
|
|
|
2
2
|
export * from './useBaseCreditPoolReceivableContract';
|
|
3
3
|
export * from './useERC20TransferableReceivableContract';
|
|
4
4
|
export * from './usePoolContract';
|
|
5
|
-
export * from './useReceivableFactoringPoolContract';
|
|
6
5
|
//# sourceMappingURL=index.js.map
|
package/dist/hooks/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,uCAAuC,CAAA;AACrD,cAAc,0CAA0C,CAAA;AACxD,cAAc,mBAAmB,CAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hooks/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAA;AAC7B,cAAc,uCAAuC,CAAA;AACrD,cAAc,0CAA0C,CAAA;AACxD,cAAc,mBAAmB,CAAA"}
|
|
@@ -3,7 +3,8 @@ import { Contract, ethers } from 'ethers';
|
|
|
3
3
|
* A react hook that returns an ethers contract instance for the BaseCreditPoolReceivable contract
|
|
4
4
|
* associated with the given pool name on the current chain.
|
|
5
5
|
*
|
|
6
|
-
* @param {
|
|
6
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
7
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
7
8
|
* @returns {Contract | null} A contract instance for the BaseCreditPoolReceivable contract or null if it could not be found.
|
|
8
9
|
*/
|
|
9
10
|
export declare function useBaseCreditPoolReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import { BASE_CREDIT_POOL_RECEIVABLE_ABI, SupplementaryContracts, SupplementaryContractsMap, } from '@
|
|
1
|
+
import { BASE_CREDIT_POOL_RECEIVABLE_ABI, SupplementaryContracts, SupplementaryContractsMap, } from '@huma-finance/shared';
|
|
2
2
|
import { useContract } from './useContract';
|
|
3
3
|
/**
|
|
4
4
|
* A react hook that returns an ethers contract instance for the BaseCreditPoolReceivable contract
|
|
5
5
|
* associated with the given pool name on the current chain.
|
|
6
6
|
*
|
|
7
|
-
* @param {
|
|
7
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
8
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
8
9
|
* @returns {Contract | null} A contract instance for the BaseCreditPoolReceivable contract or null if it could not be found.
|
|
9
10
|
*/
|
|
10
11
|
export function useBaseCreditPoolReceivableContract(signerOrProvider, chainId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useBaseCreditPoolReceivableContract.js","sourceRoot":"","sources":["../../src/hooks/useBaseCreditPoolReceivableContract.ts"],"names":[],"mappings":"AACA,OAAO,EACL,+BAA+B,EAE/B,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,
|
|
1
|
+
{"version":3,"file":"useBaseCreditPoolReceivableContract.js","sourceRoot":"","sources":["../../src/hooks/useBaseCreditPoolReceivableContract.ts"],"names":[],"mappings":"AACA,OAAO,EACL,+BAA+B,EAE/B,sBAAsB,EACtB,yBAAyB,GAC1B,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;;;;GAOG;AACH,MAAM,UAAU,mCAAmC,CACjD,gBAA2D,EAC3D,OAAe;;IAEf,MAAM,wBAAwB,GAC5B,MAAA,yBAAyB,CAAC,OAAO,CAAC,0CAChC,sBAAsB,CAAC,wBAAwB,CAChD,CAAA;IAEH,OAAO,WAAW,CAChB,wBAAwB,EACxB,+BAA+B,EAC/B,gBAAgB,CACjB,CAAA;AACH,CAAC"}
|
|
@@ -2,10 +2,12 @@ import { Contract } from '@ethersproject/contracts';
|
|
|
2
2
|
import { ethers } from 'ethers';
|
|
3
3
|
/**
|
|
4
4
|
* Custom hook for creating an ethers instance of a smart contract.
|
|
5
|
-
*
|
|
6
|
-
* @
|
|
7
|
-
* @param
|
|
5
|
+
*
|
|
6
|
+
* @template T - The type of the contract.
|
|
7
|
+
* @param {string | null | undefined} address - The address of the smart contract instance.
|
|
8
|
+
* @param {any} ABI - The ABI of the smart contract.
|
|
9
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to sign transactions or retrieve blockchain data.
|
|
8
10
|
* Note that this signerOrProvider must be connected to the same network as the smart contract in question.
|
|
9
|
-
* @returns An instance of the smart contract, or null if an error occurs.
|
|
11
|
+
* @returns {T | null} An instance of the smart contract, or null if an error occurs.
|
|
10
12
|
*/
|
|
11
13
|
export declare function useContract<T extends Contract = Contract>(address: string | null | undefined, ABI: any, signerOrProvider: ethers.providers.Provider | ethers.Signer): T | null;
|
|
@@ -2,11 +2,13 @@ import { useMemo } from 'react';
|
|
|
2
2
|
import { getContract } from '../utils/web3';
|
|
3
3
|
/**
|
|
4
4
|
* Custom hook for creating an ethers instance of a smart contract.
|
|
5
|
-
*
|
|
6
|
-
* @
|
|
7
|
-
* @param
|
|
5
|
+
*
|
|
6
|
+
* @template T - The type of the contract.
|
|
7
|
+
* @param {string | null | undefined} address - The address of the smart contract instance.
|
|
8
|
+
* @param {any} ABI - The ABI of the smart contract.
|
|
9
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to sign transactions or retrieve blockchain data.
|
|
8
10
|
* Note that this signerOrProvider must be connected to the same network as the smart contract in question.
|
|
9
|
-
* @returns An instance of the smart contract, or null if an error occurs.
|
|
11
|
+
* @returns {T | null} An instance of the smart contract, or null if an error occurs.
|
|
10
12
|
*/
|
|
11
13
|
export function useContract(address,
|
|
12
14
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useContract.js","sourceRoot":"","sources":["../../src/hooks/useContract.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAG/B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C
|
|
1
|
+
{"version":3,"file":"useContract.js","sourceRoot":"","sources":["../../src/hooks/useContract.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAA;AAG/B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;;;;;;GASG;AACH,MAAM,UAAU,WAAW,CACzB,OAAkC;AAClC,8DAA8D;AAC9D,GAAQ,EACR,gBAA2D;IAE3D,OAAO,OAAO,CAAC,GAAG,EAAE;QAClB,IAAI,CAAC,OAAO,IAAI,CAAC,GAAG,IAAI,CAAC,gBAAgB;YAAE,OAAO,IAAI,CAAA;QACtD,IAAI;YACF,OAAO,WAAW,CAAC,OAAO,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAA;SACnD;QAAC,OAAO,KAAK,EAAE;YACd,OAAO,IAAI,CAAA;SACZ;IACH,CAAC,EAAE,CAAC,OAAO,EAAE,GAAG,EAAE,gBAAgB,CAAC,CAAM,CAAA;AAC3C,CAAC"}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { POOL_NAME } from '@00labs/huma-shared';
|
|
1
|
+
import { Contract, ethers } from 'ethers';
|
|
2
|
+
import { POOL_NAME } from '@huma-finance/shared';
|
|
4
3
|
/**
|
|
5
4
|
* A react hook that returns an ethers contract instance for the ERC20TransferableReceivable contract
|
|
6
5
|
* associated with the given pool name on the current chain.
|
|
7
6
|
*
|
|
8
|
-
* @param {
|
|
7
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
8
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
9
9
|
* @param {POOL_NAME} poolName The name of the pool to get the contract for.
|
|
10
10
|
* @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
|
|
11
11
|
*/
|
|
12
|
-
export declare function useERC20TransferableReceivableContract(signerOrProvider:
|
|
12
|
+
export declare function useERC20TransferableReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME): Contract | null;
|
|
@@ -1,20 +1,17 @@
|
|
|
1
|
-
import { ERC20_TRANSFERABLE_RECEIVABLE_ABI, POOL_TYPE, PoolContractMap, } from '@
|
|
1
|
+
import { ERC20_TRANSFERABLE_RECEIVABLE_ABI, POOL_TYPE, PoolContractMap, } from '@huma-finance/shared';
|
|
2
2
|
import { useContract } from './useContract';
|
|
3
|
-
import { getChainIdFromJsonSignerOrProvider } from '../utils/chain';
|
|
4
3
|
/**
|
|
5
4
|
* A react hook that returns an ethers contract instance for the ERC20TransferableReceivable contract
|
|
6
5
|
* associated with the given pool name on the current chain.
|
|
7
6
|
*
|
|
8
|
-
* @param {
|
|
7
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
8
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
9
9
|
* @param {POOL_NAME} poolName The name of the pool to get the contract for.
|
|
10
10
|
* @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
|
|
11
11
|
*/
|
|
12
|
-
export function useERC20TransferableReceivableContract(signerOrProvider, poolName) {
|
|
12
|
+
export function useERC20TransferableReceivableContract(signerOrProvider, chainId, poolName) {
|
|
13
13
|
var _a, _b, _c;
|
|
14
|
-
const
|
|
15
|
-
const TransferableReceivableAddress = chainId
|
|
16
|
-
? (_c = (_b = (_a = PoolContractMap[chainId]) === null || _a === void 0 ? void 0 : _a[POOL_TYPE.Invoice]) === null || _b === void 0 ? void 0 : _b[poolName]) === null || _c === void 0 ? void 0 : _c.assetAddress
|
|
17
|
-
: null;
|
|
14
|
+
const TransferableReceivableAddress = (_c = (_b = (_a = PoolContractMap[chainId]) === null || _a === void 0 ? void 0 : _a[POOL_TYPE.Invoice]) === null || _b === void 0 ? void 0 : _b[poolName]) === null || _c === void 0 ? void 0 : _c.assetAddress;
|
|
18
15
|
return useContract(TransferableReceivableAddress, ERC20_TRANSFERABLE_RECEIVABLE_ABI, signerOrProvider);
|
|
19
16
|
}
|
|
20
17
|
//# sourceMappingURL=useERC20TransferableReceivableContract.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useERC20TransferableReceivableContract.js","sourceRoot":"","sources":["../../src/hooks/useERC20TransferableReceivableContract.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useERC20TransferableReceivableContract.js","sourceRoot":"","sources":["../../src/hooks/useERC20TransferableReceivableContract.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iCAAiC,EAGjC,SAAS,EACT,eAAe,GAChB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;;;;;GAQG;AACH,MAAM,UAAU,sCAAsC,CACpD,gBAA2D,EAC3D,OAAe,EACf,QAAmB;;IAEnB,MAAM,6BAA6B,GACjC,MAAA,MAAA,MAAA,eAAe,CAAC,OAAO,CAAC,0CAAG,SAAS,CAAC,OAAO,CAAC,0CAAG,QAAQ,CAAC,0CAAE,YAAY,CAAA;IAEzE,OAAO,WAAW,CAChB,6BAA6B,EAC7B,iCAAiC,EACjC,gBAAgB,CACjB,CAAA;AACH,CAAC"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
1
|
import { BigNumber } from '@ethersproject/bignumber';
|
|
2
2
|
import { Contract, ethers } from 'ethers';
|
|
3
|
-
import { POOL_NAME, POOL_TYPE } from '@
|
|
3
|
+
import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
|
|
4
4
|
/**
|
|
5
|
-
* A react hook that returns a contract instance of a specific pool using an ethers
|
|
5
|
+
* A react hook that returns a contract instance of a specific pool using an ethers provider or signer
|
|
6
6
|
*
|
|
7
|
+
* @namespace usePoolContract
|
|
7
8
|
* @template T - The type of the contract.
|
|
8
|
-
* @param {
|
|
9
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - An ethers signer or provider instance.
|
|
10
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
9
11
|
* @param {POOL_NAME} poolName - The name of the pool.
|
|
10
12
|
* @param {POOL_TYPE} poolType - The type of the pool.
|
|
11
13
|
* @returns {T} A contract instance of the specific pool.
|
|
@@ -13,6 +15,8 @@ import { POOL_NAME, POOL_TYPE } from '@00labs/huma-shared';
|
|
|
13
15
|
export declare function usePoolContract<T extends Contract>(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): T | null;
|
|
14
16
|
/**
|
|
15
17
|
* CreditRecordDetails type object representing the details of a credit line.
|
|
18
|
+
*
|
|
19
|
+
* @memberof usePoolContract
|
|
16
20
|
* @typedef {Object} CreditRecordDetails
|
|
17
21
|
* @property {number} aprInBps - The APR (annual percentage rate) in basis points.
|
|
18
22
|
* @property {BigNumber} correction - adjustment of interest over or under-counted because of drawdown
|
|
@@ -45,9 +49,12 @@ export type CreditRecordDetails = {
|
|
|
45
49
|
/**
|
|
46
50
|
* A react hook that returns the credit record details for a user in a given pool, as well as a function to refresh the data.
|
|
47
51
|
*
|
|
52
|
+
* @namespace usePoolContract
|
|
48
53
|
* @param {string} userAddress - The address of the user to get the credit record details for.
|
|
49
|
-
* @param {
|
|
54
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider object to use for the contract.
|
|
55
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
50
56
|
* @param {POOL_NAME} poolName - The name of the pool to get the credit record details for.
|
|
57
|
+
* @param {POOL_TYPE} poolType - The type of the pool.
|
|
51
58
|
* @returns {Array<CreditRecordDetails | undefined, function():void>} An array containing the credit record details and a function to refresh the data.
|
|
52
59
|
*/
|
|
53
60
|
export declare function useCreditRecordDetails(userAddress: string, signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): [CreditRecordDetails | undefined, () => void];
|
|
@@ -2,10 +2,12 @@ import { useCallback, useEffect, useState } from 'react';
|
|
|
2
2
|
import { useContract } from './useContract';
|
|
3
3
|
import { getPoolInfo } from '../utils/poolInfo';
|
|
4
4
|
/**
|
|
5
|
-
* A react hook that returns a contract instance of a specific pool using an ethers
|
|
5
|
+
* A react hook that returns a contract instance of a specific pool using an ethers provider or signer
|
|
6
6
|
*
|
|
7
|
+
* @namespace usePoolContract
|
|
7
8
|
* @template T - The type of the contract.
|
|
8
|
-
* @param {
|
|
9
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - An ethers signer or provider instance.
|
|
10
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
9
11
|
* @param {POOL_NAME} poolName - The name of the pool.
|
|
10
12
|
* @param {POOL_TYPE} poolType - The type of the pool.
|
|
11
13
|
* @returns {T} A contract instance of the specific pool.
|
|
@@ -17,9 +19,12 @@ export function usePoolContract(signerOrProvider, chainId, poolName, poolType) {
|
|
|
17
19
|
/**
|
|
18
20
|
* A react hook that returns the credit record details for a user in a given pool, as well as a function to refresh the data.
|
|
19
21
|
*
|
|
22
|
+
* @namespace usePoolContract
|
|
20
23
|
* @param {string} userAddress - The address of the user to get the credit record details for.
|
|
21
|
-
* @param {
|
|
24
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider object to use for the contract.
|
|
25
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
22
26
|
* @param {POOL_NAME} poolName - The name of the pool to get the credit record details for.
|
|
27
|
+
* @param {POOL_TYPE} poolType - The type of the pool.
|
|
23
28
|
* @returns {Array<CreditRecordDetails | undefined, function():void>} An array containing the credit record details and a function to refresh the data.
|
|
24
29
|
*/
|
|
25
30
|
export function useCreditRecordDetails(userAddress, signerOrProvider, chainId, poolName, poolType) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePoolContract.js","sourceRoot":"","sources":["../../src/hooks/usePoolContract.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C
|
|
1
|
+
{"version":3,"file":"usePoolContract.js","sourceRoot":"","sources":["../../src/hooks/usePoolContract.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAGxD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAA;AAE/C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAC7B,gBAA2D,EAC3D,OAAe,EACf,QAAmB,EACnB,QAAmB;IAEnB,MAAM,QAAQ,GAAG,WAAW,CAAC,OAAO,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAA;IACzD,OAAO,WAAW,CAAI,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,IAAI,EAAE,QAAQ,aAAR,QAAQ,uBAAR,QAAQ,CAAE,OAAO,EAAE,gBAAgB,CAAC,CAAA;AAC5E,CAAC;AAoCD;;;;;;;;;;GAUG;AACH,MAAM,UAAU,sBAAsB,CACpC,WAAmB,EACnB,gBAA2D,EAC3D,OAAe,EACf,QAAmB,EACnB,QAAmB;IAEnB,MAAM,YAAY,GAAG,eAAe,CAClC,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,QAAQ,CACT,CAAA;IACD,MAAM,CAAC,mBAAmB,EAAE,sBAAsB,CAAC,GACjD,QAAQ,EAAuB,CAAA;IACjC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAA;IAEnD,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,SAAS,GAAG,KAAK,IAAI,EAAE;YAC3B,IAAI,YAAY,IAAI,WAAW,EAAE;gBAC/B,MAAM,mBAAmB,GAAG,MAAM,YAAY,CAAC,mBAAmB,CAChE,WAAW,CACZ,CAAA;gBACD,MAAM,yBAAyB,GAC7B,MAAM,YAAY,CAAC,yBAAyB,CAAC,WAAW,CAAC,CAAA;gBAC3D,sBAAsB,iCACjB,mBAAmB,GACnB,yBAAyB,EAC5B,CAAA;aACH;QACH,CAAC,CAAA;QACD,SAAS,EAAE,CAAA;IACb,CAAC,EAAE,CAAC,WAAW,EAAE,YAAY,EAAE,YAAY,CAAC,CAAC,CAAA;IAE7C,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,EAAE;QAC/B,eAAe,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,GAAG,CAAC,CAAC,CAAA;IACnC,CAAC,EAAE,EAAE,CAAC,CAAA;IAEN,OAAO,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAA;AACvC,CAAC"}
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { FundResponse, UploadResponse } from '@bundlr-network/client/build/common/types';
|
|
2
2
|
import { Web3Provider } from '@ethersproject/providers';
|
|
3
|
-
import { POOL_NAME, POOL_TYPE } from '@
|
|
3
|
+
import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
|
|
4
4
|
/**
|
|
5
5
|
* The configuration for Bundlr network instances
|
|
6
|
+
*
|
|
7
|
+
* @typedef {Object} BundlrConfig
|
|
8
|
+
* @memberof ArweaveService
|
|
9
|
+
* @property {string} nodeUrl - The Bundlr node URL to use.
|
|
10
|
+
* @property {string} currency - The currency to pay for uploads with.
|
|
11
|
+
* Please see https://docs.bundlr.network/sdk/using-other-currencies for all the supported currencies
|
|
12
|
+
* @property {string} [providerUrl] - The provider URL, required for devnets.
|
|
6
13
|
*/
|
|
7
14
|
export type BundlrConfig = {
|
|
8
15
|
nodeUrl: string;
|
|
@@ -10,53 +17,68 @@ export type BundlrConfig = {
|
|
|
10
17
|
providerUrl?: string;
|
|
11
18
|
};
|
|
12
19
|
/**
|
|
13
|
-
* Get the configuration for Bundlr network given a chain ID
|
|
20
|
+
* Get the configuration for Bundlr network given a chain ID
|
|
14
21
|
*
|
|
15
22
|
* @function
|
|
23
|
+
* @memberof ArweaveService
|
|
16
24
|
* @param {number} chainId - The chain ID.
|
|
17
25
|
* @returns {BundlrConfig} - The configuration for the Bundlr network.
|
|
18
|
-
* nodeUrl - The node URL of the Bundlr network to use.
|
|
19
|
-
* currency - The currency to pay for uploads with, if lazy funding.
|
|
20
|
-
* providerUrl - The provider URL, required for devnets.
|
|
21
26
|
*/
|
|
22
27
|
export declare function getBundlrNetworkConfig(chainId: number): BundlrConfig;
|
|
23
28
|
/**
|
|
24
|
-
* Prefund the Bundlr network with the specified amount.
|
|
29
|
+
* Prefund the Bundlr network with the specified amount. Required if not lazy funding.
|
|
25
30
|
*
|
|
26
31
|
* @async
|
|
27
32
|
* @function
|
|
33
|
+
* @memberof ArweaveService
|
|
28
34
|
* @param {BundlrConfig} config - The configuration for the Bundlr network.
|
|
29
|
-
* @param {any}
|
|
30
|
-
* @param {number} amount - The amount to fund.
|
|
35
|
+
* @param {any} signer - The wallet to send funds from. This can be either a web3 signer or a private key string.
|
|
36
|
+
* @param {number} amount - The amount to fund, denoted in whatever currency specified by the config.
|
|
31
37
|
* @returns {Promise<FundResponse>} - The fund response.
|
|
32
38
|
*/
|
|
33
|
-
|
|
39
|
+
declare function prefundBundlr(config: BundlrConfig, signer: any, amount: number): Promise<FundResponse>;
|
|
34
40
|
/**
|
|
35
41
|
* Store data on ARWeave using the Bundlr Network.
|
|
42
|
+
*
|
|
36
43
|
* @async
|
|
37
44
|
* @function
|
|
45
|
+
* @memberof ArweaveService
|
|
38
46
|
* @param {BundlrConfig} config - Configuration object for the Bundlr instance.
|
|
39
|
-
* @param {Web3Provider |
|
|
47
|
+
* @param {Web3Provider | string} signerOrPrivateKey - Wallet object used for interacting with the Bundlr instance.
|
|
40
48
|
* If calling from a browser, this should be a `Web3Provider` instance. If calling from a Node.js
|
|
41
|
-
* environment, this should be
|
|
49
|
+
* environment, this should be a private key string.
|
|
42
50
|
* @param {JSON} data - The data to store in the Bundlr instance.
|
|
43
51
|
* @param {Array<{ name: string, value: string }>} tags - Array of tag objects with `name` and `value` properties.
|
|
44
52
|
* @param {boolean} [lazyFund=true] - Optional flag to fund the Bundlr instance lazily. If set to `false`, the
|
|
45
53
|
* Bundlr node should already be funded or else uploads will fail.
|
|
46
54
|
* @returns {Promise<UploadResponse>} Promise resolving with the upload response.
|
|
47
55
|
*/
|
|
48
|
-
|
|
56
|
+
declare function storeData(config: BundlrConfig, signerOrPrivateKey: Web3Provider | string, data: JSON, tags: {
|
|
49
57
|
name: string;
|
|
50
58
|
value: string;
|
|
51
59
|
}[], lazyFund?: boolean): Promise<UploadResponse>;
|
|
52
60
|
/**
|
|
53
61
|
* Helper method to query the Arweave network for receivables metadata previously uploaded.
|
|
62
|
+
*
|
|
54
63
|
* @async
|
|
55
64
|
* @function
|
|
65
|
+
* @memberof ArweaveService
|
|
66
|
+
* @param {number} chainId - The chain ID.
|
|
56
67
|
* @param {POOL_NAME} poolName - The pool name tag to query.
|
|
57
68
|
* @param {POOL_TYPE} poolType - The pool type tag to query.
|
|
58
69
|
* @param {string} sender - The sender tag to query.
|
|
59
|
-
* @param {string}
|
|
70
|
+
* @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
|
|
60
71
|
* @returns {Promise<any>} Promise resolving with the queried data.
|
|
61
72
|
*/
|
|
62
|
-
|
|
73
|
+
declare function queryForMetadata(chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, sender: string, referenceId: string): Promise<string | null>;
|
|
74
|
+
/**
|
|
75
|
+
* An object that contains functions to interact with Huma-related data stored on ARWeave
|
|
76
|
+
* @namespace ARWeaveService
|
|
77
|
+
*/
|
|
78
|
+
export declare const ARWeaveService: {
|
|
79
|
+
queryForMetadata: typeof queryForMetadata;
|
|
80
|
+
storeData: typeof storeData;
|
|
81
|
+
prefundBundlr: typeof prefundBundlr;
|
|
82
|
+
getBundlrNetworkConfig: typeof getBundlrNetworkConfig;
|
|
83
|
+
};
|
|
84
|
+
export {};
|