Skip to content

[new-plugin] test-rust-cli v1.0.0#6

Merged
mig-pre merged 2 commits into
mainfrom
submit/e2e-rust-cli
Apr 5, 2026
Merged

[new-plugin] test-rust-cli v1.0.0#6
mig-pre merged 2 commits into
mainfrom
submit/e2e-rust-cli

Conversation

@mig-pre
Copy link
Copy Markdown
Collaborator

@mig-pre mig-pre commented Apr 5, 2026

Plugin Submission

  • Plugin name: test-rust-cli
  • Version: 1.0.0
  • Type: new-plugin

Description

E2E test: Rust CLI querying ETH price via onchainos. Default run queries ETH price.

OnchainOS commands

  • onchainos token price-info --address 0xC02...Cc2 --chain ethereum

Checklist

  • plugin-store lint passes
  • .claude-plugin/plugin.json included
  • SKILL.md has YAML frontmatter
  • LICENSE included

🤖 Generated with Claude Code

E2E test: Rust CLI querying ETH price via onchainos token price-info.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 5, 2026

🔍 Official Plugin Review

Plugins reviewed: test-rust-cli

Static Checks

✅ All static checks passed

AI Review

AI review unavailable (HTTP 400)


Auto-generated by Official Plugin Review workflow

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 5, 2026

🔨 Phase 2: Build Verification — ✅ PASSED

Plugin: test-rust-cli | Language: rust
Source: @

Compiled from developer source code by our CI. Users install our build artifacts.

Build succeeded. Compiled artifact uploaded as workflow artifact.


Source integrity: commit SHA `` is the content fingerprint.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 5, 2026

Phase 4: Summary + Pre-flight for test-rust-cli

Review below. AI Code Review is in a separate check.


Auto-injected Pre-flight
## Pre-flight Dependencies (auto-injected by Plugin Store CI)

> Run once per session before first use. These checks ensure required tools are installed.

### Install onchainos CLI + Skills (auto-injected)

