Skip to content

Fix ES module build #36

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
"author": "@1inch",
"license": "MIT",
"private": false,
"type": "module",
"exports": {
".": {
"types": "./dist/types/src/index.d.ts",
Expand Down
12 changes: 6 additions & 6 deletions src/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import {ApiConfig, LimitOrderApiItem, SortKey, StatusKey} from './types'
import {DEV_PORTAL_LIMIT_ORDER_BASE_URL} from './constants'
import {Headers, HttpProviderConnector} from './connector'
import {Pager} from './pager'
import {LimitOrder} from '../limit-order'
import {Address} from '../address'
import {ApiConfig, LimitOrderApiItem, SortKey, StatusKey} from './types.js'
import {DEV_PORTAL_LIMIT_ORDER_BASE_URL} from './constants.js'
import {Headers, HttpProviderConnector} from './connector/index.js'
import {Pager} from './pager.js'
import {LimitOrder} from '../limit-order/index.js'
import {Address} from '../address.js'

export class Api {
private readonly baseUrl: string
Expand Down
2 changes: 1 addition & 1 deletion src/api/connector/http/axios-provider.connector.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import axios from 'axios'
import {AxiosProviderConnector} from './axios-provider.connector'
import {AxiosProviderConnector} from './axios-provider.connector.js'

describe('Axios Http provider connector', () => {
let httpConnector: AxiosProviderConnector
Expand Down
4 changes: 2 additions & 2 deletions src/api/connector/http/axios-provider.connector.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios, {isAxiosError} from 'axios'
import {Headers, HttpProviderConnector} from './http-provider.connector'
import {AuthError} from '../../errors'
import {Headers, HttpProviderConnector} from './http-provider.connector.js'
import {AuthError} from '../../errors.js'

export class AxiosProviderConnector implements HttpProviderConnector {
async get<T>(url: string, headers: Headers): Promise<T> {
Expand Down
4 changes: 2 additions & 2 deletions src/api/connector/http/fetch-provider.connector.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Headers, HttpProviderConnector} from './http-provider.connector'
import {AuthError} from '../../errors'
import {Headers, HttpProviderConnector} from './http-provider.connector.js'
import {AuthError} from '../../errors.js'

export class FetchProviderConnector implements HttpProviderConnector {
async get<T>(url: string, headers: Headers): Promise<T> {
Expand Down
4 changes: 2 additions & 2 deletions src/api/connector/http/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export * from './http-provider.connector'
export * from './fetch-provider.connector'
export * from './http-provider.connector.js'
export * from './fetch-provider.connector.js'
2 changes: 1 addition & 1 deletion src/api/connector/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './http'
export * from './http/index.js'
10 changes: 5 additions & 5 deletions src/api/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export * from './api'
export * from './errors'
export * from './pager'
export * from './types'
export * from './connector/http/http-provider.connector'
export * from './api.js'
export * from './errors.js'
export * from './pager.js'
export * from './types.js'
export * from './connector/http/http-provider.connector.js'
2 changes: 1 addition & 1 deletion src/api/pager.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import assert from 'assert'
import {isInt} from '../validations'
import {isInt} from '../validations.js'

export class Pager {
public readonly limit: number
Expand Down
4 changes: 2 additions & 2 deletions src/api/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {HttpProviderConnector} from './connector'
import {LimitOrderV4Struct} from '../limit-order'
import {HttpProviderConnector} from './connector/index.js'
import {LimitOrderV4Struct} from '../limit-order/index.js'

export type ApiConfig = {
authKey: string
Expand Down
2 changes: 1 addition & 1 deletion src/axios-ext.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './api/connector/http/axios-provider.connector'
export * from './api/connector/http/axios-provider.connector.js'
14 changes: 7 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export * from './limit-order-contract'
export * from './limit-order'
export * from './rfq-order'
export * from './address'
export * from './constants'
export * from './utils/rand-bigint'
export * from './api'
export * from './limit-order-contract/index.js'
export * from './limit-order/index.js'
export * from './rfq-order/index.js'
export * from './address.js'
export * from './constants.js'
export * from './utils/rand-bigint.js'
export * from './api/index.js'
2 changes: 1 addition & 1 deletion src/limit-order-contract/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './limit-order-contract'
export * from './limit-order-contract.js'
8 changes: 5 additions & 3 deletions src/limit-order-contract/limit-order-contract.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import {Interface, Signature} from 'ethers'
import assert from 'assert'
import {LimitOrderV4Struct, TakerTraits} from '../limit-order'
import LOP_V4_ABI from '../abi/AggregationRouterV6.abi.json'
import {ZX} from '../constants'
import {LimitOrderV4Struct, TakerTraits} from '../limit-order/index.js'
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
import LOP_V4_ABI from '../abi/AggregationRouterV6.abi.json' assert {type: 'json'}
import {ZX} from '../constants.js'

const lopContract = new Interface(LOP_V4_ABI)

Expand Down
6 changes: 3 additions & 3 deletions src/limit-order/eip712/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export * from './domain'
export * from './eip712.types'
export * from './order-typed-data-builder'
export * from './domain.js'
export * from './eip712.types.js'
export * from './order-typed-data-builder.js'
8 changes: 4 additions & 4 deletions src/limit-order/eip712/order-typed-data-builder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import {
LimitOrderV4TypeDataName,
LimitOrderV4TypeDataVersion,
Order
} from './domain'
import {EIP712DomainType, EIP712TypedData} from './eip712.types'
import {LimitOrderV4Struct} from '../types'
import {getLimitOrderContract} from '../../constants'
} from './domain.js'
import {EIP712DomainType, EIP712TypedData} from './eip712.types.js'
import {LimitOrderV4Struct} from '../types.js'
import {getLimitOrderContract} from '../../constants.js'

export function getOrderHash(data: EIP712TypedData): string {
return ethers.TypedDataEncoder.hash(
Expand Down
10 changes: 5 additions & 5 deletions src/limit-order/extension-builder.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import {isHexString, trim0x} from '@1inch/byte-utils'
import assert from 'assert'
import {Extension} from './extension'
import {IExtensionBuilder} from './types'
import {Interaction} from './interaction'
import {Address} from '../address'
import {ZX} from '../constants'
import {Extension} from './extension.js'
import {IExtensionBuilder} from './types.js'
import {Interaction} from './interaction.js'
import {Address} from '../address.js'
import {ZX} from '../constants.js'

export class ExtensionBuilder implements IExtensionBuilder {
private makerAssetSuffix = ZX
Expand Down
2 changes: 1 addition & 1 deletion src/limit-order/extension.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {Extension} from './extension'
import {Extension} from './extension.js'

describe('Extension', () => {
it('should encode/decode', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/limit-order/extension.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {keccak256} from 'ethers'
import {BytesIter, isHexString, trim0x, UINT_32_MAX} from '@1inch/byte-utils'
import assert from 'assert'
import {ZX} from '../constants'
import {ZX} from '../constants.js'

export class Extension {
private static fields = [
Expand Down
18 changes: 9 additions & 9 deletions src/limit-order/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
export * from './eip712/index'
export * from './limit-order'
export * from './maker-traits'
export * from './taker-traits'
export * from './extension'
export * from './extension-builder'
export * from './interaction'
export * from './types'
export * from './amounts'
export * from './eip712/index.js'
export * from './limit-order.js'
export * from './maker-traits.js'
export * from './taker-traits.js'
export * from './extension.js'
export * from './extension-builder.js'
export * from './interaction.js'
export * from './types.js'
export * from './amounts.js'
4 changes: 2 additions & 2 deletions src/limit-order/interaction.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Interaction} from './interaction'
import {Address} from '../address'
import {Interaction} from './interaction.js'
import {Address} from '../address.js'

describe('Interaction', () => {
it('should encode/decode', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/limit-order/interaction.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {BytesIter, isHexBytes, trim0x} from '@1inch/byte-utils'
import assert from 'assert'
import {Address} from '../address'
import {Address} from '../address.js'

export class Interaction {
constructor(public readonly target: Address, public readonly data: string) {
Expand Down
8 changes: 4 additions & 4 deletions src/limit-order/limit-order.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {LimitOrder} from './limit-order'
import {ExtensionBuilder} from './extension-builder'
import {MakerTraits} from './maker-traits'
import {Address} from '../address'
import {LimitOrder} from './limit-order.js'
import {ExtensionBuilder} from './extension-builder.js'
import {MakerTraits} from './maker-traits.js'
import {Address} from '../address.js'

describe('Limit Order', () => {
jest.spyOn(Math, 'random').mockReturnValue(1)
Expand Down
12 changes: 6 additions & 6 deletions src/limit-order/limit-order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ import {
getLimitOrderV4Domain,
getOrderHash,
EIP712TypedData
} from './eip712'
import {LimitOrderV4Struct, OrderInfoData} from './types'
import {MakerTraits} from './maker-traits'
import {Extension} from './extension'
import {Address} from '../address'
import {randBigInt} from '../utils/rand-bigint'
} from './eip712/index.js'
import {LimitOrderV4Struct, OrderInfoData} from './types.js'
import {MakerTraits} from './maker-traits.js'
import {Extension} from './extension.js'
import {Address} from '../address.js'
import {randBigInt} from '../utils/rand-bigint.js'

export class LimitOrder {
private static readonly Web3Type = `tuple(${[
Expand Down
4 changes: 2 additions & 2 deletions src/limit-order/maker-traits.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {UINT_160_MAX, UINT_40_MAX} from '@1inch/byte-utils'
import {MakerTraits} from './maker-traits'
import {Address} from '../address'
import {MakerTraits} from './maker-traits.js'
import {Address} from '../address.js'

describe('MakerTraits', () => {
test('allowed sender', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/limit-order/maker-traits.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {add0x, BitMask, BN} from '@1inch/byte-utils'
import assert from 'assert'
import {Address} from '../address'
import {Address} from '../address.js'

/**
* The MakerTraits type is an uint256, and different parts of the number are used to encode different traits.
Expand Down
8 changes: 4 additions & 4 deletions src/limit-order/taker-traits.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import {BitMask, BN, getBytesCount, trim0x} from '@1inch/byte-utils'
import {Extension} from './extension'
import {Interaction} from './interaction'
import {Address} from '../address'
import {ZX} from '../constants'
import {Extension} from './extension.js'
import {Interaction} from './interaction.js'
import {Address} from '../address.js'
import {ZX} from '../constants.js'

export enum AmountMode {
/**
Expand Down
4 changes: 2 additions & 2 deletions src/limit-order/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Extension} from './extension'
import {Address} from '../address'
import {Extension} from './extension.js'
import {Address} from '../address.js'

export type OrderInfoData = {
makerAsset: Address
Expand Down
2 changes: 1 addition & 1 deletion src/rfq-order/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from './rfq-order'
export * from './rfq-order.js'
4 changes: 2 additions & 2 deletions src/rfq-order/rfq-order.spec.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {RfqOrder} from './rfq-order'
import {Address} from '../address'
import {RfqOrder} from './rfq-order.js'
import {Address} from '../address.js'

describe('RfqOrder', () => {
it('Should validate max nonce', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/rfq-order/rfq-order.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {LimitOrder, MakerTraits, OrderInfoData} from '../limit-order'
import {Address} from '../address'
import {LimitOrder, MakerTraits, OrderInfoData} from '../limit-order/index.js'
import {Address} from '../address.js'

/**
* Light, gas efficient version of LimitOrder
Expand Down
2 changes: 1 addition & 1 deletion src/utils/rand-bigint.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {randBigInt} from './rand-bigint'
import {randBigInt} from './rand-bigint.js'

describe('randBigint', () => {
it('should generate rand bigint in correct interval', () => {
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"compilerOptions": {
"target": "ES2021",
"lib": ["ES2021"],
"module": "ESNext",
"moduleResolution": "Node",
"module": "nodenext",
"moduleResolution": "nodenext",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
Expand Down