Skip to content

Commit 4bd6065

Browse files
committed
chore: publish prep
1 parent 42d8abf commit 4bd6065

File tree

6 files changed

+1187
-2
lines changed

6 files changed

+1187
-2
lines changed

LICENSE

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

sdk/.eslintrc.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"parserOptions": {
1616
"ecmaVersion": 2020,
1717
"sourceType": "module",
18-
"project": "./sdk/tsconfig.eslint.json"
18+
"project": "./tsconfig.eslint.json"
1919
},
2020
"rules": {
2121
"no-console": "off",

sdk/API.md

Lines changed: 292 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,292 @@
1+
# Rainbow Token Launcher SDK - API Reference
2+
3+
This document provides detailed API documentation for the Rainbow Token Launcher SDK.
4+
5+
## Core Object
6+
7+
### TokenLauncher
8+
9+
The main entry point to the SDK is the `TokenLauncher` singleton object, which provides access to all SDK functionality.
10+
11+
```typescript
12+
import { TokenLauncher } from '@rainbow-me/token-launcher';
13+
```
14+
15+
## Configuration
16+
17+
### TokenLauncher.configure(config)
18+
19+
Configures the SDK with the necessary API endpoints, keys, and other settings.
20+
21+
**Parameters:**
22+
23+
```typescript
24+
interface SDKConfig {
25+
// API URLs
26+
API_URL_DEV?: string;
27+
API_URL_PROD?: string;
28+
29+
// API keys
30+
API_KEY_DEV?: string;
31+
API_KEY_PROD?: string;
32+
33+
// Supported networks
34+
SUPPORTED_NETWORKS?: SupportedNetwork[];
35+
36+
// Mode
37+
MODE?: 'jest' | 'development' | 'production';
38+
}
39+
40+
interface SupportedNetwork {
41+
chainId: number;
42+
contractAddress: string;
43+
}
44+
```
45+
46+
**Example:**
47+
48+
```typescript
49+
TokenLauncher.configure({
50+
API_URL_PROD: 'https://api.example.com',
51+
API_KEY_PROD: 'your-api-key',
52+
MODE: 'production',
53+
SUPPORTED_NETWORKS: [
54+
{
55+
chainId: 1, // Ethereum Mainnet
56+
contractAddress: '0x1234567890123456789012345678901234567890'
57+
},
58+
{
59+
chainId: 137, // Polygon Mainnet
60+
contractAddress: '0x0987654321098765432109876543210987654321'
61+
}
62+
]
63+
});
64+
```
65+
66+
### TokenLauncher.getConfig()
67+
68+
Returns the current SDK configuration.
69+
70+
**Returns:** `SDKConfig` - The current configuration object
71+
72+
**Example:**
73+
74+
```typescript
75+
const config = TokenLauncher.getConfig();
76+
console.log('Current API URL:', config.MODE === 'production' ? config.API_URL_PROD : config.API_URL_DEV);
77+
```
78+
79+
## Token Launch Methods
80+
81+
### TokenLauncher.launchToken(params)
82+
83+
Launches a new Rainbow Super Token.
84+
85+
**Parameters:**
86+
87+
```typescript
88+
interface LaunchTokenParams {
89+
name: string; // Token name
90+
symbol: string; // Token symbol
91+
supply: string; // Total supply (in wei format)
92+
wallet: Wallet; // Ethers.js Wallet instance
93+
initialTick?: number; // Initial tick (price setting)
94+
creator?: string; // Creator address (defaults to wallet address)
95+
transactionOptions?: { // Optional gas parameters
96+
gasLimit?: string;
97+
gasPrice?: string; // For legacy transactions
98+
maxFeePerGas?: string; // For EIP-1559 transactions
99+
maxPriorityFeePerGas?: string; // For EIP-1559 transactions
100+
};
101+
logoUrl: string; // URL to token logo image
102+
description?: string; // Token description
103+
links?: Record<string, string>; // Social/website links
104+
airdropMetadata?: AirdropMetadata; // Optional airdrop information
105+
}
106+
```
107+
108+
**Returns:** `Promise<LaunchTokenResponse>` - A promise that resolves to the token launch response
109+
110+
```typescript
111+
interface LaunchTokenResponse {
112+
transaction: TransactionResponse; // Ethers.js TransactionResponse
113+
tokenUri: string; // Token URI
114+
tokenAddress: string; // Deployed token contract address
115+
}
116+
```
117+
118+
**Example:**
119+
120+
```typescript
121+
const result = await TokenLauncher.launchToken({
122+
name: 'My Token',
123+
symbol: 'MTK',
124+
supply: '1000000000000000000000000', // 1 million tokens (with 18 decimals)
125+
wallet: wallet,
126+
initialTick: 0,
127+
logoUrl: 'https://example.com/logo.png',
128+
description: 'My awesome community token',
129+
links: {
130+
twitter: 'https://twitter.com/mytoken',
131+
website: 'https://mytoken.com'
132+
}
133+
});
134+
```
135+
136+
### TokenLauncher.launchTokenAndBuy(params)
137+
138+
Launches a new Rainbow Super Token and buys some tokens in a single transaction.
139+
140+
**Parameters:**
141+
142+
```typescript
143+
interface LaunchTokenAndBuyParams extends LaunchTokenParams {
144+
amountIn: string; // Required: Amount of ETH to use for purchase (in wei format)
145+
}
146+
```
147+
148+
**Returns:** `Promise<LaunchTokenResponse>` - Same as launchToken method
149+
150+
**Example:**
151+
152+
```typescript
153+
const result = await TokenLauncher.launchTokenAndBuy({
154+
name: 'My Token',
155+
symbol: 'MTK',
156+
supply: '1000000000000000000000000',
157+
wallet: wallet,
158+
initialTick: 0,
159+
logoUrl: 'https://example.com/logo.png',
160+
amountIn: '100000000000000000', // 0.1 ETH
161+
transactionOptions: {
162+
gasLimit: '3000000',
163+
gasPrice: '30000000000' // 30 gwei - for legacy networks
164+
}
165+
});
166+
```
167+
168+
### TokenLauncher.getInitialTick(tokenPrice)
169+
170+
Calculates the initial tick value based on the desired token price.
171+
172+
**Parameters:**
173+
- `tokenPrice`: `BigNumber` - The desired token price in ETH (as a BigNumber)
174+
175+
**Returns:** `number` - The calculated tick value
176+
177+
**Example:**
178+
179+
```typescript
180+
import { parseEther } from 'ethers/lib/utils';
181+
182+
// For a token price of 0.0001 ETH
183+
const tokenPrice = parseEther('0.0001');
184+
const tick = TokenLauncher.getInitialTick(tokenPrice);
185+
```
186+
187+
## Token Information Methods
188+
189+
### TokenLauncher.getRainbowSuperTokens()
190+
191+
Gets a list of all Rainbow Super Tokens.
192+
193+
**Returns:** `Promise<GetRainbowSuperTokensResponse>` - A promise that resolves to the list of tokens
194+
195+
**Example:**
196+
197+
```typescript
198+
const tokens = await TokenLauncher.getRainbowSuperTokens();
199+
console.log('Total tokens:', tokens.data.length);
200+
```
201+
202+
### TokenLauncher.getRainbowSuperTokenByUri(uri)
203+
204+
Gets information about a specific Rainbow Super Token by its URI.
205+
206+
**Parameters:**
207+
- `uri`: `string` - The token URI
208+
209+
**Returns:** `Promise<GetRainbowSuperTokenResponse>` - A promise that resolves to the token information
210+
211+
**Example:**
212+
213+
```typescript
214+
const tokenInfo = await TokenLauncher.getRainbowSuperTokenByUri('https://example.com/token/123');
215+
console.log('Token name:', tokenInfo.data.name);
216+
```
217+
218+
### TokenLauncher.getAirdropSuggestions(address)
219+
220+
Gets airdrop suggestions for a specific address.
221+
222+
**Parameters:**
223+
- `address`: `string` - The address to get suggestions for
224+
225+
**Returns:** `Promise<GetAirdropSuggestionsResponse>` - A promise that resolves to the airdrop suggestions
226+
227+
**Example:**
228+
229+
```typescript
230+
const suggestions = await TokenLauncher.getAirdropSuggestions('0x1234567890123456789012345678901234567890');
231+
232+
// Access predefined cohorts
233+
console.log('Predefined cohorts:', suggestions.predefinedCohorts);
234+
235+
// Access personalized cohorts
236+
console.log('Personalized cohorts:', suggestions.personalizedCohorts);
237+
```
238+
239+
## Error Handling
240+
241+
The SDK provides typed error codes for better error handling. All errors thrown by the SDK will be instances of `TokenLauncherSDKError`.
242+
243+
```typescript
244+
class TokenLauncherSDKError extends Error {
245+
readonly code: TokenLauncherErrorCode;
246+
readonly context: {
247+
operation: string;
248+
params?: any;
249+
source: 'api' | 'chain' | 'sdk';
250+
chainId?: number;
251+
transactionHash?: string;
252+
originalError?: any;
253+
};
254+
}
255+
```
256+
257+
### Error Codes (TokenLauncherErrorCode)
258+
259+
The following error codes are available:
260+
261+
- `API_REQUEST_FAILED`: Failed to make API request
262+
- `API_RESPONSE_INVALID`: Received invalid API response
263+
- `SUBMISSION_DETAILS_MISSING`: Missing submission details
264+
- `TRANSACTION_FAILED`: Transaction failed
265+
- `CONTRACT_INTERACTION_FAILED`: Failed to interact with contract
266+
- `INSUFFICIENT_FUNDS`: Insufficient funds for transaction
267+
- `GAS_ESTIMATION_FAILED`: Failed to estimate gas
268+
- `INVALID_SALT`: Invalid salt for token deployment
269+
- `INVALID_PARAMS`: Invalid parameters
270+
- `MISSING_REQUIRED_PARAM`: Missing required parameter
271+
- `WALLET_CONNECTION_ERROR`: Wallet connection error
272+
- `UNKNOWN_ERROR`: Unknown error
273+
274+
**Example usage:**
275+
276+
```typescript
277+
import { TokenLauncher, TokenLauncherErrorCode } from '@rainbow-me/token-launcher';
278+
279+
try {
280+
const result = await TokenLauncher.launchToken(params);
281+
} catch (error) {
282+
if (error.code === TokenLauncherErrorCode.INSUFFICIENT_FUNDS) {
283+
console.error('Insufficient funds for transaction. Please add more funds to your wallet.');
284+
} else if (error.code === TokenLauncherErrorCode.CONTRACT_INTERACTION_FAILED) {
285+
console.error('Failed to interact with contract:', error.message);
286+
console.log('Operation that failed:', error.context.operation);
287+
console.log('Source of error:', error.context.source);
288+
} else {
289+
console.error('Unknown error:', error);
290+
}
291+
}
292+
```

sdk/CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Changelog
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7+
8+
## [0.1.0] - 2023-03-20
9+
10+
### Added
11+
- Initial release of the Rainbow Token Launcher SDK
12+
- Core functionality for launching Rainbow Super Tokens
13+
- Support for token launching and buying in a single transaction
14+
- API methods for retrieving token information
15+
- Comprehensive error handling with typed error codes
16+
- TypeScript typings for all SDK functionality

0 commit comments

Comments
 (0)