Skip to content

Commit

Permalink
chore(providers): refactor minascan to blockberry (#236)
Browse files Browse the repository at this point in the history
* chore(providers): refactor minascan to blockberry

* fix(providers): fix devnet tests
  • Loading branch information
mrcnk authored Dec 19, 2024
1 parent c44a491 commit 557b25b
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -35,8 +35,9 @@ export const createChainHistoryProvider = (
const transactionsByAddresses = async (
args: TransactionsByAddressesArgs,
): Promise<Tx[]> => {
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}`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down
4 changes: 2 additions & 2 deletions packages/vault/src/network-info/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const DEFAULT_NETWORK_INFO: Record<NetworkId, ProviderConfig> = {
},
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",
Expand All @@ -36,7 +36,7 @@ export const DEFAULT_NETWORK_INFO: Record<NetworkId, ProviderConfig> = {
},
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",
Expand Down

0 comments on commit 557b25b

Please sign in to comment.