Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support non-standard RPC methods for indexing services #123

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
992702d
eth_getTransactionsByBlockNumber and eth_getTransactionReceiptsByBloc…
rahul10puchd Nov 11, 2021
b897e04
Merge remote-tracking branch 'up/master' into covalentMethods
rahul10puchd Nov 11, 2021
51a620d
Bog fix for eth_getTransactionsByBlockNumber
rahul10puchd Nov 18, 2021
d3d4ea3
Merge remote-tracking branch 'up/master' into covalentMethods
rahul10puchd Nov 18, 2021
9cff011
update lib
rahul10puchd Nov 18, 2021
a7efcc3
Merge remote-tracking branch 'up/master' into covalentMethods
rahul10puchd Nov 19, 2021
6b5df19
lint fix
rahul10puchd Nov 19, 2021
65eccec
comments removed
rahul10puchd Dec 3, 2021
f77037f
added eth_getTransactionReceiptsByBlockNumber sql function and callin…
rahul10puchd Dec 3, 2021
4a0466c
added eth_getTransactionsByBlockNumber sql function and calling it fr…
rahul10puchd Dec 7, 2021
1f88776
sorted non-standard methods in alphabetical order and updated query f…
rahul10puchd Dec 9, 2021
bec099b
Merge remote-tracking branch 'up/master' into covalentMethods
rahul10puchd Dec 9, 2021
13235bf
code formating
rahul10puchd Dec 9, 2021
936d30a
identation fixing
rahul10puchd Dec 9, 2021
a6d67a1
Merge branch 'master' of https://github.com/aurora-is-near/aurora-rel…
0x3bfc Dec 20, 2021
894d002
minor lint fixes
0x3bfc Dec 21, 2021
32424c4
return set of transaction receipts and transaction results
0x3bfc Dec 21, 2021
54282a3
Merge branch 'master' of https://github.com/aurora-is-near/aurora-rel…
0x3bfc Dec 21, 2021
2749281
revert to the old timestamp def in eth_geBlockByNumber.sql
0x3bfc Dec 21, 2021
0ee999e
Merge branch 'master' into covalentMethods
0x3bfc Dec 27, 2021
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
13 changes: 12 additions & 1 deletion etc/methods.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,18 @@ eth_getTransactionByBlockNumberAndIndex:
implementations:
- etc/schema/functions/eth_getTransactionByBlockNumberAndIndex.sql
- src/servers/skeleton.ts

