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

Task/improve makefile #23

Open
wants to merge 3 commits into
base: main
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 .env.template
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
NPM_TOKEN=
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
.DS_Store
.env
25 changes: 21 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
TS_DIR := typescript
GO_DIR := golang

# Load environment variables from .env file
-include .env
export

# Default target
all: build test

# Build all projects
build: build-ts build-go
build: clean build-ts build-go

# Build TypeScript project
build-ts:
Expand All @@ -26,7 +30,7 @@ test: test-ts test-go
# Test TypeScript project
test-ts:
@echo "Testing TypeScript project..."
cd $(TS_DIR) && npm test
cd $(TS_DIR) && pnpm test

# Test Go project
test-go:
Expand All @@ -39,11 +43,24 @@ clean: clean-ts clean-go
# Clean TypeScript project
clean-ts:
@echo "Cleaning TypeScript project..."
cd $(TS_DIR) && npm run clean
cd $(TS_DIR) && pnpm run clean

# Clean Go project
clean-go:
@echo "Cleaning Go project..."
cd $(GO_DIR) && go clean

.PHONY: all build build-ts build-go test test-ts test-go clean clean-ts clean-go
# Publish TypeScript package
publish-ts: clean-ts build-ts
@echo "Publishing TypeScript package..."
@if [ ! -f .env ]; then \
echo "Error: .env file not found"; \
exit 1; \
fi
@if [ -z "$(NPM_TOKEN)" ]; then \
echo "Error: NPM_TOKEN not found in .env file"; \
exit 1; \
fi
cd $(TS_DIR) && pnpm publish --access public --no-git-checks --//registry.npmjs.org/:_authToken=$(NPM_TOKEN)

.PHONY: all build build-ts build-go test test-ts test-go clean clean-ts clean-go publish-ts
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,15 @@ The configuration data is stored in a JSON file and includes details like contra

## Supported Chains

### Mainnets
- **Polygon Mainnet** (Chain ID: `137`)
- **Arbitrum Mainnet** (Chain ID: `42161`)
- **Base Mainnet** (Chain ID: `8453`)

- **Ethereum Sepolia** (Chain ID: `11155111`)
### Testnets
- **Base Sepolia** (Chain ID: `84532`)
- **Polygon Amoy** (Chain ID: `80002`)

- **Ethereum Sepolia** (Chain ID: `11155111`)

## Development
To contribute or make changes to the configurations:
Expand Down
246 changes: 150 additions & 96 deletions typescript/README.md
Original file line number Diff line number Diff line change
@@ -1,152 +1,206 @@
# @fastlane-labs/atlas-config
# Atlas Config - TypeScript

