diff --git a/.vscode/launch.json b/.vscode/launch.json index b9cd1a3..e13db9b 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -10,6 +10,12 @@ "type": "dart", "program": "bin/server.dart", "cwd": "${workspaceFolder}" + },{ + "name": "Test", + "request": "launch", + "type": "dart", + "cwd": "${workspaceFolder}", + "program": "bin/address.dart" } ] } \ No newline at end of file diff --git a/bin/server.dart b/bin/server.dart index 57bd1d6..f28e885 100644 --- a/bin/server.dart +++ b/bin/server.dart @@ -2,9 +2,12 @@ // for details. All rights reserved. Use of this source code is governed by a // BSD-style license that can be found in the LICENSE file. +// ignore_for_file: prefer_expression_function_bodies + import 'dart:convert'; import 'dart:io'; +import 'package:mustache_template/mustache.dart'; import 'package:shelf/shelf.dart'; import 'package:shelf/shelf_io.dart' as shelf_io; import 'package:shelf_router/shelf_router.dart' as shelf_router; @@ -39,12 +42,17 @@ Future main() async { } // Serve files from the file system. -final _staticHandler = - shelf_static.createStaticHandler('../frontend', defaultDocument: 'index.html'); +final _staticHandler = shelf_static.createStaticHandler( + '../frontend', + defaultDocument: 'index.html', +); // Router instance to handler requests. final _router = shelf_router.Router() - ..get('/helloworld', _helloWorldHandler) + ..get('/search', _search) + ..get('/address/
', _address) + ..get('/transaction/', _transaction) + ..get('/error/', _error) ..get( '/time', (request) => Response.ok(DateTime.now().toUtc().toIso8601String()), @@ -52,7 +60,344 @@ final _router = shelf_router.Router() ..get('/info.json', _infoHandler) ..get('/sum//', _sumHandler); -Response _helloWorldHandler(Request request) => Response.ok('Hello, World!'); +Future _search(Request request) async { + final asset = request.url.queryParameters["q"]; + if (asset == "0xF0245F6251Bef9447A08766b9DA2B07b28aD80B0") { + // await Future.delayed(const Duration(seconds: 3)); + // return Response.movedPermanently("/address"); + return Response(308, headers: {"location": "/address/$asset"}); + } else if (asset == + "0x25eb25e730b5c0f805ec3695040b6c8a2e1ec68effc884c3ec5b7e6dd038d1a8") { + return Response(308, headers: {"location": "/transaction/$asset"}); + } else { + return Response(308, headers: {"location": "/error/$asset"}); + } +} + +Future _address(Request request, String address) async { + final String source = await File('../frontend/address-1.html').readAsString(); + + var template = Template(source, name: 'address'); + + var output = template.renderString({ + "address": address, + "assets": [ + { + "id": "BNB", + "balance": [ + { + "amount": 0.10038, + "value": 5, + } + ], + "blockchains": [ + { + "blockchain": "Binance Smart Coin", + "token": false, + "balance": [ + { + "amount": 0.00038, + "value": 1, + } + ], + "alternatives": [ + { + "name": "com.bscscan", + "favicon": "https://bscscan.com/images/favicon.ico", + "link": + "https://bscscan.com/address/0x2b6828f4f227953fb36f42bda830b457afdc1c5e" + }, + { + "name": "io.binance.mintscan", + "favicon": "https://binance.mintscan.io/favicon.ico", + "link": + "https://binance.mintscan.io/account/0x2b6828f4f227953fb36f42bda830b457afdc1c5e" + }, + ], + }, + { + "blockchain": "Ethereum", + "token": true, + "balance": [ + { + "amount": 0.1, + "value": 4, + } + ], + "alternatives": [ + { + "name": "io.etherscan", + "favicon": "https://etherscan.io/images/favicon3.ico", + "link": + "https://etherscan.io/token/0xB8c77482e45F1F44dE1745F52C74426C631bDD52?a=0x2b6828f4f227953fb36f42bda830b457afdc1c5e" + }, + { + "name": "io.explorer.bitquery", + "favicon": + "https://bitquery.io/wp-content/uploads/2020/09/favicon.png", + "link": + "https://explorer.bitquery.io/bsc/address/0x2b6828f4f227953fb36f42bda830b457afdc1c5e" + }, + ] + } + ], + "name": "Binance Coin" + }, + { + "id": "BUSD-T", + "balance": [ + { + "amount": 0.219, + "value": 2, + } + ], + "blockchains": [ + { + "blockchain": "Ethereum", + "token": true, + "balance": [ + { + "amount": 0.219, + "value": 2, + } + ], + "alternatives": [ + { + "name": "com.bscscan", + "favicon": "https://bscscan.com/images/favicon.ico", + "link": + "https://bscscan.com/token/0x55d398326f99059ff775485246999027b3197955?a=0x2b6828f4f227953fb36f42bda830b457afdc1c5e" + }, + { + "name": "io.explorer.bitquery", + "favicon": + "https://bitquery.io/wp-content/uploads/2020/09/favicon.png", + "link": + "https://explorer.bitquery.io/bsc/token/0x2b6828f4f227953fb36f42bda830b457afdc1c5e" + }, + ], + } + ], + "name": "BUSD Token" + }, + { + "id": "ETH", + "balance": [ + { + "amount": 5.06587, + "value": 15, + } + ], + "blockchains": [ + { + "blockchain": "Ethereum", + "token": false, + "balance": [ + { + "amount": 4.06587, + "value": 10, + } + ], + "alternatives": [ + { + "name": "io.etherscan", + "favicon": "https://etherscan.io/images/favicon3.ico", + "link": + "https://etherscan.io/address/0x2b6828f4f227953fb36f42bda830b457afdc1c5e" + }, + { + "name": "io.ethplorer", + "favicon": "https://ethplorer.io/icons-29d214c3/favicon.ico", + "link": + "https://ethplorer.io/address/0x2b6828f4f227953fb36f42bda830b457afdc1c5e" + }, + { + "name": "org.etherchain", + "favicon": "https://beaconcha.in/favicon.ico", + "link": + "https://etherchain.org/account/0x2b6828f4f227953fb36f42bda830b457afdc1c5e" + }, + ], + }, + { + "blockchain": "Binance Smart Coin", + "token": true, + "balance": [ + { + "amount": 1.06587, + "value": 5, + } + ], + "alternatives": [ + { + "name": "com.bscscan", + "favicon": "https://bscscan.com/images/favicon.ico", + "link": + "https://bscscan.com/token/0x2170ed0880ac9a755fd29b2688956bd959f933f8?a=0x2b6828f4f227953fb36f42bda830b457afdc1c5e" + }, + ] + } + ], + "name": "Ether" + }, + { + "id": "MATIC", + "balance": [ + { + "amount": 56.124, + "value": 25, + } + ], + "blockchains": [ + { + "blockchain": "Ethereum", + "token": true, + "balance": [ + { + "amount": 50.124, + "value": 15, + } + ], + "alternatives": [ + { + "name": "com.blockchain", + "favicon": + "https://loutre.blockchair.io/assets/favicons/icon.svg", + "link": + "https://blockchair.com/ethereum/erc-20/token/0x2b6828f4f227953fb36f42bda830b457afdc1c5e" + }, + { + "name": "io.explorer.bitquery", + "favicon": + "https://bitquery.io/wp-content/uploads/2020/09/favicon.png", + "link": + "https://explorer.bitquery.io/matic/address/0x2b6828f4f227953fb36f42bda830b457afdc1c5e" + }, + ], + }, + { + "blockchain": "Polygon", + "token": false, + "balance": [ + { + "amount": 6, + "value": 10, + } + ], + "alternatives": [ + { + "name": "com.polygonscan", + "favicon": "https://polygonscan.com/images/favicon.ico", + "link": + "https://polygonscan.com/address/0x2b6828f4f227953fb36f42bda830b457afdc1c5e" + }, + ] + } + ], + "name": "Polygon" + }, + { + "id": "USDT", + "balance": [ + { + "amount": 39, + "value": 25, + } + ], + "blockchains": [ + { + "blockchain": "Ethereum", + "token": true, + "balance": [ + { + "amount": 30, + "value": 15, + } + ], + "alternatives": [ + { + "name": "io.etherscan", + "favicon": "https://etherscan.io/images/favicon3.ico", + "link": + "https://etherscan.io/token/0xdac17f958d2ee523a2206206994597c13d831ec7?a=0x2b6828f4f227953fb36f42bda830b457afdc1c5e" + }, + { + "name": "io.ethplorer", + "favicon": "https://ethplorer.io/icons-29d214c3/favicon.ico", + "link": + "https://ethplorer.io/address/0x2b6828f4f227953fb36f42bda830b457afdc1c5e" + }, + { + "name": "org.etherchain", + "favicon": "https://beaconcha.in/favicon.ico", + "link": + "https://etherchain.org/account/0x2b6828f4f227953fb36f42bda830b457afdc1c5e" + }, + ], + }, + { + "blockchain": "Tron", + "token": true, + "balance": [ + { + "amount": 9, + "value": 10, + } + ], + "alternatives": [ + { + "name": "org.tronscan", + "favicon": "https://tronscan.org/favicon.png?v=2", + "link": + "https://tronscan.org/#/address/0x2b6828f4f227953fb36f42bda830b457afdc1c5e/" + }, + ] + } + ], + "name": "Tether" + } + ] + }); + + return Response.ok(output, headers: {"content-type": "text/html"}); +} + +Future _transaction(Request request, String transaction) async { + final String source = + await File('../frontend/transaction.html').readAsString(); + + var template = Template(source, name: 'transaction'); + + var output = template.renderString({ + "transaction": transaction, + "explorers": [ + { + "name": "io.etherscan", + "favicon": "https://etherscan.io/images/favicon3.ico", + "link": + "https://etherscan.io/token/0xB8c77482e45F1F44dE1745F52C74426C631bDD52?a=0x2b6828f4f227953fb36f42bda830b457afdc1c5e" + }, + { + "name": "io.ethplorer", + "favicon": "https://ethplorer.io/icons-29d214c3/favicon.ico", + "link": + "https://ethplorer.io/address/0x2b6828f4f227953fb36f42bda830b457afdc1c5e" + }, + ] + }); + + return Response.ok(output, headers: {"content-type": "text/html"}); +} + +Future _error(Request request, String error) async { + final String source = await File('../frontend/error.html').readAsString(); + + var template = Template(source, name: 'error'); + + var output = template.renderString({"error": error}); + + return Response.ok(output, headers: {"content-type": "text/html"}); +} String _jsonEncode(Object? data) => const JsonEncoder.withIndent(' ').convert(data); diff --git a/database/address.sql b/database/address.sql new file mode 100644 index 0000000..c30446f --- /dev/null +++ b/database/address.sql @@ -0,0 +1,18 @@ +CREATE SEQUENCE "address_id_seq" START 1; + +CREATE TABLE "address" ( + "id" BIGINT PRIMARY KEY NOT NULL DEFAULT NEXTVAL('address_id_seq'), + "address" BYTEA NOT NULL, + "balance" NUMERIC(48,24), + "transaction_id" BIGINT NOT NULL, + CONSTRAINT "fk__address__block" FOREIGN KEY ("transaction_id") REFERENCES "transaction" ("id") +); + + +-- INSERT INTO public.address( +-- address, balance, transaction_id) +-- VALUES (('TYL7z7VSVRShLoJ6YRQMA4t9pSECt9ZLtr'::bytea), 997224171.14, 12), +-- (('TLbkcH7QLcULY8dpPAbD9EYGLUWKbeRxuB'::bytea), 997224171.15, 13), +-- (('TFKSWmnRJkzCfWUr56DQ1zqGCxZLW9dKSv'::bytea), 997224171.16, 14), +-- (('3FZbgi29cpjq2GjdwV8eyHuJJnkLtktZc5'::bytea), 0.01847823, 15), +-- (('3FZbgi29cpjq2GjdwV8eyHuJJnkLtktZd8'::bytea), 0.01847824, 13); \ No newline at end of file diff --git a/database/block.sql b/database/block.sql new file mode 100644 index 0000000..a116ffb --- /dev/null +++ b/database/block.sql @@ -0,0 +1,25 @@ +CREATE SEQUENCE "block_id_seq" START 1; + +CREATE TABLE "block" ( + "id" BIGINT PRIMARY KEY NOT NULL DEFAULT NEXTVAL('block_id_seq'), + "number" BIGINT NOT NULL, + "hash" BYTEA NOT NULL, + "parent_hash" BYTEA NOT NULL, + "blockchain_id" BIGINT NOT NULL, + CONSTRAINT "fk__block__blockchain" FOREIGN KEY ("blockchain_id") REFERENCES "blockchain" ("id") +); + +-- ALTER TABLE "block" ALTER COLUMN "id" SET DEFAULT NEXTVAL('block_id_seq'); + +-- INSERT INTO public.block( +-- "number", hash, parent_hash, blockchain_id) +-- VALUES (567789, ('\x00000000030a4e13565e8e89e26f838c62816460fb2b3f76b8f654aa802e37ce'::bytea), ('\x00000000030a4e12ad81558fbc78f10e1c38c7c64114e83150438c029c820424'::bytea), 1); + +-- INSERT INTO public.block( +-- "number", hash, parent_hash, blockchain_id) +-- VALUES (51090247, ('\x00000000030b934bce29e0d17d630fda98333daeafa24eb250f2ff06b484f244'::bytea), ('\x00000000030b934a61d20c4d88ab8414448a44f205db2d54e4a256c2fd3b4f0a'::bytea), 1), +-- (51090258, ('\x00000000030b93ff8628b8ed45ffe851d847401d91005c5ee46334a0717c2f2f'::bytea), ('\x00000000030b93fe787c1b89044acdb1ce7eb113b5d93cfb1101bc1644fb86c9'::bytea), 1), +-- (51090257, ('\x00000000030b949b63ed86e9409c03d55547298fca788cca5c927f99051834ee'::bytea), ('\x00000000030b949a41d3e50cb990f5af7a03951977faecbafc7803a21133441d'::bytea), 1), +-- (51090195, ('\x00000000030b94a32a799b9e4c7b6d5319a994f78857f51fe4cdab543ca120bb'::bytea), ('\x00000000030b94a20867d271c2e0552f2188298d4b3d849c4546a4e33ae845f5'::bytea), 1), +-- (789384, ('\x00000000000000000001ff4178367363678156ce86d7c4a8a5b35457bb1780df'::bytea), ('\x9a3147a6319f4f8592e9a9b3541dbfd318af34a8a6441d59ac7e549c74e607ad'::bytea), 2), +-- (789373, ('\x00000000000000000000343505c376a3913da102c0bf3df22b42d573e2cb2e64'::bytea), ('\x201e77e86a962bb6b532b9e398a7e1f2047bff1fa87f1f5e6ffd5eb1576feb9f'::bytea), 2); \ No newline at end of file diff --git a/database/blockchain.sql b/database/blockchain.sql new file mode 100644 index 0000000..7082c8a --- /dev/null +++ b/database/blockchain.sql @@ -0,0 +1,19 @@ +CREATE SEQUENCE "blockchain_id_seq" START 1; + +CREATE TABLE "blockchain" ( + "id" BIGINT PRIMARY KEY NOT NULL DEFAULT NEXTVAL('blockchain_id_seq'), + "name" CHARACTER VARYING(100) NOT NULL, + -- "explorer_id" BIGINT NOT NULL, + -- CONSTRAINT "fk__explorer__block" FOREIGN KEY ("explorer_id") REFERENCES "explorer" ("id") +); + + +-- INSERT INTO public.blockchain( +-- name) +-- VALUES ('Bitcoin'), +-- ('Litecoin'), +-- ('Ethereum'), +-- ('TRON'), +-- ('Solana'), +-- ('Cardano'), +-- ('Polygon'); diff --git a/database/explorer.sql b/database/explorer.sql new file mode 100644 index 0000000..ec6e6c2 --- /dev/null +++ b/database/explorer.sql @@ -0,0 +1,29 @@ +CREATE SEQUENCE "explorer_id_seq" START 1; +CREATE TABLE "explorer" ( + "id" BIGINT PRIMARY KEY NOT NULL DEFAULT NEXTVAL('explorer_id_seq'), + "name" CHARACTER VARYING(100) NOT NULL +); +INSERT INTO public.explorer(name) +VALUES ('Blockchain'), + ('Blockcypher'), + ('BinancemintscanExplorer'), + ('BitqueryExplorer'), + ('BscscanExplorer'), + ('EtherscanExplorer'), + ('BitinfochartsExplorer'), + ('BlockchairExplorer'), + ('BlockexplorerExplorer'), + ('BtcExplorer'), + ('ChainzcryptoidExplorer'), + ('DashblockExplorer'), + ('DogechainExplorer'), + ('EtherchainExplorer'), + ('EtherscanExplorer'), + ('EthplorerExplorer'), + ('LitecoinblockExplorer'), + ('PolygonscanExplorer'), + ('TronscanExplorer'), + + + + \ No newline at end of file diff --git a/database/explorer_spec.sql b/database/explorer_spec.sql new file mode 100644 index 0000000..7b6064f --- /dev/null +++ b/database/explorer_spec.sql @@ -0,0 +1,62 @@ +CREATE SEQUENCE "explorer_spec_id_seq" START 1; + +CREATE TABLE "explorer_spec" ( + "id" BIGINT PRIMARY KEY NOT NULL DEFAULT NEXTVAL('explorer_spec_id_seq'), + "explorer_id" BIGINT NOT NULL, + "explorer_url" CHARACTER VARYING(200) NOT NULL, + "tx_url" CHARACTER VARYING(300) NOT NULL, + "address_url" CHARACTER VARYING(300) NOT NULL, + "token_url" CHARACTER VARYING(300), + "block_url" CHARACTER VARYING(300) NOT NULL, + "blockchain_id" BIGINT NOT NULL, + CONSTRAINT "fk__explorer_spec__blockchain" FOREIGN KEY ("blockchain_id") REFERENCES "blockchain" ("id") +); + +INSERT INTO public.explorer( + explorer_id, explorer_url, tx_url, address_url, token_url, block_url, blockchain_id) + VALUES +(1, 'https://www.blockchain.com/en/', 'https://www.blockchain.com/explorer/transactions/btc/{0}', 'https://www.blockchain.com/explorer/addresses/btc/{0}', 'https://www.blockchain.com/explorer/blocks/btc/{0}', 1), +(1, 'https://www.blockchain.com/en/', 'https://www.blockchain.com/explorer/transactions/eth/{0}', 'https://www.blockchain.com/explorer/addresses/eth/{0}', 'https://www.blockchain.com/explorer/blocks/eth/{0}', 1), +(1, 'https://www.blockchain.com/en/', 'https://www.blockchain.com/explorer/transactions/bch/{0}', 'https://www.blockchain.com/explorer/addresses/bch/{0}', 'https://www.blockchain.com/explorer/blocks/bch/{0}', 1), + + +(2, 'https://www.blockcypher.com/', 'https://live.blockcypher.com/ltc/tx/{0}', 'https://live.blockcypher.com/ltc/address/{0}', 'https://live.blockcypher.com/ltc/block/{0}', 2), +(2, 'https://www.blockcypher.com/', 'https://live.blockcypher.com/doge/tx/{0}', 'https://live.blockcypher.com/doge/address/{0}', 'https://live.blockcypher.com/doge/block/{0}', 2), +(2, 'https://www.blockcypher.com/', 'https://live.blockcypher.com/dash/tx/{0}', 'https://live.blockcypher.com/dash/address/{0}', 'https://live.blockcypher.com/dash/block/{0}', 2), + + +(3, 'https://binance.mintscan.io/', 'https://binance.mintscan.io/txs/{0}', 'https://binance.mintscan.io/account/{0}', 'https://www.mintscan.io/blocks/{0}', 3), +(3, 'https://binance.mintscan.io/', 'https://binance.mintscan.io/cosmos/txs/{0}', 'https://binance.mintscan.io/cosmos/account/{0}', 'https://www.mintscan.io/cosmos/blocks/{0}', 3), +(3, 'https://binance.mintscan.io/', 'https://binance.mintscan.io/quasar/txs/{0}', 'https://binance.mintscan.io/quasar/account/{0}', 'https://www.mintscan.io/quasar/blocks/{0}', 3), + +(4, 'https://bscscan.com/', 'https://bscscan.com/tx/{0}', 'https://bscscan.com/address/{0}', 'https://bscscan.com/token/{1}?a={0}', 'https://bscscan.com/block/{0}', 4), + +(5, 'https://etherscan.io/', 'https://etherscan.io/tx/{0}', 'https://etherscan.io/address/{0}', 'https://etherscan.io/token/{1}?a={0}', 'https://etherscan.io/block/{0}', 6), + +(6, 'https://bitinfocharts.com/', 'https://bitinfocharts.com/bitcoin/tx/{0}', 'https://bitinfocharts.com/bitcoin/address/{0}', 'https://bitinfocharts.com/en/bitcoin/block/{0}', 4), +(6, 'https://bitinfocharts.com/', 'https://bitinfocharts.com/litecoin/tx/{0}', 'https://bitinfocharts.com/litecoin/address/{0}', 'https://bitinfocharts.com/litecoin/block/{0}', 4), +(6, 'https://bitinfocharts.com/', 'https://bitinfocharts.com/dogecoin/tx/{0}', 'https://bitinfocharts.com/dogecoin/address/{0}', 'https://bitinfocharts.com/dogecoin/block/{0}', 4), + +(7, 'https://blockchair.com/', 'https://blockchair.com/bitcoin/transaction/{0}', 'https://blockchair.com/bitcoin/address/{0}', 'https://blockchair.com/bitcoin/block/{0}', 5), +(7, 'https://blockchair.com/', 'https://blockchair.com/ethereum/transaction/{0}', 'https://blockchair.com/ethereum/address/{0}', 'https://blockchair.com/ethereum/block/{0}', 5), + +(8, 'https://blockexplorer.one/', 'https://blockexplorer.one/bitcoin/mainnet/tx/{0}', 'https://blockexplorer.one/bitcoin/mainnet/address/{0}', 'https://blockexplorer.one/bitcoin/mainnet/blockHash/{0}', 7), +(8, 'https://blockexplorer.one/', 'https://blockexplorer.one/litecoin/mainnet/tx/{0}', 'https://blockexplorer.one/litecoin/mainnet/address/{0}', 'https://blockexplorer.one/litecoin/mainnet/blockHash/{0}', 7), +(8, 'https://blockexplorer.one/', 'https://blockexplorer.one/ethereum/mainnet/tx/{0}', 'https://blockexplorer.one/ethereum/mainnet/address/{0}', 'https://blockexplorer.one/ethereum/mainnet/blockHash/{0}', 7), + +(9, 'https://chainz.cryptoid.info/', 'https://btc.cryptoid.info/btc/tx.dws?{0}.htm', 'https://btc.cryptoid.info/btc/address.dws?{0}.htm', 'https://btc.cryptoid.info/btc/block.dws?{0}.htm', 9), +(9, 'https://chainz.cryptoid.info/', 'https://btc.cryptoid.info/ltc/tx.dws?{0}.htm', 'https://btc.cryptoid.info/ltc/address.dws?{0}.htm', 'https://chainz.cryptoid.info/ltc/block.dws?{0}.htm', 9), +(9, 'https://chainz.cryptoid.info/', 'https://btc.cryptoid.info/ion/tx.dws?{0}.htm', 'https://btc.cryptoid.info/ion/address.dws?{0}.htm', 'https://chainz.cryptoid.info/ion/block.dws?{0}.htm', 9), + +(10, 'https://dashblockexplorer.com/', 'https://dashblockexplorer.com/tx/{0}', 'https://dashblockexplorer.com/address/{0}', 'https://dashblockexplorer.com/block/{0}', 8), + +(11, 'https://dogechain.info/', 'https://dogechain.info/tx/{0}', 'https://dogechain.info/address/{0}', 'https://dogechain.info/block/{0}', 10), + +(12, 'https://beaconcha.in/', 'https://beaconcha.in/tx/{0}', 'https://beaconcha.in/address/{0}', 'https://beaconcha.in/block/{0}', 11), + +(14, 'https://ethplorer.io/', 'https://etherscan.io/tx/{0}', 'https://etherscan.io/address/{0}', 'https://etherscan.io/block/{0}', 13), + +(15, 'https://polygonscan.com/', 'https://polygonscan.com/{0}', 'https://polygonscan.com/address/{0}', 'https://etherscan.io/token/{1}?a={0}', 'https://polygonscan.com/block/{0}', 14), + +(16, 'https://tronscan.org/#/', 'https://tronscan.org/#/transaction/{0}', 'https://tronscan.org/#/address/{0}', 'https://tronscan.org/#/block/{0}', 15), + diff --git a/database/transaction.sql b/database/transaction.sql new file mode 100644 index 0000000..06fc15f --- /dev/null +++ b/database/transaction.sql @@ -0,0 +1,17 @@ +CREATE SEQUENCE "transaction_id_seq" START 1; + +CREATE TABLE "transaction" ( + "id" BIGINT PRIMARY KEY NOT NULL DEFAULT NEXTVAL('transaction_id_seq'), + "hash" BYTEA NOT NULL, + "amount" NUMERIC(48,24), + "block_id" BIGINT NOT NULL, + CONSTRAINT "fk__transaction__block" FOREIGN KEY ("block_id") REFERENCES "block" ("id") +); + +-- INSERT INTO public.transaction( +-- hash, amount, block_id) +-- VALUES ('c13b2c9e1047cebc381d82a94b90a97853d0f0c711f83f2506697067a7245522'::bytea, 0.0000023, 1), +-- ('821d9d3394dd21ea1172f7772d7738f0a7b48f23bfe73a2966fe1eda57a677f3'::bytea, 0.000001, 2), +-- ('192b3ea24c63ed527d962ae92d699c70ead06c0d90265bb86db30177849c81f1'::bytea, 6264.29, 4), +-- ('d82fd5e6e25efd0a48f5115fa0161ca95647e8c2cde3375f9f03e9297974f557'::bytea, 32011.48, 5), +-- ('e494244c1e7f7357928284661f1c780ca301e2a5d24ec1b09409c98fcd28465e'::bytea, 88.888888, 3); \ No newline at end of file diff --git a/pubspec.yaml b/pubspec.yaml index 88e19f4..22d2bdd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -5,9 +5,11 @@ environment: sdk: ">=2.12.0 <3.0.0" dependencies: + mustache_template: ^2.0.0 shelf: ^1.2.0 shelf_router: ^1.0.0 shelf_static: ^1.0.0 + postgres: ^2.6.1 dev_dependencies: http: ^0.13.0