Skip to content

Commit

Permalink
fix(docs): some example docs fixes (#654)
Browse files Browse the repository at this point in the history
Co-authored-by: gautamgambhir97 <[email protected]>
Co-authored-by: gautamgambhir97 <[email protected]>
Co-authored-by: felix.bucsa <[email protected]>
  • Loading branch information
4 people authored Jul 8, 2024
1 parent 6a456e1 commit a1d48d6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 36 deletions.
10 changes: 5 additions & 5 deletions pages/examples/intermediate/agent-and-service-api.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -150,11 +150,11 @@ time.sleep(10) # Waiting before storing details to create function

```python
# Taking inputs from user for details required to create a function
name_service = input('Please give function name')
description = input('Please enter function description')
field_name = input('Please enter field name')
field_description = input('Please enter field description')
tasktype = input('Please tell primary or secondary function')
name_service = input('Please give function name: ')
description = input('Please enter function description: ')
field_name = input('Please enter field name: ')
field_description = input('Please enter field description: ')
tasktype = input('Please tell primary or secondary function: ')

# Logging details provided by user
print(f'Service name: {name_service} \nFunction Description: {description} \nField Name: {field_name}\nField Description: {field_description}\nTask Type: {tasktype}')
Expand Down
10 changes: 5 additions & 5 deletions pages/examples/intermediate/send-tokens-agents.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -37,26 +37,26 @@ This example shows how to use Agents to make them send tokens with one another.
bob = Agent(name="bob", seed="bob secret phrase")

fund_agent_if_low(alice.wallet.address())
fund_agent_if_low(bob.wallet.address())
fund_agent_if_low(bob.wallet.address(), min_balance=AMOUNT)

@alice.on_interval(period=10.0)
async def request_funds(ctx: Context):
await ctx.send(
bob.address,
PaymentRequest(
wallet_address=str(ctx.wallet.address()), amount=AMOUNT, denom=DENOM
wallet_address=str(alice.wallet.address()), amount=AMOUNT, denom=DENOM
),
)

@alice.on_message(model=TransactionInfo)
async def confirm_transaction(ctx: Context, sender: str, msg: TransactionInfo):
ctx.logger.info(f"Received transaction info from {sender}: {msg}")

tx_resp = await wait_for_tx_to_complete(msg.tx_hash)
tx_resp = await wait_for_tx_to_complete(msg.tx_hash, ctx.ledger)
coin_received = tx_resp.events["coin_received"]

if (
coin_received["receiver"] == str(ctx.wallet.address())
coin_received["receiver"] == str(alice.wallet.address())
and coin_received["amount"] == f"{AMOUNT}{DENOM}"
):
ctx.logger.info(f"Transaction was successful: {coin_received}")
Expand All @@ -65,7 +65,7 @@ This example shows how to use Agents to make them send tokens with one another.
async def send_payment(ctx: Context, sender: str, msg: PaymentRequest):
ctx.logger.info(f"Received payment request from {sender}: {msg}")
transaction = ctx.ledger.send_tokens(
msg.wallet_address, msg.amount, msg.denom, ctx.wallet
msg.wallet_address, msg.amount, msg.denom, bob.wallet
)

await ctx.send(alice.address, TransactionInfo(tx_hash=transaction.tx_hash))
Expand Down
43 changes: 17 additions & 26 deletions pnpm-lock.yaml

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

0 comments on commit a1d48d6

Please sign in to comment.