diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 33bd91d..27fe5ac 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 diff --git a/README.md b/README.md index 40fd029..d2aea7f 100644 --- a/README.md +++ b/README.md @@ -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 | @@ -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 | diff --git a/cpi/zig/build.zig b/cpi/zig/build.zig index afb481c..6134c75 100644 --- a/cpi/zig/build.zig +++ b/cpi/zig/build.zig @@ -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); @@ -7,8 +7,8 @@ pub fn build(b: *std.Build) !void { 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", @@ -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); diff --git a/cpi/zig/build.zig.zon b/cpi/zig/build.zig.zon index 3bb9ad4..c63afe7 100644 --- a/cpi/zig/build.zig.zon +++ b/cpi/zig/build.zig.zon @@ -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", diff --git a/cpi/zig/main.zig b/cpi/zig/main.zig index c83861e..ed967bf 100644 --- a/cpi/zig/main.zig +++ b/cpi/zig/main.zig @@ -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; diff --git a/helloworld/zig/build.zig b/helloworld/zig/build.zig index 8c437b7..7097e73 100644 --- a/helloworld/zig/build.zig +++ b/helloworld/zig/build.zig @@ -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); diff --git a/helloworld/zig/build.zig.zon b/helloworld/zig/build.zig.zon index 1465301..c664706 100644 --- a/helloworld/zig/build.zig.zon +++ b/helloworld/zig/build.zig.zon @@ -1,5 +1,6 @@ .{ - .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", @@ -7,7 +8,7 @@ // 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`. @@ -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", }, }, diff --git a/helloworld/zig/main.zig b/helloworld/zig/main.zig index b6edb73..7f95503 100644 --- a/helloworld/zig/main.zig +++ b/helloworld/zig/main.zig @@ -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!"); diff --git a/install-solana-zig.sh b/install-solana-zig.sh index 1974a51..d5886d3 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.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" diff --git a/pubkey/zig/build.zig b/pubkey/zig/build.zig index 050adba..49118f3 100644 --- a/pubkey/zig/build.zig +++ b/pubkey/zig/build.zig @@ -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); diff --git a/pubkey/zig/build.zig.zon b/pubkey/zig/build.zig.zon index 2410a7f..7d4e546 100644 --- a/pubkey/zig/build.zig.zon +++ b/pubkey/zig/build.zig.zon @@ -1,5 +1,6 @@ .{ - .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", @@ -7,7 +8,7 @@ // 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`. @@ -15,9 +16,9 @@ // 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 = .{ diff --git a/pubkey/zig/main.zig b/pubkey/zig/main.zig index 75cb39d..09ae1b2 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").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 7733836..5e81fe9 100644 --- a/token/zig/build.zig +++ b/token/zig/build.zig @@ -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); diff --git a/token/zig/build.zig.zon b/token/zig/build.zig.zon index 4f1fd17..27d4763 100644 --- a/token/zig/build.zig.zon +++ b/token/zig/build.zig.zon @@ -1,5 +1,6 @@ .{ - .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", @@ -7,7 +8,7 @@ // 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`. @@ -15,9 +16,9 @@ // 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", }, }, diff --git a/token/zig/src/error.zig b/token/zig/src/error.zig index 356dcc9..a254198 100644 --- a/token/zig/src/error.zig +++ b/token/zig/src/error.zig @@ -1,4 +1,4 @@ -const sol = @import("solana-program-sdk"); +const sol = @import("solana_program_sdk"); pub const TokenError = error{ NotRentExempt, diff --git a/token/zig/src/id.zig b/token/zig/src/id.zig index a43c505..20a58d1 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").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 430720d..6b7d4ad 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").PublicKey; pub const AuthorityType = enum(u8) { /// Authority to mint new tokens @@ -42,7 +42,7 @@ pub const InstructionDiscriminant = enum(u8) { }; pub fn IxOption(T: type) type { - return packed struct { + return extern struct { is_some: u8, value: T, const Self = @This(); @@ -81,7 +81,7 @@ pub fn IxOption(T: type) type { }; } -pub const InitializeMintData = packed struct { +pub const InitializeMintData = extern struct { /// Number of base 10 digits to the right of the decimal place. decimals: u8, /// The authority/multisignature to mint tokens. @@ -90,7 +90,7 @@ pub const InitializeMintData = packed struct { freeze_authority: IxOption(PublicKey), }; -pub const AmountData = packed struct { +pub const AmountData = extern struct { /// The amount of tokens to process. amount: u64, }; @@ -149,7 +149,7 @@ pub const Instruction = union(InstructionDiscriminant) { /// 1. `[]` Rent sysvar /// 2. ..2+N. `[]` The signer accounts, must equal to N where 1 <= N <= /// 11. - initialize_multisig: packed struct { + initialize_multisig: extern struct { /// The number of signers (M) required to validate this multisignature /// account. m: u8, @@ -213,7 +213,7 @@ pub const Instruction = union(InstructionDiscriminant) { /// 0. `[writable]` The mint or account to change the authority of. /// 1. `[]` The mint's or account's current multisignature authority. /// 2. ..2+M `[signer]` M signer accounts - set_authority: packed struct { + set_authority: extern struct { /// The type of authority to update. authority_type: AuthorityType, /// The new authority. @@ -321,7 +321,7 @@ pub const Instruction = union(InstructionDiscriminant) { /// 2. `[writable]` The destination account. /// 3. `[]` The source account's multisignature owner/delegate. /// 4. ..4+M `[signer]` M signer accounts. - transfer_checked: packed struct { + transfer_checked: extern struct { /// The amount of tokens to transfer. amount: u64, /// Expected number of base 10 digits to the right of the decimal place. @@ -348,7 +348,7 @@ pub const Instruction = union(InstructionDiscriminant) { /// 2. `[]` The delegate. /// 3. `[]` The source account's multisignature owner. /// 4. ..4+M `[signer]` M signer accounts - approve_checked: packed struct { + approve_checked: extern struct { /// The amount of tokens the delegate is approved for. amount: u64, /// Expected number of base 10 digits to the right of the decimal place. @@ -373,7 +373,7 @@ pub const Instruction = union(InstructionDiscriminant) { /// 1. `[writable]` The account to mint tokens to. /// 2. `[]` The mint's multisignature mint-tokens authority. /// 3. ..3+M `[signer]` M signer accounts. - mint_to_checked: packed struct { + mint_to_checked: extern struct { /// The amount of new tokens to mint. amount: u64, /// Expected number of base 10 digits to the right of the decimal place. @@ -399,7 +399,7 @@ pub const Instruction = union(InstructionDiscriminant) { /// 1. `[writable]` The token mint. /// 2. `[]` The account's multisignature owner/delegate. /// 3. ..3+M `[signer]` M signer accounts. - burn_checked: packed struct { + burn_checked: extern struct { /// The amount of tokens to burn. amount: u64, /// Expected number of base 10 digits to the right of the decimal place. @@ -415,7 +415,7 @@ pub const Instruction = union(InstructionDiscriminant) { /// 0. `[writable]` The account to initialize. /// 1. `[]` The mint this account will be associated with. /// 3. `[]` Rent sysvar - initialize_account_2: packed struct { + initialize_account_2: extern struct { /// The new account's owner/multisignature. owner_id: PublicKey, }, @@ -435,7 +435,7 @@ pub const Instruction = union(InstructionDiscriminant) { /// /// 0. `[writable]` The account to initialize. /// 1. `[]` The mint this account will be associated with. - initialize_account_3: packed struct { + initialize_account_3: extern struct { /// The new account's owner/multisignature. owner_id: PublicKey, }, @@ -446,7 +446,7 @@ pub const Instruction = union(InstructionDiscriminant) { /// 0. `[writable]` The multisignature account to initialize. /// 1. ..1+N. `[]` The signer accounts, must equal to N where 1 <= N <= /// 11. - initialize_multisig_2: packed struct { + initialize_multisig_2: extern struct { /// The number of signers (M) required to validate this multisignature /// account. m: u8, @@ -457,7 +457,7 @@ pub const Instruction = union(InstructionDiscriminant) { /// /// 0. `[writable]` The mint to initialize. /// - initialize_mint_2: packed struct { + initialize_mint_2: extern struct { /// Number of base 10 digits to the right of the decimal place. decimals: u8, /// The authority/multisignature to mint tokens. @@ -501,7 +501,7 @@ pub const Instruction = union(InstructionDiscriminant) { /// Accounts expected by this instruction: /// /// 0. `[]` The mint to calculate for - amount_to_ui_amount: packed struct { + amount_to_ui_amount: extern struct { /// The amount of tokens to reformat. amount: u64, }, @@ -514,7 +514,7 @@ pub const Instruction = union(InstructionDiscriminant) { /// Accounts expected by this instruction: /// /// 0. `[]` The mint to calculate for - ui_amount_to_amount: packed struct { + ui_amount_to_amount: extern struct { /// The ui_amount of tokens to reformat. ui_amount: [*:0]u8, }, diff --git a/token/zig/src/main.zig b/token/zig/src/main.zig index 0816d7a..7991664 100644 --- a/token/zig/src/main.zig +++ b/token/zig/src/main.zig @@ -1,4 +1,4 @@ -const sol = @import("solana-program-sdk"); +const sol = @import("solana_program_sdk"); const PublicKey = sol.PublicKey; const Rent = sol.Rent; diff --git a/token/zig/src/state.zig b/token/zig/src/state.zig index 179ca50..feacf0b 100644 --- a/token/zig/src/state.zig +++ b/token/zig/src/state.zig @@ -1,8 +1,8 @@ const std = @import("std"); -const PublicKey = @import("solana-program-sdk").PublicKey; +const PublicKey = @import("solana_program_sdk").PublicKey; const TokenError = @import("error.zig").TokenError; -pub const Mint = packed struct { +pub const Mint = extern struct { pub const len = 82; mint_authority: COption(PublicKey), @@ -23,7 +23,7 @@ pub const Mint = packed struct { } }; -pub const Account = packed struct { +pub const Account = extern struct { pub const len = 165; pub const State = enum(u8) { @@ -61,7 +61,7 @@ pub const Account = packed struct { }; pub fn COption(T: type) type { - return packed struct { + return extern struct { is_some: u32, value: T, const Self = @This(); @@ -94,7 +94,7 @@ pub fn COption(T: type) type { }; } -pub const Multisig = packed struct { +pub const Multisig = extern struct { pub const len = 355; }; diff --git a/transfer-lamports/zig/build.zig b/transfer-lamports/zig/build.zig index 1c2b386..e99fa26 100644 --- a/transfer-lamports/zig/build.zig +++ b/transfer-lamports/zig/build.zig @@ -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); diff --git a/transfer-lamports/zig/build.zig.zon b/transfer-lamports/zig/build.zig.zon index b294afb..ba29a2b 100644 --- a/transfer-lamports/zig/build.zig.zon +++ b/transfer-lamports/zig/build.zig.zon @@ -1,5 +1,6 @@ .{ - .name = "solana-program-rosetta-helloworld-zig", + .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", @@ -7,7 +8,7 @@ // 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`. @@ -15,9 +16,9 @@ // 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.0.tar.gz", + .hash = "solana_program_sdk-0.16.0-wGj9UFDgAAA31EfM9LV-cmDP5BctyNwEVvyEWtZ1QPkj", }, }, .paths = .{ diff --git a/transfer-lamports/zig/main.zig b/transfer-lamports/zig/main.zig index 6903a42..0914d90 100644 --- a/transfer-lamports/zig/main.zig +++ b/transfer-lamports/zig/main.zig @@ -1,5 +1,5 @@ const std = @import("std"); -const sol = @import("solana-program-sdk"); +const sol = @import("solana_program_sdk"); export fn entrypoint(input: [*]u8) u64 { const context = sol.Context.load(input) catch return 1;