@raac/rpc 1.0.2-beta.3 → 1.0.2-beta.4
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/{RPCLibrary.ts → RPCLibrary.js} +7 -121
- package/assets/{getAsset.ts → getAsset.js} +6 -6
- package/assets/{getAssets.ts → getAssets.js} +2 -3
- package/assets/{getSupply.ts → getSupply.js} +5 -7
- package/configs/chains/index.js +13 -0
- package/configs/index.js +17 -0
- package/contracts/feeCollector/{claimRewardFromPool.ts → claimRewardFromPool.js} +4 -10
- package/contracts/{getContract.ts → getContract.js} +5 -6
- package/contracts/{getContractAddress.ts → getContractAddress.js} +4 -6
- package/contracts/housePrices/{getLatestPrice.ts → getLatestPrice.js} +6 -8
- package/contracts/housePrices/{setOracle.ts → setOracle.js} +6 -8
- package/contracts/indexToken/{getNextRandomNFT.ts → getNextRandomNFT.js} +5 -7
- package/contracts/indexToken/{redeemNFT.ts → redeemNFT.js} +5 -7
- package/contracts/zeno/{createAuction.ts → createAuction.js} +14 -16
- package/contracts/zeno/{createZeno.ts → createZeno.js} +8 -10
- package/contracts/zeno/{getAuctions.ts → getAuctions.js} +5 -7
- package/contracts/zeno/{getZenos.ts → getZenos.js} +5 -7
- package/methods/commons/{checkAllowance.ts → checkAllowance.js} +10 -12
- package/methods/commons/{estimateGasPrice.ts → estimateGasPrice.js} +5 -7
- package/minter/{get.ts → get.js} +6 -8
- package/minter/{getApy.ts → getApy.js} +5 -7
- package/minter/{tick.ts → tick.js} +5 -7
- package/nfts/{getAllTokens.ts → getAllTokens.js} +7 -9
- package/nfts/{getBaseUri.ts → getBaseUri.js} +5 -7
- package/nfts/{getHousePrice.ts → getHousePrice.js} +6 -8
- package/nfts/{getMintFeePercentage.ts → getMintFeePercentage.js} +4 -6
- package/nfts/{getMintPrice.ts → getMintPrice.js} +7 -9
- package/nfts/{getTokenURI.ts → getTokenURI.js} +7 -9
- package/nfts/{getTokensByOwner.ts → getTokensByOwner.js} +8 -10
- package/nfts/{getTotalPropertiesCount.ts → getTotalPropertiesCount.js} +5 -7
- package/nfts/{mint.ts → mint.js} +7 -9
- package/nfts/{setBaseUri.ts → setBaseUri.js} +4 -6
- package/nfts/{totalNFTSupply.ts → totalNFTSupply.js} +4 -6
- package/package.json +1 -1
- package/pools/lendingPool/{borrowFromLendingPool.ts → borrowFromLendingPool.js} +8 -10
- package/pools/lendingPool/{borrowFromLendingPoolWithInsurance.ts → borrowFromLendingPoolWithInsurance.js} +8 -10
- package/pools/lendingPool/{calculateInsuranceFee.ts → calculateInsuranceFee.js} +9 -11
- package/pools/lendingPool/{claimReward.ts → claimReward.js} +5 -7
- package/pools/lendingPool/{closeLiquidation.ts → closeLiquidation.js} +7 -9
- package/pools/lendingPool/{depositNFTToLendingPool.ts → depositNFTToLendingPool.js} +6 -8
- package/pools/lendingPool/{depositToLendingPool.ts → depositToLendingPool.js} +6 -8
- package/pools/lendingPool/{getAllUserData.ts → getAllUserData.js} +7 -14
- package/pools/lendingPool/{getEligibleUserDeposits.ts → getEligibleUserDeposits.js} +7 -9
- package/pools/lendingPool/{getHealthFactor.ts → getHealthFactor.js} +8 -10
- package/pools/lendingPool/{getHousePrice.ts → getHousePrice.js} +6 -8
- package/pools/lendingPool/{getLendingPoolInfo.ts → getLendingPoolInfo.js} +23 -31
- package/pools/lendingPool/{getLendingPoolTotalLiquidity.ts → getLendingPoolTotalLiquidity.js} +7 -10
- package/pools/lendingPool/{getPendingReward.ts → getPendingReward.js} +7 -9
- package/pools/lendingPool/{getPositionDebt.ts → getPositionDebt.js} +8 -10
- package/pools/lendingPool/{getPositionScaledDebt.ts → getPositionScaledDebt.js} +8 -10
- package/pools/lendingPool/{getPositionView.ts → getPositionView.js} +9 -11
- package/pools/lendingPool/{getPositionsScaledDebt.ts → getPositionsScaledDebt.js} +7 -9
- package/pools/lendingPool/{getRawUserDepositsInLendingPool.ts → getRawUserDepositsInLendingPool.js} +7 -9
- package/pools/lendingPool/{getUserCollateralValue.ts → getUserCollateralValue.js} +7 -9
- package/pools/lendingPool/{initializeLiquidation.ts → initializeLiquidation.js} +8 -10
- package/pools/lendingPool/{repayToLendingPool.ts → repayToLendingPool.js} +8 -10
- package/pools/lendingPool/{withdrawFromLendingPool.ts → withdrawFromLendingPool.js} +9 -10
- package/pools/lendingPool/{withdrawNFTFromLendingPool.ts → withdrawNFTFromLendingPool.js} +7 -9
- package/pools/stabilityPool/{calculateRAACRewards.ts → calculateRAACRewards.js} +6 -9
- package/pools/stabilityPool/configs/chains/index.js +17 -0
- package/pools/stabilityPool/configs/index.js +43 -0
- package/pools/stabilityPool/{depositNFTToStabilityPool.ts → depositNFTToStabilityPool.js} +6 -9
- package/pools/stabilityPool/{depositToStabilityPool.ts → depositToStabilityPool.js} +6 -8
- package/pools/stabilityPool/{getRawUserDepositsInStabilityPool.ts → getRawUserDepositsInStabilityPool.js} +7 -9
- package/pools/stabilityPool/{getStabilityPoolInfo.ts → getStabilityPoolInfo.js} +10 -12
- package/pools/stabilityPool/{getStabilityPoolTotalDeposits.ts → getStabilityPoolTotalDeposits.js} +6 -8
- package/pools/stabilityPool/methods/commons/estimateGasPrice.js +28 -0
- package/pools/stabilityPool/pools/stabilityPool/withdrawFromStabilityPool.js +34 -0
- package/pools/stabilityPool/utils/artifacts.js +74 -0
- package/pools/stabilityPool/utils/contracts.js +82 -0
- package/pools/stabilityPool/{withdrawFromStabilityPool.ts → withdrawFromStabilityPool.js} +6 -8
- package/ts-to-js.sh +42 -0
- package/utils/{artifacts.ts → artifacts.js} +1 -4
- package/utils/{contracts.ts → contracts.js} +16 -18
- package/wallet/assets/{approveAsset.ts → approveAsset.js} +7 -8
- package/wallet/assets/{burnAsset.ts → burnAsset.js} +7 -9
- package/wallet/assets/{getAllowance.ts → getAllowance.js} +9 -10
- package/wallet/assets/{getAsset.ts → getAsset.js} +6 -7
- package/wallet/assets/{getAssets.ts → getAssets.js} +5 -6
- package/wallet/assets/{getBalance.ts → getBalance.js} +8 -9
- package/wallet/assets/{mintAsset.ts → mintAsset.js} +8 -9
- package/wallet/assets/{transferAsset.ts → transferAsset.js} +10 -11
- package/configs/chains/index.ts +0 -17
- package/configs/index.ts +0 -51
- /package/configs/chains/{chain.d.ts → chain.d.js} +0 -0
- /package/configs/{createConfig.ts → createConfig.js} +0 -0
- /package/contracts/crvUSDToken/{getBalance.ts → getBalance.js} +0 -0
- /package/contracts/crvUSDToken/{getTotalSupply.ts → getTotalSupply.js} +0 -0
- /package/contracts/rcrvUSDToken/{getBalance.ts → getBalance.js} +0 -0
- /package/contracts/rcrvUSDToken/{getTotalSupply.ts → getTotalSupply.js} +0 -0
- /package/{custom-types.d.ts → custom-types.d.js} +0 -0
- /package/{index.ts → index.js} +0 -0
- /package/methods/{approveToken.ts → approveToken.js} +0 -0
- /package/methods/{getAssetBalance.ts → getAssetBalance.js} +0 -0
- /package/methods/{getAssetsBalance.ts → getAssetsBalance.js} +0 -0
- /package/pools/liquidityPool/{getLiquidityPoolInfo.ts → getLiquidityPoolInfo.js} +0 -0
- /package/scripts/{index.ts → index.js} +0 -0
- /package/tests/{test.ts → test.js} +0 -0
- /package/utils/{chain.ts → chain.js} +0 -0
- /package/utils/{config.ts → config.js} +0 -0
|
@@ -1,17 +1,15 @@
|
|
|
1
1
|
import { Provider } from "ethers";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { ChainId } from "../../configs/chains/index";
|
|
5
|
-
import { ERC20 } from "../../typechain-types";
|
|
2
|
+
import getContract from "../../contracts/getContract";
|
|
3
|
+
import getContractAddress from "../../contracts/getContractAddress";
|
|
6
4
|
|
|
7
5
|
const checkAllowance = async (
|
|
8
|
-
chainId
|
|
9
|
-
tokenId
|
|
10
|
-
address
|
|
11
|
-
spenderAddress
|
|
12
|
-
provider
|
|
6
|
+
chainId,
|
|
7
|
+
tokenId,
|
|
8
|
+
address,
|
|
9
|
+
spenderAddress,
|
|
10
|
+
provider
|
|
13
11
|
) => {
|
|
14
|
-
let tokenAddress = getContractAddress(chainId, tokenId
|
|
12
|
+
let tokenAddress = getContractAddress(chainId, tokenId);
|
|
15
13
|
console.log(
|
|
16
14
|
`[commons/checkAllowance] Checking allowance for ${address} to ${spenderAddress} on ${chainId} ${tokenId}:${tokenAddress}`
|
|
17
15
|
);
|
|
@@ -21,10 +19,10 @@ const checkAllowance = async (
|
|
|
21
19
|
chainId,
|
|
22
20
|
tokenId,
|
|
23
21
|
provider
|
|
24
|
-
)
|
|
22
|
+
);
|
|
25
23
|
const allowance = await tokenContract.allowance(address, spenderAddress);
|
|
26
24
|
return allowance;
|
|
27
|
-
} catch (error
|
|
25
|
+
} catch (error) {
|
|
28
26
|
console.error(`Error calling allowance: ${error}`);
|
|
29
27
|
throw new Error(
|
|
30
28
|
`[commons/checkAllowance] ${chainId} ${tokenId}:${tokenAddress} ${address} ${spenderAddress} ${error}`
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export const estimateGasPrice = async (signer: Signer) => {
|
|
4
|
-
const provider = signer.provider as Provider;
|
|
1
|
+
export const estimateGasPrice = async (signer) => {
|
|
2
|
+
const provider = signer.provider;
|
|
5
3
|
try {
|
|
6
4
|
const feeData = await provider.getFeeData();
|
|
7
5
|
const maxPriorityFeePerGas = feeData.maxPriorityFeePerGas;
|
|
@@ -13,10 +11,10 @@ export const estimateGasPrice = async (signer: Signer) => {
|
|
|
13
11
|
maxFeePerGas,
|
|
14
12
|
maxPriorityFeePerGas,
|
|
15
13
|
};
|
|
16
|
-
} catch (error
|
|
14
|
+
} catch (error) {
|
|
17
15
|
console.log("Error getting gas price", error);
|
|
18
|
-
if (
|
|
19
|
-
const gasPrice = await
|
|
16
|
+
if (provider?.getGasPrice) {
|
|
17
|
+
const gasPrice = await provider.getGasPrice();
|
|
20
18
|
return { gasPrice };
|
|
21
19
|
}
|
|
22
20
|
return { gasPrice: 0 };
|
package/minter/{get.ts → get.js}
RENAMED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { ethers
|
|
2
|
-
import
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import getContractAddress from "../contracts/getContractAddress";
|
|
3
3
|
import { getABI } from "../utils/artifacts";
|
|
4
4
|
import estimateGasPrice from "../methods/commons/estimateGasPrice";
|
|
5
|
-
import { ChainId } from "../configs/chains/index";
|
|
6
|
-
import { RAACMinter } from "../typechain-types";
|
|
7
5
|
|
|
8
|
-
async function get(chainId
|
|
6
|
+
async function get(chainId, signer) {
|
|
9
7
|
if (!signer) {
|
|
10
8
|
throw new Error("Wallet not connected");
|
|
11
9
|
}
|
|
@@ -20,9 +18,9 @@ async function get(chainId: ChainId, signer: Signer) {
|
|
|
20
18
|
raacMinterAddress,
|
|
21
19
|
raacMinterABI,
|
|
22
20
|
signer
|
|
23
|
-
)
|
|
21
|
+
);
|
|
24
22
|
|
|
25
|
-
const handleError = (operation
|
|
23
|
+
const handleError = (operation) => (error) => {
|
|
26
24
|
if (error.code === "BAD_DATA") {
|
|
27
25
|
console.log(`BAD_DATA from getMinter - ${operation}:`, error.message);
|
|
28
26
|
return BigInt(0);
|
|
@@ -142,7 +140,7 @@ async function get(chainId: ChainId, signer: Signer) {
|
|
|
142
140
|
|
|
143
141
|
// console.log(tick);
|
|
144
142
|
return result;
|
|
145
|
-
} catch (error
|
|
143
|
+
} catch (error) {
|
|
146
144
|
throw new Error(`Error calculating RAAC rewards: ${error.message}`);
|
|
147
145
|
}
|
|
148
146
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { ethers
|
|
2
|
-
import
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import getContractAddress from "../contracts/getContractAddress";
|
|
3
3
|
import { getABI } from "../utils/artifacts";
|
|
4
|
-
import { ChainId } from "../configs/chains/index";
|
|
5
|
-
import { RAACMinter } from "../typechain-types";
|
|
6
4
|
|
|
7
|
-
async function getApy(chainId
|
|
5
|
+
async function getApy(chainId, provider) {
|
|
8
6
|
if (!provider) {
|
|
9
7
|
throw new Error("Wallet not connected");
|
|
10
8
|
}
|
|
@@ -16,7 +14,7 @@ async function getApy(chainId: ChainId, provider: Provider) {
|
|
|
16
14
|
raacMinterAddress,
|
|
17
15
|
raacMinterABI,
|
|
18
16
|
provider
|
|
19
|
-
)
|
|
17
|
+
);
|
|
20
18
|
|
|
21
19
|
const result = { emissionRate: 0n, BLOCKS_PER_DAY: 0n };
|
|
22
20
|
result.emissionRate = await raacMinterContract.emissionRate();
|
|
@@ -29,7 +27,7 @@ async function getApy(chainId: ChainId, provider: Provider) {
|
|
|
29
27
|
|
|
30
28
|
const apy = (emissionRatePerYear * 10000n) / totalSupply;
|
|
31
29
|
return apy;
|
|
32
|
-
} catch (error
|
|
30
|
+
} catch (error) {
|
|
33
31
|
throw new Error(`Error calculating RAAC rewards: ${error.message}`);
|
|
34
32
|
}
|
|
35
33
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import { ethers
|
|
2
|
-
import
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import getContractAddress from "../contracts/getContractAddress";
|
|
3
3
|
import { getABI } from "../utils/artifacts";
|
|
4
4
|
import estimateGasPrice from "../methods/commons/estimateGasPrice";
|
|
5
|
-
import { ChainId } from "../configs/chains/index";
|
|
6
|
-
import { RAACMinter } from "../typechain-types";
|
|
7
5
|
|
|
8
|
-
async function tick(chainId
|
|
6
|
+
async function tick(chainId, signer) {
|
|
9
7
|
if (!signer) {
|
|
10
8
|
throw new Error("Wallet not connected");
|
|
11
9
|
}
|
|
@@ -18,7 +16,7 @@ async function tick(chainId: ChainId, signer: Signer) {
|
|
|
18
16
|
raacMinterAddress,
|
|
19
17
|
raacMinterABI,
|
|
20
18
|
signer
|
|
21
|
-
)
|
|
19
|
+
);
|
|
22
20
|
|
|
23
21
|
const { maxFeePerGas } = await estimateGasPrice(signer);
|
|
24
22
|
|
|
@@ -32,7 +30,7 @@ async function tick(chainId: ChainId, signer: Signer) {
|
|
|
32
30
|
await tick.wait();
|
|
33
31
|
}
|
|
34
32
|
return tick;
|
|
35
|
-
} catch (error
|
|
33
|
+
} catch (error) {
|
|
36
34
|
throw new Error(`Error calculating RAAC rewards: ${error.message}`);
|
|
37
35
|
}
|
|
38
36
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { ethers, Provider } from "ethers";
|
|
2
|
-
import
|
|
2
|
+
import getContractAddress from "../contracts/getContractAddress";
|
|
3
3
|
import { getABI } from "../utils/artifacts";
|
|
4
|
-
import { ChainId } from "../configs/chains/index";
|
|
5
|
-
import { RAACNFT } from "../typechain-types";
|
|
6
4
|
|
|
7
5
|
async function getAllTokens(
|
|
8
|
-
chainId
|
|
9
|
-
provider
|
|
10
|
-
pagination
|
|
6
|
+
chainId,
|
|
7
|
+
provider,
|
|
8
|
+
pagination
|
|
11
9
|
) {
|
|
12
10
|
try {
|
|
13
11
|
const raacNFTAddress = getContractAddress(chainId, "raacnft");
|
|
@@ -17,14 +15,14 @@ async function getAllTokens(
|
|
|
17
15
|
raacNFTAddress,
|
|
18
16
|
raacNFTABI,
|
|
19
17
|
provider
|
|
20
|
-
)
|
|
18
|
+
);
|
|
21
19
|
|
|
22
20
|
const totalSupply = await raacNFTContract.totalSupply();
|
|
23
21
|
if (totalSupply === 0n) {
|
|
24
22
|
return [];
|
|
25
23
|
}
|
|
26
24
|
|
|
27
|
-
let tokens
|
|
25
|
+
let tokens = [];
|
|
28
26
|
if (pagination) {
|
|
29
27
|
const offset = pagination?.offset || 0;
|
|
30
28
|
const limit = pagination?.limit || 10;
|
|
@@ -42,7 +40,7 @@ async function getAllTokens(
|
|
|
42
40
|
}
|
|
43
41
|
|
|
44
42
|
return tokens;
|
|
45
|
-
} catch (error
|
|
43
|
+
} catch (error) {
|
|
46
44
|
console.error("Error getting all tokens:", error);
|
|
47
45
|
throw new Error(`Failed to get all tokens: ${error.message}`);
|
|
48
46
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { ethers
|
|
2
|
-
import
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import getContractAddress from "../contracts/getContractAddress";
|
|
3
3
|
import { getABI } from "../utils/artifacts";
|
|
4
|
-
import { ChainId } from "../configs/chains/index";
|
|
5
|
-
import { RAACNFT } from "../typechain-types";
|
|
6
4
|
|
|
7
|
-
async function getBaseUri(chainId
|
|
5
|
+
async function getBaseUri(chainId, provider) {
|
|
8
6
|
if (!provider) {
|
|
9
7
|
throw new Error("Wallet not connected");
|
|
10
8
|
}
|
|
@@ -17,13 +15,13 @@ async function getBaseUri(chainId: ChainId, provider: Provider) {
|
|
|
17
15
|
raacNFTAddress,
|
|
18
16
|
raacNFTABI,
|
|
19
17
|
provider
|
|
20
|
-
)
|
|
18
|
+
);
|
|
21
19
|
|
|
22
20
|
const uri = await raacNFTContract.baseURI();
|
|
23
21
|
|
|
24
22
|
console.log(`Retrieved base uri: ${uri}`);
|
|
25
23
|
return uri;
|
|
26
|
-
} catch (error
|
|
24
|
+
} catch (error) {
|
|
27
25
|
console.error("Error adding new batch:", error);
|
|
28
26
|
throw new Error(`Failed to add new batch: ${error.message}`);
|
|
29
27
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
1
|
import { ethers, Provider } from "ethers";
|
|
2
|
-
import
|
|
2
|
+
import getContractAddress from "../contracts/getContractAddress";
|
|
3
3
|
import { getABI } from "../utils/artifacts";
|
|
4
|
-
import { ChainId } from "../configs/chains/index";
|
|
5
|
-
import { RAACNFT } from "../typechain-types";
|
|
6
4
|
|
|
7
5
|
async function getHousePrice(
|
|
8
|
-
chainId
|
|
9
|
-
tokenId
|
|
10
|
-
provider
|
|
6
|
+
chainId,
|
|
7
|
+
tokenId,
|
|
8
|
+
provider
|
|
11
9
|
) {
|
|
12
10
|
try {
|
|
13
11
|
const raacNFTAddress = getContractAddress(chainId, "raacnft");
|
|
@@ -17,11 +15,11 @@ async function getHousePrice(
|
|
|
17
15
|
raacNFTAddress,
|
|
18
16
|
raacNFTABI,
|
|
19
17
|
provider
|
|
20
|
-
)
|
|
18
|
+
);
|
|
21
19
|
|
|
22
20
|
const price = await raacNFTContract.getHousePrice(tokenId);
|
|
23
21
|
return ethers.formatEther(price);
|
|
24
|
-
} catch (error
|
|
22
|
+
} catch (error) {
|
|
25
23
|
console.error("Error getting house price:", error);
|
|
26
24
|
throw new Error(`Failed to get house price: ${error.message}`);
|
|
27
25
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { Contract, ethers, Provider, Signer } from "ethers";
|
|
2
|
-
import
|
|
2
|
+
import getContractAddress from "../contracts/getContractAddress";
|
|
3
3
|
import { getABI } from "../utils/artifacts";
|
|
4
|
-
import { ChainId } from "../configs/chains/index";
|
|
5
|
-
import { RAACNFT } from "../typechain-types";
|
|
6
4
|
|
|
7
|
-
async function getMintFeePercentage(chainId
|
|
5
|
+
async function getMintFeePercentage(chainId, provider) {
|
|
8
6
|
if (!provider) {
|
|
9
7
|
throw new Error("Wallet not connected");
|
|
10
8
|
}
|
|
@@ -17,14 +15,14 @@ async function getMintFeePercentage(chainId: ChainId, provider: Provider) {
|
|
|
17
15
|
raacNFTAddress,
|
|
18
16
|
raacNFTABI,
|
|
19
17
|
provider
|
|
20
|
-
)
|
|
18
|
+
);
|
|
21
19
|
|
|
22
20
|
const percentage =
|
|
23
21
|
(await raacNFTContract.MINT_FEE_PERCENTAGE()) / BigInt(10e5);
|
|
24
22
|
|
|
25
23
|
console.log(`Retrieved mint fee percentage: ${percentage}`);
|
|
26
24
|
return percentage;
|
|
27
|
-
} catch (error
|
|
25
|
+
} catch (error) {
|
|
28
26
|
console.log("Error retrieving mint fee percentage", error);
|
|
29
27
|
throw new Error(`Failed to retrieve mint fee percentage: ${error.message}`);
|
|
30
28
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { Contract, ethers, Provider
|
|
2
|
-
import
|
|
1
|
+
import { Contract, ethers, Provider } from "ethers";
|
|
2
|
+
import getContractAddress from "../contracts/getContractAddress";
|
|
3
3
|
import { getABI } from "../utils/artifacts";
|
|
4
|
-
import { ChainId } from "../configs/chains/index";
|
|
5
|
-
import { RAACNFT } from "../typechain-types";
|
|
6
4
|
|
|
7
5
|
// This is the total price: includes the mint price and the mint fee
|
|
8
6
|
async function getMintPrice(
|
|
9
|
-
chainId
|
|
10
|
-
tokenId
|
|
11
|
-
provider
|
|
7
|
+
chainId,
|
|
8
|
+
tokenId,
|
|
9
|
+
provider
|
|
12
10
|
) {
|
|
13
11
|
if (!provider) {
|
|
14
12
|
throw new Error("Wallet not connected");
|
|
@@ -22,7 +20,7 @@ async function getMintPrice(
|
|
|
22
20
|
raacNFTAddress,
|
|
23
21
|
raacNFTABI,
|
|
24
22
|
provider
|
|
25
|
-
)
|
|
23
|
+
);
|
|
26
24
|
|
|
27
25
|
const price = await raacNFTContract.getMintPrice(tokenId);
|
|
28
26
|
const token = await raacNFTContract.token();
|
|
@@ -37,7 +35,7 @@ async function getMintPrice(
|
|
|
37
35
|
|
|
38
36
|
console.log(`Retrieved house price for ${tokenId}: ${formattedValue}`);
|
|
39
37
|
return { price, decimals };
|
|
40
|
-
} catch (error
|
|
38
|
+
} catch (error) {
|
|
41
39
|
console.error("Error retrieving mint price for " + tokenId, error);
|
|
42
40
|
throw new Error(`Failed retrieve mint price: ${error.message}`);
|
|
43
41
|
}
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import { ethers, Provider
|
|
2
|
-
import
|
|
1
|
+
import { ethers, Provider } from "ethers";
|
|
2
|
+
import getContractAddress from "../contracts/getContractAddress";
|
|
3
3
|
import { getABI } from "../utils/artifacts";
|
|
4
|
-
import { ChainId } from "../configs/chains/index";
|
|
5
|
-
import { RAACNFT } from "../typechain-types";
|
|
6
4
|
|
|
7
5
|
async function getTokenURI(
|
|
8
|
-
chainId
|
|
9
|
-
tokenId
|
|
10
|
-
provider
|
|
6
|
+
chainId,
|
|
7
|
+
tokenId,
|
|
8
|
+
provider
|
|
11
9
|
) {
|
|
12
10
|
if (!provider) {
|
|
13
11
|
throw new Error("Wallet not connected");
|
|
@@ -21,12 +19,12 @@ async function getTokenURI(
|
|
|
21
19
|
raacNFTAddress,
|
|
22
20
|
raacNFTABI,
|
|
23
21
|
provider
|
|
24
|
-
)
|
|
22
|
+
);
|
|
25
23
|
|
|
26
24
|
const uri = await raacNFTContract.tokenURI(tokenId);
|
|
27
25
|
console.log(`Retrieved token URI: ${uri}`);
|
|
28
26
|
return uri;
|
|
29
|
-
} catch (error
|
|
27
|
+
} catch (error) {
|
|
30
28
|
console.error("Error getting token URI:", error);
|
|
31
29
|
throw new Error(`Failed to get token URI: ${error.message}`);
|
|
32
30
|
}
|
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { ethers, Provider } from "ethers";
|
|
2
|
-
import
|
|
2
|
+
import getContractAddress from "../contracts/getContractAddress";
|
|
3
3
|
import { getABI } from "../utils/artifacts";
|
|
4
|
-
import { ChainId } from "../configs/chains/index";
|
|
5
|
-
import { RAACNFT } from "../typechain-types";
|
|
6
4
|
|
|
7
5
|
async function getTokensByOwner(
|
|
8
|
-
chainId
|
|
9
|
-
address
|
|
10
|
-
provider
|
|
11
|
-
pagination
|
|
6
|
+
chainId,
|
|
7
|
+
address,
|
|
8
|
+
provider,
|
|
9
|
+
pagination
|
|
12
10
|
) {
|
|
13
11
|
try {
|
|
14
12
|
const raacNFTAddress = getContractAddress(chainId, "raacnft");
|
|
@@ -18,14 +16,14 @@ async function getTokensByOwner(
|
|
|
18
16
|
raacNFTAddress,
|
|
19
17
|
raacNFTABI,
|
|
20
18
|
provider
|
|
21
|
-
)
|
|
19
|
+
);
|
|
22
20
|
const balance = await raacNFTContract.balanceOf(address);
|
|
23
21
|
|
|
24
22
|
if (balance === 0n) {
|
|
25
23
|
return { address, tokens: [] };
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
let tokens
|
|
26
|
+
let tokens = [];
|
|
29
27
|
if (pagination) {
|
|
30
28
|
const offset = pagination?.offset || 0;
|
|
31
29
|
const limit = pagination?.limit || 10;
|
|
@@ -42,7 +40,7 @@ async function getTokensByOwner(
|
|
|
42
40
|
|
|
43
41
|
// toString()
|
|
44
42
|
return { address, tokens: tokens.map((token) => token.toString()) };
|
|
45
|
-
} catch (error
|
|
43
|
+
} catch (error) {
|
|
46
44
|
console.error("Error getting owned NFTs:", error);
|
|
47
45
|
throw new Error(`Failed to get owned NFTs: ${error.message}`);
|
|
48
46
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { ethers, Provider
|
|
2
|
-
import
|
|
1
|
+
import { ethers, Provider } from "ethers";
|
|
2
|
+
import getContractAddress from "../contracts/getContractAddress";
|
|
3
3
|
import { getABI } from "../utils/artifacts";
|
|
4
|
-
import { ChainId } from "../configs/chains/index";
|
|
5
|
-
import { RAACHousePrices, RAACNFT } from "../typechain-types";
|
|
6
4
|
|
|
7
|
-
async function getTotalPropertiesCount(chainId
|
|
5
|
+
async function getTotalPropertiesCount(chainId, provider) {
|
|
8
6
|
if (!provider) {
|
|
9
7
|
throw new Error("Wallet not connected");
|
|
10
8
|
}
|
|
@@ -16,13 +14,13 @@ async function getTotalPropertiesCount(chainId: ChainId, provider: Provider) {
|
|
|
16
14
|
raacHousePrices,
|
|
17
15
|
raacHousePricesABI,
|
|
18
16
|
provider
|
|
19
|
-
)
|
|
17
|
+
);
|
|
20
18
|
|
|
21
19
|
const count = await raacHousePricesContract.count();
|
|
22
20
|
|
|
23
21
|
console.log(`Retrieved total properties count: ${count}`);
|
|
24
22
|
return count;
|
|
25
|
-
} catch (error
|
|
23
|
+
} catch (error) {
|
|
26
24
|
console.error("Error retrieving total houses count:", error);
|
|
27
25
|
throw new Error(
|
|
28
26
|
`Failed to retrieve the number of houses: ${error.message}`
|
package/nfts/{mint.ts → mint.js}
RENAMED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
import { ethers, Signer } from "ethers";
|
|
2
|
-
import
|
|
2
|
+
import getContractAddress from "../contracts/getContractAddress";
|
|
3
3
|
import { getABI } from "../utils/artifacts";
|
|
4
|
-
import { ChainId } from "../configs/chains/index";
|
|
5
|
-
import { RAACNFT } from "../typechain-types";
|
|
6
4
|
|
|
7
5
|
async function mint(
|
|
8
|
-
chainId
|
|
9
|
-
tokenId
|
|
10
|
-
amount
|
|
11
|
-
signer
|
|
6
|
+
chainId,
|
|
7
|
+
tokenId,
|
|
8
|
+
amount,
|
|
9
|
+
signer
|
|
12
10
|
) {
|
|
13
11
|
if (!signer) {
|
|
14
12
|
throw new Error("Wallet not connected");
|
|
@@ -22,7 +20,7 @@ async function mint(
|
|
|
22
20
|
raacNFTAddress,
|
|
23
21
|
raacNFTABI,
|
|
24
22
|
signer
|
|
25
|
-
)
|
|
23
|
+
);
|
|
26
24
|
const tx = await raacNFTContract.mint(
|
|
27
25
|
tokenId,
|
|
28
26
|
ethers.parseEther(amount.toString())
|
|
@@ -33,7 +31,7 @@ async function mint(
|
|
|
33
31
|
`Minted RAAC NFT with token ID ${tokenId} for ${amount} tokens`
|
|
34
32
|
);
|
|
35
33
|
return tx;
|
|
36
|
-
} catch (error
|
|
34
|
+
} catch (error) {
|
|
37
35
|
console.error("Error minting RAAC NFT:", error);
|
|
38
36
|
throw new Error(`Failed to mint RAAC NFT: ${error.message}`);
|
|
39
37
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { ethers, Signer } from "ethers";
|
|
2
|
-
import
|
|
2
|
+
import getContractAddress from "../contracts/getContractAddress";
|
|
3
3
|
import { getABI } from "../utils/artifacts";
|
|
4
|
-
import { ChainId } from "../configs/chains/index";
|
|
5
|
-
import { RAACNFT } from "../typechain-types";
|
|
6
4
|
|
|
7
|
-
async function setBaseUri(chainId
|
|
5
|
+
async function setBaseUri(chainId, newUri, signer) {
|
|
8
6
|
if (!signer) {
|
|
9
7
|
throw new Error("Wallet not connected");
|
|
10
8
|
}
|
|
@@ -17,14 +15,14 @@ async function setBaseUri(chainId: ChainId, newUri: string, signer: Signer) {
|
|
|
17
15
|
raacNFTAddress,
|
|
18
16
|
raacNFTABI,
|
|
19
17
|
signer
|
|
20
|
-
)
|
|
18
|
+
);
|
|
21
19
|
|
|
22
20
|
const tx = await raacNFTContract.setBaseUri(newUri);
|
|
23
21
|
await tx.wait();
|
|
24
22
|
|
|
25
23
|
console.log(`Set new base URI: ${newUri}`);
|
|
26
24
|
return tx;
|
|
27
|
-
} catch (error
|
|
25
|
+
} catch (error) {
|
|
28
26
|
console.error("Error setting base URI:", error);
|
|
29
27
|
throw new Error(`Failed to set base URI: ${error.message}`);
|
|
30
28
|
}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { ethers, Provider } from "ethers";
|
|
2
|
-
import
|
|
2
|
+
import getContractAddress from "../contracts/getContractAddress";
|
|
3
3
|
import { getABI } from "../utils/artifacts";
|
|
4
|
-
import { ChainId } from "../configs/chains/index";
|
|
5
|
-
import { RAACNFT } from "../typechain-types";
|
|
6
4
|
|
|
7
|
-
async function totalNFTSupply(chainId
|
|
5
|
+
async function totalNFTSupply(chainId, provider) {
|
|
8
6
|
try {
|
|
9
7
|
const raacNFTAddress = getContractAddress(chainId, "raacnft");
|
|
10
8
|
const raacNFTABI = getABI("raacnft");
|
|
@@ -13,11 +11,11 @@ async function totalNFTSupply(chainId: ChainId, provider: Provider) {
|
|
|
13
11
|
raacNFTAddress,
|
|
14
12
|
raacNFTABI,
|
|
15
13
|
provider
|
|
16
|
-
)
|
|
14
|
+
);
|
|
17
15
|
|
|
18
16
|
const batchSize = await raacNFTContract.totalSupply();
|
|
19
17
|
return batchSize.toString();
|
|
20
|
-
} catch (error
|
|
18
|
+
} catch (error) {
|
|
21
19
|
console.error("Error getting current batch size:", error);
|
|
22
20
|
throw new Error(`Failed to get current batch size: ${error.message}`);
|
|
23
21
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import { ethers
|
|
2
|
-
import
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import getContractAddress from "../../contracts/getContractAddress";
|
|
3
3
|
import { getABI } from "../../utils/artifacts";
|
|
4
|
-
import { ChainId } from "../../configs/chains/index";
|
|
5
|
-
import { LendingPool } from "../../typechain-types";
|
|
6
4
|
|
|
7
5
|
async function borrowFromLendingPool(
|
|
8
|
-
chainId
|
|
9
|
-
tokenId
|
|
10
|
-
amount
|
|
11
|
-
signer
|
|
6
|
+
chainId,
|
|
7
|
+
tokenId,
|
|
8
|
+
amount,
|
|
9
|
+
signer
|
|
12
10
|
) {
|
|
13
11
|
try {
|
|
14
12
|
const lendingPoolAddress = getContractAddress(chainId, "lendingpool");
|
|
@@ -17,7 +15,7 @@ async function borrowFromLendingPool(
|
|
|
17
15
|
lendingPoolAddress,
|
|
18
16
|
lendingPoolABI,
|
|
19
17
|
signer
|
|
20
|
-
)
|
|
18
|
+
);
|
|
21
19
|
|
|
22
20
|
const amountInWei = ethers.parseEther(amount);
|
|
23
21
|
console.log("Borrowing amount in wei:", amountInWei.toString());
|
|
@@ -32,7 +30,7 @@ async function borrowFromLendingPool(
|
|
|
32
30
|
console.log(`Transaction hash: ${receipt?.hash}`);
|
|
33
31
|
|
|
34
32
|
return receipt;
|
|
35
|
-
} catch (error
|
|
33
|
+
} catch (error) {
|
|
36
34
|
console.error("Error in borrowFromLendingPool:", error);
|
|
37
35
|
throw error;
|
|
38
36
|
}
|
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import { ethers
|
|
2
|
-
import
|
|
1
|
+
import { ethers } from "ethers";
|
|
2
|
+
import getContractAddress from "../../contracts/getContractAddress";
|
|
3
3
|
import { getABI } from "../../utils/artifacts";
|
|
4
|
-
import { ChainId } from "../../configs/chains/index";
|
|
5
|
-
import { LendingPool } from "../../typechain-types";
|
|
6
4
|
import checkAllowance from "../../methods/commons/checkAllowance";
|
|
7
5
|
import approveAsset from "../../wallet/assets/approveAsset";
|
|
8
6
|
|
|
9
7
|
async function borrowFromLendingPoolWithInsurance(
|
|
10
|
-
chainId
|
|
11
|
-
tokenId
|
|
12
|
-
amount
|
|
13
|
-
signer
|
|
8
|
+
chainId,
|
|
9
|
+
tokenId,
|
|
10
|
+
amount,
|
|
11
|
+
signer
|
|
14
12
|
) {
|
|
15
13
|
try {
|
|
16
14
|
const lendingPoolAddress = getContractAddress(chainId, "lendingpool");
|
|
@@ -19,7 +17,7 @@ async function borrowFromLendingPoolWithInsurance(
|
|
|
19
17
|
lendingPoolAddress,
|
|
20
18
|
lendingPoolABI,
|
|
21
19
|
signer
|
|
22
|
-
)
|
|
20
|
+
);
|
|
23
21
|
|
|
24
22
|
const feeCollectorAddress = getContractAddress(chainId, "feecollector");
|
|
25
23
|
const userAddress = await signer.getAddress();
|
|
@@ -71,7 +69,7 @@ async function borrowFromLendingPoolWithInsurance(
|
|
|
71
69
|
console.log(`Transaction hash: ${receipt?.hash}`);
|
|
72
70
|
|
|
73
71
|
return receipt;
|
|
74
|
-
} catch (error
|
|
72
|
+
} catch (error) {
|
|
75
73
|
console.error("Error in borrowFromLendingPoolWithInsurance:", error);
|
|
76
74
|
throw error;
|
|
77
75
|
}
|