Skip to content

Commit

Permalink
feat: distribute as pure esm package
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandermendes committed Nov 12, 2024
1 parent 63a97a4 commit 8487d97
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 37 deletions.
10 changes: 4 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,16 @@
"description": "Contains logic for staking and unstaking Aurora",
"author": "Alex Mendes",
"license": "UNLICENSED",
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"types": "dist/esm/index.d.ts",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"type": "module",
"scripts": {
"lint": "eslint . --ext .js,.ts",
"test": "jest",
"typecheck": "tsc --noEmit",
"clean": "rimraf dist",
"prebuild": "yarn clean",
"build:cjs": "tsc --module commonjs --outDir dist/cjs",
"build:esm": "tsc --module esnext --outDir dist/esm",
"build": "yarn build:cjs && yarn build:esm"
"build": "tsc"
},
"engines": {
"node": ">=20.9.0"
Expand Down
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ethers } from 'ethers';
import { AuroraNetwork, AuroraNetworkConfig } from './types/network';
import { type AuroraNetwork, AuroraNetworkConfig } from './types/network.js';

export const config: Record<AuroraNetwork, AuroraNetworkConfig> = {
testnet: {
Expand Down
4 changes: 2 additions & 2 deletions src/context.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { BigNumber } from 'ethers';
import { createContext } from 'react';
import { Withdrawal } from './types/withdrawal';
import { Stream } from './types/stream';
import { type Withdrawal } from './types/withdrawal.js';
import { Stream } from './types/stream.js';

export type StakingContextType = {
accountSynced: boolean;
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/useStaking.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useContext } from 'react';
import { StakingContext } from '../context';
import { StakingContext } from '../context.js';

export const useStaking = () => {
const ctx = useContext(StakingContext);
Expand Down
12 changes: 6 additions & 6 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { useStaking } from './hooks/useStaking';
export { StakingProvider } from './provider';
export { type StakingContextType } from './context';
export { stakingAbi } from './abis/staking';
export { config as stakingConfig } from './config';
export { hasShares } from './utils/shares';
export { useStaking } from './hooks/useStaking.js';
export { StakingProvider } from './provider.js';
export { type StakingContextType } from './context.js';
export { stakingAbi } from './abis/staking.js';
export { config as stakingConfig } from './config.js';
export { hasShares } from './utils/shares.js';
20 changes: 10 additions & 10 deletions src/provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ import {
unstakeAll,
withdraw,
withdrawAll,
} from './utils/staking';
import { sleep } from './utils/sleep';
import { useWeb3Provider } from './hooks/useWeb3Provider';
import { Stream } from './types/stream';
import { Withdrawal } from './types/withdrawal';
import { StakingContext } from './context';
import { erc20abi } from './abis/erc20';
import { AuroraNetwork } from './types/network';
import { config } from './config';
import { logger } from './logger';
} from './utils/staking.js';
import { sleep } from './utils/sleep.js';
import { useWeb3Provider } from './hooks/useWeb3Provider.js';
import { Stream } from './types/stream.js';
import { Withdrawal } from './types/withdrawal.js';
import { StakingContext } from './context.js';
import { erc20abi } from './abis/erc20.js';
import { AuroraNetwork } from './types/network.js';
import { config } from './config.js';
import { logger } from './logger.js';

type StakingProviderProps = {
network: AuroraNetwork;
Expand Down
2 changes: 1 addition & 1 deletion src/types/network.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Stream, VoteStream } from './stream';
import { type Stream, VoteStream } from './stream.js';

export type AuroraNetwork = 'testnet' | 'mainnet';

Expand Down
6 changes: 3 additions & 3 deletions src/utils/shares.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { providers } from 'ethers';
import { AuroraNetwork } from '../types/network';
import { config } from '../config';
import { getUserShares } from './staking';
import { type AuroraNetwork } from '../types/network.js';
import { config } from '../config.js';
import { getUserShares } from './staking.js';

/**
* Confirm that a user's account has shares.
Expand Down
8 changes: 4 additions & 4 deletions src/utils/staking.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { BigNumber, ethers, providers } from 'ethers';
import { stakingAbi } from '../abis/staking';
import { erc20abi } from '../abis/erc20';
import { AuroraNetworkConfig } from '../types/network';
import { logger } from '../logger';
import { stakingAbi } from '../abis/staking.js';
import { erc20abi } from '../abis/erc20.js';
import { type AuroraNetworkConfig } from '../types/network.js';
import { logger } from '../logger.js';

export const getDeposit = async (
account: string,
Expand Down
6 changes: 3 additions & 3 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
"compilerOptions": {
"baseUrl": ".",
"outDir": "./dist",
"target": "es2020",
"module": "ESNext",
"target": "ESNext",
"module": "NodeNext",
"lib": ["dom", "dom.iterable", "es2020"],
"declaration": true,
"strict": true,
"jsx": "react-jsx",
"moduleResolution": "node",
"moduleResolution": "NodeNext",
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
Expand Down

0 comments on commit 8487d97

Please sign in to comment.