mirror of
https://github.com/cf-sonr/dbx.git
synced 2026-01-11 18:58:54 +00:00
2584 lines
80 KiB
Go
2584 lines
80 KiB
Go
// Code generated by sqlc. DO NOT EDIT.
|
|
// versions:
|
|
// sqlc v1.28.0
|
|
// source: query.sql
|
|
|
|
package network
|
|
|
|
import (
|
|
"context"
|
|
"database/sql"
|
|
"time"
|
|
)
|
|
|
|
const countBlockchainsByChainType = `-- name: CountBlockchainsByChainType :one
|
|
SELECT COUNT(*) as count FROM blockchains
|
|
WHERE chain_type LIKE '%' || ? || '%' AND deleted_at IS NULL
|
|
`
|
|
|
|
func (q *Queries) CountBlockchainsByChainType(ctx context.Context, dollar_1 sql.NullString) (int64, error) {
|
|
row := q.db.QueryRowContext(ctx, countBlockchainsByChainType, dollar_1)
|
|
var count int64
|
|
err := row.Scan(&count)
|
|
return count, err
|
|
}
|
|
|
|
const getAssetByChainAndSymbol = `-- name: GetAssetByChainAndSymbol :one
|
|
SELECT id, created_at, updated_at, deleted_at, name, symbol, decimals, chain_id, channel, asset_type, coingecko_id FROM assets
|
|
WHERE chain_id = ? AND symbol = ? AND deleted_at IS NULL
|
|
LIMIT 1
|
|
`
|
|
|
|
type GetAssetByChainAndSymbolParams struct {
|
|
ChainID string `json:"chain_id"`
|
|
Symbol string `json:"symbol"`
|
|
}
|
|
|
|
func (q *Queries) GetAssetByChainAndSymbol(ctx context.Context, arg GetAssetByChainAndSymbolParams) (Asset, error) {
|
|
row := q.db.QueryRowContext(ctx, getAssetByChainAndSymbol, arg.ChainID, arg.Symbol)
|
|
var i Asset
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.Name,
|
|
&i.Symbol,
|
|
&i.Decimals,
|
|
&i.ChainID,
|
|
&i.Channel,
|
|
&i.AssetType,
|
|
&i.CoingeckoID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getAssetByID = `-- name: GetAssetByID :one
|
|
SELECT id, created_at, updated_at, deleted_at, name, symbol, decimals, chain_id, channel, asset_type, coingecko_id FROM assets
|
|
WHERE id = ? AND deleted_at IS NULL
|
|
LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetAssetByID(ctx context.Context, id string) (Asset, error) {
|
|
row := q.db.QueryRowContext(ctx, getAssetByID, id)
|
|
var i Asset
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.Name,
|
|
&i.Symbol,
|
|
&i.Decimals,
|
|
&i.ChainID,
|
|
&i.Channel,
|
|
&i.AssetType,
|
|
&i.CoingeckoID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getAssetBySymbol = `-- name: GetAssetBySymbol :one
|
|
SELECT id, created_at, updated_at, deleted_at, name, symbol, decimals, chain_id, channel, asset_type, coingecko_id FROM assets
|
|
WHERE symbol = ? AND deleted_at IS NULL
|
|
LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetAssetBySymbol(ctx context.Context, symbol string) (Asset, error) {
|
|
row := q.db.QueryRowContext(ctx, getAssetBySymbol, symbol)
|
|
var i Asset
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.Name,
|
|
&i.Symbol,
|
|
&i.Decimals,
|
|
&i.ChainID,
|
|
&i.Channel,
|
|
&i.AssetType,
|
|
&i.CoingeckoID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getAssetWithLatestPrice = `-- name: GetAssetWithLatestPrice :one
|
|
SELECT a.id, a.created_at, a.updated_at, a.deleted_at, a.name, a.symbol, a.decimals, a.chain_id, a.channel, a.asset_type, a.coingecko_id, p.price_usd, p.price_btc, p.volume_24h_usd, p.market_cap_usd,
|
|
p.available_supply, p.total_supply, p.max_supply,
|
|
p.percent_change_1h, p.percent_change_24h, p.percent_change_7d,
|
|
p.rank, p.last_updated
|
|
FROM assets a
|
|
LEFT JOIN (
|
|
SELECT p1.id, p1.created_at, p1.updated_at, p1.deleted_at, p1.asset_id, p1.price_usd, p1.price_btc, p1.volume_24h_usd, p1.market_cap_usd, p1.available_supply, p1.total_supply, p1.max_supply, p1.percent_change_1h, p1.percent_change_24h, p1.percent_change_7d, p1.rank, p1.last_updated
|
|
FROM prices p1
|
|
INNER JOIN (
|
|
SELECT asset_id, MAX(last_updated) as max_date
|
|
FROM prices
|
|
WHERE deleted_at IS NULL
|
|
GROUP BY asset_id
|
|
) p2 ON p1.asset_id = p2.asset_id AND p1.last_updated = p2.max_date
|
|
WHERE p1.deleted_at IS NULL
|
|
) p ON a.id = p.asset_id
|
|
WHERE a.id = ? AND a.deleted_at IS NULL
|
|
LIMIT 1
|
|
`
|
|
|
|
type GetAssetWithLatestPriceRow struct {
|
|
ID string `json:"id"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DeletedAt sql.NullTime `json:"deleted_at"`
|
|
Name string `json:"name"`
|
|
Symbol string `json:"symbol"`
|
|
Decimals int64 `json:"decimals"`
|
|
ChainID string `json:"chain_id"`
|
|
Channel string `json:"channel"`
|
|
AssetType string `json:"asset_type"`
|
|
CoingeckoID sql.NullString `json:"coingecko_id"`
|
|
PriceUsd sql.NullFloat64 `json:"price_usd"`
|
|
PriceBtc sql.NullFloat64 `json:"price_btc"`
|
|
Volume24hUsd sql.NullFloat64 `json:"volume_24h_usd"`
|
|
MarketCapUsd sql.NullFloat64 `json:"market_cap_usd"`
|
|
AvailableSupply sql.NullFloat64 `json:"available_supply"`
|
|
TotalSupply sql.NullFloat64 `json:"total_supply"`
|
|
MaxSupply sql.NullFloat64 `json:"max_supply"`
|
|
PercentChange1h sql.NullFloat64 `json:"percent_change_1h"`
|
|
PercentChange24h sql.NullFloat64 `json:"percent_change_24h"`
|
|
PercentChange7d sql.NullFloat64 `json:"percent_change_7d"`
|
|
Rank sql.NullInt64 `json:"rank"`
|
|
LastUpdated time.Time `json:"last_updated"`
|
|
}
|
|
|
|
func (q *Queries) GetAssetWithLatestPrice(ctx context.Context, id string) (GetAssetWithLatestPriceRow, error) {
|
|
row := q.db.QueryRowContext(ctx, getAssetWithLatestPrice, id)
|
|
var i GetAssetWithLatestPriceRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.Name,
|
|
&i.Symbol,
|
|
&i.Decimals,
|
|
&i.ChainID,
|
|
&i.Channel,
|
|
&i.AssetType,
|
|
&i.CoingeckoID,
|
|
&i.PriceUsd,
|
|
&i.PriceBtc,
|
|
&i.Volume24hUsd,
|
|
&i.MarketCapUsd,
|
|
&i.AvailableSupply,
|
|
&i.TotalSupply,
|
|
&i.MaxSupply,
|
|
&i.PercentChange1h,
|
|
&i.PercentChange24h,
|
|
&i.PercentChange7d,
|
|
&i.Rank,
|
|
&i.LastUpdated,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getBlockchainByChainName = `-- name: GetBlockchainByChainName :one
|
|
SELECT id, created_at, updated_at, deleted_at, chain_name, chain_id_cosmos, chain_id_evm, api_name, bech_account_prefix, bech_validator_prefix, main_asset_symbol, main_asset_denom, staking_asset_symbol, staking_asset_denom, is_stake_enabled, chain_image, main_asset_image, staking_asset_image, chain_type, is_support_mobile_wallet, is_support_extension_wallet, is_support_erc20, description_en, description_ko, description_ja, origin_genesis_time, account_type, btc_staking, cosmos_fee_info, evm_fee_info, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint, explorer, about, forum FROM blockchains
|
|
WHERE chain_name = ? AND deleted_at IS NULL
|
|
LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetBlockchainByChainName(ctx context.Context, chainName string) (Blockchain, error) {
|
|
row := q.db.QueryRowContext(ctx, getBlockchainByChainName, chainName)
|
|
var i Blockchain
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getBlockchainByCosmosChainID = `-- name: GetBlockchainByCosmosChainID :one
|
|
SELECT id, created_at, updated_at, deleted_at, chain_name, chain_id_cosmos, chain_id_evm, api_name, bech_account_prefix, bech_validator_prefix, main_asset_symbol, main_asset_denom, staking_asset_symbol, staking_asset_denom, is_stake_enabled, chain_image, main_asset_image, staking_asset_image, chain_type, is_support_mobile_wallet, is_support_extension_wallet, is_support_erc20, description_en, description_ko, description_ja, origin_genesis_time, account_type, btc_staking, cosmos_fee_info, evm_fee_info, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint, explorer, about, forum FROM blockchains
|
|
WHERE chain_id_cosmos = ? AND deleted_at IS NULL
|
|
LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetBlockchainByCosmosChainID(ctx context.Context, chainIDCosmos sql.NullString) (Blockchain, error) {
|
|
row := q.db.QueryRowContext(ctx, getBlockchainByCosmosChainID, chainIDCosmos)
|
|
var i Blockchain
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getBlockchainByEvmChainID = `-- name: GetBlockchainByEvmChainID :one
|
|
SELECT id, created_at, updated_at, deleted_at, chain_name, chain_id_cosmos, chain_id_evm, api_name, bech_account_prefix, bech_validator_prefix, main_asset_symbol, main_asset_denom, staking_asset_symbol, staking_asset_denom, is_stake_enabled, chain_image, main_asset_image, staking_asset_image, chain_type, is_support_mobile_wallet, is_support_extension_wallet, is_support_erc20, description_en, description_ko, description_ja, origin_genesis_time, account_type, btc_staking, cosmos_fee_info, evm_fee_info, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint, explorer, about, forum FROM blockchains
|
|
WHERE chain_id_evm = ? AND deleted_at IS NULL
|
|
LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetBlockchainByEvmChainID(ctx context.Context, chainIDEvm sql.NullString) (Blockchain, error) {
|
|
row := q.db.QueryRowContext(ctx, getBlockchainByEvmChainID, chainIDEvm)
|
|
var i Blockchain
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getBlockchainByID = `-- name: GetBlockchainByID :one
|
|
SELECT id, created_at, updated_at, deleted_at, chain_name, chain_id_cosmos, chain_id_evm, api_name, bech_account_prefix, bech_validator_prefix, main_asset_symbol, main_asset_denom, staking_asset_symbol, staking_asset_denom, is_stake_enabled, chain_image, main_asset_image, staking_asset_image, chain_type, is_support_mobile_wallet, is_support_extension_wallet, is_support_erc20, description_en, description_ko, description_ja, origin_genesis_time, account_type, btc_staking, cosmos_fee_info, evm_fee_info, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint, explorer, about, forum FROM blockchains
|
|
WHERE id = ? AND deleted_at IS NULL
|
|
LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetBlockchainByID(ctx context.Context, id string) (Blockchain, error) {
|
|
row := q.db.QueryRowContext(ctx, getBlockchainByID, id)
|
|
var i Blockchain
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getBlockchainEndpoints = `-- name: GetBlockchainEndpoints :one
|
|
SELECT id, chain_name, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint
|
|
FROM blockchains
|
|
WHERE id = ? AND deleted_at IS NULL
|
|
LIMIT 1
|
|
`
|
|
|
|
type GetBlockchainEndpointsRow struct {
|
|
ID string `json:"id"`
|
|
ChainName string `json:"chain_name"`
|
|
LcdEndpoint sql.NullString `json:"lcd_endpoint"`
|
|
GrpcEndpoint sql.NullString `json:"grpc_endpoint"`
|
|
EvmRpcEndpoint sql.NullString `json:"evm_rpc_endpoint"`
|
|
}
|
|
|
|
func (q *Queries) GetBlockchainEndpoints(ctx context.Context, id string) (GetBlockchainEndpointsRow, error) {
|
|
row := q.db.QueryRowContext(ctx, getBlockchainEndpoints, id)
|
|
var i GetBlockchainEndpointsRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.ChainName,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getBlockchainExplorer = `-- name: GetBlockchainExplorer :one
|
|
SELECT id, chain_name, explorer
|
|
FROM blockchains
|
|
WHERE id = ? AND deleted_at IS NULL
|
|
LIMIT 1
|
|
`
|
|
|
|
type GetBlockchainExplorerRow struct {
|
|
ID string `json:"id"`
|
|
ChainName string `json:"chain_name"`
|
|
Explorer sql.NullString `json:"explorer"`
|
|
}
|
|
|
|
func (q *Queries) GetBlockchainExplorer(ctx context.Context, id string) (GetBlockchainExplorerRow, error) {
|
|
row := q.db.QueryRowContext(ctx, getBlockchainExplorer, id)
|
|
var i GetBlockchainExplorerRow
|
|
err := row.Scan(&i.ID, &i.ChainName, &i.Explorer)
|
|
return i, err
|
|
}
|
|
|
|
const getBlockchainWithAssetInfo = `-- name: GetBlockchainWithAssetInfo :one
|
|
SELECT b.id, b.created_at, b.updated_at, b.deleted_at, b.chain_name, b.chain_id_cosmos, b.chain_id_evm, b.api_name, b.bech_account_prefix, b.bech_validator_prefix, b.main_asset_symbol, b.main_asset_denom, b.staking_asset_symbol, b.staking_asset_denom, b.is_stake_enabled, b.chain_image, b.main_asset_image, b.staking_asset_image, b.chain_type, b.is_support_mobile_wallet, b.is_support_extension_wallet, b.is_support_erc20, b.description_en, b.description_ko, b.description_ja, b.origin_genesis_time, b.account_type, b.btc_staking, b.cosmos_fee_info, b.evm_fee_info, b.lcd_endpoint, b.grpc_endpoint, b.evm_rpc_endpoint, b.explorer, b.about, b.forum, a.id as asset_id, a.symbol, a.decimals, p.price_usd, p.price_btc
|
|
FROM blockchains b
|
|
LEFT JOIN assets a ON b.main_asset_symbol = a.symbol
|
|
LEFT JOIN (
|
|
SELECT p1.id, p1.created_at, p1.updated_at, p1.deleted_at, p1.asset_id, p1.price_usd, p1.price_btc, p1.volume_24h_usd, p1.market_cap_usd, p1.available_supply, p1.total_supply, p1.max_supply, p1.percent_change_1h, p1.percent_change_24h, p1.percent_change_7d, p1.rank, p1.last_updated
|
|
FROM prices p1
|
|
INNER JOIN (
|
|
SELECT asset_id, MAX(last_updated) as max_date
|
|
FROM prices
|
|
WHERE deleted_at IS NULL
|
|
GROUP BY asset_id
|
|
) p2 ON p1.asset_id = p2.asset_id AND p1.last_updated = p2.max_date
|
|
WHERE p1.deleted_at IS NULL
|
|
) p ON a.id = p.asset_id
|
|
WHERE b.id = ? AND b.deleted_at IS NULL
|
|
LIMIT 1
|
|
`
|
|
|
|
type GetBlockchainWithAssetInfoRow struct {
|
|
ID string `json:"id"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DeletedAt sql.NullTime `json:"deleted_at"`
|
|
ChainName string `json:"chain_name"`
|
|
ChainIDCosmos sql.NullString `json:"chain_id_cosmos"`
|
|
ChainIDEvm sql.NullString `json:"chain_id_evm"`
|
|
ApiName sql.NullString `json:"api_name"`
|
|
BechAccountPrefix sql.NullString `json:"bech_account_prefix"`
|
|
BechValidatorPrefix sql.NullString `json:"bech_validator_prefix"`
|
|
MainAssetSymbol sql.NullString `json:"main_asset_symbol"`
|
|
MainAssetDenom sql.NullString `json:"main_asset_denom"`
|
|
StakingAssetSymbol sql.NullString `json:"staking_asset_symbol"`
|
|
StakingAssetDenom sql.NullString `json:"staking_asset_denom"`
|
|
IsStakeEnabled bool `json:"is_stake_enabled"`
|
|
ChainImage sql.NullString `json:"chain_image"`
|
|
MainAssetImage sql.NullString `json:"main_asset_image"`
|
|
StakingAssetImage sql.NullString `json:"staking_asset_image"`
|
|
ChainType string `json:"chain_type"`
|
|
IsSupportMobileWallet bool `json:"is_support_mobile_wallet"`
|
|
IsSupportExtensionWallet bool `json:"is_support_extension_wallet"`
|
|
IsSupportErc20 bool `json:"is_support_erc20"`
|
|
DescriptionEn sql.NullString `json:"description_en"`
|
|
DescriptionKo sql.NullString `json:"description_ko"`
|
|
DescriptionJa sql.NullString `json:"description_ja"`
|
|
OriginGenesisTime sql.NullTime `json:"origin_genesis_time"`
|
|
AccountType string `json:"account_type"`
|
|
BtcStaking sql.NullString `json:"btc_staking"`
|
|
CosmosFeeInfo sql.NullString `json:"cosmos_fee_info"`
|
|
EvmFeeInfo sql.NullString `json:"evm_fee_info"`
|
|
LcdEndpoint sql.NullString `json:"lcd_endpoint"`
|
|
GrpcEndpoint sql.NullString `json:"grpc_endpoint"`
|
|
EvmRpcEndpoint sql.NullString `json:"evm_rpc_endpoint"`
|
|
Explorer sql.NullString `json:"explorer"`
|
|
About sql.NullString `json:"about"`
|
|
Forum sql.NullString `json:"forum"`
|
|
AssetID sql.NullString `json:"asset_id"`
|
|
Symbol sql.NullString `json:"symbol"`
|
|
Decimals sql.NullInt64 `json:"decimals"`
|
|
PriceUsd sql.NullFloat64 `json:"price_usd"`
|
|
PriceBtc sql.NullFloat64 `json:"price_btc"`
|
|
}
|
|
|
|
func (q *Queries) GetBlockchainWithAssetInfo(ctx context.Context, id string) (GetBlockchainWithAssetInfoRow, error) {
|
|
row := q.db.QueryRowContext(ctx, getBlockchainWithAssetInfo, id)
|
|
var i GetBlockchainWithAssetInfoRow
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
&i.AssetID,
|
|
&i.Symbol,
|
|
&i.Decimals,
|
|
&i.PriceUsd,
|
|
&i.PriceBtc,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getPriceByAssetID = `-- name: GetPriceByAssetID :one
|
|
SELECT id, created_at, updated_at, deleted_at, asset_id, price_usd, price_btc, volume_24h_usd, market_cap_usd, available_supply, total_supply, max_supply, percent_change_1h, percent_change_24h, percent_change_7d, rank, last_updated FROM prices
|
|
WHERE asset_id = ? AND deleted_at IS NULL
|
|
ORDER BY last_updated DESC
|
|
LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetPriceByAssetID(ctx context.Context, assetID string) (Price, error) {
|
|
row := q.db.QueryRowContext(ctx, getPriceByAssetID, assetID)
|
|
var i Price
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.AssetID,
|
|
&i.PriceUsd,
|
|
&i.PriceBtc,
|
|
&i.Volume24hUsd,
|
|
&i.MarketCapUsd,
|
|
&i.AvailableSupply,
|
|
&i.TotalSupply,
|
|
&i.MaxSupply,
|
|
&i.PercentChange1h,
|
|
&i.PercentChange24h,
|
|
&i.PercentChange7d,
|
|
&i.Rank,
|
|
&i.LastUpdated,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getPriceByID = `-- name: GetPriceByID :one
|
|
SELECT id, created_at, updated_at, deleted_at, asset_id, price_usd, price_btc, volume_24h_usd, market_cap_usd, available_supply, total_supply, max_supply, percent_change_1h, percent_change_24h, percent_change_7d, rank, last_updated FROM prices
|
|
WHERE id = ? AND deleted_at IS NULL
|
|
LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetPriceByID(ctx context.Context, id string) (Price, error) {
|
|
row := q.db.QueryRowContext(ctx, getPriceByID, id)
|
|
var i Price
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.AssetID,
|
|
&i.PriceUsd,
|
|
&i.PriceBtc,
|
|
&i.Volume24hUsd,
|
|
&i.MarketCapUsd,
|
|
&i.AvailableSupply,
|
|
&i.TotalSupply,
|
|
&i.MaxSupply,
|
|
&i.PercentChange1h,
|
|
&i.PercentChange24h,
|
|
&i.PercentChange7d,
|
|
&i.Rank,
|
|
&i.LastUpdated,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getPriceConversionByCurrency = `-- name: GetPriceConversionByCurrency :one
|
|
SELECT id, created_at, updated_at, deleted_at, price_id, currency_code, price, volume_24h, market_cap, last_updated FROM price_conversions
|
|
WHERE price_id = ? AND currency_code = ? AND deleted_at IS NULL
|
|
LIMIT 1
|
|
`
|
|
|
|
type GetPriceConversionByCurrencyParams struct {
|
|
PriceID string `json:"price_id"`
|
|
CurrencyCode string `json:"currency_code"`
|
|
}
|
|
|
|
func (q *Queries) GetPriceConversionByCurrency(ctx context.Context, arg GetPriceConversionByCurrencyParams) (PriceConversion, error) {
|
|
row := q.db.QueryRowContext(ctx, getPriceConversionByCurrency, arg.PriceID, arg.CurrencyCode)
|
|
var i PriceConversion
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.PriceID,
|
|
&i.CurrencyCode,
|
|
&i.Price,
|
|
&i.Volume24h,
|
|
&i.MarketCap,
|
|
&i.LastUpdated,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getPriceConversionByID = `-- name: GetPriceConversionByID :one
|
|
SELECT id, created_at, updated_at, deleted_at, price_id, currency_code, price, volume_24h, market_cap, last_updated FROM price_conversions
|
|
WHERE id = ? AND deleted_at IS NULL
|
|
LIMIT 1
|
|
`
|
|
|
|
func (q *Queries) GetPriceConversionByID(ctx context.Context, id string) (PriceConversion, error) {
|
|
row := q.db.QueryRowContext(ctx, getPriceConversionByID, id)
|
|
var i PriceConversion
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.PriceID,
|
|
&i.CurrencyCode,
|
|
&i.Price,
|
|
&i.Volume24h,
|
|
&i.MarketCap,
|
|
&i.LastUpdated,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const getPriceConversionsByPriceID = `-- name: GetPriceConversionsByPriceID :many
|
|
SELECT id, created_at, updated_at, deleted_at, price_id, currency_code, price, volume_24h, market_cap, last_updated FROM price_conversions
|
|
WHERE price_id = ? AND deleted_at IS NULL
|
|
ORDER BY currency_code ASC
|
|
`
|
|
|
|
func (q *Queries) GetPriceConversionsByPriceID(ctx context.Context, priceID string) ([]PriceConversion, error) {
|
|
rows, err := q.db.QueryContext(ctx, getPriceConversionsByPriceID, priceID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []PriceConversion
|
|
for rows.Next() {
|
|
var i PriceConversion
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.PriceID,
|
|
&i.CurrencyCode,
|
|
&i.Price,
|
|
&i.Volume24h,
|
|
&i.MarketCap,
|
|
&i.LastUpdated,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const insertAsset = `-- name: InsertAsset :one
|
|
INSERT INTO assets (
|
|
name,
|
|
symbol,
|
|
decimals,
|
|
chain_id,
|
|
channel,
|
|
asset_type,
|
|
coingecko_id
|
|
) VALUES (?, ?, ?, ?, ?, ?, ?)
|
|
RETURNING id, created_at, updated_at, deleted_at, name, symbol, decimals, chain_id, channel, asset_type, coingecko_id
|
|
`
|
|
|
|
type InsertAssetParams struct {
|
|
Name string `json:"name"`
|
|
Symbol string `json:"symbol"`
|
|
Decimals int64 `json:"decimals"`
|
|
ChainID string `json:"chain_id"`
|
|
Channel string `json:"channel"`
|
|
AssetType string `json:"asset_type"`
|
|
CoingeckoID sql.NullString `json:"coingecko_id"`
|
|
}
|
|
|
|
// ASSET QUERIES
|
|
func (q *Queries) InsertAsset(ctx context.Context, arg InsertAssetParams) (Asset, error) {
|
|
row := q.db.QueryRowContext(ctx, insertAsset,
|
|
arg.Name,
|
|
arg.Symbol,
|
|
arg.Decimals,
|
|
arg.ChainID,
|
|
arg.Channel,
|
|
arg.AssetType,
|
|
arg.CoingeckoID,
|
|
)
|
|
var i Asset
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.Name,
|
|
&i.Symbol,
|
|
&i.Decimals,
|
|
&i.ChainID,
|
|
&i.Channel,
|
|
&i.AssetType,
|
|
&i.CoingeckoID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const insertBlockchain = `-- name: InsertBlockchain :one
|
|
INSERT INTO blockchains (
|
|
id,
|
|
chain_name,
|
|
chain_id_cosmos,
|
|
chain_id_evm,
|
|
api_name,
|
|
bech_account_prefix,
|
|
bech_validator_prefix,
|
|
main_asset_symbol,
|
|
main_asset_denom,
|
|
staking_asset_symbol,
|
|
staking_asset_denom,
|
|
is_stake_enabled,
|
|
chain_image,
|
|
main_asset_image,
|
|
staking_asset_image,
|
|
chain_type,
|
|
is_support_mobile_wallet,
|
|
is_support_extension_wallet,
|
|
is_support_erc20,
|
|
description_en,
|
|
description_ko,
|
|
description_ja,
|
|
origin_genesis_time,
|
|
account_type,
|
|
btc_staking,
|
|
cosmos_fee_info,
|
|
evm_fee_info,
|
|
lcd_endpoint,
|
|
grpc_endpoint,
|
|
evm_rpc_endpoint,
|
|
explorer,
|
|
about,
|
|
forum
|
|
) VALUES (
|
|
?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?
|
|
)
|
|
RETURNING id, created_at, updated_at, deleted_at, chain_name, chain_id_cosmos, chain_id_evm, api_name, bech_account_prefix, bech_validator_prefix, main_asset_symbol, main_asset_denom, staking_asset_symbol, staking_asset_denom, is_stake_enabled, chain_image, main_asset_image, staking_asset_image, chain_type, is_support_mobile_wallet, is_support_extension_wallet, is_support_erc20, description_en, description_ko, description_ja, origin_genesis_time, account_type, btc_staking, cosmos_fee_info, evm_fee_info, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint, explorer, about, forum
|
|
`
|
|
|
|
type InsertBlockchainParams struct {
|
|
ID string `json:"id"`
|
|
ChainName string `json:"chain_name"`
|
|
ChainIDCosmos sql.NullString `json:"chain_id_cosmos"`
|
|
ChainIDEvm sql.NullString `json:"chain_id_evm"`
|
|
ApiName sql.NullString `json:"api_name"`
|
|
BechAccountPrefix sql.NullString `json:"bech_account_prefix"`
|
|
BechValidatorPrefix sql.NullString `json:"bech_validator_prefix"`
|
|
MainAssetSymbol sql.NullString `json:"main_asset_symbol"`
|
|
MainAssetDenom sql.NullString `json:"main_asset_denom"`
|
|
StakingAssetSymbol sql.NullString `json:"staking_asset_symbol"`
|
|
StakingAssetDenom sql.NullString `json:"staking_asset_denom"`
|
|
IsStakeEnabled bool `json:"is_stake_enabled"`
|
|
ChainImage sql.NullString `json:"chain_image"`
|
|
MainAssetImage sql.NullString `json:"main_asset_image"`
|
|
StakingAssetImage sql.NullString `json:"staking_asset_image"`
|
|
ChainType string `json:"chain_type"`
|
|
IsSupportMobileWallet bool `json:"is_support_mobile_wallet"`
|
|
IsSupportExtensionWallet bool `json:"is_support_extension_wallet"`
|
|
IsSupportErc20 bool `json:"is_support_erc20"`
|
|
DescriptionEn sql.NullString `json:"description_en"`
|
|
DescriptionKo sql.NullString `json:"description_ko"`
|
|
DescriptionJa sql.NullString `json:"description_ja"`
|
|
OriginGenesisTime sql.NullTime `json:"origin_genesis_time"`
|
|
AccountType string `json:"account_type"`
|
|
BtcStaking sql.NullString `json:"btc_staking"`
|
|
CosmosFeeInfo sql.NullString `json:"cosmos_fee_info"`
|
|
EvmFeeInfo sql.NullString `json:"evm_fee_info"`
|
|
LcdEndpoint sql.NullString `json:"lcd_endpoint"`
|
|
GrpcEndpoint sql.NullString `json:"grpc_endpoint"`
|
|
EvmRpcEndpoint sql.NullString `json:"evm_rpc_endpoint"`
|
|
Explorer sql.NullString `json:"explorer"`
|
|
About sql.NullString `json:"about"`
|
|
Forum sql.NullString `json:"forum"`
|
|
}
|
|
|
|
// BLOCKCHAIN QUERIES
|
|
func (q *Queries) InsertBlockchain(ctx context.Context, arg InsertBlockchainParams) (Blockchain, error) {
|
|
row := q.db.QueryRowContext(ctx, insertBlockchain,
|
|
arg.ID,
|
|
arg.ChainName,
|
|
arg.ChainIDCosmos,
|
|
arg.ChainIDEvm,
|
|
arg.ApiName,
|
|
arg.BechAccountPrefix,
|
|
arg.BechValidatorPrefix,
|
|
arg.MainAssetSymbol,
|
|
arg.MainAssetDenom,
|
|
arg.StakingAssetSymbol,
|
|
arg.StakingAssetDenom,
|
|
arg.IsStakeEnabled,
|
|
arg.ChainImage,
|
|
arg.MainAssetImage,
|
|
arg.StakingAssetImage,
|
|
arg.ChainType,
|
|
arg.IsSupportMobileWallet,
|
|
arg.IsSupportExtensionWallet,
|
|
arg.IsSupportErc20,
|
|
arg.DescriptionEn,
|
|
arg.DescriptionKo,
|
|
arg.DescriptionJa,
|
|
arg.OriginGenesisTime,
|
|
arg.AccountType,
|
|
arg.BtcStaking,
|
|
arg.CosmosFeeInfo,
|
|
arg.EvmFeeInfo,
|
|
arg.LcdEndpoint,
|
|
arg.GrpcEndpoint,
|
|
arg.EvmRpcEndpoint,
|
|
arg.Explorer,
|
|
arg.About,
|
|
arg.Forum,
|
|
)
|
|
var i Blockchain
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const insertPrice = `-- name: InsertPrice :one
|
|
INSERT INTO prices (
|
|
asset_id,
|
|
price_usd,
|
|
price_btc,
|
|
volume_24h_usd,
|
|
market_cap_usd,
|
|
available_supply,
|
|
total_supply,
|
|
max_supply,
|
|
percent_change_1h,
|
|
percent_change_24h,
|
|
percent_change_7d,
|
|
rank,
|
|
last_updated
|
|
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
RETURNING id, created_at, updated_at, deleted_at, asset_id, price_usd, price_btc, volume_24h_usd, market_cap_usd, available_supply, total_supply, max_supply, percent_change_1h, percent_change_24h, percent_change_7d, rank, last_updated
|
|
`
|
|
|
|
type InsertPriceParams struct {
|
|
AssetID string `json:"asset_id"`
|
|
PriceUsd sql.NullFloat64 `json:"price_usd"`
|
|
PriceBtc sql.NullFloat64 `json:"price_btc"`
|
|
Volume24hUsd sql.NullFloat64 `json:"volume_24h_usd"`
|
|
MarketCapUsd sql.NullFloat64 `json:"market_cap_usd"`
|
|
AvailableSupply sql.NullFloat64 `json:"available_supply"`
|
|
TotalSupply sql.NullFloat64 `json:"total_supply"`
|
|
MaxSupply sql.NullFloat64 `json:"max_supply"`
|
|
PercentChange1h sql.NullFloat64 `json:"percent_change_1h"`
|
|
PercentChange24h sql.NullFloat64 `json:"percent_change_24h"`
|
|
PercentChange7d sql.NullFloat64 `json:"percent_change_7d"`
|
|
Rank sql.NullInt64 `json:"rank"`
|
|
LastUpdated time.Time `json:"last_updated"`
|
|
}
|
|
|
|
// PRICE QUERIES (UPDATED)
|
|
func (q *Queries) InsertPrice(ctx context.Context, arg InsertPriceParams) (Price, error) {
|
|
row := q.db.QueryRowContext(ctx, insertPrice,
|
|
arg.AssetID,
|
|
arg.PriceUsd,
|
|
arg.PriceBtc,
|
|
arg.Volume24hUsd,
|
|
arg.MarketCapUsd,
|
|
arg.AvailableSupply,
|
|
arg.TotalSupply,
|
|
arg.MaxSupply,
|
|
arg.PercentChange1h,
|
|
arg.PercentChange24h,
|
|
arg.PercentChange7d,
|
|
arg.Rank,
|
|
arg.LastUpdated,
|
|
)
|
|
var i Price
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.AssetID,
|
|
&i.PriceUsd,
|
|
&i.PriceBtc,
|
|
&i.Volume24hUsd,
|
|
&i.MarketCapUsd,
|
|
&i.AvailableSupply,
|
|
&i.TotalSupply,
|
|
&i.MaxSupply,
|
|
&i.PercentChange1h,
|
|
&i.PercentChange24h,
|
|
&i.PercentChange7d,
|
|
&i.Rank,
|
|
&i.LastUpdated,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const insertPriceConversion = `-- name: InsertPriceConversion :one
|
|
INSERT INTO price_conversions (
|
|
price_id,
|
|
currency_code,
|
|
price,
|
|
volume_24h,
|
|
market_cap,
|
|
last_updated
|
|
) VALUES (?, ?, ?, ?, ?, ?)
|
|
RETURNING id, created_at, updated_at, deleted_at, price_id, currency_code, price, volume_24h, market_cap, last_updated
|
|
`
|
|
|
|
type InsertPriceConversionParams struct {
|
|
PriceID string `json:"price_id"`
|
|
CurrencyCode string `json:"currency_code"`
|
|
Price sql.NullFloat64 `json:"price"`
|
|
Volume24h sql.NullFloat64 `json:"volume_24h"`
|
|
MarketCap sql.NullFloat64 `json:"market_cap"`
|
|
LastUpdated time.Time `json:"last_updated"`
|
|
}
|
|
|
|
// PRICE CONVERSION QUERIES (NEW)
|
|
func (q *Queries) InsertPriceConversion(ctx context.Context, arg InsertPriceConversionParams) (PriceConversion, error) {
|
|
row := q.db.QueryRowContext(ctx, insertPriceConversion,
|
|
arg.PriceID,
|
|
arg.CurrencyCode,
|
|
arg.Price,
|
|
arg.Volume24h,
|
|
arg.MarketCap,
|
|
arg.LastUpdated,
|
|
)
|
|
var i PriceConversion
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.PriceID,
|
|
&i.CurrencyCode,
|
|
&i.Price,
|
|
&i.Volume24h,
|
|
&i.MarketCap,
|
|
&i.LastUpdated,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const listAllBlockchains = `-- name: ListAllBlockchains :many
|
|
SELECT id, created_at, updated_at, deleted_at, chain_name, chain_id_cosmos, chain_id_evm, api_name, bech_account_prefix, bech_validator_prefix, main_asset_symbol, main_asset_denom, staking_asset_symbol, staking_asset_denom, is_stake_enabled, chain_image, main_asset_image, staking_asset_image, chain_type, is_support_mobile_wallet, is_support_extension_wallet, is_support_erc20, description_en, description_ko, description_ja, origin_genesis_time, account_type, btc_staking, cosmos_fee_info, evm_fee_info, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint, explorer, about, forum FROM blockchains
|
|
WHERE deleted_at IS NULL
|
|
ORDER BY chain_name ASC
|
|
`
|
|
|
|
func (q *Queries) ListAllBlockchains(ctx context.Context) ([]Blockchain, error) {
|
|
rows, err := q.db.QueryContext(ctx, listAllBlockchains)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Blockchain
|
|
for rows.Next() {
|
|
var i Blockchain
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listAssetsByChain = `-- name: ListAssetsByChain :many
|
|
SELECT id, created_at, updated_at, deleted_at, name, symbol, decimals, chain_id, channel, asset_type, coingecko_id FROM assets
|
|
WHERE chain_id = ? AND deleted_at IS NULL
|
|
ORDER BY symbol ASC
|
|
`
|
|
|
|
func (q *Queries) ListAssetsByChain(ctx context.Context, chainID string) ([]Asset, error) {
|
|
rows, err := q.db.QueryContext(ctx, listAssetsByChain, chainID)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Asset
|
|
for rows.Next() {
|
|
var i Asset
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.Name,
|
|
&i.Symbol,
|
|
&i.Decimals,
|
|
&i.ChainID,
|
|
&i.Channel,
|
|
&i.AssetType,
|
|
&i.CoingeckoID,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listAssetsWithLatestPrices = `-- name: ListAssetsWithLatestPrices :many
|
|
SELECT a.id, a.created_at, a.updated_at, a.deleted_at, a.name, a.symbol, a.decimals, a.chain_id, a.channel, a.asset_type, a.coingecko_id, p.price_usd, p.price_btc, p.volume_24h_usd, p.market_cap_usd,
|
|
p.available_supply, p.total_supply, p.max_supply,
|
|
p.percent_change_1h, p.percent_change_24h, p.percent_change_7d,
|
|
p.rank, p.last_updated
|
|
FROM assets a
|
|
LEFT JOIN (
|
|
SELECT p1.id, p1.created_at, p1.updated_at, p1.deleted_at, p1.asset_id, p1.price_usd, p1.price_btc, p1.volume_24h_usd, p1.market_cap_usd, p1.available_supply, p1.total_supply, p1.max_supply, p1.percent_change_1h, p1.percent_change_24h, p1.percent_change_7d, p1.rank, p1.last_updated
|
|
FROM prices p1
|
|
INNER JOIN (
|
|
SELECT asset_id, MAX(last_updated) as max_date
|
|
FROM prices
|
|
WHERE deleted_at IS NULL
|
|
GROUP BY asset_id
|
|
) p2 ON p1.asset_id = p2.asset_id AND p1.last_updated = p2.max_date
|
|
WHERE p1.deleted_at IS NULL
|
|
) p ON a.id = p.asset_id
|
|
WHERE a.deleted_at IS NULL
|
|
ORDER BY p.rank ASC, a.symbol ASC
|
|
LIMIT ? OFFSET ?
|
|
`
|
|
|
|
type ListAssetsWithLatestPricesParams struct {
|
|
Limit int64 `json:"limit"`
|
|
Offset int64 `json:"offset"`
|
|
}
|
|
|
|
type ListAssetsWithLatestPricesRow struct {
|
|
ID string `json:"id"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DeletedAt sql.NullTime `json:"deleted_at"`
|
|
Name string `json:"name"`
|
|
Symbol string `json:"symbol"`
|
|
Decimals int64 `json:"decimals"`
|
|
ChainID string `json:"chain_id"`
|
|
Channel string `json:"channel"`
|
|
AssetType string `json:"asset_type"`
|
|
CoingeckoID sql.NullString `json:"coingecko_id"`
|
|
PriceUsd sql.NullFloat64 `json:"price_usd"`
|
|
PriceBtc sql.NullFloat64 `json:"price_btc"`
|
|
Volume24hUsd sql.NullFloat64 `json:"volume_24h_usd"`
|
|
MarketCapUsd sql.NullFloat64 `json:"market_cap_usd"`
|
|
AvailableSupply sql.NullFloat64 `json:"available_supply"`
|
|
TotalSupply sql.NullFloat64 `json:"total_supply"`
|
|
MaxSupply sql.NullFloat64 `json:"max_supply"`
|
|
PercentChange1h sql.NullFloat64 `json:"percent_change_1h"`
|
|
PercentChange24h sql.NullFloat64 `json:"percent_change_24h"`
|
|
PercentChange7d sql.NullFloat64 `json:"percent_change_7d"`
|
|
Rank sql.NullInt64 `json:"rank"`
|
|
LastUpdated time.Time `json:"last_updated"`
|
|
}
|
|
|
|
func (q *Queries) ListAssetsWithLatestPrices(ctx context.Context, arg ListAssetsWithLatestPricesParams) ([]ListAssetsWithLatestPricesRow, error) {
|
|
rows, err := q.db.QueryContext(ctx, listAssetsWithLatestPrices, arg.Limit, arg.Offset)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ListAssetsWithLatestPricesRow
|
|
for rows.Next() {
|
|
var i ListAssetsWithLatestPricesRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.Name,
|
|
&i.Symbol,
|
|
&i.Decimals,
|
|
&i.ChainID,
|
|
&i.Channel,
|
|
&i.AssetType,
|
|
&i.CoingeckoID,
|
|
&i.PriceUsd,
|
|
&i.PriceBtc,
|
|
&i.Volume24hUsd,
|
|
&i.MarketCapUsd,
|
|
&i.AvailableSupply,
|
|
&i.TotalSupply,
|
|
&i.MaxSupply,
|
|
&i.PercentChange1h,
|
|
&i.PercentChange24h,
|
|
&i.PercentChange7d,
|
|
&i.Rank,
|
|
&i.LastUpdated,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listBlockchainsByChainType = `-- name: ListBlockchainsByChainType :many
|
|
SELECT id, created_at, updated_at, deleted_at, chain_name, chain_id_cosmos, chain_id_evm, api_name, bech_account_prefix, bech_validator_prefix, main_asset_symbol, main_asset_denom, staking_asset_symbol, staking_asset_denom, is_stake_enabled, chain_image, main_asset_image, staking_asset_image, chain_type, is_support_mobile_wallet, is_support_extension_wallet, is_support_erc20, description_en, description_ko, description_ja, origin_genesis_time, account_type, btc_staking, cosmos_fee_info, evm_fee_info, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint, explorer, about, forum FROM blockchains
|
|
WHERE chain_type LIKE '%' || ? || '%' AND deleted_at IS NULL
|
|
ORDER BY chain_name ASC
|
|
`
|
|
|
|
func (q *Queries) ListBlockchainsByChainType(ctx context.Context, dollar_1 sql.NullString) ([]Blockchain, error) {
|
|
rows, err := q.db.QueryContext(ctx, listBlockchainsByChainType, dollar_1)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Blockchain
|
|
for rows.Next() {
|
|
var i Blockchain
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listBlockchainsWithAssetInfo = `-- name: ListBlockchainsWithAssetInfo :many
|
|
SELECT b.id, b.created_at, b.updated_at, b.deleted_at, b.chain_name, b.chain_id_cosmos, b.chain_id_evm, b.api_name, b.bech_account_prefix, b.bech_validator_prefix, b.main_asset_symbol, b.main_asset_denom, b.staking_asset_symbol, b.staking_asset_denom, b.is_stake_enabled, b.chain_image, b.main_asset_image, b.staking_asset_image, b.chain_type, b.is_support_mobile_wallet, b.is_support_extension_wallet, b.is_support_erc20, b.description_en, b.description_ko, b.description_ja, b.origin_genesis_time, b.account_type, b.btc_staking, b.cosmos_fee_info, b.evm_fee_info, b.lcd_endpoint, b.grpc_endpoint, b.evm_rpc_endpoint, b.explorer, b.about, b.forum, a.id as asset_id, a.symbol, a.decimals, p.price_usd, p.price_btc
|
|
FROM blockchains b
|
|
LEFT JOIN assets a ON b.main_asset_symbol = a.symbol
|
|
LEFT JOIN (
|
|
SELECT p1.id, p1.created_at, p1.updated_at, p1.deleted_at, p1.asset_id, p1.price_usd, p1.price_btc, p1.volume_24h_usd, p1.market_cap_usd, p1.available_supply, p1.total_supply, p1.max_supply, p1.percent_change_1h, p1.percent_change_24h, p1.percent_change_7d, p1.rank, p1.last_updated
|
|
FROM prices p1
|
|
INNER JOIN (
|
|
SELECT asset_id, MAX(last_updated) as max_date
|
|
FROM prices
|
|
WHERE deleted_at IS NULL
|
|
GROUP BY asset_id
|
|
) p2 ON p1.asset_id = p2.asset_id AND p1.last_updated = p2.max_date
|
|
WHERE p1.deleted_at IS NULL
|
|
) p ON a.id = p.asset_id
|
|
WHERE b.deleted_at IS NULL
|
|
ORDER BY b.chain_name ASC
|
|
LIMIT ? OFFSET ?
|
|
`
|
|
|
|
type ListBlockchainsWithAssetInfoParams struct {
|
|
Limit int64 `json:"limit"`
|
|
Offset int64 `json:"offset"`
|
|
}
|
|
|
|
type ListBlockchainsWithAssetInfoRow struct {
|
|
ID string `json:"id"`
|
|
CreatedAt time.Time `json:"created_at"`
|
|
UpdatedAt time.Time `json:"updated_at"`
|
|
DeletedAt sql.NullTime `json:"deleted_at"`
|
|
ChainName string `json:"chain_name"`
|
|
ChainIDCosmos sql.NullString `json:"chain_id_cosmos"`
|
|
ChainIDEvm sql.NullString `json:"chain_id_evm"`
|
|
ApiName sql.NullString `json:"api_name"`
|
|
BechAccountPrefix sql.NullString `json:"bech_account_prefix"`
|
|
BechValidatorPrefix sql.NullString `json:"bech_validator_prefix"`
|
|
MainAssetSymbol sql.NullString `json:"main_asset_symbol"`
|
|
MainAssetDenom sql.NullString `json:"main_asset_denom"`
|
|
StakingAssetSymbol sql.NullString `json:"staking_asset_symbol"`
|
|
StakingAssetDenom sql.NullString `json:"staking_asset_denom"`
|
|
IsStakeEnabled bool `json:"is_stake_enabled"`
|
|
ChainImage sql.NullString `json:"chain_image"`
|
|
MainAssetImage sql.NullString `json:"main_asset_image"`
|
|
StakingAssetImage sql.NullString `json:"staking_asset_image"`
|
|
ChainType string `json:"chain_type"`
|
|
IsSupportMobileWallet bool `json:"is_support_mobile_wallet"`
|
|
IsSupportExtensionWallet bool `json:"is_support_extension_wallet"`
|
|
IsSupportErc20 bool `json:"is_support_erc20"`
|
|
DescriptionEn sql.NullString `json:"description_en"`
|
|
DescriptionKo sql.NullString `json:"description_ko"`
|
|
DescriptionJa sql.NullString `json:"description_ja"`
|
|
OriginGenesisTime sql.NullTime `json:"origin_genesis_time"`
|
|
AccountType string `json:"account_type"`
|
|
BtcStaking sql.NullString `json:"btc_staking"`
|
|
CosmosFeeInfo sql.NullString `json:"cosmos_fee_info"`
|
|
EvmFeeInfo sql.NullString `json:"evm_fee_info"`
|
|
LcdEndpoint sql.NullString `json:"lcd_endpoint"`
|
|
GrpcEndpoint sql.NullString `json:"grpc_endpoint"`
|
|
EvmRpcEndpoint sql.NullString `json:"evm_rpc_endpoint"`
|
|
Explorer sql.NullString `json:"explorer"`
|
|
About sql.NullString `json:"about"`
|
|
Forum sql.NullString `json:"forum"`
|
|
AssetID sql.NullString `json:"asset_id"`
|
|
Symbol sql.NullString `json:"symbol"`
|
|
Decimals sql.NullInt64 `json:"decimals"`
|
|
PriceUsd sql.NullFloat64 `json:"price_usd"`
|
|
PriceBtc sql.NullFloat64 `json:"price_btc"`
|
|
}
|
|
|
|
func (q *Queries) ListBlockchainsWithAssetInfo(ctx context.Context, arg ListBlockchainsWithAssetInfoParams) ([]ListBlockchainsWithAssetInfoRow, error) {
|
|
rows, err := q.db.QueryContext(ctx, listBlockchainsWithAssetInfo, arg.Limit, arg.Offset)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []ListBlockchainsWithAssetInfoRow
|
|
for rows.Next() {
|
|
var i ListBlockchainsWithAssetInfoRow
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
&i.AssetID,
|
|
&i.Symbol,
|
|
&i.Decimals,
|
|
&i.PriceUsd,
|
|
&i.PriceBtc,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listBlockchainsWithERC20Support = `-- name: ListBlockchainsWithERC20Support :many
|
|
SELECT id, created_at, updated_at, deleted_at, chain_name, chain_id_cosmos, chain_id_evm, api_name, bech_account_prefix, bech_validator_prefix, main_asset_symbol, main_asset_denom, staking_asset_symbol, staking_asset_denom, is_stake_enabled, chain_image, main_asset_image, staking_asset_image, chain_type, is_support_mobile_wallet, is_support_extension_wallet, is_support_erc20, description_en, description_ko, description_ja, origin_genesis_time, account_type, btc_staking, cosmos_fee_info, evm_fee_info, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint, explorer, about, forum FROM blockchains
|
|
WHERE is_support_erc20 = 1 AND deleted_at IS NULL
|
|
ORDER BY chain_name ASC
|
|
`
|
|
|
|
func (q *Queries) ListBlockchainsWithERC20Support(ctx context.Context) ([]Blockchain, error) {
|
|
rows, err := q.db.QueryContext(ctx, listBlockchainsWithERC20Support)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Blockchain
|
|
for rows.Next() {
|
|
var i Blockchain
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listBlockchainsWithExtensionSupport = `-- name: ListBlockchainsWithExtensionSupport :many
|
|
SELECT id, created_at, updated_at, deleted_at, chain_name, chain_id_cosmos, chain_id_evm, api_name, bech_account_prefix, bech_validator_prefix, main_asset_symbol, main_asset_denom, staking_asset_symbol, staking_asset_denom, is_stake_enabled, chain_image, main_asset_image, staking_asset_image, chain_type, is_support_mobile_wallet, is_support_extension_wallet, is_support_erc20, description_en, description_ko, description_ja, origin_genesis_time, account_type, btc_staking, cosmos_fee_info, evm_fee_info, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint, explorer, about, forum FROM blockchains
|
|
WHERE is_support_extension_wallet = 1 AND deleted_at IS NULL
|
|
ORDER BY chain_name ASC
|
|
`
|
|
|
|
func (q *Queries) ListBlockchainsWithExtensionSupport(ctx context.Context) ([]Blockchain, error) {
|
|
rows, err := q.db.QueryContext(ctx, listBlockchainsWithExtensionSupport)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Blockchain
|
|
for rows.Next() {
|
|
var i Blockchain
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listBlockchainsWithMobileSupport = `-- name: ListBlockchainsWithMobileSupport :many
|
|
SELECT id, created_at, updated_at, deleted_at, chain_name, chain_id_cosmos, chain_id_evm, api_name, bech_account_prefix, bech_validator_prefix, main_asset_symbol, main_asset_denom, staking_asset_symbol, staking_asset_denom, is_stake_enabled, chain_image, main_asset_image, staking_asset_image, chain_type, is_support_mobile_wallet, is_support_extension_wallet, is_support_erc20, description_en, description_ko, description_ja, origin_genesis_time, account_type, btc_staking, cosmos_fee_info, evm_fee_info, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint, explorer, about, forum FROM blockchains
|
|
WHERE is_support_mobile_wallet = 1 AND deleted_at IS NULL
|
|
ORDER BY chain_name ASC
|
|
`
|
|
|
|
func (q *Queries) ListBlockchainsWithMobileSupport(ctx context.Context) ([]Blockchain, error) {
|
|
rows, err := q.db.QueryContext(ctx, listBlockchainsWithMobileSupport)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Blockchain
|
|
for rows.Next() {
|
|
var i Blockchain
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listBlockchainsWithStaking = `-- name: ListBlockchainsWithStaking :many
|
|
SELECT id, created_at, updated_at, deleted_at, chain_name, chain_id_cosmos, chain_id_evm, api_name, bech_account_prefix, bech_validator_prefix, main_asset_symbol, main_asset_denom, staking_asset_symbol, staking_asset_denom, is_stake_enabled, chain_image, main_asset_image, staking_asset_image, chain_type, is_support_mobile_wallet, is_support_extension_wallet, is_support_erc20, description_en, description_ko, description_ja, origin_genesis_time, account_type, btc_staking, cosmos_fee_info, evm_fee_info, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint, explorer, about, forum FROM blockchains
|
|
WHERE is_stake_enabled = 1 AND deleted_at IS NULL
|
|
ORDER BY chain_name ASC
|
|
`
|
|
|
|
func (q *Queries) ListBlockchainsWithStaking(ctx context.Context) ([]Blockchain, error) {
|
|
rows, err := q.db.QueryContext(ctx, listBlockchainsWithStaking)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Blockchain
|
|
for rows.Next() {
|
|
var i Blockchain
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const listPriceHistoryByAssetID = `-- name: ListPriceHistoryByAssetID :many
|
|
SELECT id, created_at, updated_at, deleted_at, asset_id, price_usd, price_btc, volume_24h_usd, market_cap_usd, available_supply, total_supply, max_supply, percent_change_1h, percent_change_24h, percent_change_7d, rank, last_updated FROM prices
|
|
WHERE asset_id = ? AND deleted_at IS NULL
|
|
ORDER BY last_updated DESC
|
|
LIMIT ? OFFSET ?
|
|
`
|
|
|
|
type ListPriceHistoryByAssetIDParams struct {
|
|
AssetID string `json:"asset_id"`
|
|
Limit int64 `json:"limit"`
|
|
Offset int64 `json:"offset"`
|
|
}
|
|
|
|
func (q *Queries) ListPriceHistoryByAssetID(ctx context.Context, arg ListPriceHistoryByAssetIDParams) ([]Price, error) {
|
|
rows, err := q.db.QueryContext(ctx, listPriceHistoryByAssetID, arg.AssetID, arg.Limit, arg.Offset)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Price
|
|
for rows.Next() {
|
|
var i Price
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.AssetID,
|
|
&i.PriceUsd,
|
|
&i.PriceBtc,
|
|
&i.Volume24hUsd,
|
|
&i.MarketCapUsd,
|
|
&i.AvailableSupply,
|
|
&i.TotalSupply,
|
|
&i.MaxSupply,
|
|
&i.PercentChange1h,
|
|
&i.PercentChange24h,
|
|
&i.PercentChange7d,
|
|
&i.Rank,
|
|
&i.LastUpdated,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const searchBlockchains = `-- name: SearchBlockchains :many
|
|
SELECT id, created_at, updated_at, deleted_at, chain_name, chain_id_cosmos, chain_id_evm, api_name, bech_account_prefix, bech_validator_prefix, main_asset_symbol, main_asset_denom, staking_asset_symbol, staking_asset_denom, is_stake_enabled, chain_image, main_asset_image, staking_asset_image, chain_type, is_support_mobile_wallet, is_support_extension_wallet, is_support_erc20, description_en, description_ko, description_ja, origin_genesis_time, account_type, btc_staking, cosmos_fee_info, evm_fee_info, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint, explorer, about, forum FROM blockchains
|
|
WHERE (
|
|
chain_name LIKE '%' || ? || '%' OR
|
|
main_asset_symbol LIKE '%' || ? || '%' OR
|
|
staking_asset_symbol LIKE '%' || ? || '%' OR
|
|
description_en LIKE '%' || ? || '%'
|
|
) AND deleted_at IS NULL
|
|
ORDER BY chain_name ASC
|
|
LIMIT ? OFFSET ?
|
|
`
|
|
|
|
type SearchBlockchainsParams struct {
|
|
Column1 sql.NullString `json:"column_1"`
|
|
Column2 sql.NullString `json:"column_2"`
|
|
Column3 sql.NullString `json:"column_3"`
|
|
Column4 sql.NullString `json:"column_4"`
|
|
Limit int64 `json:"limit"`
|
|
Offset int64 `json:"offset"`
|
|
}
|
|
|
|
func (q *Queries) SearchBlockchains(ctx context.Context, arg SearchBlockchainsParams) ([]Blockchain, error) {
|
|
rows, err := q.db.QueryContext(ctx, searchBlockchains,
|
|
arg.Column1,
|
|
arg.Column2,
|
|
arg.Column3,
|
|
arg.Column4,
|
|
arg.Limit,
|
|
arg.Offset,
|
|
)
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
defer rows.Close()
|
|
var items []Blockchain
|
|
for rows.Next() {
|
|
var i Blockchain
|
|
if err := rows.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
); err != nil {
|
|
return nil, err
|
|
}
|
|
items = append(items, i)
|
|
}
|
|
if err := rows.Close(); err != nil {
|
|
return nil, err
|
|
}
|
|
if err := rows.Err(); err != nil {
|
|
return nil, err
|
|
}
|
|
return items, nil
|
|
}
|
|
|
|
const softDeleteAsset = `-- name: SoftDeleteAsset :exec
|
|
UPDATE assets
|
|
SET deleted_at = CURRENT_TIMESTAMP
|
|
WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) SoftDeleteAsset(ctx context.Context, id string) error {
|
|
_, err := q.db.ExecContext(ctx, softDeleteAsset, id)
|
|
return err
|
|
}
|
|
|
|
const softDeleteBlockchain = `-- name: SoftDeleteBlockchain :exec
|
|
UPDATE blockchains
|
|
SET deleted_at = CURRENT_TIMESTAMP
|
|
WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) SoftDeleteBlockchain(ctx context.Context, id string) error {
|
|
_, err := q.db.ExecContext(ctx, softDeleteBlockchain, id)
|
|
return err
|
|
}
|
|
|
|
const softDeletePriceConversion = `-- name: SoftDeletePriceConversion :exec
|
|
UPDATE price_conversions
|
|
SET deleted_at = CURRENT_TIMESTAMP
|
|
WHERE id = ?
|
|
`
|
|
|
|
func (q *Queries) SoftDeletePriceConversion(ctx context.Context, id string) error {
|
|
_, err := q.db.ExecContext(ctx, softDeletePriceConversion, id)
|
|
return err
|
|
}
|
|
|
|
const updateAsset = `-- name: UpdateAsset :one
|
|
UPDATE assets
|
|
SET
|
|
name = ?,
|
|
decimals = ?,
|
|
channel = ?,
|
|
asset_type = ?,
|
|
coingecko_id = ?,
|
|
updated_at = CURRENT_TIMESTAMP
|
|
WHERE id = ?
|
|
AND deleted_at IS NULL
|
|
RETURNING id, created_at, updated_at, deleted_at, name, symbol, decimals, chain_id, channel, asset_type, coingecko_id
|
|
`
|
|
|
|
type UpdateAssetParams struct {
|
|
Name string `json:"name"`
|
|
Decimals int64 `json:"decimals"`
|
|
Channel string `json:"channel"`
|
|
AssetType string `json:"asset_type"`
|
|
CoingeckoID sql.NullString `json:"coingecko_id"`
|
|
ID string `json:"id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateAsset(ctx context.Context, arg UpdateAssetParams) (Asset, error) {
|
|
row := q.db.QueryRowContext(ctx, updateAsset,
|
|
arg.Name,
|
|
arg.Decimals,
|
|
arg.Channel,
|
|
arg.AssetType,
|
|
arg.CoingeckoID,
|
|
arg.ID,
|
|
)
|
|
var i Asset
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.Name,
|
|
&i.Symbol,
|
|
&i.Decimals,
|
|
&i.ChainID,
|
|
&i.Channel,
|
|
&i.AssetType,
|
|
&i.CoingeckoID,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateBlockchain = `-- name: UpdateBlockchain :one
|
|
UPDATE blockchains
|
|
SET
|
|
chain_name = ?,
|
|
chain_id_cosmos = ?,
|
|
chain_id_evm = ?,
|
|
api_name = ?,
|
|
bech_account_prefix = ?,
|
|
bech_validator_prefix = ?,
|
|
main_asset_symbol = ?,
|
|
main_asset_denom = ?,
|
|
staking_asset_symbol = ?,
|
|
staking_asset_denom = ?,
|
|
is_stake_enabled = ?,
|
|
chain_image = ?,
|
|
main_asset_image = ?,
|
|
staking_asset_image = ?,
|
|
chain_type = ?,
|
|
is_support_mobile_wallet = ?,
|
|
is_support_extension_wallet = ?,
|
|
is_support_erc20 = ?,
|
|
description_en = ?,
|
|
description_ko = ?,
|
|
description_ja = ?,
|
|
origin_genesis_time = ?,
|
|
account_type = ?,
|
|
btc_staking = ?,
|
|
cosmos_fee_info = ?,
|
|
evm_fee_info = ?,
|
|
lcd_endpoint = ?,
|
|
grpc_endpoint = ?,
|
|
evm_rpc_endpoint = ?,
|
|
explorer = ?,
|
|
about = ?,
|
|
forum = ?,
|
|
updated_at = CURRENT_TIMESTAMP
|
|
WHERE id = ?
|
|
AND deleted_at IS NULL
|
|
RETURNING id, created_at, updated_at, deleted_at, chain_name, chain_id_cosmos, chain_id_evm, api_name, bech_account_prefix, bech_validator_prefix, main_asset_symbol, main_asset_denom, staking_asset_symbol, staking_asset_denom, is_stake_enabled, chain_image, main_asset_image, staking_asset_image, chain_type, is_support_mobile_wallet, is_support_extension_wallet, is_support_erc20, description_en, description_ko, description_ja, origin_genesis_time, account_type, btc_staking, cosmos_fee_info, evm_fee_info, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint, explorer, about, forum
|
|
`
|
|
|
|
type UpdateBlockchainParams struct {
|
|
ChainName string `json:"chain_name"`
|
|
ChainIDCosmos sql.NullString `json:"chain_id_cosmos"`
|
|
ChainIDEvm sql.NullString `json:"chain_id_evm"`
|
|
ApiName sql.NullString `json:"api_name"`
|
|
BechAccountPrefix sql.NullString `json:"bech_account_prefix"`
|
|
BechValidatorPrefix sql.NullString `json:"bech_validator_prefix"`
|
|
MainAssetSymbol sql.NullString `json:"main_asset_symbol"`
|
|
MainAssetDenom sql.NullString `json:"main_asset_denom"`
|
|
StakingAssetSymbol sql.NullString `json:"staking_asset_symbol"`
|
|
StakingAssetDenom sql.NullString `json:"staking_asset_denom"`
|
|
IsStakeEnabled bool `json:"is_stake_enabled"`
|
|
ChainImage sql.NullString `json:"chain_image"`
|
|
MainAssetImage sql.NullString `json:"main_asset_image"`
|
|
StakingAssetImage sql.NullString `json:"staking_asset_image"`
|
|
ChainType string `json:"chain_type"`
|
|
IsSupportMobileWallet bool `json:"is_support_mobile_wallet"`
|
|
IsSupportExtensionWallet bool `json:"is_support_extension_wallet"`
|
|
IsSupportErc20 bool `json:"is_support_erc20"`
|
|
DescriptionEn sql.NullString `json:"description_en"`
|
|
DescriptionKo sql.NullString `json:"description_ko"`
|
|
DescriptionJa sql.NullString `json:"description_ja"`
|
|
OriginGenesisTime sql.NullTime `json:"origin_genesis_time"`
|
|
AccountType string `json:"account_type"`
|
|
BtcStaking sql.NullString `json:"btc_staking"`
|
|
CosmosFeeInfo sql.NullString `json:"cosmos_fee_info"`
|
|
EvmFeeInfo sql.NullString `json:"evm_fee_info"`
|
|
LcdEndpoint sql.NullString `json:"lcd_endpoint"`
|
|
GrpcEndpoint sql.NullString `json:"grpc_endpoint"`
|
|
EvmRpcEndpoint sql.NullString `json:"evm_rpc_endpoint"`
|
|
Explorer sql.NullString `json:"explorer"`
|
|
About sql.NullString `json:"about"`
|
|
Forum sql.NullString `json:"forum"`
|
|
ID string `json:"id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateBlockchain(ctx context.Context, arg UpdateBlockchainParams) (Blockchain, error) {
|
|
row := q.db.QueryRowContext(ctx, updateBlockchain,
|
|
arg.ChainName,
|
|
arg.ChainIDCosmos,
|
|
arg.ChainIDEvm,
|
|
arg.ApiName,
|
|
arg.BechAccountPrefix,
|
|
arg.BechValidatorPrefix,
|
|
arg.MainAssetSymbol,
|
|
arg.MainAssetDenom,
|
|
arg.StakingAssetSymbol,
|
|
arg.StakingAssetDenom,
|
|
arg.IsStakeEnabled,
|
|
arg.ChainImage,
|
|
arg.MainAssetImage,
|
|
arg.StakingAssetImage,
|
|
arg.ChainType,
|
|
arg.IsSupportMobileWallet,
|
|
arg.IsSupportExtensionWallet,
|
|
arg.IsSupportErc20,
|
|
arg.DescriptionEn,
|
|
arg.DescriptionKo,
|
|
arg.DescriptionJa,
|
|
arg.OriginGenesisTime,
|
|
arg.AccountType,
|
|
arg.BtcStaking,
|
|
arg.CosmosFeeInfo,
|
|
arg.EvmFeeInfo,
|
|
arg.LcdEndpoint,
|
|
arg.GrpcEndpoint,
|
|
arg.EvmRpcEndpoint,
|
|
arg.Explorer,
|
|
arg.About,
|
|
arg.Forum,
|
|
arg.ID,
|
|
)
|
|
var i Blockchain
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateBlockchainDescriptions = `-- name: UpdateBlockchainDescriptions :one
|
|
UPDATE blockchains
|
|
SET
|
|
description_en = ?,
|
|
description_ko = ?,
|
|
description_ja = ?,
|
|
updated_at = CURRENT_TIMESTAMP
|
|
WHERE id = ?
|
|
AND deleted_at IS NULL
|
|
RETURNING id, created_at, updated_at, deleted_at, chain_name, chain_id_cosmos, chain_id_evm, api_name, bech_account_prefix, bech_validator_prefix, main_asset_symbol, main_asset_denom, staking_asset_symbol, staking_asset_denom, is_stake_enabled, chain_image, main_asset_image, staking_asset_image, chain_type, is_support_mobile_wallet, is_support_extension_wallet, is_support_erc20, description_en, description_ko, description_ja, origin_genesis_time, account_type, btc_staking, cosmos_fee_info, evm_fee_info, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint, explorer, about, forum
|
|
`
|
|
|
|
type UpdateBlockchainDescriptionsParams struct {
|
|
DescriptionEn sql.NullString `json:"description_en"`
|
|
DescriptionKo sql.NullString `json:"description_ko"`
|
|
DescriptionJa sql.NullString `json:"description_ja"`
|
|
ID string `json:"id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateBlockchainDescriptions(ctx context.Context, arg UpdateBlockchainDescriptionsParams) (Blockchain, error) {
|
|
row := q.db.QueryRowContext(ctx, updateBlockchainDescriptions,
|
|
arg.DescriptionEn,
|
|
arg.DescriptionKo,
|
|
arg.DescriptionJa,
|
|
arg.ID,
|
|
)
|
|
var i Blockchain
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateBlockchainEndpoints = `-- name: UpdateBlockchainEndpoints :one
|
|
UPDATE blockchains
|
|
SET
|
|
lcd_endpoint = ?,
|
|
grpc_endpoint = ?,
|
|
evm_rpc_endpoint = ?,
|
|
updated_at = CURRENT_TIMESTAMP
|
|
WHERE id = ?
|
|
AND deleted_at IS NULL
|
|
RETURNING id, created_at, updated_at, deleted_at, chain_name, chain_id_cosmos, chain_id_evm, api_name, bech_account_prefix, bech_validator_prefix, main_asset_symbol, main_asset_denom, staking_asset_symbol, staking_asset_denom, is_stake_enabled, chain_image, main_asset_image, staking_asset_image, chain_type, is_support_mobile_wallet, is_support_extension_wallet, is_support_erc20, description_en, description_ko, description_ja, origin_genesis_time, account_type, btc_staking, cosmos_fee_info, evm_fee_info, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint, explorer, about, forum
|
|
`
|
|
|
|
type UpdateBlockchainEndpointsParams struct {
|
|
LcdEndpoint sql.NullString `json:"lcd_endpoint"`
|
|
GrpcEndpoint sql.NullString `json:"grpc_endpoint"`
|
|
EvmRpcEndpoint sql.NullString `json:"evm_rpc_endpoint"`
|
|
ID string `json:"id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateBlockchainEndpoints(ctx context.Context, arg UpdateBlockchainEndpointsParams) (Blockchain, error) {
|
|
row := q.db.QueryRowContext(ctx, updateBlockchainEndpoints,
|
|
arg.LcdEndpoint,
|
|
arg.GrpcEndpoint,
|
|
arg.EvmRpcEndpoint,
|
|
arg.ID,
|
|
)
|
|
var i Blockchain
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateBlockchainExplorer = `-- name: UpdateBlockchainExplorer :one
|
|
UPDATE blockchains
|
|
SET
|
|
explorer = ?,
|
|
updated_at = CURRENT_TIMESTAMP
|
|
WHERE id = ?
|
|
AND deleted_at IS NULL
|
|
RETURNING id, created_at, updated_at, deleted_at, chain_name, chain_id_cosmos, chain_id_evm, api_name, bech_account_prefix, bech_validator_prefix, main_asset_symbol, main_asset_denom, staking_asset_symbol, staking_asset_denom, is_stake_enabled, chain_image, main_asset_image, staking_asset_image, chain_type, is_support_mobile_wallet, is_support_extension_wallet, is_support_erc20, description_en, description_ko, description_ja, origin_genesis_time, account_type, btc_staking, cosmos_fee_info, evm_fee_info, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint, explorer, about, forum
|
|
`
|
|
|
|
type UpdateBlockchainExplorerParams struct {
|
|
Explorer sql.NullString `json:"explorer"`
|
|
ID string `json:"id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateBlockchainExplorer(ctx context.Context, arg UpdateBlockchainExplorerParams) (Blockchain, error) {
|
|
row := q.db.QueryRowContext(ctx, updateBlockchainExplorer, arg.Explorer, arg.ID)
|
|
var i Blockchain
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateBlockchainFeeInfo = `-- name: UpdateBlockchainFeeInfo :one
|
|
UPDATE blockchains
|
|
SET
|
|
cosmos_fee_info = ?,
|
|
evm_fee_info = ?,
|
|
updated_at = CURRENT_TIMESTAMP
|
|
WHERE id = ?
|
|
AND deleted_at IS NULL
|
|
RETURNING id, created_at, updated_at, deleted_at, chain_name, chain_id_cosmos, chain_id_evm, api_name, bech_account_prefix, bech_validator_prefix, main_asset_symbol, main_asset_denom, staking_asset_symbol, staking_asset_denom, is_stake_enabled, chain_image, main_asset_image, staking_asset_image, chain_type, is_support_mobile_wallet, is_support_extension_wallet, is_support_erc20, description_en, description_ko, description_ja, origin_genesis_time, account_type, btc_staking, cosmos_fee_info, evm_fee_info, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint, explorer, about, forum
|
|
`
|
|
|
|
type UpdateBlockchainFeeInfoParams struct {
|
|
CosmosFeeInfo sql.NullString `json:"cosmos_fee_info"`
|
|
EvmFeeInfo sql.NullString `json:"evm_fee_info"`
|
|
ID string `json:"id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateBlockchainFeeInfo(ctx context.Context, arg UpdateBlockchainFeeInfoParams) (Blockchain, error) {
|
|
row := q.db.QueryRowContext(ctx, updateBlockchainFeeInfo, arg.CosmosFeeInfo, arg.EvmFeeInfo, arg.ID)
|
|
var i Blockchain
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateBlockchainImages = `-- name: UpdateBlockchainImages :one
|
|
UPDATE blockchains
|
|
SET
|
|
chain_image = ?,
|
|
main_asset_image = ?,
|
|
staking_asset_image = ?,
|
|
updated_at = CURRENT_TIMESTAMP
|
|
WHERE id = ?
|
|
AND deleted_at IS NULL
|
|
RETURNING id, created_at, updated_at, deleted_at, chain_name, chain_id_cosmos, chain_id_evm, api_name, bech_account_prefix, bech_validator_prefix, main_asset_symbol, main_asset_denom, staking_asset_symbol, staking_asset_denom, is_stake_enabled, chain_image, main_asset_image, staking_asset_image, chain_type, is_support_mobile_wallet, is_support_extension_wallet, is_support_erc20, description_en, description_ko, description_ja, origin_genesis_time, account_type, btc_staking, cosmos_fee_info, evm_fee_info, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint, explorer, about, forum
|
|
`
|
|
|
|
type UpdateBlockchainImagesParams struct {
|
|
ChainImage sql.NullString `json:"chain_image"`
|
|
MainAssetImage sql.NullString `json:"main_asset_image"`
|
|
StakingAssetImage sql.NullString `json:"staking_asset_image"`
|
|
ID string `json:"id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateBlockchainImages(ctx context.Context, arg UpdateBlockchainImagesParams) (Blockchain, error) {
|
|
row := q.db.QueryRowContext(ctx, updateBlockchainImages,
|
|
arg.ChainImage,
|
|
arg.MainAssetImage,
|
|
arg.StakingAssetImage,
|
|
arg.ID,
|
|
)
|
|
var i Blockchain
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updateBlockchainSocialLinks = `-- name: UpdateBlockchainSocialLinks :one
|
|
UPDATE blockchains
|
|
SET
|
|
about = ?,
|
|
forum = ?,
|
|
updated_at = CURRENT_TIMESTAMP
|
|
WHERE id = ?
|
|
AND deleted_at IS NULL
|
|
RETURNING id, created_at, updated_at, deleted_at, chain_name, chain_id_cosmos, chain_id_evm, api_name, bech_account_prefix, bech_validator_prefix, main_asset_symbol, main_asset_denom, staking_asset_symbol, staking_asset_denom, is_stake_enabled, chain_image, main_asset_image, staking_asset_image, chain_type, is_support_mobile_wallet, is_support_extension_wallet, is_support_erc20, description_en, description_ko, description_ja, origin_genesis_time, account_type, btc_staking, cosmos_fee_info, evm_fee_info, lcd_endpoint, grpc_endpoint, evm_rpc_endpoint, explorer, about, forum
|
|
`
|
|
|
|
type UpdateBlockchainSocialLinksParams struct {
|
|
About sql.NullString `json:"about"`
|
|
Forum sql.NullString `json:"forum"`
|
|
ID string `json:"id"`
|
|
}
|
|
|
|
func (q *Queries) UpdateBlockchainSocialLinks(ctx context.Context, arg UpdateBlockchainSocialLinksParams) (Blockchain, error) {
|
|
row := q.db.QueryRowContext(ctx, updateBlockchainSocialLinks, arg.About, arg.Forum, arg.ID)
|
|
var i Blockchain
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.ChainName,
|
|
&i.ChainIDCosmos,
|
|
&i.ChainIDEvm,
|
|
&i.ApiName,
|
|
&i.BechAccountPrefix,
|
|
&i.BechValidatorPrefix,
|
|
&i.MainAssetSymbol,
|
|
&i.MainAssetDenom,
|
|
&i.StakingAssetSymbol,
|
|
&i.StakingAssetDenom,
|
|
&i.IsStakeEnabled,
|
|
&i.ChainImage,
|
|
&i.MainAssetImage,
|
|
&i.StakingAssetImage,
|
|
&i.ChainType,
|
|
&i.IsSupportMobileWallet,
|
|
&i.IsSupportExtensionWallet,
|
|
&i.IsSupportErc20,
|
|
&i.DescriptionEn,
|
|
&i.DescriptionKo,
|
|
&i.DescriptionJa,
|
|
&i.OriginGenesisTime,
|
|
&i.AccountType,
|
|
&i.BtcStaking,
|
|
&i.CosmosFeeInfo,
|
|
&i.EvmFeeInfo,
|
|
&i.LcdEndpoint,
|
|
&i.GrpcEndpoint,
|
|
&i.EvmRpcEndpoint,
|
|
&i.Explorer,
|
|
&i.About,
|
|
&i.Forum,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updatePrice = `-- name: UpdatePrice :one
|
|
UPDATE prices
|
|
SET
|
|
price_usd = ?,
|
|
price_btc = ?,
|
|
volume_24h_usd = ?,
|
|
market_cap_usd = ?,
|
|
available_supply = ?,
|
|
total_supply = ?,
|
|
max_supply = ?,
|
|
percent_change_1h = ?,
|
|
percent_change_24h = ?,
|
|
percent_change_7d = ?,
|
|
rank = ?,
|
|
last_updated = ?,
|
|
updated_at = CURRENT_TIMESTAMP
|
|
WHERE id = ?
|
|
AND deleted_at IS NULL
|
|
RETURNING id, created_at, updated_at, deleted_at, asset_id, price_usd, price_btc, volume_24h_usd, market_cap_usd, available_supply, total_supply, max_supply, percent_change_1h, percent_change_24h, percent_change_7d, rank, last_updated
|
|
`
|
|
|
|
type UpdatePriceParams struct {
|
|
PriceUsd sql.NullFloat64 `json:"price_usd"`
|
|
PriceBtc sql.NullFloat64 `json:"price_btc"`
|
|
Volume24hUsd sql.NullFloat64 `json:"volume_24h_usd"`
|
|
MarketCapUsd sql.NullFloat64 `json:"market_cap_usd"`
|
|
AvailableSupply sql.NullFloat64 `json:"available_supply"`
|
|
TotalSupply sql.NullFloat64 `json:"total_supply"`
|
|
MaxSupply sql.NullFloat64 `json:"max_supply"`
|
|
PercentChange1h sql.NullFloat64 `json:"percent_change_1h"`
|
|
PercentChange24h sql.NullFloat64 `json:"percent_change_24h"`
|
|
PercentChange7d sql.NullFloat64 `json:"percent_change_7d"`
|
|
Rank sql.NullInt64 `json:"rank"`
|
|
LastUpdated time.Time `json:"last_updated"`
|
|
ID string `json:"id"`
|
|
}
|
|
|
|
func (q *Queries) UpdatePrice(ctx context.Context, arg UpdatePriceParams) (Price, error) {
|
|
row := q.db.QueryRowContext(ctx, updatePrice,
|
|
arg.PriceUsd,
|
|
arg.PriceBtc,
|
|
arg.Volume24hUsd,
|
|
arg.MarketCapUsd,
|
|
arg.AvailableSupply,
|
|
arg.TotalSupply,
|
|
arg.MaxSupply,
|
|
arg.PercentChange1h,
|
|
arg.PercentChange24h,
|
|
arg.PercentChange7d,
|
|
arg.Rank,
|
|
arg.LastUpdated,
|
|
arg.ID,
|
|
)
|
|
var i Price
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.AssetID,
|
|
&i.PriceUsd,
|
|
&i.PriceBtc,
|
|
&i.Volume24hUsd,
|
|
&i.MarketCapUsd,
|
|
&i.AvailableSupply,
|
|
&i.TotalSupply,
|
|
&i.MaxSupply,
|
|
&i.PercentChange1h,
|
|
&i.PercentChange24h,
|
|
&i.PercentChange7d,
|
|
&i.Rank,
|
|
&i.LastUpdated,
|
|
)
|
|
return i, err
|
|
}
|
|
|
|
const updatePriceConversion = `-- name: UpdatePriceConversion :one
|
|
UPDATE price_conversions
|
|
SET
|
|
price = ?,
|
|
volume_24h = ?,
|
|
market_cap = ?,
|
|
last_updated = ?,
|
|
updated_at = CURRENT_TIMESTAMP
|
|
WHERE id = ?
|
|
AND deleted_at IS NULL
|
|
RETURNING id, created_at, updated_at, deleted_at, price_id, currency_code, price, volume_24h, market_cap, last_updated
|
|
`
|
|
|
|
type UpdatePriceConversionParams struct {
|
|
Price sql.NullFloat64 `json:"price"`
|
|
Volume24h sql.NullFloat64 `json:"volume_24h"`
|
|
MarketCap sql.NullFloat64 `json:"market_cap"`
|
|
LastUpdated time.Time `json:"last_updated"`
|
|
ID string `json:"id"`
|
|
}
|
|
|
|
func (q *Queries) UpdatePriceConversion(ctx context.Context, arg UpdatePriceConversionParams) (PriceConversion, error) {
|
|
row := q.db.QueryRowContext(ctx, updatePriceConversion,
|
|
arg.Price,
|
|
arg.Volume24h,
|
|
arg.MarketCap,
|
|
arg.LastUpdated,
|
|
arg.ID,
|
|
)
|
|
var i PriceConversion
|
|
err := row.Scan(
|
|
&i.ID,
|
|
&i.CreatedAt,
|
|
&i.UpdatedAt,
|
|
&i.DeletedAt,
|
|
&i.PriceID,
|
|
&i.CurrencyCode,
|
|
&i.Price,
|
|
&i.Volume24h,
|
|
&i.MarketCap,
|
|
&i.LastUpdated,
|
|
)
|
|
return i, err
|
|
}
|