Skip to content
This repository has been archived by the owner on Jul 22, 2020. It is now read-only.

Commit

Permalink
feat: api rename application to program
Browse files Browse the repository at this point in the history
  • Loading branch information
sunnygleason committed Oct 21, 2019
1 parent 4b7d528 commit 457f00e
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 45 deletions.
4 changes: 2 additions & 2 deletions api/inbound-stream.js
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,13 @@ class RedisHandler {
// NEW
this.redisTimelineImprovedPush(
commands,
`!__timeline:application:${instruction.program_id}`,
`!__timeline:program:${instruction.program_id}`,
txnMsg,
);
// NEW
this.redisRecencySetPush(
commands,
`!__recent:applications`,
`!__recent:programs`,
instruction.program_id,
now_score,
);
Expand Down
2 changes: 1 addition & 1 deletion api/loaders/accounts/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ async function loadAccountTimestamp(redisX, accountId) {
* loadAccountDetail: retrieves raw data about an account from the data store and returns it for formatting
* @param redisX
* @param accountId
* @returns {Promise<{accountInfo: *, __errors__: *, programAccounts: *, applicationId: *, timestamp: *}>}
* @returns {Promise<{accountInfo: *, __errors__: *, programAccounts: *, programId: *, timestamp: *}>}
*/
export async function loadAccountDetail(redisX, accountId) {
const connection = new solanaWeb3.Connection(FULLNODE_URL);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ import * as solanaWeb3 from '@solana/web3.js';
import {FriendlyGet} from '../../friendlyGet';
import {FULLNODE_URL} from '../../fullnode-url';

async function loadApplicationTimestamp(redisX, applicationId) {
const result = await redisX.zscoreAsync('!__recent:programs', applicationId);
async function loadProgramTimestamp(redisX, programId) {
const result = await redisX.zscoreAsync('!__recent:programs', programId);

return result;
}

/**
* loadApplicationDetail: retrieves raw data about an application from the data store and returns it for formatting
* loadProgramDetail: retrieves raw data about a program from the data store and returns it for formatting
*
* @param redisX
* @param applicationId
* @returns {Promise<{accountInfo: *, __errors__: *, programAccounts: *, applicationId: *, timestamp: *}>}
* @param programId
* @returns {Promise<{accountInfo: *, __errors__: *, programAccounts: *, programId: *, timestamp: *}>}
*/
export async function loadApplicationDetail(redisX, applicationId) {
export async function loadProgramDetail(redisX, programId) {
const connection = new solanaWeb3.Connection(FULLNODE_URL);

const {
Expand All @@ -27,18 +27,18 @@ export async function loadApplicationDetail(redisX, applicationId) {
} = await new FriendlyGet()
.with(
'accountInfo',
connection.getAccountInfo(new solanaWeb3.PublicKey(applicationId)),
connection.getAccountInfo(new solanaWeb3.PublicKey(programId)),
)
.with(
'programAccounts',
connection.getProgramAccounts(new solanaWeb3.PublicKey(applicationId)),
connection.getProgramAccounts(new solanaWeb3.PublicKey(programId)),
)
.with('timestamp', loadApplicationTimestamp(redisX, applicationId))
.with('timestamp', loadProgramTimestamp(redisX, programId))
.get();

return {
__errors__,
applicationId,
programId,
accountInfo,
programAccounts,
timestamp,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {getRecencySetInfo, getRecencySetPage} from '../recency';

function parseApplicationEntry(data) {
function parseProgramEntry(data) {
if (!data || data.length < 2) {
return null;
}
Expand All @@ -12,24 +12,24 @@ function parseApplicationEntry(data) {
}

/**
* loadApplicationIndex: retrieves raw data from the data store and returns it for formatting
* loadProgramIndex: retrieves raw data from the data store and returns it for formatting
*
* @param redisX
* @param start
* @param count
* @param direction
* @returns {Promise<{timelinePage: *, timelineInfo: *}>}
*/
export async function loadApplicationIndex(redisX, start, count, direction) {
export async function loadProgramIndex(redisX, start, count, direction) {
const timelineInfo = await getRecencySetInfo(
redisX,
'applications',
parseApplicationEntry,
'programs',
parseProgramEntry,
);

const timelinePage = await getRecencySetPage(
redisX,
'applications',
'programs',
start,
count,
direction,
Expand Down
4 changes: 2 additions & 2 deletions api/loaders/recency.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const MAX_PAGE_SIZE = 1000;
export const DEFAULT_PAGE_SIZE = 100;

/**
* getRecencySetInfo: obtain description of recent accounts/applications set
* getRecencySetInfo: obtain description of recent accounts/programs set
*
* @param redisX
* @param timeline
Expand Down Expand Up @@ -59,7 +59,7 @@ export async function getRecencySetInfo(
}

/**
* getRecencySetPage: get one page of recent accounts/applications index
* getRecencySetPage: get one page of recent accounts/programs index
*
* @param redisX
* @param timeline
Expand Down
28 changes: 14 additions & 14 deletions api/network-explorer.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import {BlockIndexView} from './views/blocks/index';
import {BlockDetailView} from './views/blocks/detail';
import {TransactionIndexView} from './views/transactions/index';
import {TransactionDetailView} from './views/transactions/detail';
import {ApplicationIndexView} from './views/applications/index';
import {ApplicationDetailView} from './views/applications/detail';
import {ProgramIndexView} from './views/programs/index';
import {ProgramDetailView} from './views/programs/detail';
import {AccountIndexView} from './views/accounts/index';
import {AccountDetailView} from './views/accounts/detail';
import {DEFAULT_PAGE_SIZE} from './loaders/timeline';
Expand All @@ -13,8 +13,8 @@ import {loadBlockIndex} from './loaders/blocks/index';
import {loadBlockDetail} from './loaders/blocks/detail';
import {loadTransactionIndex} from './loaders/transactions/index';
import {loadTransactionDetail} from './loaders/transactions/detail';
import {loadApplicationIndex} from './loaders/applications/index';
import {loadApplicationDetail} from './loaders/applications/detail';
import {loadProgramIndex} from './loaders/programs/index';
import {loadProgramDetail} from './loaders/programs/detail';
import {loadAccountIndex} from './loaders/accounts/index';
import {loadAccountDetail} from './loaders/accounts/detail';
import {FriendlyGet} from './friendlyGet';
Expand Down Expand Up @@ -139,47 +139,47 @@ export function addNetworkExplorerRoutes(redisX, app) {
);
});

// Network Explorer Applications Index
app.get('/explorer/applications/index', async (req, res) => {
// Network Explorer Programs Index
app.get('/explorer/programs/index', async (req, res) => {
const q = req.query || {};

const version = q.v || 'ApplicationIndexView@latest';
const version = q.v || 'ProgramIndexView@latest';
const start = q.start || '';
const count = q.count ? parseInt(q.count) : DEFAULT_PAGE_SIZE;
const direction = q.direction || '-';
const {__errors__, rawData} = await new FriendlyGet()
.with(
'rawData',
loadApplicationIndex(redisX, start, count, direction),
loadProgramIndex(redisX, start, count, direction),
{},
)
.get();

res.send(
prettify(
req,
new ApplicationIndexView().asVersion(rawData, __errors__, version),
new ProgramIndexView().asVersion(rawData, __errors__, version),
),
);
});

// Network Explorer Application Detail
app.get('/explorer/applications/:id', async (req, res) => {
// Network Explorer Program Detail
app.get('/explorer/programs/:id', async (req, res) => {
const q = req.query || {};

const version = q.v || 'ApplicationDetailView@latest';
const version = q.v || 'ProgramDetailView@latest';
const {__errors__, rawData} = await new FriendlyGet()
.with(
'rawData',
loadApplicationDetail(redisX, req.params.id, version),
loadProgramDetail(redisX, req.params.id, version),
{},
)
.get();

res.send(
prettify(
req,
new ApplicationDetailView().asVersion(rawData, __errors__, version),
new ProgramDetailView().asVersion(rawData, __errors__, version),
),
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import Base58 from 'base-58';
const b58e = Base58.encode;

/**
* ApplicationDetailView : supports the application detail page
* ProgramDetailView : supports the program detail page
*
* Changes:
* - 20190912.01 : initial version
*/
const __VERSION__ = 'ApplicationDetailView@1.0.0';
const __VERSION__ = 'ProgramDetailView@1.0.0';

export class ApplicationDetailView {
export class ProgramDetailView {
asVersion(rawData, __errors__, version) {
if (__errors__) {
return {
Expand All @@ -19,7 +19,7 @@ export class ApplicationDetailView {
};
}

const applicationId = rawData.applicationId;
const programId = rawData.programId;

const accountInfo = rawData.accountInfo && {
data: rawData.accountInfo.data.toString(),
Expand All @@ -42,13 +42,13 @@ export class ApplicationDetailView {

const data = {
__VERSION__,
applicationId,
programId,
accountInfo,
programAccounts,
timestamp: rawData.timestamp && new Date(parseInt(rawData.timestamp)),
};

if (version === 'ApplicationDetailView@latest' || version === __VERSION__) {
if (version === 'ProgramDetailView@latest' || version === __VERSION__) {
return data;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import _ from 'lodash';

/**
* ApplicationIndexView : supports the application index page
* ProgramIndexView : supports the program index page
*
* Changes:
* - 20190912.01 : initial version
*/
const __VERSION__ = 'ApplicationIndexView@1.0.0';
export class ApplicationIndexView {
const __VERSION__ = 'ProgramIndexView@1.0.0';
export class ProgramIndexView {
asVersion(rawData, __errors__, version) {
if (__errors__) {
return {
Expand Down Expand Up @@ -52,7 +52,7 @@ export class ApplicationIndexView {
timestamp: timelineInfo.dt,
};

if (version === 'ApplicationIndexView@latest' || version === __VERSION__) {
if (version === 'ProgramIndexView@latest' || version === __VERSION__) {
return {
__VERSION__,
pageData,
Expand Down

0 comments on commit 457f00e

Please sign in to comment.