Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 | 1x 1x 261x 261x 261x 261x 261x 261x 261x 261x 261x 2x 148x 148x 11x 137x 1x 1x 65x | import { Cardano, ChainHistoryProvider, Paginated, TransactionsByAddressesArgs } from '@cardano-sdk/core';
const NOT_IMPLEMENTED = 'Not implemented';
export const mockChainHistoryProvider: ChainHistoryProvider = {
blocksByHashes: () => {
throw new Error(NOT_IMPLEMENTED);
},
healthCheck: () => {
throw new Error(NOT_IMPLEMENTED);
},
transactionsByAddresses: (args: TransactionsByAddressesArgs): Promise<Paginated<Cardano.HydratedTx>> => {
const address = args.addresses.length > 0 ? args.addresses[0] : undefined;
// Only even payment indices and indices less than 100 will ''return' results.
if (address) {
const segments = address.split('_');
const paymentIndex = Number(segments[1]);
const stakeIndex = Number(segments[2]);
const isPaymentEven = paymentIndex % 2 === 0;
const isExternalAddress = Number(segments[3]) === 0;
const isStakeAddress = paymentIndex === 0 && stakeIndex > 0;
return Promise.resolve({
pageResults: new Array<Cardano.HydratedTx>(),
totalResultCount: !isStakeAddress && isExternalAddress && isPaymentEven && paymentIndex < 100 ? 1 : 0
});
}
return Promise.resolve({
pageResults: new Array<Cardano.HydratedTx>(),
totalResultCount: 0
});
},
transactionsByHashes: () => {
throw new Error(NOT_IMPLEMENTED);
}
};
export const createMockChainHistoryProvider = (addressesWithTx: Map<Cardano.PaymentAddress, number>) => ({
blocksByHashes: () => {
throw new Error(NOT_IMPLEMENTED);
},
healthCheck: () => {
throw new Error(NOT_IMPLEMENTED);
},
transactionsByAddresses: (args: TransactionsByAddressesArgs): Promise<Paginated<Cardano.HydratedTx>> => {
const address = args.addresses.length > 0 ? args.addresses[0] : undefined;
if (address && addressesWithTx.has(address)) {
return Promise.resolve({
pageResults: new Array<Cardano.HydratedTx>(),
totalResultCount: addressesWithTx.get(address)!
});
}
return Promise.resolve({
pageResults: new Array<Cardano.HydratedTx>(),
totalResultCount: 0
});
},
transactionsByHashes: () => {
throw new Error(NOT_IMPLEMENTED);
}
});
export const mockAlwaysFailChainHistoryProvider: ChainHistoryProvider = {
blocksByHashes: () => {
throw new Error(NOT_IMPLEMENTED);
},
healthCheck: () => {
throw new Error(NOT_IMPLEMENTED);
},
transactionsByAddresses: (): Promise<Paginated<Cardano.HydratedTx>> => {
throw new Error(NOT_IMPLEMENTED);
},
transactionsByHashes: () => {
throw new Error(NOT_IMPLEMENTED);
}
};
export const mockAlwaysEmptyChainHistoryProvider: ChainHistoryProvider = {
blocksByHashes: () => {
throw new Error(NOT_IMPLEMENTED);
},
healthCheck: () => {
throw new Error(NOT_IMPLEMENTED);
},
transactionsByAddresses: async (): Promise<Paginated<Cardano.HydratedTx>> => ({
pageResults: [],
totalResultCount: 0
}),
transactionsByHashes: () => {
throw new Error(NOT_IMPLEMENTED);
}
};
|