[Blockchain Watcher] (WORMCHAIN) Improve how create the providers (#1561)
* Improve how create the providers for wormchain * Remove validation when create a client * Fix rpcs * Remove bsc rpcs * Add default chain * Throw error when we cant map cosmos chain
This commit is contained in:
parent
615e0e9ff1
commit
911ae24a57
|
@ -12,7 +12,6 @@
|
||||||
"rpcs": [
|
"rpcs": [
|
||||||
"https://api.securerpc.com/v1",
|
"https://api.securerpc.com/v1",
|
||||||
"https://rpc.mevblocker.io/noreverts",
|
"https://rpc.mevblocker.io/noreverts",
|
||||||
"https://endpoints.omniatech.io/v1/eth/mainnet/public",
|
|
||||||
"https://ethereum.publicnode.com"
|
"https://ethereum.publicnode.com"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -38,13 +37,7 @@
|
||||||
"polygon": {
|
"polygon": {
|
||||||
"network": "mainnet",
|
"network": "mainnet",
|
||||||
"chainId": 5,
|
"chainId": 5,
|
||||||
"rpcs": [
|
"rpcs": ["https://rpc-mainnet.matic.quiknode.pro", "https://polygon-rpc.com"]
|
||||||
"https://rpc-mainnet.matic.quiknode.pro",
|
|
||||||
"https://polygon-rpc.com",
|
|
||||||
"https://rpc-mainnet.maticvigil.com",
|
|
||||||
"https://endpoints.omniatech.io/v1/matic/mainnet/public",
|
|
||||||
"https://polygon-bor.publicnode.com"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"avalanche": {
|
"avalanche": {
|
||||||
"network": "mainnet",
|
"network": "mainnet",
|
||||||
|
@ -137,11 +130,7 @@
|
||||||
"arbitrum": {
|
"arbitrum": {
|
||||||
"network": "mainnet",
|
"network": "mainnet",
|
||||||
"chainId": 23,
|
"chainId": 23,
|
||||||
"rpcs": [
|
"rpcs": ["https://arbitrum.blockpi.network/v1/rpc/public", "https://arb1.arbitrum.io/rpc"]
|
||||||
"https://endpoints.omniatech.io/v1/arbitrum/one/public",
|
|
||||||
"https://arbitrum.blockpi.network/v1/rpc/public",
|
|
||||||
"https://arb1.arbitrum.io/rpc"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"optimism": {
|
"optimism": {
|
||||||
"network": "mainnet",
|
"network": "mainnet",
|
||||||
|
|
|
@ -5,6 +5,6 @@ const chains: Map<number, string> = new Map([
|
||||||
[4002, "kujira"],
|
[4002, "kujira"],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
export function mapChain(chainId: number) {
|
export function mapChain(chainId: number): string {
|
||||||
return chains.get(chainId) || "wormchain";
|
return chains.get(chainId) || "wormchain";
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ export class GetWormchainLogs {
|
||||||
|
|
||||||
async execute(
|
async execute(
|
||||||
range: Range,
|
range: Range,
|
||||||
opts: { addresses: string[]; chainId: number }
|
opts: { addresses: string[]; chain: string }
|
||||||
): Promise<WormchainBlockLogs[]> {
|
): Promise<WormchainBlockLogs[]> {
|
||||||
const fromBlock = range.fromBlock;
|
const fromBlock = range.fromBlock;
|
||||||
const toBlock = range.toBlock;
|
const toBlock = range.toBlock;
|
||||||
|
@ -34,7 +34,7 @@ export class GetWormchainLogs {
|
||||||
|
|
||||||
for (let blockNumber = fromBlock; blockNumber <= toBlock; blockNumber++) {
|
for (let blockNumber = fromBlock; blockNumber <= toBlock; blockNumber++) {
|
||||||
const wormchainLogs = await this.blockRepo.getBlockLogs(
|
const wormchainLogs = await this.blockRepo.getBlockLogs(
|
||||||
opts.chainId,
|
opts.chain,
|
||||||
blockNumber,
|
blockNumber,
|
||||||
ATTRIBUTES_TYPES
|
ATTRIBUTES_TYPES
|
||||||
);
|
);
|
||||||
|
|
|
@ -15,7 +15,7 @@ export class GetWormchainRedeems {
|
||||||
|
|
||||||
async execute(
|
async execute(
|
||||||
range: Range,
|
range: Range,
|
||||||
opts: { addresses: string[]; chainId: number }
|
opts: { addresses: string[]; chain: string }
|
||||||
): Promise<CosmosRedeem[]> {
|
): Promise<CosmosRedeem[]> {
|
||||||
let fromBlock = range.fromBlock;
|
let fromBlock = range.fromBlock;
|
||||||
let toBlock = range.toBlock;
|
let toBlock = range.toBlock;
|
||||||
|
@ -35,7 +35,7 @@ export class GetWormchainRedeems {
|
||||||
|
|
||||||
for (let blockNumber = fromBlock; blockNumber <= toBlock; blockNumber++) {
|
for (let blockNumber = fromBlock; blockNumber <= toBlock; blockNumber++) {
|
||||||
const wormchainLogs = await this.blockRepo.getBlockLogs(
|
const wormchainLogs = await this.blockRepo.getBlockLogs(
|
||||||
opts.chainId,
|
opts.chain,
|
||||||
blockNumber,
|
blockNumber,
|
||||||
ATTRIBUTES_TYPES
|
ATTRIBUTES_TYPES
|
||||||
);
|
);
|
||||||
|
|
|
@ -56,7 +56,7 @@ export class PollWormchain extends RunPollingJob {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async get(): Promise<any[]> {
|
protected async get(): Promise<any[]> {
|
||||||
this.latestBlockHeight = await this.blockRepo.getBlockHeight(this.cfg.chainId);
|
this.latestBlockHeight = await this.blockRepo.getBlockHeight(this.cfg.chain);
|
||||||
|
|
||||||
if (!this.latestBlockHeight) {
|
if (!this.latestBlockHeight) {
|
||||||
throw new Error(`Could not obtain latest block height: ${this.latestBlockHeight}`);
|
throw new Error(`Could not obtain latest block height: ${this.latestBlockHeight}`);
|
||||||
|
@ -66,7 +66,7 @@ export class PollWormchain extends RunPollingJob {
|
||||||
|
|
||||||
const records = await this.getWormchain.execute(range, {
|
const records = await this.getWormchain.execute(range, {
|
||||||
addresses: this.cfg.addresses,
|
addresses: this.cfg.addresses,
|
||||||
chainId: this.cfg.chainId,
|
chain: this.cfg.chain,
|
||||||
});
|
});
|
||||||
|
|
||||||
this.lastRange = range;
|
this.lastRange = range;
|
||||||
|
|
|
@ -85,9 +85,9 @@ export interface AptosRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface WormchainRepository {
|
export interface WormchainRepository {
|
||||||
getBlockHeight(chainId: number): Promise<bigint | undefined>;
|
getBlockHeight(chain: string): Promise<bigint | undefined>;
|
||||||
getBlockLogs(
|
getBlockLogs(
|
||||||
chainId: number,
|
chain: string,
|
||||||
blockNumber: bigint,
|
blockNumber: bigint,
|
||||||
attributesTypes: string[]
|
attributesTypes: string[]
|
||||||
): Promise<WormchainBlockLogs>;
|
): Promise<WormchainBlockLogs>;
|
||||||
|
|
|
@ -92,6 +92,7 @@ export class RepositoriesBuilder {
|
||||||
private build(): void {
|
private build(): void {
|
||||||
this.snsClient = this.createSnsClient();
|
this.snsClient = this.createSnsClient();
|
||||||
this.repositories.set("sns", new SnsEventRepository(this.snsClient, this.cfg.sns));
|
this.repositories.set("sns", new SnsEventRepository(this.snsClient, this.cfg.sns));
|
||||||
|
|
||||||
this.cfg.influx &&
|
this.cfg.influx &&
|
||||||
this.repositories.set(
|
this.repositories.set(
|
||||||
"infux",
|
"infux",
|
||||||
|
@ -103,18 +104,23 @@ export class RepositoriesBuilder {
|
||||||
this.cfg.influx
|
this.cfg.influx
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.cfg.metadata?.dir &&
|
this.cfg.metadata?.dir &&
|
||||||
this.repositories.set("metadata", new FileMetadataRepository(this.cfg.metadata.dir));
|
this.repositories.set("metadata", new FileMetadataRepository(this.cfg.metadata.dir));
|
||||||
|
|
||||||
this.repositories.set("metrics", new PromStatRepository());
|
this.repositories.set("metrics", new PromStatRepository());
|
||||||
|
|
||||||
|
const pools = this.createAllProvidersPool();
|
||||||
|
|
||||||
this.cfg.enabledPlatforms.forEach((chain) => {
|
this.cfg.enabledPlatforms.forEach((chain) => {
|
||||||
this.buildWormchainRepository(chain);
|
// Set up all providers because we use various chains
|
||||||
|
this.buildWormchainRepository(chain, pools);
|
||||||
|
this.buildCosmosRepository(chain, pools);
|
||||||
|
this.buildEvmRepository(chain, pools);
|
||||||
|
// Set up the specific providers for the chain
|
||||||
this.buildAlgorandRepository(chain);
|
this.buildAlgorandRepository(chain);
|
||||||
this.buildSolanaRepository(chain);
|
this.buildSolanaRepository(chain);
|
||||||
this.buildCosmosRepository(chain);
|
|
||||||
this.buildAptosRepository(chain);
|
this.buildAptosRepository(chain);
|
||||||
this.buildEvmRepository(chain);
|
|
||||||
this.buildSuiRepository(chain);
|
this.buildSuiRepository(chain);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -226,9 +232,8 @@ export class RepositoriesBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildEvmRepository(chain: string): void {
|
private buildEvmRepository(chain: string, pools: ProviderPoolMap): void {
|
||||||
if (chain == EVM_CHAIN) {
|
if (chain == EVM_CHAIN) {
|
||||||
const pools = this.createAllProvidersPool();
|
|
||||||
const repoCfg: JsonRPCBlockRepositoryCfg = {
|
const repoCfg: JsonRPCBlockRepositoryCfg = {
|
||||||
chains: this.cfg.chains,
|
chains: this.cfg.chains,
|
||||||
environment: this.cfg.environment,
|
environment: this.cfg.environment,
|
||||||
|
@ -286,9 +291,8 @@ export class RepositoriesBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildCosmosRepository(chain: string): void {
|
private buildCosmosRepository(chain: string, pools: ProviderPoolMap): void {
|
||||||
if (chain == COSMOS_CHAIN) {
|
if (chain == COSMOS_CHAIN) {
|
||||||
const pools = this.createAllProvidersPool();
|
|
||||||
const repoCfg: JsonRPCBlockRepositoryCfg = {
|
const repoCfg: JsonRPCBlockRepositoryCfg = {
|
||||||
chains: this.cfg.chains,
|
chains: this.cfg.chains,
|
||||||
environment: this.cfg.environment,
|
environment: this.cfg.environment,
|
||||||
|
@ -302,24 +306,15 @@ export class RepositoriesBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private buildWormchainRepository(chain: string): void {
|
private buildWormchainRepository(chain: string, pools: ProviderPoolMap): void {
|
||||||
if (chain == WORMCHAIN_CHAIN) {
|
if (chain == WORMCHAIN_CHAIN) {
|
||||||
const injectivePools = this.createDefaultProviderPools("injective");
|
const repoCfg: JsonRPCBlockRepositoryCfg = {
|
||||||
const wormchainPools = this.createDefaultProviderPools("wormchain");
|
chains: this.cfg.chains,
|
||||||
const osmosisPools = this.createDefaultProviderPools("osmosis");
|
environment: this.cfg.environment,
|
||||||
const kujiraPools = this.createDefaultProviderPools("kujira");
|
};
|
||||||
const evmosPools = this.createDefaultProviderPools("evmos");
|
|
||||||
|
|
||||||
const cosmosPools: Map<number, ProviderPool<InstrumentedHttpProvider>> = new Map([
|
|
||||||
[19, injectivePools],
|
|
||||||
[20, osmosisPools],
|
|
||||||
[3104, wormchainPools],
|
|
||||||
[4001, evmosPools],
|
|
||||||
[4002, kujiraPools],
|
|
||||||
]);
|
|
||||||
|
|
||||||
const wormchainRepository = new RateLimitedWormchainJsonRPCBlockRepository(
|
const wormchainRepository = new RateLimitedWormchainJsonRPCBlockRepository(
|
||||||
new WormchainJsonRPCBlockRepository(cosmosPools)
|
new WormchainJsonRPCBlockRepository(repoCfg, pools)
|
||||||
);
|
);
|
||||||
|
|
||||||
this.repositories.set("wormchain-repo", wormchainRepository);
|
this.repositories.set("wormchain-repo", wormchainRepository);
|
||||||
|
|
|
@ -17,17 +17,17 @@ export class RateLimitedWormchainJsonRPCBlockRepository
|
||||||
this.logger = winston.child({ module: "RateLimitedWormchainJsonRPCBlockRepository" });
|
this.logger = winston.child({ module: "RateLimitedWormchainJsonRPCBlockRepository" });
|
||||||
}
|
}
|
||||||
|
|
||||||
getBlockHeight(chainId: number): Promise<bigint | undefined> {
|
getBlockHeight(chain: string): Promise<bigint | undefined> {
|
||||||
return this.breaker.fn(() => this.delegate.getBlockHeight(chainId)).execute();
|
return this.breaker.fn(() => this.delegate.getBlockHeight(chain)).execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
getBlockLogs(
|
getBlockLogs(
|
||||||
chainId: number,
|
chain: string,
|
||||||
blockNumber: bigint,
|
blockNumber: bigint,
|
||||||
attributesTypes: string[]
|
attributesTypes: string[]
|
||||||
): Promise<WormchainBlockLogs> {
|
): Promise<WormchainBlockLogs> {
|
||||||
return this.breaker
|
return this.breaker
|
||||||
.fn(() => this.delegate.getBlockLogs(chainId, blockNumber, attributesTypes))
|
.fn(() => this.delegate.getBlockLogs(chain, blockNumber, attributesTypes))
|
||||||
.execute();
|
.execute();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import { divideIntoBatches, hexToHash } from "../common/utils";
|
import { divideIntoBatches, getChainProvider, hexToHash } from "../common/utils";
|
||||||
import { InstrumentedHttpProvider } from "../../rpc/http/InstrumentedHttpProvider";
|
import { ProviderPoolMap, JsonRPCBlockRepositoryCfg } from "../RepositoriesBuilder";
|
||||||
import { WormchainRepository } from "../../../domain/repositories";
|
import { WormchainRepository } from "../../../domain/repositories";
|
||||||
import { ProviderPool } from "@xlabs/rpc-pool";
|
|
||||||
import { setTimeout } from "timers/promises";
|
import { setTimeout } from "timers/promises";
|
||||||
|
import { mapChain } from "../../../common/wormchain";
|
||||||
import winston from "winston";
|
import winston from "winston";
|
||||||
import {
|
import {
|
||||||
WormchainTransaction,
|
WormchainTransaction,
|
||||||
|
@ -19,25 +19,21 @@ let BLOCK_ENDPOINT = "/block";
|
||||||
const GROW_SLEEP_TIME = 350;
|
const GROW_SLEEP_TIME = 350;
|
||||||
const MAX_ATTEMPTS = 20;
|
const MAX_ATTEMPTS = 20;
|
||||||
|
|
||||||
type ProviderPoolMap = ProviderPool<InstrumentedHttpProvider>;
|
|
||||||
|
|
||||||
export class WormchainJsonRPCBlockRepository implements WormchainRepository {
|
export class WormchainJsonRPCBlockRepository implements WormchainRepository {
|
||||||
private readonly logger: winston.Logger;
|
private readonly logger: winston.Logger;
|
||||||
protected cosmosPools: Map<number, ProviderPoolMap>;
|
protected pool: ProviderPoolMap;
|
||||||
|
protected cfg: JsonRPCBlockRepositoryCfg;
|
||||||
|
|
||||||
constructor(cosmosPools: Map<number, ProviderPoolMap>) {
|
constructor(cfg: JsonRPCBlockRepositoryCfg, pool: ProviderPoolMap) {
|
||||||
this.logger = winston.child({ module: "WormchainJsonRPCBlockRepository" });
|
this.logger = winston.child({ module: "WormchainJsonRPCBlockRepository" });
|
||||||
this.cosmosPools = cosmosPools;
|
this.pool = pool;
|
||||||
|
this.cfg = cfg;
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBlockHeight(chainId: number): Promise<bigint | undefined> {
|
async getBlockHeight(chain: string): Promise<bigint | undefined> {
|
||||||
try {
|
try {
|
||||||
let results: ResultBlockHeight;
|
let results: ResultBlockHeight;
|
||||||
|
results = await getChainProvider(chain, this.pool).get<typeof results>(BLOCK_HEIGHT_ENDPOINT);
|
||||||
results = await this.cosmosPools
|
|
||||||
.get(chainId)!
|
|
||||||
.get()
|
|
||||||
.get<typeof results>(BLOCK_HEIGHT_ENDPOINT);
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
results &&
|
results &&
|
||||||
|
@ -56,7 +52,7 @@ export class WormchainJsonRPCBlockRepository implements WormchainRepository {
|
||||||
}
|
}
|
||||||
|
|
||||||
async getBlockLogs(
|
async getBlockLogs(
|
||||||
chainId: number,
|
chain: string,
|
||||||
blockNumber: bigint,
|
blockNumber: bigint,
|
||||||
attributesTypes: string[]
|
attributesTypes: string[]
|
||||||
): Promise<WormchainBlockLogs> {
|
): Promise<WormchainBlockLogs> {
|
||||||
|
@ -65,10 +61,10 @@ export class WormchainJsonRPCBlockRepository implements WormchainRepository {
|
||||||
let resultsBlock: ResultBlock;
|
let resultsBlock: ResultBlock;
|
||||||
|
|
||||||
// Set up cosmos client
|
// Set up cosmos client
|
||||||
const cosmosClient = this.cosmosPools.get(chainId)!;
|
const cosmosClient = getChainProvider(chain, this.pool);
|
||||||
|
|
||||||
// Get wormchain block data
|
// Get wormchain block data
|
||||||
resultsBlock = await cosmosClient.get().get<typeof resultsBlock>(blockEndpoint);
|
resultsBlock = await cosmosClient.get<typeof resultsBlock>(blockEndpoint);
|
||||||
const txs = resultsBlock.result.block.data.txs;
|
const txs = resultsBlock.result.block.data.txs;
|
||||||
|
|
||||||
if (!txs || txs.length === 0) {
|
if (!txs || txs.length === 0) {
|
||||||
|
@ -90,9 +86,9 @@ export class WormchainJsonRPCBlockRepository implements WormchainRepository {
|
||||||
const txEndpoint = `${TRANSACTION_ENDPOINT}?hash=0x${hash}`;
|
const txEndpoint = `${TRANSACTION_ENDPOINT}?hash=0x${hash}`;
|
||||||
|
|
||||||
// Get wormchain transactions data
|
// Get wormchain transactions data
|
||||||
const resultTransaction: ResultTransaction = await cosmosClient
|
const resultTransaction: ResultTransaction = await cosmosClient.get<
|
||||||
.get()
|
typeof resultTransaction
|
||||||
.get<typeof resultTransaction>(txEndpoint);
|
>(txEndpoint);
|
||||||
|
|
||||||
if (
|
if (
|
||||||
resultTransaction &&
|
resultTransaction &&
|
||||||
|
@ -144,14 +140,8 @@ export class WormchainJsonRPCBlockRepository implements WormchainRepository {
|
||||||
async getRedeems(ibcTransaction: IbcTransaction): Promise<CosmosRedeem[]> {
|
async getRedeems(ibcTransaction: IbcTransaction): Promise<CosmosRedeem[]> {
|
||||||
try {
|
try {
|
||||||
// Set up cosmos client
|
// Set up cosmos client
|
||||||
const cosmosClient = this.cosmosPools.get(ibcTransaction.targetChain);
|
const chain = mapChain(ibcTransaction.targetChain);
|
||||||
|
const cosmosClient = getChainProvider(chain, this.pool);
|
||||||
if (!cosmosClient) {
|
|
||||||
this.logger.warn(
|
|
||||||
`[wormchain] No cosmos client found for chain ${ibcTransaction.targetChain}`
|
|
||||||
);
|
|
||||||
return [];
|
|
||||||
}
|
|
||||||
|
|
||||||
let resultTransactionSearch: ResultTransactionSearch | undefined;
|
let resultTransactionSearch: ResultTransactionSearch | undefined;
|
||||||
let isIBCTransferFinalized = false;
|
let isIBCTransferFinalized = false;
|
||||||
|
@ -170,9 +160,7 @@ export class WormchainJsonRPCBlockRepository implements WormchainRepository {
|
||||||
await this.sleep(sleepTime);
|
await this.sleep(sleepTime);
|
||||||
|
|
||||||
// Get cosmos transactions data
|
// Get cosmos transactions data
|
||||||
resultTransactionSearch = await cosmosClient
|
resultTransactionSearch = await cosmosClient.get<typeof resultTransactionSearch>(
|
||||||
.get()
|
|
||||||
.get<typeof resultTransactionSearch>(
|
|
||||||
`${TRANSACTION_SEARCH_ENDPOINT}?query=${query}&prove=false&page=1&per_page=1`
|
`${TRANSACTION_SEARCH_ENDPOINT}?query=${query}&prove=false&page=1&per_page=1`
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -64,7 +64,7 @@ describe("GetWormchainLogs", () => {
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
await thenWaitForAssertion(() =>
|
await thenWaitForAssertion(() =>
|
||||||
expect(getBlockLogsSpy).toBeCalledWith(3104, 7606614n, ["wasm"])
|
expect(getBlockLogsSpy).toBeCalledWith("wormchain", 7606614n, ["wasm"])
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -123,7 +123,7 @@ describe("GetWormchainLogs", () => {
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
await thenWaitForAssertion(() =>
|
await thenWaitForAssertion(() =>
|
||||||
expect(getBlockLogsSpy).toBeCalledWith(3104, 7606615n, ["wasm"])
|
expect(getBlockLogsSpy).toBeCalledWith("wormchain", 7606615n, ["wasm"])
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -64,7 +64,7 @@ describe("GetWormchainRedeems", () => {
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
await thenWaitForAssertion(() =>
|
await thenWaitForAssertion(() =>
|
||||||
expect(getBlockLogsSpy).toBeCalledWith(3104, 8418529n, ["wasm", "send_packet"])
|
expect(getBlockLogsSpy).toBeCalledWith("wormchain", 8418529n, ["wasm", "send_packet"])
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ describe("GetWormchainRedeems", () => {
|
||||||
|
|
||||||
// Then
|
// Then
|
||||||
await thenWaitForAssertion(() =>
|
await thenWaitForAssertion(() =>
|
||||||
expect(getBlockLogsSpy).toBeCalledWith(3104, 7606615n, ["wasm", "send_packet"])
|
expect(getBlockLogsSpy).toBeCalledWith("wormchain", 7606615n, ["wasm", "send_packet"])
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -93,7 +93,7 @@ describe("PollWormchain", () => {
|
||||||
|
|
||||||
await thenWaitForAssertion(
|
await thenWaitForAssertion(
|
||||||
() => expect(getBlockHeightSpy).toHaveReturnedTimes(1),
|
() => expect(getBlockHeightSpy).toHaveReturnedTimes(1),
|
||||||
() => expect(getBlockLogsSpy).toHaveBeenCalledWith(3104, currentHeight, ["wasm"])
|
() => expect(getBlockLogsSpy).toHaveBeenCalledWith("wormchain", currentHeight, ["wasm"])
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -12,22 +12,14 @@ const rpc = "http://localhost";
|
||||||
|
|
||||||
let repo: WormchainJsonRPCBlockRepository;
|
let repo: WormchainJsonRPCBlockRepository;
|
||||||
|
|
||||||
// Mock pools
|
|
||||||
const cosmosPools: Map<number, any> = new Map([
|
|
||||||
[19, () => new InstrumentedHttpProvider({ url: rpc, chain: "injective" })],
|
|
||||||
[3104, { get: () => new InstrumentedHttpProvider({ url: rpc, chain: "wormchain" }) } as any],
|
|
||||||
[4001, { get: () => new InstrumentedHttpProvider({ url: rpc, chain: "evmos" }) } as any],
|
|
||||||
[4002, () => new InstrumentedHttpProvider({ url: rpc, chain: "kujira" })],
|
|
||||||
]);
|
|
||||||
|
|
||||||
describe("WormchainJsonRPCBlockRepository", () => {
|
describe("WormchainJsonRPCBlockRepository", () => {
|
||||||
describe("getBlockHeight", () => {
|
describe("getBlockHeight", () => {
|
||||||
it("should be able to get block height", async () => {
|
it("should be able to get block height", async () => {
|
||||||
const expectedHeight = 9187752n;
|
const expectedHeight = 9187752n;
|
||||||
givenARepo(cosmosPools);
|
givenARepo();
|
||||||
givenBlockHeightIs();
|
givenBlockHeightIs();
|
||||||
|
|
||||||
const result = await repo.getBlockHeight(3104);
|
const result = await repo.getBlockHeight("wormchain");
|
||||||
|
|
||||||
expect(result).toBe(expectedHeight);
|
expect(result).toBe(expectedHeight);
|
||||||
});
|
});
|
||||||
|
@ -35,23 +27,23 @@ describe("WormchainJsonRPCBlockRepository", () => {
|
||||||
|
|
||||||
describe("getBlockLogs", () => {
|
describe("getBlockLogs", () => {
|
||||||
it("should not process the block because does not have transactions", async () => {
|
it("should not process the block because does not have transactions", async () => {
|
||||||
givenARepo(cosmosPools);
|
givenARepo();
|
||||||
givenBlockLogs([]);
|
givenBlockLogs([]);
|
||||||
|
|
||||||
const result = await repo.getBlockLogs(3104, 8453618n, ["wasm", "send_packet"]);
|
const result = await repo.getBlockLogs("wormchain", 8453618n, ["wasm", "send_packet"]);
|
||||||
|
|
||||||
expect(result.transactions).toEqual([]);
|
expect(result.transactions).toEqual([]);
|
||||||
expect(result.blockHeight).toEqual(8453618n);
|
expect(result.blockHeight).toEqual(8453618n);
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should process the block because have one transaction", async () => {
|
it("should process the block because have one transaction", async () => {
|
||||||
givenARepo(cosmosPools);
|
givenARepo();
|
||||||
givenBlockLogs([
|
givenBlockLogs([
|
||||||
"CrYICrMICiQvY29zbXdhc20ud2FzbS52MS5Nc2dFeGVjdXRlQ29udHJhY3QSiggKL3dvcm1ob2xlMTV6ZGFhbjhzN2x0MHgyd2p0d2tsdXowMHB0cGx1a3BqcnZuOGtoEkN3b3JtaG9sZTE0aGoydGF2cThmcGVzZHd4eGN1NDRydHkzaGg5MHZodWpydmNtc3RsNHpyM3R4bWZ2dzlzcnJnNDY1GpEHeyJzdWJtaXRfb2JzZXJ2YXRpb25zIjp7Im9ic2VydmF0aW9ucyI6Ilczc2lkSGhmYUdGemFDSTZJamRXVUM5b1FtazNZalJ4U0ZoQlIxZFNWSGxwUTBKeGVqRkVWVlJzZEVjM01GUnRXbFJQUWxsV2NGazlJaXdpZEdsdFpYTjBZVzF3SWpveE56RTFOelV4TXpjeExDSnViMjVqWlNJ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VRkJRVWRYYnpoSWRscHhSbTFQUnpGMGMwTnZhakJrTlRJNFFqTmFNVUZCU1VGQlFVRkJRVUZCUVVGQlFVRkJRVUZCUVVGQlFVRkJRVUZCUVVGQlFVRkJRVUZCUVVGQlFVRkJRVUU5UFNKOVhRPT0iLCJndWFyZGlhbl9zZXRfaW5kZXgiOjQsInNpZ25hdHVyZSI6eyJpbmRleCI6MCwic2lnbmF0dXJlIjpbMTE4LDI0LDIyMiwxMDcsMjE0LDE4OCwxOTUsMTg1LDYwLDEyMywyMDcsMjA4LDk2LDc5LDE0NSwxNjksNjUsMjAyLDExMyw1MSw0NSw4MiwyOCw1MCwxMDIsMTYsMTcsMTQ2LDIyNSwxNjMsMjAyLDQxLDg3LDI1MCwyMTYsNjgsNTYsMjYsMTYwLDMxLDgwLDgyLDIyMCw3MCw2NCwxNjgsMjU0LDEwMCwzOCw5Nyw1OSwyMzUsMTg0LDEyNiwyMDgsMTYsMjIxLDcyLDEyNSw5Myw5OCwxOTcsMTUyLDE4MSwwXX19fRJaClIKRgofL2Nvc21vcy5jcnlwdG8uc2VjcDI1NmsxLlB1YktleRIjCiECTNU10MWVzKLoEbR3KVeQzNN0RcrBOuz+X/R+8hcjr00SBAoCCAEYhtcEEgQQgIl6GkC6wWnfEe2JArWPIpcypfQ+AhCamp6n+hga87jh07agcAJVuCXS3EgxAc0xdb1y+2TMuapNPwjVDyKctycFVtGn",
|
||||||
]);
|
]);
|
||||||
givenOneTransaction();
|
givenOneTransaction();
|
||||||
|
|
||||||
const result = await repo.getBlockLogs(3104, 8453618n, ["wasm", "send_packet"]);
|
const result = await repo.getBlockLogs("wormchain", 8453618n, ["wasm", "send_packet"]);
|
||||||
|
|
||||||
expect(result).toEqual({
|
expect(result).toEqual({
|
||||||
transactions: [
|
transactions: [
|
||||||
|
@ -145,14 +137,14 @@ describe("WormchainJsonRPCBlockRepository", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it("should process the block because have more than one transaction", async () => {
|
it("should process the block because have more than one transaction", async () => {
|
||||||
givenARepo(cosmosPools);
|
givenARepo();
|
||||||
givenBlockLogs([
|
givenBlockLogs([
|
||||||
"CrYICrMICiQvY29zbXdhc20ud2FzbS52MS5Nc2dFeGVjdXRlQ29udHJhY3QSiggKL3dvcm1ob2xlMXJtZXJteDZ0ZDZwcHI3eDIzeThtYTc1NjRuYXV6d203bnVrOWUwEkN3b3JtaG9sZTE0aGoydGF2cThmcGVzZHd4eGN1NDRydHkzaGg5MHZodWpydmNtc3RsNHpyM3R4bWZ2dzlzcnJnNDY1GpEHeyJzdWJtaXRfb2JzZXJ2YXRpb25zIjp7Im9ic2VydmF0aW9ucyI6Ilczc2lkSGhmYUdGemFDSTZJa1o1WW5wbGRHNTVhVTVRZGpZNVJucEtUR05sTUVoV2JGUlVSV0pTWm5Wa1ZUaDJZVWd6UlRaS04yczlJaXdpZEdsdFpYTjBZVzF3SWpveE56RTFOelV4TlRNMExDSnViMjVqWlNJNk5UWTRORFl4TVRNekxDSmxiV2wwZEdWeVgyTm9ZV2x1SWpvMExDSmxiV2wwZEdWeVgyRmtaSEpsYzNNaU9pSXdNREF3TURBd01EQXdNREF3TURBd01EQXdNREF3TURCaU5tWTJaRGcyWVRobU9UZzNPV0U1WXpnM1pqWTBNemMyT0dRNVpXWmpNemhqTVdSaE5tVTNJaXdpYzJWeGRXVnVZMlVpT2pVMU1ETXpNaXdpWTI5dWMybHpkR1Z1WTNsZmJHVjJaV3dpT2pFMUxDSndZWGxzYjJGa0lqb2lRVkZCUVVGQlFVRkJRVUZCUVVGQlFVRkJRVUZCUVVGQlFVRkJRVUZCUVVGQlFVRkJRVUZUWmpaVVJtUkJRVUZCUVVGQlFVRkJRVUZCUVVGQlZqSTBjamRaT1RkU2RFNUJSbWh0U2tWak16VnBSemswZG5GalFVRm5RVUZCUVVGQlFVRkJRVUZCUVVGQlFYQnpZVlJLT1ZWWVZtODFha05RU0doNlV5OVRjM0pRVGxNdlFVSTBRVUZCUVVGQlFVRkJRVU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yMjYsMTQyLDY5LDExLDc0LDc4LDM5LDIyNywzNyw3MSw1Miw2NiwyMjUsMjA4LDIxMSwxNzEsMjA1LDIyNyw0OSwxNzksMTM3LDE5MywxNjQsMTA4LDFdfX19EloKUgpGCh8vY29zbW9zLmNyeXB0by5zZWNwMjU2azEuUHViS2V5EiMKIQPnPs02nEn7crSxHqFZ7k3b8rPU0hWuOjTvlwrU/UIvwRIECgIIARi77XQSBBCAiXoaQK57xFZmOQFdmdkoHKhlYzyoEfBIaYrzqRUBIliUIRW+Nj9faFWJleYBl4WcLeEj5AB2b7iZZGoD2s7dA10aPlE=",
|
||||||
]);
|
]);
|
||||||
givenTwoTransaction();
|
givenTwoTransaction();
|
||||||
|
|
||||||
const result = await repo.getBlockLogs(3104, 8453618n, ["wasm", "send_packet"]);
|
const result = await repo.getBlockLogs("wormchain", 8453618n, ["wasm", "send_packet"]);
|
||||||
|
|
||||||
expect(result).toEqual({
|
expect(result).toEqual({
|
||||||
transactions: [
|
transactions: [
|
||||||
|
@ -441,29 +433,65 @@ describe("WormchainJsonRPCBlockRepository", () => {
|
||||||
sender: "osmo17zr4md042hn5h84h4ycpk8eq8mwt2rgfp8nug5",
|
sender: "osmo17zr4md042hn5h84h4ycpk8eq8mwt2rgfp8nug5",
|
||||||
};
|
};
|
||||||
|
|
||||||
it("should not be able to get redeems because do not find the cosmos client", async () => {
|
|
||||||
givenARepo(cosmosPools);
|
|
||||||
givenBlockHeightIs();
|
|
||||||
|
|
||||||
osmosisRedeem.targetChain = 20;
|
|
||||||
const result = await repo.getRedeems(osmosisRedeem);
|
|
||||||
|
|
||||||
expect(result).toEqual([]);
|
|
||||||
});
|
|
||||||
|
|
||||||
it("should be able to get the redeems and map the information from cosmos transaction", async () => {
|
it("should be able to get the redeems and map the information from cosmos transaction", async () => {
|
||||||
givenARepo(cosmosPools);
|
givenARepo();
|
||||||
givenOneTransactionByQuery();
|
givenOneTransactionByQuery();
|
||||||
|
|
||||||
const result = await repo.getRedeems(osmosisRedeem);
|
const result = await repo.getRedeems(osmosisRedeem);
|
||||||
|
|
||||||
expect(result).toEqual([]);
|
expect(result.length).toEqual(1);
|
||||||
|
expect(result[0].chainId).toEqual(4001);
|
||||||
|
expect(result[0].hash).toEqual(
|
||||||
|
"1B099AAD307B55CED63DCE877961BF8AB04B0A2E13FFC7EEF7AAC1293AC069A6"
|
||||||
|
);
|
||||||
|
expect(result[0].height).toEqual(19255525n);
|
||||||
|
expect(result[0].blockTimestamp).toEqual(1715751595401);
|
||||||
|
});
|
||||||
|
|
||||||
|
it("should not be able to get redeems because do not find the cosmos client", async () => {
|
||||||
|
givenARepo();
|
||||||
|
givenBlockHeightIs();
|
||||||
|
|
||||||
|
try {
|
||||||
|
osmosisRedeem.targetChain = 20;
|
||||||
|
await repo.getRedeems(osmosisRedeem);
|
||||||
|
} catch (e) {
|
||||||
|
expect(e).toBeInstanceOf(Error);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
const givenARepo = (cosmosPools: any = undefined) => {
|
const givenARepo = () => {
|
||||||
repo = new WormchainJsonRPCBlockRepository(cosmosPools);
|
repo = new WormchainJsonRPCBlockRepository(
|
||||||
|
{
|
||||||
|
chains: {
|
||||||
|
injective: {
|
||||||
|
rpcs: [rpc],
|
||||||
|
timeout: 100,
|
||||||
|
name: "injective",
|
||||||
|
network: "mainnet",
|
||||||
|
chainId: 19,
|
||||||
|
},
|
||||||
|
wormchain: {
|
||||||
|
rpcs: [rpc],
|
||||||
|
timeout: 100,
|
||||||
|
name: "wormchain",
|
||||||
|
network: "mainnet",
|
||||||
|
chainId: 3104,
|
||||||
|
},
|
||||||
|
evmos: { rpcs: [rpc], timeout: 100, name: "evmos", network: "mainnet", chainId: 4001 },
|
||||||
|
kujira: { rpcs: [rpc], timeout: 100, name: "kujira", network: "mainnet", chainId: 4002 },
|
||||||
|
},
|
||||||
|
environment: "mainnet",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
injective: { get: () => new InstrumentedHttpProvider({ url: rpc, chain: "injective" }) },
|
||||||
|
wormchain: { get: () => new InstrumentedHttpProvider({ url: rpc, chain: "wormchain" }) },
|
||||||
|
evmos: { get: () => new InstrumentedHttpProvider({ url: rpc, chain: "evmos" }) },
|
||||||
|
kujira: { get: () => new InstrumentedHttpProvider({ url: rpc, chain: "kujira" }) },
|
||||||
|
} as any
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const givenBlockHeightIs = () => {
|
const givenBlockHeightIs = () => {
|
||||||
|
|
Loading…
Reference in New Issue