Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NFT Database Schema #2070

Merged
merged 9 commits into from
Jun 9, 2021
Merged

NFT Database Schema #2070

merged 9 commits into from
Jun 9, 2021

Conversation

ijungmann
Copy link
Contributor

@ijungmann ijungmann commented Jun 3, 2021

Detailed description:
Add Flyway migrations to support NFTs (based on NFT design doc)

  • Update token table with new values
  • Add nft and nft_transfer tables, indexes, etc.
  • Add new Response Codes

Which issue(s) this PR fixes:
Fixes #2056

Special notes for your reviewer:

Checklist

  • Documentation added
  • Tests updated

Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
@ijungmann ijungmann self-assigned this Jun 3, 2021
@ijungmann ijungmann added database Area: Database enhancement Type: New feature nft Non-Fungible Token P1 labels Jun 3, 2021
@ijungmann ijungmann added this to the Mirror 0.36.0 milestone Jun 3, 2021
Ian Jungmann added 2 commits June 4, 2021 11:04
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
@codecov
Copy link

codecov bot commented Jun 4, 2021

Codecov Report

Merging #2070 (1b1e55f) into master (126751e) will decrease coverage by 7.60%.
The diff coverage is 87.42%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master    #2070      +/-   ##
============================================
- Coverage     87.05%   79.44%   -7.61%     
- Complexity     1744     1919     +175     
============================================
  Files           315      377      +62     
  Lines          7731     9304    +1573     
  Branches        740      879     +139     
============================================
+ Hits           6730     7392     +662     
- Misses          772     1649     +877     
- Partials        229      263      +34     
Impacted Files Coverage Δ
...ensus/ConsensusCreateTopicTransactionSupplier.java 0.00% <ø> (ø)
...sus/ConsensusSubmitMessageTransactionSupplier.java 0.00% <0.00%> (ø)
...ensus/ConsensusUpdateTopicTransactionSupplier.java 0.00% <ø> (ø)
...er/schedule/ScheduleCreateTransactionSupplier.java 0.00% <ø> (ø)
...supplier/token/TokenCreateTransactionSupplier.java 0.00% <ø> (ø)
...supplier/token/TokenUpdateTransactionSupplier.java 0.00% <ø> (ø)
...ra/mirror/monitor/config/MonitorConfiguration.java 0.00% <0.00%> (ø)
...edera/mirror/monitor/publish/PublishException.java 0.00% <0.00%> (ø)
.../hedera/mirror/monitor/publish/PublishMetrics.java 0.00% <0.00%> (ø)
...a/mirror/monitor/publish/TransactionPublisher.java 1.09% <0.00%> (-0.04%) ⬇️
... and 181 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d5564f3...1b1e55f. Read the comment docs.

Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>

-- Update the token table
alter table token
add column max_supply bigint not null default 9223372036854775807,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Max long


-- Insert new response codes
insert into t_transaction_results (result, proto_id)
values ('ACCOUNT_EXPIRED_AND_PENDING_REMOVAL', 223),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one isn't part of the NFT protobufs change, but I noticed we were missing it.

@ijungmann ijungmann requested a review from a team June 7, 2021 15:21
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
@ijungmann ijungmann marked this pull request as ready for review June 7, 2021 15:24
Copy link
Contributor

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some discrepancies on the type. Also left some nits.

alter table token
add column max_supply bigint not null default 9223372036854775807, -- max long
add column supply_type character varying(10) not null default 'INFINITE',
add column type character varying(20) not null default 'NON_FUNGIBLE_UNIQUE';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the default should be FUNGIBLE_COMMON

Suggested change
add column type character varying(20) not null default 'NON_FUNGIBLE_UNIQUE';
add column type character varying(20) not null default 'FUNGIBLE_COMMON';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Correct, not sure why I got that swapped. Fixed.

);
create unique index if not exists nft__token_id_serial_num
on nft (token_id, serial_number);
comment on table nft is 'NFT';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Something more suggestive. Template suggestions below that you can modify.

Suggested change
comment on table nft is 'NFT';
comment on table nft is 'Non Fungible Tokens (NFTs) minted on network';

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like that, just made Non Fungible into Non-Fungible

symbol character varying(100) not null,
total_supply bigint not null default 0,
treasury_account_id bigint not null,
type character varying(20) not null default 'NON_FUNGIBLE_UNIQUE',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing above, this should be FUNGIBLE_COMMON right?

Suggested change
type character varying(20) not null default 'NON_FUNGIBLE_UNIQUE',
type character varying(20) not null default 'FUNGIBLE_COMMON',

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep, fixed.

Ian Jungmann added 4 commits June 8, 2021 17:28
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
Signed-off-by: Ian Jungmann <ian.jungmann@hedera.com>
@sonarcloud
Copy link

sonarcloud bot commented Jun 8, 2021

Comment on lines +6 to +9
-- Create enums for tables
CREATE TYPE token_supply_type AS ENUM ('INFINITE', 'FINITE');
CREATE TYPE token_type AS ENUM ('FUNGIBLE_COMMON', 'NON_FUNGIBLE_UNIQUE');

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any opinions on creating all enums at the top vs. creating them in their corresponding table sections?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Create at top in one group as you're doing so that the data types exist prior to table definitions.

Copy link
Contributor

@Nana-EC Nana-EC left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@steven-sheehy steven-sheehy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Let's get it in and unblock the next tasks.

@ijungmann ijungmann merged commit c89cda8 into master Jun 9, 2021
@ijungmann ijungmann deleted the nft_db branch June 9, 2021 02:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
database Area: Database enhancement Type: New feature nft Non-Fungible Token P1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

NFT database schema
3 participants