Skip to content

Commit

Permalink
Merge pull request #404 from input-output-hk/feature/multi-asset
Browse files Browse the repository at this point in the history
Feature: Initial multi-asset support
  • Loading branch information
rhyslbw authored Jan 25, 2021
2 parents ef884f3 + 1b8b0cf commit 01ade07
Show file tree
Hide file tree
Showing 19 changed files with 672 additions and 68 deletions.
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ services:
environment:
- ALLOW_INTROSPECTION=true
- CACHE_ENABLED=true
- LOGGER_LEVEL=${LOGGER_LEVEL:-info}
expose:
- ${API_PORT:-3100}
ports:
Expand Down
86 changes: 86 additions & 0 deletions packages/api-cardano-db-hasura/hasura/project/metadata/tables.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,29 @@
filter: {}
limit: 2500
allow_aggregations: true
- table:
schema: public
name: Mint
object_relationships:
- name: transaction
using:
manual_configuration:
remote_table:
schema: public
name: Transaction
column_mapping:
tx_id: id
select_permissions:
- role: cardano-graphql
permission:
columns:
- assetId
- assetName
- policyId
- quantity
filter: {}
limit: 2500
allow_aggregations: true
- table:
schema: public
name: Reward
Expand Down Expand Up @@ -451,6 +474,34 @@
filter: {}
limit: 2500
allow_aggregations: true
- table:
schema: public
name: Token
configuration:
custom_root_fields:
select_aggregate: tokens_aggregate
select: tokens
custom_column_names: {}
object_relationships:
- name: transactionOutput
using:
manual_configuration:
remote_table:
schema: public
name: TransactionOutput
column_mapping:
tx_out_id: id
select_permissions:
- role: cardano-graphql
permission:
columns:
- assetId
- assetName
- policyId
- quantity
filter: {}
limit: 2500
allow_aggregations: true
- table:
schema: public
name: Transaction
Expand Down Expand Up @@ -485,6 +536,14 @@
name: tx_metadata
column_mapping:
id: tx_id
- name: mint
using:
manual_configuration:
remote_table:
schema: public
name: Mint
column_mapping:
id: tx_id
- name: outputs
using:
manual_configuration:
Expand Down Expand Up @@ -538,6 +597,15 @@
name: Transaction
column_mapping:
txHash: hash
array_relationships:
- name: tokens
using:
manual_configuration:
remote_table:
schema: public
name: Token
column_mapping:
source_tx_out_id: tx_out_id
select_permissions:
- role: cardano-graphql
permission:
Expand All @@ -562,6 +630,15 @@
name: Transaction
column_mapping:
txHash: hash
array_relationships:
- name: tokens
using:
manual_configuration:
remote_table:
schema: public
name: Token
column_mapping:
id: tx_out_id
select_permissions:
- role: cardano-graphql
permission:
Expand Down Expand Up @@ -590,6 +667,15 @@
name: Transaction
column_mapping:
txHash: hash
array_relationships:
- name: tokens
using:
manual_configuration:
remote_table:
schema: public
name: Token
column_mapping:
id: tx_out_id
select_permissions:
- role: cardano-graphql
permission:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ DROP VIEW IF EXISTS
"Cardano",
"Delegation",
"Epoch",
"Mint",
"ShelleyEpochProtocolParams",
"Reward",
"SlotLeader",
"StakeDeregistration",
"StakePool",
"StakeRegistration",
"StakePoolRetirement",
"Token",
"Transaction",
"TransactionInput",
"TransactionOutput",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,24 @@ SELECT
( SELECT pool_hash.hash_raw FROM pool_hash WHERE pool_hash.id = pool_id ) AS "pool_hash"
FROM epoch_stake;

CREATE VIEW "Mint" AS
SELECT
CONCAT(policy,name) as "assetId",
name as "assetName",
policy as "policyId",
quantity,
tx_id
FROM ma_tx_mint;

CREATE VIEW "Token" AS
SELECT
CONCAT(policy,name) as "assetId",
name as "assetName",
policy as "policyId",
quantity,
tx_out_id
FROM ma_tx_out;

CREATE VIEW "Transaction" AS
SELECT
block.hash AS "blockHash",
Expand All @@ -194,7 +212,8 @@ SELECT
source_tx_out.value,
tx.hash AS "txHash",
source_tx.hash AS "sourceTxHash",
tx_in.tx_out_index AS "sourceTxIndex"
tx_in.tx_out_index AS "sourceTxIndex",
source_tx_out.id AS source_tx_out_id
FROM
tx
JOIN tx_in
Expand All @@ -210,6 +229,7 @@ SELECT
address,
value,
tx.hash AS "txHash",
tx_out.id,
index
FROM tx
JOIN tx_out
Expand All @@ -219,6 +239,7 @@ CREATE VIEW "Utxo" AS SELECT
address,
value,
tx.hash AS "txHash",
tx_out.id,
index
FROM tx
JOIN tx_out
Expand Down Expand Up @@ -246,8 +267,8 @@ CREATE INDEX idx_block_hash
CREATE INDEX idx_tx_hash
ON tx(hash);

CREATE INDEX idx_tx_in_consuming_tx
ON tx_in(tx_out_id);
CREATE INDEX idx_tx_in_consuming_tx
ON tx_in(tx_out_id);

CREATE INDEX idx_tx_out_tx
ON tx_out(tx_id);
Expand All @@ -258,6 +279,7 @@ RETURNS SETOF "TransactionOutput" AS $$
"TransactionOutput".address,
"TransactionOutput".value,
"TransactionOutput"."txHash",
"TransactionOutput"."id",
"TransactionOutput".index
FROM tx
JOIN tx_out
Expand Down
Loading

0 comments on commit 01ade07

Please sign in to comment.