Skip to content

Commit 9ef8fd4

Browse files
committed
Error handling fixes
1 parent 4272d6a commit 9ef8fd4

4 files changed

Lines changed: 12 additions & 3 deletions

File tree

ocp/rpc/transaction/swap_handler.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -774,12 +774,18 @@ func (h *ReserveCreateAndBuySwapHandler) MakeInstructions(ctx context.Context) (
774774
h.buyer.PublicKey().ToBytes(),
775775
common.CoreMintAccount.PublicKey().ToBytes(),
776776
)
777+
if err != nil {
778+
return nil, err
779+
}
777780

778781
createVmDepositAtaIxn, _, err := token.CreateAssociatedTokenAccountIdempotent(
779782
h.destinationCurrencyAccounts.Authority.PublicKey().ToBytes(),
780783
buyerVmDepositAccounts.Pda.PublicKey().ToBytes(),
781784
h.destinationCurrencyAccounts.Mint.PublicKey().ToBytes(),
782785
)
786+
if err != nil {
787+
return nil, err
788+
}
783789

784790
closeTemporaryCoreMintAta := token.CloseAccount(
785791
temporaryCoreMintAta,

ocp/worker/currency/launcher/util.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -495,6 +495,9 @@ func (p *runtime) initRemainingBlockchainAccounts(ctx context.Context, currencyM
495495
common.GetSubsidizer().PublicKey().ToBytes(),
496496
accounts.Mint.PublicKey().ToBytes(),
497497
)
498+
if err != nil {
499+
return errors.Wrap(err, "error creating init fee ata ixn")
500+
}
498501

499502
initAltIxn := address_lookup_table.Create(
500503
accounts.Alt.PublicKey().ToBytes(),

ocp/worker/currency/launcher/worker.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ func (p *runtime) handleStateCompletingInitialization(ctx context.Context, curre
175175
return errors.Wrap(err, "error checking if initialization phase 1 is complete")
176176
} else if !ok {
177177
// todo: How do we recover from this?
178-
return errors.Wrap(err, "initialization phase 1 did not happen")
178+
return errors.New("initialization phase 1 did not happen")
179179
}
180180

181181
//
@@ -292,7 +292,7 @@ func (p *runtime) handleStateFinalValidation(ctx context.Context, currencyMetada
292292
if err != nil {
293293
return errors.Wrap(err, "error validating liquidity pool exists")
294294
} else if !ok {
295-
return errors.New("")
295+
return errors.New("liquidity pool doesn't exist")
296296
}
297297

298298
ok, err = validateVmExists(ctx, p.data, accounts.Vm)

ocp/worker/swap/util.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func (p *runtime) maybeUpdateBalancesForFinalizedSwap(ctx context.Context, swapR
194194

195195
deltaQuarksOutOfVault, err := transaction_util.GetDeltaQuarksFromTokenBalances(currencyAccounts.VaultMint, tokenBalances)
196196
if err != nil {
197-
return 0, false, nil
197+
return 0, false, err
198198
}
199199

200200
if deltaQuarksOutOfVault >= 0 {

0 commit comments

Comments
 (0)