Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/main'
Browse files Browse the repository at this point in the history
  • Loading branch information
gabedonnan committed Nov 30, 2023
2 parents fda6152 + 437f4be commit 1e85424
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ The following builder classes are currently implemented:
- Rsync Builder
- Builder0x69
- Flashbots Builder
- Loki Builder
- Beaver Builder (Very poorly documented parameters online, may need adjustment)


Expand Down
3 changes: 2 additions & 1 deletion demo/block_submissions.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
BuilderRPC,
TitanBuilder,
RsyncBuilder,
LokiBuilder,
HexStr,
NonceManager,
Transaction,
Expand Down Expand Up @@ -49,7 +50,7 @@ async def building():
signed_tx = Account.sign_transaction(tx, acct.key).rawTransaction

async with BuilderRPC(
[TitanBuilder(), RsyncBuilder()], private_key=acct.key
[TitanBuilder(), RsyncBuilder(), LokiBuilder()], private_key=acct.key
) as brpc:
msg = await brpc.send_private_transaction(HexStr(signed_tx))
print(msg)
Expand Down
1 change: 1 addition & 0 deletions pythereum/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
TitanBuilder,
RsyncBuilder,
FlashbotsBuilder,
LokiBuilder,
ALL_BUILDERS,
)

Expand Down
31 changes: 31 additions & 0 deletions pythereum/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,36 @@ def get_header(self, payload: str = "") -> dict:
}


class LokiBuilder(Builder):
def __init__(self, private_key: str | HexStr | None = None):
super().__init__(
"https://rpc.lokibuilder.xyz/",
"eth_sendPrivateRawTransaction",
"eth_sendBundle",
"eth_cancelBundle",
"mev_sendBundle",
{
"txs",
"blockNumber",
"minTimestamp",
"maxTimestamp",
"revertingTxHashes",
"replacementUuid",
"refundPercent",
"refundRecipient",
"refundTxHashes",
},
private_key,
)

def format_private_transaction(
self,
tx: str | HexStr | list[str] | list[HexStr],
max_block_number: str | HexStr | list[str] | list[HexStr] | None = None,
) -> list[Any]:
return [tx]


class BuilderRPC:
"""
An RPC class designed for sending raw transactions and bundles to specific block builders
Expand Down Expand Up @@ -379,4 +409,5 @@ async def __aexit__(self, *args):
RsyncBuilder(),
BeaverBuilder(),
FlashbotsBuilder(),
LokiBuilder(),
]
6 changes: 6 additions & 0 deletions tests/test_builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ async def test_flashbots_builder():
)


@pytest.mark.asyncio
async def test_loki_builder():
async with pye.BuilderRPC(pye.LokiBuilder()) as brpc:
assert await brpc.send_private_transaction(None) is None


@pytest.mark.asyncio
async def test_all_builders():
async with pye.BuilderRPC(
Expand Down

0 comments on commit 1e85424

Please sign in to comment.