Skip to content

Commit

Permalink
Merge pull request #11 from axiom-crypto/release/v2.1.1
Browse files Browse the repository at this point in the history
[release] v2.1.1
  • Loading branch information
ytham authored Apr 19, 2024
2 parents 43891b2 + 1467050 commit 1cb8f22
Show file tree
Hide file tree
Showing 13 changed files with 185 additions and 309 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ jobs:
- name: Test with Jest
run: |
export PROVIDER_URI=${{ secrets.PROVIDER_URI }}
export PROVIDER_URI_GOERLI=${{ secrets.PROVIDER_URI_GOERLI }}
export PROVIDER_URI_SEPOLIA=${{ secrets.PROVIDER_URI_SEPOLIA }}
export PROVIDER_URI_10=${{ secrets.PROVIDER_URI_10 }}
export PROVIDER_URI_8453=${{ secrets.PROVIDER_URI_8453 }}
export PINATA_JWT=${{ secrets.PINATA_JWT }}
export QUICKNODE_API_KEY=${{ secrets.QUICKNODE_API_KEY }}
export QUICKNODE_IPFS_URL=${{ secrets.QUICKNODE_IPFS_URL }}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@axiom-crypto/tools",
"version": "2.1.0",
"version": "2.1.1",
"description": "Useful data, field, and byte manipulation tools for Axiom.",
"author": "Intrinsic Technologies",
"license": "MIT",
Expand Down
6 changes: 3 additions & 3 deletions pnpm-lock.yaml

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

17 changes: 12 additions & 5 deletions src/codec/v2/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,13 @@ export interface AxiomV2Result {
computeResultsHash: string;
}

export interface Subquery {}
export interface Subquery {
/**
* The block number of the block that the subquery needs data from.
* `undefined` if no block is needed.
*/
blockNumber?: number;
}

