Skip to content
This repository was archived by the owner on Jun 22, 2023. It is now read-only.

Commit 1b8cc84

Browse files
committed
tempo hack to write operation results as json, not rq gif
1 parent 9f05129 commit 1b8cc84

File tree

3 files changed

+15
-6
lines changed

3 files changed

+15
-6
lines changed

client/client.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -512,9 +512,9 @@ func (c *BaseClient) GetOperationQRPath(operationID string) (string, error) {
512512
return "", fmt.Errorf("failed to get operation in JSON: %w", err)
513513
}
514514

515-
operationQRPath := filepath.Join(QrCodesDir, fmt.Sprintf("dc4bc_qr_%s", operationID))
515+
operationQRPath := filepath.Join(QrCodesDir, fmt.Sprintf("dc4bc_json_%s", operationID))
516516

517-
qrPath := fmt.Sprintf("%s.gif", operationQRPath)
517+
qrPath := fmt.Sprintf("%s.json", operationQRPath)
518518
if err = c.qrProcessor.WriteQR(qrPath, operationJSON); err != nil {
519519
return "", err
520520
}

cmd/dc4bc_cli/main.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"encoding/hex"
1010
"encoding/json"
1111
"fmt"
12-
"github.com/lidofinance/dc4bc/client/types"
1312
"io/ioutil"
1413
"log"
1514
"net/http"
@@ -20,6 +19,7 @@ import (
2019
"strings"
2120
"time"
2221

22+
"github.com/lidofinance/dc4bc/client/types"
2323
"github.com/lidofinance/dc4bc/fsm/state_machines"
2424

2525
"github.com/lidofinance/dc4bc/fsm/fsm"
@@ -388,16 +388,16 @@ func getOperationQRPathCommand() *cobra.Command {
388388
return fmt.Errorf("failed to get operations: %s", operation.ErrorMessage)
389389
}
390390

391-
operationQRPath := filepath.Join(qrCodeFolder, fmt.Sprintf("dc4bc_qr_%s-request", operationID))
391+
operationQRPath := filepath.Join(qrCodeFolder, fmt.Sprintf("dc4bc_json_%s-request", operationID))
392392

393-
qrPath := fmt.Sprintf("%s.gif", operationQRPath)
393+
qrPath := fmt.Sprintf("%s.json", operationQRPath)
394394

395395
processor := qr.NewCameraProcessor()
396396
processor.SetChunkSize(chunkSize)
397397
processor.SetDelay(framesDelay)
398398

399399
if err = processor.WriteQR(qrPath, operation.Result); err != nil {
400-
return fmt.Errorf("failed to save QR gif: %w", err)
400+
return fmt.Errorf("failed to save json: %w", err)
401401
}
402402

403403
fmt.Printf("QR code was saved to: %s\n", qrPath)

qr/qr.go

+9
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import (
1010
"image/draw"
1111
"image/gif"
1212
"io"
13+
"io/ioutil"
1314
"os"
1415

1516
encoder "github.com/skip2/go-qrcode"
@@ -71,6 +72,14 @@ func (p *CameraProcessor) SetRecoveryLevel(recoveryLevel encoder.RecoveryLevel)
7172
}
7273

7374
func (p *CameraProcessor) WriteQR(path string, data []byte) error {
75+
err := ioutil.WriteFile(path, data, 0644)
76+
if err != nil {
77+
return fmt.Errorf("failed to write json: %w", err)
78+
}
79+
return nil
80+
}
81+
82+
func (p *CameraProcessor) WriteQR_(path string, data []byte) error {
7483
chunks, err := DataToChunks(data, p.chunkSize)
7584
if err != nil {
7685
return fmt.Errorf("failed to divide data on chunks: %w", err)

0 commit comments

Comments
 (0)