Selaa lähdekoodia

Bump anchor and other dependencies (#1570)

Update all the crates which can be updated easily.

Signed-off-by: Sean Young <sean@mess.org>
Sean Young 2 vuotta sitten
vanhempi
sitoutus
b299eae253

+ 20 - 19
Cargo.toml

@@ -30,10 +30,10 @@ serde = "1.0"
 serde_derive = { version = "1.0" }
 inkwell = { version = "0.2.0", features = ["target-webassembly", "no-libffi-linking", "llvm15-0"], optional = true }
 blake2-rfc = "0.2.18"
-handlebars = "4.3"
-contract-metadata = "3.0"
+handlebars = "4.4"
+contract-metadata = "3.2"
 semver = { version = "1.0", features = ["serde"] }
-tempfile = "3.4"
+tempfile = "3.8"
 libc = { version = "0.2", optional = true }
 tower-lsp = "0.20"
 tokio = { version = "1.27", features = ["rt", "io-std", "macros"] }
@@ -45,22 +45,22 @@ funty = "2.0"
 itertools = "0.11"
 num-rational = "0.4"
 indexmap = "2.0"
-once_cell = "1.17"
-solang-parser = { path = "solang-parser", version = "0.3.1" }
+once_cell = "1.18"
+solang-parser = { path = "solang-parser", version = "0.3.2" }
 codespan-reporting = "0.11"
 phf = { version = "0.11", features = ["macros"] }
 rust-lapper = "1.1"
-anchor-syn = { version = "0.28.0", features = ["idl"] }
+anchor-syn = { version = "0.29.0", features = ["idl-build"] }
 convert_case = "0.6"
-parse-display = "0.8.0"
-parity-scale-codec = "3.4"
-ink_env = "4.2.0"
-ink_metadata = "4.2.0"
-scale-info = "2.4"
-petgraph = "0.6.3"
+parse-display = "0.8"
+parity-scale-codec = "3.6"
+ink_env = "4.3.0"
+ink_metadata = "4.3.0"
+scale-info = "2.9"
+petgraph = "0.6"
 wasmparser = "0.110.0"
 wasm-encoder = "0.31"
-toml = "0.7"
+toml = "0.8"
 wasm-opt = { version = "0.112.0", optional = true }
 contract-build = { version = "3.0.1", optional = true }
 primitive-types = { version = "0.12", features = ["codec"] }
@@ -72,18 +72,19 @@ forge-fmt = "0.2.0"
 num-derive = "0.4"
 wasmi = "0.31"
 # solana_rbpf makes api changes in patch versions
-solana_rbpf = "=0.6.0"
-byteorder = "1.4"
+solana_rbpf = "=0.6.1"
+byteorder = "1.5"
 assert_cmd = "2.0"
 bincode = "1.3"
 ed25519-dalek = { version = "2", features = ["rand_core"] }
 path-slash = "0.2"
-pretty_assertions = "1.3"
+pretty_assertions = "1.4"
 byte-slice-cast = "1.2"
-borsh = "0.10"
+borsh = "1.1"
+borsh-derive = "1.1"
 rayon = "1"
-walkdir = "2.3.3"
-ink_primitives = "4.2.0"
+walkdir = "2.4"
+ink_primitives = "4.3.0"
 wasm_host_attr = { path = "tests/wasm_host_attr" }
 num-bigint = { version = "0.4", features = ["rand", "serde"]}
 

+ 1 - 1
integration/anchor/programs/anchor/Cargo.toml

@@ -16,5 +16,5 @@ cpi = ["no-entrypoint"]
 default = []
 
 [dependencies]
-anchor-lang = "0.28.0"
+anchor-lang = "0.29.0"
 solana-program = "1.16.1"

+ 15 - 0
integration/anchor/programs/anchor/src/lib.rs

@@ -86,6 +86,14 @@ pub mod anchor {
         })
     }
 
