@raac/rpc 1.1.0-beta.27 → 1.1.0-beta.29

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.
@@ -57,6 +57,7 @@ const mint_1 = __importDefault(require("./nfts/mint"));
57
57
  const getHousePrice_2 = __importDefault(require("./nfts/getHousePrice"));
58
58
  const setBaseUri_1 = __importDefault(require("./nfts/setBaseUri"));
59
59
  const getTokensByOwner_1 = __importDefault(require("./nfts/getTokensByOwner"));
60
+ const getOwnerOfNFT_1 = __importDefault(require("./nfts/getOwnerOfNFT"));
60
61
  // Contracts
61
62
  const getContractAddress_1 = __importDefault(require("./contracts/getContractAddress"));
62
63
  const getContract_1 = __importDefault(require("./contracts/getContract"));
@@ -163,6 +164,7 @@ class RPCLibrary {
163
164
  mint: mint_1.default,
164
165
  getHousePrice: getHousePrice_2.default,
165
166
  getTokensByOwner: getTokensByOwner_1.default,
167
+ getOwnerOfNFT: getOwnerOfNFT_1.default,
166
168
  setBaseUri: setBaseUri_1.default,
167
169
  totalSupply: totalNFTSupply_1.default,
168
170
  getMintPrice: getMintPrice_1.default,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "chainId": 11155111,
3
3
  "name": "sepolia",
4
- "rpcs": ["https://sepolia.infura.io/v3/38126531f7b3458d80e5a822dfbf5854"],
4
+ "rpcs": ["https://eth-sepolia.g.alchemy.com/v2/GRu4-s8cjabOCnh-3ZFzapF-MwUcURV_"],
5
5
  "nativeCurrency": {
6
6
  "name": "ETH",
7
7
  "symbol": "ETH",
@@ -17,12 +17,12 @@
17
17
  "raachouseprices": {
18
18
  "id": "raachouseprices",
19
19
  "name": "RAAC House Prices",
20
- "contract": "0x0f497bE68f0F96c40d4007d9848cCD933dAB3C38"
20
+ "contract": "0x3aD29bF120251BF7B2616B7460d38796535E0753"
21
21
  },
22
22
  "raacprimerateoracle": {
23
23
  "id": "raacprimerateoracle",
24
24
  "name": "RAAC Prime Rate Oracle",
25
- "contract": "0xB710417257e2bcf66759149812e9B5dA97cEcaFF"
25
+ "contract": "0x755853680b66535067E436f218AF87f1C8Db961a"
26
26
  },
27
27
  "auctionfactory": {
28
28
  "id": "auctionfactory",
@@ -42,12 +42,12 @@
42
42
  "feecollector": {
43
43
  "id": "feecollector",
44
44
  "name": "Fee Collector",
45
- "contract": "0x0a4c1755e9d76cdE0361EB6cDF77824cb06C8a98"
45
+ "contract": "0xA7154A854A86050C69Fc2081f0464ba48a1E6830"
46
46
  },
47
47
  "treasury": {
48
48
  "id": "treasury",
49
49
  "name": "Treasury",
50
- "contract": "0xEaA6082460b2a1Cb2059551A5e368d7bB410D94c"
50
+ "contract": "0x6e647B74E06fc008043174EF9fbB06629E143b70"
51
51
  },
52
52
  "repairfund": {
53
53
  "id": "repairfund",
@@ -62,26 +62,26 @@
62
62
  "rwavault": {
63
63
  "id": "rwavault",
64
64
  "name": "RWA Vault",
65
- "contract": "0x0165878A594ca255338adfa4d48449f69242Eb8F"
65
+ "contract": "0xB28264c78bFFAc4Ff4Bc9dB76F138CbaD865F642"
66
66
  }
67
67
  },
68
68
  "pools": {
69
69
  "stabilitypool": {
70
70
  "id": "stabilitypool",
71
71
  "name": "Stability Pool",
72
- "contract": "0xCDc21F23A946Ab63bdF941677AE19dC5aBdD5011"
72
+ "contract": "0x8B8265469B5495c67373fC0655F2c78AcBdAfa5f"
73
73
  },
74
74
  "lendingpool": {
75
75
  "id": "lendingpool",
76
76
  "name": "Lending Pool",
77
- "contract": "0x98981d5Ae694d8a63d008c1763716ae26e36A9A7"
77
+ "contract": "0x29f12b7195A863043C437Ae88ffAFd1e0C89Ec2E"
78
78
  }
79
79
  },
80
80
  "nfts": {
81
81
  "raacnft": {
82
82
  "id": "raacnft",
83
83
  "name": "RAAC NFT",
84
- "contract": "0xc986D2750327EA6454d16cE2cD00BA62421dd0bC"
84
+ "contract": "0xEA034D093C73eaF20dBB3d2489B39b4c86848465"
85
85
  }
86
86
  },
87
87
  "assets": {
@@ -95,43 +95,43 @@
95
95
  "id": "crvusd",
96
96
  "name": "CRVUSD",
97
97
  "decimals": 18,
98
- "contract": "0x0eeFb2Edd6865fdDA929dDAEB87701C34CE6B1A3"
98
+ "contract": "0x144346562EE47526D945E86d55C4203642C3b7fD"
99
99
  },
100
100
  "rtoken": {
101
101
  "id": "rtoken",
102
102
  "name": "RToken",
103
103
  "decimals": 18,
104
- "contract": "0x9c0Aae91BeA71737EE802cb29EAA15a279cE58E6"
104
+ "contract": "0x80D0747737453D30dCE3167bB1284B6c0e6bC5db"
105
105
  },
106
106
  "detoken": {
107
107
  "id": "detoken",
108
108
  "name": "DEToken",
109
109
  "decimals": 18,
110
- "contract": "0x8F499A9303e90a3Df10D6B3C435f78B6b6c0b503"
110
+ "contract": "0x34c4245991d5041BA8ebA6269B7b9386c32BDEEe"
111
111
  },
112
112
  "raactoken": {
113
113
  "id": "raactoken",
114
114
  "name": "RAAC",
115
115
  "decimals": 18,
116
- "contract": "0x1503F1fE0c451214D9555F524E12984858202cC6"
116
+ "contract": "0xB1839AE38339Dc0035571cf856BF24254a27FbBC"
117
117
  },
118
118
  "veraac": {
119
119
  "id": "veraac",
120
120
  "name": "VERAAC",
121
121
  "decimals": 18,
122
- "contract": "0x2a2d358cdC342f58911Fb8d569E6aA66f564e0D2"
122
+ "contract": "0x6eB1E8Ee1F16D23db63Dd8FCe8d127041E8a9588"
123
123
  },
124
124
  "debttoken": {
125
125
  "id": "debttoken",
126
126
  "name": "Debt Token",
127
127
  "decimals": 18,
128
- "contract": "0xf6e002A1E60955d006C5EC1c4Eb74677B73Fba13"
128
+ "contract": "0x596917E0180fcBa1d809511A743Ea7d4ccf92Ca9"
129
129
  },
130
130
  "rwaindextoken": {
131
131
  "id": "rwaindextoken",
132
132
  "name": "RWA Index Token",
133
133
  "decimals": 18,
134
- "contract": "0x3A663C401AdF767d710C7f0133DF40eA18F24863"
134
+ "contract": "0x1be9E0875edfbAE72D087500c502b5F84ca9E9Da"
135
135
  }
136
136
  }
137
137
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "chainId": 18453,
3
3
  "name": "raac",
4
- "rpcs": ["http://44.211.155.244:7654"],
4
+ "rpcs": ["http://44.211.155.244:8545"],
5
5
  "nativeCurrency": {
6
6
  "name": "RAAC",
7
7
  "symbol": "RAAC",
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const ethers_1 = require("ethers");
4
+ const contracts_1 = require("../utils/contracts");
5
+ const artifacts_1 = require("../utils/artifacts");
6
+ /**
7
+ * Get the owner of an NFT token
8
+ * @param chainId - The chain ID
9
+ * @param nftContractName - The NFT contract name from configs
10
+ * @param tokenId - The token ID to check ownership for
11
+ * @param provider - The provider to use for the contract call
12
+ * @returns The owner address of the NFT, or null if the token doesn't exist or has no owner
13
+ */
14
+ async function getOwnerOfNFT(chainId, nftContractName, tokenId, provider) {
15
+ if (!provider) {
16
+ throw new Error("Provider not available");
17
+ }
18
+ try {
19
+ const nftAddress = (0, contracts_1.getContractAddress)(chainId, nftContractName);
20
+ const nftABI = (0, artifacts_1.getABI)(nftContractName);
21
+ const nftContract = new ethers_1.ethers.Contract(nftAddress, nftABI, provider);
22
+ const owner = await nftContract.ownerOf(tokenId);
23
+ console.log(`NFT ${nftContractName} token ID ${tokenId} is owned by ${owner}`);
24
+ return owner;
25
+ }
26
+ catch (error) {
27
+ // If the token doesn't exist, ownerOf will throw an error
28
+ // In this case, we return null as requested
29
+ if (error.message?.includes("nonexistent token") ||
30
+ error.message?.includes("invalid token ID") ||
31
+ error.message?.includes("ERC721: owner query for nonexistent token")) {
32
+ console.log(`NFT ${nftContractName} token ID ${tokenId} does not exist or has no owner`);
33
+ return null;
34
+ }
35
+ console.error(`Error getting owner of NFT ${nftContractName} token ID ${tokenId}:`, error);
36
+ throw new Error(`Failed to get owner of NFT ${nftContractName}: ${error.message}`);
37
+ }
38
+ }
39
+ exports.default = getOwnerOfNFT;
@@ -8,6 +8,8 @@ async function getTokensByOwner(chainId, address, provider, pagination) {
8
8
  const raacNFTAddress = (0, contracts_1.getContractAddress)(chainId, "raacnft");
9
9
  const raacNFTABI = (0, artifacts_1.getABI)("raacnft");
10
10
  const raacNFTContract = new ethers_1.ethers.Contract(raacNFTAddress, raacNFTABI, provider);
11
+ console.log(raacNFTContract);
12
+ console.log(address);
11
13
  const balance = await raacNFTContract.balanceOf(address);
12
14
  if (balance === 0n) {
13
15
  return { address, tokens: [] };
@@ -9,7 +9,7 @@ const chains_1 = __importDefault(require("../configs/chains"));
9
9
  const RPCLibrary_1 = __importDefault(require("../RPCLibrary"));
10
10
  const contracts_1 = require("../utils/contracts");
11
11
  const artifacts_1 = require("../utils/artifacts");
12
- const chainId = 18453;
12
+ const chainId = 11155111;
13
13
  const config = chains_1.default[chainId];
14
14
  const TEST_MNEMONIC = process.env.TEST_MNEMONIC;
15
15
  const TEST_PRIVATE_KEY = process.env.TEST_PRIVATE_KEY;
@@ -17,16 +17,14 @@ async function getProvider() {
17
17
  return new ethers_1.ethers.JsonRpcProvider(config.rpcs[0]);
18
18
  }
19
19
  async function createWallet(mnemonic, provider) {
20
- const wallet = ethers_1.ethers.Wallet.fromPhrase(mnemonic, provider);
21
- console.info(`[${chainId}]: Loaded wallet from mnemonic: ${wallet.address}`);
22
- // the signer is the wallet
23
- return wallet;
24
- // load from private key
25
- // const wallet = new ethers.Wallet(TEST_PRIVATE_KEY, provider);
26
- // console.info(
27
- // `[${chainId}]: Loaded wallet from private key: ${wallet.address}`
28
- // );
20
+ // const wallet = ethers.Wallet.fromPhrase(mnemonic, provider);
21
+ // console.info(`[${chainId}]: Loaded wallet from mnemonic: ${wallet.address}`);
22
+ // // the signer is the wallet
29
23
  // return wallet;
24
+ // load from private key
25
+ const wallet = new ethers_1.ethers.Wallet(TEST_PRIVATE_KEY, provider);
26
+ console.info(`[${chainId}]: Loaded wallet from private key: ${wallet.address}`);
27
+ return wallet;
30
28
  }
31
29
  async function setup() {
32
30
  const provider = await getProvider();
@@ -36,15 +34,38 @@ async function setup() {
36
34
  rpc.provider = provider;
37
35
  rpc.chainId = chainId;
38
36
  // // send myself some CRVUSD
39
- await rpc.wallet.assets.mintAsset(chainId, "crvusd", 10000000n, signer.address, signer);
40
- // // set the base uri to instruxi data gateway
41
- await rpc.nfts.setBaseUri(chainId, "http://44.211.155.244:3000/v1/properties/", signer);
42
- console.log(await rpc.pools.lendingPool.getLendingPoolInfo(chainId, signer.address, provider));
43
- console.log(await rpc.wallet.assets.getBalance(chainId, "rtoken", signer.address, provider));
37
+ // await rpc.wallet.assets.mintAsset(
38
+ // chainId,
39
+ // "crvusd",
40
+ // 10000000n,
41
+ // signer.address,
42
+ // signer
43
+ // );
44
+ // // // set the base uri to instruxi data gateway
45
+ // await rpc.nfts.setBaseUri(
46
+ // chainId,
47
+ // "http://44.211.155.244:3000/v1/properties/",
48
+ // signer
49
+ // );
50
+ // console.log(
51
+ // await rpc.pools.lendingPool.getLendingPoolInfo(
52
+ // chainId,
53
+ // signer.address,
54
+ // provider
55
+ // )
56
+ // );
57
+ // console.log(
58
+ // await rpc.wallet.assets.getBalance(
59
+ // chainId,
60
+ // "rtoken",
61
+ // signer.address,
62
+ // provider
63
+ // )
64
+ // );
44
65
  console.log(await rpc.nfts.getTokensByOwner(chainId, signer.address, provider));
45
66
  // // // set the oracle address of the RAACHousePrice. TEmporarily simulating that I AM THE ORACLE
46
- await rpc.contracts.housePrices.setOracle(chainId, signer.address, signer);
47
- // // // // set price for 3 houses
67
+ // await rpc.contracts.housePrices.setOracle(chainId, signer.address, signer);
68
+ // // // // // set price for 3 houses
48
69
  const housePriceAddress = (0, contracts_1.getContractAddress)(chainId, "raachouseprices");
49
70
  const housePriceABI = (0, artifacts_1.getABI)("raachouseprices");
50
71
  const housePriceContract = new ethers_1.ethers.Contract(housePriceAddress, housePriceABI, signer);
@@ -52,41 +73,67 @@ async function setup() {
52
73
  const raacNFTABI = (0, artifacts_1.getABI)("raacnft");
53
74
  const raacNFTContract = new ethers_1.ethers.Contract(raacNFTAddress, raacNFTABI, signer);
54
75
  const countTokens = 3;
55
- // // // Generate 10 house prices between 100K and 2M
56
- const housePrices = [];
57
- for (let i = 1; i <= countTokens; i++) {
58
- const price = Math.floor(Math.random() * (2000000 - 100000) + 100000);
59
- housePrices.push(price);
60
- }
61
- // // // Mint the new properties
62
- for (let i = 1; i <= countTokens; i++) {
63
- const tx = await raacNFTContract.minterMint(signer.address, i);
64
- await tx.wait();
65
- console.log("Minted NFT", i);
66
- }
67
- // // set house prices
68
- for (let i = 1; i <= countTokens; i++) {
69
- const tx = await housePriceContract.setHousePrice(i, (0, ethers_1.parseEther)(housePrices[i - 1].toString()));
70
- await tx.wait();
71
- console.log("Price set for house", i);
72
- }
76
+ // // // // Generate 10 house prices between 100K and 2M
77
+ // const housePrices = [];
78
+ // for (let i = 1; i <= countTokens; i++) {
79
+ // const price = Math.floor(Math.random() * (2000000 - 100000) + 100000);
80
+ // housePrices.push(price);
81
+ // }
82
+ // // // set house prices with proper error handling and gas management
83
+ // for (const item of housePrices.map((price, index) => ({ id: index + 3, price: parseEther(price.toString()) }))) {
84
+ // try {
85
+ // // Get the current gas price and add a small increment
86
+ // const gasPrice = await provider.getGasPrice();
87
+ // const tx = await housePriceContract.setHousePrice(item.id, item.price, {
88
+ // gasPrice: gasPrice.add(1000000), // Add a small increment to gas price
89
+ // gasLimit: 300000 // Set a specific gas limit
90
+ // });
91
+ // // Wait for the transaction to be mined
92
+ // const receipt = await tx.wait();
93
+ // console.log("Price set for house", item.id, "tx:", receipt.hash);
94
+ // // Add a delay between transactions
95
+ // await new Promise(resolve => setTimeout(resolve, 2000));
96
+ // } catch (error) {
97
+ // console.error(`Failed to set price for house ${item.id}:`, error);
98
+ // // Continue with the next item instead of stopping
99
+ // continue;
100
+ // }
101
+ // }
73
102
  // // confirm the house prices are set
74
- for (let i = 1; i <= countTokens; i++) {
75
- const price = await rpc.nfts.getHousePrice(chainId, i, provider);
76
- console.log("Price for house", i, price);
77
- if (price !== housePrices[i - 1].toString() + ".0") {
78
- throw new Error("Price not set correctly");
79
- }
80
- }
103
+ // for (let i = 1; i <= countTokens; i++) {
104
+ // const price = await rpc.nfts.getHousePrice(chainId, i, provider);
105
+ // console.log("Price for house", i, price);
106
+ // if (price !== housePrices[i - 1].toString() + ".0") {
107
+ // throw new Error("Price not set correctly");
108
+ // }
109
+ // }
110
+ // // // // Mint the new properties
111
+ // for (let i = 1; i <= countTokens; i++) {
112
+ // const tx = await raacNFTContract.minterMint(signer.address, i);
113
+ // await tx.wait();
114
+ // console.log("Minted NFT", i);
115
+ // }
81
116
  // Generate some random NFT and set price only: not purchased yet
82
- let nftIdStart = countTokens + 1;
83
- let nftIdEnd = countTokens + 10;
84
- for (let i = nftIdStart; i <= nftIdEnd; i++) {
85
- const price = Math.floor(Math.random() * (2000000 - 100000) + 100000);
86
- const tx = await housePriceContract.setHousePrice(i, (0, ethers_1.parseEther)(price.toString()));
87
- await tx.wait();
88
- console.log("Price set for house", i);
89
- }
117
+ // let nftIdStart = countTokens + 2;
118
+ // let nftIdEnd = countTokens + 10;
119
+ // for (let i = nftIdStart; i <= nftIdEnd; i++) {
120
+ // try {
121
+ // const price = Math.floor(Math.random() * (2000000 - 100000) + 100000);
122
+ // const tx = await housePriceContract.setHousePrice(
123
+ // i,
124
+ // parseEther(price.toString()),
125
+ // {
126
+ // nonce: await provider.getTransactionCount(signer.address)
127
+ // }
128
+ // );
129
+ // const receipt = await tx.wait();
130
+ // console.log("Price set for house", i, "tx:", receipt.hash);
131
+ // await new Promise(resolve => setTimeout(resolve, 2000));
132
+ // } catch (error) {
133
+ // console.error(`Failed to set price for house ${i}:`, error);
134
+ // continue;
135
+ // }
136
+ // }
90
137
  }
91
138
  const execute = async () => {
92
139
  const provider = await getProvider();
@@ -95,14 +142,7 @@ const execute = async () => {
95
142
  rpc.address = signer.address;
96
143
  rpc.provider = provider;
97
144
  rpc.chainId = chainId;
98
- const lendingPoolAddress = (0, contracts_1.getContractAddress)(chainId, "lendingpool");
99
- const lendingPoolABI = (0, artifacts_1.getABI)("lendingpool");
100
- const lendingPoolContract = new ethers_1.ethers.Contract(lendingPoolAddress, lendingPoolABI, signer);
101
- console.log(await lendingPoolContract.primeRateOracle());
102
- const primeRateOracleAddress = (0, contracts_1.getContractAddress)(chainId, "raacprimerateoracle");
103
- const primeRateOracleABI = (0, artifacts_1.getABI)("raacprimerateoracle");
104
- const primeRateOracleContract = new ethers_1.ethers.Contract(primeRateOracleAddress, primeRateOracleABI, signer);
105
- console.log(await primeRateOracleContract.lastPrimeRate());
145
+ console.log(await rpc.nfts.getTotalPropertiesCount(chainId, provider));
106
146
  };
107
147
  const updateNFTPrice = async (id, price) => {
108
148
  const provider = await getProvider();
@@ -142,6 +182,6 @@ const fulfillRequest = async () => {
142
182
  console.log("Redemption token", redemptionToken);
143
183
  };
144
184
  // execute();
145
- // setup();
146
- // fulfillRequest();
147
185
  setup();
186
+ // fulfillRequest();
187
+ // setup();
@@ -37,6 +37,7 @@ import mintNFT from "./nfts/mint";
37
37
  import getNFTHousePrice from "./nfts/getHousePrice";
38
38
  import setNFTBaseUri from "./nfts/setBaseUri";
39
39
  import getTokensByOwner from "./nfts/getTokensByOwner";
40
+ import getOwnerOfNFT from "./nfts/getOwnerOfNFT";
40
41
  import getContractAddress from "./contracts/getContractAddress";
41
42
  import getContract from "./contracts/getContract";
42
43
  import getLatestPrice from "./contracts/housePrices/getLatestPrice";
@@ -119,6 +120,7 @@ declare class RPCLibrary {
119
120
  mint: typeof mintNFT;
120
121
  getHousePrice: typeof getNFTHousePrice;
121
122
  getTokensByOwner: typeof getTokensByOwner;
123
+ getOwnerOfNFT: typeof getOwnerOfNFT;
122
124
  setBaseUri: typeof setNFTBaseUri;
123
125
  totalSupply: typeof totalNFTSupply;
124
126
  getMintPrice: typeof getMintPrice;
@@ -0,0 +1,13 @@
1
+ import { Provider } from "ethers";
2
+ import { ChainId } from "../configs/chains/index";
3
+ import { NftContractNames } from "./approveNFT";
4
+ /**
5
+ * Get the owner of an NFT token
6
+ * @param chainId - The chain ID
7
+ * @param nftContractName - The NFT contract name from configs
8
+ * @param tokenId - The token ID to check ownership for
9
+ * @param provider - The provider to use for the contract call
10
+ * @returns The owner address of the NFT, or null if the token doesn't exist or has no owner
11
+ */
12
+ declare function getOwnerOfNFT(chainId: ChainId, nftContractName: NftContractNames, tokenId: string, provider: Provider): Promise<string | null>;
13
+ export default getOwnerOfNFT;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raac/rpc",
3
- "version": "1.1.0-beta.27",
3
+ "version": "1.1.0-beta.29",
4
4
  "description": "RPC Library for RAAC ",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",