@bigmaxwatermelon/sdk 0.4.0 → 0.4.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/README.md +91 -24
- package/dist/cli.js +25 -8
- package/dist/cli.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +24 -8
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @bigmaxwatermelon/sdk
|
|
2
2
|
|
|
3
3
|
> TypeScript SDK for the Isometry DeFi protocol — Ethereum Sepolia.
|
|
4
4
|
|
|
5
|
-
**npm:** `@
|
|
5
|
+
**npm:** `@bigmaxwatermelon/sdk`
|
|
6
6
|
**version:** `0.4.0`
|
|
7
7
|
**network:** Ethereum Sepolia (chain ID 11155111)
|
|
8
8
|
**registry:** npm
|
|
@@ -12,17 +12,84 @@
|
|
|
12
12
|
## Installation
|
|
13
13
|
|
|
14
14
|
```bash
|
|
15
|
-
npm
|
|
15
|
+
# npm (recommended)
|
|
16
|
+
npm install @bigmaxwatermelon/sdk
|
|
17
|
+
|
|
18
|
+
# 国内镜像未同步时,使用 tarball 直装
|
|
19
|
+
npm install https://registry.npmjs.org/@bigmaxwatermelon/sdk/-/sdk-0.4.0.tgz
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
**Requires:**
|
|
23
|
+
- Node.js ≥ 18
|
|
24
|
+
- ESM only (`type: module` in your project)
|
|
25
|
+
|
|
26
|
+
> ⚠️ This package is ESM-only. Use `import`, not `require`. If you use TypeScript, set `"module": "NodeNext"` or `"moduleResolution": "Bundler"`.
|
|
27
|
+
|
|
28
|
+
---
|
|
29
|
+
|
|
30
|
+
## Quick Start — SDK
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { createClient } from '@bigmaxwatermelon/sdk'
|
|
34
|
+
|
|
35
|
+
const client = createClient({
|
|
36
|
+
rpcUrl: process.env.SEPOLIA_RPC_URL ?? 'https://ethereum-sepolia.publicnode.com',
|
|
37
|
+
graphUrl: 'https://console.isometry.network/graph/subgraphs/name/isometry',
|
|
38
|
+
addresses: {
|
|
39
|
+
platform: '0x062B11C5Ed0F2b1f9B7dFaa7B95737dD221863F7',
|
|
40
|
+
factory: '0x73D6BC64f4f54F9dF05851216F70F42135d56864',
|
|
41
|
+
},
|
|
42
|
+
})
|
|
43
|
+
|
|
44
|
+
// Read platform info
|
|
45
|
+
const info = await client.rpc.platform.getPlatformInfo()
|
|
46
|
+
console.log(info)
|
|
16
47
|
```
|
|
17
48
|
|
|
18
|
-
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Quick Start — CLI
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
# Check version / connectivity
|
|
55
|
+
npx @bigmaxwatermelon/sdk isometry system version
|
|
56
|
+
|
|
57
|
+
# Read data
|
|
58
|
+
npx @bigmaxwatermelon/sdk isometry platform info --json
|
|
59
|
+
npx @bigmaxwatermelon/sdk isometry token info <token-address> --json
|
|
60
|
+
|
|
61
|
+
# Simulate a write (dry-run, no signer needed)
|
|
62
|
+
npx @bigmaxwatermelon/sdk isometry token mint <token> <to> <amount> --simulate --json
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
> 💡 All CLI commands support `--json` for machine-readable output.
|
|
66
|
+
|
|
67
|
+
---
|
|
68
|
+
|
|
69
|
+
## Write Operations
|
|
70
|
+
|
|
71
|
+
Write operations (mint, burn, pause, etc.) require a signer.
|
|
72
|
+
|
|
73
|
+
**Environment variable:**
|
|
74
|
+
```bash
|
|
75
|
+
export ISOMETRY_PRIVATE_KEY=0x_your_private_key_here
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
**Always simulate before executing:**
|
|
79
|
+
```bash
|
|
80
|
+
isometry token mint <token> <to> <amount> --simulate --json
|
|
81
|
+
# → Confirms the transaction looks correct, then:
|
|
82
|
+
isometry token mint <token> <to> <amount> --json
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
---
|
|
19
86
|
|
|
20
87
|
---
|
|
21
88
|
|
|
22
89
|
## Quick Start
|
|
23
90
|
|
|
24
91
|
```typescript
|
|
25
|
-
import { createClient } from '@
|
|
92
|
+
import { createClient } from '@bigmaxwatermelon/sdk'
|
|
26
93
|
|
|
27
94
|
const client = createClient({
|
|
28
95
|
rpcUrl: process.env.SEPOLIA_RPC_URL,
|
|
@@ -42,7 +109,7 @@ console.log(info)
|
|
|
42
109
|
### Initialize Client
|
|
43
110
|
|
|
44
111
|
```typescript
|
|
45
|
-
import { createClient } from '@
|
|
112
|
+
import { createClient } from '@bigmaxwatermelon/sdk'
|
|
46
113
|
|
|
47
114
|
const client = createClient({
|
|
48
115
|
// Required for RPC calls
|
|
@@ -105,7 +172,7 @@ const platformStats = await client.graph.analytics.platformStats()
|
|
|
105
172
|
### Write — Simulate Before Execute
|
|
106
173
|
|
|
107
174
|
```typescript
|
|
108
|
-
import { WriteExecutor } from '@
|
|
175
|
+
import { WriteExecutor } from '@bigmaxwatermelon/sdk'
|
|
109
176
|
|
|
110
177
|
// Create client with private key for signing
|
|
111
178
|
const writeClient = createClient({
|
|
@@ -153,14 +220,14 @@ The CLI is included in the same package.
|
|
|
153
220
|
### Install globally
|
|
154
221
|
|
|
155
222
|
```bash
|
|
156
|
-
npm install -g @
|
|
223
|
+
npm install -g @bigmaxwatermelon/sdk
|
|
157
224
|
isometry --version
|
|
158
225
|
```
|
|
159
226
|
|
|
160
227
|
### Or run via npx
|
|
161
228
|
|
|
162
229
|
```bash
|
|
163
|
-
npx @
|
|
230
|
+
npx @bigmaxwatermelon/sdk token info 0xd0473e07c68797f387fbe6c23981f7997d3ed5e3
|
|
164
231
|
```
|
|
165
232
|
|
|
166
233
|
### Or link locally
|
|
@@ -216,32 +283,32 @@ Full API reference at [docs/API.md](docs/API.md).
|
|
|
216
283
|
|
|
217
284
|
```typescript
|
|
218
285
|
// Client
|
|
219
|
-
import { createClient } from '@
|
|
220
|
-
import type { IsometryClient, IsometryConfig } from '@
|
|
286
|
+
import { createClient } from '@bigmaxwatermelon/sdk'
|
|
287
|
+
import type { IsometryClient, IsometryConfig } from '@bigmaxwatermelon/sdk'
|
|
221
288
|
|
|
222
289
|
// Wallet
|
|
223
|
-
import { createWallet, ReadOnlyWallet, PrivateKeyWallet } from '@
|
|
224
|
-
import type { IWallet, WalletMode } from '@
|
|
290
|
+
import { createWallet, ReadOnlyWallet, PrivateKeyWallet } from '@bigmaxwatermelon/sdk'
|
|
291
|
+
import type { IWallet, WalletMode } from '@bigmaxwatermelon/sdk'
|
|
225
292
|
|
|
226
293
|
// Write executor
|
|
227
|
-
import { WriteExecutor, makeWriteMeta } from '@
|
|
228
|
-
import type { WriteResult, SimulateResult, ExecuteResult, WriteError, WriteOpts, WriteMeta, TxReceipt } from '@
|
|
294
|
+
import { WriteExecutor, makeWriteMeta } from '@bigmaxwatermelon/sdk'
|
|
295
|
+
import type { WriteResult, SimulateResult, ExecuteResult, WriteError, WriteOpts, WriteMeta, TxReceipt } from '@bigmaxwatermelon/sdk'
|
|
229
296
|
|
|
230
297
|
// Error decoding
|
|
231
|
-
import { decodeError, ERROR_SELECTOR_MAP } from '@
|
|
232
|
-
import type { DecodedError } from '@
|
|
298
|
+
import { decodeError, ERROR_SELECTOR_MAP } from '@bigmaxwatermelon/sdk'
|
|
299
|
+
import type { DecodedError } from '@bigmaxwatermelon/sdk'
|
|
233
300
|
|
|
234
301
|
// Graph
|
|
235
|
-
import { createGraphClient, GraphClient, GraphError } from '@
|
|
236
|
-
import type { IsometryGraphConfig } from '@
|
|
237
|
-
import { TokenHistoryService, PlatformHistoryService, AnalyticsService } from '@
|
|
302
|
+
import { createGraphClient, GraphClient, GraphError } from '@bigmaxwatermelon/sdk'
|
|
303
|
+
import type { IsometryGraphConfig } from '@bigmaxwatermelon/sdk'
|
|
304
|
+
import { TokenHistoryService, PlatformHistoryService, AnalyticsService } from '@bigmaxwatermelon/sdk'
|
|
238
305
|
|
|
239
306
|
// Contract helpers
|
|
240
|
-
import { getContracts, getStableCoin } from '@
|
|
241
|
-
import type { ContractAddresses } from '@
|
|
307
|
+
import { getContracts, getStableCoin } from '@bigmaxwatermelon/sdk'
|
|
308
|
+
import type { ContractAddresses } from '@bigmaxwatermelon/sdk'
|
|
242
309
|
|
|
243
310
|
// Types
|
|
244
|
-
import type { PlatformInfo, PlatformRoles, TokenInfo, TokenStats, TokenRoles } from '@
|
|
311
|
+
import type { PlatformInfo, PlatformRoles, TokenInfo, TokenStats, TokenRoles } from '@bigmaxwatermelon/sdk'
|
|
245
312
|
```
|
|
246
313
|
|
|
247
314
|
---
|
|
@@ -304,7 +371,7 @@ All write operations return a typed `WriteResult`:
|
|
|
304
371
|
## Architecture
|
|
305
372
|
|
|
306
373
|
```
|
|
307
|
-
@
|
|
374
|
+
@bigmaxwatermelon/sdk
|
|
308
375
|
├── dist/index.js # SDK entry
|
|
309
376
|
├── dist/cli.js # CLI entry (bin: isometry)
|
|
310
377
|
└── docs/
|
package/dist/cli.js
CHANGED
|
@@ -4026,6 +4026,7 @@ function formatWriteResult(result, opts, meta) {
|
|
|
4026
4026
|
} else {
|
|
4027
4027
|
const r2 = result;
|
|
4028
4028
|
Object.assign(out, { code: r2.code, message: r2.message });
|
|
4029
|
+
if (r2.selector) Object.assign(out, { selector: r2.selector });
|
|
4029
4030
|
}
|
|
4030
4031
|
if (meta) Object.assign(out, { meta });
|
|
4031
4032
|
return JSON.stringify(
|
|
@@ -4093,7 +4094,8 @@ var init_writeExecutor = __esm({
|
|
|
4093
4094
|
ok: false,
|
|
4094
4095
|
code: "SIMULATION_FAILED",
|
|
4095
4096
|
message: `[simulate] ${decoded.message}`,
|
|
4096
|
-
details: err
|
|
4097
|
+
details: err,
|
|
4098
|
+
...decoded.selector ? { selector: decoded.selector } : {}
|
|
4097
4099
|
};
|
|
4098
4100
|
}
|
|
4099
4101
|
}
|
|
@@ -4148,23 +4150,38 @@ var init_writeExecutor = __esm({
|
|
|
4148
4150
|
ok: false,
|
|
4149
4151
|
code: decoded.code,
|
|
4150
4152
|
message: decoded.message,
|
|
4151
|
-
details: err
|
|
4153
|
+
details: err,
|
|
4154
|
+
...decoded.selector ? { selector: decoded.selector } : {}
|
|
4152
4155
|
};
|
|
4153
4156
|
}
|
|
4154
4157
|
}
|
|
4158
|
+
/**
|
|
4159
|
+
* Parse a revert error and extract { code, message, selector }.
|
|
4160
|
+
* selector is always included for unknown errors so users can report it.
|
|
4161
|
+
*/
|
|
4155
4162
|
parseRevertError(err) {
|
|
4163
|
+
let rawSelector;
|
|
4164
|
+
if (err && typeof err === "object") {
|
|
4165
|
+
const errObj = err;
|
|
4166
|
+
const data = errObj.data;
|
|
4167
|
+
if (data && data !== "0x" && data.length >= 10) {
|
|
4168
|
+
rawSelector = data.slice(0, 10).toLowerCase();
|
|
4169
|
+
}
|
|
4170
|
+
}
|
|
4156
4171
|
if (err && typeof err === "object") {
|
|
4157
4172
|
const decoded = decodeError(err);
|
|
4158
|
-
if (decoded)
|
|
4173
|
+
if (decoded) {
|
|
4174
|
+
return { code: decoded.code, message: decoded.message, selector: rawSelector };
|
|
4175
|
+
}
|
|
4159
4176
|
}
|
|
4160
4177
|
if (!(err instanceof Error)) {
|
|
4161
|
-
return { code: "UNKNOWN", message: String(err) };
|
|
4178
|
+
return { code: "UNKNOWN", message: String(err), selector: rawSelector };
|
|
4162
4179
|
}
|
|
4163
4180
|
const msg = err.message;
|
|
4164
|
-
if (msg.includes("insufficient funds")) return { code: "INSUFFICIENT_BALANCE", message: "insufficient funds for gas" };
|
|
4165
|
-
if (msg.includes("nonce")) return { code: "RPC_ERROR", message: "nonce error (tx may already be mined)" };
|
|
4166
|
-
if (msg.includes("read-only")) return { code: "NO_SIGNER", message: "wallet is read-only" };
|
|
4167
|
-
return { code: "REVERT", message: msg.slice(0, 200) };
|
|
4181
|
+
if (msg.includes("insufficient funds")) return { code: "INSUFFICIENT_BALANCE", message: "insufficient funds for gas", selector: rawSelector };
|
|
4182
|
+
if (msg.includes("nonce")) return { code: "RPC_ERROR", message: "nonce error (tx may already be mined)", selector: rawSelector };
|
|
4183
|
+
if (msg.includes("read-only")) return { code: "NO_SIGNER", message: "wallet is read-only", selector: rawSelector };
|
|
4184
|
+
return { code: "REVERT", message: msg.slice(0, 200), selector: rawSelector };
|
|
4168
4185
|
}
|
|
4169
4186
|
};
|
|
4170
4187
|
}
|