docs: run the agent-wallet lifecycle from Python#123
Conversation
|
Caution Review failedPull request was closed or merged during review 📝 WalkthroughWalkthroughAdds ChangesMAA Numeric Argument Encoding and Balance Read
Sequence Diagram(s)sequenceDiagram
rect rgba(173, 216, 230, 0.5)
note over Caller,Go Binding: Numeric arg round-trip
Caller->>TNClient.execute_agent_action: args with MAANumericArg(value, precision, scale)
TNClient.execute_agent_action->>_maa_exec_args: args list
_maa_exec_args->>_maa_json_default: json.dumps default hook
_maa_json_default-->>_maa_exec_args: {"__tn_type__":"numeric","value":v,"precision":p,"scale":s}
_maa_exec_args-->>Go Binding: JSON string via CGo
end
rect rgba(144, 238, 144, 0.5)
note over Go Binding,KwilTypes: Go-side reconstruction
Go Binding->>decodeMAAArgs: JSON array string
decodeMAAArgs->>decodeMAAArgs: recursive array walk + maaTypeKey detection
decodeMAAArgs->>ParseDecimalExplicit: value, precision, scale (uint16)
ParseDecimalExplicit-->>decodeMAAArgs: *types.Decimal
decodeMAAArgs-->>Go Binding: []any with *types.Decimal args
end
rect rgba(255, 223, 186, 0.5)
note over TNClient,Go Binding: Balance read
TNClient->>maa_get_balance: maa_address, bridge
maa_get_balance->>MAAGetBalance: []byte, string
MAAGetBalance-->>maa_get_balance: JSON {column_names, values}
maa_get_balance-->>TNClient: balance string or "0"
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~50 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Time Submission Status
Submit or update total time with: Add time on top of previous submission with: See available commands to help comply with our Guidelines. |
|
@holdex pr submit-time 4h |
resolves: https://github.com/truflation/website/issues/4165
The Modular Agent Address (MAA / "agent wallet") feature is code-complete across the SDKs, but nothing exercised the whole lifecycle from Python against a live node. This adds a runnable example that does, plus the small amount of SDK support it needs to drive every step.
Example —
examples/maa_lifecycle_example/main.pywalks the full lifecycle against a node wheremaa_execis active (testnet from height 6523123), mirroring the node oracletests/streams/maa/data_agent_test.go:create_streams+insert_recordsas the MAA — proving@calleris rewritten (the stream is owned by the MAA, not the agent key) and that fees debit the MAA's own escrow;It also cross-checks the chain-returned
rule_idand MAA address against offline derivation. Configuration is via environment variables;README.mddocuments them and what success looks like.SDK support the example needs
Driving the lifecycle surfaced that
execute_agent_actioncould not passNUMERICarguments — JSON has no decimal type and the node does not coerce text toNUMERIC(it compares precision/scale exactly) — and nested integer arrays were mis-encoded. This PR adds:MAANumericArg(value, precision, scale)(exported) — wraps aNUMERICargument so the binding rebuilds a precision/scale-exact decimal across the JSON boundary (e.g.maa_withdraw's$amount NUMERIC(78,0),insert_records'$value NUMERIC(36,18)[]);bindings/maa.goso nested integers (e.g.insert_records'INT8[]event times) reach the node as integers, not floats;TNClient.maa_get_balance(maa, bridge)— reads an agent wallet's escrow balance (the address is passed asBYTEA, which the genericcall_procedurehelper cannot do).Tests
bindings/maa_decode_test.go— Go unit tests for the decode round-trip (nested ints, scalar + array numeric markers, error cases).tests/test_maa_exec.py— extended with marker serialization, nested arrays, and validation (13 tests total).Both are pure-unit (no node required). The gopy bindings were rebuilt.
Status
The example is dry-validated offline (argument shapes match the on-chain action signatures). Running it against testnet needs funded agent + owner keys, the gateway provider URL, and the testnet bridge namespace — all documented in the README.
Summary by CodeRabbit
New Features
MAANumericArgtype.Documentation
Tests