@onrank/sdk 0.1.0 → 0.1.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/client.js +7 -2
- package/dist/decode.js +9 -1
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -15,8 +15,13 @@ export function toncenterStackToTuple(stack) {
|
|
|
15
15
|
return { type: kind === "cell" ? "cell" : "slice", cell: Cell.fromBase64(value.bytes) };
|
|
16
16
|
if (kind === "null")
|
|
17
17
|
return { type: "null" };
|
|
18
|
-
if (kind === "list" || kind === "tuple")
|
|
19
|
-
|
|
18
|
+
if (kind === "list" || kind === "tuple") {
|
|
19
|
+
const elements = (value?.elements ?? []);
|
|
20
|
+
// toncenter v2 renders TVM `null` (e.g. an unset `address?` such as a curve's `pool`) as an empty list
|
|
21
|
+
if (elements.length === 0)
|
|
22
|
+
return { type: "null" };
|
|
23
|
+
return { type: "tuple", items: toncenterStackToTuple(elements) };
|
|
24
|
+
}
|
|
20
25
|
throw new Error(`unknown stack item ${kind}`);
|
|
21
26
|
});
|
|
22
27
|
}
|
package/dist/decode.js
CHANGED
|
@@ -4,10 +4,18 @@ import { Address, TupleReader } from "@ton/core";
|
|
|
4
4
|
import { Topic } from "./constants.js";
|
|
5
5
|
function optAddress(r) {
|
|
6
6
|
const item = r.peek();
|
|
7
|
-
|
|
7
|
+
// `null`, or an empty tuple (how some RPCs render TVM null), or an addr_none slice: no address
|
|
8
|
+
if (item.type === "null" || (item.type === "tuple" && item.items.length === 0)) {
|
|
8
9
|
r.pop();
|
|
9
10
|
return null;
|
|
10
11
|
}
|
|
12
|
+
if (item.type === "slice" || item.type === "cell") {
|
|
13
|
+
const s = item.cell.beginParse();
|
|
14
|
+
if (s.remainingBits < 267) {
|
|
15
|
+
r.pop();
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
11
19
|
return r.readAddress().toString();
|
|
12
20
|
}
|
|
13
21
|
/** `get_curve_data` → the six fields the quotes need (roles / params cells are left on the stack). */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@onrank/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "ONRANK (TON launchpad) integration SDK: on-chain quotes and unsigned TON Connect messages for buying and selling coins on the curve and the pool. No keys, no network required.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|