Skip to content

Commit

Permalink
renamed to hyperfuel
Browse files Browse the repository at this point in the history
  • Loading branch information
JossDuff committed May 9, 2024
1 parent c013b15 commit 146ae6b
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 48 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
[package]
name = "hypersync-fuel"
name = "hyperfuel"
version = "0.1.2"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[lib]
name = "hypersync_fuel"
name = "hyperfuel"
crate-type = ["cdylib"]

[dependencies]
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# hypersync-fuel-client-python
Python package for [Envio's](https://envio.dev/) Hypersync-Fuel client written in Rust.
# hyperfuel-client-python
Python package for [Envio's](https://envio.dev/) hyperfuel client written in Rust.

More information about Envio's Hypersync support of Fuel at [https://github.com/enviodev/hypersync-fuel-docs](https://github.com/enviodev/hypersync-fuel-docs)
More information about Envio's Hyperfuel support of Fuel at [https://github.com/enviodev/hyperfuel-docs](https://github.com/enviodev/hyperfuel-docs)

## quickstart example
```bash
$ pip install hypersync-fuel
$ pip install hyperfuel
```

```python
# This example will simply fetch the logs from the given contracts over a block range
# returns all log data necessary for fuel's decoder
import hypersync_fuel
import hyperfuel
import asyncio

async def main():
client = hypersync_fuel.HypersyncClient()
client = hyperfuel.HyperfuelClient()

contracts = ["0xff63ad3cdb5fde197dfa2d248330d458bffe631bda65938aa7ab7e37efa561d0"]
from_block = 8076516
Expand Down
14 changes: 7 additions & 7 deletions examples/asset-id.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,23 @@
# `Inputs` where the address `0x0000000000000000000000000000000000000000000000000000000000000000`
# matches on the `asset_id` field.

import hypersync_fuel
from hypersync_fuel import InputField
import hyperfuel
from hyperfuel import InputField
import asyncio

async def main():
client = hypersync_fuel.HypersyncClient()
query = hypersync_fuel.HypersyncClient()
client = hyperfuel.HyperfuelClient()
query = hyperfuel.HyperfuelClient()

query = hypersync_fuel.Query(
query = hyperfuel.Query(
from_block=7980000,
to_block=7980100,
inputs=[
hypersync_fuel.InputSelection(
hyperfuel.InputSelection(
asset_id=["0x0000000000000000000000000000000000000000000000000000000000000000"]
)
],
field_selection=hypersync_fuel.FieldSelection(
field_selection=hyperfuel.FieldSelection(
input=[
InputField.TX_ID,
InputField.BLOCK_HEIGHT,
Expand Down
12 changes: 6 additions & 6 deletions examples/predicate-root.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
# where the `owner` field matches the predicate root 0x48a0f31c78e1c837ff6a885785ceb7c2090f86ed93db3ed2d8821d13739fe981
# `owner` is ["The owning address or predicate root."](https://docs.fuel.network/docs/beta-4/graphql/reference/objects/#inputcoin) of an InputCoin Input type

import hypersync_fuel
from hypersync_fuel import InputField
import hyperfuel
from hyperfuel import InputField
import asyncio

async def main():
client = hypersync_fuel.HypersyncClient()
client = hyperfuel.HyperfuelClient()

query = hypersync_fuel.Query(
query = hyperfuel.Query(
from_block=4105960,
to_block=4106000,
inputs=[
hypersync_fuel.InputSelection(
hyperfuel.InputSelection(
owner=["0x48a0f31c78e1c837ff6a885785ceb7c2090f86ed93db3ed2d8821d13739fe981"]
)
],
field_selection=hypersync_fuel.FieldSelection(
field_selection=hyperfuel.FieldSelection(
input=[
InputField.TX_ID,
InputField.BLOCK_HEIGHT,
Expand Down
4 changes: 2 additions & 2 deletions examples/simple-logs.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# This example will simply fetch the logs from a vector of contracts over a specified block range
import hypersync_fuel
import hyperfuel
import asyncio

async def main():
client = hypersync_fuel.HypersyncClient()
client = hyperfuel.HyperfuelClient()

contracts = ["0xff63ad3cdb5fde197dfa2d248330d458bffe631bda65938aa7ab7e37efa561d0"]
from_block = 8076516
Expand Down
6 changes: 3 additions & 3 deletions hypersync_fuel/__init__.py → hyperfuel/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from .hypersync_fuel import HypersyncClient as _HypersyncClient
from .hyperfuel import HyperfuelClient as _HyperfuelClient
from typing import Optional
from dataclasses import dataclass, asdict
from strenum import StrEnum
Expand Down Expand Up @@ -175,10 +175,10 @@ class Query:
max_num_blocks: Optional[int] = None
max_num_transactions: Optional[int] = None

class HypersyncClient:
class HyperfuelClient:
# Create a new client with given config
def __init__(self, url="https://fuel-15.hypersync.xyz", bearer_token=None, http_req_timeout_millis=None):
self.inner = _HypersyncClient({
self.inner = _HyperfuelClient({
"url": url,
"bearer_token": bearer_token,
"http_req_timeout_millis": http_req_timeout_millis
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["maturin>=1.3,<2.0"]
build-backend = "maturin"

[project]
name = "hypersync-fuel"
name = "hyperfuel"
requires-python = ">=3.9"
dependencies = ["strenum>=0.4.15,<0.4.16"]
classifiers = [
Expand Down
16 changes: 8 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,31 +21,31 @@ use pyo3::{
pub use config::Config;

#[pymodule]
fn hypersync_fuel(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<HypersyncClient>()
fn hyperfuel(_py: Python, m: &PyModule) -> PyResult<()> {
m.add_class::<HyperfuelClient>()
}
#[pyclass]
pub struct HypersyncClient {
pub struct HyperfuelClient {
inner: Arc<skar_client_fuel::Client>,
}

impl HypersyncClient {
fn new_impl(config: Config) -> Result<HypersyncClient> {
impl HyperfuelClient {
fn new_impl(config: Config) -> Result<HyperfuelClient> {
env_logger::try_init().ok();

let config = config.try_convert().context("parse config")?;

Ok(HypersyncClient {
Ok(HyperfuelClient {
inner: Arc::new(skar_client_fuel::Client::new(config).context("create client")?),
})
}
}

#[pymethods]
impl HypersyncClient {
impl HyperfuelClient {
/// Create a new client with given config
#[new]
fn new(config: Config) -> PyResult<HypersyncClient> {
fn new(config: Config) -> PyResult<HyperfuelClient> {
Self::new_impl(config).map_err(|e| PyIOError::new_err(format!("{:?}", e)))
}

Expand Down
24 changes: 12 additions & 12 deletions test.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import hypersync_fuel
import hyperfuel
import asyncio
from hypersync_fuel import BlockField, TransactionField, ReceiptField, InputField, OutputField
from hyperfuel import BlockField, TransactionField, ReceiptField, InputField, OutputField


QUERY = hypersync_fuel.Query(
QUERY = hyperfuel.Query(
from_block=8076516,
to_block=8076517,
receipts=[
hypersync_fuel.ReceiptSelection(
hyperfuel.ReceiptSelection(
root_contract_id=["0xff63ad3cdb5fde197dfa2d248330d458bffe631bda65938aa7ab7e37efa561d0"],
receipt_type=[5, 6]
)
],
field_selection=hypersync_fuel.FieldSelection(
field_selection=hyperfuel.FieldSelection(
block=[
BlockField.HEIGHT,
BlockField.TRANSACTIONS_ROOT
Expand Down Expand Up @@ -44,17 +44,17 @@
)

async def test_create_parquet_folder():
client = hypersync_fuel.HypersyncClient()
client = hyperfuel.HyperfuelClient()
await client.create_parquet_folder(QUERY, "data")

async def test_get_height():
client = hypersync_fuel.HypersyncClient()
client = hyperfuel.HyperfuelClient()
height = await client.get_height()
print("current height: " + str(height))

async def test_get_arrow_data():
import pyarrow
client = hypersync_fuel.HypersyncClient()
client = hyperfuel.HyperfuelClient()
res = await client.get_arrow_data(QUERY)
assert(type(res.data.blocks) == pyarrow.lib.Table)
assert(res.data.blocks._is_initialized())
Expand All @@ -68,20 +68,20 @@ async def test_get_arrow_data():
assert(res.data.outputs._is_initialized())

async def test_get_data():
client = hypersync_fuel.HypersyncClient()
client = hyperfuel.HyperfuelClient()
res = await client.get_data(QUERY)

async def test_get_selected_data():
client = hypersync_fuel.HypersyncClient()
client = hyperfuel.HyperfuelClient()
res = await client.get_selected_data(QUERY)

async def test_preset_query_get_logs():
client = hypersync_fuel.HypersyncClient()
client = hyperfuel.HyperfuelClient()
contracts = ["0xff63ad3cdb5fde197dfa2d248330d458bffe631bda65938aa7ab7e37efa561d0"]
res = await client.preset_query_get_logs(emitting_contracts=contracts,from_block=8076516,to_block=8076517,)

async def main():
print("smoke test hypersync-fuel-client-python")
print("smoke test hyperfuel-client-python")
await test_create_parquet_folder()
await test_get_height()
await test_get_arrow_data()
Expand Down

0 comments on commit 146ae6b

Please sign in to comment.