From 557b25b71a45b56d2ed14126a6640338191faed0 Mon Sep 17 00:00:00 2001 From: Tomek Marciniak <16132011+mrcnk@users.noreply.github.com> Date: Thu, 19 Dec 2024 09:32:08 +0100 Subject: [PATCH] chore(providers): refactor minascan to blockberry (#236) * chore(providers): refactor minascan to blockberry * fix(providers): fix devnet tests --- .../providers/chain-history-provider/types.ts | 6 +++++- .../chain-history/chain-history-provider.ts | 13 +++++++------ .../test/blockberry/chain-history-provider.test.ts | 2 +- .../test/unified-providers/unified-provider.test.ts | 2 +- packages/vault/src/network-info/default.ts | 4 ++-- 5 files changed, 16 insertions(+), 11 deletions(-) diff --git a/packages/pallad-core/src/Pallad/providers/chain-history-provider/types.ts b/packages/pallad-core/src/Pallad/providers/chain-history-provider/types.ts index 6f1a69e0..6a3f767f 100644 --- a/packages/pallad-core/src/Pallad/providers/chain-history-provider/types.ts +++ b/packages/pallad-core/src/Pallad/providers/chain-history-provider/types.ts @@ -7,7 +7,11 @@ export interface TransactionsByAddressesArgs { chainInfo?: Chain } -export type TransactionsByHashesArgs = { ids: TxHash; chainInfo?: Chain } +export type TransactionsByHashesArgs = { + ids: TxHash + publicKey: ChainAddress + chainInfo?: Chain +} export interface ChainHistoryProvider extends Provider { /** diff --git a/packages/providers/src/blockberry-provider/chain-history/chain-history-provider.ts b/packages/providers/src/blockberry-provider/chain-history/chain-history-provider.ts index 0dc1ebce..f4be3aa3 100644 --- a/packages/providers/src/blockberry-provider/chain-history/chain-history-provider.ts +++ b/packages/providers/src/blockberry-provider/chain-history/chain-history-provider.ts @@ -13,16 +13,16 @@ const convertToTransactionBody = ( ): Mina.TransactionBody[] => { return data.map((item) => ({ type: item.type.toLowerCase() as Mina.TransactionType, - from: item.direction === "OUT" ? address : item.account, - to: item.direction === "OUT" ? item.account : address, + from: item.direction === "OUT" ? address : item.accountAddress, + to: item.direction === "OUT" ? item.accountAddress : address, fee: item.fee, nonce: "", // Not available amount: item.amount, memo: item.memo, validUntil: "", // Not available - blockHeight: item.block, + blockHeight: item.blockHeight, token: "", // Not available - hash: item.transactionHash, + hash: item.txHash, failureReason: "", // Not available dateTime: new Date(item.age).toISOString(), isDelegation: item.type === "delegation", @@ -35,8 +35,9 @@ export const createChainHistoryProvider = ( const transactionsByAddresses = async ( args: TransactionsByAddressesArgs, ): Promise => { - const limit = 20 - const endpoint = `${url}/api/core/accounts/${args.addresses[0]}/activity?page=0&limit=${limit}&sortBy=age&orderBy=DESC&size=${limit}&pk=${args.addresses[0]}&direction=all` + console.log(">>>>ARGS", args, url) + const limit = 50 + const endpoint = `${url}/v1/accounts/${args.addresses[0]}/txs?page=0&sortBy=AGE&orderBy=DESC&size=${limit}&direction=ALL` const response = await fetch(endpoint) if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`) diff --git a/packages/providers/test/blockberry/chain-history-provider.test.ts b/packages/providers/test/blockberry/chain-history-provider.test.ts index f1f75248..9658f90e 100644 --- a/packages/providers/test/blockberry/chain-history-provider.test.ts +++ b/packages/providers/test/blockberry/chain-history-provider.test.ts @@ -4,7 +4,7 @@ import type { Mina } from "@palladxyz/mina-core" import { Blockberry } from "../../src" const explorerUrl = - process.env.ARCHIVE_NODE_URL || "https://minascan.io/devnet/api/" + process.env.ARCHIVE_NODE_URL || "https://pallad.co/api/proxy/mina-devnet" const publicKey = process.env.PUBLIC_KEY || "B62qjsV6WQwTeEWrNrRRBP6VaaLvQhwWTnFi4WP4LQjGvpfZEumXzxb" diff --git a/packages/providers/test/unified-providers/unified-provider.test.ts b/packages/providers/test/unified-providers/unified-provider.test.ts index 78f8a7c1..e4f0cd65 100644 --- a/packages/providers/test/unified-providers/unified-provider.test.ts +++ b/packages/providers/test/unified-providers/unified-provider.test.ts @@ -5,7 +5,7 @@ import type { Tx } from "@palladxyz/pallad-core" import { type ProviderConfig, createChainProvider } from "../../src" const explorerUrl = - process.env.EXPLORER_URL || "https://minascan.io/devnet/api/" + process.env.EXPLORER_URL || "https://pallad.co/api/proxy/mina-devnet" const nodeUrl = process.env.NODE_URL || "https://api.minascan.io/node/devnet/v1/graphql" const publicKey = diff --git a/packages/vault/src/network-info/default.ts b/packages/vault/src/network-info/default.ts index 184097fc..aa22698a 100644 --- a/packages/vault/src/network-info/default.ts +++ b/packages/vault/src/network-info/default.ts @@ -15,7 +15,7 @@ export const DEFAULT_NETWORK_INFO: Record = { }, archiveNodeEndpoint: { providerName: "mina-scan", - url: "https://minascan.io/devnet/api/", + url: "https://pallad.co/api/proxy/mina-devnet", }, explorer: { transactionUrl: "https://minascan.io/devnet/tx/{hash}/txInfo", @@ -36,7 +36,7 @@ export const DEFAULT_NETWORK_INFO: Record = { }, archiveNodeEndpoint: { providerName: "mina-scan", - url: "https://minascan.io/mainnet/api/", + url: "https://pallad.co/api/proxy/mina-mainnet", }, explorer: { transactionUrl: "https://minascan.io/mainnet/tx/{hash}/txInfo",