@huma-finance/sdk 0.0.28 → 0.0.30
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/API.md +608 -482
- package/LICENSE +660 -660
- package/README.md +34 -34
- package/dist/cjs/graphql/generatedTypes.d.ts +40 -40
- package/dist/cjs/graphql/generatedTypes.js +8 -8
- package/dist/cjs/graphql/index.d.ts +1 -1
- package/dist/cjs/graphql/index.js +4 -4
- package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.d.ts +10 -0
- package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js +22 -0
- package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js.map +1 -0
- package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -10
- package/dist/cjs/helpers/ERC20TransferableReceivableContractHelper.js +21 -21
- package/dist/cjs/helpers/PoolContractHelper.d.ts +119 -104
- package/dist/cjs/helpers/PoolContractHelper.js +142 -104
- package/dist/cjs/helpers/PoolContractHelper.js.map +1 -1
- package/dist/cjs/helpers/RealWorldReceivableContractHelper.d.ts +10 -10
- package/dist/cjs/helpers/RealWorldReceivableContractHelper.js +21 -21
- package/dist/cjs/helpers/index.d.ts +3 -3
- package/dist/cjs/helpers/index.js +6 -6
- package/dist/cjs/hooks/index.d.ts +4 -4
- package/dist/cjs/hooks/index.js +7 -7
- package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.d.ts +10 -0
- package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js +20 -0
- package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js.map +1 -0
- package/dist/cjs/hooks/useContract.d.ts +13 -13
- package/dist/cjs/hooks/useContract.js +30 -30
- package/dist/cjs/hooks/useERC20TransferableReceivableContract.d.ts +12 -12
- package/dist/cjs/hooks/useERC20TransferableReceivableContract.js +20 -20
- package/dist/cjs/hooks/usePoolContract.d.ts +60 -60
- package/dist/cjs/hooks/usePoolContract.js +53 -53
- package/dist/cjs/hooks/useRealWorldReceivableContract.d.ts +10 -10
- package/dist/cjs/hooks/useRealWorldReceivableContract.js +19 -19
- package/dist/cjs/hooks/useReceivableFactoringPoolContract.d.ts +10 -0
- package/dist/cjs/hooks/useReceivableFactoringPoolContract.js +17 -0
- package/dist/cjs/hooks/useReceivableFactoringPoolContract.js.map +1 -0
- package/dist/cjs/index.d.ts +4 -4
- package/dist/cjs/index.js +7 -7
- package/dist/cjs/services/ARWeaveService.d.ts +95 -81
- package/dist/cjs/services/ARWeaveService.js +169 -145
- package/dist/cjs/services/ARWeaveService.js.map +1 -1
- package/dist/cjs/services/EAService.d.ts +20 -20
- package/dist/cjs/services/EAService.js +33 -33
- package/dist/cjs/services/ReceivableService.d.ts +89 -89
- package/dist/cjs/services/ReceivableService.js +193 -193
- package/dist/cjs/services/SubgraphService.d.ts +53 -53
- package/dist/cjs/services/SubgraphService.js +93 -93
- package/dist/cjs/services/index.d.ts +4 -4
- package/dist/cjs/services/index.js +7 -7
- package/dist/cjs/utils/chain.d.ts +15 -15
- package/dist/cjs/utils/chain.js +37 -37
- package/dist/cjs/utils/index.d.ts +4 -4
- package/dist/cjs/utils/index.js +7 -7
- package/dist/cjs/utils/maticGasStation.d.ts +3 -3
- package/dist/cjs/utils/maticGasStation.js +38 -38
- package/dist/cjs/utils/poolInfo.d.ts +8 -8
- package/dist/cjs/utils/poolInfo.js +12 -12
- package/dist/cjs/utils/web3.d.ts +5 -4
- package/dist/cjs/utils/web3.js +33 -28
- package/dist/cjs/utils/web3.js.map +1 -1
- package/dist/graphql/generatedTypes.d.ts +40 -40
- package/dist/graphql/generatedTypes.js +4 -4
- package/dist/graphql/index.d.ts +1 -1
- package/dist/graphql/index.js +1 -1
- package/dist/helpers/BaseCreditPoolReceivableContractHelper.d.ts +10 -0
- package/dist/helpers/BaseCreditPoolReceivableContractHelper.js +18 -0
- package/dist/helpers/BaseCreditPoolReceivableContractHelper.js.map +1 -0
- package/dist/helpers/ERC20TransferableReceivableContractHelper.d.ts +10 -10
- package/dist/helpers/ERC20TransferableReceivableContractHelper.js +17 -17
- package/dist/helpers/PoolContractHelper.d.ts +119 -104
- package/dist/helpers/PoolContractHelper.js +133 -96
- package/dist/helpers/PoolContractHelper.js.map +1 -1
- package/dist/helpers/RealWorldReceivableContractHelper.d.ts +10 -10
- package/dist/helpers/RealWorldReceivableContractHelper.js +17 -17
- package/dist/helpers/index.d.ts +3 -3
- package/dist/helpers/index.js +3 -3
- package/dist/hooks/index.d.ts +4 -4
- package/dist/hooks/index.js +4 -4
- package/dist/hooks/useBaseCreditPoolReceivableContract.d.ts +10 -0
- package/dist/hooks/useBaseCreditPoolReceivableContract.js +16 -0
- package/dist/hooks/useBaseCreditPoolReceivableContract.js.map +1 -0
- package/dist/hooks/useContract.d.ts +13 -13
- package/dist/hooks/useContract.js +26 -26
- package/dist/hooks/useERC20TransferableReceivableContract.d.ts +12 -12
- package/dist/hooks/useERC20TransferableReceivableContract.js +16 -16
- package/dist/hooks/usePool.d.ts +0 -0
- package/dist/hooks/usePool.js +2 -0
- package/dist/hooks/usePool.js.map +1 -0
- package/dist/hooks/usePoolContract.d.ts +60 -60
- package/dist/hooks/usePoolContract.js +48 -48
- package/dist/hooks/useRealWorldReceivableContract.d.ts +10 -10
- package/dist/hooks/useRealWorldReceivableContract.js +15 -15
- package/dist/hooks/useReceivableFactoringPoolContract.d.ts +10 -0
- package/dist/hooks/useReceivableFactoringPoolContract.js +13 -0
- package/dist/hooks/useReceivableFactoringPoolContract.js.map +1 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +4 -4
- package/dist/services/ARWeaveService.d.ts +95 -81
- package/dist/services/ARWeaveService.js +164 -140
- package/dist/services/ARWeaveService.js.map +1 -1
- package/dist/services/EAService.d.ts +20 -20
- package/dist/services/EAService.js +30 -30
- package/dist/services/ReceivableService.d.ts +89 -89
- package/dist/services/ReceivableService.js +189 -189
- package/dist/services/SubgraphService.d.ts +53 -53
- package/dist/services/SubgraphService.js +90 -90
- package/dist/services/index.d.ts +4 -4
- package/dist/services/index.js +4 -4
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/utils/chain.d.ts +15 -15
- package/dist/utils/chain.js +31 -31
- package/dist/utils/index.d.ts +4 -4
- package/dist/utils/index.js +4 -4
- package/dist/utils/maticGasStation.d.ts +3 -3
- package/dist/utils/maticGasStation.js +33 -33
- package/dist/utils/poolInfo.d.ts +8 -8
- package/dist/utils/poolInfo.js +8 -8
- package/dist/utils/web3.d.ts +5 -4
- package/dist/utils/web3.js +27 -23
- package/dist/utils/web3.js.map +1 -1
- package/getting-started.md +190 -190
- package/package.json +6 -4
|
@@ -1,105 +1,143 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.makePaymentToPool = exports.drawdownFromPool = exports.getTotalDue = exports.getCreditRecord = exports.getPoolContract = void 0;
|
|
4
|
-
const utils_1 = require("../utils");
|
|
5
|
-
/**
|
|
6
|
-
* Returns an ethers contract instance for a Huma pool contract
|
|
7
|
-
*
|
|
8
|
-
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
9
|
-
* @param {number} chainId The chain id where the contract instance exists
|
|
10
|
-
* @param {POOL_NAME} poolName The name of the pool contract to get.
|
|
11
|
-
* @param {POOL_TYPE} poolType The type of the pool contract to get.
|
|
12
|
-
* @returns {Contract | null} A contract instance for the Pool contract or null if it could not be found.
|
|
13
|
-
*/
|
|
14
|
-
function getPoolContract(signerOrProvider, chainId, poolName, poolType) {
|
|
15
|
-
const poolInfo = (0, utils_1.getPoolInfo)(chainId, poolName, poolType);
|
|
16
|
-
if (!poolInfo)
|
|
17
|
-
return null;
|
|
18
|
-
return (0, utils_1.getContract)(poolInfo.pool, poolInfo.poolAbi, signerOrProvider);
|
|
19
|
-
}
|
|
20
|
-
exports.getPoolContract = getPoolContract;
|
|
21
|
-
/**
|
|
22
|
-
* Gets the credit record of a wallet in a Huma pool. Denominated in the ERC20 tokens of the pool.
|
|
23
|
-
*
|
|
24
|
-
* @namespace getCreditRecord
|
|
25
|
-
* @async
|
|
26
|
-
* @function
|
|
27
|
-
* @param {string} address - The address to lookup.
|
|
28
|
-
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to read data.
|
|
29
|
-
* @param {number} chainId - The chain ID of the pool. Used to lookup the pool address.
|
|
30
|
-
* @param {POOL_NAME} poolName - The name of the credit pool. Used to lookup the pool address.
|
|
31
|
-
* @param {POOL_TYPE} poolType - The type of the credit pool. Used to lookup the pool address.
|
|
32
|
-
* @returns {Promise<CreditRecord>} - A Promise of the transaction response.
|
|
33
|
-
*/
|
|
34
|
-
async function getCreditRecord(address, signerOrProvider, chainId, poolName, poolType) {
|
|
35
|
-
const poolContract = getPoolContract(signerOrProvider, chainId, poolName, poolType);
|
|
36
|
-
if (!poolContract) {
|
|
37
|
-
throw new Error('Could not find pool contract');
|
|
38
|
-
}
|
|
39
|
-
return poolContract.creditRecordMapping(address);
|
|
40
|
-
}
|
|
41
|
-
exports.getCreditRecord = getCreditRecord;
|
|
42
|
-
/**
|
|
43
|
-
* Gets the total due for a Huma pool of the given wallet. Denominated in the ERC20 tokens of the pool.
|
|
44
|
-
*
|
|
45
|
-
* @async
|
|
46
|
-
* @function
|
|
47
|
-
* @param {string} address - The address to lookup.
|
|
48
|
-
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to read data.
|
|
49
|
-
* @param {number} chainId - The chain ID of the pool. Used to lookup the pool address.
|
|
50
|
-
* @param {POOL_NAME} poolName - The name of the credit pool. Used to lookup the pool address.
|
|
51
|
-
* @param {POOL_TYPE} poolType - The type of the credit pool. Used to lookup the pool address.
|
|
52
|
-
* @returns {Promise<BigNumber>} - A Promise of the transaction response.
|
|
53
|
-
*/
|
|
54
|
-
async function getTotalDue(address, signerOrProvider, chainId, poolName, poolType) {
|
|
55
|
-
const creditRecord = await getCreditRecord(address, signerOrProvider, chainId, poolName, poolType);
|
|
56
|
-
return creditRecord.totalDue;
|
|
57
|
-
}
|
|
58
|
-
exports.getTotalDue = getTotalDue;
|
|
59
|
-
/**
|
|
60
|
-
* Calls drawdown on a Huma pool contract
|
|
61
|
-
*
|
|
62
|
-
* @async
|
|
63
|
-
* @function
|
|
64
|
-
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
65
|
-
* @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
|
|
66
|
-
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
67
|
-
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
68
|
-
* @param {BigNumberish} drawdownAmount - The amount of tokens to withdraw, denominated in the ERC20 tokens of the pool.
|
|
69
|
-
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
70
|
-
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
71
|
-
*/
|
|
72
|
-
async function drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, gasOpts = {}) {
|
|
73
|
-
const poolContract = getPoolContract(signer, chainId, poolName, poolType);
|
|
74
|
-
if (!poolContract) {
|
|
75
|
-
throw new Error('Could not find pool contract');
|
|
76
|
-
}
|
|
77
|
-
gasOpts = await (0, utils_1.getDefaultGasOptions)(gasOpts, chainId);
|
|
78
|
-
// TODO: Generate typechain for pool contract
|
|
79
|
-
return poolContract.drawdown(drawdownAmount, gasOpts);
|
|
80
|
-
}
|
|
81
|
-
exports.drawdownFromPool = drawdownFromPool;
|
|
82
|
-
/**
|
|
83
|
-
* Calls
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* @
|
|
87
|
-
* @
|
|
88
|
-
* @param {
|
|
89
|
-
* @param {
|
|
90
|
-
* @param {
|
|
91
|
-
* @param {
|
|
92
|
-
* @param {
|
|
93
|
-
* @
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.approvePoolAllowance = exports.makePaymentToPool = exports.drawdownFromPool = exports.getTotalDue = exports.getCreditRecord = exports.getPoolContract = void 0;
|
|
4
|
+
const utils_1 = require("../utils");
|
|
5
|
+
/**
|
|
6
|
+
* Returns an ethers contract instance for a Huma pool contract
|
|
7
|
+
*
|
|
8
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
9
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
10
|
+
* @param {POOL_NAME} poolName The name of the pool contract to get.
|
|
11
|
+
* @param {POOL_TYPE} poolType The type of the pool contract to get.
|
|
12
|
+
* @returns {Contract | null} A contract instance for the Pool contract or null if it could not be found.
|
|
13
|
+
*/
|
|
14
|
+
function getPoolContract(signerOrProvider, chainId, poolName, poolType) {
|
|
15
|
+
const poolInfo = (0, utils_1.getPoolInfo)(chainId, poolName, poolType);
|
|
16
|
+
if (!poolInfo)
|
|
17
|
+
return null;
|
|
18
|
+
return (0, utils_1.getContract)(poolInfo.pool, poolInfo.poolAbi, signerOrProvider);
|
|
19
|
+
}
|
|
20
|
+
exports.getPoolContract = getPoolContract;
|
|
21
|
+
/**
|
|
22
|
+
* Gets the credit record of a wallet in a Huma pool. Denominated in the ERC20 tokens of the pool.
|
|
23
|
+
*
|
|
24
|
+
* @namespace getCreditRecord
|
|
25
|
+
* @async
|
|
26
|
+
* @function
|
|
27
|
+
* @param {string} address - The address to lookup.
|
|
28
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to read data.
|
|
29
|
+
* @param {number} chainId - The chain ID of the pool. Used to lookup the pool address.
|
|
30
|
+
* @param {POOL_NAME} poolName - The name of the credit pool. Used to lookup the pool address.
|
|
31
|
+
* @param {POOL_TYPE} poolType - The type of the credit pool. Used to lookup the pool address.
|
|
32
|
+
* @returns {Promise<CreditRecord>} - A Promise of the transaction response.
|
|
33
|
+
*/
|
|
34
|
+
async function getCreditRecord(address, signerOrProvider, chainId, poolName, poolType) {
|
|
35
|
+
const poolContract = getPoolContract(signerOrProvider, chainId, poolName, poolType);
|
|
36
|
+
if (!poolContract) {
|
|
37
|
+
throw new Error('Could not find pool contract');
|
|
38
|
+
}
|
|
39
|
+
return poolContract.creditRecordMapping(address);
|
|
40
|
+
}
|
|
41
|
+
exports.getCreditRecord = getCreditRecord;
|
|
42
|
+
/**
|
|
43
|
+
* Gets the total due for a Huma pool of the given wallet. Denominated in the ERC20 tokens of the pool.
|
|
44
|
+
*
|
|
45
|
+
* @async
|
|
46
|
+
* @function
|
|
47
|
+
* @param {string} address - The address to lookup.
|
|
48
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to read data.
|
|
49
|
+
* @param {number} chainId - The chain ID of the pool. Used to lookup the pool address.
|
|
50
|
+
* @param {POOL_NAME} poolName - The name of the credit pool. Used to lookup the pool address.
|
|
51
|
+
* @param {POOL_TYPE} poolType - The type of the credit pool. Used to lookup the pool address.
|
|
52
|
+
* @returns {Promise<BigNumber>} - A Promise of the transaction response.
|
|
53
|
+
*/
|
|
54
|
+
async function getTotalDue(address, signerOrProvider, chainId, poolName, poolType) {
|
|
55
|
+
const creditRecord = await getCreditRecord(address, signerOrProvider, chainId, poolName, poolType);
|
|
56
|
+
return creditRecord.totalDue;
|
|
57
|
+
}
|
|
58
|
+
exports.getTotalDue = getTotalDue;
|
|
59
|
+
/**
|
|
60
|
+
* Calls drawdown on a Huma pool contract
|
|
61
|
+
*
|
|
62
|
+
* @async
|
|
63
|
+
* @function
|
|
64
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
65
|
+
* @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
|
|
66
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
67
|
+
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
68
|
+
* @param {BigNumberish} drawdownAmount - The amount of tokens to withdraw, denominated in the ERC20 tokens of the pool.
|
|
69
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
70
|
+
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
71
|
+
*/
|
|
72
|
+
async function drawdownFromPool(signer, chainId, poolName, poolType, drawdownAmount, gasOpts = {}) {
|
|
73
|
+
const poolContract = getPoolContract(signer, chainId, poolName, poolType);
|
|
74
|
+
if (!poolContract) {
|
|
75
|
+
throw new Error('Could not find pool contract');
|
|
76
|
+
}
|
|
77
|
+
gasOpts = await (0, utils_1.getDefaultGasOptions)(gasOpts, chainId);
|
|
78
|
+
// TODO: Generate typechain for pool contract
|
|
79
|
+
return poolContract.drawdown(drawdownAmount, gasOpts);
|
|
80
|
+
}
|
|
81
|
+
exports.drawdownFromPool = drawdownFromPool;
|
|
82
|
+
/**
|
|
83
|
+
* Calls makePayment on a Huma pool contract. If the pool does not have sufficient allowance to complete the operation,
|
|
84
|
+
* attempt to first increase the allowance of the pool.
|
|
85
|
+
*
|
|
86
|
+
* @async
|
|
87
|
+
* @function
|
|
88
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
89
|
+
* @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
|
|
90
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
91
|
+
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
92
|
+
* @param {BigNumberish} paymentAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
|
|
93
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
94
|
+
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
95
|
+
*/
|
|
96
|
+
async function makePaymentToPool(signer, chainId, poolName, poolType, paymentAmount, gasOpts = {}) {
|
|
97
|
+
const poolInfo = (0, utils_1.getPoolInfo)(chainId, poolName, poolType);
|
|
98
|
+
if (!(poolInfo === null || poolInfo === void 0 ? void 0 : poolInfo.poolUnderlyingToken.address)) {
|
|
99
|
+
throw new Error('Could not find pool underlying token address');
|
|
100
|
+
}
|
|
101
|
+
const poolTokenContract = (0, utils_1.getERC20Contract)(poolInfo === null || poolInfo === void 0 ? void 0 : poolInfo.poolUnderlyingToken.address, signer);
|
|
102
|
+
const poolContract = getPoolContract(signer, chainId, poolName, poolType);
|
|
103
|
+
if (!poolContract) {
|
|
104
|
+
throw new Error('Could not find pool contract');
|
|
105
|
+
}
|
|
106
|
+
gasOpts = await (0, utils_1.getDefaultGasOptions)(gasOpts, chainId);
|
|
107
|
+
const allowance = await poolTokenContract.allowance(await signer.getAddress(), poolContract.address);
|
|
108
|
+
if (allowance.lt(paymentAmount)) {
|
|
109
|
+
const approvalTx = await poolTokenContract.approve(poolContract.address, paymentAmount, gasOpts);
|
|
110
|
+
await approvalTx.wait();
|
|
111
|
+
}
|
|
112
|
+
// TODO: Generate typechain for pool contract
|
|
113
|
+
return poolContract.makePayment(await signer.getAddress(), paymentAmount, gasOpts);
|
|
114
|
+
}
|
|
115
|
+
exports.makePaymentToPool = makePaymentToPool;
|
|
116
|
+
/**
|
|
117
|
+
* Approves an allowance for a Huma pool contract, which is required to do certain actions (e.g. makePayment)
|
|
118
|
+
*
|
|
119
|
+
* @async
|
|
120
|
+
* @function
|
|
121
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
122
|
+
* @param {number} chainId - The chain ID of the pool to call drawdown on. Used to lookup the pool address.
|
|
123
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
124
|
+
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
125
|
+
* @param {BigNumberish} allowanceAmount - The amount of tokens to payback, denominated in the ERC20 tokens of the pool.
|
|
126
|
+
* @param {Overrides} [gasOpts] - The gas options to use for the transaction.
|
|
127
|
+
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
128
|
+
*/
|
|
129
|
+
async function approvePoolAllowance(signer, chainId, poolName, poolType, allowanceAmount, gasOpts = {}) {
|
|
130
|
+
const poolInfo = (0, utils_1.getPoolInfo)(chainId, poolName, poolType);
|
|
131
|
+
if (!(poolInfo === null || poolInfo === void 0 ? void 0 : poolInfo.poolUnderlyingToken.address)) {
|
|
132
|
+
throw new Error('Could not find pool underlying token address');
|
|
133
|
+
}
|
|
134
|
+
const poolTokenContract = (0, utils_1.getERC20Contract)(poolInfo === null || poolInfo === void 0 ? void 0 : poolInfo.poolUnderlyingToken.address, signer);
|
|
135
|
+
const poolContract = getPoolContract(signer, chainId, poolName, poolType);
|
|
136
|
+
if (!poolContract) {
|
|
137
|
+
throw new Error('Could not find pool contract');
|
|
138
|
+
}
|
|
139
|
+
gasOpts = await (0, utils_1.getDefaultGasOptions)(gasOpts, chainId);
|
|
140
|
+
return poolTokenContract.approve(poolContract.address, allowanceAmount, gasOpts);
|
|
141
|
+
}
|
|
142
|
+
exports.approvePoolAllowance = approvePoolAllowance;
|
|
105
143
|
//# sourceMappingURL=PoolContractHelper.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":";;;AAKA,
|
|
1
|
+
{"version":3,"file":"PoolContractHelper.js","sourceRoot":"","sources":["../../../src/helpers/PoolContractHelper.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { Contract, ethers } from 'ethers';
|
|
2
|
-
/**
|
|
3
|
-
* Returns an ethers contract instance for the RealWorldReceivable contract
|
|
4
|
-
* associated with the given pool name on the current chain.
|
|
5
|
-
*
|
|
6
|
-
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
7
|
-
* @param {number} chainId The chain id where the contract instance exists
|
|
8
|
-
* @returns {Contract | null} A contract instance for the RealWorldReceivable contract or null if it could not be found.
|
|
9
|
-
*/
|
|
10
|
-
export declare function getRealWorldReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
|
|
1
|
+
import { Contract, ethers } from 'ethers';
|
|
2
|
+
/**
|
|
3
|
+
* Returns an ethers contract instance for the RealWorldReceivable contract
|
|
4
|
+
* associated with the given pool name on the current chain.
|
|
5
|
+
*
|
|
6
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
7
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
8
|
+
* @returns {Contract | null} A contract instance for the RealWorldReceivable contract or null if it could not be found.
|
|
9
|
+
*/
|
|
10
|
+
export declare function getRealWorldReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getRealWorldReceivableContract = void 0;
|
|
4
|
-
const shared_1 = require("@huma-finance/shared");
|
|
5
|
-
const utils_1 = require("../utils");
|
|
6
|
-
/**
|
|
7
|
-
* Returns an ethers contract instance for the RealWorldReceivable contract
|
|
8
|
-
* associated with the given pool name on the current chain.
|
|
9
|
-
*
|
|
10
|
-
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
11
|
-
* @param {number} chainId The chain id where the contract instance exists
|
|
12
|
-
* @returns {Contract | null} A contract instance for the RealWorldReceivable contract or null if it could not be found.
|
|
13
|
-
*/
|
|
14
|
-
function getRealWorldReceivableContract(signerOrProvider, chainId) {
|
|
15
|
-
var _a;
|
|
16
|
-
const realWorldReceivable = (_a = shared_1.SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[shared_1.SupplementaryContracts.RealWorldReceivable];
|
|
17
|
-
if (!realWorldReceivable)
|
|
18
|
-
return null;
|
|
19
|
-
return (0, utils_1.getContract)(realWorldReceivable, shared_1.REAL_WORLD_RECEIVABLE_ABI, signerOrProvider);
|
|
20
|
-
}
|
|
21
|
-
exports.getRealWorldReceivableContract = getRealWorldReceivableContract;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getRealWorldReceivableContract = void 0;
|
|
4
|
+
const shared_1 = require("@huma-finance/shared");
|
|
5
|
+
const utils_1 = require("../utils");
|
|
6
|
+
/**
|
|
7
|
+
* Returns an ethers contract instance for the RealWorldReceivable contract
|
|
8
|
+
* associated with the given pool name on the current chain.
|
|
9
|
+
*
|
|
10
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
11
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
12
|
+
* @returns {Contract | null} A contract instance for the RealWorldReceivable contract or null if it could not be found.
|
|
13
|
+
*/
|
|
14
|
+
function getRealWorldReceivableContract(signerOrProvider, chainId) {
|
|
15
|
+
var _a;
|
|
16
|
+
const realWorldReceivable = (_a = shared_1.SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[shared_1.SupplementaryContracts.RealWorldReceivable];
|
|
17
|
+
if (!realWorldReceivable)
|
|
18
|
+
return null;
|
|
19
|
+
return (0, utils_1.getContract)(realWorldReceivable, shared_1.REAL_WORLD_RECEIVABLE_ABI, signerOrProvider);
|
|
20
|
+
}
|
|
21
|
+
exports.getRealWorldReceivableContract = getRealWorldReceivableContract;
|
|
22
22
|
//# sourceMappingURL=RealWorldReceivableContractHelper.js.map
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './RealWorldReceivableContractHelper';
|
|
2
|
-
export * from './ERC20TransferableReceivableContractHelper';
|
|
3
|
-
export * from './PoolContractHelper';
|
|
1
|
+
export * from './RealWorldReceivableContractHelper';
|
|
2
|
+
export * from './ERC20TransferableReceivableContractHelper';
|
|
3
|
+
export * from './PoolContractHelper';
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./RealWorldReceivableContractHelper"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./ERC20TransferableReceivableContractHelper"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./PoolContractHelper"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./RealWorldReceivableContractHelper"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./ERC20TransferableReceivableContractHelper"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./PoolContractHelper"), exports);
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './useContract';
|
|
2
|
-
export * from './useRealWorldReceivableContract';
|
|
3
|
-
export * from './useERC20TransferableReceivableContract';
|
|
4
|
-
export * from './usePoolContract';
|
|
1
|
+
export * from './useContract';
|
|
2
|
+
export * from './useRealWorldReceivableContract';
|
|
3
|
+
export * from './useERC20TransferableReceivableContract';
|
|
4
|
+
export * from './usePoolContract';
|
package/dist/cjs/hooks/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const tslib_1 = require("tslib");
|
|
4
|
-
tslib_1.__exportStar(require("./useContract"), exports);
|
|
5
|
-
tslib_1.__exportStar(require("./useRealWorldReceivableContract"), exports);
|
|
6
|
-
tslib_1.__exportStar(require("./useERC20TransferableReceivableContract"), exports);
|
|
7
|
-
tslib_1.__exportStar(require("./usePoolContract"), exports);
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./useContract"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./useRealWorldReceivableContract"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./useERC20TransferableReceivableContract"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./usePoolContract"), exports);
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Contract, ethers } from 'ethers';
|
|
2
|
+
/**
|
|
3
|
+
* A react hook that 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 useBaseCreditPoolReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number): Contract | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useBaseCreditPoolReceivableContract = void 0;
|
|
4
|
+
const shared_1 = require("@huma-finance/shared");
|
|
5
|
+
const useContract_1 = require("./useContract");
|
|
6
|
+
/**
|
|
7
|
+
* A react hook that returns an ethers contract instance for the BaseCreditPoolReceivable contract
|
|
8
|
+
* associated with the given pool name on the current chain.
|
|
9
|
+
*
|
|
10
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
11
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
12
|
+
* @returns {Contract | null} A contract instance for the BaseCreditPoolReceivable contract or null if it could not be found.
|
|
13
|
+
*/
|
|
14
|
+
function useBaseCreditPoolReceivableContract(signerOrProvider, chainId) {
|
|
15
|
+
var _a;
|
|
16
|
+
const baseCreditPoolReceivable = (_a = shared_1.SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[shared_1.SupplementaryContracts.BaseCreditPoolReceivable];
|
|
17
|
+
return (0, useContract_1.useContract)(baseCreditPoolReceivable, shared_1.BASE_CREDIT_POOL_RECEIVABLE_ABI, signerOrProvider);
|
|
18
|
+
}
|
|
19
|
+
exports.useBaseCreditPoolReceivableContract = useBaseCreditPoolReceivableContract;
|
|
20
|
+
//# sourceMappingURL=useBaseCreditPoolReceivableContract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useBaseCreditPoolReceivableContract.js","sourceRoot":"","sources":["../../../src/hooks/useBaseCreditPoolReceivableContract.ts"],"names":[],"mappings":";;;AACA,iDAK6B;AAE7B,+CAA2C;AAE3C;;;;;;;GAOG;AACH,SAAgB,mCAAmC,CACjD,gBAA2D,EAC3D,OAAe;;IAEf,MAAM,wBAAwB,GAC5B,MAAA,kCAAyB,CAAC,OAAO,CAAC,0CAChC,+BAAsB,CAAC,wBAAwB,CAChD,CAAA;IAEH,OAAO,IAAA,yBAAW,EAChB,wBAAwB,EACxB,wCAA+B,EAC/B,gBAAgB,CACjB,CAAA;AACH,CAAC;AAdD,kFAcC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Contract } from '@ethersproject/contracts';
|
|
2
|
-
import { ethers } from 'ethers';
|
|
3
|
-
/**
|
|
4
|
-
* Custom hook for creating an ethers instance of a smart contract.
|
|
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.
|
|
10
|
-
* Note that this signerOrProvider must be connected to the same network as the smart contract in question.
|
|
11
|
-
* @returns {T | null} An instance of the smart contract, or null if an error occurs.
|
|
12
|
-
*/
|
|
13
|
-
export declare function useContract<T extends Contract = Contract>(address: string | null | undefined, ABI: any, signerOrProvider: ethers.providers.Provider | ethers.Signer): T | null;
|
|
1
|
+
import { Contract } from '@ethersproject/contracts';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
|
+
/**
|
|
4
|
+
* Custom hook for creating an ethers instance of a smart contract.
|
|
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.
|
|
10
|
+
* Note that this signerOrProvider must be connected to the same network as the smart contract in question.
|
|
11
|
+
* @returns {T | null} An instance of the smart contract, or null if an error occurs.
|
|
12
|
+
*/
|
|
13
|
+
export declare function useContract<T extends Contract = Contract>(address: string | null | undefined, ABI: any, signerOrProvider: ethers.providers.Provider | ethers.Signer): T | null;
|
|
@@ -1,31 +1,31 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useContract = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const web3_1 = require("../utils/web3");
|
|
6
|
-
/**
|
|
7
|
-
* Custom hook for creating an ethers instance of a smart contract.
|
|
8
|
-
*
|
|
9
|
-
* @template T - The type of the contract.
|
|
10
|
-
* @param {string | null | undefined} address - The address of the smart contract instance.
|
|
11
|
-
* @param {any} ABI - The ABI of the smart contract.
|
|
12
|
-
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to sign transactions or retrieve blockchain data.
|
|
13
|
-
* Note that this signerOrProvider must be connected to the same network as the smart contract in question.
|
|
14
|
-
* @returns {T | null} An instance of the smart contract, or null if an error occurs.
|
|
15
|
-
*/
|
|
16
|
-
function useContract(address,
|
|
17
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
-
ABI, signerOrProvider) {
|
|
19
|
-
return (0, react_1.useMemo)(() => {
|
|
20
|
-
if (!address || !ABI || !signerOrProvider)
|
|
21
|
-
return null;
|
|
22
|
-
try {
|
|
23
|
-
return (0, web3_1.getContract)(address, ABI, signerOrProvider);
|
|
24
|
-
}
|
|
25
|
-
catch (error) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
}, [address, ABI, signerOrProvider]);
|
|
29
|
-
}
|
|
30
|
-
exports.useContract = useContract;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useContract = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const web3_1 = require("../utils/web3");
|
|
6
|
+
/**
|
|
7
|
+
* Custom hook for creating an ethers instance of a smart contract.
|
|
8
|
+
*
|
|
9
|
+
* @template T - The type of the contract.
|
|
10
|
+
* @param {string | null | undefined} address - The address of the smart contract instance.
|
|
11
|
+
* @param {any} ABI - The ABI of the smart contract.
|
|
12
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider used to sign transactions or retrieve blockchain data.
|
|
13
|
+
* Note that this signerOrProvider must be connected to the same network as the smart contract in question.
|
|
14
|
+
* @returns {T | null} An instance of the smart contract, or null if an error occurs.
|
|
15
|
+
*/
|
|
16
|
+
function useContract(address,
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
18
|
+
ABI, signerOrProvider) {
|
|
19
|
+
return (0, react_1.useMemo)(() => {
|
|
20
|
+
if (!address || !ABI || !signerOrProvider)
|
|
21
|
+
return null;
|
|
22
|
+
try {
|
|
23
|
+
return (0, web3_1.getContract)(address, ABI, signerOrProvider);
|
|
24
|
+
}
|
|
25
|
+
catch (error) {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}, [address, ABI, signerOrProvider]);
|
|
29
|
+
}
|
|
30
|
+
exports.useContract = useContract;
|
|
31
31
|
//# sourceMappingURL=useContract.js.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Contract, ethers } from 'ethers';
|
|
2
|
-
import { POOL_NAME } from '@huma-finance/shared';
|
|
3
|
-
/**
|
|
4
|
-
* A react hook that returns an ethers contract instance for the ERC20TransferableReceivable 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
|
-
* @param {POOL_NAME} poolName The name of the pool to get the contract for.
|
|
10
|
-
* @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
|
|
11
|
-
*/
|
|
12
|
-
export declare function useERC20TransferableReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME): Contract | null;
|
|
1
|
+
import { Contract, ethers } from 'ethers';
|
|
2
|
+
import { POOL_NAME } from '@huma-finance/shared';
|
|
3
|
+
/**
|
|
4
|
+
* A react hook that returns an ethers contract instance for the ERC20TransferableReceivable 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
|
+
* @param {POOL_NAME} poolName The name of the pool to get the contract for.
|
|
10
|
+
* @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useERC20TransferableReceivableContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME): Contract | null;
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useERC20TransferableReceivableContract = void 0;
|
|
4
|
-
const shared_1 = require("@huma-finance/shared");
|
|
5
|
-
const useContract_1 = require("./useContract");
|
|
6
|
-
/**
|
|
7
|
-
* A react hook that returns an ethers contract instance for the ERC20TransferableReceivable contract
|
|
8
|
-
* associated with the given pool name on the current chain.
|
|
9
|
-
*
|
|
10
|
-
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
11
|
-
* @param {number} chainId The chain id where the contract instance exists
|
|
12
|
-
* @param {POOL_NAME} poolName The name of the pool to get the contract for.
|
|
13
|
-
* @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
|
|
14
|
-
*/
|
|
15
|
-
function useERC20TransferableReceivableContract(signerOrProvider, chainId, poolName) {
|
|
16
|
-
var _a, _b, _c;
|
|
17
|
-
const TransferableReceivableAddress = (_c = (_b = (_a = shared_1.PoolContractMap[chainId]) === null || _a === void 0 ? void 0 : _a[shared_1.POOL_TYPE.Invoice]) === null || _b === void 0 ? void 0 : _b[poolName]) === null || _c === void 0 ? void 0 : _c.assetAddress;
|
|
18
|
-
return (0, useContract_1.useContract)(TransferableReceivableAddress, shared_1.ERC20_TRANSFERABLE_RECEIVABLE_ABI, signerOrProvider);
|
|
19
|
-
}
|
|
20
|
-
exports.useERC20TransferableReceivableContract = useERC20TransferableReceivableContract;
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useERC20TransferableReceivableContract = void 0;
|
|
4
|
+
const shared_1 = require("@huma-finance/shared");
|
|
5
|
+
const useContract_1 = require("./useContract");
|
|
6
|
+
/**
|
|
7
|
+
* A react hook that returns an ethers contract instance for the ERC20TransferableReceivable contract
|
|
8
|
+
* associated with the given pool name on the current chain.
|
|
9
|
+
*
|
|
10
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider The provider or signer instance to use for the contract.
|
|
11
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
12
|
+
* @param {POOL_NAME} poolName The name of the pool to get the contract for.
|
|
13
|
+
* @returns {Contract | null} A contract instance for the ERC20TransferableReceivable contract or null if it could not be found.
|
|
14
|
+
*/
|
|
15
|
+
function useERC20TransferableReceivableContract(signerOrProvider, chainId, poolName) {
|
|
16
|
+
var _a, _b, _c;
|
|
17
|
+
const TransferableReceivableAddress = (_c = (_b = (_a = shared_1.PoolContractMap[chainId]) === null || _a === void 0 ? void 0 : _a[shared_1.POOL_TYPE.Invoice]) === null || _b === void 0 ? void 0 : _b[poolName]) === null || _c === void 0 ? void 0 : _c.assetAddress;
|
|
18
|
+
return (0, useContract_1.useContract)(TransferableReceivableAddress, shared_1.ERC20_TRANSFERABLE_RECEIVABLE_ABI, signerOrProvider);
|
|
19
|
+
}
|
|
20
|
+
exports.useERC20TransferableReceivableContract = useERC20TransferableReceivableContract;
|
|
21
21
|
//# sourceMappingURL=useERC20TransferableReceivableContract.js.map
|