+    pub fn test_event(_ctx: Context<State>) -> Result<()> {
+        emit!(MyEvent {
+            data: 6,
+            label: "bye".to_string(),
+        });
+        Ok(())
+    }
+
     pub fn multi_dimensional(
         _ctx: Context<NoAccountsNeeded>,
         arr: [[u16; 3]; 4],
@@ -181,3 +189,10 @@ pub struct State<'info> {
     #[account()]
     pub my_account: Account<'info, MyAccount>,
 }
+
+#[event]
+pub struct MyEvent {
+    pub data: i64,
+    #[index]
+    pub label: String,
+}

+ 4 - 0
integration/anchor/tests/call_anchor.sol

@@ -73,4 +73,8 @@ contract call_anchor {
         require(ret8[1][2] == 8000, "array 2");
         require(ret8[2][0] == 3000, "array 3");
     }
+
+    function test_event() public {
+        emit MyEvent({data: 102, label: "yadayada" });
+    }
 }

+ 19 - 1
integration/anchor/tests/call_anchor.spec.ts

@@ -2,7 +2,7 @@ import expect from 'expect';
 import { AnchorProvider, Program } from '@coral-xyz/anchor';
 import {
     PublicKey, AccountMeta,
-    Keypair, Signer,
+    Keypair,
     Connection,
     LAMPORTS_PER_SOL,
     BpfLoader, Transaction,
@@ -69,6 +69,24 @@ describe('Call Anchor program from Solidity via IDL', () => {
             .remainingAccounts(remainingAccounts)
             .signers([data, payer])
             .rpc();
+
+        let seen = false;
+
+        const listenId = program.addEventListener("MyEvent", (ev) => {
+            expect(ev.data.toNumber()).toBe(102);
+            expect(ev.label).toBe("yadayada");
+            seen = true;
+        });
+
+        await program.methods.testEvent()
+            .accounts({
+                dataAccount: storage.publicKey,
+            })
+            .rpc();
+
+        program.removeEventListener(listenId);
+
+        expect(seen).toBe(true);
     });
 });
 

+ 1 - 2
solang-parser/Cargo.toml

@@ -19,11 +19,10 @@ phf = { version = "0.11", features = ["macros"] }
 unicode-xid = "0.2"
 itertools = "0.11"
 thiserror = "1.0"
-
 serde = { version = "1.0", features = ["derive"], optional = true }
 
 [dev-dependencies]
-walkdir = "2.3.3"
+walkdir = "2.4"
 regex = "1"
 pretty_assertions = "1.3"
 

+ 5 - 1
src/abi/anchor.rs

@@ -3,7 +3,7 @@
 use crate::sema::ast::{
     ArrayLength, Contract, Function, Namespace, Parameter, StructDecl, StructType, Tag, Type,
 };
-use anchor_syn::idl::{
+use anchor_syn::idl::types::{
     Idl, IdlAccount, IdlAccountItem, IdlEnumVariant, IdlEvent, IdlEventField, IdlField,
     IdlInstruction, IdlType, IdlTypeDefinition, IdlTypeDefinitionTy,
 };
@@ -243,6 +243,7 @@ impl TypeManager<'_> {
                 func.name
             )]),
             ty: IdlTypeDefinitionTy::Struct { fields },
+            generics: None,
         });
 
         IdlType::Defined(name)
@@ -313,6 +314,7 @@ impl TypeManager<'_> {
             name,
             docs,
             ty: IdlTypeDefinitionTy::Struct { fields },
+            generics: None,
         });
     }
 
@@ -337,6 +339,7 @@ impl TypeManager<'_> {
                 name,
                 docs: item.docs,
                 ty: item.ty,
+                generics: None,
             });
         }
 
@@ -372,6 +375,7 @@ impl TypeManager<'_> {
             name,
             docs,
             ty: IdlTypeDefinitionTy::Enum { variants },
+            generics: None,
         });
     }
 

+ 24 - 11
src/abi/tests.rs

@@ -7,7 +7,7 @@ use crate::codegen::{codegen, Options};
 use crate::file_resolver::FileResolver;
 use crate::sema::ast::Namespace;
 use crate::{codegen, parse_and_resolve, Target};
