@rainprotocolsdk/sdk 1.0.1 → 1.0.3

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.
package/README.md CHANGED
@@ -53,8 +53,8 @@ getPublicMarkets(params: GetMarketsParams): Promise<Market[]>;
53
53
  interface GetMarketsParams {
54
54
  limit: number;
55
55
  offset: number;
56
- sortBy?: "totalVolume" | "createdAt" | "liquidity";
57
- status?: "Live" | "Resolved" | "Closed";
56
+ sortBy?: "Liquidity" | "Volumn" | "latest";
57
+ status?: 'Live' | 'New' | 'WaitingForResult' | 'UnderDispute' | 'UnderAppeal' | 'ClosingSoon' | 'InReview' | 'InEvaluation' | 'Closed' | 'Trading';
58
58
  }
59
59
  ```
60
60
 
@@ -64,7 +64,7 @@ interface GetMarketsParams {
64
64
  const markets = await rain.getPublicMarkets({
65
65
  limit?: 12,
66
66
  offset?: 1,
67
- sortBy?: "totalVolume",
67
+ sortBy?: "Liquidity",
68
68
  status?: "Live",
69
69
  });
70
70
  ```
package/dist/Rain.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { GetMarketsParams, Market } from './markets/types';
2
- import { ApproveTxParams, EnterOptionTxParams, RawTransaction } from './tx/types';
1
+ import { GetMarketsParams, Market } from './markets/types.js';
2
+ import { ApproveTxParams, EnterOptionTxParams, RawTransaction } from './tx/types.js';
3
3
  export declare class Rain {
4
4
  getPublicMarkets(params: GetMarketsParams): Promise<Market[]>;
5
5
  buildApprovalTx(params: ApproveTxParams): RawTransaction | Error;
package/dist/Rain.js CHANGED
@@ -1,6 +1,6 @@
1
- import { getMarkets } from './markets/getMarkets';
2
- import { buildEnterOptionRawTx } from './tx/buildRawTransactions';
3
- import { buildApproveRawTx } from './tx/buildApprovalRawTx';
1
+ import { getMarkets } from './markets/getMarkets.js';
2
+ import { buildEnterOptionRawTx } from './tx/buildRawTransactions.js';
3
+ import { buildApproveRawTx } from './tx/buildApprovalRawTx.js';
4
4
  export class Rain {
5
5
  async getPublicMarkets(params) {
6
6
  return getMarkets(params);
package/dist/RainAA.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { RainConfig } from './types';
1
+ import { RainConfig } from './types.js';
2
2
  export declare class RainAA {
3
3
  private config;
4
4
  private _client;
@@ -0,0 +1 @@
1
+ export declare const API_BASE_URL = "https://dev-api.rain.one";
@@ -0,0 +1 @@
1
+ export const API_BASE_URL = "https://dev-api.rain.one";
package/dist/index.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- export { Rain } from './Rain';
2
- export { RainAA } from './RainAA';
3
- export * from './types';
1
+ export { Rain } from './Rain.js';
2
+ export { RainAA } from './RainAA.js';
3
+ export * from './types.js';
package/dist/index.js CHANGED
@@ -1,3 +1,3 @@
1
- export { Rain } from './Rain';
2
- export { RainAA } from './RainAA';
3
- export * from './types';
1
+ export { Rain } from './Rain.js';
2
+ export { RainAA } from './RainAA.js';
3
+ export * from './types.js';
@@ -0,0 +1,17 @@
1
+ export declare const MARKET_STATUS: {
2
+ readonly New: "New";
3
+ readonly Live: "Live";
4
+ readonly WaitingForResult: "Waiting_for_Result";
5
+ readonly UnderDispute: "Under_Dispute";
6
+ readonly UnderAppeal: "Under_Appeal";
7
+ readonly Closed: "Closed";
8
+ readonly ClosingSoon: "Closing_Soon";
9
+ readonly InReview: "Dispute_Window_Open";
10
+ readonly InEvaluation: "Appeal_Window_Open";
11
+ readonly Trading: "Pending_Finalization";
12
+ };
13
+ export declare const MARKET_SORT_BY: {
14
+ Liquidity: string;
15
+ Volumn: string;
16
+ latest: string;
17
+ };
@@ -0,0 +1,17 @@
1
+ export const MARKET_STATUS = {
2
+ New: "New",
3
+ Live: "Live",
4
+ WaitingForResult: 'Waiting_for_Result',
5
+ UnderDispute: "Under_Dispute",
6
+ UnderAppeal: "Under_Appeal",
7
+ Closed: "Closed",
8
+ ClosingSoon: "Closing_Soon",
9
+ InReview: "Dispute_Window_Open",
10
+ InEvaluation: "Appeal_Window_Open",
11
+ Trading: "Pending_Finalization"
12
+ };
13
+ export const MARKET_SORT_BY = {
14
+ Liquidity: "totalLiquidity",
15
+ Volumn: "totalVolumn",
16
+ latest: "age"
17
+ };
@@ -1,2 +1,2 @@
1
- import { GetMarketsParams, Market } from './types';
1
+ import { GetMarketsParams, Market } from './types.js';
2
2
  export declare function getMarkets(params: GetMarketsParams): Promise<Market[]>;
@@ -1,15 +1,16 @@
1
+ import { API_BASE_URL } from '../config/api.js';
2
+ import { MARKET_SORT_BY, MARKET_STATUS } from './constants.js';
1
3
  export async function getMarkets(params) {
2
4
  const query = new URLSearchParams();
3
- const apiBaseUrl = 'https://dev-api.rain.one'; // Dev API base URL
4
5
  if (params?.limit)
5
6
  query.append('limit', params.limit.toString());
6
7
  if (params?.offset)
7
8
  query.append('offset', params.offset.toString());
8
9
  if (params?.sortBy)
9
- query.append('sortBy', params.sortBy);
10
+ query.append('sortBy', MARKET_SORT_BY[params.sortBy]);
10
11
  if (params?.status)
11
- query.append('status', params.status);
12
- const res = await fetch(`${apiBaseUrl}/pools/public-pools?${query.toString()}`);
12
+ query.append('status', MARKET_STATUS[params.status]);
13
+ const res = await fetch(`${API_BASE_URL}/pools/public-pools?${query.toString()}`);
13
14
  if (!res.ok) {
14
15
  throw new Error(`Failed to fetch markets: ${res.status}`);
15
16
  }
@@ -1,5 +1,5 @@
1
- export type MarketStatus = 'Live' | 'New' | 'Closing Soon' | 'Closed' | 'pending finalization';
2
- export type MarketSortBy = 'totalVolume' | 'createdAt' | 'endTime';
1
+ export type MarketStatus = 'Live' | 'New' | 'WaitingForResult' | 'UnderDispute' | 'UnderAppeal' | 'ClosingSoon' | 'InReview' | 'InEvaluation' | 'Closed' | 'Trading';
2
+ export type MarketSortBy = 'Liquidity' | 'Volumn' | 'latest';
3
3
  export interface GetMarketsParams {
4
4
  limit?: number;
5
5
  offset?: number;
@@ -1,2 +1,2 @@
1
- import { ApproveTxParams, RawTransaction } from "./types";
1
+ import { ApproveTxParams, RawTransaction } from "./types.js";
2
2
  export declare function buildApproveRawTx(params: ApproveTxParams): RawTransaction | Error;
@@ -1,5 +1,5 @@
1
1
  import { encodeFunctionData } from "viem";
2
- import { ERC20Abi } from "../abi/ERC20Abi";
2
+ import { ERC20Abi } from "../abi/ERC20Abi.js";
3
3
  import { ethers } from "ethers";
4
4
  const DEFAULT_APPROVE_AMOUNT = ethers.MaxUint256;
5
5
  export function buildApproveRawTx(params) {
@@ -1,2 +1,2 @@
1
- import { EnterOptionTxParams, RawTransaction } from './types';
1
+ import { EnterOptionTxParams, RawTransaction } from './types.js';
2
2
  export declare function buildEnterOptionRawTx(params: EnterOptionTxParams): RawTransaction;
@@ -1,5 +1,5 @@
1
1
  import { encodeFunctionData } from 'viem';
2
- import { TradePoolAbi } from '../abi/TradeMarketsAbi';
2
+ import { TradePoolAbi } from '../abi/TradeMarketsAbi.js';
3
3
  export function buildEnterOptionRawTx(params) {
4
4
  const { marketContractAddress, selectedOption, buyAmountInWei } = params;
5
5
  if (!marketContractAddress)
package/package.json CHANGED
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "name": "@rainprotocolsdk/sdk",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
+ "type": "module",
4
5
  "description": "Rain SDK",
5
6
  "main": "dist/index.js",
6
7
  "types": "dist/index.d.ts",
@@ -35,4 +36,4 @@
35
36
  "devDependencies": {
36
37
  "typescript": "^5.9.3"
37
38
  }
38
- }
39
+ }