Extract signer public key from tx hash

This commit is contained in:
Shreerang Kale 2025-07-21 17:15:53 +05:30
parent 8f0a727373
commit 0e23e2f3dc
3 changed files with 17 additions and 4 deletions

View File

@ -145,7 +145,21 @@ export async function POST(request: NextRequest) {
const body = await request.json();
url = body.url;
txHash = body.txHash;
senderPublicKey = body.senderPublicKey;
const tx = await connection.getParsedTransaction(txHash, 'confirmed');
if (!tx) {
console.error("Transaction not found.");
return NextResponse.json({
status: 'error',
message: 'Invalid tx hash'
}, { status: 400 });
}
const signerKeys = tx.transaction.message.accountKeys
.filter(k => k.signer)
.map(k => k.pubkey.toBase58());
senderPublicKey = signerKeys[0];
if (!url || !txHash) {
return NextResponse.json({

View File

@ -53,7 +53,7 @@ export default function Home() {
try {
// Create the Laconic Registry record (payment verification is done in the API)
const result = await createApplicationDeploymentRequest(url, hash, solanaWalletState.publicKey);
const result = await createApplicationDeploymentRequest(url, hash);
if (result.status === 'success') {
setRecordId(result.id);

View File

@ -3,7 +3,6 @@ import { CreateRecordResponse } from '../types';
export const createApplicationDeploymentRequest = async (
url: string,
txHash: string,
senderPublicKey: string,
): Promise<CreateRecordResponse> => {
try {
console.log(`Creating deployment request for URL: ${url} with transaction: ${txHash} using ${process.env.NEXT_PUBLIC_SOLANA_TOKEN_SYMBOL} payment`);
@ -14,7 +13,7 @@ export const createApplicationDeploymentRequest = async (
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ url, txHash, senderPublicKey }),
body: JSON.stringify({ url, txHash }),
});
const result = await response.json();