Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/wevm/ox into tmm/1193-errors
Browse files Browse the repository at this point in the history
  • Loading branch information
tmm committed Nov 12, 2024
2 parents 603e571 + 2a7d21b commit af7b6db
Show file tree
Hide file tree
Showing 195 changed files with 648 additions and 592 deletions.
23 changes: 12 additions & 11 deletions .github/workflows/snapshot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ jobs:
- name: Install dependencies
uses: ./.github/actions/install-dependencies

- name: Setup .npmrc file
uses: actions/setup-node@v4
with:
registry-url: 'https://registry.npmjs.org'

- name: Publish to npm
run: |
cd src && pnpm version $(npm pkg get version | sed 's/"//g')-$(date +'%Y%m%dT%H%M%S') && cd ../
pnpm changeset:prepublish
cd src && pnpm publish --no-git-checks --provenance false && cd ../
- name: Publish Snapshots
continue-on-error: true
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
snapshot=$(git branch --show-current | tr -cs '[:alnum:]-' '-' | tr '[:upper:]' '[:lower:]' | sed 's/-$//')
npm config set "//registry.npmjs.org/:_authToken" "$NPM_TOKEN"
pnpm clean
pnpm changeset version --no-git-tag --snapshot $snapshot
pnpm changeset:prepublish
pnpm changeset publish --no-git-tag --snapshot $snapshot --tag $snapshot
35 changes: 35 additions & 0 deletions examples/webauthn-p256/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,40 @@
# webauthn-p256

## 0.0.6

### Patch Changes

