Extract signer public key from tx hash
This commit is contained in:
parent
8f0a727373
commit
0e23e2f3dc
@ -145,7 +145,21 @@ export async function POST(request: NextRequest) {
|
|||||||
const body = await request.json();
|
const body = await request.json();
|
||||||
url = body.url;
|
url = body.url;
|
||||||
txHash = body.txHash;
|
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) {
|
if (!url || !txHash) {
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
|
@ -53,7 +53,7 @@ export default function Home() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Create the Laconic Registry record (payment verification is done in the API)
|
// 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') {
|
if (result.status === 'success') {
|
||||||
setRecordId(result.id);
|
setRecordId(result.id);
|
||||||
|
@ -3,7 +3,6 @@ import { CreateRecordResponse } from '../types';
|
|||||||
export const createApplicationDeploymentRequest = async (
|
export const createApplicationDeploymentRequest = async (
|
||||||
url: string,
|
url: string,
|
||||||
txHash: string,
|
txHash: string,
|
||||||
senderPublicKey: string,
|
|
||||||
): Promise<CreateRecordResponse> => {
|
): Promise<CreateRecordResponse> => {
|
||||||
try {
|
try {
|
||||||
console.log(`Creating deployment request for URL: ${url} with transaction: ${txHash} using ${process.env.NEXT_PUBLIC_SOLANA_TOKEN_SYMBOL} payment`);
|
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: {
|
headers: {
|
||||||
'Content-Type': 'application/json',
|
'Content-Type': 'application/json',
|
||||||
},
|
},
|
||||||
body: JSON.stringify({ url, txHash, senderPublicKey }),
|
body: JSON.stringify({ url, txHash }),
|
||||||
});
|
});
|
||||||
|
|
||||||
const result = await response.json();
|
const result = await response.json();
|
||||||
|
Loading…
Reference in New Issue
Block a user