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

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": 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;
@@ -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 = 8453;
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;
@@ -95,14 +95,7 @@ const execute = async () => {
95
95
  rpc.address = signer.address;
96
96
  rpc.provider = provider;
97
97
  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());
98
+ console.log(await rpc.nfts.getTotalPropertiesCount(chainId, provider));
106
99
  };
107
100
  const updateNFTPrice = async (id, price) => {
108
101
  const provider = await getProvider();
@@ -141,7 +134,7 @@ const fulfillRequest = async () => {
141
134
  const redemptionToken = await rwaVaultContract.getNextRandomNFT();
142
135
  console.log("Redemption token", redemptionToken);
143
136
  };
144
- // execute();
137
+ execute();
145
138
  // setup();
146
139
  // fulfillRequest();
147
- setup();
140
+ // 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.28",
4
4
  "description": "RPC Library for RAAC ",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",