-use anchor_syn::idl::{
+use anchor_syn::idl::types::{
     IdlAccount, IdlAccountItem, IdlEnumVariant, IdlEvent, IdlEventField, IdlField, IdlType,
     IdlTypeDefinition, IdlTypeDefinitionTy,
 };
@@ -311,7 +311,8 @@ fn instructions_and_types() {
                         ty: IdlType::String,
                     }
                 ]
-            }
+            },
+            generics: None
         }
     );
 
@@ -408,7 +409,8 @@ contract caller {
                         fields: None,
                     }
                 ]
-            }
+            },
+            generics: None
         }
     );
 
@@ -664,6 +666,7 @@ contract Testing {
                     }
                 ],
             },
+            generics: None
         }
     );
 }
@@ -765,7 +768,8 @@ contract Testing {
                         ty: IdlType::U64
                     }
                 ]
-            }
+            },
+            generics: None
         }
     );
 
@@ -789,7 +793,8 @@ contract Testing {
                         ty: IdlType::I32
                     }
                 ]
-            }
+            },
+            generics: None
         }
     );
 }
@@ -832,6 +837,7 @@ fn name_collision() {
                     ty: IdlType::String,
                 }]
             },
+            generics: None
         }
     );
 
@@ -855,7 +861,8 @@ fn name_collision() {
                         ty: IdlType::U64
                     }
                 ]
-            }
+            },
+            generics: None
         }
     );
 
@@ -879,7 +886,8 @@ fn name_collision() {
                         ty: IdlType::I32
                     }
                 ]
-            }
+            },
+            generics: None
         }
     );
 }
@@ -926,6 +934,7 @@ fn double_name_collision() {
                     ty: IdlType::String,
                 }]
             },
+            generics: None
         }
     );
 
@@ -940,7 +949,8 @@ fn double_name_collision() {
                     docs: None,
                     ty: IdlType::Bytes
                 },]
-            }
+            },
+            generics: None
         }
     );
 
@@ -964,7 +974,8 @@ fn double_name_collision() {
                         ty: IdlType::U64
                     }
                 ]
-            }
+            },
+            generics: None
         }
     );
 
@@ -988,7 +999,8 @@ fn double_name_collision() {
                         ty: IdlType::I32
                     }
                 ]
-            }
+            },
+            generics: None
         }
     );
 }
@@ -1054,7 +1066,8 @@ fn deduplication() {
                         ty: IdlType::PublicKey
                     }
                 ]
-            }
+            },
+            generics: None
         }
     );
 

+ 6 - 3
src/bin/idl/mod.rs

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: Apache-2.0
 
 use crate::cli::IdlCommand;
-use anchor_syn::idl::{Idl, IdlAccountItem, IdlInstruction, IdlType, IdlTypeDefinitionTy};
+use anchor_syn::idl::types::{Idl, IdlAccountItem, IdlInstruction, IdlType, IdlTypeDefinitionTy};
 use itertools::Itertools;
 use serde_json::Value as JsonValue;
 use solang::abi::anchor::discriminator;
@@ -176,7 +176,7 @@ fn write_solidity(idl: &Idl, mut f: File) -> Result<(), std::io::Error> {
 
                 let name = &ty_names.iter().find(|e| *e.0 == event.name).unwrap().1;
 
-                writeln!(f, "event {name} {{")?;
+                writeln!(f, "event {name} (")?;
                 let mut iter = event.fields.iter().enumerate();
                 let mut next = iter.next();
                 while let Some((no, e)) = next {
@@ -191,7 +191,7 @@ fn write_solidity(idl: &Idl, mut f: File) -> Result<(), std::io::Error> {
                         if next.is_some() { "," } else { "" }
                     )?;
                 }
-                writeln!(f, "}}")?;
+                writeln!(f, ");")?;
             } else {
                 eprintln!(
                     "event {} has fields of type {} which is not supported on Solidity",
@@ -367,6 +367,9 @@ fn idltype_to_solidity(ty: &IdlType, ty_names: &[(String, String)]) -> Result<St
             Ok(ty) => Ok(format!("{ty}[{size}]")),
             Err(ty) => Err(format!("{ty}[{size}]")),
         },
+        IdlType::Generic(..)
+        | IdlType::GenericLenArray(..)
+        | IdlType::DefinedWithTypeArgs { .. } => Err("generics are not supported".into()),
     }
 }
 

