2023-02-21 18:34:22 +01:00
|
|
|
-- Otx tx type enum table
|
|
|
|
CREATE TABLE IF NOT EXISTS otx_tx_type (
|
|
|
|
value TEXT PRIMARY KEY
|
|
|
|
);
|
|
|
|
INSERT INTO otx_tx_type (value) VALUES
|
|
|
|
('GIFT_GAS'),
|
|
|
|
('ACCOUNT_REGISTER'),
|
|
|
|
('GIFT_VOUCHER'),
|
|
|
|
('REFILL_GAS'),
|
|
|
|
('TRANSFER_VOUCHER');
|
|
|
|
|
2023-02-15 08:05:43 +01:00
|
|
|
-- Origin tx table
|
2023-02-21 18:34:22 +01:00
|
|
|
CREATE TABLE IF NOT EXISTS otx_sign (
|
2023-02-15 08:05:43 +01:00
|
|
|
id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
2023-03-08 07:49:09 +01:00
|
|
|
tracking_id uuid NOT NULL,
|
2023-02-21 18:34:22 +01:00
|
|
|
"type" TEXT REFERENCES otx_tx_type(value) NOT NULL,
|
2023-02-15 08:05:43 +01:00
|
|
|
raw_tx TEXT NOT NULL,
|
|
|
|
tx_hash TEXT NOT NULL,
|
|
|
|
"from" TEXT NOT NULL,
|
|
|
|
"data" TEXT NOT NULL,
|
|
|
|
gas_price bigint NOT NULL,
|
2023-02-21 18:34:22 +01:00
|
|
|
gas_limit bigint NOT NULL,
|
|
|
|
transfer_value bigint NOT NULL,
|
2023-02-15 08:05:43 +01:00
|
|
|
nonce int NOT NULL,
|
|
|
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
|
|
);
|
2023-03-08 07:49:09 +01:00
|
|
|
CREATE INDEX IF NOT EXISTS tracking_id_idx ON otx_sign (tracking_id);
|
|
|
|
CREATE INDEX IF NOT EXISTS tx_hash_idx ON otx_sign (tx_hash);
|
|
|
|
CREATE INDEX IF NOT EXISTS from_idx ON otx_sign ("from");
|
2023-02-21 18:34:22 +01:00
|
|
|
|
|
|
|
-- Otx dispatch status enum table
|
|
|
|
-- Enforces referential integrity on the dispatch table
|
|
|
|
CREATE TABLE IF NOT EXISTS otx_dispatch_status_type (
|
|
|
|
value TEXT PRIMARY KEY
|
|
|
|
);
|
|
|
|
INSERT INTO otx_dispatch_status_type (value) VALUES
|
|
|
|
('IN_NETWORK'),
|
|
|
|
('OBSOLETE'),
|
|
|
|
('SUCCESS'),
|
|
|
|
('FAIL_NO_GAS'),
|
|
|
|
('FAIL_LOW_NONCE'),
|
|
|
|
('FAIL_LOW_GAS_PRICE'),
|
|
|
|
('FAIL_UNKNOWN_RPC_ERROR'),
|
|
|
|
('REVERTED');
|
2023-02-15 08:05:43 +01:00
|
|
|
|
|
|
|
-- Dispatch status table
|
2023-02-21 18:34:22 +01:00
|
|
|
CREATE TABLE IF NOT EXISTS otx_dispatch (
|
2023-02-15 08:05:43 +01:00
|
|
|
id INT GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
|
2023-02-21 18:34:22 +01:00
|
|
|
otx_id INT REFERENCES otx_sign(id),
|
|
|
|
"status" TEXT REFERENCES otx_dispatch_status_type(value) NOT NULL,
|
|
|
|
"block" bigint,
|
2023-02-15 08:05:43 +01:00
|
|
|
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP
|
|
|
|
);
|
2023-02-21 18:34:22 +01:00
|
|
|
CREATE INDEX IF NOT EXISTS status_idx ON otx_dispatch("status");
|