@huma-finance/sdk 0.0.6-alpha.0
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/LICENSE +661 -0
- package/README.md +15 -0
- package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.d.ts +9 -0
- package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js +21 -0
- package/dist/cjs/helpers/BaseCreditPoolReceivableContractHelper.js.map +1 -0
- package/dist/cjs/helpers/index.d.ts +1 -0
- package/dist/cjs/helpers/index.js +5 -0
- package/dist/cjs/helpers/index.js.map +1 -0
- package/dist/cjs/hooks/index.d.ts +5 -0
- package/dist/cjs/hooks/index.js +9 -0
- package/dist/cjs/hooks/index.js.map +1 -0
- package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.d.ts +9 -0
- package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js +19 -0
- package/dist/cjs/hooks/useBaseCreditPoolReceivableContract.js.map +1 -0
- package/dist/cjs/hooks/useContract.d.ts +11 -0
- package/dist/cjs/hooks/useContract.js +29 -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 +24 -0
- package/dist/cjs/hooks/useERC20TransferableReceivableContract.js.map +1 -0
- package/dist/cjs/hooks/usePoolContract.d.ts +53 -0
- package/dist/cjs/hooks/usePoolContract.js +49 -0
- package/dist/cjs/hooks/usePoolContract.js.map +1 -0
- 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 -0
- package/dist/cjs/index.js +8 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/services/ARWeaveService.d.ts +62 -0
- package/dist/cjs/services/ARWeaveService.js +141 -0
- package/dist/cjs/services/ARWeaveService.js.map +1 -0
- package/dist/cjs/services/EAService.d.ts +13 -0
- package/dist/cjs/services/EAService.js +17 -0
- package/dist/cjs/services/EAService.js.map +1 -0
- package/dist/cjs/services/ReceivableService.d.ts +76 -0
- package/dist/cjs/services/ReceivableService.js +156 -0
- package/dist/cjs/services/ReceivableService.js.map +1 -0
- package/dist/cjs/services/SubgraphService.d.ts +39 -0
- package/dist/cjs/services/SubgraphService.js +92 -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 +14 -0
- package/dist/cjs/utils/chain.js +34 -0
- package/dist/cjs/utils/chain.js.map +1 -0
- package/dist/cjs/utils/index.d.ts +3 -0
- package/dist/cjs/utils/index.js +7 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/poolInfo.d.ts +9 -0
- package/dist/cjs/utils/poolInfo.js +14 -0
- package/dist/cjs/utils/poolInfo.js.map +1 -0
- package/dist/cjs/utils/web3.d.ts +4 -0
- package/dist/cjs/utils/web3.js +29 -0
- package/dist/cjs/utils/web3.js.map +1 -0
- package/dist/helpers/BaseCreditPoolReceivableContractHelper.d.ts +9 -0
- package/dist/helpers/BaseCreditPoolReceivableContractHelper.js +17 -0
- package/dist/helpers/BaseCreditPoolReceivableContractHelper.js.map +1 -0
- package/dist/helpers/index.d.ts +1 -0
- package/dist/helpers/index.js +2 -0
- package/dist/helpers/index.js.map +1 -0
- package/dist/hooks/index.d.ts +5 -0
- package/dist/hooks/index.js +6 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useBaseCreditPoolReceivableContract.d.ts +9 -0
- package/dist/hooks/useBaseCreditPoolReceivableContract.js +15 -0
- package/dist/hooks/useBaseCreditPoolReceivableContract.js.map +1 -0
- package/dist/hooks/useContract.d.ts +11 -0
- package/dist/hooks/useContract.js +25 -0
- package/dist/hooks/useContract.js.map +1 -0
- package/dist/hooks/useERC20TransferableReceivableContract.d.ts +12 -0
- package/dist/hooks/useERC20TransferableReceivableContract.js +20 -0
- package/dist/hooks/useERC20TransferableReceivableContract.js.map +1 -0
- 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 +53 -0
- package/dist/hooks/usePoolContract.js +44 -0
- package/dist/hooks/usePoolContract.js.map +1 -0
- 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 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/services/ARWeaveService.d.ts +62 -0
- package/dist/services/ARWeaveService.js +133 -0
- package/dist/services/ARWeaveService.js.map +1 -0
- package/dist/services/EAService.d.ts +13 -0
- package/dist/services/EAService.js +14 -0
- package/dist/services/EAService.js.map +1 -0
- package/dist/services/ReceivableService.d.ts +76 -0
- package/dist/services/ReceivableService.js +149 -0
- package/dist/services/ReceivableService.js.map +1 -0
- package/dist/services/SubgraphService.d.ts +39 -0
- package/dist/services/SubgraphService.js +86 -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 +14 -0
- package/dist/utils/chain.js +29 -0
- package/dist/utils/chain.js.map +1 -0
- package/dist/utils/index.d.ts +3 -0
- package/dist/utils/index.js +4 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/poolInfo.d.ts +9 -0
- package/dist/utils/poolInfo.js +10 -0
- package/dist/utils/poolInfo.js.map +1 -0
- package/dist/utils/web3.d.ts +4 -0
- package/dist/utils/web3.js +24 -0
- package/dist/utils/web3.js.map +1 -0
- package/package.json +86 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { BASE_CREDIT_POOL_RECEIVABLE_ABI, SupplementaryContracts, SupplementaryContractsMap, } from '@00labs/huma-shared';
|
|
2
|
+
import { useContract } from './useContract';
|
|
3
|
+
/**
|
|
4
|
+
* A react hook that returns an ethers contract instance for the BaseCreditPoolReceivable contract
|
|
5
|
+
* associated with the given pool name on the current chain.
|
|
6
|
+
*
|
|
7
|
+
* @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider The provider or signer instance to use for the contract.
|
|
8
|
+
* @returns {Contract | null} A contract instance for the BaseCreditPoolReceivable contract or null if it could not be found.
|
|
9
|
+
*/
|
|
10
|
+
export function useBaseCreditPoolReceivableContract(signerOrProvider, chainId) {
|
|
11
|
+
var _a;
|
|
12
|
+
const baseCreditPoolReceivable = (_a = SupplementaryContractsMap[chainId]) === null || _a === void 0 ? void 0 : _a[SupplementaryContracts.BaseCreditPoolReceivable];
|
|
13
|
+
return useContract(baseCreditPoolReceivable, BASE_CREDIT_POOL_RECEIVABLE_ABI, signerOrProvider);
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=useBaseCreditPoolReceivableContract.js.map
|
|
@@ -0,0 +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,qBAAqB,CAAA;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAE3C;;;;;;GAMG;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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
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
|
+
* @param address - The address of the smart contract instance.
|
|
6
|
+
* @param ABI - The ABI of the smart contract.
|
|
7
|
+
* @param signerOrProvider - The signer or provider used to sign transactions or retrieve blockchain data.
|
|
8
|
+
* 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.
|
|
10
|
+
*/
|
|
11
|
+
export declare function useContract<T extends Contract = Contract>(address: string | null | undefined, ABI: any, signerOrProvider: ethers.providers.Provider | ethers.Signer): T | null;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { getContract } from '../utils/web3';
|
|
3
|
+
/**
|
|
4
|
+
* Custom hook for creating an ethers instance of a smart contract.
|
|
5
|
+
* @param address - The address of the smart contract instance.
|
|
6
|
+
* @param ABI - The ABI of the smart contract.
|
|
7
|
+
* @param signerOrProvider - The signer or provider used to sign transactions or retrieve blockchain data.
|
|
8
|
+
* 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.
|
|
10
|
+
*/
|
|
11
|
+
export function useContract(address,
|
|
12
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
13
|
+
ABI, signerOrProvider) {
|
|
14
|
+
return useMemo(() => {
|
|
15
|
+
if (!address || !ABI || !signerOrProvider)
|
|
16
|
+
return null;
|
|
17
|
+
try {
|
|
18
|
+
return getContract(address, ABI, signerOrProvider);
|
|
19
|
+
}
|
|
20
|
+
catch (error) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}, [address, ABI, signerOrProvider]);
|
|
24
|
+
}
|
|
25
|
+
//# sourceMappingURL=useContract.js.map
|
|
@@ -0,0 +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;;;;;;;GAOG;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"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { JsonRpcProvider, JsonRpcSigner } from '@ethersproject/providers';
|
|
2
|
+
import { Contract } from 'ethers';
|
|
3
|
+
import { POOL_NAME } from '@00labs/huma-shared';
|
|
4
|
+
/**
|
|
5
|
+
* A react hook that returns an ethers contract instance for the ERC20TransferableReceivable contract
|
|
6
|
+
* associated with the given pool name on the current chain.
|
|
7
|
+
*
|
|
8
|
+
* @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider The provider or signer instance to use for the contract.
|
|
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: JsonRpcProvider | JsonRpcSigner, poolName: POOL_NAME): Contract | null;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { ERC20_TRANSFERABLE_RECEIVABLE_ABI, POOL_TYPE, PoolContractMap, } from '@00labs/huma-shared';
|
|
2
|
+
import { useContract } from './useContract';
|
|
3
|
+
import { getChainIdFromJsonSignerOrProvider } from '../utils/chain';
|
|
4
|
+
/**
|
|
5
|
+
* A react hook that returns an ethers contract instance for the ERC20TransferableReceivable contract
|
|
6
|
+
* associated with the given pool name on the current chain.
|
|
7
|
+
*
|
|
8
|
+
* @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider The provider or signer instance to use for the contract.
|
|
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 function useERC20TransferableReceivableContract(signerOrProvider, poolName) {
|
|
13
|
+
var _a, _b, _c;
|
|
14
|
+
const chainId = getChainIdFromJsonSignerOrProvider(signerOrProvider);
|
|
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;
|
|
18
|
+
return useContract(TransferableReceivableAddress, ERC20_TRANSFERABLE_RECEIVABLE_ABI, signerOrProvider);
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=useERC20TransferableReceivableContract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useERC20TransferableReceivableContract.js","sourceRoot":"","sources":["../../src/hooks/useERC20TransferableReceivableContract.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,iCAAiC,EAGjC,SAAS,EACT,eAAe,GAChB,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAC3C,OAAO,EAAE,kCAAkC,EAAE,MAAM,gBAAgB,CAAA;AAEnE;;;;;;;GAOG;AACH,MAAM,UAAU,sCAAsC,CACpD,gBAAiD,EACjD,QAAmB;;IAEnB,MAAM,OAAO,GAAG,kCAAkC,CAAC,gBAAgB,CAAC,CAAA;IAEpE,MAAM,6BAA6B,GAAG,OAAO;QAC3C,CAAC,CAAC,MAAA,MAAA,MAAA,eAAe,CAAC,OAAO,CAAC,0CAAG,SAAS,CAAC,OAAO,CAAC,0CAAG,QAAQ,CAAC,0CAAE,YAAY;QACzE,CAAC,CAAC,IAAI,CAAA;IAER,OAAO,WAAW,CAChB,6BAA6B,EAC7B,iCAAiC,EACjC,gBAAgB,CACjB,CAAA;AACH,CAAC"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usePool.js","sourceRoot":"","sources":["../../src/hooks/usePool.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { BigNumber } from '@ethersproject/bignumber';
|
|
2
|
+
import { Contract, ethers } from 'ethers';
|
|
3
|
+
import { POOL_NAME, POOL_TYPE } from '@00labs/huma-shared';
|
|
4
|
+
/**
|
|
5
|
+
* A react hook that returns a contract instance of a specific pool using an ethers JsonRpcProvider or JsonRpcSigner.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type of the contract.
|
|
8
|
+
* @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - A JsonRpcProvider or JsonRpcSigner instance.
|
|
9
|
+
* @param {POOL_NAME} poolName - The name of the pool.
|
|
10
|
+
* @param {POOL_TYPE} poolType - The type of the pool.
|
|
11
|
+
* @returns {T} A contract instance of the specific pool.
|
|
12
|
+
*/
|
|
13
|
+
export declare function usePoolContract<T extends Contract>(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE): T | null;
|
|
14
|
+
/**
|
|
15
|
+
* CreditRecordDetails type object representing the details of a credit line.
|
|
16
|
+
* @typedef {Object} CreditRecordDetails
|
|
17
|
+
* @property {number} aprInBps - The APR (annual percentage rate) in basis points.
|
|
18
|
+
* @property {BigNumber} correction - adjustment of interest over or under-counted because of drawdown
|
|
19
|
+
* or principal payment in the middle of a billing period
|
|
20
|
+
* @property {BigNumber} creditLimit - The credit limit in the pools base currency.
|
|
21
|
+
* @property {BigNumber} defaultAmount - The amount of the default, if any.
|
|
22
|
+
* @property {BigNumber} dueDate - The due date of the next payment.
|
|
23
|
+
* @property {BigNumber} feesAndInterestDue - The fees and interest due.
|
|
24
|
+
* @property {number} intervalInDays - The interval in days between payment periods.
|
|
25
|
+
* @property {number} missedPeriods - The number of missed periods.
|
|
26
|
+
* @property {number} remainingPeriods - The number of remaining periods before this credit line is considered paid off.
|
|
27
|
+
* @property {number} state - The state of the factorization. Please see the CreditState in huma-contracts for more details.
|
|
28
|
+
* @property {BigNumber} totalDue - The total due amount of this credit line.
|
|
29
|
+
* @property {BigNumber} unbilledPrincipal - The unbilled principal of the next payment.
|
|
30
|
+
*/
|
|
31
|
+
export type CreditRecordDetails = {
|
|
32
|
+
aprInBps: number;
|
|
33
|
+
correction: BigNumber;
|
|
34
|
+
creditLimit: BigNumber;
|
|
35
|
+
defaultAmount: BigNumber;
|
|
36
|
+
dueDate: BigNumber;
|
|
37
|
+
feesAndInterestDue: BigNumber;
|
|
38
|
+
intervalInDays: number;
|
|
39
|
+
missedPeriods: number;
|
|
40
|
+
remainingPeriods: number;
|
|
41
|
+
state: number;
|
|
42
|
+
totalDue: BigNumber;
|
|
43
|
+
unbilledPrincipal: BigNumber;
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* 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
|
+
*
|
|
48
|
+
* @param {string} userAddress - The address of the user to get the credit record details for.
|
|
49
|
+
* @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The signer or provider object to use for the contract.
|
|
50
|
+
* @param {POOL_NAME} poolName - The name of the pool to get the credit record details for.
|
|
51
|
+
* @returns {Array<CreditRecordDetails | undefined, function():void>} An array containing the credit record details and a function to refresh the data.
|
|
52
|
+
*/
|
|
53
|
+
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,44 @@
|
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
import { useContract } from './useContract';
|
|
3
|
+
import { getPoolInfo } from '../utils/poolInfo';
|
|
4
|
+
/**
|
|
5
|
+
* A react hook that returns a contract instance of a specific pool using an ethers JsonRpcProvider or JsonRpcSigner.
|
|
6
|
+
*
|
|
7
|
+
* @template T - The type of the contract.
|
|
8
|
+
* @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - A JsonRpcProvider or JsonRpcSigner instance.
|
|
9
|
+
* @param {POOL_NAME} poolName - The name of the pool.
|
|
10
|
+
* @param {POOL_TYPE} poolType - The type of the pool.
|
|
11
|
+
* @returns {T} A contract instance of the specific pool.
|
|
12
|
+
*/
|
|
13
|
+
export function usePoolContract(signerOrProvider, chainId, poolName, poolType) {
|
|
14
|
+
const poolInfo = getPoolInfo(chainId, poolName, poolType);
|
|
15
|
+
return useContract(poolInfo === null || poolInfo === void 0 ? void 0 : poolInfo.pool, poolInfo === null || poolInfo === void 0 ? void 0 : poolInfo.poolAbi, signerOrProvider);
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* 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
|
+
*
|
|
20
|
+
* @param {string} userAddress - The address of the user to get the credit record details for.
|
|
21
|
+
* @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The signer or provider object to use for the contract.
|
|
22
|
+
* @param {POOL_NAME} poolName - The name of the pool to get the credit record details for.
|
|
23
|
+
* @returns {Array<CreditRecordDetails | undefined, function():void>} An array containing the credit record details and a function to refresh the data.
|
|
24
|
+
*/
|
|
25
|
+
export function useCreditRecordDetails(userAddress, signerOrProvider, chainId, poolName, poolType) {
|
|
26
|
+
const poolContract = usePoolContract(signerOrProvider, chainId, poolName, poolType);
|
|
27
|
+
const [creditRecordDetails, setCreditRecordDetails] = useState();
|
|
28
|
+
const [refreshCount, setRefreshCount] = useState(0);
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const fetchData = async () => {
|
|
31
|
+
if (poolContract && userAddress) {
|
|
32
|
+
const creditRecordMapping = await poolContract.creditRecordMapping(userAddress);
|
|
33
|
+
const creditRecordStaticMapping = await poolContract.creditRecordStaticMapping(userAddress);
|
|
34
|
+
setCreditRecordDetails(Object.assign(Object.assign({}, creditRecordMapping), creditRecordStaticMapping));
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
fetchData();
|
|
38
|
+
}, [userAddress, poolContract, refreshCount]);
|
|
39
|
+
const refresh = useCallback(() => {
|
|
40
|
+
setRefreshCount((pre) => pre + 1);
|
|
41
|
+
}, []);
|
|
42
|
+
return [creditRecordDetails, refresh];
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=usePoolContract.js.map
|
|
@@ -0,0 +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;;;;;;;;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;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;AAkCD;;;;;;;GAOG;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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { POOL_NAME, ReceivableFactoringPool } from '@00labs/huma-shared';
|
|
2
|
+
import { ethers } from 'ethers';
|
|
3
|
+
/**
|
|
4
|
+
* A react hook that returns the instance of the ReceivableFactoringPool contract for a given signer or provider and pool name.
|
|
5
|
+
*
|
|
6
|
+
* @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The signer or provider object to use for the contract.
|
|
7
|
+
* @param {POOL_NAME} poolName - The name of the pool to get the contract for. Check the type for more details.
|
|
8
|
+
* @returns {ReceivableFactoringPool} An ethers instance of the ReceivableFactoringPool contract.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useReceivableFactoringPoolContract(signerOrProvider: ethers.providers.Provider | ethers.Signer, chainId: number, poolName: POOL_NAME): ReceivableFactoringPool | null;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { POOL_TYPE, } from '@00labs/huma-shared';
|
|
2
|
+
import { usePoolContract } from './usePoolContract';
|
|
3
|
+
/**
|
|
4
|
+
* A react hook that returns the instance of the ReceivableFactoringPool contract for a given signer or provider and pool name.
|
|
5
|
+
*
|
|
6
|
+
* @param {JsonRpcProvider | JsonRpcSigner} signerOrProvider - The signer or provider object to use for the contract.
|
|
7
|
+
* @param {POOL_NAME} poolName - The name of the pool to get the contract for. Check the type for more details.
|
|
8
|
+
* @returns {ReceivableFactoringPool} An ethers instance of the ReceivableFactoringPool contract.
|
|
9
|
+
*/
|
|
10
|
+
export function useReceivableFactoringPoolContract(signerOrProvider, chainId, poolName) {
|
|
11
|
+
return usePoolContract(signerOrProvider, chainId, poolName, POOL_TYPE.Invoice);
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=useReceivableFactoringPoolContract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useReceivableFactoringPoolContract.js","sourceRoot":"","sources":["../../src/hooks/useReceivableFactoringPoolContract.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,SAAS,GAEV,MAAM,qBAAqB,CAAA;AAG5B,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAA;AAEnD;;;;;;GAMG;AACH,MAAM,UAAU,kCAAkC,CAChD,gBAA2D,EAC3D,OAAe,EACf,QAAmB;IAEnB,OAAO,eAAe,CACpB,gBAAgB,EAChB,OAAO,EACP,QAAQ,EACR,SAAS,CAAC,OAAO,CAClB,CAAA;AACH,CAAC"}
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAA;AACzB,cAAc,SAAS,CAAA;AACvB,cAAc,YAAY,CAAA;AAC1B,cAAc,SAAS,CAAA"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { FundResponse, UploadResponse } from '@bundlr-network/client/build/common/types';
|
|
2
|
+
import { Web3Provider } from '@ethersproject/providers';
|
|
3
|
+
import { POOL_NAME, POOL_TYPE } from '@00labs/huma-shared';
|
|
4
|
+
/**
|
|
5
|
+
* The configuration for Bundlr network instances
|
|
6
|
+
*/
|
|
7
|
+
export type BundlrConfig = {
|
|
8
|
+
nodeUrl: string;
|
|
9
|
+
currency: string;
|
|
10
|
+
providerUrl?: string;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* Get the configuration for Bundlr network given a chain ID.
|
|
14
|
+
*
|
|
15
|
+
* @function
|
|
16
|
+
* @param {number} chainId - The chain ID.
|
|
17
|
+
* @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
|
+
*/
|
|
22
|
+
export declare function getBundlrNetworkConfig(chainId: number): BundlrConfig;
|
|
23
|
+
/**
|
|
24
|
+
* Prefund the Bundlr network with the specified amount. Useful if not lazy funding.
|
|
25
|
+
*
|
|
26
|
+
* @async
|
|
27
|
+
* @function
|
|
28
|
+
* @param {BundlrConfig} config - The configuration for the Bundlr network.
|
|
29
|
+
* @param {any} wallet - The wallet to send funds from
|
|
30
|
+
* @param {number} amount - The amount to fund.
|
|
31
|
+
* @returns {Promise<FundResponse>} - The fund response.
|
|
32
|
+
*/
|
|
33
|
+
export declare function prefundBundlr(config: BundlrConfig, wallet: any, amount: number): Promise<FundResponse>;
|
|
34
|
+
/**
|
|
35
|
+
* Store data on ARWeave using the Bundlr Network.
|
|
36
|
+
* @async
|
|
37
|
+
* @function
|
|
38
|
+
* @param {BundlrConfig} config - Configuration object for the Bundlr instance.
|
|
39
|
+
* @param {Web3Provider | ethers.Signer} wallet - Wallet object used for interacting with the Bundlr instance.
|
|
40
|
+
* If calling from a browser, this should be a `Web3Provider` instance. If calling from a Node.js
|
|
41
|
+
* environment, this should be an `ethers.Signer` instance.
|
|
42
|
+
* @param {JSON} data - The data to store in the Bundlr instance.
|
|
43
|
+
* @param {Array<{ name: string, value: string }>} tags - Array of tag objects with `name` and `value` properties.
|
|
44
|
+
* @param {boolean} [lazyFund=true] - Optional flag to fund the Bundlr instance lazily. If set to `false`, the
|
|
45
|
+
* Bundlr node should already be funded or else uploads will fail.
|
|
46
|
+
* @returns {Promise<UploadResponse>} Promise resolving with the upload response.
|
|
47
|
+
*/
|
|
48
|
+
export declare function storeData(config: BundlrConfig, wallet: Web3Provider | string, data: JSON, tags: {
|
|
49
|
+
name: string;
|
|
50
|
+
value: string;
|
|
51
|
+
}[], lazyFund?: boolean): Promise<UploadResponse>;
|
|
52
|
+
/**
|
|
53
|
+
* Helper method to query the Arweave network for receivables metadata previously uploaded.
|
|
54
|
+
* @async
|
|
55
|
+
* @function
|
|
56
|
+
* @param {POOL_NAME} poolName - The pool name tag to query.
|
|
57
|
+
* @param {POOL_TYPE} poolType - The pool type tag to query.
|
|
58
|
+
* @param {string} sender - The sender tag to query.
|
|
59
|
+
* @param {string} internalID - The internal ID tag to query, whatever was used when uploading the metadata.
|
|
60
|
+
* @returns {Promise<any>} Promise resolving with the queried data.
|
|
61
|
+
*/
|
|
62
|
+
export declare function queryForMetadata(chainId: number, poolName: POOL_NAME, poolType: POOL_TYPE, sender: string, internalId: string): Promise<string | null>;
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import Bundlr from '@bundlr-network/client';
|
|
2
|
+
import request, { gql } from 'graphql-request';
|
|
3
|
+
/**
|
|
4
|
+
* Get the configuration for Bundlr network given a chain ID.
|
|
5
|
+
*
|
|
6
|
+
* @function
|
|
7
|
+
* @param {number} chainId - The chain ID.
|
|
8
|
+
* @returns {BundlrConfig} - The configuration for the Bundlr network.
|
|
9
|
+
* nodeUrl - The node URL of the Bundlr network to use.
|
|
10
|
+
* currency - The currency to pay for uploads with, if lazy funding.
|
|
11
|
+
* providerUrl - The provider URL, required for devnets.
|
|
12
|
+
*/
|
|
13
|
+
export function getBundlrNetworkConfig(chainId) {
|
|
14
|
+
switch (chainId) {
|
|
15
|
+
case 5:
|
|
16
|
+
return {
|
|
17
|
+
nodeUrl: 'https://devnet.bundlr.network',
|
|
18
|
+
currency: 'ethereum',
|
|
19
|
+
providerUrl: 'https://goerli.infura.io/v3/9aa3d95b3bc440fa88ea12eaa4456161',
|
|
20
|
+
};
|
|
21
|
+
case 80001:
|
|
22
|
+
return {
|
|
23
|
+
nodeUrl: 'https://devnet.bundlr.network',
|
|
24
|
+
currency: 'matic',
|
|
25
|
+
providerUrl: 'https://rpc-mumbai.matic.today',
|
|
26
|
+
};
|
|
27
|
+
default:
|
|
28
|
+
return {
|
|
29
|
+
nodeUrl: '',
|
|
30
|
+
currency: '',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Prefund the Bundlr network with the specified amount. Useful if not lazy funding.
|
|
36
|
+
*
|
|
37
|
+
* @async
|
|
38
|
+
* @function
|
|
39
|
+
* @param {BundlrConfig} config - The configuration for the Bundlr network.
|
|
40
|
+
* @param {any} wallet - The wallet to send funds from
|
|
41
|
+
* @param {number} amount - The amount to fund.
|
|
42
|
+
* @returns {Promise<FundResponse>} - The fund response.
|
|
43
|
+
*/
|
|
44
|
+
export async function prefundBundlr(config,
|
|
45
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
46
|
+
wallet, amount) {
|
|
47
|
+
const bundlr = new Bundlr(config.nodeUrl, config.currency, wallet, config.providerUrl
|
|
48
|
+
? {
|
|
49
|
+
providerUrl: config.providerUrl,
|
|
50
|
+
}
|
|
51
|
+
: undefined);
|
|
52
|
+
await bundlr.ready();
|
|
53
|
+
return bundlr.fund(amount);
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Store data on ARWeave using the Bundlr Network.
|
|
57
|
+
* @async
|
|
58
|
+
* @function
|
|
59
|
+
* @param {BundlrConfig} config - Configuration object for the Bundlr instance.
|
|
60
|
+
* @param {Web3Provider | ethers.Signer} wallet - Wallet object used for interacting with the Bundlr instance.
|
|
61
|
+
* If calling from a browser, this should be a `Web3Provider` instance. If calling from a Node.js
|
|
62
|
+
* environment, this should be an `ethers.Signer` instance.
|
|
63
|
+
* @param {JSON} data - The data to store in the Bundlr instance.
|
|
64
|
+
* @param {Array<{ name: string, value: string }>} tags - Array of tag objects with `name` and `value` properties.
|
|
65
|
+
* @param {boolean} [lazyFund=true] - Optional flag to fund the Bundlr instance lazily. If set to `false`, the
|
|
66
|
+
* Bundlr node should already be funded or else uploads will fail.
|
|
67
|
+
* @returns {Promise<UploadResponse>} Promise resolving with the upload response.
|
|
68
|
+
*/
|
|
69
|
+
export async function storeData(config, wallet, data, tags, lazyFund = true) {
|
|
70
|
+
const bundlr = new Bundlr(config.nodeUrl, config.currency, wallet, config.providerUrl
|
|
71
|
+
? {
|
|
72
|
+
providerUrl: config.providerUrl,
|
|
73
|
+
}
|
|
74
|
+
: undefined);
|
|
75
|
+
await bundlr.ready();
|
|
76
|
+
const dataStr = JSON.stringify(data);
|
|
77
|
+
if (lazyFund) {
|
|
78
|
+
const size = Buffer.byteLength(dataStr);
|
|
79
|
+
const price = await bundlr.getPrice(size);
|
|
80
|
+
// Add a buffer of 10% to account for fluctuations in the price
|
|
81
|
+
price.multipliedBy(1.1);
|
|
82
|
+
console.log(`Funding bundlr with ${price} ${config.currency} to upload data`);
|
|
83
|
+
await bundlr.fund(price);
|
|
84
|
+
}
|
|
85
|
+
return bundlr.upload(dataStr, { tags });
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Helper method to query the Arweave network for receivables metadata previously uploaded.
|
|
89
|
+
* @async
|
|
90
|
+
* @function
|
|
91
|
+
* @param {POOL_NAME} poolName - The pool name tag to query.
|
|
92
|
+
* @param {POOL_TYPE} poolType - The pool type tag to query.
|
|
93
|
+
* @param {string} sender - The sender tag to query.
|
|
94
|
+
* @param {string} internalID - The internal ID tag to query, whatever was used when uploading the metadata.
|
|
95
|
+
* @returns {Promise<any>} Promise resolving with the queried data.
|
|
96
|
+
*/
|
|
97
|
+
export async function queryForMetadata(chainId, poolName, poolType, sender, internalId) {
|
|
98
|
+
var _a, _b, _c, _d;
|
|
99
|
+
const config = getBundlrNetworkConfig(chainId);
|
|
100
|
+
const query = gql `
|
|
101
|
+
query ArweaveHumaMetadataQuery(
|
|
102
|
+
$poolName: String!
|
|
103
|
+
$poolType: String!
|
|
104
|
+
$sender: String!
|
|
105
|
+
$internalId: String!
|
|
106
|
+
) {
|
|
107
|
+
transactions(
|
|
108
|
+
owners: [$sender]
|
|
109
|
+
tags: [
|
|
110
|
+
{ name: "appName", values: ["HumaFinance"] }
|
|
111
|
+
{ name: "poolName", values: [$poolName] }
|
|
112
|
+
{ name: "poolType", values: [$poolType] }
|
|
113
|
+
{ name: "internalId", values: [$internalId] }
|
|
114
|
+
]
|
|
115
|
+
) {
|
|
116
|
+
edges {
|
|
117
|
+
node {
|
|
118
|
+
id
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
`;
|
|
124
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
125
|
+
const data = await request(`${config.nodeUrl}/graphql`, query, {
|
|
126
|
+
poolName,
|
|
127
|
+
poolType,
|
|
128
|
+
sender,
|
|
129
|
+
internalId,
|
|
130
|
+
});
|
|
131
|
+
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;
|
|
132
|
+
}
|
|
133
|
+
//# sourceMappingURL=ARWeaveService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ARWeaveService.js","sourceRoot":"","sources":["../../src/services/ARWeaveService.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,wBAAwB,CAAA;AAM3C,OAAO,OAAO,EAAE,EAAE,GAAG,EAAE,MAAM,iBAAiB,CAAA;AAY9C;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAe;IACpD,QAAQ,OAAO,EAAE;QACf,KAAK,CAAC;YACJ,OAAO;gBACL,OAAO,EAAE,+BAA+B;gBACxC,QAAQ,EAAE,UAAU;gBACpB,WAAW,EACT,8DAA8D;aACjE,CAAA;QACH,KAAK,KAAK;YACR,OAAO;gBACL,OAAO,EAAE,+BAA+B;gBACxC,QAAQ,EAAE,OAAO;gBACjB,WAAW,EAAE,gCAAgC;aAC9C,CAAA;QACH;YACE,OAAO;gBACL,OAAO,EAAE,EAAE;gBACX,QAAQ,EAAE,EAAE;aACb,CAAA;KACJ;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,aAAa,CACjC,MAAoB;AACpB,8DAA8D;AAC9D,MAAW,EACX,MAAc;IAEd,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,QAAQ,EACf,MAAM,EACN,MAAM,CAAC,WAAW;QAChB,CAAC,CAAC;YACE,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC;QACH,CAAC,CAAC,SAAS,CACd,CAAA;IACD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;IAEpB,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAA;AAC5B,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,MAAoB,EACpB,MAA6B,EAC7B,IAAU,EACV,IAAuC,EACvC,WAAoB,IAAI;IAExB,MAAM,MAAM,GAAG,IAAI,MAAM,CACvB,MAAM,CAAC,OAAO,EACd,MAAM,CAAC,QAAQ,EACf,MAAM,EACN,MAAM,CAAC,WAAW;QAChB,CAAC,CAAC;YACE,WAAW,EAAE,MAAM,CAAC,WAAW;SAChC;QACH,CAAC,CAAC,SAAS,CACd,CAAA;IACD,MAAM,MAAM,CAAC,KAAK,EAAE,CAAA;IAEpB,MAAM,OAAO,GAAG,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAA;IAEpC,IAAI,QAAQ,EAAE;QACZ,MAAM,IAAI,GAAG,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;QACvC,MAAM,KAAK,GAAG,MAAM,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;QAEzC,+DAA+D;QAC/D,KAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAA;QACvB,OAAO,CAAC,GAAG,CACT,uBAAuB,KAAK,IAAI,MAAM,CAAC,QAAQ,iBAAiB,CACjE,CAAA;QACD,MAAM,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAA;KACzB;IAED,OAAO,MAAM,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,CAAC,CAAA;AACzC,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,OAAe,EACf,QAAmB,EACnB,QAAmB,EACnB,MAAc,EACd,UAAkB;;IAGlB,MAAM,MAAM,GAAG,sBAAsB,CAAC,OAAO,CAAC,CAAA;IAC9C,MAAM,KAAK,GAAG,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBhB,CAAA;IAED,8DAA8D;IAC9D,MAAM,IAAI,GAAQ,MAAM,OAAO,CAAC,GAAG,MAAM,CAAC,OAAO,UAAU,EAAE,KAAK,EAAE;QAClE,QAAQ;QACR,QAAQ;QACR,MAAM;QACN,UAAU;KACX,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"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type { ApproveInfo, EAPayload } from '@00labs/huma-shared';
|
|
2
|
+
/**
|
|
3
|
+
* An object that contains functions to interact with Huma's EAVerse service.
|
|
4
|
+
*
|
|
5
|
+
* approve: Submits a credit underwriting request to Huma's EAVerse.
|
|
6
|
+
* @param {EAPayload} payload The payload for the underwrite approval.
|
|
7
|
+
* @param {number} chainId The chain ID.
|
|
8
|
+
* @returns {Promise<ApproveInfo>} Promise that returns approval info on success.
|
|
9
|
+
* @throws {EARejectionError} If the underwrite approval is rejected.
|
|
10
|
+
*/
|
|
11
|
+
export declare const EAService: {
|
|
12
|
+
approve: (payload: import("@00labs/huma-shared").EAPayload, chainId: number, isDev?: boolean | undefined) => Promise<import("@00labs/huma-shared").ApproveInfo>;
|
|
13
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { EAService as EAServiceInternal } from '@00labs/huma-shared';
|
|
2
|
+
/**
|
|
3
|
+
* An object that contains functions to interact with Huma's EAVerse service.
|
|
4
|
+
*
|
|
5
|
+
* approve: Submits a credit underwriting request to Huma's EAVerse.
|
|
6
|
+
* @param {EAPayload} payload The payload for the underwrite approval.
|
|
7
|
+
* @param {number} chainId The chain ID.
|
|
8
|
+
* @returns {Promise<ApproveInfo>} Promise that returns approval info on success.
|
|
9
|
+
* @throws {EARejectionError} If the underwrite approval is rejected.
|
|
10
|
+
*/
|
|
11
|
+
export const EAService = {
|
|
12
|
+
approve: EAServiceInternal.approve,
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=EAService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EAService.js","sourceRoot":"","sources":["../../src/services/EAService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,iBAAiB,EAAE,MAAM,qBAAqB,CAAA;AAIpE;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG;IACvB,OAAO,EAAE,iBAAiB,CAAC,OAAO;CACnC,CAAA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { TransactionReceipt, TransactionResponse, Web3Provider } from '@ethersproject/providers';
|
|
2
|
+
import { BigNumberish, ethers } from 'ethers';
|
|
3
|
+
import { POOL_NAME, POOL_TYPE } from '@00labs/huma-shared';
|
|
4
|
+
/**
|
|
5
|
+
* Enumeration of payment methods. Maps to the PaymentMethod enum in the BaseCreditPoolReceivable contract.
|
|
6
|
+
* Declarative payment methods are those that do not actually send ERC20 funds. Payable payment methods are those that
|
|
7
|
+
* do by calling makePayment on the BaseCreditPool contract.
|
|
8
|
+
* @enum {number}
|
|
9
|
+
*/
|
|
10
|
+
export declare enum PaymentMethod {
|
|
11
|
+
Declarative = 0,
|
|
12
|
+
Payable = 1
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Pays a BaseCreditPoolReceivable using the specified payment method, given an internalId mapping to the receivable's metadata
|
|
16
|
+
*
|
|
17
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
|
|
18
|
+
* @param {BigNumberish} receivableTokenId - The ID of the receivable token to pay.
|
|
19
|
+
* @param {number} paymentAmount - The amount to pay the receivable.
|
|
20
|
+
* @param {PaymentMethod} paymentMethod - The payment method to use. See PaymentMethod for more details.
|
|
21
|
+
* @returns {Promise<TransactionReceipt>} - A Promise of the transaction receipt.
|
|
22
|
+
* @throws {Error} - Throws an error if the BaseCreditPoolReceivable contract is not available on the network.
|
|
23
|
+
*/
|
|
24
|
+
export declare function payReceivableByInternalId(signer: ethers.Signer, internalId: string, paymentAmount: number, paymentMethod: PaymentMethod): Promise<TransactionReceipt>;
|
|
25
|
+
/**
|
|
26
|
+
* Pays a BaseCreditPoolReceivable using the specified payment method, given a tokenID of the receivable.
|
|
27
|
+
*
|
|
28
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction. Note only the receivable owner can pay the receivable.
|
|
29
|
+
* @param {BigNumberish} receivableTokenId - The ID of the receivable token to pay.
|
|
30
|
+
* @param {number} paymentAmount - The amount to pay the receivable.
|
|
31
|
+
* @param {PaymentMethod} paymentMethod - The payment method to use. See PaymentMethod for more details.
|
|
32
|
+
* @returns {Promise<TransactionReceipt>} - A Promise of the transaction receipt.
|
|
33
|
+
* @throws {Error} - Throws an error if the BaseCreditPoolReceivable contract is not available on the network.
|
|
34
|
+
*/
|
|
35
|
+
export declare function payReceivableByTokenId(signer: ethers.Signer, receivableTokenId: BigNumberish, paymentAmount: number, paymentMethod: PaymentMethod): Promise<TransactionReceipt>;
|
|
36
|
+
/**
|
|
37
|
+
* Mints a new BaseCreditPoolReceivable token on the given chain of the signer
|
|
38
|
+
*
|
|
39
|
+
* @param {ethers.Signer} signer - The signer used to send the transaction.
|
|
40
|
+
* @param {string} recipient - The address of the recipient of the receivable token.
|
|
41
|
+
* @param {POOL_NAME} poolName - The name of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
42
|
+
* @param {POOL_TYPE} poolType - The type of the credit pool to mint the receivable token from. Used to lookup the pool address.
|
|
43
|
+
* @param {number} receivableAmount - The amount of the receivable token to mint.
|
|
44
|
+
* @param {number} maturityDate - The maturity date of the receivable token, in UNIX timestamp format.
|
|
45
|
+
* @param {PaymentMethod} paymentMethod - The payment method to use. See PaymentMethod for more details.
|
|
46
|
+
* @param {string} uri - The URI of the receivable token metadata.
|
|
47
|
+
* @returns {Promise<TransactionResponse>} - A Promise of the transaction response.
|
|
48
|
+
* @throws {Error} - Throws an error if the BaseCreditPoolReceivable contract is not available on the network.
|
|
49
|
+
*/
|
|
50
|
+
export declare function mintReceivable(signer: ethers.Signer, recipient: string, poolName: POOL_NAME, poolType: POOL_TYPE, receivableAmount: number, maturityDate: number, paymentMethod: PaymentMethod, uri: string): Promise<TransactionResponse>;
|
|
51
|
+
/**
|
|
52
|
+
* Mints a BaseCreditPoolReceivable token with metadata uploaded onto ARWeave
|
|
53
|
+
*
|
|
54
|
+
* @param {Web3Provider | ethers.Signer} wallet - If calling this function from a browser, this function expects a Web3Provider.
|
|
55
|
+
* If calling this function from a server, this function expects an ethers Signer. Note that privateKey only needs to be included
|
|
56
|
+
* from server calls.
|
|
57
|
+
* @param {string} privateKey - Private key of the wallet used to upload metadata to ARWeave. Only required if calling this function from a server.
|
|
58
|
+
* @param {number} chainId - The chain ID to mint the receivable token on and pay ARWeave funds from.
|
|
59
|
+
* @param {string} recipient - The receivable token recipient.
|
|
60
|
+
* @param {POOL_NAME} poolName - The pool name. Used to lookup the pool address to pay to.
|
|
61
|
+
* @param {POOL_TYPE} poolType - The pool type. Used to lookup the pool address to pay to.
|
|
62
|
+
* @param {number} receivableAmount - The receivable amount.
|
|
63
|
+
* @param {number} maturityDate - The maturity date of the receivable, in UNIX timestamp format.
|
|
64
|
+
* @param {PaymentMethod} paymentMethod - The payment method to use. See PaymentMethod for more details.
|
|
65
|
+
* @param {JSON} metadata - The metadata in JSON format. This will be uploaded onto ARWeave
|
|
66
|
+
* @param {number} internalId - An internal identifier value added as a tag on ARWeave, for easily querying the metadata later.
|
|
67
|
+
* @param {Array<{ name: string, value: string }>} extraTags - Any extraTags you'd like to tag your metadata with. Note that metadata on
|
|
68
|
+
* ARWeave is indexed by these tags, so make sure to include any tags that you'd like to be able to query by.
|
|
69
|
+
* @param {boolean} [lazyFund=true] - Whether to lazy fund the ARWeave uploads. If true, the ARWeave uploads will be paid for by the
|
|
70
|
+
* metadata uploader immediately before uploading. If false, the ARWeave node must be pre-funded before calling this function.
|
|
71
|
+
* @returns {Promise<TransactionReceipt>} - The transaction receipt.
|
|
72
|
+
*/
|
|
73
|
+
export declare function mintReceivableWithMetadata(wallet: Web3Provider | ethers.Signer, privateKey: string, chainId: number, recipient: string, poolName: POOL_NAME, poolType: POOL_TYPE, receivableAmount: number, maturityDate: number, paymentMethod: PaymentMethod, metadata: JSON, internalId: string, extraTags: {
|
|
74
|
+
name: string;
|
|
75
|
+
value: string;
|
|
76
|
+
}[], lazyFund?: boolean): Promise<TransactionReceipt>;
|