A configuration package for Atlas Protocol, providing essential chain configuration data for EVM networks. This package is designed to be used in conjunction with the [atlas-sdk](https://www.npmjs.com/package/@fastlane-labs/atlas-sdk) and contains all relevant smart contract addresses for the Atlas protocol.
TypeScript package that provides chain configurations for Atlas Protocol smart contracts. This package is part of the Atlas Protocol suite and is designed to work seamlessly with the Atlas SDK.

## Installation

Install the package using npm:

```bash
npm install @fastlane-labs/atlas-config
```

```bash
# or
pnpm add @fastlane-labs/atlas-config
# or
yarn add @fastlane-labs/atlas-config
```

## Usage

Import and use the configuration data in your TypeScript or JavaScript project
### Basic Usage

```typescript
import { chainConfig, getChainConfig, getAllChainConfigs, getSupportedChainIds, mergeChainConfigs } from '@fastlane-labs/atlas-config';
import { getChainConfig } from '@fastlane-labs/atlas-config';

// Get config for a specific chain
const sepoliaConfig = getChainConfig(11155111); // Sepolia testnet
console.log(sepoliaConfig.contracts.atlas); // Atlas contract address
console.log(sepoliaConfig.eip712Domain); // EIP-712 domain config
```

### Access the entire chain configuration
### Getting Supported Chain IDs

```typescript
console.log(chainConfig);
import { getSupportedChainIds } from '@fastlane-labs/atlas-config';

const chainIds = getSupportedChainIds();
console.log("Supported chain IDs:", chainIds); // [137, 11155111, ...]
```

### Get configuration for a specific chain (e.g., Polygon mainnet)
### Getting All Chain Configs

```typescript
const polygonConfig = getChainConfig(137);
console.log(polygonConfig);
import { getAllChainConfigs } from '@fastlane-labs/atlas-config';

const allConfigs = getAllChainConfigs();
console.log("All chain configs:", allConfigs.map(config => ({
chainId: config.chainId,
name: config.config.eip712Domain.name
})));
```

### Attempting to get configuration for an unknown chain will throw an error
### Merging Custom Configurations

You can merge your own configurations with the default ones. This is useful for testing or using custom contract deployments.

```typescript
import { mergeChainConfigs } from '@fastlane-labs/atlas-config';

// Example: Updating a single contract address
const partialUpdate = {
'11155111': { // Sepolia
'1.0': {
contracts: {
atlas: { address: '0x1234567890123456789012345678901234567890' }
}
}
}
};

// Example: Adding a new chain with complete configuration
const newChainConfig = {
'999999': {
'1.0': {
contracts: {
atlas: { address: '0x0987654321098765432109876543210987654321' },
atlasVerification: { address: '0x0987654321098765432109876543210987654321' },
sorter: { address: '0x0987654321098765432109876543210987654321' },
simulator: { address: '0x0987654321098765432109876543210987654321' },
multicall3: { address: '0x0987654321098765432109876543210987654321' }
},
eip712Domain: {
name: 'New Test Chain',
version: '1.0',
chainId: 999999,
verifyingContract: '0x1111111111111111111111111111111111111111'
}
}
}
};

// Merge configurations
try {
const unknownConfig = getChainConfig(999999);
const mergedConfigs = mergeChainConfigs({
...partialUpdate,
...newChainConfig
});
console.log("Updated Sepolia config:", mergedConfigs['11155111']);
console.log("New chain config:", mergedConfigs['999999']);
} catch (error) {
console.error(error); // "Chain configuration not found for chainId: 999999"
console.error("Error merging configs:", error);
}
```

### Get all chain configurations
### Integration with Atlas SDK

The package is designed to work seamlessly with the Atlas SDK:

```typescript
const allConfigs = getAllChainConfigs();
console.log(allConfigs);
import { getChainConfig } from '@fastlane-labs/atlas-config';
import { OperationBuilder } from '@fastlane-labs/atlas-sdk';

// Example: Creating a solver operation
OperationBuilder.newSolverOperation({
from: "0x...",
to: "0x...",
value: BigInt(0),
gas: BigInt(0),
maxFeePerGas: BigInt(0),
deadline: BigInt(0),
solver: "0x...",
control: "0x...",
userOpHash: "0x...",
bidToken: "0x...",
bidAmount: BigInt(10000000000000000), // 0.01 ETH
data: "0x...",
signature: "0x..."
});
```

### Get supported chain IDs
## Configuration Types

### Contract Configuration
```typescript
const supportedChainIds = getSupportedChainIds();
console.log(supportedChainIds);
type ContractConfig = {
atlas: string;
atlasVerification: string;
sorter: string;
simulator: string;
multicall3: string;
};
```

### Merge provided chain configurations with existing ones

### EIP-712 Domain Configuration
```typescript
const additionalConfig = {
137: {
contracts: {
atlas: { address: '0x1234567890123456789012345678901234567890' }
}
},
999999: {
contracts: {
atlas: { address: '0x0987654321098765432109876543210987654321' },
atlasVerification: { address: '0x0987654321098765432109876543210987654321' },
sorter: { address: '0x0987654321098765432109876543210987654321' },
simulator: { address: '0x0987654321098765432109876543210987654321' },
multicall3: { address: '0x0987654321098765432109876543210987654321' }
},
eip712Domain: {
name: 'New Chain',
version: '1',
chainId: 999999,
verifyingContract: '0x1111111111111111111111111111111111111111'
}
}
type EIP712Domain = {
name: string;
version: string;
chainId: number;
verifyingContract: string;
};

const mergedConfigs = mergeChainConfigs(additionalConfig);
console.log(mergedConfigs);
```

````
### Version Configuration
```typescript
type VersionConfig = {
contracts: ContractConfig;
eip712Domain: EIP712Domain;
};
```

## Configuration Structure
## Error Handling

The `ChainConfig` interface describes the structure of the configuration for each supported chain:
The package includes proper error handling for common scenarios:

```typescript
interface ChainConfig {
contracts: {
atlas: object;
atlasVerification: object;
sorter: object;
simulator: object;
multicall3: object;
};
eip712Domain: {
name: string;
version: string;
chainId: number;
verifyingContract: string;
};
// Invalid chain ID
try {
const config = getChainConfig(999999);
} catch (error) {
console.error("Chain not supported:", error);
}
````

## Supported Chains

This package includes configurations for various Ethereum networks. Use the `getChainConfig` function with the appropriate chain ID to retrieve the configuration for a specific network.

### Mainnets

- Polygon (Chain ID: 137)
- Base (Chain ID: 8453)
- Arbitrum (Chain ID: 42161)

### Testnets

- Ethereum Sepolia (Chain ID: 11155111)
- Polygon Amoy (Chain ID: 80002)

Each chain configuration includes contract addresses and EIP-712 domain information specific to that network. Use the appropriate chain ID when calling `getChainConfig()` to retrieve the configuration for your desired network.
// Invalid version
try {
const config = getChainConfig(11155111, '9.9');
} catch (error) {
console.error("Version not found:", error);
}

## Integration with atlas-sdk
// Incomplete configuration when merging
try {
const incompleteConfig = {
'888888': {
'1.0': {
contracts: {
atlas: { address: '0x1234567890123456789012345678901234567890' }
}
}
}
};
mergeChainConfigs(incompleteConfig);
} catch (error) {
console.error("Expected error:", error);
}
```

This configuration package is designed to work seamlessly with the [Atlas Typescript SDK](https://www.npmjs.com/package/@fastlane-labs/atlas-sdk). It provides all the necessary smart contract addresses and network-specific information required for interacting with the Atlas protocol.
## Development

## Contributing
To contribute to this package:

If you'd like to contribute to this project, please submit a pull request or open an issue on our GitHub repository.
1. Clone the repository
2. Install dependencies: `pnpm install`
3. Run tests: `pnpm test`
4. Build: `pnpm build`

## License

This project is licensed under the [MIT License](LICENSE).

## Support

For questions, issues, or feature requests, please open an issue on our GitHub repository or contact our support team at [[email protected]](mailto\:[email protected]).

## Disclaimer

This package is part of the Atlas protocol ecosystem. Make sure to use it in conjunction with other Atlas-related packages and follow best practices for blockchain development and security.
MIT License - see the [LICENSE](../LICENSE) file for details.

2 changes: 1 addition & 1 deletion typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@fastlane-labs/atlas-config",
"version": "1.3.0",
"version": "1.3.1",
"description": "A configuration package for Atlas Protocol",
"main": "dist/index.js",
"types": "dist/index.d.ts",
Expand Down
Loading