Skip to content

Commit

Permalink
use borsh 1.5
Browse files Browse the repository at this point in the history
# Conflicts:
#	Cargo.lock
#	clients/js/dist/src/index.js.map
#	clients/js/dist/src/index.mjs.map
#	package.json
#	pnpm-lock.yaml

# Conflicts:
#	Cargo.lock
#	Cargo.toml
#	clients/rust/src/generated/instructions/create_activated_device.rs
  • Loading branch information
Kabie authored and jasl committed Jun 24, 2024
1 parent b18434b commit 83724f9
Show file tree
Hide file tree
Showing 11 changed files with 723 additions and 1,105 deletions.
1,731 changes: 653 additions & 1,078 deletions Cargo.lock

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ thiserror = "1.0.61"
serde = "1.0.202"
serde_with = "3.8.1"
assert_matches = "1.5.0"
solana-program = "1.18.16"
solana-program-test = "1.18.16"
solana-sdk = "1.18.16"
solana-client = "1.18.16"
solana-zk-token-sdk = "1.18.16"
solana-program = "2.0.0"
solana-program-test = "2.0.0"
solana-sdk = "2.0.0"
solana-client = "2.0.0"
solana-zk-token-sdk = "2.0.0"
spl-associated-token-account = "3.0.2"
spl-token-2022 = "3.0.2"
spl-token-metadata-interface = "0.3.3"
Expand Down
2 changes: 1 addition & 1 deletion clients/rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ edition = "2021"
publish = false

[dependencies]
borsh = "0.10.3" # 1.5.0 has trouble
borsh = { workspace = true }
num-derive = { workspace = true }
num-traits = { workspace = true }
serde = { workspace = true, optional = true, features = ["derive"] }
Expand Down
8 changes: 4 additions & 4 deletions clients/rust/src/generated/instructions/activate_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ impl ActivateDevice {
self.owner, false,
));
accounts.extend_from_slice(remaining_accounts);
let mut data = ActivateDeviceInstructionData::new().try_to_vec().unwrap();
let mut args = args.try_to_vec().unwrap();
let mut data = borsh::to_vec(&ActivateDeviceInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&args).unwrap();
data.append(&mut args);

solana_program::instruction::Instruction {
Expand Down Expand Up @@ -467,8 +467,8 @@ impl<'a, 'b> ActivateDeviceCpi<'a, 'b> {
is_writable: remaining_account.2,
})
});
let mut data = ActivateDeviceInstructionData::new().try_to_vec().unwrap();
let mut args = self.__args.try_to_vec().unwrap();
let mut data = borsh::to_vec(&ActivateDeviceInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&self.__args).unwrap();
data.append(&mut args);

let instruction = solana_program::instruction::Instruction {
Expand Down
8 changes: 4 additions & 4 deletions clients/rust/src/generated/instructions/create_device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,8 @@ impl CreateDevice {
false,
));
accounts.extend_from_slice(remaining_accounts);
let mut data = CreateDeviceInstructionData::new().try_to_vec().unwrap();
let mut args = args.try_to_vec().unwrap();
let mut data = borsh::to_vec(&CreateDeviceInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&args).unwrap();
data.append(&mut args);

solana_program::instruction::Instruction {
Expand Down Expand Up @@ -435,8 +435,8 @@ impl<'a, 'b> CreateDeviceCpi<'a, 'b> {
is_writable: remaining_account.2,
})
});
let mut data = CreateDeviceInstructionData::new().try_to_vec().unwrap();
let mut args = self.__args.try_to_vec().unwrap();
let mut data = borsh::to_vec(&CreateDeviceInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&self.__args).unwrap();
data.append(&mut args);

let instruction = solana_program::instruction::Instruction {
Expand Down
8 changes: 4 additions & 4 deletions clients/rust/src/generated/instructions/create_product.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ impl CreateProduct {
false,
));
accounts.extend_from_slice(remaining_accounts);
let mut data = CreateProductInstructionData::new().try_to_vec().unwrap();
let mut args = args.try_to_vec().unwrap();
let mut data = borsh::to_vec(&CreateProductInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&args).unwrap();
data.append(&mut args);

solana_program::instruction::Instruction {
Expand Down Expand Up @@ -330,8 +330,8 @@ impl<'a, 'b> CreateProductCpi<'a, 'b> {
is_writable: remaining_account.2,
})
});
let mut data = CreateProductInstructionData::new().try_to_vec().unwrap();
let mut args = self.__args.try_to_vec().unwrap();
let mut data = borsh::to_vec(&CreateProductInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&self.__args).unwrap();
data.append(&mut args);

