@rainprotocolsdk/sdk 1.0.0 → 1.0.1

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/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export { Rain } from './Rain';
2
+ export { RainAA } from './RainAA';
2
3
  export * from './types';
package/dist/index.js CHANGED
@@ -1,2 +1,3 @@
1
1
  export { Rain } from './Rain';
2
+ export { RainAA } from './RainAA';
2
3
  export * from './types';
@@ -1,13 +1,13 @@
1
1
  export async function getMarkets(params) {
2
2
  const query = new URLSearchParams();
3
3
  const apiBaseUrl = 'https://dev-api.rain.one'; // Dev API base URL
4
- if (params.limit)
4
+ if (params?.limit)
5
5
  query.append('limit', params.limit.toString());
6
- if (params.offset)
6
+ if (params?.offset)
7
7
  query.append('offset', params.offset.toString());
8
- if (params.sortBy)
8
+ if (params?.sortBy)
9
9
  query.append('sortBy', params.sortBy);
10
- if (params.status)
10
+ if (params?.status)
11
11
  query.append('status', params.status);
12
12
  const res = await fetch(`${apiBaseUrl}/pools/public-pools?${query.toString()}`);
13
13
  if (!res.ok) {
@@ -1,4 +1,4 @@
1
- export type MarketStatus = 'Live' | 'Closed' | 'Resolved';
1
+ export type MarketStatus = 'Live' | 'New' | 'Closing Soon' | 'Closed' | 'pending finalization';
2
2
  export type MarketSortBy = 'totalVolume' | 'createdAt' | 'endTime';
3
3
  export interface GetMarketsParams {
4
4
  limit?: number;
@@ -0,0 +1,2 @@
1
+ import { ApproveTxParams, RawTransaction } from "./types";
2
+ export declare function buildApproveRawTx(params: ApproveTxParams): RawTransaction | Error;
@@ -0,0 +1,20 @@
1
+ import { encodeFunctionData } from "viem";
2
+ import { ERC20Abi } from "../abi/ERC20Abi";
3
+ import { ethers } from "ethers";
4
+ const DEFAULT_APPROVE_AMOUNT = ethers.MaxUint256;
5
+ export function buildApproveRawTx(params) {
6
+ const { tokenAddress, spender, amount = DEFAULT_APPROVE_AMOUNT, } = params;
7
+ if (!params.tokenAddress)
8
+ throw new Error("token address is required");
9
+ if (!params.spender)
10
+ throw new Error("spender address is required");
11
+ return {
12
+ to: tokenAddress,
13
+ data: encodeFunctionData({
14
+ abi: ERC20Abi,
15
+ functionName: "approve",
16
+ args: [spender, amount],
17
+ }),
18
+ value: 0n,
19
+ };
20
+ }
@@ -6,4 +6,10 @@ export interface EnterOptionTxParams {
6
6
  export interface RawTransaction {
7
7
  to: `0x${string}`;
8
8
  data: `0x${string}`;
9
+ value?: bigint;
9
10
  }
11
+ export type ApproveTxParams = {
12
+ tokenAddress: `0x${string}`;
13
+ spender: `0x${string}`;
14
+ amount?: bigint;
15
+ };
package/dist/types.d.ts CHANGED
@@ -2,8 +2,8 @@ import { WalletClient } from 'viem';
2
2
  import { Chain } from 'viem/chains';
3
3
  export interface RainConfig {
4
4
  walletClient: WalletClient;
5
- alchemyApiKey: string;
6
- paymasterPolicyId: string;
5
+ alchemyApiKey?: string;
6
+ paymasterPolicyId?: string;
7
7
  chain: Chain;
8
8
  rpcUrl?: string;
9
9
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rainprotocolsdk/sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Rain SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -29,7 +29,8 @@
29
29
  "@account-kit/infra": "^4.48.0",
30
30
  "@account-kit/wallet-client": "^0.1.0-alpha.10",
31
31
  "@alchemy/aa-alchemy": "^3.0.0",
32
- "@alchemy/aa-core": "^3.0.0"
32
+ "@alchemy/aa-core": "^3.0.0",
33
+ "ethers": "^6.16.0"
33
34
  },
34
35
  "devDependencies": {
35
36
  "typescript": "^5.9.3"