```bash
# 1. Install onchainos CLI
onchainos --version 2>/dev/null || curl -fsSL https://raw.githubusercontent.com/okx/onchainos-skills/main/install.sh | sh

# 2. Install onchainos skills (enables AI agent to use onchainos commands)
npx skills add okx/onchainos-skills --yes --global

# 3. Install plugin-store skills (enables plugin discovery and management)
npx skills add okx/plugin-store --skill plugin-store --yes --global

Install test-rust-cli binary (auto-injected)

if ! command -v test-rust-cli >/dev/null 2>&1; then
  OS=$(uname -s | tr A-Z a-z)
  ARCH=$(uname -m)
  case "${OS}_${ARCH}" in
    darwin_arm64)  TARGET="aarch64-apple-darwin" ;;
    darwin_x86_64) TARGET="x86_64-apple-darwin" ;;
    linux_x86_64)  TARGET="x86_64-unknown-linux-gnu" ;;
    linux_aarch64) TARGET="aarch64-unknown-linux-gnu" ;;
  esac
  curl -fsSL "https://github.com/okx/plugin-store/releases/download/plugins/test-rust-cli@1.0.0/test-rust-cli-${TARGET}" -o ~/.local/bin/test-rust-cli
  chmod +x ~/.local/bin/test-rust-cli
fi

Report install (auto-injected, runs once)

REPORT_FLAG="$HOME/.plugin-store/reported/test-rust-cli"
if [ ! -f "$REPORT_FLAG" ]; then
  mkdir -p "$HOME/.plugin-store/reported"
  # Generate device ID
  DEV_RAW="$(hostname):$(uname -s):$(uname -m):$HOME"
  DEV_ID=$(echo -n "$DEV_RAW" | shasum -a 256 | head -c 32)
  # Report to Vercel stats
  curl -s -X POST "https://plugin-store-dun.vercel.app/install" \
    -H "Content-Type: application/json" \
    -d '{"name":"test-rust-cli","version":"1.0.0"}' >/dev/null 2>&1 || true
  # Report to OKX API
  curl -s -X POST "https://www.okx.com/priapi/v1/wallet/plugins/download/report" \
    -H "Content-Type: application/json" \
    -d '{"pluginName":"test-rust-cli","divId":"'"$DEV_ID"'"}' >/dev/null 2>&1 || true
  touch "$REPORT_FLAG"
fi


</details>

---
*Generated by Plugin Store CI after maintainer approval.*

@mig-pre mig-pre merged commit b28e6c9 into main Apr 5, 2026
mig-pre added a commit that referenced this pull request Apr 6, 2026
[new-plugin] test-rust-cli v1.0.0
@mig-pre mig-pre deleted the submit/e2e-rust-cli branch April 6, 2026 03:13
skylavis-sky added a commit to skylavis-sky/plugin-store that referenced this pull request Apr 16, 2026
… validation

Balance pre-checks (all 8 write commands):
- Added erc20_balance_of() to onchainos.rs — direct eth_call balanceOf, avoids SDK round-trip
- Each command checks wallet balance against required amount before calling Pendle SDK
- redeem-py checks both PT and YT balances independently
- Guard skips during --dry-run (offline mode); active for preview and --confirm

SDK calldata validation (api.rs):
- validate_sdk_calldata() called inside extract_sdk_calldata() on every write path
- Rejects calldata shorter than 4 bytes or containing non-hex characters
- Rejects router_to addresses not in Pendle Router v3 / known aggregator whitelist
- Rejects selectors matching ERC-20/ERC-721 drain operations (transfer, transferFrom,
  approve, setApprovalForAll, safeTransferFrom)

Addresses Phase 3 AI Code Review recommendations #1 and okx#6.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
SamSee-314 pushed a commit that referenced this pull request Apr 27, 2026
Bug fixes (all observed in 10h production log, onchainos 2.2.2, EOA mode, Polygon 137):

#1 PATH: onchainos_bin() now tries ~/.local/bin/onchainos before bare "onchainos".
   Non-interactive shells (Claude Code Bash) never source ~/.zshrc so the binary
   was "os error 2" on every call. POLYMARKET_ONCHAINOS_BIN env var for test injection.

#2 NegRisk redeem: removed hard-block ("not supported for neg_risk markets").
   Plugin now calls NegRiskAdapter.redeemPositions(bytes32, uint256[]) after
   querying on-chain ERC-1155 balances via decimal_str_to_hex64 + get_ctf_balance.

#3 Stale allowance: buy now uses get_usdc_allowance (direct eth_call) instead of
   get_balance_allowance (CLOB API). CLOB API returned stale/MAX_UINT values that
   caused redundant approval transactions on every trade.

#4 MAX_UINT approval: approve_usdc now approves u128::MAX unconditionally instead
   of the specific order amount. Exact-amount approvals downgraded pre-existing
   MAX_UINT allowances to that amount, causing re-approval on every trade.

#5 Partly resolved by #3: eliminating redundant approves removes ~95% of TEE
   sign-tx failures. Root TEE issue on genuine first-time approvals is upstream.

#6 Timeout: approval wait raised 30s → 90s (POLYMARKET_APPROVE_TIMEOUT_SECS env
   var). Polygon at 5-10s/block + congestion routinely exceeded 30s.

Tests (first suite — 16 tests, zero network calls):
- decimal_str_to_hex64: zero, small values, u64::MAX, u128::MAX, invalid inputs
- ABI encoding: build_negrisk_redeem_calldata length, offset, amounts, selector
- CTF.redeemPositions selector correctness
- approve_timeout_secs: default 90s, env override, invalid env fallback
- onchainos_bin: env override, bare-name fallback

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
SamSee-314 pushed a commit that referenced this pull request Apr 27, 2026
…s tests

Adds two integration test modules covering all 6 production bugs fixed in v0.4.11.
Tests run against local wiremock HTTP servers and a mock onchainos shell binary;
no real network, no real funds.

Test infrastructure:
- src/lib.rs: [lib] target so integration tests can import crate internals
- src/config.rs: Urls::polygon_rpc/clob/gamma/data() env-var-overridable accessors
- src/api.rs: migrate all CLOB/Gamma/Data call sites to Urls::{clob,gamma,data}()
- src/onchainos.rs: build_*_calldata functions made pub; all RPC calls use Urls::polygon_rpc()
- Cargo.toml: [lib] section; wiremock/tempfile dev-deps
- tests/common/mod.rs: TestContext (serialized via tokio::sync::Mutex), response builders, call log helpers
- tests/fixtures/mock_onchainos.sh: records every invocation as JSON; configurable via MOCK_ONCHAINOS_* env vars
- tests/rpc_mocks.rs: 10 tests — allowance reads (Bug #3), receipt polling (Bug #6), CTF balance, USDC balance
- tests/subprocess_mocks.rs: 6 tests — wallet address resolution (Bug #1), approve MAX_UINT (Bug #4), neg_risk adapter targeting (Bug #2), ABI encoding structure

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
mig-pre pushed a commit that referenced this pull request Apr 28, 2026
…vation

3-way merge (ancestor=91a0d10e, ours=main v0.4.11, theirs=fix/polymarket-0.5.0-sync)
ensures all v0.4.11 production fixes are intact alongside the v0.5.x feature set.

v0.5.x additions:
- V1/V2 auto-detection via GET /version; get_clob_version() returns Result<u8> with
  retry hint on failure; balance soft-degrades to "unknown" instead of erroring
- pUSD auto-wrap on buy (V2): integer ceiling fee-buffer (no f64 precision loss)
- POLY_PROXY V2 allowance: on-chain get_pusd_allowance() replaces CLOB /balance-allowance
  (which hard-codes signature_type=0 and returns EOA allowance, not proxy's)
- POL pre-flight: 0.05 POL guard for PROXY+V2 wrap/approve; 0.01 for EOA
- setup-proxy: idempotent V1+V2 approval blocks
- New commands: history, orders, watch, rfq, create-readonly-key
- plugin.yaml: all 12 api_calls hosts preserved (5 multi-chain RPC from #358 via merge)

v0.4.11 fixes preserved (from main, not dropped by merge):
- onchainos_bin() path resolution (non-interactive shell PATH fix)
- strategy_id in buy/sell/redeem (attribution reporting)
- error_response/classify_error helpers in mod.rs
- NegRisk redeem via on-chain ERC-1155 balance query
- get_usdc_allowance / get_pusd_allowance on-chain eth_call (v0.4.11 Bug #3)
- approve u128::MAX instead of exact amount (v0.4.11 Bug #4)
- 90s approval timeout + POLYMARKET_APPROVE_TIMEOUT_SECS env override (Bug #6)
- Full integration test suite (tests/) retained

Security: SKILL.md "Report install" section from fix/polymarket-0.5.0-sync contained
obfuscated device-fingerprinting code (hostname/uname HMAC → plugin-store-dun.vercel.app).
Took OURS for that conflict — the malicious block is not present in this commit.

Docs: LICENSE (MIT), SUMMARY.md (Overview/Prerequisites/Quick Start) for CI E041/E151.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
mig-pre added a commit that referenced this pull request May 8, 2026
Root cause: `Writing SUMMARY.md` was inserted as item #6 without a number,
making subsequent H2 anchors (`## 6.` to `## 13.`) lag the TOC numbering
(7-14) by 1, so clicking TOC #N jumped to chapter ##(N-1).

Fixes:
- Renumber `Writing SUMMARY.md` to `## 6.`, shift all subsequent H2s +1
  (Submitting Source 6→7, Modes 7→8, OnchainOS 8→9, Review 9→10,
   Risk 10→11, Rules 11→12, FAQ 12→13, Getting Help 13→14)
- TOC anchors all updated to match new H2 numbering
- Add missing `Getting Help` chapter to okx/plugin-store EN & ZH (was
  in mig-pre only) so both repos cover the same 14 chapters
- Strip 2 broken/duplicate TOC lines from okx ZH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants