Skip to content
This repository has been archived by the owner on Jan 7, 2025. It is now read-only.

Changes to few console.log messages. #405

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
33 changes: 23 additions & 10 deletions src/client/hello_world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export async function establishConnection(): Promise<void> {
const rpcUrl = await getRpcUrl();
connection = new Connection(rpcUrl, 'confirmed');
const version = await connection.getVersion();
console.log('Connection to cluster established:', rpcUrl, version);
console.log('\nConnection to Solana cluster established:', rpcUrl, version);
}

/**
Expand All @@ -111,6 +111,18 @@ export async function establishPayer(): Promise<void> {
}

let lamports = await connection.getBalance(payer.publicKey);
console.log('\nPayer Account ID: [' + payer.publicKey + '].');
console.log('\nPayer Account Balance (Before Airdrop): ' + lamports/LAMPORTS_PER_SOL + ' SOL.');

// Request an Airdrop (although not needed) 1 SOL (LAMPORTS_PER_SOL)
const myAirDrop = await connection.requestAirdrop(
payer.publicKey,
LAMPORTS_PER_SOL
);
await connection.confirmTransaction(myAirDrop);
lamports = await connection.getBalance(payer.publicKey);
console.log('\nPayer Account Balance (After Airdrop): ' + lamports/LAMPORTS_PER_SOL + ' SOL.');

if (lamports < fees) {
// If current balance is not enough to pay for fees, request an airdrop
const sig = await connection.requestAirdrop(
Expand All @@ -122,11 +134,11 @@ export async function establishPayer(): Promise<void> {
}

console.log(
'Using account',
payer.publicKey.toBase58(),
'\nUsing Solana blockchain account: ',
'[' + payer.publicKey.toBase58() + ']',
'containing',
lamports / LAMPORTS_PER_SOL,
'SOL to pay for fees',
'SOL to pay for fees.',
);
}

Expand Down Expand Up @@ -158,7 +170,7 @@ export async function checkProgram(): Promise<void> {
} else if (!programInfo.executable) {
throw new Error(`Program is not executable`);
}
console.log(`Using program ${programId.toBase58()}`);
console.log(`\nUsing Solana blockchain program ID: [${programId.toBase58()}].`);

// Derive the address (public key) of a greeting account from the program so that it's easy to find later.
const GREETING_SEED = 'hello';
Expand All @@ -172,7 +184,7 @@ export async function checkProgram(): Promise<void> {
const greetedAccount = await connection.getAccountInfo(greetedPubkey);
if (greetedAccount === null) {
console.log(
'Creating account',
'\nCreating account',
greetedPubkey.toBase58(),
'to say hello to',
);
Expand All @@ -199,7 +211,7 @@ export async function checkProgram(): Promise<void> {
* Say hello
*/
export async function sayHello(): Promise<void> {
console.log('Saying hello to', greetedPubkey.toBase58());
console.log('\nNow saying hello to Solana blockchain account ID: [' + greetedPubkey.toBase58() + '].');
const instruction = new TransactionInstruction({
keys: [{pubkey: greetedPubkey, isSigner: false, isWritable: true}],
programId,
Expand All @@ -217,6 +229,7 @@ export async function sayHello(): Promise<void> {
*/
export async function reportGreetings(): Promise<void> {
const accountInfo = await connection.getAccountInfo(greetedPubkey);

if (accountInfo === null) {
throw 'Error: cannot find the greeted account';
}
Expand All @@ -225,10 +238,10 @@ export async function reportGreetings(): Promise<void> {
GreetingAccount,
accountInfo.data,
);
console.log(
greetedPubkey.toBase58(),
console.log('\nSolana blockchain account ID: ' +
'[' + greetedPubkey.toBase58() + ']',
'has been greeted',
greeting.counter,
'time(s)',
'time(s) so far!',
);
}
8 changes: 5 additions & 3 deletions src/client/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import {
} from './hello_world';

async function main() {
console.log("Let's say hello to a Solana account...");

console.log("****************************************************************************")
console.log("Let's say hello to a Solana blockchain account!");
console.log("****************************************************************************")
// Establish connection to the cluster
await establishConnection();

Expand All @@ -28,7 +29,8 @@ async function main() {
// Find out how many times that account has been greeted
await reportGreetings();

console.log('Success');
console.log('\nSuccess!!');
console.log("*****************************************************************************");
}

main().then(
Expand Down
2 changes: 1 addition & 1 deletion src/program-c/src/helloworld/helloworld.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ uint64_t helloworld(SolParameters *params) {
return ERROR_INVALID_ACCOUNT_DATA;
}

// Increment and store the number of times the account has been greeted
// Increment and store the number of times the account has been greeted
uint32_t *num_greets = (uint32_t *)greeted_account->data;
*num_greets += 1;

Expand Down