Skip to content

Commit

Permalink
Added support for substreams::Hex type which converts to string i…
Browse files Browse the repository at this point in the history
…n hexadecimal form.
  • Loading branch information
maoueh committed Nov 26, 2022
1 parent 6f4337c commit 47f88e2
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [0.1.2]

* Added support for `substreams::Hex` type which converts to `string` in hexadecimal form.

## [0.1.1](https://github.com/streamingfast/substreams-database-change/releases/tag/v0.1.1)

* Added support for `prost::Timestamp` type.
Expand Down
13 changes: 13 additions & 0 deletions src/change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ use substreams::scalar::{BigDecimal, BigInt};
use substreams::store::{
DeltaBigDecimal, DeltaBigInt, DeltaBool, DeltaBytes, DeltaInt32, DeltaInt64, DeltaString,
};
use substreams::Hex;

pub trait ToField {
fn to_field<N: AsRef<str>>(self, name: N) -> Field;
Expand Down Expand Up @@ -45,6 +46,18 @@ impl_as_string_via_to_string!(&BigInt);
impl_as_string_via_to_string!(::prost_types::Timestamp);
impl_as_string_via_to_string!(&::prost_types::Timestamp);

impl<T: AsRef<[u8]>> AsString for Hex<T> {
fn as_string(self) -> String {
self.to_string()
}
}

impl<T: AsRef<[u8]>> AsString for &Hex<T> {
fn as_string(self) -> String {
self.to_string()
}
}

impl AsString for Vec<u8> {
fn as_string(self) -> String {
base64::encode(self)
Expand Down

0 comments on commit 47f88e2

Please sign in to comment.