@rainprotocolsdk/sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,2 @@
1
+ export { Rain } from './Rain';
2
+ export * from './types';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { Rain } from './Rain';
2
+ export * from './types';
@@ -0,0 +1,2 @@
1
+ import { GetMarketsParams, Market } from './types';
2
+ export declare function getMarkets(params: GetMarketsParams): Promise<Market[]>;
@@ -0,0 +1,18 @@
1
+ export async function getMarkets(params) {
2
+ const query = new URLSearchParams();
3
+ const apiBaseUrl = 'https://dev-api.rain.one'; // Dev API base URL
4
+ if (params.limit)
5
+ query.append('limit', params.limit.toString());
6
+ if (params.offset)
7
+ query.append('offset', params.offset.toString());
8
+ if (params.sortBy)
9
+ query.append('sortBy', params.sortBy);
10
+ if (params.status)
11
+ query.append('status', params.status);
12
+ const res = await fetch(`${apiBaseUrl}/pools/public-pools?${query.toString()}`);
13
+ if (!res.ok) {
14
+ throw new Error(`Failed to fetch markets: ${res.status}`);
15
+ }
16
+ const data = await res.json();
17
+ return data;
18
+ }
@@ -0,0 +1,14 @@
1
+ export type MarketStatus = 'Live' | 'Closed' | 'Resolved';
2
+ export type MarketSortBy = 'totalVolume' | 'createdAt' | 'endTime';
3
+ export interface GetMarketsParams {
4
+ limit?: number;
5
+ offset?: number;
6
+ sortBy?: MarketSortBy;
7
+ status?: MarketStatus;
8
+ }
9
+ export interface Market {
10
+ id: string;
11
+ title: string;
12
+ totalVolume: string;
13
+ status: MarketStatus;
14
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import { EnterOptionTxParams, RawTransaction } from './types';
2
+ export declare function buildEnterOptionRawTx(params: EnterOptionTxParams): RawTransaction;
@@ -0,0 +1,19 @@
1
+ import { encodeFunctionData } from 'viem';
2
+ import { TradePoolAbi } from '../abi/TradeMarketsAbi';
3
+ export function buildEnterOptionRawTx(params) {
4
+ const { marketContractAddress, selectedOption, buyAmountInWei } = params;
5
+ if (!marketContractAddress)
6
+ throw new Error('Market contract address is required');
7
+ if (selectedOption === undefined)
8
+ throw new Error('Selected Option is required');
9
+ if (!buyAmountInWei)
10
+ throw new Error('Buy amount is required');
11
+ return {
12
+ to: marketContractAddress,
13
+ data: encodeFunctionData({
14
+ abi: TradePoolAbi,
15
+ functionName: 'enterOption',
16
+ args: [selectedOption, buyAmountInWei],
17
+ }),
18
+ };
19
+ }
@@ -0,0 +1,9 @@
1
+ export interface EnterOptionTxParams {
2
+ marketContractAddress: `0x${string}`;
3
+ selectedOption: bigint;
4
+ buyAmountInWei: bigint;
5
+ }
6
+ export interface RawTransaction {
7
+ to: `0x${string}`;
8
+ data: `0x${string}`;
9
+ }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { WalletClient } from 'viem';
2
+ import { Chain } from 'viem/chains';
3
+ export interface RainConfig {
4
+ walletClient: WalletClient;
5
+ alchemyApiKey: string;
6
+ paymasterPolicyId: string;
7
+ chain: Chain;
8
+ rpcUrl?: string;
9
+ }
package/dist/types.js ADDED
@@ -0,0 +1 @@
1
+ export {};
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@rainprotocolsdk/sdk",
3
+ "version": "1.0.0",
4
+ "description": "Rain SDK",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "dev": "tsc -w",
13
+ "prepublishOnly": "npm run build"
14
+ },
15
+ "keywords": [
16
+ "web3",
17
+ "account-abstraction",
18
+ "smart-account",
19
+ "rain",
20
+ "viem",
21
+ "alchemy"
22
+ ],
23
+ "author": "Rain Protocol",
24
+ "license": "MIT",
25
+ "peerDependencies": {
26
+ "viem": "^2.0.0"
27
+ },
28
+ "dependencies": {
29
+ "@account-kit/infra": "^4.48.0",
30
+ "@account-kit/wallet-client": "^0.1.0-alpha.10",
31
+ "@alchemy/aa-alchemy": "^3.0.0",
32
+ "@alchemy/aa-core": "^3.0.0"
33
+ },
34
+ "devDependencies": {
35
+ "typescript": "^5.9.3"
36
+ }
37
+ }