eth_getTransactionByBlockNumber:
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
status: ok
comment:
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
link: https://eth.wiki/json-rpc/API#eth_getTransactionByBlockNumber
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
implementations:
- src/servers/skeleton.ts
eth_getTransactionReceiptsByBlockNumber:
status: ok
comment:
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
link: https://eth.wiki/json-rpc/API#eth_getTransactionReceiptsByBlockNumber
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
implementations:
- src/servers/skeleton.ts
eth_getTransactionByHash:
status: wip
comment:
Expand Down
2 changes: 2 additions & 0 deletions lib/servers/database.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@ export declare class DatabaseServer extends SkeletonServer {
eth_getLogs(_request: any, filter: web3.FilterOptions): Promise<web3.LogObject[]>;
eth_getStorageAt(_request: any, address: web3.Data, key: web3.Quantity, blockNumber: web3.Quantity | web3.Tag): Promise<web3.Data>;
eth_getTransactionByBlockHashAndIndex(_request: any, blockHash: web3.Data, transactionIndex: web3.Quantity): Promise<web3.TransactionResult | null>;
eth_getTransactionsByBlockNumber(_request: any, blockNumber: web3.Quantity | web3.Tag): Promise<web3.TransactionResult | null>;
eth_getTransactionByBlockNumberAndIndex(_request: any, blockNumber: web3.Quantity | web3.Tag, transactionIndex: web3.Quantity): Promise<web3.TransactionResult | null>;
eth_getTransactionByHash(_request: any, transactionHash: web3.Data): Promise<web3.TransactionResult | null>;
eth_getTransactionCount(_request: any, address: web3.Data, blockNumber: web3.Quantity | web3.Tag): Promise<web3.Quantity>;
eth_getTransactionReceipt(_request: any, transactionHash: string): Promise<web3.TransactionReceipt | null>;
eth_getTransactionReceiptsByBlockNumber(_request: any, blockNumber: web3.Quantity | web3.Tag): Promise<web3.TransactionReceipt[] | null>;
eth_getUncleCountByBlockHash(_request: any, blockHash: web3.Data): Promise<web3.Quantity | null>;
eth_getUncleCountByBlockNumber(_request: any, blockNumber: web3.Quantity | web3.Tag): Promise<web3.Quantity | null>;
eth_newBlockFilter(_request: any): Promise<web3.Quantity>;
Expand Down
64 changes: 64 additions & 0 deletions lib/servers/database.js

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

2 changes: 2 additions & 0 deletions lib/servers/skeleton.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ export declare abstract class SkeletonServer implements web3.Service {
eth_getStorageAt(_request: any, _address: web3.Data, _key: web3.Quantity, _blockNumber: web3.Quantity | web3.Tag): Promise<web3.Data>;
eth_getTransactionByBlockHashAndIndex(_request: any, _blockHash: web3.Data, _transactionIndex: web3.Quantity): Promise<web3.TransactionResult | null>;
eth_getTransactionByBlockNumberAndIndex(_request: any, _blockNumber: web3.Quantity | web3.Tag, _transactionIndex: web3.Quantity): Promise<web3.TransactionResult | null>;
eth_getTransactionsByBlockNumber(_request: any, _blockNumber: web3.Quantity | web3.Tag): Promise<web3.TransactionResult | null>;
eth_getTransactionReceiptsByBlockNumber(_request: any, _blockNumber: web3.Quantity | web3.Tag): Promise<web3.TransactionReceipt[] | null>;
eth_getTransactionByHash(_request: any, _transactionHash: web3.Data): Promise<web3.TransactionResult | null>;
eth_getTransactionCount(_request: any, _address: web3.Data, _blockNumber: web3.Quantity | web3.Tag): Promise<web3.Quantity>;
eth_getTransactionReceipt(_request: any, _transactionHash: string): Promise<web3.TransactionReceipt | null>;
Expand Down
8 changes: 8 additions & 0 deletions lib/servers/skeleton.js

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

2 changes: 2 additions & 0 deletions lib/web3.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ export interface Service {
eth_getProof(_request: any, address: Data, keys: Data[], blockNumber: Quantity | Tag): Promise<ProofResult>;
eth_getStorageAt(_request: any, address: Data, key: Quantity, blockNumber: Quantity | Tag): Promise<Data>;
eth_getTransactionByBlockHashAndIndex(_request: any, blockHash: Data, transactionIndex: Quantity): Promise<TransactionResult | null>;
eth_getTransactionsByBlockNumber(_request: any, blockNumber: Quantity | Tag): Promise<TransactionResult | null>;
eth_getTransactionReceiptsByBlockNumber(_request: any, blockNumber: Quantity | Tag): Promise<TransactionReceipt[] | null>;
eth_getTransactionByBlockNumberAndIndex(_request: any, blockNumber: Quantity | Tag, transactionIndex: Quantity): Promise<TransactionResult | null>;
eth_getTransactionByHash(_request: any, transactionHash: Data): Promise<TransactionResult | null>;
eth_getTransactionCount(_request: any, address: Data, blockNumber: Quantity | Tag): Promise<Quantity>;
Expand Down
82 changes: 81 additions & 1 deletion src/servers/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,45 @@ export class DatabaseServer extends SkeletonServer {
return null;
}
}

async eth_getTransactionsByBlockNumber(
_request: any,
blockNumber: web3.Quantity | web3.Tag
): Promise<web3.TransactionResult | null> {
const blockNumber_ =
artob marked this conversation as resolved.
Show resolved Hide resolved
parseBlockSpec(blockNumber) || (await this._fetchCurrentBlockID());

try {
const {
rows,
} = await this._query(
`SELECT
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
b.id AS "blockNumber",
b.hash AS "blockHash",
t.index AS "transactionIndex",
t.hash AS "hash",
t.from AS "from",
t.to AS "to",
t.gas_limit AS "gas",
t.gas_price AS "gasPrice",
t.nonce AS "nonce",
t.value AS "value",
coalesce(t.input, '\\x'::bytea) AS "input",
t.v AS "v",
t.r AS "r",
t.s AS "s"
FROM transaction t
LEFT JOIN block b ON t.block = b.id
WHERE b.id = $1`,
[blockNumber_]
);
return !rows || !rows.length ? null : exportJSON(rows[0]);
artob marked this conversation as resolved.
Show resolved Hide resolved
} catch (error) {
if (this.config.debug) {
console.debug('eth_getTransactionsByBlockNumber', error);
}
return null;
}
}
async eth_getTransactionByBlockNumberAndIndex(
_request: any,
blockNumber: web3.Quantity | web3.Tag,
Expand Down Expand Up @@ -550,7 +588,49 @@ export class DatabaseServer extends SkeletonServer {
return null;
}
}
async eth_getTransactionReceiptsByBlockNumber(
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
_request: any,
blockNumber: web3.Quantity | web3.Tag
): Promise<web3.TransactionReceipt[] | null> {
const blockNumber_ =
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
parseBlockSpec(blockNumber) || (await this._fetchCurrentBlockID());
try {
const {
rows: [receipt],
} = await this._query(
`SELECT
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
b.id AS "blockNumber",
b.hash AS "blockHash",
t.index AS "transactionIndex",
t.hash AS "transactionHash",
t.from AS "from",
t.to AS "to",
t.gas_used AS "gasUsed",
0::u256 AS "cumulativeGasUsed", -- TODO: tally?
CASE WHEN t.to IS NULL OR t.to = '\\x0000000000000000000000000000000000000000' THEN t.output
ELSE NULL
END AS "contractAddress",
NULL AS "logs", -- TODO: fetch event.id[]
repeat('\\000', 256)::bytea AS "logsBloom",
CASE WHEN t.status THEN 1 ELSE 0 END AS "status",
t.near_hash AS "nearTransactionHash",
artob marked this conversation as resolved.
Show resolved Hide resolved
t.near_receipt_hash AS "nearReceiptHash"
FROM transaction t
LEFT JOIN block b ON t.block = b.id
WHERE b.id = $1`,
[blockNumber_]
);
//assert(receipt, 'receipt is not null');

receipt.logs = await this._fetchEvents(hexToBytes(receipt.transactionHash.toString()));
return exportJSON(receipt);
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
} catch (error) {
if (this.config.debug) {
console.debug('eth_getTransactionReceiptsByBlockNumber', error);
}
return null;
}
}
async eth_getUncleCountByBlockHash(
_request: any,
blockHash: web3.Data
Expand Down
15 changes: 14 additions & 1 deletion src/servers/skeleton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,20 @@ export abstract class SkeletonServer implements web3.Service {
unimplemented('eth_getTransactionByBlockNumberAndIndex');
return null;
}

async eth_getTransactionsByBlockNumber(
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
_request: any,
_blockNumber: web3.Quantity | web3.Tag
): Promise<web3.TransactionResult | null> {
unimplemented('eth_getTransactionsByBlockNumber');
return null;
}
async eth_getTransactionReceiptsByBlockNumber(
_request: any,
_blockNumber: web3.Quantity | web3.Tag
): Promise<web3.TransactionReceipt[] | null> {
unimplemented('eth_getTransactionReceiptsByBlockNumber');
return null;
}
async eth_getTransactionByHash(
_request: any,
_transactionHash: web3.Data
Expand Down
8 changes: 8 additions & 0 deletions src/web3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,14 @@ export interface Service {
blockHash: Data,
transactionIndex: Quantity
): Promise<TransactionResult | null>;
eth_getTransactionsByBlockNumber(
_request: any,
blockNumber: Quantity | Tag,
): Promise<TransactionResult | null>;
eth_getTransactionReceiptsByBlockNumber(
_request: any,
blockNumber: Quantity | Tag,
): Promise<TransactionReceipt[] | null>;
0x3bfc marked this conversation as resolved.
Show resolved Hide resolved
eth_getTransactionByBlockNumberAndIndex(
_request: any,
blockNumber: Quantity | Tag,
Expand Down