Comments (10)
I'm not able to reproduce this. Are you you using version 0.22.0
of the cli and the imported anchor-lang
?
from anchor-book.
0.22.0 on Ubuntu WSL on Windows 10 loaded via the AWM & the same errors thrown with 0.20.1 installed with NPM before the upgrade. Following instructions on both verbatim.
from anchor-book.
Possible to upload the finalized versions of the modified lib.rs files etc.; maybe at the end of the book example...I think there are other requests for this.
from anchor-book.
have you uninstalled the npm version?
Ill upload the files tmr when Im back at my laptop
from anchor-book.
Yes. The NPM version was successfully removed. Anchor was off the machine, then reinstalled with the AWM and restarted with latest.
from anchor-book.
in the Cargo.toml of the program itself does it say anchor-lang = 0.22.0
?
from anchor-book.
No. Now updated from 0.20.1 but this error is thrown...
error[E0412]: cannot find type ProgramResult
in this scope
--> programs/tic-tac-toe/src/lib.rs:11:52
|
11 | pub fn initialize(ctx: Context) -> ProgramResult {
| ^^^^^^^^^^^^^ not found in this scope
warning: unused import: num_traits
--> programs/tic-tac-toe/src/lib.rs:6:5
|
6 | use num_traits::*;
| ^^^^^^^^^^
|
= note: #[warn(unused_imports)]
on by default
For more information about this error, try rustc --explain E0412
.
warning: tic-tac-toe
(lib) generated 1 warning
error: could not compile tic-tac-toe
due to previous error; 1 warning emitted
from anchor-book.
this is a bug in the cli. Just change ProgramResult to Result<()>
or copy the code from the book.
from anchor-book.
Success. Much thanks! Here is the complete, updated lib.rs for reference.
`use anchor_lang::prelude::*;
declare_id!("Fg6PaFpoGXkYsidMpWTK6W2BeZ7FEfcYkg476zPFsLnS");
use num_derive::;
use num_traits::;
#[program]
pub mod tic_tac_toe {
use super::*;
pub fn initialize(ctx: Context) -> Result<()> {
Ok(())
}
}
#[derive(Accounts)]
pub struct Initialize {}
#[account]
#[derive(Default)]
pub struct Game {
players: [Pubkey; 2], // 64
turn: u8, // 1
board: [[Option; 3]; 3], // 9 * (1 + 1) = 18
state: GameState, // 32 + 1
}
#[derive(AnchorSerialize, AnchorDeserialize, Clone, PartialEq, Eq)]
pub enum GameState {
Active,
Tie,
Won { winner: Pubkey },
}
#[derive(
AnchorSerialize, AnchorDeserialize, FromPrimitive, ToPrimitive, Copy, Clone, PartialEq, Eq,
)]
pub enum Sign {
X,
O,
}
impl Default for GameState {
fn default() -> Self {
Self::Active
}
}
#[derive(Accounts)]
pub struct SetupGame<'info> {
#[account(init, payer = player_one)]
pub game: Account<'info, Game>,
#[account(mut)]
pub player_one: Signer<'info>,
pub system_program: Program<'info, System>,
}
pub fn setup_game(ctx: Context, player_two: Pubkey) -> Result<()> {
let game = &mut ctx.accounts.game;
game.players = [ctx.accounts.player_one.key(), player_two];
game.turn = 1;
Ok(())
}
`
from anchor-book.
great! Im uploading the program to the repo currently
from anchor-book.
Related Issues (20)
- tic-tac-toe test throwing Error: unknown signer: ... HOT 1
- add Anchor.toml reference section HOT 1
- remove default space calc from book HOT 1
- multiple book versions at the same time HOT 1
- `anchor shell` is undocumented in the cli chapter HOT 1
- add an appendix chapter (below the line where the `Reference Links` are) for rust types and rust types -> ts types conversion HOT 1
- update error and milestone project section to include `AnchorError` HOT 1
- Add a chapter that explains the space used by borsh serialization in an easier-to-understand way than borsh.io does HOT 1
- Move some info out of the milestone chapter such as how space is calculated HOT 1
- Cargo cannot install avm HOT 2
- require! macro
- TicTacToe example: trying to use ctx inside Game HOT 1
- Testing a game that transfer lamports: "sum of account balances before and after instruction do not match" HOT 2
- use mdbook includes and Anchors for milestone project instead of copy pasting code into the book
- Initial test fails
- bug about "Tic-Tac-Toe" project.
- Splitting program into multiple files failed HOT 1
- Syntax Error Due to Missing Semicolon in PDAs.md
- [broken link]
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from anchor-book.