mirror of
https://github.com/alexgo-io/gaze-indexer.git
synced 2026-01-12 08:34:28 +08:00
* feat: recover nodesale module. * fix: refactored. * fix: fix table type. * fix: add entity * fix: bug UTC time. * ci: try to tidy before testing * ci: touch result file * ci: use echo to create new file * fix: try to skip test in ci * fix: remove os.Exit * fix: handle error * feat: add todo note * fix: Cannot run nodesale test because qtx is not initiated. * fix: 50% chance public key compare incorrectly. * fix: more consistent SQL * fix: sanity refactor. * fix: remove unused code. * fix: move last_block_default to config file. * fix: minor mistakes. * fix: * fix: refactor * fix: refactor * fix: delegate tx hash not record into db. * refactor: prepare for moving integration tests. * refactor: convert to unit tests. * fix: change to using input values since output values deducted fee. * feat: add extra unit test. * fix: wrong timestamp format. * fix: handle block timeout = 0 --------- Co-authored-by: Gaze <gazenw@users.noreply.github.com>
93 lines
2.2 KiB
Go
93 lines
2.2 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.26.0
|
|
// source: nodesales.sql
|
|
|
|
package gen
|
|
|
|
import (
|
|
"context"
|
|
|
|
"github.com/jackc/pgx/v5/pgtype"
|
|
)
|
|
|
|
const createNodeSale = `-- name: CreateNodeSale :exec
|
|
INSERT INTO node_sales ("block_height", "tx_index", "name", "starts_at", "ends_at", "tiers", "seller_public_key", "max_per_address", "deploy_tx_hash", "max_discount_percentage", "seller_wallet")
|
|
VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11)
|
|
`
|
|
|
|
type CreateNodeSaleParams struct {
|
|
BlockHeight int64
|
|
TxIndex int32
|
|
Name string
|
|
StartsAt pgtype.Timestamp
|
|
EndsAt pgtype.Timestamp
|
|
Tiers [][]byte
|
|
SellerPublicKey string
|
|
MaxPerAddress int32
|
|
DeployTxHash string
|
|
MaxDiscountPercentage int32
|
|
SellerWallet string
|
|
}
|
|
|
|
func (q *Queries) CreateNodeSale(ctx context.Context, arg CreateNodeSaleParams) error {
|
|
_, err := q.db.Exec(ctx, createNodeSale,
|
|
arg.BlockHeight,
|
|
arg.TxIndex,
|
|
arg.Name,
|
|
arg.StartsAt,
|
|
arg.EndsAt,
|
|
arg.Tiers,
|
|
arg.SellerPublicKey,
|
|
arg.MaxPerAddress,
|
|
arg.DeployTxHash,
|
|
arg.MaxDiscountPercentage,
|
|
arg.SellerWallet,
|
|
)
|
|
return err
|
|
}
|
|
|
|
const getNodeSale = `-- name: GetNodeSale :many
|
|
SELECT block_height, tx_index, name, starts_at, ends_at, tiers, seller_public_key, max_per_address, deploy_tx_hash, max_discount_percentage, seller_wallet
|
|
FROM node_sales
|
|
WHERE block_height = $1 AND
|
|
tx_index = $2
|
|
`
|
|
|
|
type GetNodeSaleParams struct {
|
|
BlockHeight int64
|
|
TxIndex int32
|
|
}
|
|
|
|
func (q *Queries) GetNodeSale(ctx context.Context, arg GetNodeSaleParams) ([]NodeSale, error) {
|
|
rows, err := q.db.Query(ctx, getNodeSale, arg.BlockHeight, arg.TxIndex)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []NodeSale
|
|
for rows.Next() {
|
|
var i NodeSale
|
|
if err := rows.Scan(
|
|
&i.BlockHeight,
|
|
&i.TxIndex,
|
|
&i.Name,
|
|
&i.StartsAt,
|
|
&i.EndsAt,
|
|
&i.Tiers,
|
|
&i.SellerPublicKey,
|
|
&i.MaxPerAddress,
|
|
&i.DeployTxHash,
|
|
&i.MaxDiscountPercentage,
|
|
&i.SellerWallet,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|