Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
227aca3
first pass at basic ethereum primitives
pemulis May 3, 2026
e8c7281
check that rpc response ids match request ids, and note jsonrpc 2.0 i…
pemulis May 3, 2026
af7bae6
remove status from packageInfo for non-placeholder packages
pemulis May 3, 2026
c42499b
remove packageInfo object from non-placeholder packages, and update s…
pemulis May 3, 2026
4683324
refactor shared utility functions into @oyaprotocol/utils
pemulis May 3, 2026
77268e1
remove placeholder @oyaprotocol/verification package since we will li…
pemulis May 3, 2026
e96ead4
add generic HttpConfig and CreateHttpConfigOptions interfaces in the …
pemulis May 3, 2026
77287ec
implement allowlist for retryable eth transactions, limited to read-o…
pemulis May 3, 2026
e983096
consolidate shared functionality of http config creator functions int…
pemulis May 3, 2026
d33ada6
refactor retryable http errors into the shared utils package
pemulis May 3, 2026
cf29a96
validate the normalized config url before returning since normalizati…
pemulis May 3, 2026
8697731
add an ethSendRawTransaction wrapper that optionally accepts a transa…
pemulis May 3, 2026
0e64012
rename ethereum.ts to raw-transactions.ts
pemulis May 3, 2026
55e6a87
actually, make it transactions.ts
pemulis May 3, 2026
9aa29ca
update test file naming
pemulis May 3, 2026
5e7c903
preserve caller casing for hex values instead of forcing lowercase
pemulis May 3, 2026
747295f
encapsulate shared abort and retry utils
pemulis May 3, 2026
0e44dbf
better handle retries in the special case of raw transactions, rather…
pemulis May 3, 2026
e0bd0b7
better handle abort signals
pemulis May 3, 2026
39e68d0
catch request and response id mismatches before handling errors and r…
pemulis May 4, 2026
c42c569
create a shared type for http post requests, passing in a custom body…
pemulis May 5, 2026
13471f1
consolidate http utility files into a single http-utils file so we ha…
pemulis May 5, 2026
345346d
use generic createHttpConfig for setting up Ethereum client instead o…
pemulis May 5, 2026
0438247
consolidate more utility functions
pemulis May 5, 2026
95bf5fc
add some edge case tests
pemulis May 5, 2026
3e1d5df
add shared HttpStatusError to utilities, and use it in ipfs and ether…
pemulis May 6, 2026
25509dc
refactor shared error string handling function into utils
pemulis May 6, 2026
e216c59
simplify buildJsonRpcBody error message since errors won't always be …
pemulis May 6, 2026
ae5d4e6
handle fetch errors with an opaque code of 0
pemulis May 6, 2026
650a842
add runWithRetry function to async-utils and use for ipfs and ethereu…
pemulis May 6, 2026
3df20a1
rename requestEthereumJsonRpcWithRetryPolicy to requestEthereumJsonRp…
pemulis May 6, 2026
f398690
clarify function name for checking if a raw transaction error indicat…
pemulis May 6, 2026
36a5b99
rename RAW_TRANSACTION_RECOVERY_MESSAGES to RAW_TRANSACTION_DUPLICATE…
pemulis May 6, 2026
dbbe7f9
rename shouldRetryRawTransactionMethod to isRawTransactionMethod
pemulis May 6, 2026
6d489f5
move transaction hash existence check into the catch before triggerin…
pemulis May 6, 2026
741d359
undo a function renaming for custom retry policy
pemulis May 6, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
- `packages/messages` -> `@oyaprotocol/messages`
- `packages/ipfs` -> `@oyaprotocol/ipfs`
- `packages/ethereum` -> `@oyaprotocol/ethereum`
- `packages/verification` -> `@oyaprotocol/verification`

## Import Strategy

Expand All @@ -25,4 +24,6 @@

## Current Constraints

- These package shells do not define functional ownership yet.
- `@oyaprotocol/ipfs`, `@oyaprotocol/ethereum`, and `@oyaprotocol/utils` expose functional kernel APIs.
- `@oyaprotocol/messages` is still a placeholder package shell.
- Proposal or proof verification packages are intentionally not represented here yet; those may be implemented later in a lower-level language while TypeScript packages focus on network interactions.
21 changes: 20 additions & 1 deletion packages/ethereum/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,26 @@
# @oyaprotocol/ethereum

Placeholder shell for the Oya Ethereum package.
Ethereum JSON-RPC utilities for Oya kernel code. This package is a hardened kernel surface: callers provide explicit transport settings and explicit `fetch` implementations instead of relying on process-level defaults.

## Public Entrypoint

- `@oyaprotocol/ethereum`

## Current Surface

