diff --git a/cmd/build.mk b/cmd/build.mk index ce247077..8bcc2573 100644 --- a/cmd/build.mk +++ b/cmd/build.mk @@ -1,5 +1,5 @@ -ORG_ROOT := fluidity +ORG_ROOT := superposition INSTALL_DIR := $(or ${INSTALL_DIR},/usr/local/bin) diff --git a/cmd/graphql.ethereum/Makefile b/cmd/graphql.ethereum/Makefile index 8643d209..ee790b18 100644 --- a/cmd/graphql.ethereum/Makefile +++ b/cmd/graphql.ethereum/Makefile @@ -1,5 +1,5 @@ -EXTRA_FILES := pools.toml +EXTRA_FILES := pools.toml bootstrap bootstrap.zip include ../golang.mk diff --git a/db/migrations/1723693657-events_leo.sql b/db/migrations/1723693657-events_leo.sql index 616d0ef2..53fd7b3d 100644 --- a/db/migrations/1723693657-events_leo.sql +++ b/db/migrations/1723693657-events_leo.sql @@ -27,7 +27,8 @@ CREATE TABLE events_leo_campaigncreated ( tick_upper INTEGER NOT NULL, owner ADDRESS NOT NULL, starting TIMESTAMP WITHOUT TIME ZONE, - ending TIMESTAMP WITHOUT TIME ZONE + ending TIMESTAMP WITHOUT TIME ZONE, + per_second BIGINT NOT NULL ); CREATE UNIQUE INDEX ON events_leo_campaigncreated (identifier, pool); diff --git a/lib/events/fluidity/abi.json b/lib/events/fluidity/abi.json new file mode 100644 index 00000000..e69de29b diff --git a/lib/events/fluidity/fluidity.go b/lib/events/fluidity/fluidity.go new file mode 100644 index 00000000..e69de29b diff --git a/lib/events/fluidity/types.go b/lib/events/fluidity/types.go new file mode 100644 index 00000000..e69de29b diff --git a/lib/events/leo/leo.go b/lib/events/leo/leo.go index b1fc250c..35aab3a8 100644 --- a/lib/events/leo/leo.go +++ b/lib/events/leo/leo.go @@ -54,7 +54,7 @@ func UnpackCampaignCreated(topic1, topic2, topic3 ethCommon.Hash, d []byte) (*Ca return nil, fmt.Errorf("bad times: %T", i[1]) } tickLower, tickUpper, owner := unpackDetails(details) - starting, ending := unpackTimes(times) + starting, ending, perSecond := unpackTimes(times) return &CampaignCreated{ Identifier: hashToBytes8Data(topic1), Pool: hashToAddr(topic2), @@ -64,6 +64,7 @@ func UnpackCampaignCreated(topic1, topic2, topic3 ethCommon.Hash, d []byte) (*Ca Owner: owner, Starting: time.Unix(int64(starting), 0), Ending: time.Unix(int64(ending), 0), + PerSecond: perSecond, }, nil } @@ -123,9 +124,10 @@ func unpackDetails(i *big.Int) (tickLower int32, tickUpper int32, owner types.Ad return } -func unpackTimes(i *big.Int) (starting uint64, ending uint64) { - starting = new(big.Int).Rsh(i, 64).Uint64() - ending = i.Uint64() +func unpackTimes(i *big.Int) (starting uint64, ending uint64, perSecond uint64) { + starting = new(big.Int).Rsh(i, 64 * 2).Uint64() + ending = new(big.Int).Rsh(i, 64).Uint64() + perSecond = i.Uint64() return } diff --git a/lib/events/leo/leo_test.go b/lib/events/leo/leo_test.go index 27e183c2..47a38444 100644 --- a/lib/events/leo/leo_test.go +++ b/lib/events/leo/leo_test.go @@ -34,9 +34,11 @@ func TestUnpackDetails(t *testing.T) { } func TestUnpackTimes(t *testing.T) { - starting, ending := unpackTimes(new(big.Int).SetBits([]big.Word{545464, 5000, 0, 0})) + //1701411834604692327378907846580747919949856 + starting, ending, perSecond := unpackTimes(new(big.Int).SetBits([]big.Word{32, 545464, 5000, 0})) assert.Equalf(t, uint64(5000), starting, "starting not equal") assert.Equalf(t, uint64(545464), ending, "ending not equal") + assert.Equalf(t, uint64(32), perSecond, "per second not equal") } func TestUnpackExtras(t *testing.T) { diff --git a/lib/events/leo/types.go b/lib/events/leo/types.go index 17c5143c..2519b6e3 100644 --- a/lib/events/leo/types.go +++ b/lib/events/leo/types.go @@ -28,6 +28,7 @@ type ( Owner types.Address `json:"owner"` Starting time.Time `json:"starting"` Ending time.Time `json:"ending"` + PerSecond uint64 `json:"perSecond"` } CampaignUpdated struct { diff --git a/pkg/leo/src/events.rs b/pkg/leo/src/events.rs index fc2b729e..4b07bd20 100644 --- a/pkg/leo/src/events.rs +++ b/pkg/leo/src/events.rs @@ -18,6 +18,7 @@ pub fn emit_campaign_created( tick_upper: i32, starting: u64, ending: u64, + per_second: u64 ) { #[cfg(feature = "log-events")] evm::log(CampaignCreated { @@ -25,7 +26,7 @@ pub fn emit_campaign_created( pool, token, details: pack_details(tick_lower, tick_upper, owner), - times: pack_times(starting, ending), + times: pack_times(starting, ending, per_second), }); } @@ -39,8 +40,10 @@ fn pack_details(tick_lower: i32, tick_upper: i32, owner: Address) -> U256 { } #[allow(dead_code)] -fn pack_times(starting: u64, ending: u64) -> U256 { - (U256::from(starting) << 64) | U256::from(ending) +fn pack_times(starting: u64, ending: u64, per_second: u64) -> U256 { + let mut packed = U256::from(starting) << 64 * 2; + packed |= U256::from(ending) << 64; + packed | U256::from(per_second) } #[allow(dead_code)] @@ -83,7 +86,7 @@ fn test_pack_details() { #[test] fn test_pack_times() { - dbg!(pack_times(5000, 545464)); + dbg!(pack_times(5000, 545464, 32)); } #[test]