33
44import { BlockFrostAPI , Responses } from '@blockfrost/blockfrost-js' ;
55import { Cardano } from '@cardano-sdk/core' ;
6- import { blockfrostChainHistoryProvider } from '../src' ;
6+ import { blockfrostChainHistoryProvider } from '../../ src/ChainHistoryProvider/blockfrostChainHistoryProvider ' ;
77import { dummyLogger as logger } from 'ts-log' ;
88
99jest . mock ( '@blockfrost/blockfrost-js' ) ;
@@ -136,7 +136,7 @@ describe('blockfrostChainHistoryProvider', () => {
136136 ] ;
137137 BlockFrostAPI . prototype . txs = jest . fn ( ) . mockResolvedValue ( mockedTxResponse ) ;
138138 BlockFrostAPI . prototype . txsMetadata = jest . fn ( ) . mockResolvedValue ( mockedMetadataResponse ) ;
139- const blockfrost = new BlockFrostAPI ( { isTestnet : true , projectId : apiKey } ) ;
139+ const blockfrost = new BlockFrostAPI ( { network : 'preprod' , projectId : apiKey } ) ;
140140 const client = blockfrostChainHistoryProvider ( blockfrost , logger ) ;
141141 const response = await client . transactionsByHashes ( {
142142 ids : [ '4123d70f66414cc921f6ffc29a899aafc7137a99a0fd453d6b200863ef5702d6' ] . map ( Cardano . TransactionId )
@@ -172,15 +172,15 @@ describe('blockfrostChainHistoryProvider', () => {
172172 }
173173 } ,
174174 blockHeader : {
175- blockNo : 123_456 ,
175+ blockNo : Cardano . BlockNo ( 123_456 ) ,
176176 hash : Cardano . BlockId ( '356b7d7dbb696ccd12775c016941057a9dc70898d87a63fc752271bb46856940' ) ,
177- slot : 42_000_000
177+ slot : Cardano . Slot ( 42_000_000 )
178178 } ,
179179 body : {
180180 fee : 182_485n ,
181181 inputs : [
182182 {
183- address : Cardano . Address (
183+ address : Cardano . PaymentAddress (
184184 'addr_test1qr05llxkwg5t6c4j3ck5mqfax9wmz35rpcgw3qthrn9z7xcxu2hyfhlkwuxupa9d5085eunq2qywy7hvmvej456flknstdz3k2'
185185 ) ,
186186 index : 1 ,
@@ -189,7 +189,7 @@ describe('blockfrostChainHistoryProvider', () => {
189189 ] ,
190190 outputs : [
191191 {
192- address : Cardano . Address (
192+ address : Cardano . PaymentAddress (
193193 'addr_test1qzx9hu8j4ah3auytk0mwcupd69hpc52t0cw39a65ndrah86djs784u92a3m5w475w3w35tyd6v3qumkze80j8a6h5tuqq5xe8y'
194194 ) ,
195195 value : {
@@ -201,7 +201,7 @@ describe('blockfrostChainHistoryProvider', () => {
201201 }
202202 } ,
203203 {
204- address : Cardano . Address (
204+ address : Cardano . PaymentAddress (
205205 'addr_test1qra788mu4sg8kwd93ns9nfdh3k4ufxwg4xhz2r3n064tzfgxu2hyfhlkwuxupa9d5085eunq2qywy7hvmvej456flkns6cy45x'
206206 ) ,
207207 value : {
@@ -211,13 +211,18 @@ describe('blockfrostChainHistoryProvider', () => {
211211 }
212212 ] ,
213213 validityInterval : {
214- invalidHereafter : 13_885_913
214+ invalidHereafter : Cardano . Slot ( 13_885_913 )
215215 }
216216 } ,
217217 id : Cardano . TransactionId ( '4123d70f66414cc921f6ffc29a899aafc7137a99a0fd453d6b200863ef5702d6' ) ,
218218 index : 1 ,
219- txSize : 433
220- } as Cardano . TxAlonzo ) ;
219+ inputSource : Cardano . InputSource . inputs ,
220+ txSize : 433 ,
221+ witness : {
222+ redeemers : [ ] ,
223+ signatures : new Map ( ) // not available in blockfrost
224+ }
225+ } as Cardano . HydratedTx ) ;
221226 } ) ;
222227 it . todo ( 'with withdrawals' ) ;
223228 it . todo ( 'with redeemer' ) ;
@@ -233,7 +238,7 @@ describe('blockfrostChainHistoryProvider', () => {
233238 test ( 'blocksByHashes' , async ( ) => {
234239 BlockFrostAPI . prototype . blocks = jest . fn ( ) . mockResolvedValue ( blockResponse ) ;
235240
236- const blockfrost = new BlockFrostAPI ( { isTestnet : true , projectId : apiKey } ) ;
241+ const blockfrost = new BlockFrostAPI ( { network : 'preprod' , projectId : apiKey } ) ;
237242 const client = blockfrostChainHistoryProvider ( blockfrost , logger ) ;
238243 const response = await client . blocksByHashes ( {
239244 ids : [ Cardano . BlockId ( '0dbe461fb5f981c0d01615332b8666340eb1a692b3034f46bcb5f5ea4172b2ed' ) ]
@@ -258,15 +263,15 @@ describe('blockfrostChainHistoryProvider', () => {
258263 totalOutput : 9_249_073_880n ,
259264 txCount : 3 ,
260265 vrf : Cardano . VrfVkBech32 ( 'vrf_vk19j362pkr4t9y0m3qxgmrv0365vd7c4ze03ny4jh84q8agjy4ep4s99zvg8' )
261- } as Cardano . Block
266+ } as Cardano . ExtendedBlockInfo
262267 ] ) ;
263268 } ) ;
264269
265270 test ( 'blocksByHashes, genesis delegate slot leader' , async ( ) => {
266271 const slotLeader = 'ShelleyGenesis-eff1b5b26e65b791' ;
267272 BlockFrostAPI . prototype . blocks = jest . fn ( ) . mockResolvedValue ( { ...blockResponse , slot_leader : slotLeader } ) ;
268273
269- const blockfrost = new BlockFrostAPI ( { isTestnet : true , projectId : apiKey } ) ;
274+ const blockfrost = new BlockFrostAPI ( { network : 'preprod' , projectId : apiKey } ) ;
270275 const client = blockfrostChainHistoryProvider ( blockfrost , logger ) ;
271276 const response = await client . blocksByHashes ( {
272277 ids : [ Cardano . BlockId ( '0dbe461fb5f981c0d01615332b8666340eb1a692b3034f46bcb5f5ea4172b2ed' ) ]
0 commit comments