46 lines
1.6 KiB
Go
46 lines
1.6 KiB
Go
package pump_parser
|
|
|
|
import (
|
|
"encoding/binary"
|
|
"encoding/hex"
|
|
"fmt"
|
|
"testing"
|
|
|
|
agbinary "github.com/gagliardetto/binary"
|
|
"github.com/gagliardetto/solana-go"
|
|
"github.com/mr-tron/base58"
|
|
)
|
|
|
|
func TestTradeEvent(t *testing.T) {
|
|
hexData := "e445a52e51cb9a1dbddb7fd34ee661ee051d1834b36cc6f04cc5bd998d53ab2a566a0ca2415bcfad5f9ed6941a851d3f84ecb200000000006c267d17170000000190d2c525ef0ea205f4b4abfdb6eaaf37fcb5a1b1dec2e2689448eecab6ba93b6c922246900000000c314f11a0d000000be71bf9e22080200c368cd1e06000000bed9ac52910901004ac2f8d0dd5cbc97e3289c197cb5062a54f3d956b9ce6e5115f96567aa5cb3e65f000000000000002c6a010000000000c9e17c171227a50a5b62e3a4a3f8ff4fafe0bca9c332bdf7f32eedbc4229604d1e000000000000005f72000000000000010000000000000000000000000000000000000000000000000000000000000000100000006275795f65786163745f736f6c5f696e"
|
|
d, err := hex.DecodeString(hexData)
|
|
if err != nil {
|
|
t.Errorf("Failed to decode base64 data: %v", err)
|
|
}
|
|
|
|
var tradeEvent PumpTradeEvent
|
|
|
|
err = agbinary.NewBorshDecoder(d[16:]).Decode(&tradeEvent)
|
|
if err != nil {
|
|
t.Errorf("Failed to deserialize trade event: %v", err)
|
|
}
|
|
|
|
t.Logf("Trade Event: %+v", tradeEvent)
|
|
|
|
xx, err := base58.Decode("3Bxs48EzTZB4tzRd")
|
|
fmt.Println(len(xx), err)
|
|
|
|
}
|
|
func TestCal(t *testing.T) {
|
|
//e445a52e51cb9a1db94afc7d1bd7bc6f5e99e54b
|
|
// . b94afc7d1bd7bc6f
|
|
s := calculateDiscriminator("global:initialize_with_permission")
|
|
fmt.Println(hex.EncodeToString(s[:]))
|
|
|
|
s2, _ := base58.Decode("6ApXSNCamGdm")
|
|
s3 := binary.LittleEndian.Uint64(s2[1:])
|
|
fmt.Println(s2, s3)
|
|
|
|
fmt.Println(solana.MustPublicKeyFromBase58("BM9CcyErJcu2mjrFvUsRRrD3snGeHDDVirJLvL6EjvMN").IsOnCurve())
|
|
}
|