Skip to content

Commit 3c8d9e9

Browse files
authored
Merge pull request #194 from silentgeckoaudit3801/fix/remove-dead-castvote-165
Remove dead stellar-interact castVote helper
2 parents 934f9b8 + e1e017d commit 3c8d9e9

1 file changed

Lines changed: 0 additions & 36 deletions

File tree

src/lib/stellar-interact.ts

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import * as StellarSdk from '@stellar/stellar-sdk';
2-
import { signTransaction } from '@stellar/freighter-api';
32

43
const HORIZON_URL = process.env.NEXT_PUBLIC_HORIZON_URL ?? 'https://horizon-testnet.stellar.org';
54
const server = new StellarSdk.Horizon.Server(HORIZON_URL);
@@ -11,41 +10,6 @@ function decodeBase64(value: string): string {
1110
return Buffer.from(value, 'base64').toString();
1211
}
1312

14-
/**
15-
* Build, sign with Freighter, and submit a vote transaction.
16-
* @param prId GitHub PR number registered by the Vero Relayer
17-
* @param publicKey Guardian's Stellar public key from WalletContext
18-
*/
19-
export async function castVote(prId: number, publicKey: string): Promise<string> {
20-
const account = await server.loadAccount(publicKey);
21-
22-
const tx = new StellarSdk.TransactionBuilder(account, {
23-
fee: StellarSdk.BASE_FEE,
24-
networkPassphrase: StellarSdk.Networks.TESTNET,
25-
})
26-
.addOperation(
27-
StellarSdk.Operation.manageData({ name: `vote_${prId}`, value: 'approve' })
28-
)
29-
.setTimeout(30)
30-
.build();
31-
32-
const signed = await signTransaction(tx.toXDR(), {
33-
networkPassphrase: StellarSdk.Networks.TESTNET,
34-
address: publicKey,
35-
});
36-
if (signed.error) {
37-
throw new Error(signed.error.message ?? 'Freighter failed to sign the vote transaction');
38-
}
39-
if (!signed.signedTxXdr) {
40-
throw new Error('Freighter did not return a signed transaction. Unlock Freighter and try again.');
41-
}
42-
43-
const result = await server.submitTransaction(
44-
StellarSdk.TransactionBuilder.fromXDR(signed.signedTxXdr, StellarSdk.Networks.TESTNET)
45-
);
46-
return result.hash;
47-
}
48-
4913
/** Fetch Guardian reputation score from contract data entries. */
5014
export async function getReputation(publicKey: string): Promise<number> {
5115
const account = await server.loadAccount(publicKey);

0 commit comments

Comments
 (0)