say i have a PDA
struct Foo {
created_at: i64
}
with a created_at
unix sec timestamp field (ex: 1690004000
). I want to filter all PDAs that were created in 1690000000
. as far as i know ints are store in bs58 encoded little endian, which the bs58 encoding kind of ruins things. I tried doing
const bytes = anchor.utils.bytes.bs58.encode(new anchor.BN(1690000000).toBuffer("le", 8)).slice(0, 4)
const accts = await program
.account.foo.all(
[
{
memcmp: {
offset: 8,
bytes,
}
}
]
)
but got nothing. is there a way to go about doing this or will i need to store the time epoch (1690000000
) as a separate field in the PDA and do an exact filter?