Skip to content

Commit

Permalink
Merge pull request #22 from XP-NETWORK/test
Browse files Browse the repository at this point in the history
feat(near::selfIsValidator): use the useMutex hook
  • Loading branch information
D4mph1r authored Dec 6, 2024
2 parents ca2f11d + 7714595 commit f6fb0c9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
28 changes: 14 additions & 14 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,20 +104,20 @@ export const bridgeTestChains = [
nativeCoinSymbol: "ICP",
rpcURL: "https://tools.xp.network/",
},
// {
// chain: "NEAR",
// chainType: "near",
// contractAddress: "xp-bridge-test.testnet",
// decimals: 24,
// intialFund: "100000000000000000000000",
// lastBlock: 0,
// nativeCoinSymbol: "NEAR",
// nearBlocksUrl: "https://api-testnet.nearblocks.io/v1/",
// networkId: "testnet",
// rpcURL: "https://archival-rpc.testnet.near.org",
// theGraphApiUrl:
// "https://api.studio.thegraph.com/query/89122/near-xp/version/latest",
// },
{
chain: "NEAR",
chainType: "near",
contractAddress: "xp-bridge-test.testnet",
decimals: 24,
intialFund: "100000000000000000000000",
lastBlock: 0,
nativeCoinSymbol: "NEAR",
nearBlocksUrl: "https://api-testnet.nearblocks.io/v1/",
networkId: "testnet",
rpcURL: "https://archival-rpc.testnet.near.org",
theGraphApiUrl:
"https://api.studio.thegraph.com/query/89122/near-xp/version/latest",
},
{
chain: "BLAST",
rpcURL: "https://blast-sepolia.blockpi.network/v1/rpc/public",
Expand Down
8 changes: 5 additions & 3 deletions src/handler/chains/near/utils/selfIsValidator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Contract } from "near-api-js";
import { useMutexAndRelease } from "../../../utils";

export default async function selfIsValidator(
fetchBridge: () => Promise<
Expand All @@ -7,9 +8,10 @@ export default async function selfIsValidator(
publicKeyInHex: string,
) {
try {
const [bridge, release] = await fetchBridge();
const validator = await bridge.validator({ public_key: publicKeyInHex });
release();
const validator = await useMutexAndRelease(
fetchBridge,
async (bridge) => await bridge.validator({ public_key: publicKeyInHex }),
);
if (!validator) return false;
return true;
} catch (e) {
Expand Down

0 comments on commit f6fb0c9

Please sign in to comment.