Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ on:
- main

env:
SOLANA_ZIG_VERSION: v1.43.0
SOLANA_ZIG_VERSION: v1.47.0
SOLANA_ZIG_DIR: solana-zig
SOLANA_C_DIR: solana-c-sdk
SOLANA_LLVM_DIR: solana-llvm
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | 2825 | 325 |
| Zig | 2809 | 309 |
| C | 3122 | 622 |
| Rust (pinocchio) | 2816 | 316 |

Expand Down Expand Up @@ -215,39 +215,39 @@ program.
| Language | CU Usage |
| --- | --- |
| Rust | 1115 |
| Zig | 158 |
| Zig | 152 |

* Initialize Account

| Language | CU Usage |
| --- | --- |
| Rust | 2071 |
| Zig | 176 |
| Zig | 175 |

* Mint To

| Language | CU Usage |
| --- | --- |
| Rust | 2189 |
| Zig | 179 |
| Zig | 154 |

* Transfer

| Language | CU Usage |
| --- | --- |
| Rust | 2208 |
| Zig | 148 |
| Zig | 145 |

* Burn

| Language | CU Usage |
| --- | --- |
| Rust | 2045 |
| Zig | 145 |
| Zig | 141 |

* Close Account

| Language | CU Usage |
| --- | --- |
| Rust | 1483 |
| Zig | 130 |
| Zig | 122 |
8 changes: 4 additions & 4 deletions cpi/zig/build.zig
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
const std = @import("std");
const solana = @import("solana-program-sdk");
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 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(.{
.name = "solana_program_rosetta_cpi",
Expand All @@ -17,7 +17,7 @@ pub fn build(b: *std.Build) !void {
.optimize = optimize,
});

program.root_module.addImport("solana-program-library", solana_lib_mod);
program.root_module.addImport("solana_program_library", solana_lib_mod);

_ = solana.buildProgram(b, program, target, optimize);

Expand Down
35 changes: 9 additions & 26 deletions cpi/zig/build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,38 +1,21 @@
.{
.name = "solana-program-rosetta-cpi-zig",
// This is a [Semantic Version](https://semver.org/).
// In a future version of Zig it will be used for package deduplication.
.fingerprint = 0x32a89e177ff27d07,
.name = .solana_program_rosetta_cpi,
.version = "0.13.0",
.minimum_zig_version = "0.14.0",

// This field is optional.
// This is currently advisory only; Zig does not yet do anything
// with this value.
.minimum_zig_version = "0.13.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.
.dependencies = .{
.@"solana-program-sdk" = .{
.url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.14.0.tar.gz",
.hash = "1220bdfa4ea1ab6330959ce4bc40feb5b39a7f98923a266a94b69e27fd20c3526786",
.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",
},
.@"solana-program-library" = .{
.url = "https://github.com/joncinque/solana-program-library-zig/archive/refs/tags/v0.14.0.tar.gz",
.hash = "1220b5f9dbfa8e36b67c4bcbddb44d1e74a1c8eda0f10f485c553f4a316994e1a3d5",
.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",
},
},

// 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",
Expand Down
4 changes: 2 additions & 2 deletions cpi/zig/main.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const sol = @import("solana-program-sdk");
const sol_lib = @import("solana-program-library");
const sol = @import("solana_program_sdk");
const sol_lib = @import("solana_program_library");

const system_ix = sol_lib.system;
const SIZE = 42;
Expand Down
2 changes: 1 addition & 1 deletion helloworld/zig/build.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const std = @import("std");
const solana = @import("solana-program-sdk");
const solana = @import("solana_program_sdk");

pub fn build(b: *std.Build) !void {
const target = b.resolveTargetQuery(solana.sbf_target);
Expand Down
15 changes: 8 additions & 7 deletions helloworld/zig/build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
.{
.name = "solana-program-rosetta-helloworld-zig",
.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.13.0",
.minimum_zig_version = "0.14.0",

// This field is optional.
// Each dependency must either provide a `url` and `hash`, or a `path`.
Expand All @@ -16,12 +17,12 @@
// internet connectivity.
.dependencies = .{
.base58 = .{
.url = "https://github.com/joncinque/base58-zig/archive/refs/tags/v0.13.3.tar.gz",
.hash = "1220fd067bf167b9062cc29ccf715ff97643c2d3f8958beea863b6036876bb71bcb8",
.url = "https://github.com/joncinque/base58-zig/archive/refs/tags/v0.14.0.tar.gz",
.hash = "base58-0.14.0-6-CZm81qAAD4JCRHgewcNh8FS0pmnk7-OmwUkosaFKvg",
},
.@"solana-program-sdk" = .{
.url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.13.1.tar.gz",
.hash = "122030336f1257e3c0aa64243f5243f554b903c6b9ef3a91d48bfbe896c0c7d9b13b",
.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",
},
},

Expand Down
2 changes: 1 addition & 1 deletion helloworld/zig/main.zig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const sol = @import("solana-program-sdk");
const sol = @import("solana_program_sdk");

export fn entrypoint(_: [*]u8) u64 {
sol.log("Hello world!");
Expand Down
2 changes: 1 addition & 1 deletion install-solana-zig.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
if [[ -n $SOLANA_ZIG_VERSION ]]; then
solana_zig_version="$SOLANA_ZIG_VERSION"
else
solana_zig_version="v1.43.0"
solana_zig_version="v1.47.0"
fi
solana_zig_release_url="https://github.com/joncinque/solana-zig-bootstrap/releases/download/solana-$solana_zig_version"

Expand Down
2 changes: 1 addition & 1 deletion pubkey/zig/build.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const std = @import("std");
const solana = @import("solana-program-sdk");
const solana = @import("solana_program_sdk");

pub fn build(b: *std.Build) !void {
const target = b.resolveTargetQuery(solana.sbf_target);
Expand Down
11 changes: 6 additions & 5 deletions pubkey/zig/build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
.{
.name = "solana-program-rosetta-pubkey-zig",
.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.13.0",
.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.
.dependencies = .{
.@"solana-program-sdk" = .{
.url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.14.0.tar.gz",
.hash = "1220bdfa4ea1ab6330959ce4bc40feb5b39a7f98923a266a94b69e27fd20c3526786",
.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",
},
},
.paths = .{
Expand Down
2 changes: 1 addition & 1 deletion pubkey/zig/main.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const std = @import("std");
const PublicKey = @import("solana-program-sdk").PublicKey;
const PublicKey = @import("solana_program_sdk").PublicKey;

export fn entrypoint(input: [*]u8) u64 {
const id: *align(1) PublicKey = @ptrCast(input + 16);
Expand Down
2 changes: 1 addition & 1 deletion token/zig/build.zig
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const std = @import("std");
const solana = @import("solana-program-sdk");
const solana = @import("solana_program_sdk");

pub fn build(b: *std.Build) !void {
const target = b.resolveTargetQuery(solana.sbf_target);
Expand Down
11 changes: 6 additions & 5 deletions token/zig/build.zig.zon
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
.{
.name = "solana-program-rosetta-token-zig",
.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.13.0",
.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.
.dependencies = .{
.@"solana-program-sdk" = .{
.url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.15.1.tar.gz",
.hash = "12203631b9eba91c479991ec8f0525f181addb5879bbb96e256427f802c2ca67e108",
.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",
},
},

Expand Down
2 changes: 1 addition & 1 deletion token/zig/src/error.zig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const sol = @import("solana-program-sdk");
const sol = @import("solana_program_sdk");

pub const TokenError = error{
NotRentExempt,
Expand Down
2 changes: 1 addition & 1 deletion token/zig/src/id.zig
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const PublicKey = @import("solana-program-sdk").PublicKey;
const PublicKey = @import("solana_program_sdk").PublicKey;
pub const id = PublicKey.comptimeFromBase58("TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA");
pub const native_mint_id = PublicKey.comptimeFromBase58("So11111111111111111111111111111111111111112");
pub const system_program_id = PublicKey.comptimeFromBase58("11111111111111111111111111111111");
Loading