OpenPay (1 crate, 2174 LOC, 14 tests)
op-payouts Multi-rail payout engine. Visa Direct, Mastercard Send,
ACH credits (NACHA), Fedwire + SWIFT MT103 + ISO 20022
pacs.008, SEPA SCT + SCT Inst (mod-97 IBAN), UK FPS,
FedNow, RTP, PayPal, Wise. Crypto: USDC/USDT on
ETH/Polygon/Base/Solana + BTC + Lightning with real
ERC-20 transfer(address,uint256) calldata. Offline-pure
drivers (emit wire payloads — operators transmit).
Smart Byte (1 crate, 2605 LOC, 38 tests)
smart-byte-nostr Nostr adapter. NIP-01 canonical event id + BIP-340
Schnorr sign/verify; from-scratch bech32 + NIP-19 TLV
(npub/nsec/note/nprofile/nevent/nrelay); NIP-04 legacy
AES-256-CBC DMs; NIP-44 v2 HKDF-SHA256→ChaCha20+HMAC
with bucketed padding; NIP-17 gift-wrap (kind 1059) +
seal (kind 13) + rumor (kind 14); NIP-05/11/13/26/65.
Relay client message vocabulary (REQ/EVENT/CLOSE/AUTH/
EOSE/OK/NOTICE/CLOSED) + in-memory router.
EOC (1 crate, 2024 LOC, 30 tests)
eoc-streaming Token-by-token + tool-call streaming primitives.
SSE framing (data: lines); Anthropic event mapper
(message_start/content_block_*/message_delta/stop/ping);
OpenAI delta mapper; Vercel AI SDK mapper. Bounded-channel
backpressure with watermarks; CancelToken propagation;
Last-Event-ID resumable streams; per-stream joule meter.
Co-Authored-By: Claude Opus 4.7 <[email protected]>
82 lines
3.1 KiB
Rust
82 lines
3.1 KiB
Rust
//! Integration: USDC payout on Base produces ERC-20 transfer calldata.
|
|
|
|
use op_core::{Currency, Money};
|
|
use op_payouts::crypto::{CryptoPayoutDriver, USDC_BASE};
|
|
use op_payouts::{
|
|
Beneficiary, BeneficiaryAccount, FundingSource, Payout, PayoutMethod, PayoutRequest,
|
|
PayoutStatus,
|
|
};
|
|
|
|
#[test]
|
|
fn usdc_on_base_builds_evm_intent() {
|
|
let driver = CryptoPayoutDriver {
|
|
source_wallet: "0xfeedfacefeedfacefeedfacefeedfacefeedface".to_string(),
|
|
};
|
|
// USDC has 6 decimals on Base. ISO 4217 has no slot for crypto and
|
|
// `Currency::try_new` caps exponent at 4, so we model the on-chain
|
|
// amount as raw token-minor-units carried in a Currency with
|
|
// exponent 0. The driver reads `minor_units` verbatim into
|
|
// calldata, which is what we assert.
|
|
let usdc = Currency::try_new(*b"USC", 0).expect("currency");
|
|
let amount = Money::from_minor(25_000_000, usdc); // 25 USDC in 6-dec minor units
|
|
let req = PayoutRequest {
|
|
idempotency_key: "44444444-4444-4444-8444-444444444444".to_string(),
|
|
method: PayoutMethod::Crypto {
|
|
asset: "USDC".to_string(),
|
|
network: "base".to_string(),
|
|
},
|
|
amount,
|
|
beneficiary: Beneficiary {
|
|
name: "wallet".to_string(),
|
|
address: None,
|
|
account: BeneficiaryAccount::EvmAddress(
|
|
"0x000000000000000000000000000000000000beef".to_string(),
|
|
),
|
|
kyc_ref: None,
|
|
},
|
|
funding: FundingSource::Prefunded {
|
|
account_ref: "hot-wallet-base".to_string(),
|
|
},
|
|
memo: None,
|
|
};
|
|
|
|
let res = driver.submit(&req).expect("offline build");
|
|
assert_eq!(res.status, PayoutStatus::PreparedOffline);
|
|
let body: serde_json::Value =
|
|
serde_json::from_slice(&res.wire_payload.expect("payload")).expect("json");
|
|
assert_eq!(body["chain"], "base");
|
|
assert_eq!(body["asset"], "USDC");
|
|
assert_eq!(body["token_contract"], USDC_BASE);
|
|
let calldata = body["calldata_hex"].as_str().expect("calldata");
|
|
assert!(calldata.starts_with("0xa9059cbb"));
|
|
// amount field at the end: 25_000_000 in hex right-padded to 64 chars
|
|
let expected_amt = format!("{:064x}", 25_000_000u128);
|
|
assert!(calldata.ends_with(&expected_amt));
|
|
}
|
|
|
|
#[test]
|
|
fn usdc_evm_rejects_bad_address() {
|
|
let driver = CryptoPayoutDriver {
|
|
source_wallet: "0xfeed".to_string(),
|
|
};
|
|
let usdc = Currency::try_new(*b"USC", 0).expect("currency");
|
|
let req = PayoutRequest {
|
|
idempotency_key: "55555555-5555-4555-8555-555555555555".to_string(),
|
|
method: PayoutMethod::Crypto {
|
|
asset: "USDC".to_string(),
|
|
network: "ethereum".to_string(),
|
|
},
|
|
amount: Money::from_minor(1_000_000, usdc),
|
|
beneficiary: Beneficiary {
|
|
name: "wallet".to_string(),
|
|
address: None,
|
|
account: BeneficiaryAccount::EvmAddress("0xnothex".to_string()),
|
|
kyc_ref: None,
|
|
},
|
|
funding: FundingSource::Prefunded {
|
|
account_ref: "hot".to_string(),
|
|
},
|
|
memo: None,
|
|
};
|
|
assert!(driver.submit(&req).is_err());
|
|
}
|