queries

package
v0.6.12 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 15, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Status = `` /* 151-byte string literal not displayed */

	NodeHeight = `
		SELECT height
			FROM chain.latest_node_heights
			WHERE layer=$1`

	TotalSupply = `
		SELECT total_supply
			FROM chain.blocks
			ORDER BY height DESC
			LIMIT 1`

	AddressesTotalBalance = `
		SELECT
			COALESCE(SUM(total_balance), 0)
			FROM views.accounts_list
			WHERE address = ANY($1)`

	Blocks = `` /* 1229-byte string literal not displayed */

	// When no filtering on related account, avoid the join altogether.
	TransactionsNoRelated = transactionsSelect + `
			FROM chain.transactions AS t
			JOIN chain.blocks AS b ON
				t.block = b.height
			WHERE
				($1::text IS NULL OR t.tx_hash = $1::text) AND
				($2::bigint IS NULL OR t.block = $2::bigint) AND
				($3::text IS NULL OR t.method = $3::text) AND
				($4::text IS NULL OR t.sender = $4::text) AND
				($5::timestamptz IS NULL OR b.time >= $5::timestamptz) AND
				($6::timestamptz IS NULL OR b.time < $6::timestamptz)
			ORDER BY t.block DESC, t.tx_index
			LIMIT $7::bigint
			OFFSET $8::bigint`

	// When filtering on related account, filter on the related account table.
	TransactionsWithRelated = `
		WITH filtered AS (
			SELECT
				art.tx_block, art.tx_index
			FROM
				chain.accounts_related_transactions art
			WHERE
				($2::bigint IS NULL OR art.tx_block = $2::bigint) AND
				($3::text IS NULL OR art.method = $3::text) AND
				($4::text IS NULL OR art.account_address = $4::text)
			ORDER BY art.tx_block DESC, art.tx_index
			LIMIT $7::bigint
			OFFSET $8::bigint
		)` +
		transactionsSelect + `
		FROM filtered AS art
		JOIN chain.transactions AS t ON
			t.block = art.tx_block AND
			t.tx_index = art.tx_index
		JOIN chain.blocks AS b ON
			t.block = b.height
		WHERE
			-- No filtering on tx_hash.
			($1::text IS NULL OR TRUE) AND
			-- No filtering on timestamps.
			($5::timestamptz IS NULL OR TRUE) AND
			($6::timestamptz IS NULL OR TRUE)`

	Events = `` /* 1035-byte string literal not displayed */

	RoothashMessages = `` /* 400-byte string literal not displayed */

	Entities = `
		SELECT id, address
			FROM chain.entities
		ORDER BY id
		LIMIT $1::bigint
		OFFSET $2::bigint`

	Entity = `
		SELECT id, address
			FROM chain.entities
			WHERE address = $1::text`

	EntityNodeIds = `` /* 173-byte string literal not displayed */

	EntityNodes = `` /* 294-byte string literal not displayed */

	EntityNode = `` /* 244-byte string literal not displayed */

	Account = `` /* 982-byte string literal not displayed */

	// Uses periodically computed view.
	Accounts = `` /* 290-byte string literal not displayed */

	AccountAllowances = `
		SELECT beneficiary, allowance
			FROM chain.allowances
			WHERE owner = $1::text`

	Delegations = `` /* 286-byte string literal not displayed */

	DelegationsTo = `` /* 486-byte string literal not displayed */

	DebondingDelegations = `` /* 336-byte string literal not displayed */

	DebondingDelegationsTo = `` /* 542-byte string literal not displayed */

	Epochs = `` /* 251-byte string literal not displayed */

	Proposals = `` /* 421-byte string literal not displayed */

	Proposal = `` /* 287-byte string literal not displayed */

	ProposalVotes = `` /* 261-byte string literal not displayed */

	LatestEpochStart = `
		SELECT id, start_height
			FROM chain.epochs
			ORDER BY id DESC
			LIMIT 1`

	ValidatorsAggStats = `` /* 433-byte string literal not displayed */

	ValidatorLast100BlocksSigned = `` /* 208-byte string literal not displayed */

	ValidatorsData = `` /* 4256-byte string literal not displayed */

	ValidatorHistory = `` /* 666-byte string literal not displayed */

	RuntimeBlocks = `` /* 483-byte string literal not displayed */

	RuntimeBlock = `` /* 150-byte string literal not displayed */

	RuntimeTransactionsNoRelated = runtimeTxSelect + `
		FROM chain.runtime_transactions AS txs` +
		runtimeTxCommonJoins + `
		WHERE
			txs.runtime = $1 AND
			($2::bigint IS NULL OR txs.round = $2::bigint) AND
			($3::bigint IS NULL OR txs.tx_index = $3::bigint) AND
			($4::text IS NULL OR txs.tx_hash = $4::text OR txs.tx_eth_hash = $4::text) AND
			-- No filtering on related address.
			($5::text IS NULL OR true) AND
			-- No filtering on related rofl.
			($6::text IS NULL OR true) AND
			(
				-- No filtering on method.
				$7::text IS NULL OR
				(
					-- Special case to return are 'likely to be native transfers'.
					('native_transfers' = $7::text AND txs.likely_native_transfer) OR
					-- Special case to return all evm.Calls that are likely not native transfers.
					('evm.Call_no_native' = $7::text AND txs.method = 'evm.Call' AND NOT txs.likely_native_transfer) OR
					-- Regular case.
					(txs.method = $7::text)
				)
			) AND
			($8::timestamptz IS NULL OR txs.timestamp >= $8::timestamptz) AND
			($9::timestamptz IS NULL OR txs.timestamp < $9::timestamptz)
		ORDER BY txs.round DESC, txs.tx_index DESC
		LIMIT $10::bigint
		OFFSET $11::bigint`

	RuntimeTransactionsRelatedAddr = `
		WITH filtered AS (
			SELECT
				rel.runtime, rel.tx_round, rel.tx_index
			FROM
				chain.runtime_related_transactions AS rel
			WHERE
				rel.runtime = $1::runtime AND
				($2::bigint IS NULL OR rel.tx_round = $2::bigint) AND
				($3::bigint IS NULL OR rel.tx_index = $3::bigint) AND
				($5::text IS NULL OR rel.account_address = $5::text) AND
				(
					-- No filtering on method.
					$7::text IS NULL OR
					(
						-- Special case to return are 'likely to be native transfers'.
						('native_transfers' = $7::text AND rel.likely_native_transfer) OR
						-- Special case to return all evm.Calls that are likely not native transfers.
						('evm.Call_no_native' = $7::text AND rel.method = 'evm.Call' AND NOT rel.likely_native_transfer) OR
						-- Regular case.
						(rel.method = $7::text)
					)
				)
			ORDER BY rel.tx_round DESC, rel.tx_index DESC
			LIMIT $10::bigint
			OFFSET $11::bigint
		)` +
		runtimeTxSelect + `
		FROM filtered AS rel
		JOIN chain.runtime_transactions AS txs ON
			rel.runtime = txs.runtime AND
			rel.tx_round = txs.round AND
			rel.tx_index = txs.tx_index` +
		runtimeTxCommonJoins + `
		WHERE
			-- No filtering on tx_hash.
			($4::text IS NULL OR TRUE) AND
			-- No filtering on related rofl.
			($6::text IS NULL OR true) AND
			-- No filtering on timestamps.
			($8::timestamptz IS NULL OR TRUE) AND
			($9::timestamptz IS NULL OR TRUE)`

	RuntimeTransactionsRelatedRofl = `
		WITH filtered AS (
			SELECT
				rel.runtime, rel.tx_round, rel.tx_index
			FROM
				chain.rofl_related_transactions AS rel
			WHERE
				rel.runtime = $1::runtime AND
				($2::bigint IS NULL OR rel.tx_round = $2::bigint) AND
				($3::bigint IS NULL OR rel.tx_index = $3::bigint) AND
				($6::text IS NULL OR rel.app_id = $6::text) AND
				(
					-- No filtering on method.
					$7::text IS NULL OR
					(
						-- Special case to return are 'likely to be native transfers'.
						('native_transfers' = $7::text AND rel.likely_native_transfer) OR
						-- Special case to return all evm.Calls that are likely not native transfers.
						('evm.Call_no_native' = $7::text AND rel.method = 'evm.Call' AND NOT rel.likely_native_transfer) OR
						-- Regular case.
						(rel.method = $7::text)
					)
				)
			ORDER BY rel.tx_round DESC, rel.tx_index DESC
			LIMIT $10::bigint
			OFFSET $11::bigint
		)` +
		runtimeTxSelect + `
		FROM filtered AS rel
		JOIN chain.runtime_transactions AS txs ON
			rel.runtime = txs.runtime AND
			rel.tx_round = txs.round AND
			rel.tx_index = txs.tx_index` +
		runtimeTxCommonJoins + `
		WHERE
			-- No filtering on tx_hash.
			($4::text IS NULL OR TRUE) AND
			-- No filtering on related address.
			($5::text IS NULL OR true) AND
			-- No filtering on timestamps.
			($8::timestamptz IS NULL OR TRUE) AND
			($9::timestamptz IS NULL OR TRUE)`

	RuntimeEvents = `` /* 3222-byte string literal not displayed */

	RuntimeEvmContract = `` /* 672-byte string literal not displayed */

	AddressPreimage = `
		SELECT context_identifier, context_version, address_data
			FROM chain.address_preimages
			WHERE address = $1::text`

	RuntimeAccountStats = `` /* 132-byte string literal not displayed */

	//nolint:gosec // Linter suspects a hardcoded access token.
	EvmTokens = `` /* 5116-byte string literal not displayed */

	//nolint:gosec // Linter suspects a hardcoded credentials token.
	EvmTokenHolders = `` /* 579-byte string literal not displayed */

	EvmNfts = `` /* 1865-byte string literal not displayed */

	AccountRuntimeSdkBalances = `` /* 325-byte string literal not displayed */

	AccountRuntimeEvmBalances = `` /* 1105-byte string literal not displayed */

	RuntimeActiveNodes = `
		SELECT COUNT(*) AS active_nodes
		FROM chain.runtime_nodes
		WHERE runtime_id = $1::text`

	RuntimeRoflApps = `` /* 3653-byte string literal not displayed */

	RuntimeRoflAppInstances = `` /* 308-byte string literal not displayed */

	RuntimeRoflAppInstanceTransactions = `
		WITH filtered AS (
			SELECT
				rel.runtime, rel.tx_round, rel.tx_index
			FROM
				chain.rofl_instance_transactions as rel
			WHERE
				rel.runtime = $1 AND
				rel.app_id = $2::text AND
				($3::text IS NULL OR rel.rak = $3::text) AND
				(
					-- No filtering on method.
					$4::text IS NULL OR
					(
						-- Special case to return are 'likely to be native transfers'.
						('native_transfers' = $4::text AND rel.likely_native_transfer) OR
						-- Special case to return all evm.Calls that are likely not native transfers.
						('evm.Call_no_native' = $4::text AND rel.method = 'evm.Call' AND NOT rel.likely_native_transfer) OR
						-- Regular case.
						(rel.method = $4::text)
					)
				)
			ORDER BY rel.tx_round DESC, rel.tx_index DESC
			LIMIT $5::bigint
			OFFSET $6::bigint
		)` +
		runtimeTxSelect + `
		FROM filtered as rel
		JOIN chain.runtime_transactions AS txs ON
			txs.runtime = rel.runtime AND
			txs.round = rel.tx_round AND
			txs.tx_index = rel.tx_index` +
		runtimeTxCommonJoins

	// FineTxVolumes returns the fine-grained query for 5-minute sampled tx volume windows.
	FineTxVolumes = `` /* 153-byte string literal not displayed */

	// FineDailyTxVolumes returns the query for daily tx volume windows.
	FineDailyTxVolumes = `` /* 154-byte string literal not displayed */

	// DailyTxVolumes returns the query for daily sampled daily tx volume windows.
	DailyTxVolumes = `` /* 211-byte string literal not displayed */

	// FineDailyActiveAccounts returns the fine-grained query for daily active account windows.
	FineDailyActiveAccounts = `` /* 166-byte string literal not displayed */

	// DailyActiveAccounts returns the query for daily sampled daily active account windows.
	DailyActiveAccounts = `` /* 223-byte string literal not displayed */

)

Variables

This section is empty.

Functions

func TotalCountQuery

func TotalCountQuery(inner string) string

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL