is_true(x) — polymorphic truthy check. The transpiler emits
is_true(&X) where X may be a Value, a bool, or the result of
any other predicate (is_equal, in_op, …). This trait lets all of
them work without manual conversion at the call site.
obj[key].push(v) — append to an array field of a dict in place. The
transpiled dict['bids'].push(x) otherwise lowers to
append_to_array(&mut get_value(&dict, &key), x), whose get_value yields a
COW clone, so the push is lost (paradex’s order-book inserts). Mutate the
field through the dict instead.
Bridge an async exchange call’s panic-based error convention onto Rust’s
Result. The transpiled bodies use panic!("[Kind] message") (mirroring
the TS throw new <Kind>(message) pattern); the typed-wrapper layer
wraps every delegate call in this helper so its public surface is
idiomatic Rust (Result<T, ExchangeError>) rather than panicking.
Synchronous sibling of call_typed: runs a closure that may signal an
error the transpiled way (panic!("[Kind] message")) and converts that into
a typed Result. Used by the typed wrappers’ non-async accessors.
Forge a &mut Value from a &Value. Used by the transpiler to
emit nested-key writes (this.options['k1'][k2] = v in TS) inside
&self parser methods like bitstamp.parseCurrency that accumulate
state into self.options. The naive &mut self.options.clone()
mutably borrows a temporary — the write never reaches self.options,
silently breaking the parser.
contains(haystack, needle) — substring check for Value::Str,
element check for Value::Array. Used by the transpiled tests
for string.includes(...) / array.includes(...) (the regex
transpiler rewrites both into this free function).
Decode mexc’s PushDataV3ApiWrapper protobuf frame into the same shape
protobufjs’ .toJSON() produces, so the ported handlers read it unchanged.
Wires the public order-book (depth), book-ticker, deals and kline bodies.
Recursively deep-extend base with over (CCXT deepExtend semantics):
nested dicts are merged key-by-key rather than wholesale-replaced, and
over’s leaves win on conflict. Used by generated init() to merge a pro
Core’s describe().options over the parent REST Core’s — e.g. mexc’s
options.timeframes is a flat {1m: Min1} in the pro block but a nested
{spot, swap} in REST; a shallow merge dropped one, breaking watchOHLCV’s
interval lookup. Deep-merge yields the union both forms rely on.
eddsa(request, secret, curve) — Ed25519 signature, mirroring
ts/src/base/functions/crypto.ts. request is the message (already-bytes
Value::Arr as produced by encode(...), or a hex/utf8 string); secret is
either a 32-byte raw seed string or a base64/PEM PKCS#8 key (seed at DER
offset 16). Returns the standard-base64 signature. Fails loudly (NotSupported
panic) rather than returning an empty/invalid signature.
Mirrors TS e instanceof <ClassName>: panic payloads in the
transpiled tests are Value::Str(format!("[{kind}] {message}"))
(see ExchangeError’s Display impl), so the class name is whatever
sits between the first pair of square brackets. Matches the
expected-error-class names that broker-id and static-request tests
pass as Value::Str("InvalidProxySettings").
Parse a transpiled error payload ("[Kind] message") into a typed
ExchangeError. Falls back to the generic ExchangeError kind when
the payload doesn’t carry a leading [Kind] marker.
Convert a catch_unwind panic payload into the Value::Str shape
that transpiled catch (e) blocks expect. The transpiled code uses
this from the catch arm emitted by rewriteTryCatchAsync — kept in
the ccxt crate (rather than the test crate) so exchange files that
catch downstream panics (e.g. pacifica try { approveBuilderCode } catch { disable_builder_fee }) can use it without a test-crate dep.
Wraps every JSON object number VALUE in quotes, replicating CCXT’s
onJsonResponse transform responseBody.replace(/":([+.0-9eE-]+)([,}])/g, '":"$1"$2')
used when quoteJsonNumbers is on (the default). This preserves big
integer ids and high-precision decimals as strings through parsing,
matching how the unified parsers (safeString/safeNumber/Precise)
expect to read them. Only object values (a number right after ":
and right before , or }) are quoted — array elements are left
alone, mirroring the upstream regex. Byte-oriented so multi-byte
UTF-8 in the surrounding text is preserved.
Array.prototype.shift() — removes and returns the first element.
Called as a free function from transpiled WS code (shift(stored)).
Returns Value::Null if the array is empty or the target isn’t an
array.
totp(secret) — RFC 6238 time-based one-time password (HMAC-SHA1, 30s step,
6 digits), mirroring ts/src/base/functions/totp.ts. The secret is a
base32 string (spaces allowed, as in “4TDV WOGO”). Returns Value::Null for
a non-string secret.