export interface StorageSubqueryV1 extends Subquery {
blockNumber: number;
Expand Down Expand Up @@ -190,8 +196,9 @@ export enum ReceiptField {
}

export enum TxType {
Legacy,
Eip2930,
Eip1559,
Eip4844,
Legacy = 0,
Eip2930 = 1,
Eip1559 = 2,
Eip4844 = 3,
OpSystem = 126, // 0x7E
}
6 changes: 6 additions & 0 deletions src/rpc/subqueryField.ts
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,9 @@ export async function getTxFieldValue(
if (type === TxType.Eip4844) {
logger.error(`EIP-4844 transactions are not yet supported`);
return null;
} else if (type === TxType.OpSystem) {
logger.error(`OP stack System transactions are not yet supported`);
return null;
}
const value = getValue(tx, type);

Expand Down Expand Up @@ -487,6 +490,9 @@ export async function getReceiptFieldValue(
if (Number(receipt?.type) === TxType.Eip4844) {
logger.error(`EIP-4844 transaction receipts are not yet supported`);
return null;
} else if (Number(receipt?.type) === TxType.OpSystem) {
logger.error(`OP stack System transaction receipts are not yet supported`);
return null;
}

const value = getValue(receipt);
Expand Down
16 changes: 16 additions & 0 deletions src/utils/gasCalc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { ByteStringReader } from "./byteStringReader";

export function calculateCalldataGas(hexString: string): number {
let gas = 0;
const reader = new ByteStringReader(hexString);
while (reader.getNumBytesRemaining() > 0) {
const byte = reader.readBytes(1);
if (byte === "0x00") {
gas += 4;
} else {
gas += 16;
}
}

return gas;
}
1 change: 1 addition & 0 deletions src/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,4 @@ export * from "./storage";
export * from "./byteStringReader";
export * from "./evm";
export * from "./rlp";
export * from "./gasCalc";
20 changes: 13 additions & 7 deletions test/codec/v2/data/codecData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ import {
AxiomV2DataQuery,
bytes32,
AxiomV2FeeData,
HeaderSubquery,
AccountSubquery,
StorageSubquery,
TxSubquery,
ReceiptSubquery,
SolidityNestedMappingSubquery,
} from "../../../../src";


Expand Down Expand Up @@ -88,38 +94,38 @@ export const dataSubqueries: DataSubquery[] = [
subqueryData: {
blockNumber: BLOCK_NUMBER,
fieldIdx: HeaderField.Miner,
},
} as HeaderSubquery,
},
{
type: DataSubqueryType.Header,
subqueryData: {
blockNumber: BLOCK_NUMBER + 1,
fieldIdx: HeaderField.GasLimit,
},
} as HeaderSubquery,
},
{
type: DataSubqueryType.Account,
subqueryData: {
blockNumber: BLOCK_NUMBER,
addr: WETH_ADDR,
fieldIdx: AccountField.CodeHash,
},
} as AccountSubquery,
},
{
type: DataSubqueryType.Storage,
subqueryData: {
blockNumber: BLOCK_NUMBER,
addr: WETH_ADDR,
slot: bytes32(1),
},
} as StorageSubquery,
},
{
type: DataSubqueryType.Transaction,
subqueryData: {
blockNumber: 15060942,
txIdx: 114,
fieldOrCalldataIdx: TxField.To,
},
} as TxSubquery,
},
{
type: DataSubqueryType.Receipt,
Expand All @@ -129,7 +135,7 @@ export const dataSubqueries: DataSubquery[] = [
fieldOrLogIdx: 0,
topicOrDataOrAddressIdx: 0,
eventSchema: "0x255910aca2752f3c05fcb4a54d3d8d93bb809a9c8cc215d5eed2504d44cbd865",
},
} as ReceiptSubquery,
},
{
type: DataSubqueryType.SolidityNestedMapping,
Expand All @@ -139,7 +145,7 @@ export const dataSubqueries: DataSubquery[] = [
mappingSlot: bytes32(5),
mappingDepth: 3,
keys: [bytes32(WETH_ADDR), bytes32(WSOL_ADDR), bytes32(10000)],
},
} as SolidityNestedMappingSubquery,
},
];
export const dataQuery: AxiomV2DataQuery = {
Expand Down
20 changes: 13 additions & 7 deletions test/codec/v2/encode.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ import {
getCallbackHash,
AxiomV2FeeData,
encodeFullQueryV2,
HeaderSubquery,
AccountSubquery,
StorageSubquery,
TxSubquery,
ReceiptSubquery,
SolidityNestedMappingSubquery,
} from "../../../src";
import {
BLOCK_NUMBER,
Expand Down Expand Up @@ -277,38 +283,38 @@ describe("Encoder V2", () => {
subqueryData: {
blockNumber,
fieldIdx,
},
} as HeaderSubquery,
},
{
type: DataSubqueryType.Header,
subqueryData: {
blockNumber: blockNumber + 1,
fieldIdx: fieldIdx + 1,
},
} as HeaderSubquery,
},
{
type: DataSubqueryType.Account,
subqueryData: {
blockNumber,
addr,
fieldIdx,
},
} as AccountSubquery,
},
{
type: DataSubqueryType.Storage,
subqueryData: {
blockNumber,
addr,
slot,
},
} as StorageSubquery,
},
{
type: DataSubqueryType.Transaction,
subqueryData: {
blockNumber: 15060942,
txIdx: 114,
fieldOrCalldataIdx,
},
} as TxSubquery,
},
{
type: DataSubqueryType.Receipt,
Expand All @@ -318,7 +324,7 @@ describe("Encoder V2", () => {
fieldOrLogIdx,
topicOrDataOrAddressIdx,
eventSchema: "0x255910aca2752f3c05fcb4a54d3d8d93bb809a9c8cc215d5eed2504d44cbd865",
},
} as ReceiptSubquery,
},
{
type: DataSubqueryType.SolidityNestedMapping,
Expand All @@ -328,7 +334,7 @@ describe("Encoder V2", () => {
mappingSlot,
mappingDepth,
keys,
},
} as SolidityNestedMappingSubquery,
},
];

Expand Down
6 changes: 3 additions & 3 deletions test/ipfs/scenarios.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe("Additional IPFS scenarios to test", () => {
};
}
}
}, 30000);
}, 50000);

test(`Read all pinned data`, async () => {
for await (const client of ipfsClients) {
Expand All @@ -64,7 +64,7 @@ describe("Additional IPFS scenarios to test", () => {
}
}
}
}, 30000);
}, 60000);

test(`Unpin all data`, async () => {
for await (const client of ipfsClients) {
Expand All @@ -73,5 +73,5 @@ describe("Additional IPFS scenarios to test", () => {
expect(unpin.value as boolean).toEqual(true);
}
}
}, 30000);
}, 50000);
});
Loading

0 comments on commit 1cb8f22

Please sign in to comment.