@@ -3,8 +3,6 @@ package transaction
33import (
44 "context"
55
6- indexerpb "github.com/code-payments/code-vm-indexer/generated/indexer/v1"
7-
86 "github.com/code-payments/ocp-server/ocp/common"
97 ocp_data "github.com/code-payments/ocp-server/ocp/data"
108 vm_util "github.com/code-payments/ocp-server/ocp/vm"
@@ -36,8 +34,7 @@ type SwapHandler interface {
3634}
3735
3836type CurrencyCreatorBuySwapHandler struct {
39- data ocp_data.Provider
40- vmIndexerClient indexerpb.IndexerClient
37+ data ocp_data.Provider
4138
4239 buyer * common.Account
4340 temporaryHolder * common.Account
@@ -54,24 +51,22 @@ type CurrencyCreatorBuySwapHandler struct {
5451
5552func NewCurrencyCreatorBuySwapHandler (
5653 data ocp_data.Provider ,
57- vmIndexerClient indexerpb.IndexerClient ,
5854 buyer * common.Account ,
5955 temporaryHolder * common.Account ,
6056 mint * common.Account ,
6157 amount uint64 ,
6258 nonce * common.Account ,
6359) SwapHandler {
6460 return & CurrencyCreatorBuySwapHandler {
65- data : data ,
66- vmIndexerClient : vmIndexerClient ,
61+ data : data ,
6762
6863 buyer : buyer ,
6964 temporaryHolder : temporaryHolder ,
7065 mint : mint ,
7166 amount : amount ,
7267
7368 nonce : nonce ,
74- computeUnitLimit : 300_000 ,
69+ computeUnitLimit : 150_000 ,
7570 computeUnitPrice : 1_000 ,
7671 memoValue : "buy_v0" ,
7772 }
@@ -103,7 +98,12 @@ func (h *CurrencyCreatorBuySwapHandler) MakeInstructions(ctx context.Context) ([
10398 return nil , err
10499 }
105100
106- h .memoryAccount , h .memoryIndex , err = vm_util .GetVirtualTimelockAccountLocationInMemory (ctx , h .vmIndexerClient , destinationVmConfig .Vm , h .buyer )
101+ destinationTimelockAccounts , err := h .buyer .GetTimelockAccounts (destinationVmConfig )
102+ if err != nil {
103+ return nil , err
104+ }
105+
106+ h .memoryAccount , h .memoryIndex , err = vm_util .GetVirtualTimelockAccountLocationInMemory (ctx , h .data , destinationTimelockAccounts .Vault )
107107 if err != nil {
108108 return nil , err
109109 }
@@ -203,8 +203,7 @@ func (h *CurrencyCreatorBuySwapHandler) MakeInstructions(ctx context.Context) ([
203203}
204204
205205type CurrencyCreatorSellSwapHandler struct {
206- data ocp_data.Provider
207- vmIndexerClient indexerpb.IndexerClient
206+ data ocp_data.Provider
208207
209208 seller * common.Account
210209 temporaryHolder * common.Account
@@ -221,24 +220,22 @@ type CurrencyCreatorSellSwapHandler struct {
221220
222221func NewCurrencyCreatorSellSwapHandler (
223222 data ocp_data.Provider ,
224- vmIndexerClient indexerpb.IndexerClient ,
225223 seller * common.Account ,
226224 temporaryHolder * common.Account ,
227225 mint * common.Account ,
228226 amount uint64 ,
229227 nonce * common.Account ,
230228) SwapHandler {
231229 return & CurrencyCreatorSellSwapHandler {
232- data : data ,
233- vmIndexerClient : vmIndexerClient ,
230+ data : data ,
234231
235232 seller : seller ,
236233 temporaryHolder : temporaryHolder ,
237234 mint : mint ,
238235 amount : amount ,
239236
240237 nonce : nonce ,
241- computeUnitLimit : 300_000 ,
238+ computeUnitLimit : 175_000 ,
242239 computeUnitPrice : 1_000 ,
243240 memoValue : "sell_v0" ,
244241 }
@@ -280,7 +277,12 @@ func (h *CurrencyCreatorSellSwapHandler) MakeInstructions(ctx context.Context) (
280277 return nil , err
281278 }
282279
283- h .memoryAccount , h .memoryIndex , err = vm_util .GetVirtualTimelockAccountLocationInMemory (ctx , h .vmIndexerClient , destinationVmConfig .Vm , h .seller )
280+ destinationTimelockAccounts , err := h .seller .GetTimelockAccounts (destinationVmConfig )
281+ if err != nil {
282+ return nil , err
283+ }
284+
285+ h .memoryAccount , h .memoryIndex , err = vm_util .GetVirtualTimelockAccountLocationInMemory (ctx , h .data , destinationTimelockAccounts .Vault )
284286 if err != nil {
285287 return nil , err
286288 }
@@ -370,8 +372,7 @@ func (h *CurrencyCreatorSellSwapHandler) MakeInstructions(ctx context.Context) (
370372}
371373
372374type CurrencyCreatorBuySellSwapHandler struct {
373- data ocp_data.Provider
374- vmIndexerClient indexerpb.IndexerClient
375+ data ocp_data.Provider
375376
376377 swapper * common.Account
377378 temporaryHolder * common.Account
@@ -389,7 +390,6 @@ type CurrencyCreatorBuySellSwapHandler struct {
389390
390391func NewCurrencyCreatorBuySellSwapHandler (
391392 data ocp_data.Provider ,
392- vmIndexerClient indexerpb.IndexerClient ,
393393 swapper * common.Account ,
394394 temporaryHolder * common.Account ,
395395 fromMint * common.Account ,
@@ -398,8 +398,7 @@ func NewCurrencyCreatorBuySellSwapHandler(
398398 nonce * common.Account ,
399399) SwapHandler {
400400 return & CurrencyCreatorBuySellSwapHandler {
401- data : data ,
402- vmIndexerClient : vmIndexerClient ,
401+ data : data ,
403402
404403 swapper : swapper ,
405404 temporaryHolder : temporaryHolder ,
@@ -450,7 +449,12 @@ func (h *CurrencyCreatorBuySellSwapHandler) MakeInstructions(ctx context.Context
450449 return nil , err
451450 }
452451
453- h .memoryAccount , h .memoryIndex , err = vm_util .GetVirtualTimelockAccountLocationInMemory (ctx , h .vmIndexerClient , destinationVmConfig .Vm , h .swapper )
452+ destinationTimelockAccounts , err := h .swapper .GetTimelockAccounts (destinationVmConfig )
453+ if err != nil {
454+ return nil , err
455+ }
456+
457+ h .memoryAccount , h .memoryIndex , err = vm_util .GetVirtualTimelockAccountLocationInMemory (ctx , h .data , destinationTimelockAccounts .Vault )
454458 if err != nil {
455459 return nil , err
456460 }
0 commit comments