aftermath-ts-sdk 2.1.0 → 2.2.0-abort.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.
package/README.md CHANGED
@@ -24,21 +24,58 @@ const farms = afSdk.Farms();
24
24
  const dca = afSdk.Dca();
25
25
  ```
26
26
 
27
+ ## Cancellation and transport errors
28
+
29
+ `Aftermath.create(config, abortSignal)` accepts a caller-owned `AbortSignal`
30
+ for cancellation during address discovery. The same final positional
31
+ `abortSignal` is available on the SDK's pool, farm, price, coin metadata, and
32
+ decimal read methods. Signals are runtime inputs and are not serialized into
33
+ configuration or request bodies; supplying `addresses` or `api` keeps the
34
+ existing no-network initialization fast path.
35
+
36
+ Transport failures are exposed as `AftermathTransportError` with structured
37
+ `kind`, optional `status`, `retryAfterMs`, `code`, `cause`, and `abortSource`
38
+ fields. These fields are additive: existing error messages and names are
39
+ preserved, including the legacy HTTP format
40
+ `HTTP <status> <statusText>: <body>`. Caller cancellation uses
41
+ `kind: "abort"` and `abortSource: "caller"`; timeout facts use
42
+ `kind: "timeout"` and `abortSource: "timeout"`. Arbitrary response headers
43
+ are not exposed.
44
+
45
+ ```typescript
46
+ const controller = new AbortController();
47
+ const sdk = await Aftermath.create({ network: "MAINNET" }, controller.signal);
48
+
49
+ try {
50
+ await sdk.Pools().getAllPools(controller.signal);
51
+ } catch (error) {
52
+ if (isAftermathTransportError(error)) {
53
+ if (error.kind === "abort" && error.abortSource === "caller") {
54
+ return;
55
+ }
56
+ console.error(error.kind, error.status, error.retryAfterMs);
57
+ }
58
+ }
59
+ ```
60
+
27
61
  ## Advanced Usage (AftermathApi)
28
62
 
29
63
  For complex transaction construction, use AftermathApi for direct control:
30
64
 
31
65
  ```typescript
66
+ import { SuiGrpcClient } from "@mysten/sui/grpc";
67
+ import { SuiJsonRpcClient } from "@mysten/sui/jsonRpc";
68
+
32
69
  const afSdk = await Aftermath.create({ network: "MAINNET" });
33
70
  const addresses = await afSdk.getAddresses();
34
71
 
72
+ const fullnodeUrl = "https://fullnode.mainnet.sui.io";
73
+
35
74
  const afApi = new AftermathApi(
36
- new SuiClient({
37
- transport: new SuiHTTPTransport({
38
- url: "https://fullnode.mainnet.sui.io",
39
- }),
40
- }),
41
- addresses // Configuration addresses
75
+ new SuiGrpcClient({ network: "mainnet", baseUrl: fullnodeUrl }),
76
+ addresses, // Configuration addresses
77
+ // Still required by the few helpers that have no gRPC equivalent — see below
78
+ new SuiJsonRpcClient({ network: "mainnet", url: fullnodeUrl })
42
79
  );
43
80
 
44
81
  // Access protocol APIs
@@ -47,6 +84,29 @@ const stakingApi = afApi.Staking();
47
84
  const farmsApi = afApi.Farms();
48
85
  ```
49
86
 
87
+ `Aftermath.create`'s `fullnodeUrl` option takes a **gRPC base URL** (it is passed
88
+ to `SuiGrpcClient` as `baseUrl`, and to `SuiJsonRpcClient` as `url`). Sui
89
+ fullnodes serve both protocols from the same host, so a single URL is enough.
90
+
91
+ ### Remaining JSON-RPC surface
92
+
93
+ Sui JSON-RPC is deprecated and scheduled for removal from fullnodes in
94
+ mid-October 2026. Every fullnode call this SDK makes goes over gRPC **except**
95
+ the following, which cannot be expressed with `SuiGrpcClient` without changing
96
+ what they return:
97
+
98
+ | Helper | Why |
99
+ | --- | --- |
100
+ | `Events().fetchCastEventsWithCursor` | `suix_queryEvents` has no `SuiGrpcClient` equivalent; `ledgerService.ListEvents` has a different filter model and BCS-only payloads |
101
+ | `Transactions().fetchTransactionsWithCursor` | `suix_queryTransactionBlocks` has no gRPC equivalent at all |
102
+ | `Objects().fetchObject` / `fetchObjectGeneral` / `fetchObjectBatch` / `fetchOwnedObjects` | gRPC returns Move object contents as BCS bytes or as a differently-shaped `json` view, so the parsed `content.fields` these helpers' casters consume cannot be reproduced |
103
+ | `DynamicFields().fetchDynamicFieldObject` | same; gRPC returns the field value as BCS bytes |
104
+ | `Sui().fetchSystemState` (deprecated) | gRPC has no `SuiSystemStateSummary` equivalent |
105
+
106
+ Prefer the Aftermath API (`Aftermath.create(...)`'s high-level providers) for
107
+ events, transaction history and system state — those already avoid the fullnode
108
+ entirely.
109
+
50
110
  ## Available Protocols
51
111
 
52
112
  ### Pools (AMM)