From c4730ef120ac9adf8e7561f0722af935d1163bf7 Mon Sep 17 00:00:00 2001 From: Jon C Date: Sat, 1 Nov 2025 16:19:25 +0100 Subject: [PATCH 1/2] zig: Bump all programs to Zig 0.15 #### Problem The solana zig compiler is out for Zig 0.15, but all the examples in the repo are still on 0.14. #### Summary of changes Bump all dependencies and versions, along with any fixes required. --- README.md | 16 +++++------ cpi/zig/build.zig | 12 +++++---- cpi/zig/build.zig.zon | 8 +++--- cpi/zig/main.zig | 4 +-- helloworld/zig/build.zig | 11 +++++--- helloworld/zig/build.zig.zon | 32 +++++----------------- helloworld/zig/main.zig | 2 +- install-solana-zig.sh | 2 +- pubkey/zig/build.zig | 11 +++++--- pubkey/zig/build.zig.zon | 20 +++----------- pubkey/zig/main.zig | 2 +- token/zig/build.zig | 11 +++++--- token/zig/build.zig.zon | 28 +++---------------- token/zig/src/error.zig | 42 ++++++++++++++--------------- token/zig/src/id.zig | 2 +- token/zig/src/instruction.zig | 2 +- token/zig/src/main.zig | 25 ++++++++--------- token/zig/src/state.zig | 2 +- transfer-lamports/zig/build.zig | 11 +++++--- transfer-lamports/zig/build.zig.zon | 20 +++----------- transfer-lamports/zig/main.zig | 2 +- 21 files changed, 108 insertions(+), 157 deletions(-) diff --git a/README.md b/README.md index 2ef8048..d4fb377 100644 --- a/README.md +++ b/README.md @@ -167,7 +167,7 @@ a little-endian u64 in instruction data. | Language | CU Usage | | --- | --- | | Rust | 459 | -| Zig | 38 | +| Zig | 37 | | C | 104 | | Assembly | 30 | | Rust (pinocchio) | 28 | @@ -186,7 +186,7 @@ address and `invoke_signed` to CPI to the system program. | Language | CU Usage | CU Usage (minus syscalls) | | --- | --- | --- | | Rust | 3698 | 1198 | -| Zig | 2809 | 309 | +| Zig | 2967 | 309 | | C | 3122 | 622 | | Rust (pinocchio) | 2802 | 302 | @@ -215,39 +215,39 @@ program. | Language | CU Usage | | --- | --- | | Rust | 1115 | -| Zig | 152 | +| Zig | 142 | * Initialize Account | Language | CU Usage | | --- | --- | | Rust | 2071 | -| Zig | 175 | +| Zig | 158 | * Mint To | Language | CU Usage | | --- | --- | | Rust | 2189 | -| Zig | 154 | +| Zig | 133 | * Transfer | Language | CU Usage | | --- | --- | | Rust | 2208 | -| Zig | 145 | +| Zig | 124 | * Burn | Language | CU Usage | | --- | --- | | Rust | 2045 | -| Zig | 141 | +| Zig | 123 | * Close Account | Language | CU Usage | | --- | --- | | Rust | 1483 | -| Zig | 122 | +| Zig | 114 | diff --git a/cpi/zig/build.zig b/cpi/zig/build.zig index 6134c75..457736a 100644 --- a/cpi/zig/build.zig +++ b/cpi/zig/build.zig @@ -4,17 +4,19 @@ const solana = @import("solana_program_sdk"); pub fn build(b: *std.Build) !void { const target = b.resolveTargetQuery(solana.sbf_target); const optimize = .ReleaseFast; - const dep_opts = .{ .target = target, .optimize = optimize }; const solana_lib_dep = b.dependency("solana_program_library", dep_opts); const solana_lib_mod = solana_lib_dep.module("solana_program_library"); - const program = b.addSharedLibrary(.{ + const program = b.addLibrary(.{ .name = "solana_program_rosetta_cpi", - .root_source_file = b.path("main.zig"), - .target = target, - .optimize = optimize, + .linkage = .dynamic, + .root_module = b.createModule(.{ + .root_source_file = b.path("main.zig"), + .optimize = optimize, + .target = target, + }) }); program.root_module.addImport("solana_program_library", solana_lib_mod); diff --git a/cpi/zig/build.zig.zon b/cpi/zig/build.zig.zon index c63afe7..1fa0708 100644 --- a/cpi/zig/build.zig.zon +++ b/cpi/zig/build.zig.zon @@ -6,12 +6,12 @@ .dependencies = .{ .solana_program_sdk = .{ - .url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.16.2.tar.gz", - .hash = "solana_program_sdk-0.16.2-wGj9UHXjAAAK5z6ZdLUJ5uu2SxgE8o7ZJ9Il4EG22IJP", + .url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.17.1.tar.gz", + .hash = "solana_program_sdk-0.17.1-wGj9UBrlAADAagTi3MSX1vSpGg-DePWB_5znbUgMlH1U", }, .solana_program_library = .{ - .url = "https://github.com/joncinque/solana-program-library-zig/archive/refs/tags/v0.15.1.tar.gz", - .hash = "solana_program_library-0.15.1-10r-le4EAQBXCYrq-CeWEKfTnJEh29ErMm8tA46Mi2Dd", + .url = "https://github.com/joncinque/solana-program-library-zig/archive/refs/tags/v0.16.1.tar.gz", + .hash = "solana_program_library-0.16.1-10r-lcr-AACkeemV1ql6olBAHLdID3JPJmGcNsx1gayC", }, }, diff --git a/cpi/zig/main.zig b/cpi/zig/main.zig index ed967bf..35b00fb 100644 --- a/cpi/zig/main.zig +++ b/cpi/zig/main.zig @@ -5,10 +5,10 @@ const system_ix = sol_lib.system; const SIZE = 42; export fn entrypoint(input: [*]u8) u64 { - const context = sol.Context.load(input) catch return 1; + const context = sol.context.Context.load(input) catch return 1; const allocated = context.accounts[0]; - const expected_allocated_key = sol.PublicKey.createProgramAddress( + const expected_allocated_key = sol.public_key.PublicKey.createProgramAddress( &.{ "You pass butter", &.{context.data[0]} }, context.program_id.*, ) catch return 1; diff --git a/helloworld/zig/build.zig b/helloworld/zig/build.zig index 7097e73..a96a8a7 100644 --- a/helloworld/zig/build.zig +++ b/helloworld/zig/build.zig @@ -4,11 +4,14 @@ const solana = @import("solana_program_sdk"); pub fn build(b: *std.Build) !void { const target = b.resolveTargetQuery(solana.sbf_target); const optimize = .ReleaseFast; - const program = b.addSharedLibrary(.{ + const program = b.addLibrary(.{ .name = "solana_program_rosetta_helloworld", - .root_source_file = b.path("main.zig"), - .target = target, - .optimize = optimize, + .linkage = .dynamic, + .root_module = b.createModule(.{ + .root_source_file = b.path("main.zig"), + .optimize = optimize, + .target = target, + }) }); _ = solana.buildProgram(b, program, target, optimize); b.installArtifact(program); diff --git a/helloworld/zig/build.zig.zon b/helloworld/zig/build.zig.zon index c664706..5d5ca42 100644 --- a/helloworld/zig/build.zig.zon +++ b/helloworld/zig/build.zig.zon @@ -1,39 +1,19 @@ .{ .name = .solana_rosetta_helloworld, .fingerprint = 0x34d885e7d0be5910, - // This is a [Semantic Version](https://semver.org/). - // In a future version of Zig it will be used for package deduplication. - .version = "0.13.0", - - // This field is optional. - // This is currently advisory only; Zig does not yet do anything - // with this value. - .minimum_zig_version = "0.14.0", - - // This field is optional. - // Each dependency must either provide a `url` and `hash`, or a `path`. - // `zig build --fetch` can be used to fetch all dependencies of a package, recursively. - // Once all dependencies are fetched, `zig build` no longer requires - // internet connectivity. + .version = "0.15.0", + .minimum_zig_version = "0.15.0", .dependencies = .{ .base58 = .{ - .url = "https://github.com/joncinque/base58-zig/archive/refs/tags/v0.14.0.tar.gz", - .hash = "base58-0.14.0-6-CZm81qAAD4JCRHgewcNh8FS0pmnk7-OmwUkosaFKvg", + .url = "https://github.com/joncinque/base58-zig/archive/refs/tags/v0.15.0.tar.gz", + .hash = "base58-0.15.0-6-CZmwVpAAAxqof6REya9G_XyHL1fTqUsAcsZ-J1IHMF", }, .solana_program_sdk = .{ - .url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.16.2.tar.gz", - .hash = "solana_program_sdk-0.16.2-wGj9UHXjAAAK5z6ZdLUJ5uu2SxgE8o7ZJ9Il4EG22IJP", + .url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.17.0.tar.gz", + .hash = "solana_program_sdk-0.17.0-wGj9UHjiAAC5lyL1BQ4MI7wcQYrqSjHrxdvZXDaA8Glb", }, }, - - // Specifies the set of files and directories that are included in this package. - // Only files and directories listed here are included in the `hash` that - // is computed for this package. - // Paths are relative to the build root. Use the empty string (`""`) to refer to - // the build root itself. - // A directory listed here means that all files within, recursively, are included. .paths = .{ - // For example... "build.zig", "build.zig.zon", "src", diff --git a/helloworld/zig/main.zig b/helloworld/zig/main.zig index 7f95503..ea9d694 100644 --- a/helloworld/zig/main.zig +++ b/helloworld/zig/main.zig @@ -1,6 +1,6 @@ const sol = @import("solana_program_sdk"); export fn entrypoint(_: [*]u8) u64 { - sol.log("Hello world!"); + sol.log.log("Hello world!"); return 0; } diff --git a/install-solana-zig.sh b/install-solana-zig.sh index d5886d3..f519c98 100755 --- a/install-solana-zig.sh +++ b/install-solana-zig.sh @@ -3,7 +3,7 @@ if [[ -n $SOLANA_ZIG_VERSION ]]; then solana_zig_version="$SOLANA_ZIG_VERSION" else - solana_zig_version="v1.47.0" + solana_zig_version="v1.52.0" fi solana_zig_release_url="https://github.com/joncinque/solana-zig-bootstrap/releases/download/solana-$solana_zig_version" diff --git a/pubkey/zig/build.zig b/pubkey/zig/build.zig index 49118f3..17e2c9a 100644 --- a/pubkey/zig/build.zig +++ b/pubkey/zig/build.zig @@ -4,11 +4,14 @@ const solana = @import("solana_program_sdk"); pub fn build(b: *std.Build) !void { const target = b.resolveTargetQuery(solana.sbf_target); const optimize = .ReleaseFast; - const program = b.addSharedLibrary(.{ + const program = b.addLibrary(.{ .name = "solana_program_rosetta_pubkey", - .root_source_file = b.path("main.zig"), - .target = target, - .optimize = optimize, + .linkage = .dynamic, + .root_module = b.createModule(.{ + .root_source_file = b.path("main.zig"), + .optimize = optimize, + .target = target, + }) }); _ = solana.buildProgram(b, program, target, optimize); b.installArtifact(program); diff --git a/pubkey/zig/build.zig.zon b/pubkey/zig/build.zig.zon index 7d4e546..c1ef256 100644 --- a/pubkey/zig/build.zig.zon +++ b/pubkey/zig/build.zig.zon @@ -1,24 +1,12 @@ .{ .name = .solana_rosetta_pubkey, .fingerprint = 0xa8636daaef29becd, - // This is a [Semantic Version](https://semver.org/). - // In a future version of Zig it will be used for package deduplication. - .version = "0.13.0", - - // This field is optional. - // This is currently advisory only; Zig does not yet do anything - // with this value. - .minimum_zig_version = "0.14.0", - - // This field is optional. - // Each dependency must either provide a `url` and `hash`, or a `path`. - // `zig build --fetch` can be used to fetch all dependencies of a package, recursively. - // Once all dependencies are fetched, `zig build` no longer requires - // internet connectivity. + .version = "0.15.0", + .minimum_zig_version = "0.15.0", .dependencies = .{ .solana_program_sdk = .{ - .url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.16.2.tar.gz", - .hash = "solana_program_sdk-0.16.2-wGj9UHXjAAAK5z6ZdLUJ5uu2SxgE8o7ZJ9Il4EG22IJP", + .url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.17.0.tar.gz", + .hash = "solana_program_sdk-0.17.0-wGj9UHjiAAC5lyL1BQ4MI7wcQYrqSjHrxdvZXDaA8Glb", }, }, .paths = .{ diff --git a/pubkey/zig/main.zig b/pubkey/zig/main.zig index 09ae1b2..69c8f22 100644 --- a/pubkey/zig/main.zig +++ b/pubkey/zig/main.zig @@ -1,5 +1,5 @@ const std = @import("std"); -const PublicKey = @import("solana_program_sdk").PublicKey; +const PublicKey = @import("solana_program_sdk").public_key.PublicKey; export fn entrypoint(input: [*]u8) u64 { const id: *align(1) PublicKey = @ptrCast(input + 16); diff --git a/token/zig/build.zig b/token/zig/build.zig index 5e81fe9..d3df104 100644 --- a/token/zig/build.zig +++ b/token/zig/build.zig @@ -9,11 +9,14 @@ pub fn build(b: *std.Build) !void { //const solana_lib_dep = b.dependency("solana-program-library", dep_opts); //const solana_lib_mod = solana_lib_dep.module("solana-program-library"); - const program = b.addSharedLibrary(.{ + const program = b.addLibrary(.{ .name = "spl_token", - .root_source_file = b.path("src/main.zig"), - .target = target, - .optimize = optimize, + .linkage = .dynamic, + .root_module = b.createModule(.{ + .root_source_file = b.path("src/main.zig"), + .optimize = optimize, + .target = target, + }) }); //program.root_module.addImport("solana-program-library", solana_lib_mod); diff --git a/token/zig/build.zig.zon b/token/zig/build.zig.zon index 27d4763..eede475 100644 --- a/token/zig/build.zig.zon +++ b/token/zig/build.zig.zon @@ -1,35 +1,15 @@ .{ .name = .solana_rosetta_token, .fingerprint = 0xc77c51400e78e0da, - // This is a [Semantic Version](https://semver.org/). - // In a future version of Zig it will be used for package deduplication. - .version = "0.13.0", - - // This field is optional. - // This is currently advisory only; Zig does not yet do anything - // with this value. - .minimum_zig_version = "0.14.0", - - // This field is optional. - // Each dependency must either provide a `url` and `hash`, or a `path`. - // `zig build --fetch` can be used to fetch all dependencies of a package, recursively. - // Once all dependencies are fetched, `zig build` no longer requires - // internet connectivity. + .version = "0.15.0", + .minimum_zig_version = "0.15.0", .dependencies = .{ .solana_program_sdk = .{ - .url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.16.2.tar.gz", - .hash = "solana_program_sdk-0.16.2-wGj9UHXjAAAK5z6ZdLUJ5uu2SxgE8o7ZJ9Il4EG22IJP", + .url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.17.1.tar.gz", + .hash = "solana_program_sdk-0.17.1-wGj9UBrlAADAagTi3MSX1vSpGg-DePWB_5znbUgMlH1U", }, }, - - // Specifies the set of files and directories that are included in this package. - // Only files and directories listed here are included in the `hash` that - // is computed for this package. - // Paths are relative to the build root. Use the empty string (`""`) to refer to - // the build root itself. - // A directory listed here means that all files within, recursively, are included. .paths = .{ - // For example... "build.zig", "build.zig.zon", "src", diff --git a/token/zig/src/error.zig b/token/zig/src/error.zig index a254198..07e317a 100644 --- a/token/zig/src/error.zig +++ b/token/zig/src/error.zig @@ -1,4 +1,4 @@ -const sol = @import("solana_program_sdk"); +const log = @import("solana_program_sdk").log.log; pub const TokenError = error{ NotRentExempt, @@ -52,64 +52,64 @@ pub const TokenError = error{ pub fn logError(e: TokenError) void { switch (e) { TokenError.NotRentExempt => { - sol.log("Error: Lamport balance below rent-exempt threshold"); + log("Error: Lamport balance below rent-exempt threshold"); }, TokenError.InsufficientFunds => { - sol.log("Error: insufficient funds"); + log("Error: insufficient funds"); }, TokenError.InvalidMint => { - sol.log("Error: Invalid Mint"); + log("Error: Invalid Mint"); }, TokenError.MintMismatch => { - sol.log("Error: Account not associated with this Mint"); + log("Error: Account not associated with this Mint"); }, TokenError.OwnerMismatch => { - sol.log("Error: owner does not match"); + log("Error: owner does not match"); }, TokenError.FixedSupply => { - sol.log("Error: the total supply of this token is fixed"); + log("Error: the total supply of this token is fixed"); }, TokenError.AlreadyInUse => { - sol.log("Error: account or token already in use"); + log("Error: account or token already in use"); }, TokenError.InvalidNumberOfProvidedSigners => { - sol.log("Error: Invalid number of provided signers"); + log("Error: Invalid number of provided signers"); }, TokenError.InvalidNumberOfRequiredSigners => { - sol.log("Error: Invalid number of required signers"); + log("Error: Invalid number of required signers"); }, TokenError.UninitializedState => { - sol.log("Error: State is uninitialized"); + log("Error: State is uninitialized"); }, TokenError.NativeNotSupported => { - sol.log("Error: Instruction does not support native tokens"); + log("Error: Instruction does not support native tokens"); }, TokenError.NonNativeHasBalance => { - sol.log("Error: Non-native account can only be closed if its balance is zero"); + log("Error: Non-native account can only be closed if its balance is zero"); }, TokenError.InvalidInstruction => { - sol.log("Error: Invalid instruction"); + log("Error: Invalid instruction"); }, TokenError.InvalidState => { - sol.log("Error: Invalid account state for operation"); + log("Error: Invalid account state for operation"); }, TokenError.Overflow => { - sol.log("Error: Operation overflowed"); + log("Error: Operation overflowed"); }, TokenError.AuthorityTypeNotSupported => { - sol.log("Error: Account does not support specified authority type"); + log("Error: Account does not support specified authority type"); }, TokenError.MintCannotFreeze => { - sol.log("Error: This token mint cannot freeze accounts"); + log("Error: This token mint cannot freeze accounts"); }, TokenError.AccountFrozen => { - sol.log("Error: Account is frozen"); + log("Error: Account is frozen"); }, TokenError.MintDecimalsMismatch => { - sol.log("Error: decimals different from the Mint decimals"); + log("Error: decimals different from the Mint decimals"); }, TokenError.NonNativeNotSupported => { - sol.log("Error: Instruction does not support non-native tokens"); + log("Error: Instruction does not support non-native tokens"); }, TokenError.InvalidArgument => {}, TokenError.InvalidInstructionData => {}, diff --git a/token/zig/src/id.zig b/token/zig/src/id.zig index 20a58d1..099f342 100644 --- a/token/zig/src/id.zig +++ b/token/zig/src/id.zig @@ -1,4 +1,4 @@ -const PublicKey = @import("solana_program_sdk").PublicKey; +const PublicKey = @import("solana_program_sdk").public_key.PublicKey; pub const id = PublicKey.comptimeFromBase58("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"); pub const native_mint_id = PublicKey.comptimeFromBase58("So11111111111111111111111111111111111111112"); pub const system_program_id = PublicKey.comptimeFromBase58("11111111111111111111111111111111"); diff --git a/token/zig/src/instruction.zig b/token/zig/src/instruction.zig index 6b7d4ad..e6dbc1c 100644 --- a/token/zig/src/instruction.zig +++ b/token/zig/src/instruction.zig @@ -1,6 +1,6 @@ const std = @import("std"); const COption = @import("state.zig").COption; -const PublicKey = @import("solana_program_sdk").PublicKey; +const PublicKey = @import("solana_program_sdk").public_key.PublicKey; pub const AuthorityType = enum(u8) { /// Authority to mint new tokens diff --git a/token/zig/src/main.zig b/token/zig/src/main.zig index 7991664..a682ca8 100644 --- a/token/zig/src/main.zig +++ b/token/zig/src/main.zig @@ -1,6 +1,7 @@ const sol = @import("solana_program_sdk"); -const PublicKey = sol.PublicKey; -const Rent = sol.Rent; +const Account = sol.account.Account; +const PublicKey = sol.public_key.PublicKey; +const Rent = sol.rent.Rent; const ix = @import("instruction.zig"); const state = @import("state.zig"); @@ -9,12 +10,12 @@ const native_mint_id = @import("id.zig").native_mint_id; const system_program_id = @import("id.zig").system_program_id; export fn entrypoint(input: [*]u8) u64 { - var context = sol.Context.load(input) catch return 1; + var context = sol.context.Context.load(input) catch return 1; processInstruction(context.program_id, context.accounts[0..context.num_accounts], context.data) catch |err| return @intFromError(err); return 0; } -fn initializeMint(accounts: []sol.Account, data: []const u8) TokenError!void { +fn initializeMint(accounts: []Account, data: []const u8) TokenError!void { if (accounts.len < 2) { return TokenError.NotEnoughAccountKeys; } @@ -44,7 +45,7 @@ fn initializeMint(accounts: []sol.Account, data: []const u8) TokenError!void { mint.freeze_authority = ix_data.freeze_authority.toCOption(); } -fn initializeAccount(program_id: *align(1) PublicKey, accounts: []sol.Account) TokenError!void { +fn initializeAccount(program_id: *align(1) PublicKey, accounts: []Account) TokenError!void { if (accounts.len < 4) { return TokenError.NotEnoughAccountKeys; } @@ -95,7 +96,7 @@ fn initializeAccount(program_id: *align(1) PublicKey, accounts: []sol.Account) T } } -fn transfer(program_id: *align(1) PublicKey, accounts: []sol.Account, data: []const u8) TokenError!void { +fn transfer(program_id: *align(1) PublicKey, accounts: []Account, data: []const u8) TokenError!void { if (accounts.len < 3) { return TokenError.NotEnoughAccountKeys; } @@ -162,7 +163,7 @@ fn transfer(program_id: *align(1) PublicKey, accounts: []sol.Account, data: []co } } -fn mintTo(program_id: *align(1) PublicKey, accounts: []sol.Account, data: []const u8) TokenError!void { +fn mintTo(program_id: *align(1) PublicKey, accounts: []Account, data: []const u8) TokenError!void { if (accounts.len < 3) { return TokenError.NotEnoughAccountKeys; } @@ -214,7 +215,7 @@ fn mintTo(program_id: *align(1) PublicKey, accounts: []sol.Account, data: []cons destination.amount += ix_data.amount; } -fn burn(program_id: *align(1) PublicKey, accounts: []sol.Account, data: []const u8) TokenError!void { +fn burn(program_id: *align(1) PublicKey, accounts: []Account, data: []const u8) TokenError!void { if (accounts.len < 3) { return TokenError.NotEnoughAccountKeys; } @@ -285,7 +286,7 @@ fn burn(program_id: *align(1) PublicKey, accounts: []sol.Account, data: []const } } -fn closeAccount(program_id: *align(1) PublicKey, accounts: []sol.Account) TokenError!void { +fn closeAccount(program_id: *align(1) PublicKey, accounts: []Account) TokenError!void { if (accounts.len < 3) { return TokenError.NotEnoughAccountKeys; } @@ -333,7 +334,7 @@ fn closeAccount(program_id: *align(1) PublicKey, accounts: []sol.Account) TokenE } } -fn processInstruction(program_id: *align(1) PublicKey, accounts: []sol.Account, data: []const u8) TokenError!void { +fn processInstruction(program_id: *align(1) PublicKey, accounts: []Account, data: []const u8) TokenError!void { const instruction_type: *const ix.InstructionDiscriminant = @ptrCast(data); switch (instruction_type.*) { ix.InstructionDiscriminant.initialize_mint => { @@ -423,8 +424,8 @@ fn processInstruction(program_id: *align(1) PublicKey, accounts: []sol.Account, fn validateOwner( program_id: *align(1) const PublicKey, expected_owner: *align(1) const PublicKey, - owner_account: sol.Account, - _: []sol.Account, + owner_account: Account, + _: []Account, ) TokenError!void { if (!expected_owner.equals(owner_account.id())) { return TokenError.OwnerMismatch; diff --git a/token/zig/src/state.zig b/token/zig/src/state.zig index feacf0b..a65c2f2 100644 --- a/token/zig/src/state.zig +++ b/token/zig/src/state.zig @@ -1,5 +1,5 @@ const std = @import("std"); -const PublicKey = @import("solana_program_sdk").PublicKey; +const PublicKey = @import("solana_program_sdk").public_key.PublicKey; const TokenError = @import("error.zig").TokenError; pub const Mint = extern struct { diff --git a/transfer-lamports/zig/build.zig b/transfer-lamports/zig/build.zig index e99fa26..6aaac73 100644 --- a/transfer-lamports/zig/build.zig +++ b/transfer-lamports/zig/build.zig @@ -4,11 +4,14 @@ const solana = @import("solana_program_sdk"); pub fn build(b: *std.Build) !void { const target = b.resolveTargetQuery(solana.sbf_target); const optimize = .ReleaseFast; - const program = b.addSharedLibrary(.{ + const program = b.addLibrary(.{ .name = "solana_program_rosetta_transfer_lamports", - .root_source_file = b.path("main.zig"), - .target = target, - .optimize = optimize, + .linkage = .dynamic, + .root_module = b.createModule(.{ + .root_source_file = b.path("main.zig"), + .optimize = optimize, + .target = target, + }) }); _ = solana.buildProgram(b, program, target, optimize); b.installArtifact(program); diff --git a/transfer-lamports/zig/build.zig.zon b/transfer-lamports/zig/build.zig.zon index ba29a2b..6b0f31e 100644 --- a/transfer-lamports/zig/build.zig.zon +++ b/transfer-lamports/zig/build.zig.zon @@ -1,24 +1,12 @@ .{ .name = .solana_rosetta_transfer_lamports, .fingerprint = 0x1ecd6515ce9d93ec, - // This is a [Semantic Version](https://semver.org/). - // In a future version of Zig it will be used for package deduplication. - .version = "0.13.0", - - // This field is optional. - // This is currently advisory only; Zig does not yet do anything - // with this value. - .minimum_zig_version = "0.14.0", - - // This field is optional. - // Each dependency must either provide a `url` and `hash`, or a `path`. - // `zig build --fetch` can be used to fetch all dependencies of a package, recursively. - // Once all dependencies are fetched, `zig build` no longer requires - // internet connectivity. + .version = "0.15.0", + .minimum_zig_version = "0.15.0", .dependencies = .{ .solana_program_sdk = .{ - .url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.16.0.tar.gz", - .hash = "solana_program_sdk-0.16.0-wGj9UFDgAAA31EfM9LV-cmDP5BctyNwEVvyEWtZ1QPkj", + .url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.17.0.tar.gz", + .hash = "solana_program_sdk-0.17.0-wGj9UHjiAAC5lyL1BQ4MI7wcQYrqSjHrxdvZXDaA8Glb", }, }, .paths = .{ diff --git a/transfer-lamports/zig/main.zig b/transfer-lamports/zig/main.zig index 0914d90..ebfdbfa 100644 --- a/transfer-lamports/zig/main.zig +++ b/transfer-lamports/zig/main.zig @@ -2,7 +2,7 @@ const std = @import("std"); const sol = @import("solana_program_sdk"); export fn entrypoint(input: [*]u8) u64 { - const context = sol.Context.load(input) catch return 1; + const context = sol.context.Context.load(input) catch return 1; const source = context.accounts[0]; const destination = context.accounts[1]; const transfer_amount = std.mem.bytesToValue(u64, context.data[0..@sizeOf(u64)]); From 0a5451e43d199055c44cdab6076be58196b814cb Mon Sep 17 00:00:00 2001 From: Jon C Date: Sat, 1 Nov 2025 16:24:16 +0100 Subject: [PATCH 2/2] Bump version in CI --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 27fe5ac..23bd5ca 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -9,7 +9,7 @@ on: - main env: - SOLANA_ZIG_VERSION: v1.47.0 + SOLANA_ZIG_VERSION: v1.52.0 SOLANA_ZIG_DIR: solana-zig SOLANA_C_DIR: solana-c-sdk SOLANA_LLVM_DIR: solana-llvm