- Updated dependencies [[`644b96a`](https://github.com/wevm/ox/commit/644b96a169a118c6f0606eda5354785523ed099b)]:
- [email protected]

## 0.0.5

### Patch Changes

- Updated dependencies [[`777fe42`](https://github.com/wevm/ox/commit/777fe4249c5225c676ff690fda58c5fcfb35d1f0)]:
- [email protected]

## 0.0.4

### Patch Changes

- Updated dependencies [[`868d431`](https://github.com/wevm/ox/commit/868d4319a8cda77345f85f9f2e88ca786f0c8cfe)]:
- [email protected]

## 0.0.3

### Patch Changes

- Updated dependencies [[`f438faf`](https://github.com/wevm/ox/commit/f438fafbd396248283876eba220f4c661c47bfd2)]:
- [email protected]

## 0.0.2

### Patch Changes

- Updated dependencies [[`b7de4f2`](https://github.com/wevm/ox/commit/b7de4f2180520fd7f2bf08955df6e676d75db93e)]:
- [email protected]

## 0.0.1

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion examples/webauthn-p256/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "webauthn-p256",
"private": true,
"version": "0.0.1",
"version": "0.0.6",
"type": "module",
"scripts": {
"dev": "vite"
Expand Down
1 change: 1 addition & 0 deletions scripts/utils/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export function getExports({
if (!parentEntry.isDirectory()) {
if (parentEntry.name.endsWith('test.ts')) continue
if (parentEntry.name === 'jsr.json') continue
if (parentEntry.name === 'tsdoc.json') continue
if (
!parentEntry.name.endsWith('.ts') &&
!parentEntry.name.endsWith('.json')
Expand Down
30 changes: 30 additions & 0 deletions src/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,35 @@
# ox

## 0.1.5

### Patch Changes

- [`644b96a`](https://github.com/wevm/ox/commit/644b96a169a118c6f0606eda5354785523ed099b) Thanks [@jxom](https://github.com/jxom)! - Added additional guard for `result` in `Provider.from`.

## 0.1.4

### Patch Changes

- [`777fe42`](https://github.com/wevm/ox/commit/777fe4249c5225c676ff690fda58c5fcfb35d1f0) Thanks [@jxom](https://github.com/jxom)! - Tweaked `trimLeft` to remove all leading zeros.

## 0.1.3

### Patch Changes

- [`868d431`](https://github.com/wevm/ox/commit/868d4319a8cda77345f85f9f2e88ca786f0c8cfe) Thanks [@jxom](https://github.com/jxom)! - Added handling for odd-length hex values.

## 0.1.2

### Patch Changes

- [#17](https://github.com/wevm/ox/pull/17) [`f438faf`](https://github.com/wevm/ox/commit/f438fafbd396248283876eba220f4c661c47bfd2) Thanks [@jxom](https://github.com/jxom)! - Moved modules to `core/`.

## 0.1.1

### Patch Changes

- [`b7de4f2`](https://github.com/wevm/ox/commit/b7de4f2180520fd7f2bf08955df6e676d75db93e) Thanks [@jxom](https://github.com/jxom)! - Fixed `RpcSchema` inference on `params`.

## 0.1.0

### Minor Changes
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/AccountProof.ts → src/core/AccountProof.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Address, Hex } from './index.js'
import type { Address, Hex } from '../index.js'

/** An Account Proof as defined in the [Execution API specification](https://github.com/ethereum/execution-apis/blob/main/src/schemas/state.yaml). */
export type AccountProof<bigintType = bigint, numberType = number> = {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 2 additions & 4 deletions src/Bytes.ts → src/core/Bytes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,15 +230,14 @@ fromBoolean.parseError = (error: unknown) =>
export function fromHex(value: Hex.Hex, options: fromHex.Options = {}): Bytes {
const { size } = options

if (value.length % 2) throw new Hex.InvalidLengthError(value)

let hex = value
if (size) {
internal_hex.assertSize(value, size)
hex = Hex.padRight(value, size)
}

const hexString = hex.slice(2) as string
let hexString = hex.slice(2) as string
if (hexString.length % 2) hexString = `0${hexString}`

const length = hexString.length / 2
const bytes = new Uint8Array(length)
Expand All @@ -264,7 +263,6 @@ export declare namespace fromHex {
type ErrorType =
| internal_hex.assertSize.ErrorType
| Hex.padRight.ErrorType
| Hex.InvalidLengthError
| Errors.GlobalErrorType
}

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
18 changes: 7 additions & 11 deletions src/Hex.ts → src/core/Hex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ export function fromBoolean(
value: boolean,
options: fromBoolean.Options = {},
): Hex {
const hex: Hex = `0x0${Number(value)}`
const hex: Hex = `0x${Number(value)}`
if (typeof options.size === 'number') {
internal.assertSize(hex, options.size)
return padLeft(hex, options.size)
Expand Down Expand Up @@ -275,8 +275,7 @@ export function fromNumber(
signed && value_ < 0 ? (1n << BigInt(size * 8)) + BigInt(value_) : value_
).toString(16)

const hex =
`0x${stringValue.length % 2 === 0 ? stringValue : `0${stringValue}`}` as Hex
const hex = `0x${stringValue}` as Hex
if (size) return padLeft(hex, size) as Hex
return hex
}
Expand Down Expand Up @@ -649,14 +648,11 @@ toBigInt.parseError = (error: unknown) => error as toBigInt.ErrorType
* @returns The decoded boolean.
*/
export function toBoolean(hex: Hex, options: toBoolean.Options = {}): boolean {
let hex_ = hex
if (options.size) {
internal.assertSize(hex, options.size)
hex_ = trimLeft(hex_)
}
if (trimLeft(hex_) === '0x00') return false
if (trimLeft(hex_) === '0x01') return true
throw new InvalidHexBooleanError(hex_)
if (options.size) internal.assertSize(hex, options.size)
const hex_ = trimLeft(hex)
if (hex_ === '0x') return false
if (hex_ === '0x1') return true
throw new InvalidHexBooleanError(hex)
}

export declare namespace toBoolean {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions src/Provider.ts → src/core/Provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,7 @@ export function from(provider: any, options: Options = {}): Provider<Options> {
async request(args) {
const result = await provider.request(args)
if (
result &&
typeof result === 'object' &&
'jsonrpc' in (result as { jsonrpc?: unknown })
)
Expand Down
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/RpcRequest.ts → src/core/RpcRequest.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type { Errors } from '../index.js'
import type * as RpcSchema from './RpcSchema.js'
import type { Errors } from './index.js'
import type * as RpcSchema_internal from './internal/rpcSchema.js'
import type { Compute } from './internal/types.js'

Expand Down
2 changes: 1 addition & 1 deletion src/RpcResponse.ts → src/core/RpcResponse.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { Errors, RpcRequest } from './index.js'
import type { Errors, RpcRequest } from '../index.js'
import type {
Compute,
IsNarrowable,
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { AbiConstructor } from 'ox'
import { describe, expect, test } from 'vitest'

import { Constructor } from '../../contracts/generated.js'
import { anvilMainnet } from '../../test/anvil.js'
import { seaportContractConfig } from '../../test/constants/abis.js'
import { address } from '../../test/constants/addresses.js'
import { Constructor } from '../../../contracts/generated.js'
import { anvilMainnet } from '../../../test/anvil.js'
import { seaportContractConfig } from '../../../test/constants/abis.js'
import { address } from '../../../test/constants/addresses.js'

describe('decode', () => {
test('default', () => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { Abi, AbiError, AbiFunction, AbiItem } from 'ox'
import { describe, expect, test } from 'vitest'
import { Errors } from '../../contracts/generated.js'
import { anvilMainnet } from '../../test/anvil.js'
import { seaportContractConfig } from '../../test/constants/abis.js'
import { Errors } from '../../../contracts/generated.js'
import { anvilMainnet } from '../../../test/anvil.js'
import { seaportContractConfig } from '../../../test/constants/abis.js'

describe('decode', () => {
test('behavior: no args', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { describe, test } from 'vitest'
import {
seaportContractConfig,
wagmiContractConfig,
} from '../../test/constants/abis.js'
} from '../../../test/constants/abis.js'

describe('decode', () => {
test('behavior: named', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Abi, AbiEvent, Hex } from 'ox'
import { describe, expect, test } from 'vitest'

import { anvilMainnet } from '../../test/anvil.js'
import { wagmiContractConfig } from '../../test/constants/abis.js'
import { address } from '../../test/constants/addresses.js'
import { anvilMainnet } from '../../../test/anvil.js'
import { wagmiContractConfig } from '../../../test/constants/abis.js'
import { address } from '../../../test/constants/addresses.js'

describe('assertArgs', () => {
test('default', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { attest } from '@ark/attest'
import { Abi, AbiFunction, AbiParameters } from 'ox'
import { describe, test } from 'vitest'
import { erc20Abi, wagmiContractConfig } from '../../test/constants/abis.js'
import { address } from '../../test/constants/addresses.js'
import { erc20Abi, wagmiContractConfig } from '../../../test/constants/abis.js'
import { address } from '../../../test/constants/addresses.js'

describe('decodeData', () => {
test('default', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Abi, AbiFunction, AbiParameters } from 'ox'
import { describe, expect, test } from 'vitest'

import { anvilMainnet } from '../../test/anvil.js'
import { erc20Abi, wagmiContractConfig } from '../../test/constants/abis.js'
import { address } from '../../test/constants/addresses.js'
import { anvilMainnet } from '../../../test/anvil.js'
import { erc20Abi, wagmiContractConfig } from '../../../test/constants/abis.js'
import { address } from '../../../test/constants/addresses.js'

describe('decodeData', () => {
test('default', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { attest } from '@ark/attest'
import { Abi, AbiFunction, AbiItem } from 'ox'
import { describe, test } from 'vitest'

import { wagmiContractConfig } from '../../test/constants/abis.js'
import { wagmiContractConfig } from '../../../test/constants/abis.js'

describe('fromAbi', () => {
test('default', () => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import { AbiItem } from 'ox'
import { bench, describe } from 'vitest'
import { Web3 } from 'web3'

import { seaportContractConfig } from '../../test/constants/abis.js'
import { address } from '../../test/constants/addresses.js'
import { seaportContractConfig } from '../../../test/constants/abis.js'
import { address } from '../../../test/constants/addresses.js'
import { decode, encode } from '../AbiParameters.js'

const fulfillAdvancedOrder = AbiItem.fromAbi(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { assertType, describe, expect, test } from 'vitest'
import {
multicall3Abi,
seaportContractConfig,
} from '../../test/constants/abis.js'
import { address } from '../../test/constants/addresses.js'
} from '../../../test/constants/abis.js'
import { address } from '../../../test/constants/addresses.js'

describe('static', () => {
test('blank', () => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { AbiItem, AbiParameters } from 'ox'
import { describe, expect, test } from 'vitest'

import { seaportContractConfig } from '../../test/constants/abis.js'
import { address } from '../../test/constants/addresses.js'
import { seaportContractConfig } from '../../../test/constants/abis.js'
import { address } from '../../../test/constants/addresses.js'
import { getArrayComponents } from '../internal/abiParameters.js'

describe('static', () => {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { AbiParameters } from 'ox'
import { describe, expect, test } from 'vitest'
import { address } from '../../test/constants/addresses.js'
import { address } from '../../../test/constants/addresses.js'

describe('encodePacked', () => {
test.each([
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit af7b6db

Please sign in to comment.