@huma-finance/widgets 0.0.62-beta.636 → 0.0.62-beta.637
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/dist/cjs/index.cjs +18 -10
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/index.js +20 -12
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/src/components/CreditLine/solanaBorrow/2-Transfer.tsx +9 -9
- package/src/components/CreditLine/solanaPayment/2-Transfer.tsx +5 -5
- package/src/components/Lend/components/PersonaEvaluation.tsx +5 -0
- package/src/components/Lend/solanaAddRedemption/3-Transfer.tsx +3 -3
- package/src/components/Lend/solanaCancelRedemption/2-Transfer.tsx +1 -1
- package/src/components/Lend/solanaSupply/1-Evaluation.tsx +12 -1
- package/src/components/Lend/solanaSupply/4-Transfer.tsx +13 -9
package/dist/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { useTheme, css, Box, Typography, Tooltip, Button, Dialog, Slider, Input,
|
|
|
4
4
|
import { useAtom, Provider as Provider$2 } from 'jotai';
|
|
5
5
|
import React, { useCallback, useState, useEffect, useMemo, useRef } from 'react';
|
|
6
6
|
import { useSelector, useDispatch, Provider } from 'react-redux';
|
|
7
|
-
import { supportedChainId, isTxFailed, getExplorerUrl, openInNewTab, TxStateType, decodeLogs, ERC20_ABI, downScale, formatMoney, POOL_NAME, POOL_TYPE, getERC20Contract, checkIsDev, EAService, EARejectionError, EARejectMessage, EARejectReason, timeUtil, formatNumber, doesChainSupportNotifi, CreditState, isEmpty, CreditStateV2, upScale, toBigNumber, TRANSFER_ABI, FirstLossCoverIndex, combineStyles, timestampToLL, getTrancheAssetsAndShares, IdentityService, CHAINS, configUtil, IdentityServiceV2, IdentityVerificationStatusV2, CampaignService, CAMPAIGN_REFERENCE_CODE, KYC_PROVIDER, CHAIN_TYPE, formatAmount, getTrancheVaultContractV2, getTrancheRedemptionStatusV2, getPoolContractV2, CURRENCY_CODE, SuperfluidPoolProcessor_ABI, PoolMap, SolanaTokenUtils, getSolanaExplorerUrl, getTokenAccounts, getSentinelAddress, getCreditAccounts, ChainEnum, getBlockchainConfigFromChain } from '@huma-finance/shared';
|
|
7
|
+
import { supportedChainId, isTxFailed, getExplorerUrl, openInNewTab, TxStateType, decodeLogs, ERC20_ABI, downScale, formatMoney, POOL_NAME, POOL_TYPE, getERC20Contract, checkIsDev, EAService, EARejectionError, EARejectMessage, EARejectReason, timeUtil, formatNumber, doesChainSupportNotifi, CreditState, isEmpty, CreditStateV2, upScale, toBigNumber, TRANSFER_ABI, FirstLossCoverIndex, combineStyles, timestampToLL, getTrancheAssetsAndShares, IdentityService, CHAINS, configUtil, IdentityServiceV2, IdentityVerificationStatusV2, CampaignService, CAMPAIGN_REFERENCE_CODE, KYC_PROVIDER, CHAIN_TYPE, formatAmount, getTrancheVaultContractV2, getTrancheRedemptionStatusV2, getPoolContractV2, CURRENCY_CODE, SuperfluidPoolProcessor_ABI, PoolMap, SOLANA_CHAIN_INFO, SolanaTokenUtils, getSolanaExplorerUrl, getTokenAccounts, getSentinelAddress, getCreditAccounts, ChainEnum, getBlockchainConfigFromChain } from '@huma-finance/shared';
|
|
8
8
|
import { useWeb3React } from '@web3-react/core';
|
|
9
9
|
import ErrorOutlineIcon from '@mui/icons-material/ErrorOutline';
|
|
10
10
|
import { useResetAtom } from 'jotai/utils';
|
|
@@ -27,7 +27,7 @@ import { drawdownWithReceivable, HumaContext, HumaReceivableFactory, makePayment
|
|
|
27
27
|
import moment from 'moment';
|
|
28
28
|
import { getAddress } from '@ethersproject/address';
|
|
29
29
|
import { BN } from '@coral-xyz/anchor';
|
|
30
|
-
import { TOKEN_2022_PROGRAM_ID, getAccount, TokenAccountNotFoundError, TokenInvalidAccountOwnerError, createAssociatedTokenAccountInstruction, ASSOCIATED_TOKEN_PROGRAM_ID, createApproveCheckedInstruction } from '@solana/spl-token';
|
|
30
|
+
import { TOKEN_2022_PROGRAM_ID, TOKEN_PROGRAM_ID, getAccount, TokenAccountNotFoundError, TokenInvalidAccountOwnerError, createAssociatedTokenAccountInstruction, ASSOCIATED_TOKEN_PROGRAM_ID, createApproveCheckedInstruction } from '@solana/spl-token';
|
|
31
31
|
import { useWallet, useConnection } from '@solana/wallet-adapter-react';
|
|
32
32
|
import { Transaction, PublicKey } from '@solana/web3.js';
|
|
33
33
|
import { arrayify } from '@ethersproject/bytes';
|
|
@@ -5509,6 +5509,7 @@ function PersonaEvaluation(_ref) {
|
|
|
5509
5509
|
campaign,
|
|
5510
5510
|
pointsTestnetExperience,
|
|
5511
5511
|
chainType,
|
|
5512
|
+
chainSpecificData,
|
|
5512
5513
|
changeTranche,
|
|
5513
5514
|
handleClose
|
|
5514
5515
|
} = _ref;
|
|
@@ -5549,9 +5550,9 @@ function PersonaEvaluation(_ref) {
|
|
|
5549
5550
|
try {
|
|
5550
5551
|
isActionOngoingRef.current = true;
|
|
5551
5552
|
setLoadingType('approveLender');
|
|
5552
|
-
await IdentityServiceV2.approveLender(account, chainId, poolInfo.juniorTrancheVault, isDev);
|
|
5553
|
+
await IdentityServiceV2.approveLender(account, chainId, poolInfo.juniorTrancheVault, isDev, chainSpecificData);
|
|
5553
5554
|
if (!isUniTranche) {
|
|
5554
|
-
await IdentityServiceV2.approveLender(account, chainId, poolInfo.seniorTrancheVault, isDev);
|
|
5555
|
+
await IdentityServiceV2.approveLender(account, chainId, poolInfo.seniorTrancheVault, isDev, chainSpecificData);
|
|
5555
5556
|
}
|
|
5556
5557
|
if (isUniTranche) {
|
|
5557
5558
|
changeTranche('junior');
|
|
@@ -5563,7 +5564,7 @@ function PersonaEvaluation(_ref) {
|
|
|
5563
5564
|
isActionOngoingRef.current = false;
|
|
5564
5565
|
setLoadingType(undefined);
|
|
5565
5566
|
}
|
|
5566
|
-
}, [account, chainId, changeTranche, dispatch, isDev, isUniTranche, poolInfo.juniorTrancheVault, poolInfo.seniorTrancheVault]);
|
|
5567
|
+
}, [account, chainId, chainSpecificData, changeTranche, dispatch, isDev, isUniTranche, poolInfo.juniorTrancheVault, poolInfo.seniorTrancheVault]);
|
|
5567
5568
|
const checkVerificationStatus = useCallback(async () => {
|
|
5568
5569
|
if (isActionOngoingRef.current || isKYCResumedRef.current) {
|
|
5569
5570
|
return;
|
|
@@ -8582,6 +8583,7 @@ function Evaluation(_ref) {
|
|
|
8582
8583
|
handleClose
|
|
8583
8584
|
} = _ref;
|
|
8584
8585
|
if ((_poolInfo$KYC = poolInfo.KYC) !== null && _poolInfo$KYC !== void 0 && _poolInfo$KYC.Persona) {
|
|
8586
|
+
const solanChainInfo = SOLANA_CHAIN_INFO[poolInfo.chainId];
|
|
8585
8587
|
return jsx(PersonaEvaluation, {
|
|
8586
8588
|
poolInfo: {
|
|
8587
8589
|
KYC: poolInfo.KYC,
|
|
@@ -8592,6 +8594,10 @@ function Evaluation(_ref) {
|
|
|
8592
8594
|
isUniTranche: isUniTranche,
|
|
8593
8595
|
pointsTestnetExperience: pointsTestnetExperience,
|
|
8594
8596
|
campaign: campaign,
|
|
8597
|
+
chainSpecificData: {
|
|
8598
|
+
huma_program_id: solanChainInfo.poolProgram,
|
|
8599
|
+
pool_id: poolInfo.poolId
|
|
8600
|
+
},
|
|
8595
8601
|
chainType: CHAIN_TYPE.SOLANA,
|
|
8596
8602
|
changeTranche: changeTranche
|
|
8597
8603
|
});
|
|
@@ -8846,12 +8852,13 @@ function Transfer$4(_ref) {
|
|
|
8846
8852
|
seniorTrancheATA,
|
|
8847
8853
|
juniorTrancheATA
|
|
8848
8854
|
} = getTokenAccounts(poolInfo, publicKey);
|
|
8855
|
+
const approvedLender = selectedTranche === 'senior' ? seniorLenderApprovedAccountPDA : juniorLenderApprovedAccountPDA;
|
|
8849
8856
|
if (selectedTranche === 'senior' && !seniorLenderStateAccount || selectedTranche === 'junior' && !juniorLenderStateAccount) {
|
|
8850
8857
|
const createLenderAccountsTx = await program.methods.createLenderAccounts().accountsPartial({
|
|
8851
8858
|
lender: publicKey,
|
|
8852
8859
|
humaConfig: poolInfo.humaConfig,
|
|
8853
8860
|
poolConfig: poolInfo.poolConfig,
|
|
8854
|
-
approvedLender
|
|
8861
|
+
approvedLender,
|
|
8855
8862
|
trancheMint: selectedTranche === 'senior' ? poolInfo.seniorTrancheMint : poolInfo.juniorTrancheMint,
|
|
8856
8863
|
lenderTrancheToken: selectedTranche === 'senior' ? seniorTrancheATA : juniorTrancheATA,
|
|
8857
8864
|
tokenProgram: TOKEN_2022_PROGRAM_ID
|
|
@@ -8859,6 +8866,7 @@ function Transfer$4(_ref) {
|
|
|
8859
8866
|
tx.add(createLenderAccountsTx);
|
|
8860
8867
|
}
|
|
8861
8868
|
const depositTx = await program.methods.deposit(supplyBigNumber).accountsPartial({
|
|
8869
|
+
approvedLender,
|
|
8862
8870
|
depositor: publicKey,
|
|
8863
8871
|
poolConfig: poolInfo.poolConfig,
|
|
8864
8872
|
underlyingMint: poolInfo.underlyingMint.address,
|
|
@@ -8867,7 +8875,7 @@ function Transfer$4(_ref) {
|
|
|
8867
8875
|
depositorUnderlyingToken: underlyingTokenATA,
|
|
8868
8876
|
depositorTrancheToken: selectedTranche === 'senior' ? seniorTrancheATA : juniorTrancheATA,
|
|
8869
8877
|
humaConfig: poolInfo.humaConfig,
|
|
8870
|
-
|
|
8878
|
+
underlyingTokenProgram: TOKEN_PROGRAM_ID
|
|
8871
8879
|
}).transaction();
|
|
8872
8880
|
tx.add(depositTx);
|
|
8873
8881
|
setTransaction(tx);
|
|
@@ -9835,14 +9843,14 @@ function Transfer$1(_ref) {
|
|
|
9835
9843
|
// Create user token account if it doesn't exist
|
|
9836
9844
|
let tokenAccount;
|
|
9837
9845
|
try {
|
|
9838
|
-
tokenAccount = await getAccount(connection, underlyingTokenATA, undefined,
|
|
9846
|
+
tokenAccount = await getAccount(connection, underlyingTokenATA, undefined, TOKEN_PROGRAM_ID);
|
|
9839
9847
|
} catch (error) {
|
|
9840
9848
|
// TokenAccountNotFoundError can be possible if the associated address has already received some lamports,
|
|
9841
9849
|
// becoming a system account. Assuming program derived addressing is safe, this is the only case for the
|
|
9842
9850
|
// TokenInvalidAccountOwnerError in this code path.
|
|
9843
9851
|
if (error instanceof TokenAccountNotFoundError || error instanceof TokenInvalidAccountOwnerError) {
|
|
9844
9852
|
// As this isn't atomic, it's possible others can create associated accounts meanwhile.
|
|
9845
|
-
tx.add(createAssociatedTokenAccountInstruction(publicKey, underlyingTokenATA, publicKey, new PublicKey(poolInfo.underlyingMint.address),
|
|
9853
|
+
tx.add(createAssociatedTokenAccountInstruction(publicKey, underlyingTokenATA, publicKey, new PublicKey(poolInfo.underlyingMint.address), TOKEN_PROGRAM_ID, ASSOCIATED_TOKEN_PROGRAM_ID));
|
|
9846
9854
|
}
|
|
9847
9855
|
}
|
|
9848
9856
|
|
|
@@ -9859,7 +9867,7 @@ function Transfer$1(_ref) {
|
|
|
9859
9867
|
// amount
|
|
9860
9868
|
poolInfo.underlyingMint.decimals, undefined,
|
|
9861
9869
|
// multiSigners
|
|
9862
|
-
|
|
9870
|
+
TOKEN_PROGRAM_ID));
|
|
9863
9871
|
}
|
|
9864
9872
|
const {
|
|
9865
9873
|
creditConfigAccount,
|
|
@@ -9877,7 +9885,7 @@ function Transfer$1(_ref) {
|
|
|
9877
9885
|
underlyingMint: poolInfo.underlyingMint.address,
|
|
9878
9886
|
poolUnderlyingToken: poolInfo.poolUnderlyingTokenAccount,
|
|
9879
9887
|
borrowerUnderlyingToken: underlyingTokenATA,
|
|
9880
|
-
tokenProgram:
|
|
9888
|
+
tokenProgram: TOKEN_PROGRAM_ID
|
|
9881
9889
|
}).transaction();
|
|
9882
9890
|
tx.add(programTx);
|
|
9883
9891
|
setTransaction(tx);
|
|
@@ -10057,7 +10065,7 @@ function Transfer(_ref) {
|
|
|
10057
10065
|
underlyingMint: poolInfo.underlyingMint.address,
|
|
10058
10066
|
poolUnderlyingToken: poolInfo.poolUnderlyingTokenAccount,
|
|
10059
10067
|
borrowerUnderlyingToken: underlyingTokenATA,
|
|
10060
|
-
tokenProgram:
|
|
10068
|
+
tokenProgram: TOKEN_PROGRAM_ID
|
|
10061
10069
|
}).transaction();
|
|
10062
10070
|
setTransaction(tx);
|
|
10063
10071
|
}
|