@huma-finance/sdk 0.0.39 → 0.0.41
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 +45 -9
- package/dist/cjs/graphql/generatedTypes.d.ts +40 -0
- package/dist/cjs/graphql/generatedTypes.js +9 -0
- package/dist/cjs/graphql/generatedTypes.js.map +1 -0
- package/dist/cjs/graphql/index.d.ts +1 -0
- package/dist/cjs/graphql/index.js +5 -0
- package/dist/cjs/graphql/index.js.map +1 -0
- 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 +119 -0
- package/dist/cjs/helpers/PoolContractHelper.js +144 -0
- package/dist/cjs/helpers/PoolContractHelper.js.map +1 -0
- package/dist/cjs/helpers/RealWorldReceivableContractHelper.d.ts +10 -0
- package/dist/cjs/helpers/RealWorldReceivableContractHelper.js +22 -0
- package/dist/cjs/helpers/RealWorldReceivableContractHelper.js.map +1 -0
- package/dist/cjs/helpers/index.d.ts +3 -0
- package/dist/cjs/helpers/index.js +7 -0
- package/dist/cjs/helpers/index.js.map +1 -0
- package/dist/cjs/hooks/index.d.ts +4 -0
- package/dist/cjs/hooks/index.js +8 -0
- package/dist/cjs/hooks/index.js.map +1 -0
- package/dist/cjs/hooks/useContract.d.ts +13 -0
- package/dist/cjs/hooks/useContract.js +31 -0
- package/dist/cjs/hooks/useContract.js.map +1 -0
- package/dist/cjs/hooks/useERC20TransferableReceivableContract.d.ts +12 -0
- package/dist/cjs/hooks/useERC20TransferableReceivableContract.js +21 -0
- package/dist/cjs/hooks/useERC20TransferableReceivableContract.js.map +1 -0
- package/dist/cjs/hooks/usePoolContract.d.ts +60 -0
- package/dist/cjs/hooks/usePoolContract.js +54 -0
- package/dist/cjs/hooks/usePoolContract.js.map +1 -0
- package/dist/cjs/hooks/useRealWorldReceivableContract.d.ts +10 -0
- package/dist/cjs/hooks/useRealWorldReceivableContract.js +20 -0
- package/dist/cjs/hooks/useRealWorldReceivableContract.js.map +1 -0
- package/dist/cjs/index.d.ts +4 -0
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/services/ARWeaveService.d.ts +117 -0
- package/dist/cjs/services/ARWeaveService.js +204 -0
- package/dist/cjs/services/ARWeaveService.js.map +1 -0
- package/dist/cjs/services/EAService.d.ts +20 -0
- package/dist/cjs/services/EAService.js +34 -0
- package/dist/cjs/services/EAService.js.map +1 -0
- package/dist/cjs/services/ReceivableService.d.ts +142 -0
- package/dist/cjs/services/ReceivableService.js +330 -0
- package/dist/cjs/services/ReceivableService.js.map +1 -0
- package/dist/cjs/services/SubgraphService.d.ts +53 -0
- package/dist/cjs/services/SubgraphService.js +94 -0
- package/dist/cjs/services/SubgraphService.js.map +1 -0
- package/dist/cjs/services/index.d.ts +4 -0
- package/dist/cjs/services/index.js +8 -0
- package/dist/cjs/services/index.js.map +1 -0
- package/dist/cjs/utils/chain.d.ts +15 -0
- package/dist/cjs/utils/chain.js +38 -0
- package/dist/cjs/utils/chain.js.map +1 -0
- package/dist/cjs/utils/index.d.ts +4 -0
- package/dist/cjs/utils/index.js +8 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/maticGasStation.d.ts +3 -0
- package/dist/cjs/utils/maticGasStation.js +39 -0
- package/dist/cjs/utils/maticGasStation.js.map +1 -0
- package/dist/cjs/utils/poolInfo.d.ts +8 -0
- package/dist/cjs/utils/poolInfo.js +13 -0
- package/dist/cjs/utils/poolInfo.js.map +1 -0
- package/dist/cjs/utils/web3.d.ts +5 -0
- package/dist/cjs/utils/web3.js +34 -0
- package/dist/cjs/utils/web3.js.map +1 -0
- package/dist/graphql/generatedTypes.d.ts +40 -0
- package/dist/graphql/generatedTypes.js +5 -0
- package/dist/graphql/generatedTypes.js.map +1 -0
- package/dist/graphql/index.d.ts +1 -0
- package/dist/graphql/index.js +2 -0
- package/dist/graphql/index.js.map +1 -0
- 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 +119 -0
- package/dist/helpers/PoolContractHelper.js +135 -0
- package/dist/helpers/PoolContractHelper.js.map +1 -0
- package/dist/helpers/RealWorldReceivableContractHelper.d.ts +10 -0
- package/dist/helpers/RealWorldReceivableContractHelper.js +18 -0
- package/dist/helpers/RealWorldReceivableContractHelper.js.map +1 -0
- package/dist/helpers/index.d.ts +3 -0
- package/dist/helpers/index.js +4 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/hooks/index.d.ts +4 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useContract.d.ts +13 -0
- package/dist/hooks/useContract.js +27 -0
- package/dist/hooks/useContract.js.map +1 -0
- package/dist/hooks/useERC20TransferableReceivableContract.d.ts +12 -0
- package/dist/hooks/useERC20TransferableReceivableContract.js +17 -0
- package/dist/hooks/useERC20TransferableReceivableContract.js.map +1 -0
- package/dist/hooks/usePoolContract.d.ts +60 -0
- package/dist/hooks/usePoolContract.js +49 -0
- package/dist/hooks/usePoolContract.js.map +1 -0
- package/dist/hooks/useRealWorldReceivableContract.d.ts +10 -0
- package/dist/hooks/useRealWorldReceivableContract.js +16 -0
- package/dist/hooks/useRealWorldReceivableContract.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/services/ARWeaveService.d.ts +117 -0
- package/dist/services/ARWeaveService.js +199 -0
- package/dist/services/ARWeaveService.js.map +1 -0
- package/dist/services/EAService.d.ts +20 -0
- package/dist/services/EAService.js +31 -0
- package/dist/services/EAService.js.map +1 -0
- package/dist/services/ReceivableService.d.ts +142 -0
- package/dist/services/ReceivableService.js +327 -0
- package/dist/services/ReceivableService.js.map +1 -0
- package/dist/services/SubgraphService.d.ts +53 -0
- package/dist/services/SubgraphService.js +91 -0
- package/dist/services/SubgraphService.js.map +1 -0
- package/dist/services/index.d.ts +4 -0
- package/dist/services/index.js +5 -0
- package/dist/services/index.js.map +1 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -0
- package/dist/utils/chain.d.ts +15 -0
- package/dist/utils/chain.js +32 -0
- package/dist/utils/chain.js.map +1 -0
- package/dist/utils/index.d.ts +4 -0
- package/dist/utils/index.js +5 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/maticGasStation.d.ts +3 -0
- package/dist/utils/maticGasStation.js +34 -0
- package/dist/utils/maticGasStation.js.map +1 -0
- package/dist/utils/poolInfo.d.ts +8 -0
- package/dist/utils/poolInfo.js +9 -0
- package/dist/utils/poolInfo.js.map +1 -0
- package/dist/utils/web3.d.ts +5 -0
- package/dist/utils/web3.js +28 -0
- package/dist/utils/web3.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +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;
|
|
@@ -0,0 +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;
|
|
21
|
+
//# sourceMappingURL=useERC20TransferableReceivableContract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useERC20TransferableReceivableContract.js","sourceRoot":"","sources":["../../../src/hooks/useERC20TransferableReceivableContract.ts"],"names":[],"mappings":";;;AACA,iDAM6B;AAE7B,+CAA2C;AAE3C;;;;;;;;GAQG;AACH,SAAgB,sCAAsC,CACpD,gBAA2D,EAC3D,OAAe,EACf,QAAmB;;IAEnB,MAAM,6BAA6B,GACjC,MAAA,MAAA,MAAA,wBAAe,CAAC,OAAO,CAAC,0CAAG,kBAAS,CAAC,OAAO,CAAC,0CAAG,QAAQ,CAAC,0CAAE,YAAY,CAAA;IAEzE,OAAO,IAAA,yBAAW,EAChB,6BAA6B,EAC7B,0CAAiC,EACjC,gBAAgB,CACjB,CAAA;AACH,CAAC;AAbD,wFAaC"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { BigNumber } from '@ethersproject/bignumber';
|
|
2
|
+
import { Contract, ethers } from 'ethers';
|
|
3
|
+
import { POOL_NAME, POOL_TYPE } from '@huma-finance/shared';
|
|
4
|
+
/**
|
|
5
|
+
* A react hook that returns a contract instance of a specific pool using an ethers provider or signer
|
|
6
|
+
*
|
|
7
|
+
* @namespace usePoolContract
|
|
8
|
+
* @template T - The type of the contract.
|
|
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
|
|
11
|
+
* @param {POOL_NAME} poolName - The name of the pool.
|
|
12
|
+
* @param {POOL_TYPE} poolType - The type of the pool.
|
|
13
|
+
* @returns {T} A contract instance of the specific pool.
|
|
14
|
+
*/
|
|
15
|
+
export declare function usePoolContract<T extends Contract>(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): T | null;
|
|
16
|
+
/**
|
|
17
|
+
* CreditRecordDetails type object representing the details of a credit line.
|
|
18
|
+
*
|
|
19
|
+
* @memberof usePoolContract
|
|
20
|
+
* @typedef {Object} CreditRecordDetails
|
|
21
|
+
* @property {number} aprInBps - The APR (annual percentage rate) in basis points.
|
|
22
|
+
* @property {BigNumber} correction - adjustment of interest over or under-counted because of drawdown
|
|
23
|
+
* or principal payment in the middle of a billing period
|
|
24
|
+
* @property {BigNumber} creditLimit - The credit limit in the pools base currency.
|
|
25
|
+
* @property {BigNumber} defaultAmount - The amount of the default, if any.
|
|
26
|
+
* @property {BigNumber} dueDate - The due date of the next payment.
|
|
27
|
+
* @property {BigNumber} feesAndInterestDue - The fees and interest due.
|
|
28
|
+
* @property {number} intervalInDays - The interval in days between payment periods.
|
|
29
|
+
* @property {number} missedPeriods - The number of missed periods.
|
|
30
|
+
* @property {number} remainingPeriods - The number of remaining periods before this credit line is considered paid off.
|
|
31
|
+
* @property {number} state - The state of the factorization. Please see the CreditState in huma-contracts for more details.
|
|
32
|
+
* @property {BigNumber} totalDue - The total due amount of this credit line.
|
|
33
|
+
* @property {BigNumber} unbilledPrincipal - The unbilled principal of the next payment.
|
|
34
|
+
*/
|
|
35
|
+
export type CreditRecordDetails = {
|
|
36
|
+
aprInBps: number;
|
|
37
|
+
correction: BigNumber;
|
|
38
|
+
creditLimit: BigNumber;
|
|
39
|
+
defaultAmount: BigNumber;
|
|
40
|
+
dueDate: BigNumber;
|
|
41
|
+
feesAndInterestDue: BigNumber;
|
|
42
|
+
intervalInDays: number;
|
|
43
|
+
missedPeriods: number;
|
|
44
|
+
remainingPeriods: number;
|
|
45
|
+
state: number;
|
|
46
|
+
totalDue: BigNumber;
|
|
47
|
+
unbilledPrincipal: BigNumber;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
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.
|
|
51
|
+
*
|
|
52
|
+
* @memberof usePoolContract
|
|
53
|
+
* @param {string} userAddress - The address of the user to get the credit record details for.
|
|
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
|
|
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.
|
|
58
|
+
* @returns {Array<CreditRecordDetails | undefined, function():void>} An array containing the credit record details and a function to refresh the data.
|
|
59
|
+
*/
|
|
60
|
+
export declare function useCreditRecordDetails(userAddress: string, signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): [CreditRecordDetails | undefined, () => void];
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useCreditRecordDetails = exports.usePoolContract = void 0;
|
|
4
|
+
const react_1 = require("react");
|
|
5
|
+
const useContract_1 = require("./useContract");
|
|
6
|
+
const poolInfo_1 = require("../utils/poolInfo");
|
|
7
|
+
/**
|
|
8
|
+
* A react hook that returns a contract instance of a specific pool using an ethers provider or signer
|
|
9
|
+
*
|
|
10
|
+
* @namespace usePoolContract
|
|
11
|
+
* @template T - The type of the contract.
|
|
12
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - An ethers signer or provider instance.
|
|
13
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
14
|
+
* @param {POOL_NAME} poolName - The name of the pool.
|
|
15
|
+
* @param {POOL_TYPE} poolType - The type of the pool.
|
|
16
|
+
* @returns {T} A contract instance of the specific pool.
|
|
17
|
+
*/
|
|
18
|
+
function usePoolContract(signerOrProvider, chainId, poolName, poolType) {
|
|
19
|
+
const poolInfo = (0, poolInfo_1.getPoolInfo)(chainId, poolName, poolType);
|
|
20
|
+
return (0, useContract_1.useContract)(poolInfo === null || poolInfo === void 0 ? void 0 : poolInfo.pool, poolInfo === null || poolInfo === void 0 ? void 0 : poolInfo.poolAbi, signerOrProvider);
|
|
21
|
+
}
|
|
22
|
+
exports.usePoolContract = usePoolContract;
|
|
23
|
+
/**
|
|
24
|
+
* 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.
|
|
25
|
+
*
|
|
26
|
+
* @memberof usePoolContract
|
|
27
|
+
* @param {string} userAddress - The address of the user to get the credit record details for.
|
|
28
|
+
* @param {ethers.providers.Provider | ethers.Signer} signerOrProvider - The signer or provider object to use for the contract.
|
|
29
|
+
* @param {number} chainId The chain id where the contract instance exists
|
|
30
|
+
* @param {POOL_NAME} poolName - The name of the pool to get the credit record details for.
|
|
31
|
+
* @param {POOL_TYPE} poolType - The type of the pool.
|
|
32
|
+
* @returns {Array<CreditRecordDetails | undefined, function():void>} An array containing the credit record details and a function to refresh the data.
|
|
33
|
+
*/
|
|
34
|
+
function useCreditRecordDetails(userAddress, signerOrProvider, chainId, poolName, poolType) {
|
|
35
|
+
const poolContract = usePoolContract(signerOrProvider, chainId, poolName, poolType);
|
|
36
|
+
const [creditRecordDetails, setCreditRecordDetails] = (0, react_1.useState)();
|
|
37
|
+
const [refreshCount, setRefreshCount] = (0, react_1.useState)(0);
|
|
38
|
+
(0, react_1.useEffect)(() => {
|
|
39
|
+
const fetchData = async () => {
|
|
40
|
+
if (poolContract && userAddress) {
|
|
41
|
+
const creditRecordMapping = await poolContract.creditRecordMapping(userAddress);
|
|
42
|
+
const creditRecordStaticMapping = await poolContract.creditRecordStaticMapping(userAddress);
|
|
43
|
+
setCreditRecordDetails(Object.assign(Object.assign({}, creditRecordMapping), creditRecordStaticMapping));
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
fetchData();
|
|
47
|
+
}, [userAddress, poolContract, refreshCount]);
|
|
48
|
+
const refresh = (0, react_1.useCallback)(() => {
|
|
49
|
+
setRefreshCount((pre) => pre + 1);
|
|
50
|
+
}, []);
|
|
51
|
+
return [creditRecordDetails, refresh];
|
|
52
|
+
}
|
|
53
|
+
exports.useCreditRecordDetails = useCreditRecordDetails;
|
|
54
|
+
//# sourceMappingURL=usePoolContract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePoolContract.js","sourceRoot":"","sources":["../../../src/hooks/usePoolContract.ts"],"names":[],"mappings":";;;AAEA,iCAAwD;AAGxD,+CAA2C;AAC3C,gDAA+C;AAE/C;;;;;;;;;;GAUG;AACH,SAAgB,eAAe,CAC7B,gBAA2D,EAC3D,OAAe,EACf,QAAmB,EACnB,QAAmB;IAEnB,MAAM,QAAQ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E,CAAC,CAAA;IAEN,OAAO,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAA;AACvC,CAAC;AAvCD,wDAuCC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Contract, ethers } from 'ethers';
|
|
2
|
+
/**
|
|
3
|
+
* A react hook that 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 useRealWorldReceivableContract(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.useRealWorldReceivableContract = 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 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 useRealWorldReceivableContract(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
|
+
return (0, useContract_1.useContract)(realWorldReceivable, shared_1.REAL_WORLD_RECEIVABLE_ABI, signerOrProvider);
|
|
18
|
+
}
|
|
19
|
+
exports.useRealWorldReceivableContract = useRealWorldReceivableContract;
|
|
20
|
+
//# sourceMappingURL=useRealWorldReceivableContract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useRealWorldReceivableContract.js","sourceRoot":"","sources":["../../../src/hooks/useRealWorldReceivableContract.ts"],"names":[],"mappings":";;;AACA,iDAK6B;AAE7B,+CAA2C;AAE3C;;;;;;;GAOG;AACH,SAAgB,8BAA8B,CAC5C,gBAA2D,EAC3D,OAAe;;IAEf,MAAM,mBAAmB,GACvB,MAAA,kCAAyB,CAAC,OAAO,CAAC,0CAChC,+BAAsB,CAAC,mBAAmB,CAC3C,CAAA;IAEH,OAAO,IAAA,yBAAW,EAChB,mBAAmB,EACnB,kCAAyB,EACzB,gBAAgB,CACjB,CAAA;AACH,CAAC;AAdD,wEAcC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./helpers"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./hooks"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./services"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./utils"), exports);
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;AAAA,oDAAyB;AACzB,kDAAuB;AACvB,qDAA0B;AAC1B,kDAAuB"}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import type { FundResponse, UploadResponse } from '@bundlr-network/client/build/cjs/common/types';
|
|
2
|
+
import { Web3Provider } from '@ethersproject/providers';
|
|
3
|
+
/**
|
|
4
|
+
* The configuration for Bundlr network instances
|
|
5
|
+
*
|
|
6
|
+
* @typedef {Object} BundlrConfig
|
|
7
|
+
* @memberof ARWeaveService
|
|
8
|
+
* @property {string} nodeUrl - The Bundlr node URL to use.
|
|
9
|
+
* @property {string} currency - The currency to pay for uploads with.
|
|
10
|
+
* Please see https://docs.bundlr.network/sdk/using-other-currencies for all the supported currencies
|
|
11
|
+
* @property {string} [providerUrl] - The provider URL, required for devnets.
|
|
12
|
+
*/
|
|
13
|
+
export type BundlrConfig = {
|
|
14
|
+
nodeUrl: string;
|
|
15
|
+
currency: string;
|
|
16
|
+
providerUrl?: string;
|
|
17
|
+
};
|
|
18
|
+
/**
|
|
19
|
+
* Get the configuration for Bundlr network given a chain ID
|
|
20
|
+
*
|
|
21
|
+
* @function
|
|
22
|
+
* @memberof ARWeaveService
|
|
23
|
+
* @param {number} chainId - The chain ID.
|
|
24
|
+
* @returns {BundlrConfig} - The configuration for the Bundlr network.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getBundlrNetworkConfig(chainId: number): BundlrConfig;
|
|
27
|
+
/**
|
|
28
|
+
* Get a Bundlr instance for a specific network
|
|
29
|
+
*
|
|
30
|
+
* @async
|
|
31
|
+
* @function
|
|
32
|
+
* @memberof ARWeaveService
|
|
33
|
+
* @param {BundlrConfig} config - The configuration for the Bundlr network.
|
|
34
|
+
* @param {string} signer - The private key of the wallet to use Bundlr with.
|
|
35
|
+
* @returns The Bundlr instance
|
|
36
|
+
*/
|
|
37
|
+
declare function getBundlrInstance(config: BundlrConfig, signer: string): Promise<import("@bundlr-network/client/build/cjs/node/bundlr").default>;
|
|
38
|
+
/**
|
|
39
|
+
* Prefund the Bundlr network with the specified amount. Required if not lazy funding.
|
|
40
|
+
* Important note: The amount is denominated in the base unit of currency for that network.
|
|
41
|
+
* If you want to upload 5 Matic to the Bundlr node, pass in an amount of 5.
|
|
42
|
+
*
|
|
43
|
+
* @async
|
|
44
|
+
* @function
|
|
45
|
+
* @memberof ARWeaveService
|
|
46
|
+
* @param {BundlrConfig} config - The configuration for the Bundlr network.
|
|
47
|
+
* @param {string} signer - The private key of the wallet to send funds from.
|
|
48
|
+
* @param {number} amount - The amount to fund, denoted in whatever currency specified by the config (e.g. MATIC, ETH)
|
|
49
|
+
* @returns {Promise<FundResponse>} - The fund response.
|
|
50
|
+
*/
|
|
51
|
+
declare function prefundBundlr(config: BundlrConfig, signer: string, amount: number): Promise<FundResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* Store data on ARWeave using the Bundlr Network.
|
|
54
|
+
*
|
|
55
|
+
* @async
|
|
56
|
+
* @function
|
|
57
|
+
* @memberof ARWeaveService
|
|
58
|
+
* @param {BundlrConfig} config - Configuration object for the Bundlr instance.
|
|
59
|
+
* @param {Web3Provider | string} signerOrPrivateKey - Wallet object used for interacting with the Bundlr instance.
|
|
60
|
+
* If calling from a browser, this should be a `Web3Provider` instance. If calling from a Node.js
|
|
61
|
+
* environment, this should be a private key string.
|
|
62
|
+
* @param {Record<string, unknown>} data - The data to store in the Bundlr instance.
|
|
63
|
+
* @param {Array<{ name: string, value: string }>} tags - Array of tag objects with `name` and `value` properties.
|
|
64
|
+
* @param {boolean} [lazyFund=true] - Optional flag to fund the Bundlr instance lazily. If set to `false`, the
|
|
65
|
+
* Bundlr node should already be funded or else uploads will fail.
|
|
66
|
+
* @returns {Promise<UploadResponse>} Promise resolving with the upload response.
|
|
67
|
+
*/
|
|
68
|
+
declare function storeData(config: BundlrConfig, signerOrPrivateKey: Web3Provider | string, data: Record<string, unknown>, tags: {
|
|
69
|
+
name: string;
|
|
70
|
+
value: string;
|
|
71
|
+
}[], lazyFund?: boolean): Promise<UploadResponse>;
|
|
72
|
+
/**
|
|
73
|
+
* Helper method to query the Arweave network for receivables metadata previously uploaded.
|
|
74
|
+
*
|
|
75
|
+
* @async
|
|
76
|
+
* @function
|
|
77
|
+
* @memberof ARWeaveService
|
|
78
|
+
* @param {number} chainId - The chain ID.
|
|
79
|
+
* @param {string} sender - The sender tag to query.
|
|
80
|
+
* @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
|
|
81
|
+
* @returns {Promise<any>} Promise resolving with the queried data.
|
|
82
|
+
*/
|
|
83
|
+
declare function queryForMetadata(chainId: number, sender: string, referenceId: string): Promise<string | null>;
|
|
84
|
+
/**
|
|
85
|
+
* Helper method to fetch data from an ARWeave URL.
|
|
86
|
+
*
|
|
87
|
+
* @async
|
|
88
|
+
* @function
|
|
89
|
+
* @memberof ARWeaveService
|
|
90
|
+
* @param {string} url - The ARWeave metadata URL to query.
|
|
91
|
+
* @returns {Promise<JSON>} Promise resolving with the queried data.
|
|
92
|
+
*/
|
|
93
|
+
declare function fetchMetadataFromUrl(url: string): Promise<JSON | null>;
|
|
94
|
+
/**
|
|
95
|
+
* Helper method to get an ARWeave URI from an ARWeave ID.
|
|
96
|
+
*
|
|
97
|
+
* @async
|
|
98
|
+
* @function
|
|
99
|
+
* @memberof ARWeaveService
|
|
100
|
+
* @param {string} arweaveId - The ARWeave metadata ID.
|
|
101
|
+
* @returns {string} The ARWeave URI.
|
|
102
|
+
*/
|
|
103
|
+
declare function getURIFromARWeaveId(arweaveId: string): string;
|
|
104
|
+
/**
|
|
105
|
+
* An object that contains functions to interact with Huma-related data stored on ARWeave
|
|
106
|
+
* @namespace ARWeaveService
|
|
107
|
+
*/
|
|
108
|
+
export declare const ARWeaveService: {
|
|
109
|
+
queryForMetadata: typeof queryForMetadata;
|
|
110
|
+
storeData: typeof storeData;
|
|
111
|
+
prefundBundlr: typeof prefundBundlr;
|
|
112
|
+
getBundlrNetworkConfig: typeof getBundlrNetworkConfig;
|
|
113
|
+
getBundlrInstance: typeof getBundlrInstance;
|
|
114
|
+
fetchMetadataFromUrl: typeof fetchMetadataFromUrl;
|
|
115
|
+
getURIFromARWeaveId: typeof getURIFromARWeaveId;
|
|
116
|
+
};
|
|
117
|
+
export {};
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ARWeaveService = exports.getBundlrNetworkConfig = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const client_1 = tslib_1.__importDefault(require("@bundlr-network/client"));
|
|
6
|
+
const axios_1 = tslib_1.__importDefault(require("axios"));
|
|
7
|
+
const graphql_request_1 = tslib_1.__importStar(require("graphql-request"));
|
|
8
|
+
/**
|
|
9
|
+
* Get the configuration for Bundlr network given a chain ID
|
|
10
|
+
*
|
|
11
|
+
* @function
|
|
12
|
+
* @memberof ARWeaveService
|
|
13
|
+
* @param {number} chainId - The chain ID.
|
|
14
|
+
* @returns {BundlrConfig} - The configuration for the Bundlr network.
|
|
15
|
+
*/
|
|
16
|
+
function getBundlrNetworkConfig(chainId) {
|
|
17
|
+
switch (chainId) {
|
|
18
|
+
case 5: // Goerli
|
|
19
|
+
return {
|
|
20
|
+
nodeUrl: 'https://devnet.bundlr.network',
|
|
21
|
+
currency: 'ethereum',
|
|
22
|
+
providerUrl: 'https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161',
|
|
23
|
+
};
|
|
24
|
+
case 80001: // Mumbai
|
|
25
|
+
return {
|
|
26
|
+
nodeUrl: 'https://devnet.bundlr.network',
|
|
27
|
+
currency: 'matic',
|
|
28
|
+
providerUrl: 'https://rpc.ankr.com/polygon_mumbai',
|
|
29
|
+
};
|
|
30
|
+
case 137: // Matic
|
|
31
|
+
return {
|
|
32
|
+
nodeUrl: 'https://node1.bundlr.network',
|
|
33
|
+
currency: 'matic',
|
|
34
|
+
};
|
|
35
|
+
default:
|
|
36
|
+
return {
|
|
37
|
+
nodeUrl: '',
|
|
38
|
+
currency: '',
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.getBundlrNetworkConfig = getBundlrNetworkConfig;
|
|
43
|
+
/**
|
|
44
|
+
* Get a Bundlr instance for a specific network
|
|
45
|
+
*
|
|
46
|
+
* @async
|
|
47
|
+
* @function
|
|
48
|
+
* @memberof ARWeaveService
|
|
49
|
+
* @param {BundlrConfig} config - The configuration for the Bundlr network.
|
|
50
|
+
* @param {string} signer - The private key of the wallet to use Bundlr with.
|
|
51
|
+
* @returns The Bundlr instance
|
|
52
|
+
*/
|
|
53
|
+
async function getBundlrInstance(config, signer) {
|
|
54
|
+
const bundlr = new client_1.default(config.nodeUrl, config.currency, signer, config.providerUrl
|
|
55
|
+
? {
|
|
56
|
+
providerUrl: config.providerUrl,
|
|
57
|
+
}
|
|
58
|
+
: undefined);
|
|
59
|
+
await bundlr.ready();
|
|
60
|
+
return bundlr;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Prefund the Bundlr network with the specified amount. Required if not lazy funding.
|
|
64
|
+
* Important note: The amount is denominated in the base unit of currency for that network.
|
|
65
|
+
* If you want to upload 5 Matic to the Bundlr node, pass in an amount of 5.
|
|
66
|
+
*
|
|
67
|
+
* @async
|
|
68
|
+
* @function
|
|
69
|
+
* @memberof ARWeaveService
|
|
70
|
+
* @param {BundlrConfig} config - The configuration for the Bundlr network.
|
|
71
|
+
* @param {string} signer - The private key of the wallet to send funds from.
|
|
72
|
+
* @param {number} amount - The amount to fund, denoted in whatever currency specified by the config (e.g. MATIC, ETH)
|
|
73
|
+
* @returns {Promise<FundResponse>} - The fund response.
|
|
74
|
+
*/
|
|
75
|
+
async function prefundBundlr(config,
|
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
77
|
+
signer, amount) {
|
|
78
|
+
const bundlr = new client_1.default(config.nodeUrl, config.currency, signer, config.providerUrl
|
|
79
|
+
? {
|
|
80
|
+
providerUrl: config.providerUrl,
|
|
81
|
+
}
|
|
82
|
+
: undefined);
|
|
83
|
+
await bundlr.ready();
|
|
84
|
+
// Convert currency to its atomic units (e.g. MATIC -> wei)
|
|
85
|
+
const atomicAmount = bundlr.utils.toAtomic(amount);
|
|
86
|
+
return bundlr.fund(atomicAmount);
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Store data on ARWeave using the Bundlr Network.
|
|
90
|
+
*
|
|
91
|
+
* @async
|
|
92
|
+
* @function
|
|
93
|
+
* @memberof ARWeaveService
|
|
94
|
+
* @param {BundlrConfig} config - Configuration object for the Bundlr instance.
|
|
95
|
+
* @param {Web3Provider | string} signerOrPrivateKey - Wallet object used for interacting with the Bundlr instance.
|
|
96
|
+
* If calling from a browser, this should be a `Web3Provider` instance. If calling from a Node.js
|
|
97
|
+
* environment, this should be a private key string.
|
|
98
|
+
* @param {Record<string, unknown>} data - The data to store in the Bundlr instance.
|
|
99
|
+
* @param {Array<{ name: string, value: string }>} tags - Array of tag objects with `name` and `value` properties.
|
|
100
|
+
* @param {boolean} [lazyFund=true] - Optional flag to fund the Bundlr instance lazily. If set to `false`, the
|
|
101
|
+
* Bundlr node should already be funded or else uploads will fail.
|
|
102
|
+
* @returns {Promise<UploadResponse>} Promise resolving with the upload response.
|
|
103
|
+
*/
|
|
104
|
+
async function storeData(config, signerOrPrivateKey, data, tags, lazyFund = true) {
|
|
105
|
+
const bundlr = new client_1.default(config.nodeUrl, config.currency, signerOrPrivateKey, config.providerUrl
|
|
106
|
+
? {
|
|
107
|
+
providerUrl: config.providerUrl,
|
|
108
|
+
}
|
|
109
|
+
: undefined);
|
|
110
|
+
await bundlr.ready();
|
|
111
|
+
const dataStr = JSON.stringify(data);
|
|
112
|
+
if (lazyFund) {
|
|
113
|
+
const size = Buffer.byteLength(dataStr);
|
|
114
|
+
const price = await bundlr.getPrice(size);
|
|
115
|
+
// Add a buffer of 20% to account for fluctuations in the price
|
|
116
|
+
const priceWithBuffer = price.multipliedBy(1.2).integerValue();
|
|
117
|
+
console.log(`Funding bundlr with ${priceWithBuffer} ${config.currency} to upload data`);
|
|
118
|
+
await bundlr.fund(priceWithBuffer);
|
|
119
|
+
}
|
|
120
|
+
return bundlr.upload(dataStr, { tags });
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Helper method to query the Arweave network for receivables metadata previously uploaded.
|
|
124
|
+
*
|
|
125
|
+
* @async
|
|
126
|
+
* @function
|
|
127
|
+
* @memberof ARWeaveService
|
|
128
|
+
* @param {number} chainId - The chain ID.
|
|
129
|
+
* @param {string} sender - The sender tag to query.
|
|
130
|
+
* @param {string} referenceId - The referenceId tag to query, whatever was used when uploading the metadata.
|
|
131
|
+
* @returns {Promise<any>} Promise resolving with the queried data.
|
|
132
|
+
*/
|
|
133
|
+
async function queryForMetadata(chainId, sender, referenceId) {
|
|
134
|
+
var _a, _b, _c, _d;
|
|
135
|
+
const config = getBundlrNetworkConfig(chainId);
|
|
136
|
+
const query = (0, graphql_request_1.gql) `
|
|
137
|
+
query ArweaveHumaMetadataQuery($sender: String!, $referenceId: String!) {
|
|
138
|
+
transactions(
|
|
139
|
+
owners: [$sender]
|
|
140
|
+
tags: [
|
|
141
|
+
{ name: "appName", values: ["HumaFinance"] }
|
|
142
|
+
{ name: "referenceId", values: [$referenceId] }
|
|
143
|
+
]
|
|
144
|
+
) {
|
|
145
|
+
edges {
|
|
146
|
+
node {
|
|
147
|
+
id
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
`;
|
|
153
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
154
|
+
const data = await (0, graphql_request_1.default)(`${config.nodeUrl}/graphql`, query, {
|
|
155
|
+
sender,
|
|
156
|
+
referenceId,
|
|
157
|
+
});
|
|
158
|
+
return (_d = (_c = (_b = (_a = data === null || data === void 0 ? void 0 : data.transactions) === null || _a === void 0 ? void 0 : _a.edges) === null || _b === void 0 ? void 0 : _b[0]) === null || _c === void 0 ? void 0 : _c.node) === null || _d === void 0 ? void 0 : _d.id;
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Helper method to fetch data from an ARWeave URL.
|
|
162
|
+
*
|
|
163
|
+
* @async
|
|
164
|
+
* @function
|
|
165
|
+
* @memberof ARWeaveService
|
|
166
|
+
* @param {string} url - The ARWeave metadata URL to query.
|
|
167
|
+
* @returns {Promise<JSON>} Promise resolving with the queried data.
|
|
168
|
+
*/
|
|
169
|
+
async function fetchMetadataFromUrl(url) {
|
|
170
|
+
try {
|
|
171
|
+
const response = await axios_1.default.get(url);
|
|
172
|
+
return response.data;
|
|
173
|
+
}
|
|
174
|
+
catch (error) {
|
|
175
|
+
console.error('Error fetching data:', error);
|
|
176
|
+
return null;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Helper method to get an ARWeave URI from an ARWeave ID.
|
|
181
|
+
*
|
|
182
|
+
* @async
|
|
183
|
+
* @function
|
|
184
|
+
* @memberof ARWeaveService
|
|
185
|
+
* @param {string} arweaveId - The ARWeave metadata ID.
|
|
186
|
+
* @returns {string} The ARWeave URI.
|
|
187
|
+
*/
|
|
188
|
+
function getURIFromARWeaveId(arweaveId) {
|
|
189
|
+
return `https://arweave.net/${arweaveId}`;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* An object that contains functions to interact with Huma-related data stored on ARWeave
|
|
193
|
+
* @namespace ARWeaveService
|
|
194
|
+
*/
|
|
195
|
+
exports.ARWeaveService = {
|
|
196
|
+
queryForMetadata,
|
|
197
|
+
storeData,
|
|
198
|
+
prefundBundlr,
|
|
199
|
+
getBundlrNetworkConfig,
|
|
200
|
+
getBundlrInstance,
|
|
201
|
+
fetchMetadataFromUrl,
|
|
202
|
+
getURIFromARWeaveId,
|
|
203
|
+
};
|
|
204
|
+
//# sourceMappingURL=ARWeaveService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ARWeaveService.js","sourceRoot":"","sources":["../../../src/services/ARWeaveService.ts"],"names":[],"mappings":";;;;AAAA,4EAA2C;AAM3C,0DAAyB;AACzB,2EAA8C;AAkB9C;;;;;;;GAOG;AACH,SAAgB,sBAAsB,CAAC,OAAe;IACpD,QAAQ,OAAO,EAAE;QACf,KAAK,CAAC,EAAE,SAAS;YACf,OAAO;gBACL,O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;;GAgBhB,CAAA;IAED,8DAA8D;IAC9D,MAAM,IAAI,GAAQ,MAAM,IAAA,yBAAO,EAAC,GAAG,MAAM,CAAC,OAAO,UAAU,EAAE,KAAK,EAAE;QAClE,MAAM;QACN,WAAW;KACZ,CAAC,CAAA;IAEF,OAAO,MAAA,MAAA,MAAA,MAAA,IAAI,aAAJ,IAAI,uBAAJ,IAAI,CAAE,YAAY,0CAAE,KAAK,0CAAG,CAAC,CAAC,0CAAE,IAAI,0CAAE,EAAE,CAAA;AACjD,CAAC;AAED;;;;;;;;GAQG;AACH,KAAK,UAAU,oBAAoB,CAAC,GAAW;IAC7C,IAAI;QACF,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACrC,OAAO,QAAQ,CAAC,IAAI,CAAA;KACrB;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAA;QAC5C,OAAO,IAAI,CAAA;KACZ;AACH,CAAC;AAED;;;;;;;;GAQG;AACH,SAAS,mBAAmB,CAAC,SAAiB;IAC5C,OAAO,uBAAuB,SAAS,EAAE,CAAA;AAC3C,CAAC;AAED;;;GAGG;AACU,QAAA,cAAc,GAAG;IAC5B,gBAAgB;IAChB,SAAS;IACT,aAAa;IACb,sBAAsB;IACtB,iBAAiB;IACjB,oBAAoB;IACpB,mBAAmB;CACpB,CAAA"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EAPayload, EAPreapprovalPayload } from '@huma-finance/shared';
|
|
2
|
+
/**
|
|
3
|
+
* Object representing the response to the underwriting approval request.
|
|
4
|
+
* @typedef {Object} ApprovalResult
|
|
5
|
+
*/
|
|
6
|
+
/**
|
|
7
|
+
* Object representing an invoice payload for underwriting approval.
|
|
8
|
+
*
|
|
9
|
+
* @typedef {Object} EAPayload
|
|
10
|
+
*/
|
|
11
|
+
export type { ApprovalResult, EAPayload } from '@huma-finance/shared';
|
|
12
|
+
/**
|
|
13
|
+
* An object that contains functions to interact with Huma's EAVerse service.
|
|
14
|
+
*
|
|
15
|
+
* @namespace EAService
|
|
16
|
+
*/
|
|
17
|
+
export declare const EAService: {
|
|
18
|
+
approve: (payload: EAPayload, chainId: number) => Promise<import("@huma-finance/shared").Approval>;
|
|
19
|
+
preapprove: (payload: EAPreapprovalPayload, chainId: number) => Promise<import("@huma-finance/shared").PreapprovalResult>;
|
|
20
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.EAService = void 0;
|
|
4
|
+
const shared_1 = require("@huma-finance/shared");
|
|
5
|
+
/**
|
|
6
|
+
* Submits a credit underwriting request to Huma's EAVerse. This approves a creditline
|
|
7
|
+
* in Huma's pools that can be drawn down by the borrower.
|
|
8
|
+
*
|
|
9
|
+
* @memberof EAService
|
|
10
|
+
* @param {EAPayload} payload The payload for the underwrite approval.
|
|
11
|
+
* @param {number} chainId The chain ID.
|
|
12
|
+
* @returns {Promise<Approval>} Promise that returns the approval on success.
|
|
13
|
+
* @throws {EARejectionError} If the underwrite approval is rejected.
|
|
14
|
+
*/
|
|
15
|
+
const approve = async (payload, chainId) => shared_1.EAService.approve(payload, chainId);
|
|
16
|
+
/**
|
|
17
|
+
* Checks whether or not a credit underwriting request to Huma's EAVerse would be approved.
|
|
18
|
+
* Note that this does not approve a creditline in Huma's pools and an approve call is still required.
|
|
19
|
+
*
|
|
20
|
+
* @param {EAPreapprovalPayload} payload The payload for the underwrite approval.
|
|
21
|
+
* @param {number} chainId The chain ID.
|
|
22
|
+
* @returns {Promise<Approval>} Promise that returns the approval on success.
|
|
23
|
+
*/
|
|
24
|
+
const preapprove = async (payload, chainId) => shared_1.EAService.preapprove(payload, chainId);
|
|
25
|
+
/**
|
|
26
|
+
* An object that contains functions to interact with Huma's EAVerse service.
|
|
27
|
+
*
|
|
28
|
+
* @namespace EAService
|
|
29
|
+
*/
|
|
30
|
+
exports.EAService = {
|
|
31
|
+
approve,
|
|
32
|
+
preapprove,
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=EAService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EAService.js","sourceRoot":"","sources":["../../../src/services/EAService.ts"],"names":[],"mappings":";;;AAAA,iDAI6B;AAa7B;;;;;;;;;GASG;AACH,MAAM,OAAO,GAAG,KAAK,EAAE,OAAkB,EAAE,OAAe,EAAE,EAAE,CAC5D,kBAAiB,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AAE7C;;;;;;;GAOG;AACH,MAAM,UAAU,GAAG,KAAK,EAAE,OAA6B,EAAE,OAAe,EAAE,EAAE,CAC1E,kBAAiB,CAAC,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;AAEhD;;;;GAIG;AACU,QAAA,SAAS,GAAG;IACvB,OAAO;IACP,UAAU;CACX,CAAA"}
|