Merge pull request #8 from vulcanize/vdb-280-vat-diff-parsing
(VDB-280) Vat diff parsing
This commit is contained in:
commit
c166e8d612
@ -57,7 +57,10 @@ func parseStorageDiffs() {
|
||||
|
||||
// TODO: configure transformers
|
||||
watcher := shared.NewStorageWatcher(tailer, db)
|
||||
watcher.AddTransformers([]storage.TransformerInitializer{transformers.GetPitStorageTransformer().NewTransformer})
|
||||
watcher.AddTransformers([]storage.TransformerInitializer{
|
||||
transformers.GetPitStorageTransformer().NewTransformer,
|
||||
transformers.GetVatStorageTransformer().NewTransformer,
|
||||
})
|
||||
|
||||
err = watcher.Execute()
|
||||
if err != nil {
|
||||
|
102
db/migrations/00073_create_vat_contract_storage_tables.sql
Normal file
102
db/migrations/00073_create_vat_contract_storage_tables.sql
Normal file
@ -0,0 +1,102 @@
|
||||
-- +goose Up
|
||||
CREATE TABLE maker.vat_debt (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
debt NUMERIC NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE maker.vat_vice (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
vice NUMERIC NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE maker.vat_ilk_art (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
ilk TEXT,
|
||||
art NUMERIC NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE maker.vat_ilk_ink (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
ilk TEXT,
|
||||
ink NUMERIC NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE maker.vat_ilk_rate (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
ilk TEXT,
|
||||
rate NUMERIC NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE maker.vat_ilk_take (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
ilk TEXT,
|
||||
take NUMERIC NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE maker.vat_urn_art (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
ilk TEXT,
|
||||
urn TEXT,
|
||||
art TEXT
|
||||
);
|
||||
|
||||
CREATE TABLE maker.vat_urn_ink (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
ilk TEXT,
|
||||
urn TEXT,
|
||||
ink NUMERIC NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE maker.vat_gem (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
ilk TEXT,
|
||||
guy TEXT,
|
||||
gem NUMERIC NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE maker.vat_dai (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
guy TEXT,
|
||||
dai NUMERIC NOT NULL
|
||||
);
|
||||
|
||||
CREATE TABLE maker.vat_sin (
|
||||
id SERIAL PRIMARY KEY,
|
||||
block_number BIGINT,
|
||||
block_hash TEXT,
|
||||
guy TEXT,
|
||||
sin NUMERIC NOT NULL
|
||||
);
|
||||
|
||||
-- +goose Down
|
||||
DROP TABLE maker.vat_debt;
|
||||
DROP TABLE maker.vat_vice;
|
||||
DROP TABLE maker.vat_ilk_art;
|
||||
DROP TABLE maker.vat_ilk_ink;
|
||||
DROP TABLE maker.vat_ilk_rate;
|
||||
DROP TABLE maker.vat_ilk_take;
|
||||
DROP TABLE maker.vat_urn_art;
|
||||
DROP TABLE maker.vat_urn_ink;
|
||||
DROP TABLE maker.vat_gem;
|
||||
DROP TABLE maker.vat_dai;
|
||||
DROP TABLE maker.vat_sin;
|
529
db/schema.sql
529
db/schema.sql
@ -912,6 +912,71 @@ CREATE SEQUENCE maker.tend_id_seq
|
||||
ALTER SEQUENCE maker.tend_id_seq OWNED BY maker.tend.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_dai; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vat_dai (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
guy text,
|
||||
dai numeric NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_dai_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vat_dai_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_dai_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vat_dai_id_seq OWNED BY maker.vat_dai.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_debt; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vat_debt (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
debt numeric NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_debt_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vat_debt_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_debt_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vat_debt_id_seq OWNED BY maker.vat_debt.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_flux; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
@ -985,6 +1050,40 @@ CREATE SEQUENCE maker.vat_fold_id_seq
|
||||
ALTER SEQUENCE maker.vat_fold_id_seq OWNED BY maker.vat_fold.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_gem; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vat_gem (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
ilk text,
|
||||
guy text,
|
||||
gem numeric NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_gem_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vat_gem_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_gem_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vat_gem_id_seq OWNED BY maker.vat_gem.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_grab; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
@ -1060,6 +1159,138 @@ CREATE SEQUENCE maker.vat_heal_id_seq
|
||||
ALTER SEQUENCE maker.vat_heal_id_seq OWNED BY maker.vat_heal.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_art; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vat_ilk_art (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
ilk text,
|
||||
art numeric NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_art_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vat_ilk_art_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_art_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vat_ilk_art_id_seq OWNED BY maker.vat_ilk_art.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_ink; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vat_ilk_ink (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
ilk text,
|
||||
ink numeric NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_ink_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vat_ilk_ink_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_ink_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vat_ilk_ink_id_seq OWNED BY maker.vat_ilk_ink.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_rate; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vat_ilk_rate (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
ilk text,
|
||||
rate numeric NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_rate_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vat_ilk_rate_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_rate_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vat_ilk_rate_id_seq OWNED BY maker.vat_ilk_rate.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_take; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vat_ilk_take (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
ilk text,
|
||||
take numeric NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_take_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vat_ilk_take_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_take_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vat_ilk_take_id_seq OWNED BY maker.vat_ilk_take.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_init; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
@ -1130,6 +1361,39 @@ CREATE SEQUENCE maker.vat_move_id_seq
|
||||
ALTER SEQUENCE maker.vat_move_id_seq OWNED BY maker.vat_move.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_sin; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vat_sin (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
guy text,
|
||||
sin numeric NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_sin_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vat_sin_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_sin_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vat_sin_id_seq OWNED BY maker.vat_sin.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_slip; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
@ -1241,6 +1505,106 @@ CREATE SEQUENCE maker.vat_tune_id_seq
|
||||
ALTER SEQUENCE maker.vat_tune_id_seq OWNED BY maker.vat_tune.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_urn_art; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vat_urn_art (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
ilk text,
|
||||
urn text,
|
||||
art text
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_urn_art_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vat_urn_art_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_urn_art_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vat_urn_art_id_seq OWNED BY maker.vat_urn_art.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_urn_ink; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vat_urn_ink (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
ilk text,
|
||||
urn text,
|
||||
ink numeric NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_urn_ink_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vat_urn_ink_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_urn_ink_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vat_urn_ink_id_seq OWNED BY maker.vat_urn_ink.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_vice; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE TABLE maker.vat_vice (
|
||||
id integer NOT NULL,
|
||||
block_number bigint,
|
||||
block_hash text,
|
||||
vice numeric NOT NULL
|
||||
);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_vice_id_seq; Type: SEQUENCE; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
CREATE SEQUENCE maker.vat_vice_id_seq
|
||||
AS integer
|
||||
START WITH 1
|
||||
INCREMENT BY 1
|
||||
NO MINVALUE
|
||||
NO MAXVALUE
|
||||
CACHE 1;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_vice_id_seq; Type: SEQUENCE OWNED BY; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER SEQUENCE maker.vat_vice_id_seq OWNED BY maker.vat_vice.id;
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_flog; Type: TABLE; Schema: maker; Owner: -
|
||||
--
|
||||
@ -1896,6 +2260,20 @@ ALTER TABLE ONLY maker.price_feeds ALTER COLUMN id SET DEFAULT nextval('maker.pr
|
||||
ALTER TABLE ONLY maker.tend ALTER COLUMN id SET DEFAULT nextval('maker.tend_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_dai id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_dai ALTER COLUMN id SET DEFAULT nextval('maker.vat_dai_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_debt id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_debt ALTER COLUMN id SET DEFAULT nextval('maker.vat_debt_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_flux id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
@ -1910,6 +2288,13 @@ ALTER TABLE ONLY maker.vat_flux ALTER COLUMN id SET DEFAULT nextval('maker.vat_f
|
||||
ALTER TABLE ONLY maker.vat_fold ALTER COLUMN id SET DEFAULT nextval('maker.vat_fold_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_gem id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_gem ALTER COLUMN id SET DEFAULT nextval('maker.vat_gem_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_grab id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
@ -1924,6 +2309,34 @@ ALTER TABLE ONLY maker.vat_grab ALTER COLUMN id SET DEFAULT nextval('maker.vat_g
|
||||
ALTER TABLE ONLY maker.vat_heal ALTER COLUMN id SET DEFAULT nextval('maker.vat_heal_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_art id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_ilk_art ALTER COLUMN id SET DEFAULT nextval('maker.vat_ilk_art_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_ink id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_ilk_ink ALTER COLUMN id SET DEFAULT nextval('maker.vat_ilk_ink_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_rate id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_ilk_rate ALTER COLUMN id SET DEFAULT nextval('maker.vat_ilk_rate_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_take id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_ilk_take ALTER COLUMN id SET DEFAULT nextval('maker.vat_ilk_take_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_init id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
@ -1938,6 +2351,13 @@ ALTER TABLE ONLY maker.vat_init ALTER COLUMN id SET DEFAULT nextval('maker.vat_i
|
||||
ALTER TABLE ONLY maker.vat_move ALTER COLUMN id SET DEFAULT nextval('maker.vat_move_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_sin id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_sin ALTER COLUMN id SET DEFAULT nextval('maker.vat_sin_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_slip id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
@ -1959,6 +2379,27 @@ ALTER TABLE ONLY maker.vat_toll ALTER COLUMN id SET DEFAULT nextval('maker.vat_t
|
||||
ALTER TABLE ONLY maker.vat_tune ALTER COLUMN id SET DEFAULT nextval('maker.vat_tune_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_urn_art id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_urn_art ALTER COLUMN id SET DEFAULT nextval('maker.vat_urn_art_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_urn_ink id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_urn_ink ALTER COLUMN id SET DEFAULT nextval('maker.vat_urn_ink_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_vice id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_vice ALTER COLUMN id SET DEFAULT nextval('maker.vat_vice_id_seq'::regclass);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_flog id; Type: DEFAULT; Schema: maker; Owner: -
|
||||
--
|
||||
@ -2379,6 +2820,22 @@ ALTER TABLE ONLY maker.tend
|
||||
ADD CONSTRAINT tend_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_dai vat_dai_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_dai
|
||||
ADD CONSTRAINT vat_dai_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_debt vat_debt_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_debt
|
||||
ADD CONSTRAINT vat_debt_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_flux vat_flux_header_id_tx_idx_log_idx_key; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
@ -2411,6 +2868,14 @@ ALTER TABLE ONLY maker.vat_fold
|
||||
ADD CONSTRAINT vat_fold_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_gem vat_gem_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_gem
|
||||
ADD CONSTRAINT vat_gem_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_grab vat_grab_header_id_tx_idx_log_idx_key; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
@ -2443,6 +2908,38 @@ ALTER TABLE ONLY maker.vat_heal
|
||||
ADD CONSTRAINT vat_heal_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_art vat_ilk_art_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_ilk_art
|
||||
ADD CONSTRAINT vat_ilk_art_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_ink vat_ilk_ink_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_ilk_ink
|
||||
ADD CONSTRAINT vat_ilk_ink_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_rate vat_ilk_rate_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_ilk_rate
|
||||
ADD CONSTRAINT vat_ilk_rate_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_ilk_take vat_ilk_take_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_ilk_take
|
||||
ADD CONSTRAINT vat_ilk_take_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_init vat_init_header_id_tx_idx_log_idx_key; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
@ -2475,6 +2972,14 @@ ALTER TABLE ONLY maker.vat_move
|
||||
ADD CONSTRAINT vat_move_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_sin vat_sin_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_sin
|
||||
ADD CONSTRAINT vat_sin_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_slip vat_slip_header_id_tx_idx_log_idx_key; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
@ -2523,6 +3028,30 @@ ALTER TABLE ONLY maker.vat_tune
|
||||
ADD CONSTRAINT vat_tune_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_urn_art vat_urn_art_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_urn_art
|
||||
ADD CONSTRAINT vat_urn_art_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_urn_ink vat_urn_ink_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_urn_ink
|
||||
ADD CONSTRAINT vat_urn_ink_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vat_vice vat_vice_pkey; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
||||
ALTER TABLE ONLY maker.vat_vice
|
||||
ADD CONSTRAINT vat_vice_pkey PRIMARY KEY (id);
|
||||
|
||||
|
||||
--
|
||||
-- Name: vow_flog vow_flog_header_id_tx_idx_log_idx_key; Type: CONSTRAINT; Schema: maker; Owner: -
|
||||
--
|
||||
|
@ -20,7 +20,6 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
@ -63,8 +62,8 @@ func (converter BiteConverter) ToModels(entities []interface{}) ([]interface{},
|
||||
return nil, fmt.Errorf("entity of type %T, not %T", entity, BiteEntity{})
|
||||
}
|
||||
|
||||
ilk := common.Bytes2Hex(biteEntity.Ilk[:])
|
||||
urn := common.BytesToAddress(biteEntity.Urn[:]).String()
|
||||
ilk := shared.GetHexWithoutPrefix(biteEntity.Ilk[:])
|
||||
urn := shared.GetHexWithoutPrefix(biteEntity.Urn[:])
|
||||
ink := biteEntity.Ink
|
||||
art := biteEntity.Art
|
||||
iArt := biteEntity.IArt
|
||||
|
@ -71,7 +71,7 @@ var _ = Describe("Bite Converter", func() {
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
expectedModel := bite.BiteModel{
|
||||
Ilk: "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
Urn: "0x0000000000000000000000000000000000000000",
|
||||
Urn: "0000000000000000000000000000000000000000000000000000000000000000",
|
||||
Ink: "",
|
||||
Art: "",
|
||||
IArt: "",
|
||||
|
@ -41,6 +41,7 @@ func (c DentConverter) ToModels(ethLogs []types.Log) (result []interface{}, err
|
||||
bidId := log.Topics[2].Big()
|
||||
lot := log.Topics[3].Big().String()
|
||||
bidValue := getBidValue(log)
|
||||
// TODO: verify guy is available on Topics[1] (looks like it may just be an int id)
|
||||
guy := common.HexToAddress(log.Topics[1].Hex()).String()
|
||||
|
||||
logIndex := log.Index
|
||||
|
@ -17,7 +17,6 @@
|
||||
package ilk
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"math/big"
|
||||
@ -39,7 +38,7 @@ func (DripFileIlkConverter) ToModels(ethLogs []types.Log) ([]interface{}, error)
|
||||
}
|
||||
|
||||
ilk := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes())
|
||||
vow := string(bytes.Trim(ethLog.Topics[3].Bytes(), "\x00"))
|
||||
vow := shared.GetHexWithoutPrefix(ethLog.Topics[3].Bytes())
|
||||
taxBytes := ethLog.Data[len(ethLog.Data)-constants.DataItemLength:]
|
||||
tax := shared.ConvertToRay(big.NewInt(0).SetBytes(taxBytes).String())
|
||||
raw, err := json.Marshal(ethLog)
|
||||
|
@ -20,8 +20,8 @@ import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/ethereum/go-ethereum/accounts/abi/bind"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/geth"
|
||||
)
|
||||
@ -64,8 +64,8 @@ func (FrobConverter) ToModels(entities []interface{}) ([]interface{}, error) {
|
||||
return nil, err
|
||||
}
|
||||
model := FrobModel{
|
||||
Ilk: common.Bytes2Hex(frobEntity.Ilk[:]),
|
||||
Urn: common.BytesToAddress(frobEntity.Urn[:]).String(),
|
||||
Ilk: shared.GetHexWithoutPrefix(frobEntity.Ilk[:]),
|
||||
Urn: shared.GetHexWithoutPrefix(frobEntity.Urn[:]),
|
||||
Ink: frobEntity.Ink.String(),
|
||||
Art: frobEntity.Art.String(),
|
||||
Dink: frobEntity.Dink.String(),
|
||||
|
@ -87,7 +87,7 @@ var _ = Describe("Bite Transformer", func() {
|
||||
Expect(dbResult[0].Ink).To(Equal("1000000000000000000"))
|
||||
Expect(dbResult[0].NFlip).To(Equal("2"))
|
||||
Expect(dbResult[0].Tab).To(Equal("149846666666666655744"))
|
||||
Expect(dbResult[0].Urn).To(Equal("0x0000d8b4147eDa80Fec7122AE16DA2479Cbd7ffB"))
|
||||
Expect(dbResult[0].Urn).To(Equal("0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb"))
|
||||
})
|
||||
|
||||
It("unpacks an event log", func() {
|
||||
|
@ -96,7 +96,7 @@ var _ = Describe("Frob Transformer", func() {
|
||||
Expect(dbResult[0].IArt).To(Equal("1495509999999999999992"))
|
||||
Expect(dbResult[0].Ilk).To(Equal("4554480000000000000000000000000000000000000000000000000000000000"))
|
||||
Expect(dbResult[0].Ink).To(Equal("10050100000000000"))
|
||||
Expect(dbResult[0].Urn).To(Equal("0xc8E093e5f3F9B5Aa6A6b33ea45960b93C161430C"))
|
||||
Expect(dbResult[0].Urn).To(Equal("000000000000000000000000c8e093e5f3f9b5aa6a6b33ea45960b93c161430c"))
|
||||
})
|
||||
|
||||
It("rechecks frob event", func() {
|
||||
@ -141,7 +141,7 @@ var _ = Describe("Frob Transformer", func() {
|
||||
Expect(dbResult[0].IArt).To(Equal("1495509999999999999992"))
|
||||
Expect(dbResult[0].Ilk).To(Equal("4554480000000000000000000000000000000000000000000000000000000000"))
|
||||
Expect(dbResult[0].Ink).To(Equal("10050100000000000"))
|
||||
Expect(dbResult[0].Urn).To(Equal("0xc8E093e5f3F9B5Aa6A6b33ea45960b93C161430C"))
|
||||
Expect(dbResult[0].Urn).To(Equal("000000000000000000000000c8e093e5f3f9b5aa6a6b33ea45960b93c161430c"))
|
||||
})
|
||||
|
||||
It("unpacks an event log", func() {
|
||||
|
@ -91,7 +91,7 @@ var _ = Describe("Tend LogNoteTransformer", func() {
|
||||
Expect(len(dbResult)).To(Equal(1))
|
||||
Expect(dbResult[0].Bid).To(Equal("4000"))
|
||||
Expect(dbResult[0].BidId).To(Equal("3"))
|
||||
Expect(dbResult[0].Guy).To(Equal("0x0000d8b4147eDa80Fec7122AE16DA2479Cbd7ffB"))
|
||||
Expect(dbResult[0].Guy).To(Equal("0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb"))
|
||||
Expect(dbResult[0].Lot).To(Equal("1000000000000000000"))
|
||||
|
||||
var dbTic int64
|
||||
@ -137,7 +137,7 @@ var _ = Describe("Tend LogNoteTransformer", func() {
|
||||
Expect(len(dbResult)).To(Equal(1))
|
||||
Expect(dbResult[0].Bid).To(Equal("4000"))
|
||||
Expect(dbResult[0].BidId).To(Equal("3"))
|
||||
Expect(dbResult[0].Guy).To(Equal("0x0000d8b4147eDa80Fec7122AE16DA2479Cbd7ffB"))
|
||||
Expect(dbResult[0].Guy).To(Equal("0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb"))
|
||||
Expect(dbResult[0].Lot).To(Equal("1000000000000000000"))
|
||||
|
||||
var dbTic int64
|
||||
@ -170,7 +170,7 @@ var _ = Describe("Tend LogNoteTransformer", func() {
|
||||
Expect(len(dbResult)).To(Equal(1))
|
||||
Expect(dbResult[0].Bid).To(Equal("4300"))
|
||||
Expect(dbResult[0].BidId).To(Equal("3"))
|
||||
Expect(dbResult[0].Guy).To(Equal("0x0000d8b4147eDa80Fec7122AE16DA2479Cbd7ffB"))
|
||||
Expect(dbResult[0].Guy).To(Equal("0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb"))
|
||||
Expect(dbResult[0].Lot).To(Equal("1000000000000000000"))
|
||||
|
||||
var dbTic int64
|
||||
@ -203,7 +203,7 @@ var _ = Describe("Tend LogNoteTransformer", func() {
|
||||
Expect(len(dbResult)).To(Equal(1))
|
||||
Expect(dbResult[0].Bid).To(Equal("1000000000000000"))
|
||||
Expect(dbResult[0].BidId).To(Equal("1"))
|
||||
Expect(dbResult[0].Guy).To(Equal("0x0000d8b4147eDa80Fec7122AE16DA2479Cbd7ffB"))
|
||||
Expect(dbResult[0].Guy).To(Equal("0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb"))
|
||||
Expect(dbResult[0].Lot).To(Equal("1000000000000000000"))
|
||||
|
||||
var dbTic int64
|
||||
|
@ -75,8 +75,8 @@ var _ = Describe("VatFlux LogNoteTransformer", func() {
|
||||
|
||||
Expect(len(dbResult)).To(Equal(1))
|
||||
Expect(dbResult[0].Ilk).To(Equal("5245500000000000000000000000000000000000000000000000000000000000"))
|
||||
Expect(dbResult[0].Src).To(Equal("0xC0851F73CC8DD5c0765E71980eC7E7Fd1EF74434"))
|
||||
Expect(dbResult[0].Dst).To(Equal("0x0000d8b4147eDa80Fec7122AE16DA2479Cbd7ffB"))
|
||||
Expect(dbResult[0].Src).To(Equal("000000000000000000000000c0851f73cc8dd5c0765e71980ec7e7fd1ef74434"))
|
||||
Expect(dbResult[0].Dst).To(Equal("0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb"))
|
||||
Expect(dbResult[0].Rad).To(Equal("1800000000000000000000000000000000000000000000"))
|
||||
Expect(dbResult[0].TransactionIndex).To(Equal(uint(0)))
|
||||
})
|
||||
@ -139,8 +139,8 @@ var _ = Describe("VatFlux LogNoteTransformer", func() {
|
||||
|
||||
Expect(len(dbResult)).To(Equal(1))
|
||||
Expect(dbResult[0].Ilk).To(Equal("5245500000000000000000000000000000000000000000000000000000000000"))
|
||||
Expect(dbResult[0].Src).To(Equal("0xC0851F73CC8DD5c0765E71980eC7E7Fd1EF74434"))
|
||||
Expect(dbResult[0].Dst).To(Equal("0x0000d8b4147eDa80Fec7122AE16DA2479Cbd7ffB"))
|
||||
Expect(dbResult[0].Src).To(Equal("000000000000000000000000c0851f73cc8dd5c0765e71980ec7e7fd1ef74434"))
|
||||
Expect(dbResult[0].Dst).To(Equal("0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb"))
|
||||
Expect(dbResult[0].Rad).To(Equal("1800000000000000000000000000000000000000000000"))
|
||||
Expect(dbResult[0].TransactionIndex).To(Equal(uint(0)))
|
||||
})
|
||||
|
@ -83,7 +83,7 @@ var _ = Describe("VatFold Transformer", func() {
|
||||
Expect(len(dbResults)).To(Equal(1))
|
||||
dbResult := dbResults[0]
|
||||
Expect(dbResult.Ilk).To(Equal("5245500000000000000000000000000000000000000000000000000000000000"))
|
||||
Expect(dbResult.Urn).To(Equal(common.HexToAddress("0x0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1").String()))
|
||||
Expect(dbResult.Urn).To(Equal("0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1"))
|
||||
Expect(dbResult.Rate).To(Equal("0.000000000000000000000000000"))
|
||||
})
|
||||
|
||||
@ -137,7 +137,7 @@ var _ = Describe("VatFold Transformer", func() {
|
||||
Expect(len(dbResults)).To(Equal(1))
|
||||
dbResult := dbResults[0]
|
||||
Expect(dbResult.Ilk).To(Equal("5245500000000000000000000000000000000000000000000000000000000000"))
|
||||
Expect(dbResult.Urn).To(Equal(common.HexToAddress("0x0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1").String()))
|
||||
Expect(dbResult.Urn).To(Equal("0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1"))
|
||||
Expect(dbResult.Rate).To(Equal("0.000000000000000000000000000"))
|
||||
})
|
||||
})
|
||||
|
@ -76,9 +76,9 @@ var _ = Describe("Vat Grab Transformer", func() {
|
||||
|
||||
Expect(len(dbResult)).To(Equal(1))
|
||||
Expect(dbResult[0].Ilk).To(Equal("5245500000000000000000000000000000000000000000000000000000000000"))
|
||||
Expect(dbResult[0].Urn).To(Equal("0x6a3AE20C315E845B2E398e68EfFe39139eC6060C"))
|
||||
Expect(dbResult[0].V).To(Equal("0x2F34f22a00eE4b7a8F8BBC4eAee1658774c624e0")) //cat contract address
|
||||
Expect(dbResult[0].W).To(Equal("0x3728e9777B2a0a611ee0F89e00E01044ce4736d1"))
|
||||
Expect(dbResult[0].Urn).To(Equal("0000000000000000000000006a3ae20c315e845b2e398e68effe39139ec6060c"))
|
||||
Expect(dbResult[0].V).To(Equal("0000000000000000000000002f34f22a00ee4b7a8f8bbc4eaee1658774c624e0")) //cat contract address as bytes32
|
||||
Expect(dbResult[0].W).To(Equal("0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1"))
|
||||
expectedDink := new(big.Int)
|
||||
expectedDink.SetString("115792089237316195423570985008687907853269984665640564039455584007913129639936", 10)
|
||||
Expect(dbResult[0].Dink).To(Equal(expectedDink.String()))
|
||||
@ -144,9 +144,9 @@ var _ = Describe("Vat Grab Transformer", func() {
|
||||
|
||||
Expect(len(dbResult)).To(Equal(1))
|
||||
Expect(dbResult[0].Ilk).To(Equal("5245500000000000000000000000000000000000000000000000000000000000"))
|
||||
Expect(dbResult[0].Urn).To(Equal("0x6a3AE20C315E845B2E398e68EfFe39139eC6060C"))
|
||||
Expect(dbResult[0].V).To(Equal("0x2F34f22a00eE4b7a8F8BBC4eAee1658774c624e0")) //cat contract address
|
||||
Expect(dbResult[0].W).To(Equal("0x3728e9777B2a0a611ee0F89e00E01044ce4736d1"))
|
||||
Expect(dbResult[0].Urn).To(Equal("0000000000000000000000006a3ae20c315e845b2e398e68effe39139ec6060c"))
|
||||
Expect(dbResult[0].V).To(Equal("0000000000000000000000002f34f22a00ee4b7a8f8bbc4eaee1658774c624e0")) //cat contract address
|
||||
Expect(dbResult[0].W).To(Equal("0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1"))
|
||||
expectedDink := new(big.Int)
|
||||
expectedDink.SetString("115792089237316195423570985008687907853269984665640564039455584007913129639936", 10)
|
||||
Expect(dbResult[0].Dink).To(Equal(expectedDink.String()))
|
||||
|
@ -74,8 +74,8 @@ var _ = Describe("VatHeal Transformer", func() {
|
||||
|
||||
Expect(len(dbResults)).To(Equal(1))
|
||||
dbResult := dbResults[0]
|
||||
Expect(dbResult.Urn).To(Equal(common.HexToAddress("0x0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1").String()))
|
||||
Expect(dbResult.V).To(Equal(common.HexToAddress("0x0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1").String()))
|
||||
Expect(dbResult.Urn).To(Equal("0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1"))
|
||||
Expect(dbResult.V).To(Equal("0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1"))
|
||||
Expect(dbResult.Rad).To(Equal("1000000000000000000000000000"))
|
||||
})
|
||||
|
||||
@ -135,8 +135,8 @@ var _ = Describe("VatHeal Transformer", func() {
|
||||
|
||||
Expect(len(dbResults)).To(Equal(1))
|
||||
dbResult := dbResults[0]
|
||||
Expect(dbResult.Urn).To(Equal(common.HexToAddress("0x0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1").String()))
|
||||
Expect(dbResult.V).To(Equal(common.HexToAddress("0x0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1").String()))
|
||||
Expect(dbResult.Urn).To(Equal("0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1"))
|
||||
Expect(dbResult.V).To(Equal("0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1"))
|
||||
Expect(dbResult.Rad).To(Equal("1000000000000000000000000000"))
|
||||
})
|
||||
})
|
||||
|
@ -74,8 +74,8 @@ var _ = Describe("VatMove LogNoteTransformer", func() {
|
||||
|
||||
Expect(len(dbResults)).To(Equal(1))
|
||||
dbResult := dbResults[0]
|
||||
Expect(dbResult.Src).To(Equal(common.HexToAddress("0x8868bad8e74fca4505676d1b5b21ecc23328d132").String()))
|
||||
Expect(dbResult.Dst).To(Equal(common.HexToAddress("0x0000d8b4147eda80fec7122ae16da2479cbd7ffb").String()))
|
||||
Expect(dbResult.Src).To(Equal("0000000000000000000000008868bad8e74fca4505676d1b5b21ecc23328d132"))
|
||||
Expect(dbResult.Dst).To(Equal("0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb"))
|
||||
Expect(dbResult.Rad).To(Equal("1000000000000000000000000000000000000000000000"))
|
||||
})
|
||||
|
||||
@ -136,8 +136,8 @@ var _ = Describe("VatMove LogNoteTransformer", func() {
|
||||
|
||||
Expect(len(dbResults)).To(Equal(1))
|
||||
dbResult := dbResults[0]
|
||||
Expect(dbResult.Src).To(Equal(common.HexToAddress("0x8868bad8e74fca4505676d1b5b21ecc23328d132").String()))
|
||||
Expect(dbResult.Dst).To(Equal(common.HexToAddress("0x0000d8b4147eda80fec7122ae16da2479cbd7ffb").String()))
|
||||
Expect(dbResult.Src).To(Equal("0000000000000000000000008868bad8e74fca4505676d1b5b21ecc23328d132"))
|
||||
Expect(dbResult.Dst).To(Equal("0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb"))
|
||||
Expect(dbResult.Rad).To(Equal("1000000000000000000000000000000000000000000000"))
|
||||
})
|
||||
})
|
||||
|
@ -67,7 +67,7 @@ var _ = Describe("Vat slip transformer", func() {
|
||||
err = db.Get(&model, `SELECT ilk, guy, rad, tx_idx FROM maker.vat_slip WHERE header_id = $1`, headerID)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(model.Ilk).To(Equal("4554480000000000000000000000000000000000000000000000000000000000"))
|
||||
Expect(model.Guy).To(Equal("0xDA15dCE70ab462E66779f23ee14F21d993789eE3"))
|
||||
Expect(model.Guy).To(Equal("000000000000000000000000da15dce70ab462e66779f23ee14f21d993789ee3"))
|
||||
Expect(model.Rad).To(Equal("100000000000000000000000000000000000000000000000"))
|
||||
Expect(model.TransactionIndex).To(Equal(uint(0)))
|
||||
var headerChecked bool
|
||||
@ -125,7 +125,7 @@ var _ = Describe("Vat slip transformer", func() {
|
||||
err = db.Get(&model, `SELECT ilk, guy, rad, tx_idx FROM maker.vat_slip WHERE header_id = $1`, headerID)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(model.Ilk).To(Equal("4554480000000000000000000000000000000000000000000000000000000000"))
|
||||
Expect(model.Guy).To(Equal("0xDA15dCE70ab462E66779f23ee14F21d993789eE3"))
|
||||
Expect(model.Guy).To(Equal("000000000000000000000000da15dce70ab462e66779f23ee14f21d993789ee3"))
|
||||
Expect(model.Rad).To(Equal("100000000000000000000000000000000000000000000000"))
|
||||
Expect(model.TransactionIndex).To(Equal(uint(0)))
|
||||
var headerChecked int
|
||||
|
@ -76,9 +76,9 @@ var _ = Describe("VatTune LogNoteTransformer", func() {
|
||||
|
||||
Expect(len(dbResult)).To(Equal(1))
|
||||
Expect(dbResult[0].Ilk).To(Equal("4554480000000000000000000000000000000000000000000000000000000000"))
|
||||
Expect(dbResult[0].Urn).To(Equal("0x4F26FfBe5F04ED43630fdC30A87638d53D0b0876"))
|
||||
Expect(dbResult[0].V).To(Equal("0x4F26FfBe5F04ED43630fdC30A87638d53D0b0876"))
|
||||
Expect(dbResult[0].W).To(Equal("0x4F26FfBe5F04ED43630fdC30A87638d53D0b0876"))
|
||||
Expect(dbResult[0].Urn).To(Equal("0000000000000000000000004f26ffbe5f04ed43630fdc30a87638d53d0b0876"))
|
||||
Expect(dbResult[0].V).To(Equal("0000000000000000000000004f26ffbe5f04ed43630fdc30a87638d53d0b0876"))
|
||||
Expect(dbResult[0].W).To(Equal("0000000000000000000000004f26ffbe5f04ed43630fdc30a87638d53d0b0876"))
|
||||
Expect(dbResult[0].Dink).To(Equal("0"))
|
||||
expectedDart := new(big.Int)
|
||||
expectedDart.SetString("115792089237316195423570985008687907853269984665640564039455584007913129639936", 10)
|
||||
@ -143,9 +143,9 @@ var _ = Describe("VatTune LogNoteTransformer", func() {
|
||||
|
||||
Expect(len(dbResult)).To(Equal(1))
|
||||
Expect(dbResult[0].Ilk).To(Equal("4554480000000000000000000000000000000000000000000000000000000000"))
|
||||
Expect(dbResult[0].Urn).To(Equal("0x4F26FfBe5F04ED43630fdC30A87638d53D0b0876"))
|
||||
Expect(dbResult[0].V).To(Equal("0x4F26FfBe5F04ED43630fdC30A87638d53D0b0876"))
|
||||
Expect(dbResult[0].W).To(Equal("0x4F26FfBe5F04ED43630fdC30A87638d53D0b0876"))
|
||||
Expect(dbResult[0].Urn).To(Equal("0000000000000000000000004f26ffbe5f04ed43630fdc30a87638d53d0b0876"))
|
||||
Expect(dbResult[0].V).To(Equal("0000000000000000000000004f26ffbe5f04ed43630fdc30a87638d53d0b0876"))
|
||||
Expect(dbResult[0].W).To(Equal("0000000000000000000000004f26ffbe5f04ed43630fdc30a87638d53d0b0876"))
|
||||
Expect(dbResult[0].Dink).To(Equal("0"))
|
||||
expectedDart := new(big.Int)
|
||||
expectedDart.SetString("115792089237316195423570985008687907853269984665640564039455584007913129639936", 10)
|
||||
|
@ -18,8 +18,17 @@ package maker
|
||||
|
||||
import "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
|
||||
type Urn struct {
|
||||
Ilk string
|
||||
Guy string
|
||||
}
|
||||
|
||||
type IMakerStorageRepository interface {
|
||||
GetDaiKeys() ([]string, error)
|
||||
GetGemKeys() ([]Urn, error)
|
||||
GetIlks() ([]string, error)
|
||||
GetSinKeys() ([]string, error)
|
||||
GetUrns() ([]Urn, error)
|
||||
SetDB(db *postgres.DB)
|
||||
}
|
||||
|
||||
@ -27,8 +36,29 @@ type MakerStorageRepository struct {
|
||||
db *postgres.DB
|
||||
}
|
||||
|
||||
func (repository *MakerStorageRepository) SetDB(db *postgres.DB) {
|
||||
repository.db = db
|
||||
func (repository *MakerStorageRepository) GetDaiKeys() ([]string, error) {
|
||||
var daiKeys []string
|
||||
err := repository.db.Select(&daiKeys, `
|
||||
SELECT DISTINCT src FROM maker.vat_move UNION
|
||||
SELECT DISTINCT dst FROM maker.vat_move UNION
|
||||
SELECT DISTINCT w FROM maker.vat_tune UNION
|
||||
SELECT DISTINCT v FROM maker.vat_heal UNION
|
||||
SELECT DISTINCT urn FROM maker.vat_fold
|
||||
`)
|
||||
return daiKeys, err
|
||||
}
|
||||
|
||||
func (repository *MakerStorageRepository) GetGemKeys() ([]Urn, error) {
|
||||
var gems []Urn
|
||||
err := repository.db.Select(&gems, `
|
||||
SELECT DISTINCT ilk, guy FROM maker.vat_slip UNION
|
||||
SELECT DISTINCT ilk, src AS guy FROM maker.vat_flux UNION
|
||||
SELECT DISTINCT ilk, dst AS guy FROM maker.vat_flux UNION
|
||||
SELECT DISTINCT ilk, v AS guy FROM maker.vat_tune UNION
|
||||
SELECT DISTINCT ilk, v AS guy FROM maker.vat_grab UNION
|
||||
SELECT DISTINCT ilk, urn AS guy FROM maker.vat_toll
|
||||
`)
|
||||
return gems, err
|
||||
}
|
||||
|
||||
func (repository MakerStorageRepository) GetIlks() ([]string, error) {
|
||||
@ -36,3 +66,21 @@ func (repository MakerStorageRepository) GetIlks() ([]string, error) {
|
||||
err := repository.db.Select(&ilks, `SELECT DISTINCT ilk FROM maker.vat_init`)
|
||||
return ilks, err
|
||||
}
|
||||
|
||||
func (repository *MakerStorageRepository) GetSinKeys() ([]string, error) {
|
||||
var sinKeys []string
|
||||
err := repository.db.Select(&sinKeys, `SELECT DISTINCT w FROM maker.vat_grab UNION
|
||||
SELECT DISTINCT urn FROM maker.vat_heal`)
|
||||
return sinKeys, err
|
||||
}
|
||||
|
||||
func (repository *MakerStorageRepository) GetUrns() ([]Urn, error) {
|
||||
var urns []Urn
|
||||
err := repository.db.Select(&urns, `SELECT DISTINCT ilk, urn AS guy FROM maker.vat_tune UNION
|
||||
SELECT DISTINCT ilk, urn AS guy FROM maker.vat_grab`)
|
||||
return urns, err
|
||||
}
|
||||
|
||||
func (repository *MakerStorageRepository) SetDB(db *postgres.DB) {
|
||||
repository.db = db
|
||||
}
|
||||
|
@ -27,31 +27,368 @@ import (
|
||||
)
|
||||
|
||||
var _ = Describe("Maker storage repository", func() {
|
||||
It("fetches unique ilks from vat init events", func() {
|
||||
db := test_config.NewTestDB(test_config.NewTestNode())
|
||||
var (
|
||||
db *postgres.DB
|
||||
repository maker.IMakerStorageRepository
|
||||
ilk1 = "ilk1"
|
||||
ilk2 = "ilk2"
|
||||
guy1 = "guy1"
|
||||
guy2 = "guy2"
|
||||
guy3 = "guy3"
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
db = test_config.NewTestDB(test_config.NewTestNode())
|
||||
test_config.CleanTestDB(db)
|
||||
insertVatInit("ilk1", 1, db)
|
||||
insertVatInit("ilk2", 2, db)
|
||||
insertVatInit("ilk2", 3, db)
|
||||
repository := maker.MakerStorageRepository{}
|
||||
repository = &maker.MakerStorageRepository{}
|
||||
repository.SetDB(db)
|
||||
})
|
||||
|
||||
ilks, err := repository.GetIlks()
|
||||
Describe("getting dai keys", func() {
|
||||
It("fetches guy from both src and dst field on vat_move", func() {
|
||||
insertVatMove(guy1, guy2, 1, db)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(ilks)).To(Equal(2))
|
||||
Expect(ilks).To(ConsistOf("ilk1", "ilk2"))
|
||||
keys, err := repository.GetDaiKeys()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(keys)).To(Equal(2))
|
||||
Expect(keys).To(ConsistOf(guy1, guy2))
|
||||
})
|
||||
|
||||
It("fetches guy from w field on vat_tune", func() {
|
||||
insertVatTune(guy1, guy1, guy1, guy2, 1, db)
|
||||
|
||||
keys, err := repository.GetDaiKeys()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(keys)).To(Equal(1))
|
||||
Expect(keys).To(ConsistOf(guy2))
|
||||
})
|
||||
|
||||
It("fetches guy from v field on vat_heal", func() {
|
||||
insertVatHeal(guy2, guy1, 1, db)
|
||||
|
||||
keys, err := repository.GetDaiKeys()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(keys)).To(Equal(1))
|
||||
Expect(keys).To(ConsistOf(guy1))
|
||||
})
|
||||
|
||||
It("fetches unique guys from vat_move + vat_tune + vat_heal + vat_fold", func() {
|
||||
guy4 := "guy4"
|
||||
guy5 := "guy5"
|
||||
guy6 := "guy6"
|
||||
insertVatMove(guy1, guy2, 1, db)
|
||||
insertVatTune(guy1, guy1, guy1, guy3, 2, db)
|
||||
insertVatHeal(guy6, guy4, 3, db)
|
||||
insertVatFold(guy5, 4, db)
|
||||
// duplicates
|
||||
insertVatMove(guy3, guy1, 5, db)
|
||||
insertVatTune(guy2, guy2, guy2, guy5, 6, db)
|
||||
insertVatHeal(guy6, guy2, 7, db)
|
||||
insertVatFold(guy4, 8, db)
|
||||
|
||||
keys, err := repository.GetDaiKeys()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(keys)).To(Equal(5))
|
||||
Expect(keys).To(ConsistOf(guy1, guy2, guy3, guy4, guy5))
|
||||
})
|
||||
|
||||
It("does not return error if no matching rows", func() {
|
||||
daiKeys, err := repository.GetDaiKeys()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(daiKeys)).To(BeZero())
|
||||
})
|
||||
})
|
||||
|
||||
Describe("getting gem keys", func() {
|
||||
It("fetches guy from both src and dst field on vat_flux", func() {
|
||||
insertVatFlux(ilk1, guy1, guy2, 1, db)
|
||||
|
||||
gems, err := repository.GetGemKeys()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(gems)).To(Equal(2))
|
||||
Expect(gems).To(ConsistOf([]maker.Urn{{
|
||||
Ilk: ilk1,
|
||||
Guy: guy1,
|
||||
}, {
|
||||
Ilk: ilk1,
|
||||
Guy: guy2,
|
||||
}}))
|
||||
})
|
||||
|
||||
It("fetches guy from v field on vat_tune + vat_grab", func() {
|
||||
insertVatTune(ilk1, guy1, guy2, guy1, 1, db)
|
||||
insertVatGrab(ilk1, guy1, guy3, guy1, 2, db)
|
||||
|
||||
gems, err := repository.GetGemKeys()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(gems)).To(Equal(2))
|
||||
Expect(gems).To(ConsistOf([]maker.Urn{{
|
||||
Ilk: ilk1,
|
||||
Guy: guy2,
|
||||
}, {
|
||||
Ilk: ilk1,
|
||||
Guy: guy3,
|
||||
}}))
|
||||
})
|
||||
|
||||
It("fetches unique urns from vat_slip + vat_flux + vat_tune + vat_grab + vat_toll events", func() {
|
||||
insertVatSlip(ilk1, guy1, 1, db)
|
||||
insertVatFlux(ilk1, guy2, guy3, 2, db)
|
||||
insertVatTune(ilk2, guy1, guy1, guy1, 3, db)
|
||||
insertVatGrab(ilk2, guy1, guy2, guy1, 4, db)
|
||||
insertVatToll(ilk2, guy3, 5, db)
|
||||
// duplicates
|
||||
insertVatSlip(ilk1, guy2, 6, db)
|
||||
insertVatFlux(ilk2, guy2, guy3, 7, db)
|
||||
insertVatTune(ilk2, guy1, guy1, guy1, 8, db)
|
||||
insertVatGrab(ilk1, guy1, guy1, guy1, 9, db)
|
||||
insertVatToll(ilk1, guy3, 10, db)
|
||||
|
||||
gems, err := repository.GetGemKeys()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(gems)).To(Equal(6))
|
||||
Expect(gems).To(ConsistOf([]maker.Urn{{
|
||||
Ilk: ilk1,
|
||||
Guy: guy1,
|
||||
}, {
|
||||
Ilk: ilk1,
|
||||
Guy: guy2,
|
||||
}, {
|
||||
Ilk: ilk1,
|
||||
Guy: guy3,
|
||||
}, {
|
||||
Ilk: ilk2,
|
||||
Guy: guy1,
|
||||
}, {
|
||||
Ilk: ilk2,
|
||||
Guy: guy2,
|
||||
}, {
|
||||
Ilk: ilk2,
|
||||
Guy: guy3,
|
||||
}}))
|
||||
})
|
||||
|
||||
It("does not return error if no matching rows", func() {
|
||||
gemKeys, err := repository.GetGemKeys()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(gemKeys)).To(BeZero())
|
||||
})
|
||||
})
|
||||
|
||||
Describe("getting ilks", func() {
|
||||
It("fetches unique ilks from vat init events", func() {
|
||||
insertVatInit(ilk1, 1, db)
|
||||
insertVatInit(ilk2, 2, db)
|
||||
insertVatInit(ilk2, 3, db)
|
||||
|
||||
ilks, err := repository.GetIlks()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(ilks)).To(Equal(2))
|
||||
Expect(ilks).To(ConsistOf(ilk1, ilk2))
|
||||
})
|
||||
|
||||
It("does not return error if no matching rows", func() {
|
||||
ilks, err := repository.GetIlks()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(ilks)).To(BeZero())
|
||||
})
|
||||
})
|
||||
|
||||
Describe("getting sin keys", func() {
|
||||
It("fetches guy from w field of vat grab", func() {
|
||||
insertVatGrab(guy1, guy1, guy1, guy2, 1, db)
|
||||
|
||||
sinKeys, err := repository.GetSinKeys()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(sinKeys)).To(Equal(1))
|
||||
Expect(sinKeys).To(ConsistOf(guy2))
|
||||
})
|
||||
|
||||
It("fetches guy from u field of vat heal", func() {
|
||||
insertVatHeal(guy1, guy2, 1, db)
|
||||
|
||||
sinKeys, err := repository.GetSinKeys()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(sinKeys)).To(Equal(1))
|
||||
Expect(sinKeys).To(ConsistOf(guy1))
|
||||
})
|
||||
|
||||
It("fetches unique sin keys from vat_grab + vat_heal", func() {
|
||||
insertVatGrab(guy3, guy3, guy3, guy1, 1, db)
|
||||
insertVatHeal(guy2, guy3, 2, db)
|
||||
// duplicates
|
||||
insertVatGrab(guy2, guy2, guy2, guy2, 3, db)
|
||||
insertVatHeal(guy1, guy2, 4, db)
|
||||
|
||||
sinKeys, err := repository.GetSinKeys()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(sinKeys)).To(Equal(2))
|
||||
Expect(sinKeys).To(ConsistOf(guy1, guy2))
|
||||
})
|
||||
|
||||
It("does not return error if no matching rows", func() {
|
||||
sinKeys, err := repository.GetSinKeys()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(sinKeys)).To(BeZero())
|
||||
})
|
||||
})
|
||||
|
||||
Describe("getting urns", func() {
|
||||
It("fetches unique urns from vat_tune + vat_grab events", func() {
|
||||
insertVatTune(ilk1, guy1, guy1, guy1, 1, db)
|
||||
insertVatTune(ilk1, guy2, guy1, guy1, 2, db)
|
||||
insertVatTune(ilk2, guy1, guy1, guy1, 3, db)
|
||||
insertVatTune(ilk1, guy1, guy1, guy1, 4, db)
|
||||
insertVatGrab(ilk1, guy1, guy1, guy1, 5, db)
|
||||
insertVatGrab(ilk1, guy3, guy1, guy1, 6, db)
|
||||
|
||||
urns, err := repository.GetUrns()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(urns)).To(Equal(4))
|
||||
Expect(urns).To(ConsistOf([]maker.Urn{{
|
||||
Ilk: ilk1,
|
||||
Guy: guy1,
|
||||
}, {
|
||||
Ilk: ilk1,
|
||||
Guy: guy2,
|
||||
}, {
|
||||
Ilk: ilk2,
|
||||
Guy: guy1,
|
||||
}, {
|
||||
Ilk: ilk1,
|
||||
Guy: guy3,
|
||||
}}))
|
||||
})
|
||||
|
||||
It("does not return error if no matching rows", func() {
|
||||
urns, err := repository.GetUrns()
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(len(urns)).To(BeZero())
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
func insertVatFold(urn string, blockNumber int64, db *postgres.DB) {
|
||||
headerRepository := repositories.NewHeaderRepository(db)
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(blockNumber))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
_, execErr := db.Exec(
|
||||
`INSERT INTO maker.vat_fold (header_id, urn, log_idx, tx_idx)
|
||||
VALUES($1, $2, $3, $4)`,
|
||||
headerID, urn, 0, 0,
|
||||
)
|
||||
Expect(execErr).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
func insertVatFlux(ilk, src, dst string, blockNumber int64, db *postgres.DB) {
|
||||
headerRepository := repositories.NewHeaderRepository(db)
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(blockNumber))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
_, execErr := db.Exec(
|
||||
`INSERT INTO maker.vat_flux (header_id, ilk, src, dst, log_idx, tx_idx)
|
||||
VALUES($1, $2, $3, $4, $5, $6)`,
|
||||
headerID, ilk, src, dst, 0, 0,
|
||||
)
|
||||
Expect(execErr).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
func insertVatGrab(ilk, urn, v, w string, blockNumber int64, db *postgres.DB) {
|
||||
headerRepository := repositories.NewHeaderRepository(db)
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(blockNumber))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
_, execErr := db.Exec(
|
||||
`INSERT INTO maker.vat_grab (header_id, ilk, urn, v, w, log_idx, tx_idx)
|
||||
VALUES($1, $2, $3, $4, $5, $6, $7)`,
|
||||
headerID, ilk, urn, v, w, 0, 0,
|
||||
)
|
||||
Expect(execErr).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
func insertVatHeal(urn, v string, blockNumber int64, db *postgres.DB) {
|
||||
headerRepository := repositories.NewHeaderRepository(db)
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(blockNumber))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
_, execErr := db.Exec(
|
||||
`INSERT INTO maker.vat_heal (header_id, urn, v, log_idx, tx_idx)
|
||||
VALUES($1, $2, $3, $4, $5)`,
|
||||
headerID, urn, v, 0, 0,
|
||||
)
|
||||
Expect(execErr).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
func insertVatInit(ilk string, blockNumber int64, db *postgres.DB) {
|
||||
headerRepository := repositories.NewHeaderRepository(db)
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(blockNumber))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
_, execErr := db.Exec(
|
||||
`INSERT INTO maker.vat_init (header_id, ilk, log_idx, tx_idx, raw_log)
|
||||
VALUES($1, $2, $3, $4, $5)`,
|
||||
headerID, ilk, 0, 0, "[]",
|
||||
`INSERT INTO maker.vat_init (header_id, ilk, log_idx, tx_idx)
|
||||
VALUES($1, $2, $3, $4)`,
|
||||
headerID, ilk, 0, 0,
|
||||
)
|
||||
Expect(execErr).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
func insertVatMove(src, dst string, blockNumber int64, db *postgres.DB) {
|
||||
headerRepository := repositories.NewHeaderRepository(db)
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(blockNumber))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
_, execErr := db.Exec(
|
||||
`INSERT INTO maker.vat_move (header_id, src, dst, rad, log_idx, tx_idx)
|
||||
VALUES($1, $2, $3, $4, $5, $6)`,
|
||||
headerID, src, dst, 0, 0, 0,
|
||||
)
|
||||
Expect(execErr).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
func insertVatSlip(ilk, guy string, blockNumber int64, db *postgres.DB) {
|
||||
headerRepository := repositories.NewHeaderRepository(db)
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(blockNumber))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
_, execErr := db.Exec(
|
||||
`INSERT INTO maker.vat_slip (header_id, ilk, guy, log_idx, tx_idx)
|
||||
VALUES($1, $2, $3, $4, $5)`,
|
||||
headerID, ilk, guy, 0, 0,
|
||||
)
|
||||
Expect(execErr).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
func insertVatToll(ilk, urn string, blockNumber int64, db *postgres.DB) {
|
||||
headerRepository := repositories.NewHeaderRepository(db)
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(blockNumber))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
_, execErr := db.Exec(
|
||||
`INSERT INTO maker.vat_toll (header_id, ilk, urn, log_idx, tx_idx)
|
||||
VALUES($1, $2, $3, $4, $5)`,
|
||||
headerID, ilk, urn, 0, 0,
|
||||
)
|
||||
Expect(execErr).NotTo(HaveOccurred())
|
||||
}
|
||||
|
||||
func insertVatTune(ilk, urn, v, w string, blockNumber int64, db *postgres.DB) {
|
||||
headerRepository := repositories.NewHeaderRepository(db)
|
||||
headerID, err := headerRepository.CreateOrUpdateHeader(fakes.GetFakeHeader(blockNumber))
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
_, execErr := db.Exec(
|
||||
`INSERT INTO maker.vat_tune (header_id, ilk, urn, v, w, log_idx, tx_idx)
|
||||
VALUES($1, $2, $3, $4, $5, $6, $7)`,
|
||||
headerID, ilk, urn, v, w, 0, 0,
|
||||
)
|
||||
Expect(execErr).NotTo(HaveOccurred())
|
||||
}
|
||||
|
@ -18,12 +18,10 @@ package pit
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"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"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
const (
|
||||
@ -40,7 +38,7 @@ var (
|
||||
DripKey = common.HexToHash(storage_diffs.IndexFive)
|
||||
DripMetadata = shared.StorageValueMetadata{
|
||||
Name: PitDrip,
|
||||
Key: "",
|
||||
Keys: nil,
|
||||
Type: shared.Address,
|
||||
}
|
||||
|
||||
@ -50,7 +48,7 @@ var (
|
||||
LineKey = common.HexToHash(storage_diffs.IndexThree)
|
||||
LineMetadata = shared.StorageValueMetadata{
|
||||
Name: PitLine,
|
||||
Key: "",
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
@ -58,7 +56,7 @@ var (
|
||||
LiveKey = common.HexToHash(storage_diffs.IndexTwo)
|
||||
LiveMetadata = shared.StorageValueMetadata{
|
||||
Name: PitLive,
|
||||
Key: "",
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
@ -66,7 +64,7 @@ var (
|
||||
VatKey = common.HexToHash(storage_diffs.IndexFour)
|
||||
VatMetadata = shared.StorageValueMetadata{
|
||||
Name: PitVat,
|
||||
Key: "",
|
||||
Keys: nil,
|
||||
Type: shared.Address,
|
||||
}
|
||||
)
|
||||
@ -118,29 +116,19 @@ func getStaticMappings() map[common.Hash]shared.StorageValueMetadata {
|
||||
}
|
||||
|
||||
func getSpotKey(ilk string) common.Hash {
|
||||
keyBytes := common.FromHex("0x" + ilk + IlkSpotIndex)
|
||||
encoded := crypto.Keccak256(keyBytes)
|
||||
return common.BytesToHash(encoded)
|
||||
return storage_diffs.GetMapping(IlkSpotIndex, ilk)
|
||||
}
|
||||
|
||||
func getSpotMetadata(ilk string) shared.StorageValueMetadata {
|
||||
return shared.StorageValueMetadata{
|
||||
Name: IlkSpot,
|
||||
Key: ilk,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
keys := map[shared.Key]string{shared.Ilk: ilk}
|
||||
return shared.GetStorageValueMetadata(IlkSpot, keys, shared.Uint256)
|
||||
}
|
||||
|
||||
func getLineKey(ilk string) common.Hash {
|
||||
spotMappingAsInt := big.NewInt(0).SetBytes(getSpotKey(ilk).Bytes())
|
||||
incrementedByOne := big.NewInt(0).Add(spotMappingAsInt, big.NewInt(1))
|
||||
return common.BytesToHash(incrementedByOne.Bytes())
|
||||
return storage_diffs.GetIncrementedKey(getSpotKey(ilk), 1)
|
||||
}
|
||||
|
||||
func getLineMetadata(ilk string) shared.StorageValueMetadata {
|
||||
return shared.StorageValueMetadata{
|
||||
Name: IlkLine,
|
||||
Key: ilk,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
keys := map[shared.Key]string{shared.Ilk: ilk}
|
||||
return shared.GetStorageValueMetadata(IlkLine, keys, shared.Uint256)
|
||||
}
|
||||
|
@ -47,12 +47,12 @@ var _ = Describe("Pit storage mappings", func() {
|
||||
It("returns value metadata for spot when ilk in the DB", func() {
|
||||
storageRepository := &test_helpers.MockMakerStorageRepository{}
|
||||
fakeIlk := "fakeIlk"
|
||||
storageRepository.SetIlks([]string{fakeIlk})
|
||||
storageRepository.Ilks = []string{fakeIlk}
|
||||
mappings := pit.PitMappings{StorageRepository: storageRepository}
|
||||
ilkSpotKey := common.BytesToHash(crypto.Keccak256(common.FromHex("0x" + fakeIlk + pit.IlkSpotIndex)))
|
||||
expectedMetadata := shared.StorageValueMetadata{
|
||||
Name: pit.IlkSpot,
|
||||
Key: fakeIlk,
|
||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ var _ = Describe("Pit storage mappings", func() {
|
||||
It("returns value metadata for line when ilk in the DB", func() {
|
||||
storageRepository := &test_helpers.MockMakerStorageRepository{}
|
||||
fakeIlk := "fakeIlk"
|
||||
storageRepository.SetIlks([]string{fakeIlk})
|
||||
storageRepository.Ilks = []string{fakeIlk}
|
||||
mappings := pit.PitMappings{StorageRepository: storageRepository}
|
||||
ilkSpotKeyBytes := crypto.Keccak256(common.FromHex("0x" + fakeIlk + pit.IlkSpotIndex))
|
||||
ilkSpotAsInt := big.NewInt(0).SetBytes(ilkSpotKeyBytes)
|
||||
@ -70,7 +70,7 @@ var _ = Describe("Pit storage mappings", func() {
|
||||
ilkLineKey := common.BytesToHash(incrementedIlkSpot.Bytes())
|
||||
expectedMetadata := shared.StorageValueMetadata{
|
||||
Name: pit.IlkLine,
|
||||
Key: fakeIlk,
|
||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
|
@ -17,6 +17,7 @@
|
||||
package pit
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared"
|
||||
)
|
||||
@ -32,9 +33,9 @@ func (repository *PitStorageRepository) SetDB(db *postgres.DB) {
|
||||
func (repository PitStorageRepository) Create(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, value interface{}) error {
|
||||
switch metadata.Name {
|
||||
case IlkLine:
|
||||
return repository.insertIlkLine(blockNumber, blockHash, metadata.Key, value.(string))
|
||||
return repository.insertIlkLine(blockNumber, blockHash, metadata.Keys[shared.Ilk], value.(string))
|
||||
case IlkSpot:
|
||||
return repository.insertIlkSpot(blockNumber, blockHash, metadata.Key, value.(string))
|
||||
return repository.insertIlkSpot(blockNumber, blockHash, metadata.Keys[shared.Ilk], value.(string))
|
||||
case PitDrip:
|
||||
return repository.insertPitDrip(blockNumber, blockHash, value.(string))
|
||||
case PitLine:
|
||||
@ -44,7 +45,7 @@ func (repository PitStorageRepository) Create(blockNumber int, blockHash string,
|
||||
case PitVat:
|
||||
return repository.insertPitVat(blockNumber, blockHash, value.(string))
|
||||
default:
|
||||
panic("unrecognized storage metadata name")
|
||||
panic(fmt.Sprintf("unrecognized pit contract storage name: %s", metadata.Name))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,7 +48,7 @@ var _ = Describe("Pit storage repository", func() {
|
||||
expectedLine := "12345"
|
||||
ilkLineMetadata := shared.StorageValueMetadata{
|
||||
Name: pit.IlkLine,
|
||||
Key: expectedIlk,
|
||||
Keys: map[shared.Key]string{shared.Ilk: expectedIlk},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
err = repo.Create(blockNumber, blockHash, ilkLineMetadata, expectedLine)
|
||||
@ -73,7 +73,7 @@ var _ = Describe("Pit storage repository", func() {
|
||||
expectedSpot := "12345"
|
||||
ilkSpotMetadata := shared.StorageValueMetadata{
|
||||
Name: pit.IlkSpot,
|
||||
Key: expectedIlk,
|
||||
Keys: map[shared.Key]string{shared.Ilk: expectedIlk},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
err = repo.Create(blockNumber, blockHash, ilkSpotMetadata, expectedSpot)
|
||||
|
@ -1,19 +1,51 @@
|
||||
package test_helpers
|
||||
|
||||
import "github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker"
|
||||
)
|
||||
|
||||
type MockMakerStorageRepository struct {
|
||||
GetIlksCalled bool
|
||||
ilks []string
|
||||
DaiKeys []string
|
||||
GemKeys []maker.Urn
|
||||
GetDaiKeysCalled bool
|
||||
GetDaiKeysError error
|
||||
GetGemKeysCalled bool
|
||||
GetGemKeysError error
|
||||
GetIlksCalled bool
|
||||
GetIlksError error
|
||||
GetSinKeysCalled bool
|
||||
GetSinKeysError error
|
||||
GetUrnsCalled bool
|
||||
GetUrnsError error
|
||||
Ilks []string
|
||||
SinKeys []string
|
||||
Urns []maker.Urn
|
||||
}
|
||||
|
||||
func (repository *MockMakerStorageRepository) GetDaiKeys() ([]string, error) {
|
||||
repository.GetDaiKeysCalled = true
|
||||
return repository.DaiKeys, repository.GetDaiKeysError
|
||||
}
|
||||
|
||||
func (repository *MockMakerStorageRepository) GetGemKeys() ([]maker.Urn, error) {
|
||||
repository.GetGemKeysCalled = true
|
||||
return repository.GemKeys, repository.GetGemKeysError
|
||||
}
|
||||
|
||||
func (repository *MockMakerStorageRepository) GetIlks() ([]string, error) {
|
||||
repository.GetIlksCalled = true
|
||||
return repository.ilks, nil
|
||||
return repository.Ilks, repository.GetIlksError
|
||||
}
|
||||
|
||||
func (repository *MockMakerStorageRepository) GetSinKeys() ([]string, error) {
|
||||
repository.GetSinKeysCalled = true
|
||||
return repository.SinKeys, repository.GetSinKeysError
|
||||
}
|
||||
|
||||
func (repository *MockMakerStorageRepository) GetUrns() ([]maker.Urn, error) {
|
||||
repository.GetUrnsCalled = true
|
||||
return repository.Urns, repository.GetUrnsError
|
||||
}
|
||||
|
||||
func (repository *MockMakerStorageRepository) SetDB(db *postgres.DB) {}
|
||||
|
||||
func (repository *MockMakerStorageRepository) SetIlks(ilks []string) {
|
||||
repository.ilks = ilks
|
||||
}
|
||||
|
241
pkg/transformers/storage_diffs/maker/vat/mappings.go
Normal file
241
pkg/transformers/storage_diffs/maker/vat/mappings.go
Normal file
@ -0,0 +1,241 @@
|
||||
package vat
|
||||
|
||||
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 (
|
||||
Dai = "dai"
|
||||
Gem = "gem"
|
||||
IlkArt = "Art"
|
||||
IlkInk = "Ink"
|
||||
IlkRate = "rate"
|
||||
IlkTake = "take"
|
||||
Sin = "sin"
|
||||
UrnArt = "art"
|
||||
UrnInk = "ink"
|
||||
VatDebt = "debt"
|
||||
VatVice = "vice"
|
||||
)
|
||||
|
||||
var (
|
||||
DebtKey = common.HexToHash(storage_diffs.IndexSix)
|
||||
DebtMetadata = shared.StorageValueMetadata{
|
||||
Name: VatDebt,
|
||||
Keys: nil,
|
||||
Type: 0,
|
||||
}
|
||||
|
||||
IlksMappingIndex = storage_diffs.IndexOne
|
||||
UrnsMappingIndex = storage_diffs.IndexTwo
|
||||
GemsMappingIndex = storage_diffs.IndexThree
|
||||
DaiMappingIndex = storage_diffs.IndexFour
|
||||
SinMappingIndex = storage_diffs.IndexFive
|
||||
|
||||
ViceKey = common.HexToHash(storage_diffs.IndexSeven)
|
||||
ViceMetadata = shared.StorageValueMetadata{
|
||||
Name: VatVice,
|
||||
Keys: nil,
|
||||
Type: 0,
|
||||
}
|
||||
)
|
||||
|
||||
type VatMappings struct {
|
||||
StorageRepository maker.IMakerStorageRepository
|
||||
mappings map[common.Hash]shared.StorageValueMetadata
|
||||
}
|
||||
|
||||
func (mappings VatMappings) 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 *VatMappings) SetDB(db *postgres.DB) {
|
||||
mappings.StorageRepository.SetDB(db)
|
||||
}
|
||||
|
||||
func (mappings *VatMappings) loadMappings() error {
|
||||
mappings.mappings = loadStaticMappings()
|
||||
daiErr := mappings.loadDaiKeys()
|
||||
if daiErr != nil {
|
||||
return daiErr
|
||||
}
|
||||
gemErr := mappings.loadGemKeys()
|
||||
if gemErr != nil {
|
||||
return gemErr
|
||||
}
|
||||
ilkErr := mappings.loadIlkKeys()
|
||||
if ilkErr != nil {
|
||||
return ilkErr
|
||||
}
|
||||
sinErr := mappings.loadSinKeys()
|
||||
if sinErr != nil {
|
||||
return sinErr
|
||||
}
|
||||
urnErr := mappings.loadUrnKeys()
|
||||
if urnErr != nil {
|
||||
return urnErr
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func loadStaticMappings() map[common.Hash]shared.StorageValueMetadata {
|
||||
mappings := make(map[common.Hash]shared.StorageValueMetadata)
|
||||
mappings[DebtKey] = DebtMetadata
|
||||
mappings[ViceKey] = ViceMetadata
|
||||
return mappings
|
||||
}
|
||||
|
||||
func (mappings *VatMappings) loadDaiKeys() error {
|
||||
daiKeys, err := mappings.StorageRepository.GetDaiKeys()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, d := range daiKeys {
|
||||
mappings.mappings[getDaiKey(d)] = getDaiMetadata(d)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mappings *VatMappings) loadGemKeys() error {
|
||||
gemKeys, err := mappings.StorageRepository.GetGemKeys()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, gem := range gemKeys {
|
||||
mappings.mappings[getGemKey(gem.Ilk, gem.Guy)] = getGemMetadata(gem.Ilk, gem.Guy)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mappings *VatMappings) loadIlkKeys() error {
|
||||
ilks, err := mappings.StorageRepository.GetIlks()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, ilk := range ilks {
|
||||
mappings.mappings[getIlkTakeKey(ilk)] = getIlkTakeMetadata(ilk)
|
||||
mappings.mappings[getIlkRateKey(ilk)] = getIlkRateMetadata(ilk)
|
||||
mappings.mappings[getIlkInkKey(ilk)] = getIlkInkMetadata(ilk)
|
||||
mappings.mappings[getIlkArtKey(ilk)] = getIlkArtMetadata(ilk)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mappings *VatMappings) loadSinKeys() error {
|
||||
sinKeys, err := mappings.StorageRepository.GetSinKeys()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, s := range sinKeys {
|
||||
mappings.mappings[getSinKey(s)] = getSinMetadata(s)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (mappings *VatMappings) loadUrnKeys() error {
|
||||
urns, err := mappings.StorageRepository.GetUrns()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
for _, urn := range urns {
|
||||
mappings.mappings[getUrnInkKey(urn.Ilk, urn.Guy)] = getUrnInkMetadata(urn.Ilk, urn.Guy)
|
||||
mappings.mappings[getUrnArtKey(urn.Ilk, urn.Guy)] = getUrnArtMetadata(urn.Ilk, urn.Guy)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func getIlkTakeKey(ilk string) common.Hash {
|
||||
return storage_diffs.GetMapping(IlksMappingIndex, ilk)
|
||||
}
|
||||
|
||||
func getIlkTakeMetadata(ilk string) shared.StorageValueMetadata {
|
||||
keys := map[shared.Key]string{shared.Ilk: ilk}
|
||||
return shared.GetStorageValueMetadata(IlkTake, keys, shared.Uint256)
|
||||
}
|
||||
|
||||
func getIlkRateKey(ilk string) common.Hash {
|
||||
return storage_diffs.GetIncrementedKey(getIlkTakeKey(ilk), 1)
|
||||
}
|
||||
|
||||
func getIlkRateMetadata(ilk string) shared.StorageValueMetadata {
|
||||
keys := map[shared.Key]string{shared.Ilk: ilk}
|
||||
return shared.GetStorageValueMetadata(IlkRate, keys, shared.Uint256)
|
||||
}
|
||||
|
||||
func getIlkInkKey(ilk string) common.Hash {
|
||||
return storage_diffs.GetIncrementedKey(getIlkTakeKey(ilk), 2)
|
||||
}
|
||||
|
||||
func getIlkInkMetadata(ilk string) shared.StorageValueMetadata {
|
||||
keys := map[shared.Key]string{shared.Ilk: ilk}
|
||||
return shared.GetStorageValueMetadata(IlkInk, keys, shared.Uint256)
|
||||
}
|
||||
|
||||
func getIlkArtKey(ilk string) common.Hash {
|
||||
return storage_diffs.GetIncrementedKey(getIlkTakeKey(ilk), 3)
|
||||
}
|
||||
|
||||
func getIlkArtMetadata(ilk string) shared.StorageValueMetadata {
|
||||
keys := map[shared.Key]string{shared.Ilk: ilk}
|
||||
return shared.GetStorageValueMetadata(IlkArt, keys, shared.Uint256)
|
||||
}
|
||||
|
||||
func getUrnInkKey(ilk, guy string) common.Hash {
|
||||
return storage_diffs.GetNestedMapping(UrnsMappingIndex, ilk, guy)
|
||||
}
|
||||
|
||||
func getUrnInkMetadata(ilk, guy string) shared.StorageValueMetadata {
|
||||
keys := map[shared.Key]string{shared.Ilk: ilk, shared.Guy: guy}
|
||||
return shared.GetStorageValueMetadata(UrnInk, keys, shared.Uint256)
|
||||
}
|
||||
|
||||
func getUrnArtKey(ilk, guy string) common.Hash {
|
||||
return storage_diffs.GetIncrementedKey(getUrnInkKey(ilk, guy), 1)
|
||||
}
|
||||
|
||||
func getUrnArtMetadata(ilk, guy string) shared.StorageValueMetadata {
|
||||
keys := map[shared.Key]string{shared.Ilk: ilk, shared.Guy: guy}
|
||||
return shared.GetStorageValueMetadata(UrnArt, keys, shared.Uint256)
|
||||
}
|
||||
|
||||
func getGemKey(ilk, guy string) common.Hash {
|
||||
return storage_diffs.GetNestedMapping(GemsMappingIndex, ilk, guy)
|
||||
}
|
||||
|
||||
func getGemMetadata(ilk, guy string) shared.StorageValueMetadata {
|
||||
keys := map[shared.Key]string{shared.Ilk: ilk, shared.Guy: guy}
|
||||
return shared.GetStorageValueMetadata(Gem, keys, shared.Uint256)
|
||||
}
|
||||
|
||||
func getDaiKey(guy string) common.Hash {
|
||||
return storage_diffs.GetMapping(DaiMappingIndex, guy)
|
||||
}
|
||||
|
||||
func getDaiMetadata(guy string) shared.StorageValueMetadata {
|
||||
keys := map[shared.Key]string{shared.Guy: guy}
|
||||
return shared.GetStorageValueMetadata(Dai, keys, shared.Uint256)
|
||||
}
|
||||
|
||||
func getSinKey(guy string) common.Hash {
|
||||
return storage_diffs.GetMapping(SinMappingIndex, guy)
|
||||
}
|
||||
|
||||
func getSinMetadata(guy string) shared.StorageValueMetadata {
|
||||
keys := map[shared.Key]string{shared.Guy: guy}
|
||||
return shared.GetStorageValueMetadata(Sin, keys, shared.Uint256)
|
||||
}
|
233
pkg/transformers/storage_diffs/maker/vat/mappings_test.go
Normal file
233
pkg/transformers/storage_diffs/maker/vat/mappings_test.go
Normal file
@ -0,0 +1,233 @@
|
||||
package vat_test
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/fakes"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/test_helpers"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/maker/vat"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
var _ = Describe("Vat storage mappings", func() {
|
||||
var (
|
||||
fakeIlk = "fakeIlk"
|
||||
fakeGuy = "fakeGuy"
|
||||
storageRepository *test_helpers.MockMakerStorageRepository
|
||||
mappings vat.VatMappings
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
storageRepository = &test_helpers.MockMakerStorageRepository{}
|
||||
mappings = vat.VatMappings{StorageRepository: storageRepository}
|
||||
})
|
||||
|
||||
Describe("looking up static keys", func() {
|
||||
It("returns value metadata if key exists", func() {
|
||||
Expect(mappings.Lookup(vat.DebtKey)).To(Equal(vat.DebtMetadata))
|
||||
Expect(mappings.Lookup(vat.ViceKey)).To(Equal(vat.ViceMetadata))
|
||||
})
|
||||
|
||||
It("returns error if key does not exist", func() {
|
||||
_, err := mappings.Lookup(common.HexToHash(fakes.FakeHash.Hex()))
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(shared.ErrStorageKeyNotFound{Key: fakes.FakeHash.Hex()}))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("looking up dynamic keys", func() {
|
||||
It("refreshes mappings from repository if key not found", func() {
|
||||
mappings.Lookup(fakes.FakeHash)
|
||||
|
||||
Expect(storageRepository.GetDaiKeysCalled).To(BeTrue())
|
||||
Expect(storageRepository.GetGemKeysCalled).To(BeTrue())
|
||||
Expect(storageRepository.GetIlksCalled).To(BeTrue())
|
||||
Expect(storageRepository.GetSinKeysCalled).To(BeTrue())
|
||||
Expect(storageRepository.GetUrnsCalled).To(BeTrue())
|
||||
})
|
||||
|
||||
It("returns error if dai keys lookup fails", func() {
|
||||
storageRepository.GetDaiKeysError = fakes.FakeError
|
||||
|
||||
_, err := mappings.Lookup(fakes.FakeHash)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(fakes.FakeError))
|
||||
})
|
||||
|
||||
It("returns error if gem keys lookup fails", func() {
|
||||
storageRepository.GetGemKeysError = fakes.FakeError
|
||||
|
||||
_, err := mappings.Lookup(fakes.FakeHash)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(fakes.FakeError))
|
||||
})
|
||||
|
||||
It("returns error if ilks lookup fails", func() {
|
||||
storageRepository.GetIlksError = fakes.FakeError
|
||||
|
||||
_, err := mappings.Lookup(fakes.FakeHash)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(fakes.FakeError))
|
||||
})
|
||||
|
||||
It("returns error if sin keys lookup fails", func() {
|
||||
storageRepository.GetSinKeysError = fakes.FakeError
|
||||
|
||||
_, err := mappings.Lookup(fakes.FakeHash)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(fakes.FakeError))
|
||||
})
|
||||
|
||||
It("returns error if urns lookup fails", func() {
|
||||
storageRepository.GetUrnsError = fakes.FakeError
|
||||
|
||||
_, err := mappings.Lookup(fakes.FakeHash)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(fakes.FakeError))
|
||||
})
|
||||
|
||||
Describe("ilk", func() {
|
||||
It("returns value metadata for ilk take", func() {
|
||||
storageRepository.Ilks = []string{fakeIlk}
|
||||
ilkTakeKey := common.BytesToHash(crypto.Keccak256(common.FromHex("0x" + fakeIlk + vat.IlksMappingIndex)))
|
||||
expectedMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.IlkTake,
|
||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
Expect(mappings.Lookup(ilkTakeKey)).To(Equal(expectedMetadata))
|
||||
})
|
||||
|
||||
It("returns value metadata for ilk rate", func() {
|
||||
storageRepository.Ilks = []string{fakeIlk}
|
||||
ilkTakeBytes := crypto.Keccak256(common.FromHex("0x" + fakeIlk + vat.IlksMappingIndex))
|
||||
ilkTakeAsInt := big.NewInt(0).SetBytes(ilkTakeBytes)
|
||||
incrementedIlkTake := big.NewInt(0).Add(ilkTakeAsInt, big.NewInt(1))
|
||||
ilkRateKey := common.BytesToHash(incrementedIlkTake.Bytes())
|
||||
expectedMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.IlkRate,
|
||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
Expect(mappings.Lookup(ilkRateKey)).To(Equal(expectedMetadata))
|
||||
})
|
||||
|
||||
It("returns value metadata for ilk Ink", func() {
|
||||
storageRepository.Ilks = []string{fakeIlk}
|
||||
ilkTakeBytes := crypto.Keccak256(common.FromHex("0x" + fakeIlk + vat.IlksMappingIndex))
|
||||
ilkTakeAsInt := big.NewInt(0).SetBytes(ilkTakeBytes)
|
||||
doubleIncrementedIlkTake := big.NewInt(0).Add(ilkTakeAsInt, big.NewInt(2))
|
||||
ilkInkKey := common.BytesToHash(doubleIncrementedIlkTake.Bytes())
|
||||
expectedMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.IlkInk,
|
||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
Expect(mappings.Lookup(ilkInkKey)).To(Equal(expectedMetadata))
|
||||
})
|
||||
|
||||
It("returns value metadata for ilk Art", func() {
|
||||
storageRepository.Ilks = []string{fakeIlk}
|
||||
ilkTakeBytes := crypto.Keccak256(common.FromHex("0x" + fakeIlk + vat.IlksMappingIndex))
|
||||
ilkTakeAsInt := big.NewInt(0).SetBytes(ilkTakeBytes)
|
||||
tripleIncrementedIlkTake := big.NewInt(0).Add(ilkTakeAsInt, big.NewInt(3))
|
||||
ilkArtKey := common.BytesToHash(tripleIncrementedIlkTake.Bytes())
|
||||
expectedMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.IlkArt,
|
||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
Expect(mappings.Lookup(ilkArtKey)).To(Equal(expectedMetadata))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("urn", func() {
|
||||
It("returns value metadata for urn ink", func() {
|
||||
storageRepository.Urns = []maker.Urn{{Ilk: fakeIlk, Guy: fakeGuy}}
|
||||
encodedPrimaryMapIndex := crypto.Keccak256(common.FromHex("0x" + fakeIlk + vat.UrnsMappingIndex))
|
||||
encodedSecondaryMapIndex := crypto.Keccak256(common.FromHex(fakeGuy), encodedPrimaryMapIndex)
|
||||
urnInkKey := common.BytesToHash(encodedSecondaryMapIndex)
|
||||
expectedMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.UrnInk,
|
||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk, shared.Guy: fakeGuy},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
Expect(mappings.Lookup(urnInkKey)).To(Equal(expectedMetadata))
|
||||
})
|
||||
|
||||
It("returns value metadata for urn art", func() {
|
||||
storageRepository.Urns = []maker.Urn{{Ilk: fakeIlk, Guy: fakeGuy}}
|
||||
encodedPrimaryMapIndex := crypto.Keccak256(common.FromHex("0x" + fakeIlk + vat.UrnsMappingIndex))
|
||||
urnInkAsInt := big.NewInt(0).SetBytes(crypto.Keccak256(common.FromHex(fakeGuy), encodedPrimaryMapIndex))
|
||||
incrementedUrnInk := big.NewInt(0).Add(urnInkAsInt, big.NewInt(1))
|
||||
urnArtKey := common.BytesToHash(incrementedUrnInk.Bytes())
|
||||
expectedMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.UrnArt,
|
||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk, shared.Guy: fakeGuy},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
Expect(mappings.Lookup(urnArtKey)).To(Equal(expectedMetadata))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("gem", func() {
|
||||
It("returns value metadata for gem", func() {
|
||||
storageRepository.GemKeys = []maker.Urn{{Ilk: fakeIlk, Guy: fakeGuy}}
|
||||
encodedPrimaryMapIndex := crypto.Keccak256(common.FromHex("0x" + fakeIlk + vat.GemsMappingIndex))
|
||||
encodedSecondaryMapIndex := crypto.Keccak256(common.FromHex(fakeGuy), encodedPrimaryMapIndex)
|
||||
gemKey := common.BytesToHash(encodedSecondaryMapIndex)
|
||||
expectedMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.Gem,
|
||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk, shared.Guy: fakeGuy},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
Expect(mappings.Lookup(gemKey)).To(Equal(expectedMetadata))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("dai", func() {
|
||||
It("returns value metadata for dai", func() {
|
||||
storageRepository.DaiKeys = []string{fakeGuy}
|
||||
daiKey := common.BytesToHash(crypto.Keccak256(common.FromHex("0x" + fakeGuy + vat.DaiMappingIndex)))
|
||||
expectedMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.Dai,
|
||||
Keys: map[shared.Key]string{shared.Guy: fakeGuy},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
Expect(mappings.Lookup(daiKey)).To(Equal(expectedMetadata))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("when sin key exists in the db", func() {
|
||||
It("returns value metadata for sin", func() {
|
||||
storageRepository.SinKeys = []string{fakeGuy}
|
||||
sinKey := common.BytesToHash(crypto.Keccak256(common.FromHex("0x" + fakeGuy + vat.SinMappingIndex)))
|
||||
expectedMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.Sin,
|
||||
Keys: map[shared.Key]string{shared.Guy: fakeGuy},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
Expect(mappings.Lookup(sinKey)).To(Equal(expectedMetadata))
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
163
pkg/transformers/storage_diffs/maker/vat/repository.go
Normal file
163
pkg/transformers/storage_diffs/maker/vat/repository.go
Normal file
@ -0,0 +1,163 @@
|
||||
package vat
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared"
|
||||
)
|
||||
|
||||
type VatStorageRepository struct {
|
||||
db *postgres.DB
|
||||
}
|
||||
|
||||
func (repository *VatStorageRepository) Create(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, value interface{}) error {
|
||||
switch metadata.Name {
|
||||
case Dai:
|
||||
return repository.insertDai(blockNumber, blockHash, metadata, value.(string))
|
||||
case Gem:
|
||||
return repository.insertGem(blockNumber, blockHash, metadata, value.(string))
|
||||
case IlkArt:
|
||||
return repository.insertIlkArt(blockNumber, blockHash, metadata, value.(string))
|
||||
case IlkInk:
|
||||
return repository.insertIlkInk(blockNumber, blockHash, metadata, value.(string))
|
||||
case IlkRate:
|
||||
return repository.insertIlkRate(blockNumber, blockHash, metadata, value.(string))
|
||||
case IlkTake:
|
||||
return repository.insertIlkTake(blockNumber, blockHash, metadata, value.(string))
|
||||
case Sin:
|
||||
return repository.insertSin(blockNumber, blockHash, metadata, value.(string))
|
||||
case UrnArt:
|
||||
return repository.insertUrnArt(blockNumber, blockHash, metadata, value.(string))
|
||||
case UrnInk:
|
||||
return repository.insertUrnInk(blockNumber, blockHash, metadata, value.(string))
|
||||
case VatDebt:
|
||||
return repository.insertVatDebt(blockNumber, blockHash, value.(string))
|
||||
case VatVice:
|
||||
return repository.insertVatVice(blockNumber, blockHash, value.(string))
|
||||
default:
|
||||
panic(fmt.Sprintf("unrecognized vat contract storage name: %s", metadata.Name))
|
||||
}
|
||||
}
|
||||
|
||||
func (repository *VatStorageRepository) SetDB(db *postgres.DB) {
|
||||
repository.db = db
|
||||
}
|
||||
|
||||
func (repository *VatStorageRepository) insertDai(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, dai string) error {
|
||||
guy, err := getGuy(metadata.Keys)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, writeErr := repository.db.Exec(`INSERT INTO maker.vat_dai (block_number, block_hash, guy, dai) VALUES ($1, $2, $3, $4)`, blockNumber, blockHash, guy, dai)
|
||||
return writeErr
|
||||
}
|
||||
|
||||
func (repository *VatStorageRepository) insertGem(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, gem string) error {
|
||||
ilk, ilkErr := getIlk(metadata.Keys)
|
||||
if ilkErr != nil {
|
||||
return ilkErr
|
||||
}
|
||||
guy, guyErr := getGuy(metadata.Keys)
|
||||
if guyErr != nil {
|
||||
return guyErr
|
||||
}
|
||||
_, writeErr := repository.db.Exec(`INSERT INTO maker.vat_gem (block_number, block_hash, ilk, guy, gem) VALUES ($1, $2, $3, $4, $5)`, blockNumber, blockHash, ilk, guy, gem)
|
||||
return writeErr
|
||||
}
|
||||
|
||||
func (repository *VatStorageRepository) insertIlkArt(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, art string) error {
|
||||
ilk, err := getIlk(metadata.Keys)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, writeErr := repository.db.Exec(`INSERT INTO maker.vat_ilk_art (block_number, block_hash, ilk, art) VALUES ($1, $2, $3, $4)`, blockNumber, blockHash, ilk, art)
|
||||
return writeErr
|
||||
}
|
||||
|
||||
func (repository *VatStorageRepository) insertIlkInk(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, ink string) error {
|
||||
ilk, err := getIlk(metadata.Keys)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, writeErr := repository.db.Exec(`INSERT INTO maker.vat_ilk_ink (block_number, block_hash, ilk, ink) VALUES ($1, $2, $3, $4)`, blockNumber, blockHash, ilk, ink)
|
||||
return writeErr
|
||||
}
|
||||
|
||||
func (repository *VatStorageRepository) insertIlkRate(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, rate string) error {
|
||||
ilk, err := getIlk(metadata.Keys)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, writeErr := repository.db.Exec(`INSERT INTO maker.vat_ilk_rate (block_number, block_hash, ilk, rate) VALUES ($1, $2, $3, $4)`, blockNumber, blockHash, ilk, rate)
|
||||
return writeErr
|
||||
}
|
||||
|
||||
func (repository *VatStorageRepository) insertIlkTake(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, take string) error {
|
||||
ilk, err := getIlk(metadata.Keys)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, writeErr := repository.db.Exec(`INSERT INTO maker.vat_ilk_take (block_number, block_hash, ilk, take) VALUES ($1, $2, $3, $4)`, blockNumber, blockHash, ilk, take)
|
||||
return writeErr
|
||||
}
|
||||
|
||||
func (repository *VatStorageRepository) insertSin(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, sin string) error {
|
||||
guy, err := getGuy(metadata.Keys)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
_, writeErr := repository.db.Exec(`INSERT INTO maker.vat_sin (block_number, block_hash, guy, sin) VALUES ($1, $2, $3, $4)`, blockNumber, blockHash, guy, sin)
|
||||
return writeErr
|
||||
}
|
||||
|
||||
func (repository *VatStorageRepository) insertUrnArt(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, art string) error {
|
||||
ilk, ilkErr := getIlk(metadata.Keys)
|
||||
if ilkErr != nil {
|
||||
return ilkErr
|
||||
}
|
||||
guy, guyErr := getGuy(metadata.Keys)
|
||||
if guyErr != nil {
|
||||
return guyErr
|
||||
}
|
||||
_, writeErr := repository.db.Exec(`INSERT INTO maker.vat_urn_art (block_number, block_hash, ilk, urn, art) VALUES ($1, $2, $3, $4, $5)`, blockNumber, blockHash, ilk, guy, art)
|
||||
return writeErr
|
||||
}
|
||||
|
||||
func (repository *VatStorageRepository) insertUrnInk(blockNumber int, blockHash string, metadata shared.StorageValueMetadata, ink string) error {
|
||||
ilk, ilkErr := getIlk(metadata.Keys)
|
||||
if ilkErr != nil {
|
||||
return ilkErr
|
||||
}
|
||||
guy, guyErr := getGuy(metadata.Keys)
|
||||
if guyErr != nil {
|
||||
return guyErr
|
||||
}
|
||||
_, writeErr := repository.db.Exec(`INSERT INTO maker.vat_urn_ink (block_number, block_hash, ilk, urn, ink) VALUES ($1, $2, $3, $4, $5)`, blockNumber, blockHash, ilk, guy, ink)
|
||||
return writeErr
|
||||
}
|
||||
|
||||
func (repository *VatStorageRepository) insertVatDebt(blockNumber int, blockHash, debt string) error {
|
||||
_, err := repository.db.Exec(`INSERT INTO maker.vat_debt (block_number, block_hash, debt) VALUES ($1, $2, $3)`, blockNumber, blockHash, debt)
|
||||
return err
|
||||
}
|
||||
|
||||
func (repository *VatStorageRepository) insertVatVice(blockNumber int, blockHash, vice string) error {
|
||||
_, err := repository.db.Exec(`INSERT INTO maker.vat_vice (block_number, block_hash, vice) VALUES ($1, $2, $3)`, blockNumber, blockHash, vice)
|
||||
return err
|
||||
}
|
||||
|
||||
func getGuy(keys map[shared.Key]string) (string, error) {
|
||||
guy, ok := keys[shared.Guy]
|
||||
if !ok {
|
||||
return "", shared.ErrMetadataMalformed{MissingData: shared.Guy}
|
||||
}
|
||||
return guy, nil
|
||||
}
|
||||
|
||||
func getIlk(keys map[shared.Key]string) (string, error) {
|
||||
ilk, ok := keys[shared.Ilk]
|
||||
if !ok {
|
||||
return "", shared.ErrMetadataMalformed{MissingData: shared.Ilk}
|
||||
}
|
||||
return ilk, nil
|
||||
}
|
474
pkg/transformers/storage_diffs/maker/vat/repository_test.go
Normal file
474
pkg/transformers/storage_diffs/maker/vat/repository_test.go
Normal file
@ -0,0 +1,474 @@
|
||||
package vat_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/vat"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
)
|
||||
|
||||
var _ = Describe("Vat storage repository", func() {
|
||||
var (
|
||||
db *postgres.DB
|
||||
repo vat.VatStorageRepository
|
||||
fakeBlockNumber = 123
|
||||
fakeBlockHash = "expected_block_hash"
|
||||
fakeIlk = "fake_ilk"
|
||||
fakeGuy = "fake_urn"
|
||||
fakeUint256 = "12345"
|
||||
)
|
||||
|
||||
BeforeEach(func() {
|
||||
db = test_config.NewTestDB(test_config.NewTestNode())
|
||||
test_config.CleanTestDB(db)
|
||||
repo = vat.VatStorageRepository{}
|
||||
repo.SetDB(db)
|
||||
})
|
||||
|
||||
Describe("dai", func() {
|
||||
It("writes a row", func() {
|
||||
daiMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.Dai,
|
||||
Keys: map[shared.Key]string{shared.Guy: fakeGuy},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, daiMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type Dai struct {
|
||||
BlockMetadata
|
||||
Guy string
|
||||
Dai string
|
||||
}
|
||||
var result Dai
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, guy, dai FROM maker.vat_dai`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Guy).To(Equal(fakeGuy))
|
||||
Expect(result.Dai).To(Equal(fakeUint256))
|
||||
})
|
||||
|
||||
It("returns error if metadata missing guy", func() {
|
||||
malformedDaiMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.Dai,
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedDaiMetadata, fakeUint256)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(shared.ErrMetadataMalformed{MissingData: shared.Guy}))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("gem", func() {
|
||||
It("writes row", func() {
|
||||
gemMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.Gem,
|
||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk, shared.Guy: fakeGuy},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, gemMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type Gem struct {
|
||||
BlockMetadata
|
||||
Ilk string
|
||||
Guy string
|
||||
Gem string
|
||||
}
|
||||
var result Gem
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, guy, gem FROM maker.vat_gem`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
||||
Expect(result.Guy).To(Equal(fakeGuy))
|
||||
Expect(result.Gem).To(Equal(fakeUint256))
|
||||
})
|
||||
|
||||
It("returns error if metadata missing ilk", func() {
|
||||
malformedGemMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.Gem,
|
||||
Keys: map[shared.Key]string{shared.Guy: fakeGuy},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedGemMetadata, fakeUint256)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(shared.ErrMetadataMalformed{MissingData: shared.Ilk}))
|
||||
})
|
||||
|
||||
It("returns error if metadata missing guy", func() {
|
||||
malformedGemMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.Gem,
|
||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedGemMetadata, fakeUint256)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(shared.ErrMetadataMalformed{MissingData: shared.Guy}))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("ilk Art", func() {
|
||||
It("writes row", func() {
|
||||
ilkArtMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.IlkArt,
|
||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkArtMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type IlkArt struct {
|
||||
BlockMetadata
|
||||
Ilk string
|
||||
Art string
|
||||
}
|
||||
var result IlkArt
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, art FROM maker.vat_ilk_art`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
||||
Expect(result.Art).To(Equal(fakeUint256))
|
||||
})
|
||||
|
||||
It("returns error if metadata missing ilk", func() {
|
||||
malformedIlkArtMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.IlkArt,
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedIlkArtMetadata, fakeUint256)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(shared.ErrMetadataMalformed{MissingData: shared.Ilk}))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("ilk Ink", func() {
|
||||
It("writes row", func() {
|
||||
ilkInkMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.IlkInk,
|
||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkInkMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type IlkInk struct {
|
||||
BlockMetadata
|
||||
Ilk string
|
||||
Ink string
|
||||
}
|
||||
var result IlkInk
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, ink FROM maker.vat_ilk_ink`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
||||
Expect(result.Ink).To(Equal(fakeUint256))
|
||||
})
|
||||
|
||||
It("returns error if metadata missing ilk", func() {
|
||||
malformedIlkInkMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.IlkInk,
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedIlkInkMetadata, fakeUint256)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(shared.ErrMetadataMalformed{MissingData: shared.Ilk}))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("ilk rate", func() {
|
||||
It("writes row", func() {
|
||||
ilkRateMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.IlkRate,
|
||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkRateMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type IlkRate struct {
|
||||
BlockMetadata
|
||||
Ilk string
|
||||
Rate string
|
||||
}
|
||||
var result IlkRate
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, rate FROM maker.vat_ilk_rate`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
||||
Expect(result.Rate).To(Equal(fakeUint256))
|
||||
})
|
||||
|
||||
It("returns error if metadata missing ilk", func() {
|
||||
malformedIlkRateMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.IlkRate,
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedIlkRateMetadata, fakeUint256)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(shared.ErrMetadataMalformed{MissingData: shared.Ilk}))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("ilk take", func() {
|
||||
It("writes row", func() {
|
||||
ilkTakeMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.IlkTake,
|
||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, ilkTakeMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type IlkTake struct {
|
||||
BlockMetadata
|
||||
Ilk string
|
||||
Take string
|
||||
}
|
||||
var result IlkTake
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, take FROM maker.vat_ilk_take`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
||||
Expect(result.Take).To(Equal(fakeUint256))
|
||||
})
|
||||
|
||||
It("returns error if metadata missing ilk", func() {
|
||||
malformedIlkTakeMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.IlkTake,
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedIlkTakeMetadata, fakeUint256)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(shared.ErrMetadataMalformed{MissingData: shared.Ilk}))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("sin", func() {
|
||||
It("writes a row", func() {
|
||||
sinMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.Sin,
|
||||
Keys: map[shared.Key]string{shared.Guy: fakeGuy},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, sinMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type Sin struct {
|
||||
BlockMetadata
|
||||
Guy string
|
||||
Sin string
|
||||
}
|
||||
var result Sin
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, guy, sin FROM maker.vat_sin`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Guy).To(Equal(fakeGuy))
|
||||
Expect(result.Sin).To(Equal(fakeUint256))
|
||||
})
|
||||
|
||||
It("returns error if metadata missing guy", func() {
|
||||
malformedSinMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.Sin,
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedSinMetadata, fakeUint256)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(shared.ErrMetadataMalformed{MissingData: shared.Guy}))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("urn art", func() {
|
||||
It("writes row", func() {
|
||||
urnArtMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.UrnArt,
|
||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk, shared.Guy: fakeGuy},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, urnArtMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type UrnArt struct {
|
||||
BlockMetadata
|
||||
Ilk string
|
||||
Urn string
|
||||
Art string
|
||||
}
|
||||
var result UrnArt
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, urn, art FROM maker.vat_urn_art`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
||||
Expect(result.Urn).To(Equal(fakeGuy))
|
||||
Expect(result.Art).To(Equal(fakeUint256))
|
||||
})
|
||||
|
||||
It("returns error if metadata missing ilk", func() {
|
||||
malformedUrnArtMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.UrnArt,
|
||||
Keys: map[shared.Key]string{shared.Guy: fakeGuy},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedUrnArtMetadata, fakeUint256)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(shared.ErrMetadataMalformed{MissingData: shared.Ilk}))
|
||||
})
|
||||
|
||||
It("returns error if metadata missing guy", func() {
|
||||
malformedUrnArtMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.UrnArt,
|
||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedUrnArtMetadata, fakeUint256)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(shared.ErrMetadataMalformed{MissingData: shared.Guy}))
|
||||
})
|
||||
})
|
||||
|
||||
Describe("urn ink", func() {
|
||||
It("writes row", func() {
|
||||
urnInkMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.UrnInk,
|
||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk, shared.Guy: fakeGuy},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, urnInkMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type UrnInk struct {
|
||||
BlockMetadata
|
||||
Ilk string
|
||||
Urn string
|
||||
Ink string
|
||||
}
|
||||
var result UrnInk
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, ilk, urn, ink FROM maker.vat_urn_ink`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Ilk).To(Equal(fakeIlk))
|
||||
Expect(result.Urn).To(Equal(fakeGuy))
|
||||
Expect(result.Ink).To(Equal(fakeUint256))
|
||||
})
|
||||
|
||||
It("returns error if metadata missing ilk", func() {
|
||||
malformedUrnInkMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.UrnInk,
|
||||
Keys: map[shared.Key]string{shared.Guy: fakeGuy},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedUrnInkMetadata, fakeUint256)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(shared.ErrMetadataMalformed{MissingData: shared.Ilk}))
|
||||
})
|
||||
|
||||
It("returns error if metadata missing guy", func() {
|
||||
malformedUrnInkMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.UrnInk,
|
||||
Keys: map[shared.Key]string{shared.Ilk: fakeIlk},
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, malformedUrnInkMetadata, fakeUint256)
|
||||
|
||||
Expect(err).To(HaveOccurred())
|
||||
Expect(err).To(MatchError(shared.ErrMetadataMalformed{MissingData: shared.Guy}))
|
||||
})
|
||||
})
|
||||
|
||||
It("persists vat debt", func() {
|
||||
debtMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.VatDebt,
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, debtMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type Debt struct {
|
||||
BlockMetadata
|
||||
Debt string
|
||||
}
|
||||
var result Debt
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, debt FROM maker.vat_debt`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Debt).To(Equal(fakeUint256))
|
||||
})
|
||||
|
||||
It("persists vat vice", func() {
|
||||
viceMetadata := shared.StorageValueMetadata{
|
||||
Name: vat.VatVice,
|
||||
Keys: nil,
|
||||
Type: shared.Uint256,
|
||||
}
|
||||
|
||||
err := repo.Create(fakeBlockNumber, fakeBlockHash, viceMetadata, fakeUint256)
|
||||
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
type Vice struct {
|
||||
BlockMetadata
|
||||
Vice string
|
||||
}
|
||||
var result Vice
|
||||
err = db.Get(&result, `SELECT block_number, block_hash, vice FROM maker.vat_vice`)
|
||||
Expect(err).NotTo(HaveOccurred())
|
||||
Expect(result.BlockNumber).To(Equal(fakeBlockNumber))
|
||||
Expect(result.BlockHash).To(Equal(fakeBlockHash))
|
||||
Expect(result.Vice).To(Equal(fakeUint256))
|
||||
})
|
||||
})
|
||||
|
||||
type BlockMetadata struct {
|
||||
BlockNumber int `db:"block_number"`
|
||||
BlockHash string `db:"block_hash"`
|
||||
}
|
13
pkg/transformers/storage_diffs/maker/vat/vat_suite_test.go
Normal file
13
pkg/transformers/storage_diffs/maker/vat/vat_suite_test.go
Normal file
@ -0,0 +1,13 @@
|
||||
package vat_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
)
|
||||
|
||||
func TestVat(t *testing.T) {
|
||||
RegisterFailHandler(Fail)
|
||||
RunSpecs(t, "Vat Suite")
|
||||
}
|
@ -18,8 +18,10 @@ package storage_diffs
|
||||
|
||||
import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/crypto"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/storage_diffs/shared"
|
||||
"math/big"
|
||||
)
|
||||
|
||||
type Mappings interface {
|
||||
@ -37,3 +39,21 @@ const (
|
||||
IndexSix = "0000000000000000000000000000000000000000000000000000000000000006"
|
||||
IndexSeven = "0000000000000000000000000000000000000000000000000000000000000007"
|
||||
)
|
||||
|
||||
func GetMapping(indexOnContract, key string) common.Hash {
|
||||
keyBytes := common.FromHex("0x" + key + indexOnContract)
|
||||
encoded := crypto.Keccak256(keyBytes)
|
||||
return common.BytesToHash(encoded)
|
||||
}
|
||||
|
||||
func GetNestedMapping(indexOnContract, primaryKey, secondaryKey string) common.Hash {
|
||||
primaryMappingIndex := crypto.Keccak256(common.FromHex(primaryKey + indexOnContract))
|
||||
secondaryMappingIndex := crypto.Keccak256(common.FromHex(secondaryKey), primaryMappingIndex)
|
||||
return common.BytesToHash(secondaryMappingIndex)
|
||||
}
|
||||
|
||||
func GetIncrementedKey(original common.Hash, incrementBy int64) common.Hash {
|
||||
originalMappingAsInt := original.Big()
|
||||
incremented := big.NewInt(0).Add(originalMappingAsInt, big.NewInt(incrementBy))
|
||||
return common.BytesToHash(incremented.Bytes())
|
||||
}
|
||||
|
@ -16,7 +16,9 @@
|
||||
|
||||
package shared
|
||||
|
||||
import "fmt"
|
||||
import (
|
||||
"fmt"
|
||||
)
|
||||
|
||||
type ErrContractNotFound struct {
|
||||
Contract string
|
||||
@ -36,6 +38,14 @@ func (e ErrHeaderMismatch) Error() string {
|
||||
return fmt.Sprintf("header hash in row does not match db at height %d - row: %s, db: %s", e.BlockHeight, e.DbHash, e.DiffHash)
|
||||
}
|
||||
|
||||
type ErrMetadataMalformed struct {
|
||||
MissingData Key
|
||||
}
|
||||
|
||||
func (e ErrMetadataMalformed) Error() string {
|
||||
return fmt.Sprintf("storage metadata malformed: missing %s", e.MissingData)
|
||||
}
|
||||
|
||||
type ErrRowMalformed struct {
|
||||
Length int
|
||||
}
|
||||
|
@ -24,8 +24,23 @@ const (
|
||||
Address
|
||||
)
|
||||
|
||||
type Key string
|
||||
|
||||
const (
|
||||
Ilk Key = "ilk"
|
||||
Guy Key = "guy"
|
||||
)
|
||||
|
||||
type StorageValueMetadata struct {
|
||||
Name string
|
||||
Key string
|
||||
Keys map[Key]string
|
||||
Type ValueType
|
||||
}
|
||||
|
||||
func GetStorageValueMetadata(name string, keys map[Key]string, t ValueType) StorageValueMetadata {
|
||||
return StorageValueMetadata{
|
||||
Name: name,
|
||||
Keys: keys,
|
||||
Type: t,
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ import (
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
"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"
|
||||
)
|
||||
|
||||
func GetPitStorageTransformer() storage.Transformer {
|
||||
@ -15,3 +16,11 @@ func GetPitStorageTransformer() storage.Transformer {
|
||||
Repository: &pit.PitStorageRepository{},
|
||||
}
|
||||
}
|
||||
|
||||
func GetVatStorageTransformer() storage.Transformer {
|
||||
return storage.Transformer{
|
||||
Address: common.HexToAddress(constants.VatContractAddress()),
|
||||
Mappings: &vat.VatMappings{StorageRepository: &maker.MakerStorageRepository{}},
|
||||
Repository: &vat.VatStorageRepository{},
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,9 @@ package tend
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
)
|
||||
|
||||
@ -35,7 +35,7 @@ func (TendConverter) ToModels(ethLogs []types.Log) (results []interface{}, err e
|
||||
}
|
||||
|
||||
bidId := ethLog.Topics[2].Big()
|
||||
guy := common.HexToAddress(ethLog.Topics[1].Hex()).String()
|
||||
guy := shared.GetHexWithoutPrefix(ethLog.Topics[1].Bytes())
|
||||
lot := ethLog.Topics[3].Big().String()
|
||||
|
||||
lastDataItemStartIndex := len(ethLog.Data) - 32
|
||||
|
@ -42,7 +42,7 @@ var (
|
||||
biteIlk = [32]byte{69, 84, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
biteLad = [32]byte{0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 216, 180, 20, 126, 218, 128, 254, 199, 18, 42, 225, 109, 162, 71, 156, 189, 127, 251}
|
||||
biteIlkString = "4554480000000000000000000000000000000000000000000000000000000000"
|
||||
biteLadString = "0x0000d8b4147eDa80Fec7122AE16DA2479Cbd7ffB"
|
||||
biteLadString = "0000000000000000000000000000d8b4147eda80fec7122ae16da2479cbd7ffb"
|
||||
)
|
||||
|
||||
var EthBiteLog = types.Log{
|
||||
|
@ -48,7 +48,7 @@ var EthDripFileIlkLog = types.Log{
|
||||
var rawDripFileIlkLog, _ = json.Marshal(EthDripFileIlkLog)
|
||||
var DripFileIlkModel = ilk2.DripFileIlkModel{
|
||||
Ilk: "66616b6520696c6b000000000000000000000000000000000000000000000000",
|
||||
Vow: "fake vow",
|
||||
Vow: "66616b6520766f77000000000000000000000000000000000000000000000000",
|
||||
Tax: "12300.000000000000000000000000000",
|
||||
LogIndex: EthDripFileIlkLog.Index,
|
||||
TransactionIndex: EthDripFileIlkLog.TxIndex,
|
||||
|
@ -38,7 +38,7 @@ var (
|
||||
bid = new(big.Int).SetBytes([]byte{0})
|
||||
gal = "0x07Fa9eF6609cA7921112231F8f195138ebbA2977"
|
||||
end = int64(1535991025)
|
||||
urn = [32]byte{115, 64, 224, 6, 244, 19, 91, 166, 151, 13, 67, 191, 67, 216, 141, 202, 212, 231, 168, 202, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
urnBytes = [32]byte{115, 64, 224, 6, 244, 19, 91, 166, 151, 13, 67, 191, 67, 216, 141, 202, 212, 231, 168, 202, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
urnString = "0x7340e006f4135BA6970D43bf43d88DCAD4e7a8CA"
|
||||
tabString = "50"
|
||||
tab, _ = new(big.Int).SetString(tabString, 10)
|
||||
@ -73,7 +73,7 @@ var FlipKickEntity = flip_kick.FlipKickEntity{
|
||||
Bid: bid,
|
||||
Gal: common.HexToAddress(gal),
|
||||
End: big.NewInt(end),
|
||||
Urn: urn,
|
||||
Urn: urnBytes,
|
||||
Tab: tab,
|
||||
TransactionIndex: EthFlipKickLog.TxIndex,
|
||||
LogIndex: EthFlipKickLog.Index,
|
||||
|
@ -42,7 +42,7 @@ var (
|
||||
ink = big.NewInt(15)
|
||||
ilk = [32]byte{102, 97, 107, 101, 32, 105, 108, 107, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
|
||||
frobIlkString = "66616b6520696c6b000000000000000000000000000000000000000000000000"
|
||||
frobUrnString = "0x64d922894153BE9EEf7b7218dc565d1D0Ce2a092"
|
||||
frobUrnString = "00000000000000000000000064d922894153be9eef7b7218dc565d1d0ce2a092"
|
||||
)
|
||||
|
||||
var EthFrobLog = types.Log{
|
||||
|
@ -32,7 +32,7 @@ var (
|
||||
tendBidId = int64(10)
|
||||
tendLot = "85000000000000000000"
|
||||
tendBid = "1000000000000000000"
|
||||
tendGuy = "0x7d7bEe5fCfD8028cf7b00876C5b1421c800561A6"
|
||||
tendGuy = "0000000000000000000000007d7bee5fcfd8028cf7b00876c5b1421c800561a6"
|
||||
tendData = "0x0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000644b43ed12000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000049b9ca9a6943400000000000000000000000000000000000000000000000000000de0b6b3a7640000"
|
||||
tendTransactionHash = "0x7909c8793ded2b8348f5db623044fbc26bb7ab78ad5792897abdf68ddc1df63d"
|
||||
tendBlockHash = "0xa8ea87147c0a68daeb6b1d9f8c0937ba975a650809cab80d19c969e8d0df452c"
|
||||
|
@ -45,8 +45,8 @@ var VatFluxLog = types.Log{
|
||||
var rawFluxLog, _ = json.Marshal(VatFluxLog)
|
||||
var VatFluxModel = vat_flux.VatFluxModel{
|
||||
Ilk: "5245500000000000000000000000000000000000000000000000000000000000",
|
||||
Src: "0x7FA9EF6609Ca7921112231f8f195138ebba29770",
|
||||
Dst: "0x93086347c52a8878af71bB818509d484c6a2e1bF",
|
||||
Src: "0000000000000000000000007fa9ef6609ca7921112231f8f195138ebba29770",
|
||||
Dst: "00000000000000000000000093086347c52a8878af71bb818509d484c6a2e1bf",
|
||||
Rad: "123",
|
||||
TransactionIndex: VatFluxLog.TxIndex,
|
||||
LogIndex: VatFluxLog.Index,
|
||||
|
@ -47,7 +47,7 @@ var EthVatFoldLog = types.Log{
|
||||
var rawVatFoldLog, _ = json.Marshal(EthVatFoldLog)
|
||||
var VatFoldModel = vat_fold.VatFoldModel{
|
||||
Ilk: "5245500000000000000000000000000000000000000000000000000000000000",
|
||||
Urn: "0x3728e9777B2a0a611ee0F89e00E01044ce4736d1",
|
||||
Urn: "0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1",
|
||||
Rate: "0.000000000000000000000000002",
|
||||
LogIndex: EthVatFoldLog.Index,
|
||||
TransactionIndex: EthVatFoldLog.TxIndex,
|
||||
|
@ -29,9 +29,9 @@ var EthVatGrabLog = types.Log{
|
||||
var rawVatGrabLog, _ = json.Marshal(EthVatGrabLog)
|
||||
var VatGrabModel = vat_grab.VatGrabModel{
|
||||
Ilk: "5245500000000000000000000000000000000000000000000000000000000000",
|
||||
Urn: "0x6a3AE20C315E845B2E398e68EfFe39139eC6060C",
|
||||
V: "0x2F34f22a00eE4b7a8F8BBC4eAee1658774c624e0",
|
||||
W: "0x3728e9777B2a0a611ee0F89e00E01044ce4736d1",
|
||||
Urn: "0000000000000000000000006a3ae20c315e845b2e398e68effe39139ec6060c",
|
||||
V: "0000000000000000000000002f34f22a00ee4b7a8f8bbc4eaee1658774c624e0",
|
||||
W: "0000000000000000000000003728e9777b2a0a611ee0f89e00e01044ce4736d1",
|
||||
Dink: "115792089237316195423570985008687907853269984665640564039455584007913129639936",
|
||||
Dart: "115792089237316195423570985008687907853269984665640564039441803007913129639936",
|
||||
LogIndex: EthVatGrabLog.Index,
|
||||
|
@ -44,8 +44,8 @@ var VatHealLog = types.Log{
|
||||
|
||||
var rawHealLog, _ = json.Marshal(VatHealLog)
|
||||
var VatHealModel = vat_heal.VatHealModel{
|
||||
Urn: "0x7d7bEe5fCfD8028cf7b00876C5b1421c800561A6",
|
||||
V: "0x7340e006f4135BA6970D43bf43d88DCAD4e7a8CA",
|
||||
Urn: "0000000000000000000000007d7bee5fcfd8028cf7b00876c5b1421c800561a6",
|
||||
V: "0000000000000000000000007340e006f4135ba6970d43bf43d88dcad4e7a8ca",
|
||||
Rad: "120",
|
||||
LogIndex: VatHealLog.Index,
|
||||
TransactionIndex: VatHealLog.TxIndex,
|
||||
|
@ -46,8 +46,8 @@ var EthVatMoveLog = types.Log{
|
||||
|
||||
var rawVatMoveLog, _ = json.Marshal(EthVatMoveLog)
|
||||
var VatMoveModel = vat_move.VatMoveModel{
|
||||
Src: "0xA730d1FF8B6Bc74a26d54c20a9dda539909BaB0e",
|
||||
Dst: "0xB730D1fF8b6BC74a26D54c20a9ddA539909BAb0e",
|
||||
Src: "000000000000000000000000a730d1ff8b6bc74a26d54c20a9dda539909bab0e",
|
||||
Dst: "000000000000000000000000b730d1ff8b6bc74a26d54c20a9dda539909bab0e",
|
||||
Rad: "42",
|
||||
LogIndex: EthVatMoveLog.Index,
|
||||
TransactionIndex: EthVatMoveLog.TxIndex,
|
||||
|
@ -47,7 +47,7 @@ var EthVatSlipLog = types.Log{
|
||||
var rawVatSlipLog, _ = json.Marshal(EthVatSlipLog)
|
||||
var VatSlipModel = vat_slip.VatSlipModel{
|
||||
Ilk: "66616b6520696c6b000000000000000000000000000000000000000000000000",
|
||||
Guy: common.HexToAddress("0x7d7bEe5fCfD8028cf7b00876C5b1421c800561A6").String(),
|
||||
Guy: "0000000000000000000000007d7bee5fcfd8028cf7b00876c5b1421c800561a6",
|
||||
Rad: "987654321",
|
||||
TransactionIndex: EthVatSlipLog.TxIndex,
|
||||
LogIndex: EthVatSlipLog.Index,
|
||||
|
@ -15,7 +15,7 @@ var EthVatTollLog = types.Log{
|
||||
Topics: []common.Hash{
|
||||
common.HexToHash("0x09b7a0b500000000000000000000000000000000000000000000000000000000"),
|
||||
common.HexToHash("0x66616b6520696c6b000000000000000000000000000000000000000000000000"),
|
||||
common.HexToHash("0xa3e37186e017747dba34042e83e3f76ad3cce9b0000000000000000000000000"),
|
||||
common.HexToHash("0x0000000000000000000000000a3e37186e017747dba34042e83e3f76ad3cce9b"),
|
||||
common.HexToHash("0x00000000000000000000000000000000000000000000000000000000075bcd15"),
|
||||
},
|
||||
Data: hexutil.MustDecode("0x0000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000006409b7a0b566616b6520696c6b000000000000000000000000000000000000000000000000a3e37186e017747dba34042e83e3f76ad3cce9b000000000000000000000000000000000000000000000000000000000000000000000000000000000075bcd15"),
|
||||
@ -30,7 +30,7 @@ var EthVatTollLog = types.Log{
|
||||
var rawVatTollLog, _ = json.Marshal(EthVatTollLog)
|
||||
var VatTollModel = vat_toll.VatTollModel{
|
||||
Ilk: "66616b6520696c6b000000000000000000000000000000000000000000000000",
|
||||
Urn: "0xA3E37186E017747DbA34042e83e3F76Ad3CcE9b0",
|
||||
Urn: "0000000000000000000000000a3e37186e017747dba34042e83e3f76ad3cce9b",
|
||||
Take: big.NewInt(123456789).String(),
|
||||
TransactionIndex: EthVatTollLog.TxIndex,
|
||||
LogIndex: EthVatTollLog.Index,
|
||||
|
@ -32,12 +32,12 @@ var EthVatTuneLog = types.Log{
|
||||
var rawVatTuneLog, _ = json.Marshal(EthVatTuneLog)
|
||||
var dartString = "115792089237316195423570985008687907853269984665640564039455584007913129639936"
|
||||
var vatTuneDart, _ = new(big.Int).SetString(dartString, 10)
|
||||
var urnAddress = "0x4F26FfBe5F04ED43630fdC30A87638d53D0b0876"
|
||||
var urn = "0000000000000000000000004f26ffbe5f04ed43630fdc30a87638d53d0b0876"
|
||||
var VatTuneModel = vat_tune.VatTuneModel{
|
||||
Ilk: "4554480000000000000000000000000000000000000000000000000000000000",
|
||||
Urn: urnAddress,
|
||||
V: urnAddress,
|
||||
W: urnAddress,
|
||||
Urn: urn,
|
||||
V: urn,
|
||||
W: urn,
|
||||
Dink: big.NewInt(0).String(),
|
||||
Dart: vatTuneDart.String(),
|
||||
TransactionIndex: EthVatTuneLog.TxIndex,
|
||||
|
@ -19,7 +19,6 @@ package vat_flux
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
"math/big"
|
||||
@ -36,8 +35,8 @@ func (VatFluxConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
|
||||
}
|
||||
|
||||
ilk := shared.GetHexWithoutPrefix(ethLog.Topics[1].Bytes())
|
||||
src := common.BytesToAddress(ethLog.Topics[2].Bytes())
|
||||
dst := common.BytesToAddress(ethLog.Topics[3].Bytes())
|
||||
src := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes())
|
||||
dst := shared.GetHexWithoutPrefix(ethLog.Topics[3].Bytes())
|
||||
radBytes := shared.GetDataBytesAtIndex(-1, ethLog.Data)
|
||||
rad := big.NewInt(0).SetBytes(radBytes).String()
|
||||
|
||||
@ -52,8 +51,8 @@ func (VatFluxConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
|
||||
|
||||
model := VatFluxModel{
|
||||
Ilk: ilk,
|
||||
Src: src.String(),
|
||||
Dst: dst.String(),
|
||||
Src: src,
|
||||
Dst: dst,
|
||||
Rad: rad,
|
||||
TransactionIndex: ethLog.TxIndex,
|
||||
LogIndex: ethLog.Index,
|
||||
|
@ -19,7 +19,6 @@ package vat_fold
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
)
|
||||
@ -35,7 +34,7 @@ func (VatFoldConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
|
||||
}
|
||||
|
||||
ilk := shared.GetHexWithoutPrefix(ethLog.Topics[1].Bytes())
|
||||
urn := common.BytesToAddress(ethLog.Topics[2].Bytes()).String()
|
||||
urn := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes())
|
||||
rate := shared.ConvertToRay(ethLog.Topics[3].Big().String())
|
||||
raw, err := json.Marshal(ethLog)
|
||||
|
||||
|
@ -3,7 +3,6 @@ package vat_grab
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared/constants"
|
||||
@ -20,10 +19,10 @@ func (VatGrabConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
|
||||
return nil, err
|
||||
}
|
||||
ilk := shared.GetHexWithoutPrefix(ethLog.Topics[1].Bytes())
|
||||
urn := common.BytesToAddress(ethLog.Topics[2].Bytes())
|
||||
v := common.BytesToAddress(ethLog.Topics[3].Bytes())
|
||||
urn := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes())
|
||||
v := shared.GetHexWithoutPrefix(ethLog.Topics[3].Bytes())
|
||||
wBytes := shared.GetDataBytesAtIndex(-3, ethLog.Data)
|
||||
w := common.BytesToAddress(wBytes)
|
||||
w := shared.GetHexWithoutPrefix(wBytes)
|
||||
dinkBytes := shared.GetDataBytesAtIndex(-2, ethLog.Data)
|
||||
dink := big.NewInt(0).SetBytes(dinkBytes).String()
|
||||
dartBytes := shared.GetDataBytesAtIndex(-1, ethLog.Data)
|
||||
@ -35,9 +34,9 @@ func (VatGrabConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
|
||||
}
|
||||
model := VatGrabModel{
|
||||
Ilk: ilk,
|
||||
Urn: urn.String(),
|
||||
V: v.String(),
|
||||
W: w.String(),
|
||||
Urn: urn,
|
||||
V: v,
|
||||
W: w,
|
||||
Dink: dink,
|
||||
Dart: dart,
|
||||
LogIndex: ethLog.Index,
|
||||
|
@ -19,8 +19,8 @@ package vat_heal
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
)
|
||||
|
||||
@ -34,8 +34,8 @@ func (VatHealConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
urn := common.BytesToAddress(ethLog.Topics[1].Bytes())
|
||||
v := common.BytesToAddress(ethLog.Topics[2].Bytes())
|
||||
urn := shared.GetHexWithoutPrefix(ethLog.Topics[1].Bytes())
|
||||
v := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes())
|
||||
radInt := ethLog.Topics[3].Big()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@ -47,8 +47,8 @@ func (VatHealConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
|
||||
}
|
||||
|
||||
model := VatHealModel{
|
||||
Urn: urn.String(),
|
||||
V: v.String(),
|
||||
Urn: urn,
|
||||
V: v,
|
||||
Rad: radInt.String(),
|
||||
LogIndex: ethLog.Index,
|
||||
TransactionIndex: ethLog.TxIndex,
|
||||
|
@ -19,8 +19,8 @@ package vat_move
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
shared2 "github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
)
|
||||
|
||||
type VatMoveConverter struct{}
|
||||
@ -33,8 +33,8 @@ func (VatMoveConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
|
||||
return []interface{}{}, err
|
||||
}
|
||||
|
||||
src := common.BytesToAddress(ethLog.Topics[1].Bytes())
|
||||
dst := common.BytesToAddress(ethLog.Topics[2].Bytes())
|
||||
src := shared2.GetHexWithoutPrefix(ethLog.Topics[1].Bytes())
|
||||
dst := shared2.GetHexWithoutPrefix(ethLog.Topics[2].Bytes())
|
||||
rad := ethLog.Topics[3].Big()
|
||||
raw, err := json.Marshal(ethLog)
|
||||
if err != nil {
|
||||
@ -42,8 +42,8 @@ func (VatMoveConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
|
||||
}
|
||||
|
||||
models = append(models, VatMoveModel{
|
||||
Src: src.String(),
|
||||
Dst: dst.String(),
|
||||
Src: src,
|
||||
Dst: dst,
|
||||
Rad: rad.String(),
|
||||
LogIndex: ethLog.Index,
|
||||
TransactionIndex: ethLog.TxIndex,
|
||||
|
@ -19,7 +19,6 @@ package vat_slip
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
)
|
||||
@ -34,7 +33,7 @@ func (VatSlipConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
|
||||
return nil, err
|
||||
}
|
||||
ilk := shared.GetHexWithoutPrefix(ethLog.Topics[1].Bytes())
|
||||
guy := common.BytesToAddress(ethLog.Topics[2].Bytes())
|
||||
guy := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes())
|
||||
rad := ethLog.Topics[3].Big()
|
||||
|
||||
raw, err := json.Marshal(ethLog)
|
||||
@ -43,7 +42,7 @@ func (VatSlipConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
|
||||
}
|
||||
model := VatSlipModel{
|
||||
Ilk: ilk,
|
||||
Guy: guy.String(),
|
||||
Guy: guy,
|
||||
Rad: rad.String(),
|
||||
TransactionIndex: ethLog.TxIndex,
|
||||
LogIndex: ethLog.Index,
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"errors"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
)
|
||||
|
||||
@ -19,7 +18,7 @@ func (VatTollConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
|
||||
return nil, err
|
||||
}
|
||||
ilk := shared.GetHexWithoutPrefix(ethLog.Topics[1].Bytes())
|
||||
urn := common.BytesToAddress(ethLog.Topics[2].Bytes()[:common.AddressLength])
|
||||
urn := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes())
|
||||
take := ethLog.Topics[3].Big()
|
||||
|
||||
raw, err := json.Marshal(ethLog)
|
||||
@ -28,7 +27,7 @@ func (VatTollConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
|
||||
}
|
||||
model := VatTollModel{
|
||||
Ilk: ilk,
|
||||
Urn: urn.String(),
|
||||
Urn: urn,
|
||||
Take: take.String(),
|
||||
TransactionIndex: ethLog.TxIndex,
|
||||
LogIndex: ethLog.Index,
|
||||
|
@ -5,7 +5,6 @@ import (
|
||||
"errors"
|
||||
"math/big"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/transformers/shared"
|
||||
@ -22,10 +21,10 @@ func (VatTuneConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
|
||||
return nil, err
|
||||
}
|
||||
ilk := shared.GetHexWithoutPrefix(ethLog.Topics[1].Bytes())
|
||||
urn := common.BytesToAddress(ethLog.Topics[2].Bytes())
|
||||
v := common.BytesToAddress(ethLog.Topics[3].Bytes())
|
||||
urn := shared.GetHexWithoutPrefix(ethLog.Topics[2].Bytes())
|
||||
v := shared.GetHexWithoutPrefix(ethLog.Topics[3].Bytes())
|
||||
wBytes := shared.GetDataBytesAtIndex(-3, ethLog.Data)
|
||||
w := common.BytesToAddress(wBytes)
|
||||
w := shared.GetHexWithoutPrefix(wBytes)
|
||||
dinkBytes := shared.GetDataBytesAtIndex(-2, ethLog.Data)
|
||||
dink := big.NewInt(0).SetBytes(dinkBytes)
|
||||
dartBytes := shared.GetDataBytesAtIndex(-1, ethLog.Data)
|
||||
@ -37,9 +36,9 @@ func (VatTuneConverter) ToModels(ethLogs []types.Log) ([]interface{}, error) {
|
||||
}
|
||||
model := VatTuneModel{
|
||||
Ilk: ilk,
|
||||
Urn: urn.String(),
|
||||
V: v.String(),
|
||||
W: w.String(),
|
||||
Urn: urn,
|
||||
V: v,
|
||||
W: w,
|
||||
Dink: dink.String(),
|
||||
Dart: dart.String(),
|
||||
TransactionIndex: ethLog.TxIndex,
|
||||
|
Loading…
Reference in New Issue
Block a user