rain-sdk-v2 2.5.1 → 2.5.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/CHANGELOG.md CHANGED
@@ -9,6 +9,20 @@ APIs slated for removal are marked `@deprecated` in the type declarations for at
9
9
  least one minor release before they are removed, with the replacement named in
10
10
  the deprecation notice. Breaking removals land only in a major version.
11
11
 
12
+ ## Security
13
+
14
+ Versions `< 2.5.0` are **deprecated on npm** — they build sell transactions with no
15
+ slippage protection by default (fixed in 2.5.0). See the Security notice in the
16
+ README and the 2.5.0 entry below. Upgrade to `>= 2.5.0`.
17
+
18
+ ## [2.5.2] - Remove ngrok dev header
19
+
20
+ ### Removed
21
+ - Dropped the `ngrok-skip-browser-warning` header handling from all request paths
22
+ (`buildHeaders`, dispute upload, login, IPFS metadata upload). It was a dev-tunnel
23
+ convenience gated behind `apiUrl.includes('ngrok')` and never fired against real
24
+ environments. No behavior change for non-ngrok usage.
25
+
12
26
  ## [2.5.1] - Add LICENSE
13
27
 
14
28
  ### Added
package/README.md CHANGED
@@ -2,6 +2,23 @@
2
2
 
3
3
  TypeScript SDK for the Rain prediction markets protocol on Arbitrum One. Provides transaction builders for market creation, trading, liquidity management, order book operations, dispute resolution, and smart account (Account Abstraction) support.
4
4
 
5
+ ## ⚠️ Security notice — upgrade to >= 2.5.0
6
+
7
+ Versions **below 2.5.0** build **sell** transactions with no slippage protection by
8
+ default: `buildSellOptionTx` defaulted `minAmountOut` to `0` and the documented
9
+ `slippageTolerance` option was ignored, exposing sells to MEV/sandwich loss.
10
+ **Fixed in 2.5.0** — sells now quote `getSellProceeds` on-chain and apply
11
+ `slippageTolerance` (default 5%). Versions `<2.5.0` are deprecated on npm.
12
+
13
+ Migration is one line: **`buildSellOptionTx` is now async** — add `await`.
14
+
15
+ ```typescript
16
+ // before (< 2.5.0)
17
+ const tx = rain.buildSellOptionTx({ /* ... */ });
18
+ // after (>= 2.5.0)
19
+ const tx = await rain.buildSellOptionTx({ /* ... */ });
20
+ ```
21
+
5
22
  ## Installation
6
23
 
7
24
  ```bash
@@ -15,9 +15,6 @@ export async function createDisputeMessage(params, config) {
15
15
  if (config.accessToken) {
16
16
  headers['Authorization'] = `Bearer ${config.accessToken}`;
17
17
  }
18
- if (config.apiUrl?.includes('ngrok')) {
19
- headers['ngrok-skip-browser-warning'] = 'true';
20
- }
21
18
  // Do not set Content-Type for FormData; the browser sets the boundary automatically.
22
19
  const res = await fetch(`${config.apiUrl}/dispute/create-dispute-message`, {
23
20
  method: 'POST',
@@ -1,8 +1,5 @@
1
1
  export function buildHeaders(config, contentType) {
2
2
  const headers = {};
3
- if (config.apiUrl?.includes('ngrok')) {
4
- headers['ngrok-skip-browser-warning'] = 'true';
5
- }
6
3
  if (contentType) {
7
4
  headers['Content-Type'] = contentType;
8
5
  }
@@ -21,7 +21,6 @@ export async function loginUser(params) {
21
21
  method: 'POST',
22
22
  headers: {
23
23
  'Content-Type': 'application/json',
24
- ...(apiUrl.includes('ngrok') ? { 'ngrok-skip-browser-warning': 'true' } : {}),
25
24
  },
26
25
  body: JSON.stringify({
27
26
  sign: signature,
@@ -28,7 +28,7 @@ export const ENV_CONFIG = {
28
28
  oracle_fixed_fee_per_option: 1000000000000000000n, // $1 in 18 decimals
29
29
  },
30
30
  usdr: {
31
- address: "0x2b67d5367175d8C0Ce3c755004565a60F1D08D4D",
31
+ address: "0x9cD5Dd558d5C0eac93D7f1C9d994916f9Bfbc50a",
32
32
  symbol: "USDR",
33
33
  decimals: 18,
34
34
  oracle_fixed_fee_per_option: 1000000000000000000n, // $1 in 18 decimals
@@ -53,7 +53,7 @@ export const ENV_CONFIG = {
53
53
  oracle_fixed_fee_per_option: 1000000000000000000n,
54
54
  },
55
55
  usdr: {
56
- address: "0xC1aeb1D39008337E127698c10f6338E93E5f3369",
56
+ address: "0xD3Ffde8ca474E15f207463cb223daae2719D70c8",
57
57
  symbol: "USDR",
58
58
  decimals: 18,
59
59
  oracle_fixed_fee_per_option: 1000000000000000000n,
@@ -29,7 +29,6 @@ export async function uploadMetaData(params) {
29
29
  method: "POST",
30
30
  headers: {
31
31
  "Content-Type": "application/json",
32
- ...(apiUrl?.includes('ngrok') ? { "ngrok-skip-browser-warning": "true" } : {}),
33
32
  },
34
33
  body: JSON.stringify(metadata),
35
34
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rain-sdk-v2",
3
- "version": "2.5.1",
3
+ "version": "2.5.3",
4
4
  "type": "module",
5
5
  "description": "Rain SDK V2 — TypeScript SDK for Rain prediction markets on Arbitrum. Market creation, trading, liquidity, order book, split/merge, dispute, and smart account support.",
6
6
  "main": "dist/index.js",
@@ -22,7 +22,8 @@
22
22
  "test": "vitest run",
23
23
  "test:watch": "vitest",
24
24
  "test:integration": "RUN_INTEGRATION=1 vitest run test/integration.test.ts",
25
- "prepublishOnly": "npm run build"
25
+ "test:coverage": "vitest run --coverage",
26
+ "prepublishOnly": "npm run build && npm test"
26
27
  },
27
28
  "repository": {
28
29
  "type": "git",
@@ -63,6 +64,7 @@
63
64
  "socket.io-client": "^4.8.3"
64
65
  },
65
66
  "devDependencies": {
67
+ "@vitest/coverage-v8": "^5.0.1",
66
68
  "typescript": "^5.9.3",
67
69
  "viem": "^2.48.8",
68
70
  "vitest": "^5.0.1"