-
Notifications
You must be signed in to change notification settings - Fork 300
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
2,252 additions
and
605 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[workspace] | ||
members = [ | ||
"program", | ||
] | ||
resolver = "2" | ||
|
||
[profile.release] | ||
overflow-checks = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{ | ||
"name": "steel-hello-solana", | ||
"version": "1.0.0", | ||
"description": "hello world with steel framework for solana", | ||
"scripts": { | ||
"test": "pnpm ts-mocha -p ./tsconfig.json -t 1000000 ./tests/test.ts", | ||
"build-and-test": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./tests/fixtures && pnpm test", | ||
"build": "cargo build-sbf --manifest-path=./program/Cargo.toml --sbf-out-dir=./program/target/so", | ||
"deploy": "solana program deploy ./program/target/so/hello_solana_program.so" | ||
}, | ||
"keywords": [], | ||
"author": "Ayush Chauhan", | ||
"license": "ISC", | ||
"devDependencies": { | ||
"@types/bn.js": "^5.1.0", | ||
"@types/chai": "^4.3.1", | ||
"@types/mocha": "^9.1.1", | ||
"@types/node": "^22.7.4", | ||
"chai": "^4.3.4", | ||
"mocha": "^9.0.3", | ||
"solana-bankrun": "^0.3.0", | ||
"ts-mocha": "^10.0.0", | ||
"typescript": "^4.3.5" | ||
}, | ||
"dependencies": { | ||
"@solana/web3.js": "^1.95.3" | ||
} | ||
} |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[package] | ||
name = "steel-hello-solana" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[lib] | ||
crate-type = ["cdylib", "lib"] | ||
|
||
[dependencies] | ||
solana-program = "2.0.13" | ||
steel = "1.3.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
use steel::*; | ||
use solana_program::msg; | ||
|
||
entrypoint!(process_instruction); | ||
|
||
fn process_instruction( | ||
program_id: &Pubkey, | ||
_accounts: &[AccountInfo], | ||
_instruction_data: &[u8], | ||
) -> ProgramResult { | ||
msg!("Hello, Solana!"); | ||
|
||
msg!("Our program's Program ID: {}", &program_id); | ||
|
||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import { describe, test } from 'node:test'; | ||
import { PublicKey, Transaction, TransactionInstruction } from '@solana/web3.js'; | ||
import { assert } from 'chai'; | ||
import { start } from 'solana-bankrun'; | ||
|
||
describe('hello-solana', async () => { | ||
// load program in solana-bankrun | ||
const PROGRAM_ID = PublicKey.unique(); | ||
const context = await start([{ name: 'steel_hello_solana', programId: PROGRAM_ID }], []); | ||
const client = context.banksClient; | ||
const payer = context.payer; | ||
|
||
test('Say hello!', async () => { | ||
const blockhash = context.lastBlockhash; | ||
// We set up our instruction first. | ||
const ix = new TransactionInstruction({ | ||
keys: [{ pubkey: payer.publicKey, isSigner: true, isWritable: true }], | ||
programId: PROGRAM_ID, | ||
data: Buffer.alloc(0), // No data | ||
}); | ||
|
||
const tx = new Transaction(); | ||
tx.recentBlockhash = blockhash; | ||
tx.add(ix).sign(payer); | ||
|
||
// Now we process the transaction | ||
const transaction = await client.processTransaction(tx); | ||
|
||
assert(transaction.logMessages[0].startsWith(`Program ${PROGRAM_ID}`)); | ||
assert(transaction.logMessages[1] === 'Program log: Hello, Solana!'); | ||
assert(transaction.logMessages[2] === `Program log: Our program's Program ID: ${PROGRAM_ID}`); | ||
assert(transaction.logMessages[3].startsWith(`Program ${PROGRAM_ID} consumed`)); | ||
assert(transaction.logMessages[4] === `Program ${PROGRAM_ID} success`); | ||
assert(transaction.logMessages.length === 5); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
{ | ||
"compilerOptions": { | ||
"types": ["mocha", "chai", "node"], | ||
"typeRoots": ["./node_modules/@types"], | ||
"lib": ["es2015"], | ||
"module": "commonjs", | ||
"target": "es6", | ||
"esModuleInterop": true | ||
} | ||
} |