Skip to content

Commit d616481

Browse files
authored
Merge pull request #89 from propeller-heads/lp/uniswap-v2-be-encoding
feat: Convert uniswap v2 attributes to big endian encoding
2 parents 78f6cb2 + 5c38cd6 commit d616481

File tree

7 files changed

+44
-31
lines changed

7 files changed

+44
-31
lines changed

.github/workflows/substream.cd.yaml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ on:
99
package:
1010
required: true
1111
description: "Package to build"
12+
config_file:
13+
required: false
14+
description: "Path to the substreams configuration file"
15+
default: "substreams.yaml"
1216

1317
jobs:
1418
Release:
@@ -42,4 +46,4 @@ jobs:
4246
- name: Run checks
4347
run: |
4448
cd substreams
45-
./release.sh ${{ inputs.package }}
49+
./release.sh ${{ inputs.package }} ${{ inputs.config_file }}

substreams/Cargo.lock

Lines changed: 19 additions & 19 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

substreams/ethereum-uniswap-v2/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
2-
name = "substreams-ethereum-uniswap-v2"
3-
version = "0.2.1"
2+
name = "ethereum-uniswap-v2"
3+
version = "0.3.0"
44
edition = "2021"
55

66
[lib]

substreams/ethereum-uniswap-v2/ethereum-uniswap-v2.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
specVersion: v0.1.0
22
package:
33
name: "ethereum_uniswap_v2"
4-
version: v0.2.1
4+
version: v0.3.0
55

66
protobuf:
77
files:
@@ -15,7 +15,7 @@ protobuf:
1515
binaries:
1616
default:
1717
type: wasm/rust-v1
18-
file: ../../target/wasm32-unknown-unknown/substreams/ethereum_uniswap_v2.wasm
18+
file: ../target/wasm32-unknown-unknown/release/ethereum_uniswap_v2.wasm
1919

2020
modules:
2121
- name: map_pools_created

substreams/ethereum-uniswap-v2/src/modules/1_map_pool_created.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,12 @@ fn get_pools(block: &eth::Block, new_pools: &mut Vec<TransactionChanges>, params
4646
attributes: vec![
4747
Attribute {
4848
name: "reserve0".to_string(),
49-
value: BigInt::from(0).to_signed_bytes_le(),
49+
value: BigInt::from(0).to_signed_bytes_be(),
5050
change: ChangeType::Creation.into(),
5151
},
5252
Attribute {
5353
name: "reserve1".to_string(),
54-
value: BigInt::from(0).to_signed_bytes_le(),
54+
value: BigInt::from(0).to_signed_bytes_be(),
5555
change: ChangeType::Creation.into(),
5656
},
5757
],
@@ -64,7 +64,7 @@ fn get_pools(block: &eth::Block, new_pools: &mut Vec<TransactionChanges>, params
6464
// Trading Fee is hardcoded to 0.3%, saved as int in bps (basis points)
6565
Attribute {
6666
name: "fee".to_string(),
67-
value: BigInt::from(30).to_signed_bytes_le(),
67+
value: BigInt::from(30).to_signed_bytes_be(),
6868
change: ChangeType::Creation.into(),
6969
},
7070
Attribute {

substreams/ethereum-uniswap-v2/src/modules/3_map_pool_events.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ fn handle_sync(
104104
name: attribute_name,
105105
value: reserve_bytes
106106
.clone()
107-
.to_signed_bytes_le(), //TODO: Unify bytes encoding (either be or le)
107+
.to_signed_bytes_be(),
108108
change: ChangeType::Update.into(),
109109
},
110110
);

substreams/release.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if [ -n "$current_tag" ]; then
1616
# Semantic version
1717
version="${BASH_REMATCH[2]}"
1818

19-
cargo_version=$(cargo pkgid -p ethereum-balancer | cut -d# -f2 | cut -d: -f2)
19+
cargo_version=$(cargo pkgid -p "$package" | cut -d# -f2 | cut -d: -f2)
2020
if [[ "$cargo_version" != "$version" ]]; then
2121
echo "Error: Cargo version: ${cargo_version} does not match tag version: ${version}!"
2222
exit 1
@@ -52,9 +52,18 @@ fi
5252
REPOSITORY=${REPOSITORY:-"s3://repo.propellerheads/substreams"}
5353
repository_path="$REPOSITORY/$package/$package-$version.spkg"
5454

55+
# Optional input for yaml file; defaults to substreams.yaml if not provided
56+
yaml_file=${2:-"substreams.yaml"}
57+
58+
if [[ ! -f "$package/$yaml_file" ]]; then
59+
echo "Error: manifest reader: unable to stat input file $yaml_file: file does not exist."
60+
exit 1
61+
fi
62+
63+
set -e # Exit the script if any command fails
5564
cargo build --target wasm32-unknown-unknown --release -p "$package"
5665
mkdir -p ./target/spkg/
57-
substreams pack $package/substreams.yaml -o ./target/spkg/$package-$version.spkg
66+
substreams pack "$package/$yaml_file" -o ./target/spkg/$package-$version.spkg
5867
aws s3 cp ./target/spkg/$package-$version.spkg $repository_path
5968

60-
echo "Released substreams package: '$repository_path'"
69+
echo "Released substreams package: '$repository_path'"

0 commit comments

Comments
 (0)