vow contract storage diffing excluding sin
This commit is contained in:
parent
f73623789e
commit
c2c21325b5
@ -60,6 +60,7 @@ func parseStorageDiffs() {
|
||||
watcher.AddTransformers([]storage.TransformerInitializer{
|
||||
transformers.GetPitStorageTransformer().NewTransformer,
|
||||
transformers.GetVatStorageTransformer().NewTransformer,
|
||||
transformers.GetVowStorageTransformer().NewTransformer,
|
||||
})
|
||||
|
||||
err = watcher.Execute()
|
||||
|
74
db/migrations/00074_create_vow_contract_storage_tables.sql
Normal file
74
db/migrations/00074_create_vow_contract_storage_tables.sql
Normal file
@ -0,0 +1,74 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.vow_vat (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
vat TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE maker.vow_cow (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
cow TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE maker.vow_row (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
row TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE maker.vow_sin (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
sin TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE maker.vow_ash (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
ash TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE maker.vow_wait (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
wait TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE maker.vow_sump (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
sump TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE maker.vow_bump (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
bump TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE maker.vow_hump (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
hump TEXT
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.vow_vat
|
||||
DROP TABLE maker.vow_cow
|
||||
DROP TABLE maker.vow_row
|
||||
DROP TABLE maker.vow_sin
|
||||
DROP TABLE maker.vow_ash
|
||||
DROP TABLE maker.vow_wait
|
||||
DROP TABLE maker.vow_sump
|
||||
DROP TABLE maker.vow_bump
|
||||
DROP TABLE maker.vow_hump
|
427
db/schema.sql
427
db/schema.sql
@ -2,8 +2,8 @@
|
||||
-- PostgreSQL database dump
|
||||
--
|
||||
|
||||
-- Dumped from database version 10.5
|
||||
-- Dumped by pg_dump version 10.5
|
||||
-- Dumped from database version 10.4
|
||||
-- Dumped by pg_dump version 10.4
|
||||
|
||||
SET statement_timeout = 0;
|
||||
SET lock_timeout = 0;
|
||||
@ -1605,6 +1605,102 @@ CREATE SEQUENCE maker.vat_vice_id_seq
|
||||
ALTER SEQUENCE maker.vat_vice_id_seq OWNED BY maker.vat_vice.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_ash; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vow_ash (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
ash text
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_ash_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vow_ash_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_ash_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vow_ash_id_seq OWNED BY maker.vow_ash.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_bump; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vow_bump (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
bump text
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_bump_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vow_bump_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_bump_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vow_bump_id_seq OWNED BY maker.vow_bump.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_cow; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vow_cow (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
cow text
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_cow_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vow_cow_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_cow_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vow_cow_id_seq OWNED BY maker.vow_cow.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_flog; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
@ -1639,6 +1735,198 @@ CREATE SEQUENCE maker.vow_flog_id_seq
|
||||
ALTER SEQUENCE maker.vow_flog_id_seq OWNED BY maker.vow_flog.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_hump; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vow_hump (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
hump text
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_hump_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vow_hump_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_hump_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vow_hump_id_seq OWNED BY maker.vow_hump.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_row; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vow_row (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
"row" text
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_row_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vow_row_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_row_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vow_row_id_seq OWNED BY maker.vow_row.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_sin; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vow_sin (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
sin text
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_sin_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vow_sin_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_sin_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vow_sin_id_seq OWNED BY maker.vow_sin.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_sump; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vow_sump (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
sump text
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_sump_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vow_sump_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_sump_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vow_sump_id_seq OWNED BY maker.vow_sump.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_vat; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vow_vat (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
vat text
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_vat_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vow_vat_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_vat_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vow_vat_id_seq OWNED BY maker.vow_vat.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_wait; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vow_wait (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
wait text
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_wait_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vow_wait_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_wait_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vow_wait_id_seq OWNED BY maker.vow_wait.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: logs; Type: TABLE; Schema: public; Owner: -
|
||||
--
|
||||
@ -2400,6 +2688,27 @@ ALTER TABLE ONLY maker.vat_urn_ink ALTER COLUMN id SET DEFAULT nextval('maker.va
|
||||
ALTER TABLE ONLY maker.vat_vice ALTER COLUMN id SET DEFAULT nextval('maker.vat_vice_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_ash id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vow_ash ALTER COLUMN id SET DEFAULT nextval('maker.vow_ash_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_bump id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vow_bump ALTER COLUMN id SET DEFAULT nextval('maker.vow_bump_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_cow id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vow_cow ALTER COLUMN id SET DEFAULT nextval('maker.vow_cow_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_flog id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
@ -2407,6 +2716,48 @@ ALTER TABLE ONLY maker.vat_vice ALTER COLUMN id SET DEFAULT nextval('maker.vat_v
|
||||
ALTER TABLE ONLY maker.vow_flog ALTER COLUMN id SET DEFAULT nextval('maker.vow_flog_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_hump id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vow_hump ALTER COLUMN id SET DEFAULT nextval('maker.vow_hump_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_row id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vow_row ALTER COLUMN id SET DEFAULT nextval('maker.vow_row_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_sin id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vow_sin ALTER COLUMN id SET DEFAULT nextval('maker.vow_sin_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_sump id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vow_sump ALTER COLUMN id SET DEFAULT nextval('maker.vow_sump_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_vat id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vow_vat ALTER COLUMN id SET DEFAULT nextval('maker.vow_vat_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_wait id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vow_wait ALTER COLUMN id SET DEFAULT nextval('maker.vow_wait_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: blocks id; Type: DEFAULT; Schema: public; Owner: -
|
||||
--
|
||||
@ -3052,6 +3403,30 @@ ALTER TABLE ONLY maker.vat_vice
|
||||
ADD CONSTRAINT vat_vice_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_ash vow_ash_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vow_ash
|
||||
ADD CONSTRAINT vow_ash_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_bump vow_bump_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vow_bump
|
||||
ADD CONSTRAINT vow_bump_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_cow vow_cow_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vow_cow
|
||||
ADD CONSTRAINT vow_cow_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_flog vow_flog_header_id_tx_idx_log_idx_key; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
@ -3068,6 +3443,54 @@ ALTER TABLE ONLY maker.vow_flog
|
||||
ADD CONSTRAINT vow_flog_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_hump vow_hump_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vow_hump
|
||||
ADD CONSTRAINT vow_hump_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_row vow_row_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vow_row
|
||||
ADD CONSTRAINT vow_row_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_sin vow_sin_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vow_sin
|
||||
ADD CONSTRAINT vow_sin_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_sump vow_sump_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vow_sump
|
||||
ADD CONSTRAINT vow_sump_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_vat vow_vat_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vow_vat
|
||||
ADD CONSTRAINT vow_vat_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_wait vow_wait_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vow_wait
|
||||
ADD CONSTRAINT vow_wait_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: blocks blocks_pkey; Type: CONSTRAINT; Schema: public; Owner: -
|
||||
--
|
||||
|
@ -18,7 +18,6 @@ package postgres
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/jmoiron/sqlx"
|
||||
_ "github.com/lib/pq" //postgres driver
|
||||
@ -41,7 +40,6 @@ var (
|
||||
|
||||
func NewDB(databaseConfig config.Database, node core.Node) (*DB, error) {
|
||||
connectString := config.DbConnectionString(databaseConfig)
|
||||
logrus.Info("Using connection string: ", connectString)
|
||||
db, err := sqlx.Connect("postgres", connectString)
|
||||
if err != nil {
|
||||
return &DB{}, ErrDBConnectionFailed
|
||||
|
143
pkg/transformers/storage_diffs/maker/vow/mappings.go
Normal file
143
pkg/transformers/storage_diffs/maker/vow/mappings.go
Normal file
@ -0,0 +1,143 @@
|
||||
/*
|
||||
* Copyright 2018 Vulcanize
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package vow
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared"
|
||||
)
|
||||
|
||||
const (
|
||||
VowVat = "vat"
|
||||
CowVat = "cow"
|
||||
RowVat = "row"
|
||||
SinVat = "Sin"
|
||||
AshVat = "ash"
|
||||
WaitVat = "wait"
|
||||
SumpVat = "sump"
|
||||
BumpVat = "bump"
|
||||
HumpVat = "hump"
|
||||
)
|
||||
|
||||
var (
|
||||
VatKey = common.HexToHash(storage_diffs.IndexOne)
|
||||
VatMetadata = shared.StorageValueMetadata{
|
||||
Name: VowVat,
|
||||
Keys: nil,
|
||||
Type: shared.Address,
|
||||
}
|
||||
|
||||
CowKey = common.HexToHash(storage_diffs.IndexTwo)
|
||||
CowMetadata = shared.StorageValueMetadata{
|
||||
Name: CowVat,
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
RowKey = common.HexToHash(storage_diffs.IndexThree)
|
||||
RowMetadata = shared.StorageValueMetadata{
|
||||
Name: RowVat,
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
SinKey = common.HexToHash(storage_diffs.IndexFive)
|
||||
SinMetadata = shared.StorageValueMetadata{
|
||||
Name: SinVat,
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
AshKey = common.HexToHash(storage_diffs.IndexSeven)
|
||||
AshMetadata = shared.StorageValueMetadata{
|
||||
Name: AshVat,
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
WaitKey = common.HexToHash(storage_diffs.IndexEight)
|
||||
WaitMetadata = shared.StorageValueMetadata{
|
||||
Name: WaitVat,
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
SumpKey = common.HexToHash(storage_diffs.IndexNine)
|
||||
SumpMetadata = shared.StorageValueMetadata{
|
||||
Name: SumpVat,
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
BumpKey = common.HexToHash(storage_diffs.IndexTen)
|
||||
BumpMetadata = shared.StorageValueMetadata{
|
||||
Name: BumpVat,
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
HumpKey = common.HexToHash(storage_diffs.IndexEleven)
|
||||
HumpMetadata = shared.StorageValueMetadata{
|
||||
Name: HumpVat,
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
)
|
||||
|
||||
type VowMappings struct {
|
||||
StorageRepository maker.IMakerStorageRepository
|
||||
mappings map[common.Hash]shared.StorageValueMetadata
|
||||
}
|
||||
|
||||
func (mappings *VowMappings) Lookup(key common.Hash) (shared.StorageValueMetadata, error) {
|
||||
metadata, ok := mappings.mappings[key]
|
||||
if !ok {
|
||||
err := mappings.loadMappings()
|
||||
if err != nil {
|
||||
return metadata, err
|
||||
}
|
||||
metadata, ok = mappings.mappings[key]
|
||||
if !ok {
|
||||
return metadata, shared.ErrStorageKeyNotFound{Key: key.Hex()}
|
||||
}
|
||||
}
|
||||
return metadata, nil
|
||||
}
|
||||
|
||||
func (mappings *VowMappings) loadMappings() error {
|
||||
staticMappings := make(map[common.Hash]shared.StorageValueMetadata)
|
||||
staticMappings[VatKey] = VatMetadata
|
||||
staticMappings[CowKey] = CowMetadata
|
||||
staticMappings[RowKey] = RowMetadata
|
||||
staticMappings[SinKey] = SinMetadata
|
||||
staticMappings[AshKey] = AshMetadata
|
||||
staticMappings[WaitKey] = WaitMetadata
|
||||
staticMappings[SumpKey] = SumpMetadata
|
||||
staticMappings[BumpKey] = BumpMetadata
|
||||
staticMappings[HumpKey] = HumpMetadata
|
||||
|
||||
mappings.mappings = staticMappings
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mappings *VowMappings) SetDB(db *postgres.DB) {
|
||||
mappings.StorageRepository.SetDB(db)
|
||||
}
|
41
pkg/transformers/storage_diffs/maker/vow/mappings_test.go
Normal file
41
pkg/transformers/storage_diffs/maker/vow/mappings_test.go
Normal file
@ -0,0 +1,41 @@
|
||||
package vow_test
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/test_helpers"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/vow"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared"
|
||||
)
|
||||
|
||||
var _ = Describe("Vow storage mappings", func() {
|
||||
Describe("looking up static keys", func() {
|
||||
It("returns value metadata if key exists", func() {
|
||||
storageRepository := &test_helpers.MockMakerStorageRepository{}
|
||||
|
||||
mappings := vow.VowMappings{StorageRepository: storageRepository}
|
||||
|
||||
Expect(mappings.Lookup(vow.VatKey)).To(Equal(vow.VatMetadata))
|
||||
Expect(mappings.Lookup(vow.CowKey)).To(Equal(vow.CowMetadata))
|
||||
Expect(mappings.Lookup(vow.RowKey)).To(Equal(vow.RowMetadata))
|
||||
Expect(mappings.Lookup(vow.SinKey)).To(Equal(vow.SinMetadata))
|
||||
Expect(mappings.Lookup(vow.AshKey)).To(Equal(vow.AshMetadata))
|
||||
Expect(mappings.Lookup(vow.WaitKey)).To(Equal(vow.WaitMetadata))
|
||||
Expect(mappings.Lookup(vow.SumpKey)).To(Equal(vow.SumpMetadata))
|
||||
Expect(mappings.Lookup(vow.BumpKey)).To(Equal(vow.BumpMetadata))
|
||||
Expect(mappings.Lookup(vow.HumpKey)).To(Equal(vow.HumpMetadata))
|
||||
})
|
||||
|
||||
It("returns error if key does not exist", func() {
|
||||
storageRepository := &test_helpers.MockMakerStorageRepository{}
|
||||
|
||||
mappings := vow.VowMappings{StorageRepository: storageRepository}
|
||||
_, err := mappings.Lookup(common.HexToHash(fakes.FakeHash.Hex()))
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(shared.ErrStorageKeyNotFound{Key: fakes.FakeHash.Hex()}))
|
||||
})
|
||||
})
|
||||
})
|
45
pkg/transformers/storage_diffs/maker/vow/repository.go
Normal file
45
pkg/transformers/storage_diffs/maker/vow/repository.go
Normal file
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* Copyright 2018 Vulcanize
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package vow
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared"
|
||||
)
|
||||
|
||||
type VowStorageRepository struct {
|
||||
db *postgres.DB
|
||||
}
|
||||
|
||||
func (repository *VowStorageRepository) SetDB(db *postgres.DB) {
|
||||
repository.db = db
|
||||
}
|
||||
|
||||
func (repository VowStorageRepository) Create(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, value interface{}) error {
|
||||
switch metadata.Name {
|
||||
case VowVat:
|
||||
return repository.insertVowVat(blockNumber, blockHash, value.(string))
|
||||
default:
|
||||
panic("unrecognized storage metadata name")
|
||||
}
|
||||
}
|
||||
|
||||
func (repository VowStorageRepository) insertVowVat(blockNumber int, blockHash string, vat string) error {
|
||||
_, err := repository.db.Exec(`INSERT INTO maker.vow_vat (block_number, block_hash, vat) VALUES ($1, $2, $3)`, blockNumber, blockHash, vat)
|
||||
|
||||
return err
|
||||
}
|
68
pkg/transformers/storage_diffs/maker/vow/repository_test.go
Normal file
68
pkg/transformers/storage_diffs/maker/vow/repository_test.go
Normal file
@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2018 Vulcanize
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package vow_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/vow"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
)
|
||||
|
||||
var _ = Describe("Vow storage repository test", func() {
|
||||
var (
|
||||
blockNumber int
|
||||
blockHash string
|
||||
db *postgres.DB
|
||||
err error
|
||||
repo vow.VowStorageRepository
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
blockNumber = 123
|
||||
blockHash = "expected_block_hash"
|
||||
db = test_config.NewTestDB(test_config.NewTestNode())
|
||||
test_config.CleanTestDB(db)
|
||||
repo = vow.VowStorageRepository{}
|
||||
repo.SetDB(db)
|
||||
})
|
||||
|
||||
It("persists a vow vat", func() {
|
||||
expectedVat := "yo"
|
||||
|
||||
err = repo.Create(blockNumber, blockHash, vow.VatMetadata, expectedVat)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type VowVat struct {
|
||||
BlockMetadata
|
||||
Vat string
|
||||
}
|
||||
var result VowVat
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, vat from maker.vow_vat`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(blockNumber))
|
||||
Expect(result.BlockHash).To(Equal(blockHash))
|
||||
Expect(result.Vat).To(Equal(expectedVat))
|
||||
})
|
||||
})
|
||||
|
||||
type BlockMetadata struct {
|
||||
BlockNumber int `db:"block_number"`
|
||||
BlockHash string `db:"block_hash"`
|
||||
}
|
13
pkg/transformers/storage_diffs/maker/vow/vow_suite_test.go
Normal file
13
pkg/transformers/storage_diffs/maker/vow/vow_suite_test.go
Normal file
@ -0,0 +1,13 @@
|
||||
package vow_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
func TestVow(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Storage Diff Vow Suite")
|
||||
}
|
@ -30,14 +30,18 @@ type Mappings interface {
|
||||
}
|
||||
|
||||
const (
|
||||
IndexZero = "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
IndexOne = "0000000000000000000000000000000000000000000000000000000000000001"
|
||||
IndexTwo = "0000000000000000000000000000000000000000000000000000000000000002"
|
||||
IndexThree = "0000000000000000000000000000000000000000000000000000000000000003"
|
||||
IndexFour = "0000000000000000000000000000000000000000000000000000000000000004"
|
||||
IndexFive = "0000000000000000000000000000000000000000000000000000000000000005"
|
||||
IndexSix = "0000000000000000000000000000000000000000000000000000000000000006"
|
||||
IndexSeven = "0000000000000000000000000000000000000000000000000000000000000007"
|
||||
IndexZero = "0000000000000000000000000000000000000000000000000000000000000000"
|
||||
IndexOne = "0000000000000000000000000000000000000000000000000000000000000001"
|
||||
IndexTwo = "0000000000000000000000000000000000000000000000000000000000000002"
|
||||
IndexThree = "0000000000000000000000000000000000000000000000000000000000000003"
|
||||
IndexFour = "0000000000000000000000000000000000000000000000000000000000000004"
|
||||
IndexFive = "0000000000000000000000000000000000000000000000000000000000000005"
|
||||
IndexSix = "0000000000000000000000000000000000000000000000000000000000000006"
|
||||
IndexSeven = "0000000000000000000000000000000000000000000000000000000000000007"
|
||||
IndexEight = "0000000000000000000000000000000000000000000000000000000000000008"
|
||||
IndexNine = "0000000000000000000000000000000000000000000000000000000000000009"
|
||||
IndexTen = "0000000000000000000000000000000000000000000000000000000000000010"
|
||||
IndexEleven = "0000000000000000000000000000000000000000000000000000000000000011 "
|
||||
)
|
||||
|
||||
func GetMapping(indexOnContract, key string) common.Hash {
|
||||
|
@ -7,6 +7,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/pit"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/vat"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/vow"
|
||||
)
|
||||
|
||||
func GetPitStorageTransformer() storage.Transformer {
|
||||
@ -24,3 +25,11 @@ func GetVatStorageTransformer() storage.Transformer {
|
||||
Repository: &vat.VatStorageRepository{},
|
||||
}
|
||||
}
|
||||
|
||||
func GetVowStorageTransformer() storage.Transformer {
|
||||
return storage.Transformer{
|
||||
Address: common.HexToAddress(constants.VowContractAddress()),
|
||||
Mappings: &vow.VowMappings{StorageRepository: &maker.MakerStorageRepository{}},
|
||||
Repository: &vow.VowStorageRepository{},
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user