Skip to content

Commit fde7c35

Browse files
committed
fix: add dummy signature for unauthenticated price estimates
When estimating prices without authentication, there's no valid signature available. This fix uses a dummy signature so that message validation passes in these cases.
1 parent 1562f26 commit fde7c35

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

src/aleph/sdk/client/http.py

+17-16
Original file line numberDiff line numberDiff line change
@@ -468,24 +468,25 @@ async def get_estimated_price(
468468
separators=(",", ":"),
469469
default=extended_json_encoder,
470470
)
471-
message = parse_message(
472-
dict(
473-
sender=content.address,
474-
chain=Chain.ETH,
475-
type=(
476-
MessageType.program
477-
if isinstance(content, ProgramContent)
478-
else MessageType.instance
479-
),
480-
content=cleaned_content,
481-
item_content=item_content,
482-
time=time.time(),
483-
channel=settings.DEFAULT_CHANNEL,
484-
item_type=ItemType.inline,
485-
item_hash=compute_sha256(item_content),
486-
)
471+
message_dict = dict(
472+
sender=content.address,
473+
chain=Chain.ETH,
474+
type=(
475+
MessageType.program
476+
if isinstance(content, ProgramContent)
477+
else MessageType.instance
478+
),
479+
content=cleaned_content,
480+
item_content=item_content,
481+
time=time.time(),
482+
channel=settings.DEFAULT_CHANNEL,
483+
item_type=ItemType.inline,
484+
item_hash=compute_sha256(item_content),
485+
signature="0x" + "0" * 130, # Add a dummy signature to pass validation
487486
)
488487

488+
message = parse_message(message_dict)
489+
489490
async with self.http_session.post(
490491
"/api/v0/price/estimate", json=dict(message=message)
491492
) as resp:

0 commit comments

Comments
 (0)