diff --git a/.bun-version b/.bun-version index 1c99cf0..e516bb9 100644 --- a/.bun-version +++ b/.bun-version @@ -1 +1 @@ -1.4.4 +1.4.5 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index f22c3e2..8c03110 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -24,7 +24,7 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 with: - bun-version: 1.4.4 + bun-version: 1.4.5 - name: Restore Bun cache uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: @@ -70,7 +70,7 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 with: - bun-version: 1.4.4 + bun-version: 1.4.5 - name: Restore Bun cache uses: actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: @@ -101,7 +101,7 @@ jobs: cargo-${{ runner.os }}-${{ hashFiles('rust-toolchain.toml') }}- - name: Install Cargo tools # Installs the versions pinned in mise.toml, and caches them. - uses: jdx/mise-action@b44d12e7d0d8ee7461bb893e1b1993500433185b # v5.2.7 + uses: jdx/mise-action@90f833d396d0cc3674b631d2d225e306476c303a # v5.2.10 - name: Audit dependencies run: cargo audit - name: Check formatting diff --git a/.github/workflows/mutants.yml b/.github/workflows/mutants.yml index e24f20f..7f052b4 100644 --- a/.github/workflows/mutants.yml +++ b/.github/workflows/mutants.yml @@ -76,7 +76,7 @@ jobs: fetch-depth: 2 - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 with: - bun-version: 1.4.4 + bun-version: 1.4.5 - name: Restore Bun cache uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: @@ -219,7 +219,7 @@ jobs: - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 with: - bun-version: 1.4.4 + bun-version: 1.4.5 - name: Restore Bun cache uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0 with: diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 52d093b..63d99bd 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -24,13 +24,13 @@ jobs: - name: Setup Node.js uses: actions/setup-node@949feb2413d6458794dcd2491c4babbbce0c15c1 # v7.1.0 with: - node-version: 26.13.0 + node-version: 26.13.1 registry-url: https://npm.pkg.github.com scope: "@timbagame" - uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0 with: - bun-version: 1.4.4 + bun-version: 1.4.5 - name: Check whether this version is published id: version diff --git a/.node-version b/.node-version index 1dda03d..a2e8115 100644 --- a/.node-version +++ b/.node-version @@ -1 +1 @@ -26.13.0 +26.13.1 diff --git a/Cargo.lock b/Cargo.lock index 7de08d9..8fcba90 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1016,9 +1016,9 @@ checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb" [[package]] name = "form_urlencoded" -version = "1.2.2" +version = "1.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cb4cb245038516f5f85277875cdaa4f7d2c9a0fa0468de06ed190163b1581fcf" +checksum = "afa489199eaffb1211795df1c6236ce1ad0d41a6fa45250add73e3b02420f06e" dependencies = [ "percent-encoding", ] @@ -1911,9 +1911,9 @@ dependencies = [ [[package]] name = "regex" -version = "1.13.1" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d" +checksum = "9807af0e638c12e753aa1b4e601791bf2a8f71274023c8bbeec12fc149950857" dependencies = [ "aho-corasick", "memchr", @@ -1923,9 +1923,9 @@ dependencies = [ [[package]] name = "regex-automata" -version = "0.4.18" +version = "0.4.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2" +checksum = "41d60ef07df457506a0a1a2073112eb4aae5733dbd2813c3da77d1b0fd441158" dependencies = [ "aho-corasick", "memchr", @@ -1934,9 +1934,9 @@ dependencies = [ [[package]] name = "regex-syntax" -version = "0.8.11" +version = "0.8.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4" +checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6" [[package]] name = "rfc6979" @@ -2516,9 +2516,9 @@ checksum = "ebc1c04c71510c7f702b52b7c350734c9ff1295c464a03335b00bb84fc54f853" [[package]] name = "url" -version = "2.5.8" +version = "2.5.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ff67a8a4397373c3ef660812acab3268222035010ab8680ec4215f38ba3d0eed" +checksum = "f00cd2407bb42c0ef17be88d4cf020f5cceffd121665bac9b8b9493a369b3b1a" dependencies = [ "form_urlencoded", "idna", diff --git a/bun.lock b/bun.lock index b66fa3a..63281df 100644 --- a/bun.lock +++ b/bun.lock @@ -8,12 +8,12 @@ "@solana-program/system": "0.16.0", "@solana-program/token": "0.18.0", "@solana/kit": "8.6.0", - "viem": "2.57.16", + "viem": "2.58.1", "zod": "4.6.7", }, "devDependencies": { "@codama/nodes-from-anchor": "1.5.6", - "@codama/renderers-js": "2.8.0", + "@codama/renderers-js": "2.9.0", "@hughescr/stryker-bun-runner": "1.6.0", "@stryker-mutator/core": "10.1.1", "@types/bun": "^1.4.4", @@ -121,7 +121,7 @@ "@codama/renderers-core": ["@codama/renderers-core@1.4.1", "", { "dependencies": { "@codama/errors": "1.11.0", "@codama/fragments": "1.0.0", "@codama/nodes": "1.11.0", "@codama/visitors-core": "1.11.0" } }, "sha512-L/mNuzP29emEz9O2+tghToNvtTnfjpenJ984LrnRi4p8uonf3vOROUzDE+9w5httoowQt0YHCxFvQ8DP5lK0DQ=="], - "@codama/renderers-js": ["@codama/renderers-js@2.8.0", "", { "dependencies": { "@codama/errors": "^1.10.0", "@codama/nodes": "^1.10.0", "@codama/renderers-core": "^1.3.11", "@codama/visitors-core": "^1.10.0", "@solana/codecs-strings": "^8.0.0", "prettier": "^3.8.1", "semver": "^7.7.3" } }, "sha512-1aiLDaZw73lYY848W19giAwIKLf92eLWtO8yI8OS7oIBSPZ3fY73SjgBnGX5fqvju11hzt9T9i7IGu04JNuDGA=="], + "@codama/renderers-js": ["@codama/renderers-js@2.9.0", "", { "dependencies": { "@codama/errors": "^1.10.0", "@codama/nodes": "^1.10.0", "@codama/renderers-core": "^1.3.11", "@codama/visitors-core": "^1.10.0", "@solana/codecs-strings": "^8.0.0", "prettier": "^3.8.1", "semver": "^7.7.3" } }, "sha512-7m6m2CZoM5qEWw7S5FC/bFnIqvZ7tGHSqv+KIcawfip2ozVA2iJdhAWE68fHs+AF3z4/X4lGtqkQLppE/yev+A=="], "@codama/validators": ["@codama/validators@1.11.0", "", { "dependencies": { "@codama/errors": "1.11.0", "@codama/nodes": "1.11.0", "@codama/visitors-core": "1.11.0" } }, "sha512-aOv+DL01aUkg7lW4N1A37NZ6cpWdNvlYV0M6FSP7IhqX4h3wsdnoBWMp5pRbZKYlJp78uF1dG9+W5U7l9SKxOg=="], @@ -503,7 +503,7 @@ "obug": ["obug@3.0.0", "", {}, "sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw=="], - "ox": ["ox@0.14.59", "", { "dependencies": { "@adraffy/ens-normalize": "^1.11.0", "@noble/ciphers": "^1.3.0", "@noble/curves": "1.9.1", "@noble/hashes": "^1.8.0", "@scure/bip32": "^1.7.0", "@scure/bip39": "^1.6.0", "abitype": "^1.2.3", "eventemitter3": "5.0.1" }, "peerDependencies": { "typescript": ">=5.4.0" }, "optionalPeers": ["typescript"] }, "sha512-Y+DPEQScTEGKteQATjtytE1JRQ5cg1R2+DvYQ/lbhUCm/xS9n0Jnkkf2AqQyIntefQxs8xY6dZ+kyNZ7zf2FzA=="], + "ox": ["ox@0.14.67", "", { "dependencies": { "@adraffy/ens-normalize": "^1.11.0", "@noble/ciphers": "^1.3.0", "@noble/curves": "1.9.1", "@noble/hashes": "^1.8.0", "@scure/bip32": "^1.7.0", "@scure/bip39": "^1.6.0", "abitype": "^1.2.3", "eventemitter3": "5.0.1" }, "peerDependencies": { "typescript": ">=5.4.0" }, "optionalPeers": ["typescript"] }, "sha512-6v6UlwgsmiyTujZp0aVDuN8uIBAtl/QZadBADFRZ2zp1+CM9TqDzd+rPKJ5PYvWPlCvz8JvoO9dTr42+1PhBhA=="], "parse-ms": ["parse-ms@4.0.0", "", {}, "sha512-TXfryirbmq34y8QBwgqCVLi+8oA3oWx2eAnSn62ITyEhEYaWRlVZ2DvMM9eZbMs/RfxPu/PK/aBLyGj4IrqMHw=="], @@ -579,7 +579,7 @@ "verkit": ["verkit@0.5.0", "", {}, "sha512-u4J1hr6Y+C/hit34GwL3eIcUf3wngT8TlYUjK7tk0jxydKLAq3sYvifjdTDA6U3KCKRcQCQDGf/srjxfZF3l7g=="], - "viem": ["viem@2.57.16", "", { "dependencies": { "@noble/curves": "1.9.1", "@noble/hashes": "1.8.0", "@scure/bip32": "1.7.0", "@scure/bip39": "1.6.0", "abitype": "1.2.3", "isows": "1.0.7", "ox": "0.14.59", "ws": "8.21.0" }, "peerDependencies": { "mppx": ">=0.17.0", "typescript": ">=5.0.4" }, "optionalPeers": ["mppx", "typescript"] }, "sha512-+4uaUw3NfkqjaqsZp8Zci94K33oc9rv7mIUgvPduJxsY/tI0ASi2YkaXoUVSBGfdIw/QPWuVnIf9LTFf35IoMg=="], + "viem": ["viem@2.58.1", "", { "dependencies": { "@noble/curves": "1.9.1", "@noble/hashes": "1.8.0", "@scure/bip32": "1.7.0", "@scure/bip39": "1.6.0", "abitype": "1.2.3", "isows": "1.0.7", "ox": "0.14.67", "ws": "8.21.0" }, "peerDependencies": { "mppx": ">=0.17.0", "typescript": ">=5.0.4" }, "optionalPeers": ["mppx", "typescript"] }, "sha512-8qzo5+rbG4Sr9/MvUit9g0r/0H25suExk5WEBOzqXoTu7nYfm8EpgCTtpqQAlu8HkBmz96clZHfN7RkXKT3a1g=="], "weapon-regex": ["weapon-regex@2.0.6", "", {}, "sha512-iJC2vqYp+bh3r4X6zjuP0h65XqXjgUX3nJgmhj0PQMrdhAbUwCfN76CSTEEQqV3G7468kjOJ69PmytTG8l/8Gg=="], diff --git a/crates/timba-protocol/src/events.rs b/crates/timba-protocol/src/events.rs index 853abd3..c66269b 100644 --- a/crates/timba-protocol/src/events.rs +++ b/crates/timba-protocol/src/events.rs @@ -625,4 +625,20 @@ mod tests { ]; assert_eq!(get_trusted_program_data(&logs, program), vec![vec![5u8; 12]]); } + + #[test] + fn trusted_program_data_keeps_the_frame_after_a_stray_completion() { + let program = "32Jr4JnXWvqq9GqPQynkooHsszaucUUvZfNLh2hdX2L5"; + let other = "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"; + let payload = base64::engine::general_purpose::STANDARD.encode([5u8; 12]); + let logs = vec![ + format!("Program {program} invoke [1]"), + // A completion for a program that does not own the top frame + // must not close the frame. + format!("Program {other} success"), + format!("Program data: {payload}"), + format!("Program {program} success"), + ]; + assert_eq!(get_trusted_program_data(&logs, program), vec![vec![5u8; 12]]); + } } diff --git a/crates/timba-protocol/src/plans.rs b/crates/timba-protocol/src/plans.rs index 358d856..984a371 100644 --- a/crates/timba-protocol/src/plans.rs +++ b/crates/timba-protocol/src/plans.rs @@ -468,4 +468,46 @@ mod tests { assert!(is_wrapped_sol(&NATIVE_MINT)); assert!(!is_wrapped_sol(&TOKEN_PROGRAM_ID)); } + + #[test] + fn sol_joins_require_a_positive_stake() { + let adapter = ContractAdapter::new(ContractVersion::V0_3_0, PROGRAM_ID); + let player = Address::parse("9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM").unwrap(); + for token_amount in [None, Some(0)] { + let input = GameInstructionInput { + game: Address([9; 32]), + player, + token_mint: NATIVE_MINT, + token_amount, + authority: None, + }; + assert_eq!( + adapter.build_join_plan(&input).unwrap_err(), + PlanError::Invalid("SOL joins require a positive stake amount".into()), + "{token_amount:?}" + ); + } + } + + #[test] + fn create_game_requires_a_32_byte_oracle_commitment() { + let creator = Address::parse("9WzDXwBbmkg8ZTbNMqUxvQRAyrZzDsGYdLVL9zYtAWWM").unwrap(); + for random_hash in [vec![], vec![7; 31], vec![7; 33]] { + let input = CreateGameInput { + creator, + token_mint: NATIVE_MINT, + game_type: GameType::Coinflip, + amount: 1, + min_players: 2, + max_players: 2, + timeout_seconds: 60, + random_hash, + oracle_operator: creator, + }; + assert_eq!( + build_create_game_plan(&input, ContractVersion::V0_3_0, &PROGRAM_ID).unwrap_err(), + PlanError::Invalid("Oracle commitment must be 32 bytes".into()) + ); + } + } } diff --git a/mise.toml b/mise.toml index 54350c8..f916149 100644 --- a/mise.toml +++ b/mise.toml @@ -1,4 +1,4 @@ # Tools CI installs. Renovate updates these versions by itself. [tools] "cargo:cargo-llvm-cov" = "0.9.1" -"cargo:cargo-audit" = "0.22.2" +"cargo:cargo-audit" = "0.23.0" diff --git a/package.json b/package.json index 3447630..34979ab 100644 --- a/package.json +++ b/package.json @@ -147,14 +147,14 @@ }, "dependencies": { "@solana/kit": "8.6.0", - "viem": "2.57.16", + "viem": "2.58.1", "zod": "4.6.7", "@solana-program/token": "0.18.0", "@solana-program/system": "0.16.0" }, "devDependencies": { "@codama/nodes-from-anchor": "1.5.6", - "@codama/renderers-js": "2.8.0", + "@codama/renderers-js": "2.9.0", "@hughescr/stryker-bun-runner": "1.6.0", "@stryker-mutator/core": "10.1.1", "@types/bun": "^1.4.4", @@ -179,5 +179,5 @@ "registry": "https://npm.pkg.github.com", "access": "public" }, - "packageManager": "bun@1.4.4" + "packageManager": "bun@1.4.5" } diff --git a/rust-toolchain.toml b/rust-toolchain.toml index 7755d76..4879316 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,4 +1,4 @@ [toolchain] -channel = "1.99.1" +channel = "1.100.0" components = ["rustfmt", "clippy", "llvm-tools-preview"] profile = "minimal"