Closed GitBolt closed 1 year ago
@buffalojoec you can review this one as well! also close the previous expense tracker one. i've been waiting for acheron to review the tutorial, but seems like he is too busy, its been 3 weeks now
Hey there, finally got around to reviewing this. Here's my feedback:
crate::accounts
and crate::instructions
. Not many people (myself included) even know this is a thing.// Clockwork Target Instruction
let target_ix = Instruction {
program_id: ID,
accounts: crate::accounts::AddInterest {
bank_account: bank_account.key(),
thread: thread.key(),
thread_authority: thread_authority.key(),
}.to_account_metas(Some(true)),
data: crate::instruction::AddInterest {
_thread_id: thread_id.clone(),
}.data(),
};
env()
for both Anchor provider calls, and why not pass provider
into ClockworkProvider
instead of program.provider
?anchor.setProvider(anchor.AnchorProvider.env());
const provider = anchor.AnchorProvider.local();
const program = anchor.workspace.Etracker as Program<Bank>;
const wallet = provider.wallet as anchor.Wallet;
const clockworkProvider = ClockworkProvider.fromAnchorProvider(
program.provider as AnchorProvider
);
"dependencies": {
"@clockwork-xyz/sdk": "^0.3.3",
"@coral-xyz/anchor": "^0.27.0",
"@project-serum/anchor": "^0.26.0"
},
import { ClockworkProvider } from "@clockwork-xyz/sdk";
import * as anchor from "@project-serum/anchor";
import { Program } from "@project-serum/anchor";
import { Bank } from "../target/types/bank";
import { AnchorProvider } from "@coral-xyz/anchor";
[test.validator]
url = "https://api.mainnet-beta.solana.com"
[[test.validator.clone]]
address = "CLoCKyJ6DXBJqqu2VWx9RLbgnwwR6BMHHuyasVmfMzBh"
Your naming conventions for the program are different across the various configuration files. You are calling it "program" in Cargo.toml
, but you call it "bank" in other areas like Anchor.toml
. These should all be the same.
In the time since you first submitted this project, there's been a new Solana release (1.16.10
), which has caused issues with Anchor's dependency tree. Please upgrade to Anchor v0.28.
Please address all above feedback, upgrade to Anchor v0.28, and fix the tests so they run for anyone who clones the repo.
Here's what I see when I run the tests:
hey, appreciate it! yeah clearly i missed certain stuff. i used solpg to code it, so the proper local setup was missed as well. fixing them right now.
about versions. right now clockwork does not support solana v1.16.0 (https://github.com/clockwork-xyz/clockwork/releases) so we can't use it right now, and hence, anchor v0.28 won't be required either. I'll fix dependency versions so that it works out of the box for Solana v1.14.16 or v1.14.17
Hey @buffalojoec. Can you check now? I've added detailed instruction of running it locally at the end of the Readme. Also, we don't need to clone the clockwork test validator right? The CLI tool has everything for us and works out of the box
Thanks for addressing my feedback!
Couple more requests, then we should be good to go:
0.26
but the program uses 0.27
lib.rs
: native_token::LAMPORTS_PER_SOL
Fixed! Here is the SolPg tutorial PR - https://github.com/solana-playground/solana-playground/pull/137
Here's the new repo for ya https://github.com/Solana-Workshops/Bank-Simulator
Thank you!
Link: https://github.com/GitBolt/solana-bank-workshop
I'm adding it to SolPg right now. In the meantime, you can review this one as well!
This is a simple bank simulator workshop, which uses Clockwork to automate interest returns and update user's balance every 10 seconds at the rate of 5% return every minute.
Users can:
Since this is a simulation. The interest returns are lot, because we obviously wouldn't want someone to wait for a year to see 5% increment in their initial amount like real world haha