Skip to content
Open
5 changes: 4 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ func runServer(cfg *config.Config) error {

// Flow client
// TODO: WithInsecure()?
flowClient, err := client.New(cfg.AccessAPIHost, grpc.WithInsecure())
maxSize := 1024 * 1024 * 64
flowClient, err := client.New(cfg.AccessAPIHost, grpc.WithInsecure(),
grpc.WithDefaultCallOptions(grpc.MaxCallRecvMsgSize(maxSize)),
)
if err != nil {
return err
}
Expand Down
17 changes: 12 additions & 5 deletions service/app/contract_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -754,7 +754,8 @@ func (svc *ContractService) UpdateMintingStatus(ctx context.Context, db *gorm.DB
// Set the FlowID of the pack
// Make sure the pack is in correct state
if err := pack.Seal(packFlowID); err != nil {
return err // rollback
logger.Warn(fmt.Sprintf("pack in wrong state %s packFlowId:%+v", err, packFlowID))
continue
}

// Update the pack in database
Expand Down Expand Up @@ -910,14 +911,17 @@ func (svc *ContractService) UpdateCirculatingPackContract(ctx context.Context, d
"packFlowID": pack.FlowID,
})

eventLogger.Info("handling event...")

switch eventName {
// -- REVEAL_REQUEST, Owner has requested to reveal a pack ------------
case REVEAL_REQUEST:

// Make sure the pack is in correct state
if err := pack.RevealRequestHandled(); err != nil {
err := fmt.Errorf("error while handling %s: %w", eventName, err)
return err // rollback
eventLogger.Warn(fmt.Sprintf("distID:%s distFlowID:%s packID:%s packFlowID:%s err:%s", distribution.ID, distribution.FlowID, pack.ID, pack.FlowID, err.Error()))
continue
}

// Update the pack in database
Expand Down Expand Up @@ -1006,7 +1010,8 @@ func (svc *ContractService) UpdateCirculatingPackContract(ctx context.Context, d
// Make sure the pack is in correct state
if err := pack.Reveal(); err != nil {
err := fmt.Errorf("error while handling %s: %w", eventName, err)
return err // rollback
eventLogger.Warn(fmt.Sprintf("distID:%s distFlowID:%s packID:%s packFlowID:%s err:%s", distribution.ID, distribution.FlowID, pack.ID, pack.FlowID, err.Error()))
continue
}

// Update the pack in database
Expand All @@ -1020,7 +1025,8 @@ func (svc *ContractService) UpdateCirculatingPackContract(ctx context.Context, d
// Make sure the pack is in correct state
if err := pack.OpenRequestHandled(); err != nil {
err := fmt.Errorf("error while handling %s: %w", eventName, err)
return err // rollback
eventLogger.Warn(fmt.Sprintf("distID:%s distFlowID:%s packID:%s packFlowID:%s err:%s", distribution.ID, distribution.FlowID, pack.ID, pack.FlowID, err.Error()))
continue
}

// Update the pack in database
Expand Down Expand Up @@ -1088,7 +1094,8 @@ func (svc *ContractService) UpdateCirculatingPackContract(ctx context.Context, d
// Make sure the pack is in correct state
if err := pack.Open(); err != nil {
err := fmt.Errorf("error while handling %s: %w", eventName, err)
return err // rollback
eventLogger.Warn(fmt.Sprintf("distID:%s distFlowID:%s packID:%s packFlowID:%s err:%s", distribution.ID, distribution.FlowID, pack.ID, pack.FlowID, err.Error()))
continue
}

// Update the pack in database
Expand Down