Skip to content

Commit ed96fc7

Browse files
authored
Update Zig examples to 0.14 (#21)
* Upgrade default version * Update helloworld program * Update CI version * Update token program * Update pubkey program * Update transfer-lamports * Update cpi * Update all programs to 0.16.2, update CU numbers
1 parent d73dcbb commit ed96fc7

File tree

22 files changed

+81
-94
lines changed

22 files changed

+81
-94
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- main
1010

1111
env:
12-
SOLANA_ZIG_VERSION: v1.43.0
12+
SOLANA_ZIG_VERSION: v1.47.0
1313
SOLANA_ZIG_DIR: solana-zig
1414
SOLANA_C_DIR: solana-c-sdk
1515
SOLANA_LLVM_DIR: solana-llvm

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ address and `invoke_signed` to CPI to the system program.
186186
| Language | CU Usage | CU Usage (minus syscalls) |
187187
| --- | --- | --- |
188188
| Rust | 3698 | 1198 |
189-
| Zig | 2825 | 325 |
189+
| Zig | 2809 | 309 |
190190
| C | 3122 | 622 |
191191
| Rust (pinocchio) | 2816 | 316 |
192192

@@ -215,39 +215,39 @@ program.
215215
| Language | CU Usage |
216216
| --- | --- |
217217
| Rust | 1115 |
218-
| Zig | 158 |
218+
| Zig | 152 |
219219

220220
* Initialize Account
221221

222222
| Language | CU Usage |
223223
| --- | --- |
224224
| Rust | 2071 |
225-
| Zig | 176 |
225+
| Zig | 175 |
226226

227227
* Mint To
228228

229229
| Language | CU Usage |
230230
| --- | --- |
231231
| Rust | 2189 |
232-
| Zig | 179 |
232+
| Zig | 154 |
233233

234234
* Transfer
235235

236236
| Language | CU Usage |
237237
| --- | --- |
238238
| Rust | 2208 |
239-
| Zig | 148 |
239+
| Zig | 145 |
240240

241241
* Burn
242242

243243
| Language | CU Usage |
244244
| --- | --- |
245245
| Rust | 2045 |
246-
| Zig | 145 |
246+
| Zig | 141 |
247247

248248
* Close Account
249249

250250
| Language | CU Usage |
251251
| --- | --- |
252252
| Rust | 1483 |
253-
| Zig | 130 |
253+
| Zig | 122 |

cpi/zig/build.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
const std = @import("std");
2-
const solana = @import("solana-program-sdk");
2+
const solana = @import("solana_program_sdk");
33

44
pub fn build(b: *std.Build) !void {
55
const target = b.resolveTargetQuery(solana.sbf_target);
66
const optimize = .ReleaseFast;
77

88
const dep_opts = .{ .target = target, .optimize = optimize };
99

10-
const solana_lib_dep = b.dependency("solana-program-library", dep_opts);
11-
const solana_lib_mod = solana_lib_dep.module("solana-program-library");
10+
const solana_lib_dep = b.dependency("solana_program_library", dep_opts);
11+
const solana_lib_mod = solana_lib_dep.module("solana_program_library");
1212

1313
const program = b.addSharedLibrary(.{
1414
.name = "solana_program_rosetta_cpi",
@@ -17,7 +17,7 @@ pub fn build(b: *std.Build) !void {
1717
.optimize = optimize,
1818
});
1919

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

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

cpi/zig/build.zig.zon

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,21 @@
11
.{
2-
.name = "solana-program-rosetta-cpi-zig",
3-
// This is a [Semantic Version](https://semver.org/).
4-
// In a future version of Zig it will be used for package deduplication.
2+
.fingerprint = 0x32a89e177ff27d07,
3+
.name = .solana_program_rosetta_cpi,
54
.version = "0.13.0",
5+
.minimum_zig_version = "0.14.0",
66

7-
// This field is optional.
8-
// This is currently advisory only; Zig does not yet do anything
9-
// with this value.
10-
.minimum_zig_version = "0.13.0",
11-
12-
// This field is optional.
13-
// Each dependency must either provide a `url` and `hash`, or a `path`.
14-
// `zig build --fetch` can be used to fetch all dependencies of a package, recursively.
15-
// Once all dependencies are fetched, `zig build` no longer requires
16-
// internet connectivity.
177
.dependencies = .{
18-
.@"solana-program-sdk" = .{
19-
.url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.14.0.tar.gz",
20-
.hash = "1220bdfa4ea1ab6330959ce4bc40feb5b39a7f98923a266a94b69e27fd20c3526786",
8+
.solana_program_sdk = .{
9+
.url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.16.2.tar.gz",
10+
.hash = "solana_program_sdk-0.16.2-wGj9UHXjAAAK5z6ZdLUJ5uu2SxgE8o7ZJ9Il4EG22IJP",
2111
},
22-
.@"solana-program-library" = .{
23-
.url = "https://github.com/joncinque/solana-program-library-zig/archive/refs/tags/v0.14.0.tar.gz",
24-
.hash = "1220b5f9dbfa8e36b67c4bcbddb44d1e74a1c8eda0f10f485c553f4a316994e1a3d5",
12+
.solana_program_library = .{
13+
.url = "https://github.com/joncinque/solana-program-library-zig/archive/refs/tags/v0.15.1.tar.gz",
14+
.hash = "solana_program_library-0.15.1-10r-le4EAQBXCYrq-CeWEKfTnJEh29ErMm8tA46Mi2Dd",
2515
},
2616
},
2717

28-
// Specifies the set of files and directories that are included in this package.
29-
// Only files and directories listed here are included in the `hash` that
30-
// is computed for this package.
31-
// Paths are relative to the build root. Use the empty string (`""`) to refer to
32-
// the build root itself.
33-
// A directory listed here means that all files within, recursively, are included.
3418
.paths = .{
35-
// For example...
3619
"build.zig",
3720
"build.zig.zon",
3821
"src",

cpi/zig/main.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const sol = @import("solana-program-sdk");
2-
const sol_lib = @import("solana-program-library");
1+
const sol = @import("solana_program_sdk");
2+
const sol_lib = @import("solana_program_library");
33

44
const system_ix = sol_lib.system;
55
const SIZE = 42;

helloworld/zig/build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const std = @import("std");
2-
const solana = @import("solana-program-sdk");
2+
const solana = @import("solana_program_sdk");
33

44
pub fn build(b: *std.Build) !void {
55
const target = b.resolveTargetQuery(solana.sbf_target);

helloworld/zig/build.zig.zon

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
.{
2-
.name = "solana-program-rosetta-helloworld-zig",
2+
.name = .solana_rosetta_helloworld,
3+
.fingerprint = 0x34d885e7d0be5910,
34
// This is a [Semantic Version](https://semver.org/).
45
// In a future version of Zig it will be used for package deduplication.
56
.version = "0.13.0",
67

78
// This field is optional.
89
// This is currently advisory only; Zig does not yet do anything
910
// with this value.
10-
.minimum_zig_version = "0.13.0",
11+
.minimum_zig_version = "0.14.0",
1112

1213
// This field is optional.
1314
// Each dependency must either provide a `url` and `hash`, or a `path`.
@@ -16,12 +17,12 @@
1617
// internet connectivity.
1718
.dependencies = .{
1819
.base58 = .{
19-
.url = "https://github.com/joncinque/base58-zig/archive/refs/tags/v0.13.3.tar.gz",
20-
.hash = "1220fd067bf167b9062cc29ccf715ff97643c2d3f8958beea863b6036876bb71bcb8",
20+
.url = "https://github.com/joncinque/base58-zig/archive/refs/tags/v0.14.0.tar.gz",
21+
.hash = "base58-0.14.0-6-CZm81qAAD4JCRHgewcNh8FS0pmnk7-OmwUkosaFKvg",
2122
},
22-
.@"solana-program-sdk" = .{
23-
.url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.13.1.tar.gz",
24-
.hash = "122030336f1257e3c0aa64243f5243f554b903c6b9ef3a91d48bfbe896c0c7d9b13b",
23+
.solana_program_sdk = .{
24+
.url = "https://github.com/joncinque/solana-program-sdk-zig/archive/refs/tags/v0.16.2.tar.gz",
25+
.hash = "solana_program_sdk-0.16.2-wGj9UHXjAAAK5z6ZdLUJ5uu2SxgE8o7ZJ9Il4EG22IJP",
2526
},
2627
},
2728

helloworld/zig/main.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const sol = @import("solana-program-sdk");
1+
const sol = @import("solana_program_sdk");
22

33
export fn entrypoint(_: [*]u8) u64 {
44
sol.log("Hello world!");

install-solana-zig.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
if [[ -n $SOLANA_ZIG_VERSION ]]; then
44
solana_zig_version="$SOLANA_ZIG_VERSION"
55
else
6-
solana_zig_version="v1.43.0"
6+
solana_zig_version="v1.47.0"
77
fi
88
solana_zig_release_url="https://github.com/joncinque/solana-zig-bootstrap/releases/download/solana-$solana_zig_version"
99

pubkey/zig/build.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
const std = @import("std");
2-
const solana = @import("solana-program-sdk");
2+
const solana = @import("solana_program_sdk");
33

44
pub fn build(b: *std.Build) !void {
55
const target = b.resolveTargetQuery(solana.sbf_target);

0 commit comments

Comments
 (0)