Open rafaelvanoni opened 2 years ago
Just as a follow up for anyone else experiencing this issue: we figured out that the usage is like this:
// create the CancelOrder instruction
cancelInstruction := serum.InstructionCancelOrderByClientIdV2{
ClientID: clientID,
Accounts: &serum.CancelOrderByClientIdV2Accounts{
Market: solana.Meta(marketPk).WRITE(),
Bids: solana.Meta(bidsPk).WRITE(),
Asks: solana.Meta(asksPk).WRITE(),
OpenOrders: solana.Meta(openOrdersPk).WRITE(),
Owner: solana.Meta(ownerPk).SIGNER(),
EventQueue: solana.Meta(eventQueuePk).WRITE(),
},
}
serumInstruction := serum.Instruction{
BaseVariant: bin.BaseVariant{
TypeID: serum.InstructionDefVariant.TypeID("cancel_order_by_client_id_v2"),
Impl: cancelInstruction,
},
Version: serumInstructionVersion,
}
buf := new(bytes.Buffer)
err := bin.NewBinEncoder(buf).Encode(serumInstruction)
if err != nil {
return nil, fmt.Errorf("failed to encode CancelOrder instruction (%w)", err)
}
serumV3Dex, _ := solana.PublicKeyFromBase58("9xQeWvG816bUx9EPjHmaT23yvVM2ZWbrrpZb9PusVFin")
instruction := &solana.GenericInstruction{
AccountValues: []*solana.AccountMeta{
cancelInstruction.Accounts.Market,
cancelInstruction.Accounts.Bids,
cancelInstruction.Accounts.Asks,
cancelInstruction.Accounts.OpenOrders,
cancelInstruction.Accounts.Owner,
cancelInstruction.Accounts.EventQueue,
},
ProgID: serumV3Dex,
DataBytes: buf.Bytes(),
}
Hi folks, I'm trying to write a client that issues CancelOrder transactions and it seems that program hasn't been implemented yet. Is that correct? If so, I'd be happy to propose a PR with it.
To clarify, the problem I'm trying to solve is that I can't create a
solana.NewTransaction()
with aInstructionCancelOrder{}
because the latter doesn't fully implementsolana.Instruction
. It seems that "fully" implementing CancelOrder similarly to what's done inprograms/system/CreateAccount.go
for example, would solve that.