From ca6b3a4bb0ffd4149eb9d565af6c8e891765c574 Mon Sep 17 00:00:00 2001 From: Ilya Oskin Date: Sun, 30 May 2021 19:35:04 +0300 Subject: [PATCH] Assets duplication allowed. (#135) * Assets duplication allowed. * Unconfirmed assets duplication allowed. --- build.sbt | 2 +- .../explorer-core/src/main/resources/db/V8__Schema.sql | 4 ++-- .../ergoplatform/explorer/db/queries/AssetQuerySet.scala | 8 ++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/build.sbt b/build.sbt index e96e6182b..448808761 100644 --- a/build.sbt +++ b/build.sbt @@ -2,7 +2,7 @@ lazy val commonSettings = Seq( scalacOptions ++= commonScalacOptions, scalaVersion := "2.12.13", organization := "org.ergoplatform", - version := "8.0.0-M2", + version := "8.0.0-M3", resolvers += Resolver.sonatypeRepo("public"), resolvers += Resolver.sonatypeRepo("snapshots"), libraryDependencies ++= dependencies.Testing ++ dependencies.CompilerPlugins, diff --git a/modules/explorer-core/src/main/resources/db/V8__Schema.sql b/modules/explorer-core/src/main/resources/db/V8__Schema.sql index e7ea64270..f1bb0271c 100644 --- a/modules/explorer-core/src/main/resources/db/V8__Schema.sql +++ b/modules/explorer-core/src/main/resources/db/V8__Schema.sql @@ -162,7 +162,7 @@ CREATE TABLE node_assets header_id VARCHAR(64) NOT NULL, index INTEGER NOT NULL, value BIGINT NOT NULL, - PRIMARY KEY (token_id, box_id, header_id) + PRIMARY KEY (index, token_id, box_id, header_id) ); CREATE INDEX "node_assets__box_id" ON node_assets (box_id); @@ -260,7 +260,7 @@ CREATE TABLE node_u_assets box_id VARCHAR(64) NOT NULL REFERENCES node_u_outputs (box_id) ON DELETE CASCADE, index INTEGER NOT NULL, value BIGINT NOT NULL, - PRIMARY KEY (token_id, box_id) + PRIMARY KEY (index, token_id, box_id) ); CREATE INDEX "node_u_assets__box_id" ON node_u_assets (box_id); diff --git a/modules/explorer-core/src/main/scala/org/ergoplatform/explorer/db/queries/AssetQuerySet.scala b/modules/explorer-core/src/main/scala/org/ergoplatform/explorer/db/queries/AssetQuerySet.scala index b9260be0c..a1b659eb7 100644 --- a/modules/explorer-core/src/main/scala/org/ergoplatform/explorer/db/queries/AssetQuerySet.scala +++ b/modules/explorer-core/src/main/scala/org/ergoplatform/explorer/db/queries/AssetQuerySet.scala @@ -26,7 +26,7 @@ object AssetQuerySet extends QuerySet { def getAllByBoxId(boxId: BoxId)(implicit lh: LogHandler): Query0[ExtendedAsset] = sql""" - |select distinct on (a.token_id, a.box_id) + |select distinct on (a.index, a.token_id, a.box_id) | a.token_id, | a.box_id, | a.header_id, @@ -42,7 +42,7 @@ object AssetQuerySet extends QuerySet { def getAllByBoxIds(boxIds: NonEmptyList[BoxId])(implicit lh: LogHandler): Query0[ExtendedAsset] = (sql""" - |select distinct on (a.token_id, a.box_id) + |select distinct on (a.index, a.token_id, a.box_id) | a.token_id, | a.box_id, | a.header_id, @@ -59,7 +59,7 @@ object AssetQuerySet extends QuerySet { def getAllMainUnspentByErgoTree(ergoTree: HexString)(implicit lh: LogHandler): Query0[ExtendedAsset] = sql""" - |select distinct on (a.token_id, a.box_id) + |select distinct on (a.index, a.token_id, a.box_id) | a.token_id, | a.box_id, | a.header_id, @@ -85,7 +85,7 @@ object AssetQuerySet extends QuerySet { sql""" |select agg.token_id, agg.total, t.name, t.decimals from ( | select ia.token_id, sum(ia.value) as total from ( - | select distinct on (a.token_id, a.box_id) + | select distinct on (a.index, a.token_id, a.box_id) | a.token_id, | a.box_id, | a.value