Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add getDataByMessageHash data endpoint #950

Merged
merged 4 commits into from
Nov 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions apps/mana/src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,10 @@ export async function markProposalProcessed(id: string) {
export async function getProposal(id: string) {
return knex(REGISTERED_PROPOSALS).select('*').where({ id }).first();
}

export async function getDataByMessageHash(hash: string) {
return knex(REGISTERED_TRANSACTIONS)
.select(['type', 'data', 'hash', 'network'])
.where({ hash })
.first();
}
3 changes: 2 additions & 1 deletion apps/mana/src/stark/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const jsonRpcRequestSchema = z.object({
'send',
'execute',
'registerTransaction',
'registerProposal'
'registerProposal',
'getDataByMessageHash'
]),
params: z.any()
});
Expand Down
16 changes: 15 additions & 1 deletion apps/mana/src/stark/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,25 @@ export const createNetworkHandler = (chainId: string) => {
}
}

async function getDataByMessageHash(id: number, params: any, res: Response) {
try {
const { hash } = params;

const transaction = await db.getDataByMessageHash(hash);

return rpcSuccess(res, transaction, id);
} catch (e) {
console.log('Failed', e);
return rpcError(res, 500, e, id);
}
}

return {
send,
execute,
registerTransaction,
registerProposal,
getAccount
getAccount,
getDataByMessageHash
};
};
Loading