anchor
anchor copied to clipboard
Hashmaps arent supported in anchor idl
getting this error in logs when running anchor deployELF error: Found writable section (.bss._ZN3std11collections4hash3map11RandomState3new4KEYS7__getit5__KEY17h9d3c0f65754b98d3E) in ELF, read-write data not supported
code
credit to @abishekk92 for pointing this out
solana has no support for the hashmap type, so anchor doesn't either
It has a hash function though so maybe we could roll our own hashmap. @armaniferrante wdyt?
Having a mapping function would be super useful, right now we have to use custom structs and arrays for everything and arrays aren't really a safe replacement for maps
Highly request this @armaniferrante
Second on this, hashmaps seem to be quite useful
solana has no support for the hashmap type, so anchor doesn't either
It has a hash function though so maybe we could roll our own hashmap. @armaniferrante wdyt?
https://docs.solana.com/implemented-proposals/persistent-account-storage
I think, Solana has support HashMap
solana has no support for the hashmap type, so anchor doesn't either It has a hash function though so maybe we could roll our own hashmap. @armaniferrante wdyt?
https://docs.solana.com/implemented-proposals/persistent-account-storage
I think, Solana has support HashMap
i think the anchor team prefers using PDAs as hashmaps as Paul mentioned in the anchor book so traditional hashmaps might never be implemented
@anoushk1234 what about size bounded BTreeMap? @armaniferrante ???
solana has no support for the hashmap type, so anchor doesn't either It has a hash function though so maybe we could roll our own hashmap. @armaniferrante wdyt?
https://docs.solana.com/implemented-proposals/persistent-account-storage I think, Solana has support HashMap
i think the anchor team prefers using PDAs as hashmaps as Paul mentioned in the anchor book so traditional hashmaps might never be implemented
PDA's also come with the additional cost associated with creating and rent-exempting accounts on-demand. If you know your HashMap won't exceed a certain size, serializing and deserializing it in one account makes a lot of sense.
If Anchor could:
- Use normal borsh serialize / deserialize for HashMap data types
- give the user the ability to assign whatever type they want on the client side (perhaps by typing the property that is a HashMap with
unknown
)
Then I'm sure developers could figure out the rest
solana has no support for the hashmap type, so anchor doesn't either It has a hash function though so maybe we could roll our own hashmap. @armaniferrante wdyt?
https://docs.solana.com/implemented-proposals/persistent-account-storage I think, Solana has support HashMap
i think the anchor team prefers using PDAs as hashmaps as Paul mentioned in the anchor book so traditional hashmaps might never be implemented
PDA's also come with the additional cost associated with creating and rent-exempting accounts on-demand. If you know your HashMap won't exceed a certain size, serializing and deserializing it in one account makes a lot of sense.
If Anchor could:
* Use normal borsh serialize / deserialize for HashMap data types * give the user the ability to assign whatever type they want on the client side (perhaps by typing the property that is a HashMap with `unknown`)
Then I'm sure developers could figure out the rest
It's a good idea, wdyt @paul-schaaf ?
Solana has support BtreeMap, but anchor has not support
IdlError: Type not found: {"name":"participants","type":{"defined":"BTreeMap<Pubkey,u64>"}}
and anchor has not support tuple
type
IdlError: Type not found: {"type":{"defined":"(Pubkey,u64)"}}
I meet the same problem, but the differentence is i defined an struct,but it also can not work. IdlError: Type not found: {"type":{"defined":"Tick"}}
I meet the same problem, but the differentence is i defined an struct,but it also can not work.
IdlError: Type not found: {"type":{"defined":"Tick"}}
You have to use Anchor serialise and deserialise macros
You have to use Anchor serialise and deserialise macros
@anoushk1234 hey where do i have to use them?
#[account]
#[derive(AnchorSerialise, AnchorDeserialise)]
pub struct List {
pub list: Vec<TodoItem>,
}
Here?