- `createHttpConfig(options)`: validate explicit HTTP transport settings, re-exported from `@oyaprotocol/utils`.
- `requestEthereumJsonRpc(options)`: send one JSON-RPC POST request with explicit config and injected `fetch`, returning the raw `result`, attempt count, id, and parsed response payload.
- `ethSendRawTransaction(options)`: submit a signed raw transaction and return the transaction hash with attempt metadata. Callers may pass `transactionHash` when they already know the hash, allowing the wrapper to verify duplicate-style retry errors with `eth_getTransactionByHash`.
- `EthereumJsonRpcError`: thrown when an HTTP-successful JSON-RPC response contains an `error` payload.
- `HttpStatusError`: thrown when the HTTP response itself is not successful, re-exported from `@oyaprotocol/utils`.
- `EthereumRawTransactionRecoveryError`: thrown when raw transaction submission may have succeeded before a retry returned a duplicate-style error, but the wrapper could not verify the supplied transaction hash.

## Behavior

`createHttpConfig(...)` accepts the shared `CreateHttpConfigOptions` shape from `@oyaprotocol/utils`. The `url` value is normalized by trimming trailing slashes before JSON-RPC requests are sent.

`requestEthereumJsonRpc(...)` owns the JSON-RPC envelope and request headers. It sends `content-type: application/json`, rejects caller-provided `content-type` config headers, enforces a request timeout, retries transient HTTP/network failures only for read-only Ethereum methods, and treats JSON-RPC error payloads as non-retryable semantic errors.

`ethSendRawTransaction(...)` does not sign transactions and does not compute transaction hashes. It expects callers to provide a signed raw transaction. If `transactionHash` is supplied and a retry of `eth_sendRawTransaction` returns duplicate-style JSON-RPC errors such as `already known` or `nonce too low`, the wrapper checks `eth_getTransactionByHash(transactionHash)` before returning a recovered result. Without `transactionHash`, those cases are surfaced as `EthereumRawTransactionRecoveryError` because the package cannot verify acceptance without Keccak hashing.

This package does not sign transactions, encode ABIs, read environment variables, or own RPC endpoint discovery. Callers are responsible for preparing JSON-RPC params, including converting `bigint` values to Ethereum quantity hex before calling the raw request primitive.
10 changes: 6 additions & 4 deletions packages/ethereum/dist/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export declare const packageInfo: Readonly<{
name: "@oyaprotocol/ethereum";
status: "placeholder";
}>;
export { createHttpConfig, HttpStatusError } from '@oyaprotocol/utils';
export type { CreateHttpConfigOptions, HttpConfig, HttpFetchLike, HttpPostFetchLike, HttpPostFetchOptions, HttpStatusErrorOptions, HttpTextResponse, } from '@oyaprotocol/utils';
export { EthereumRawTransactionRecoveryError, ethSendRawTransaction, } from './transactions.js';
export type { EthSendRawTransactionOptions, EthSendRawTransactionResult, } from './transactions.js';
export { EthereumJsonRpcError, requestEthereumJsonRpc, } from './request-utils.js';
export type { RequestEthereumJsonRpcOptions, RequestEthereumJsonRpcResult, } from './request-utils.js';
7 changes: 3 additions & 4 deletions packages/ethereum/dist/index.js

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

2 changes: 1 addition & 1 deletion packages/ethereum/dist/index.js.map

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

36 changes: 36 additions & 0 deletions packages/ethereum/dist/request-utils.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import type { HttpConfig, HttpPostFetchLike } from '@oyaprotocol/utils';
export interface RequestEthereumJsonRpcOptions {
config: HttpConfig;
fetch: HttpPostFetchLike<string>;
method: string;
params?: readonly unknown[];
id?: string | number;
signal?: AbortSignal;
}
export interface RequestEthereumJsonRpcResult<TResult = unknown> {
result: TResult;
attemptCount: number;
id: string | number;
response: unknown;
}
interface EthereumJsonRpcErrorOptions {
method: string;
response: unknown;
attemptCount?: number;
}
interface JsonRpcErrorPayload {
code?: unknown;
message?: unknown;
data?: unknown;
}
declare class EthereumJsonRpcError extends Error {
readonly attemptCount: number;
readonly code: number | null;
readonly data?: unknown;
readonly method: string;
readonly response: unknown;
constructor(error: JsonRpcErrorPayload, { method, response, attemptCount }: EthereumJsonRpcErrorOptions);
}
declare function requestEthereumJsonRpcWithCustomRetryPolicy<TResult = unknown>({ config, fetch, method, params, id, signal, }: RequestEthereumJsonRpcOptions, shouldRetryJsonRpcMethod: (method: string) => boolean): Promise<RequestEthereumJsonRpcResult<TResult>>;
declare function requestEthereumJsonRpc<TResult = unknown>(options: RequestEthereumJsonRpcOptions): Promise<RequestEthereumJsonRpcResult<TResult>>;
export { EthereumJsonRpcError, requestEthereumJsonRpc, requestEthereumJsonRpcWithCustomRetryPolicy, };
227 changes: 227 additions & 0 deletions packages/ethereum/dist/request-utils.js

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

Loading
Loading