All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Bumped dependencies to
substreams
to 0.6 andprost
to 0.13 (see Upgrade notes)
Maintenance release introducing experimental hidden methods to deal with arrays.
Better support for using composite primary keys:
- New enum in this crate:
tables::PrimaryKey
Single(String)
:let single: PrimaryKey = "hello world".into()
Composite(BTreeMap<String, String>)
:let composite: PrimaryKey = [("evt_tx_hash","hello".to_string()),("evt_index","world".to_string())].into()
Breaking changes:
- The
Rows.pks
field is not public anymore. create_row()
,update_row()
anddelete_row()
now require aPrimaryKey
instead of aString
. This should work directly with aString
,&String
or&str
.
- Changed imports in
substreams.yaml
definition so that packaged.spkg
can you the expect pathsf/substreams/sink/database/v1
to exclude and generating from the.spkg
will generate data on the right path.
If you were using --exclude-paths
on substreams protogen
and your path was database.proto
, you should change to sf/substreams/sink/database/v1
. We think this affects no one has everyone is probably using the pre-rendered Protobuf found in Rust crate substreams-database-change
.
-
Breaking Renamed
substreams_database_change::pb::database::table_change::Operation::Unset
to be become...::Operation::Unspecified
to make the Protobuf conforms to buf lint rules.We take the liberty to change it because we expect that almost everyone is using the abstraction provided by this library.
- Removed some useless dependencies.
- Added some missing conversion for
ToDatabaseValue
trait.
- Fixed encoding of
Vec<u8>
to be inhex
format as expected by Postgres (and hopefully other database). This is technically a breaking change but it was probably never actually working, so we are changing. If you were relying onbase64
decoding, please let use know and we will find a solution.
-
Added
tables
module so that you can use it as a better abstraction to build up your entity changes.use substreams_database_change::tables::Tables; let mut tables = Tables::new(); // Create a row (<entity_name>, <id>).[set(<column>, <value>), ...] tables .create_row("Factory", id) .set("poolCount", &bigint0) .set("txCount", &bigint0) .set("totalVolumeUSD", &bigdecimal0) .set("totalVolumeETH", &bigdecimal0) .set("totalFeesUSD", &bigdecimal0) .set("totalFeesETH", &bigdecimal0) .set("untrackedVolumeUSD", &bigdecimal0) .set("totalValueLockedUSD", &bigdecimal0) .set("totalValueLockedETH", &bigdecimal0) .set("totalValueLockedUSDUntracked", &bigdecimal0) .set("totalValueLockedETHUntracked", &bigdecimal0) .set("owner", &format!("0x{}", Hex(utils::ZERO_ADDRESS).to_string())); // Update a row (<entity_name>, <id>).[set(<column>, <value>), ...] tables .update_row("Bundle", "1").set("ethPriceUSD", &delta.new_value);
-
Add composite primary keys for Protobuf with
oneof
and addpush_change_composite()
tohelpers.rs
. -
Note Changed database protobuf location path from
tosubstreams/sink/database/v1
sf/substreams/sink/database/v1
, this is not a change of the Protobuf package id which is stillsf.substreams.sink.database.v1
. This will have an impact if you usebuf gen --exclude-path
as the path here is the Protobuf original path location, so addsf/
if you were excludingsubstreams/sink/database
. -
GitHub repository has been renamed to
substreams-sink-database-changes
, note the Rust crate's name is stillsubstreams-database-change
to avoid breaking change when importing the crate. We are planning a future rename of the crate, but that might come with a v2 of the data protocol.
- Separate generic types for table name and private key
- BREAKING Changed database proto package path from
substreams.sink.database.v1tosf.substreams.sink.database.v1
- BREAKING Updated
substreams
dependencies to0.5.0
.
- Added support for
substreams::Hex
type which converts tostring
in hexadecimal form.
-
Added support for
prost::Timestamp
type. -
Made
AsString
public so you can implement on your own custom types.
-
Added support for
u8
,u16
,u32
,u64
,i8
,i16
,i32
,i64
types. -
Added possibility to record a
change
using(new: AsString, old: AsString)
to simulate a value update. -
Added possibility to record a
change
using(old: AsString, new: Option<Into<Typed>>)
to simulate a value deletion. -
Added possibility to record a
change
using(old: Option<AsString>, new: AsString)
to simulate a value creation. -
Refactored to allow delta to be taken from any
AsString
which makes it much easier to extend when there is missing types. -
Introduced our own
AsString
type becauseInto<String>
usage andToString
usage lead to Rust compiler errors on our desired change typings. -
Refactored to reduce amount of
clone
perform. -
Added
database.proto
containing proto message definitions