+ 10 - 2
tests/borsh_encoding.rs

@@ -1,6 +1,6 @@
 // SPDX-License-Identifier: Apache-2.0
 
-use anchor_syn::idl::{IdlType, IdlTypeDefinition, IdlTypeDefinitionTy};
+use anchor_syn::idl::types::{IdlType, IdlTypeDefinition, IdlTypeDefinitionTy};
 use byte_slice_cast::AsByteSlice;
 use num_bigint::{BigInt, Sign};
 use num_traits::ToPrimitive;
@@ -341,6 +341,9 @@ pub fn decode_at_offset(
 
                     BorshToken::Tuple(read_items)
                 }
+                IdlTypeDefinitionTy::Alias { value } => {
+                    decode_at_offset(data, offset, value, custom_types)
+                }
             }
         }
         IdlType::Bytes => {
@@ -353,7 +356,12 @@ pub fn decode_at_offset(
             BorshToken::Bytes(read_data.to_vec())
         }
 
-        IdlType::Option(_) | IdlType::F32 | IdlType::F64 => {
+        IdlType::Option(_)
+        | IdlType::F32
+        | IdlType::F64
+        | IdlType::Generic(..)
+        | IdlType::DefinedWithTypeArgs { .. }
+        | IdlType::GenericLenArray(..) => {
             unreachable!("Type not available in Solidity")
         }
     }

+ 1 - 1
tests/solana.rs

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: Apache-2.0
 
 use crate::borsh_encoding::{decode_at_offset, encode_arguments, BorshToken};
-use anchor_syn::idl::{Idl, IdlAccountItem};
+use anchor_syn::idl::types::{Idl, IdlAccountItem};
 use base58::{FromBase58, ToBase58};
 use byteorder::{ByteOrder, LittleEndian, WriteBytesExt};
 use itertools::Itertools;

+ 34 - 33
tests/solana_tests/abi_decode.rs

@@ -2,7 +2,8 @@
 
 use crate::solana_tests::abi_encode::create_response;
 use crate::{build_solidity, BorshToken};
-use borsh::BorshSerialize;
+use borsh::to_vec;
+use borsh_derive::BorshSerialize;
 
 #[test]
 fn integers_bool_enum() {
@@ -80,7 +81,7 @@ fn integers_bool_enum() {
         day: WeekDay::Wednesday,
         h: false,
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("decodeTest1")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -91,7 +92,7 @@ fn integers_bool_enum() {
         item_2: WeekDay::Saturday,
         item_3: WeekDay::Friday,
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("decodeTest2")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -128,7 +129,7 @@ fn decode_address() {
         address: vm.stack[0].id,
         this: vm.stack[0].id,
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("testAddress")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -164,7 +165,7 @@ fn string_and_bytes() {
         a: "coffee".to_string(),
         b: b"tea".to_vec(),
     };
-    let encoded = data.try_to_vec().unwrap();
+    let encoded = to_vec(&data).unwrap();
     let _ = vm
         .function("testStringAndBytes")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -221,7 +222,7 @@ fn primitive_struct() {
         .accounts(vec![("dataAccount", data_account)])
         .call();
     let data = NoPadStruct { a: 1238, b: 87123 };
-    let encoded = data.try_to_vec().unwrap();
+    let encoded = to_vec(&data).unwrap();
     let _ = vm
         .function("testNoPadStruct")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -234,7 +235,7 @@ fn primitive_struct() {
         b: 240,
         c: <[u8; 32]>::try_from(&elem[0..32]).unwrap(),
     };
-    let encoded = data.try_to_vec().unwrap();
+    let encoded = to_vec(&data).unwrap();
     let _ = vm
         .function("testPaddedStruct")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -265,7 +266,7 @@ fn returned_string() {
     let data = Input {
         rr: "cortado".to_string(),
     };
-    let encoded = data.try_to_vec().unwrap();
+    let encoded = to_vec(&data).unwrap();
     let returns = vm
         .function("returnedString")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -304,7 +305,7 @@ fn test_string_array() {
             "cappuccino".to_string(),
         ],
     };
-    let encoded = data.try_to_vec().unwrap();
+    let encoded = to_vec(&data).unwrap();
     let returns = vm
         .function("testStringVector")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -396,7 +397,7 @@ fn struct_within_struct() {
         no_pad,
         pad,
     };
-    let encoded = data.try_to_vec().unwrap();
+    let encoded = to_vec(&data).unwrap();
     let _ = vm
         .function("testStruct")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -510,7 +511,7 @@ fn struct_in_array() {
             c: <[u8; 32]>::try_from(bytes_string).unwrap(),
         },
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("twoStructs")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -525,7 +526,7 @@ fn struct_in_array() {
             NoPadStruct { a: 945, b: 7453 },
         ],
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("fixedArrays")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -534,7 +535,7 @@ fn struct_in_array() {
     let input = Input3 {
         vec: vec![NoPadStruct { a: 5, b: 6 }, NoPadStruct { a: 7, b: 8 }],
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("primitiveDynamic")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -627,7 +628,7 @@ fn arrays() {
             },
         ],
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("decodeComplex")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -636,7 +637,7 @@ fn arrays() {
     let input = Input2 {
         vec: vec![-90, 5523, -89],
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("dynamicArray")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -645,7 +646,7 @@ fn arrays() {
     let input = Input3 {
         multi_dim: [[1, 2], [4, 5], [6, 7]],
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("decodeMultiDim")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -805,7 +806,7 @@ fn multi_dimensional_arrays() {
         ]],
         item_2: -90,
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("multiDimStruct")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -817,7 +818,7 @@ fn multi_dimensional_arrays() {
             [[9, 10, 11, 12], [13, 14, 15, 16]],
         ],
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("multiDimInt")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -826,7 +827,7 @@ fn multi_dimensional_arrays() {
     let input = Input3 {
         vec: vec![9, 3, 4, 90, 834],
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("uniqueDim")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -873,7 +874,7 @@ fn empty_arrays() {
         vec_1: vec![],
         vec_2: vec![],
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("testEmpty")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -910,7 +911,7 @@ fn external_function() {
             24, 25, 26, 27, 28, 29, 30, 31,
         ],
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
 
     let returns = vm
         .function("testExternalFunction")
@@ -959,7 +960,7 @@ fn bytes_arrays() {
         item_1: [b"abcd".to_owned(), b"efgh".to_owned()],
         item_2: vec![b"12345".to_owned(), b"67890".to_owned()],
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("testByteArrays")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -997,7 +998,7 @@ fn different_types() {
         .accounts(vec![("dataAccount", data_account)])
         .call();
     let input = Input1 { a: -789, b: 14234 };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("testByteArrays")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -1030,7 +1031,7 @@ fn more_elements() {
         .call();
 
     let input = Input { vec: [1, 4, 5, 6] };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("wrongNumber")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -1066,7 +1067,7 @@ fn extra_element() {
         vec: vec![-90, 89, -2341],
     };
 
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("extraElement")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -1099,7 +1100,7 @@ fn invalid_type() {
         .call();
 
     let input = Input { item: 5 };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("invalidType")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -1136,7 +1137,7 @@ fn longer_buffer() {
         item_1: 4,
         item_2: 5,
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("testLongerBuffer")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -1174,7 +1175,7 @@ fn longer_buffer_array() {
         item_1: 23434,
         item_2: [1, 2, 3, 4],
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("testLongerBuffer")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -1212,7 +1213,7 @@ fn dynamic_array_of_array() {
     let input = Input {
         vec: vec![[0, 1], [2, -3]],
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("testArrayAssign")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -1271,7 +1272,7 @@ fn test_struct_validation() {
             d: "string".to_string(),
         },
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("test")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -1329,7 +1330,7 @@ fn test_struct_validation_invalid() {
             d: "string".to_string(),
         },
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("test")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -1369,7 +1370,7 @@ fn string_fixed_array() {
             "d".to_string(),
         ],
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("testing")
         .arguments(&[BorshToken::Bytes(encoded)])
@@ -1410,7 +1411,7 @@ fn double_dynamic_array() {
         item_2: vec![vec![99, 20], vec![15, 88]],
         item_3: -755,
     };
-    let encoded = input.try_to_vec().unwrap();
+    let encoded = to_vec(&input).unwrap();
     let _ = vm
         .function("testThis")
         .arguments(&[BorshToken::Bytes(encoded)])

+ 1 - 0
tests/solana_tests/abi_encode.rs

@@ -2,6 +2,7 @@
 
 use crate::{build_solidity, BorshToken};
 use borsh::BorshDeserialize;
+use borsh_derive::BorshDeserialize;
 use num_bigint::BigInt;
 
 #[test]

+ 1 - 1
tests/solana_tests/account_access.rs

@@ -2,7 +2,7 @@
 
 use crate::borsh_encoding::BorshToken;
 use crate::{account_new, build_solidity, create_program_address, AccountState};
-use anchor_syn::idl::{IdlAccount, IdlAccountItem, IdlInstruction};
+use anchor_syn::idl::types::{IdlAccount, IdlAccountItem, IdlInstruction};
 
 #[test]
 fn access_payer() {

+ 1 - 1
tests/solana_tests/balance.rs

@@ -1,7 +1,7 @@
 // SPDX-License-Identifier: Apache-2.0
 
 use crate::{account_new, build_solidity, AccountMeta, AccountState, BorshToken, Pubkey};
-use anchor_syn::idl::IdlInstruction;
+use anchor_syn::idl::types::IdlInstruction;
 use num_bigint::BigInt;
 
 #[test]

+ 1 - 0
tests/solana_tests/events.rs

@@ -2,6 +2,7 @@
 
 use crate::build_solidity;
 use borsh::BorshDeserialize;
+use borsh_derive::BorshDeserialize;
 use sha2::{Digest, Sha256};
 
 #[test]

+ 6 - 5
tests/solana_tests/metas.rs

@@ -1,7 +1,8 @@
 // SPDX-License-Identifier: Apache-2.0
 
 use crate::{account_new, build_solidity, build_solidity_with_cache, AccountState, BorshToken};
-use borsh::BorshSerialize;
+use borsh::to_vec;
+use borsh_derive::BorshSerialize;
 use num_bigint::BigInt;
 use solang::file_resolver::FileResolver;
 
@@ -130,7 +131,7 @@ contract Foo {
         close_authority: account_new(),
     };
 
-    let encoded = data.try_to_vec().unwrap();
+    let encoded = to_vec(&data).unwrap();
 
     let account = account_new();
     vm.account_data.insert(
@@ -187,7 +188,7 @@ contract Foo {
     data.is_native_present = 1;
     data.close_authority_present = 1;
 
-    let encoded = data.try_to_vec().unwrap();
+    let encoded = to_vec(&data).unwrap();
     vm.account_data.get_mut(&account).unwrap().data = encoded;
 
     let res = vm
@@ -269,7 +270,7 @@ contract Foo {
         freeze_authority: account_new(),
     };
 
-    let encoded = data.try_to_vec().unwrap();
+    let encoded = to_vec(&data).unwrap();
     let account = account_new();
     vm.account_data.insert(
         account,
@@ -314,7 +315,7 @@ contract Foo {
     data.authority_present = 1;
     data.is_initialized = true;
     data.freeze_authority_present = 1;
-    let encoded = data.try_to_vec().unwrap();
+    let encoded = to_vec(&data).unwrap();
     vm.account_data.get_mut(&account).unwrap().data = encoded;
 
     let res = vm

+ 1 - 1
tests/solana_tests/optimizations.rs

@@ -4,7 +4,7 @@ use crate::{
     borsh_encoding::{visit_mut, VisitorMut},
     AccountMeta, BorshToken, Pubkey, VirtualMachineBuilder,
 };
-use anchor_syn::idl::IdlAccountItem;
+use anchor_syn::idl::types::IdlAccountItem;
 use once_cell::sync::Lazy;
 use rayon::iter::ParallelIterator;
 use rayon::prelude::IntoParallelIterator;