let instruction = solana_program::instruction::Instruction {
Expand Down
8 changes: 4 additions & 4 deletions clients/rust/src/generated/instructions/initialize.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ impl Initialize {
true,
));
accounts.extend_from_slice(remaining_accounts);
let mut data = InitializeInstructionData::new().try_to_vec().unwrap();
let mut args = args.try_to_vec().unwrap();
let mut data = borsh::to_vec(&InitializeInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&args).unwrap();
data.append(&mut args);

solana_program::instruction::Instruction {
Expand Down Expand Up @@ -273,8 +273,8 @@ impl<'a, 'b> InitializeCpi<'a, 'b> {
is_writable: remaining_account.2,
})
});
let mut data = InitializeInstructionData::new().try_to_vec().unwrap();
let mut args = self.__args.try_to_vec().unwrap();
let mut data = borsh::to_vec(&InitializeInstructionData::new()).unwrap();
let mut args = borsh::to_vec(&self.__args).unwrap();
data.append(&mut args);

let instruction = solana_program::instruction::Instruction {
Expand Down
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,10 @@
"typescript": "^5.5.2",
"zx": "^7.2.3"
},
"packageManager": "[email protected]"
"packageManager": "[email protected]",
"pnpm": {
"patchedDependencies": {
"@kinobi-so/[email protected]": "patches/@[email protected]"
}
}
}
32 changes: 32 additions & 0 deletions patches/@[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
diff --git a/dist/templates/instructionsCpiPage.njk b/dist/templates/instructionsCpiPage.njk
index b955b9acdec9fe52b2c10ba2b9abb1ad2401cff5..054b449a1e8d94cdb522c397305893c2e5241afe 100644
--- a/dist/templates/instructionsCpiPage.njk
+++ b/dist/templates/instructionsCpiPage.njk
@@ -150,9 +150,9 @@ impl<'a, 'b> {{ instruction.name | pascalCase }}Cpi<'a, 'b> {
is_writable: remaining_account.2,
})
});
- let {{ 'mut ' if hasArgs }}data = {{ instruction.name | pascalCase }}InstructionData::new().try_to_vec().unwrap();
+ let {{ 'mut ' if hasArgs }}data = borsh::to_vec(&{{ instruction.name | pascalCase }}InstructionData::new()).unwrap();
{% if hasArgs %}
- let mut args = self.__args.try_to_vec().unwrap();
+ let mut args = borsh::to_vec(&self.__args).unwrap();
data.append(&mut args);
{% endif %}

diff --git a/dist/templates/instructionsPage.njk b/dist/templates/instructionsPage.njk
index b58249d4a96464117234aab646ba7fe9f5114b1a..f5df940c05d7ea46440a3bb64c08909c2f016a14 100644
--- a/dist/templates/instructionsPage.njk
+++ b/dist/templates/instructionsPage.njk
@@ -93,9 +93,9 @@ impl {{ instruction.name | pascalCase }} {
{% endif %}
{% endfor %}
accounts.extend_from_slice(remaining_accounts);
- let {{ 'mut ' if hasArgs }}data = {{ instruction.name | pascalCase }}InstructionData::new().try_to_vec().unwrap();
+ let {{ 'mut ' if hasArgs }}data = borsh::to_vec(&{{ instruction.name | pascalCase }}InstructionData::new()).unwrap();
{% if hasArgs %}
- let mut args = args.try_to_vec().unwrap();
+ let mut args = borsh::to_vec(&args).unwrap();
data.append(&mut args);
{% endif %}

9 changes: 7 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions scripts/generate-clients.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env zx
import "zx/globals";
import fs from 'fs';
import * as k from "kinobi";
import {rootNodeFromAnchor} from "@kinobi-so/nodes-from-anchor";
import {renderVisitor as renderJavaScriptVisitor} from "@kinobi-so/renderers-js";
Expand All @@ -8,8 +9,8 @@ import {getAllProgramIdls, workingDirectory} from "./utils.mjs";
import {renderVisitor as renderUmiVisitor} from "@kinobi-so/renderers-js-umi";

// Instanciate Kinobi.
const [idl, ...additionalIdls] = getAllProgramIdls().map(idl => rootNodeFromAnchor(require(idl)))
const kinobi = k.createFromRoot(idl, additionalIdls);
const [idl, ...additionalIdls] = getAllProgramIdls().filter(fs.existsSync).map(idl => rootNodeFromAnchor(require(idl)))
const kinobi = k.createFromRoot(idl);

// Update programs.
kinobi.update(
Expand Down

0 comments on commit 83724f9

Please sign in to comment.