@suigar/sdk 2.0.0-beta.8 → 2.0.0-beta.9
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 +9 -0
- package/README.md +2 -2
- package/dist/{chunk-YGYMLRE4.js → chunk-FEQY5O43.js} +8 -16
- package/dist/{index-jwSXA8q3.d.cts → index-3P_LBbDM.d.cts} +4 -4
- package/dist/{index-jwSXA8q3.d.ts → index-3P_LBbDM.d.ts} +4 -4
- package/dist/index.cjs +26 -37
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +28 -39
- package/dist/utils.cjs +8 -16
- package/dist/utils.d.cts +23 -1
- package/dist/utils.d.ts +23 -1
- package/dist/utils.js +1 -1
- package/package.json +6 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# @suigar/sdk
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.9
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- eaf8b3a: Fix metadata encoding so partner metadata is only added when configured and hex metadata values are encoded consistently as bytes. Improve supported-coin and price-info resolution error handling for transaction configuration.
|
|
8
|
+
- 9929e05: Refine Move parser helpers by simplifying BCS type usage, normalizing missing
|
|
9
|
+
`i64` and float mantissa values to `0`, and documenting the numeric conversion
|
|
10
|
+
behavior in `fromMoveI64` and `fromMoveFloat`.
|
|
11
|
+
|
|
3
12
|
## 2.0.0-beta.8
|
|
4
13
|
|
|
5
14
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -110,7 +110,7 @@ Creates a named Sui client extension. By default, it registers under `client.sui
|
|
|
110
110
|
### Partner Setup
|
|
111
111
|
|
|
112
112
|
> **Important:** `partner` is the partner wallet address. Configure it once
|
|
113
|
-
> when you register the extension so the SDK can
|
|
113
|
+
> when you register the extension so the SDK can prepend that wallet address to
|
|
114
114
|
> supported bet metadata automatically.
|
|
115
115
|
|
|
116
116
|
```ts
|
|
@@ -310,7 +310,7 @@ Shared behavior:
|
|
|
310
310
|
- `cashStake` controls the withdrawn balance and defaults to `stake`
|
|
311
311
|
- `betCount` defaults to `1`
|
|
312
312
|
- `metadata` is encoded into `keys` and `values` byte arrays
|
|
313
|
-
- `partner` configured via `suigar({ partner })` is
|
|
313
|
+
- `partner` configured via `suigar({ partner })` is prepended automatically to metadata as the partner wallet address
|
|
314
314
|
- `metadata.partner` and `metadata.referrer` are reserved and ignored with a warning
|
|
315
315
|
- the SDK resolves the price info object from the configured supported-coin mapping
|
|
316
316
|
- the reward object is transferred back to `playerAddress`
|
|
@@ -256,36 +256,28 @@ var GAME_DETAILS_SCHEMA = {
|
|
|
256
256
|
};
|
|
257
257
|
|
|
258
258
|
// src/utils/parser.ts
|
|
259
|
-
var bcsU8 = bcs.u8();
|
|
260
|
-
var bcsU64 = bcs.u64();
|
|
261
|
-
var bcsBool = bcs.bool();
|
|
262
|
-
var bcsString = bcs.string();
|
|
263
259
|
var textDecoder = new TextDecoder();
|
|
264
260
|
var GAME_DETAIL_BCS = {
|
|
265
|
-
u8:
|
|
266
|
-
u64:
|
|
267
|
-
bool:
|
|
261
|
+
u8: bcs.U8,
|
|
262
|
+
u64: bcs.U64,
|
|
263
|
+
bool: bcs.Bool,
|
|
268
264
|
float: Float,
|
|
269
|
-
string:
|
|
265
|
+
string: bcs.String
|
|
270
266
|
};
|
|
271
267
|
function fromMoveI64(i64) {
|
|
272
268
|
try {
|
|
273
|
-
|
|
274
|
-
const maxPositive = 1n << 63n;
|
|
275
|
-
const twoPow64 = 1n << 64n;
|
|
276
|
-
const signed = value >= maxPositive ? value - twoPow64 : value;
|
|
277
|
-
return Number(signed);
|
|
269
|
+
return Number(BigInt.asIntN(64, BigInt(i64.bits ?? 0)));
|
|
278
270
|
} catch {
|
|
279
271
|
return 0;
|
|
280
272
|
}
|
|
281
273
|
}
|
|
282
274
|
function fromMoveFloat(float) {
|
|
283
|
-
const mantissa = BigInt(float.mant);
|
|
275
|
+
const mantissa = BigInt(float.mant ?? 0);
|
|
284
276
|
if (mantissa === 0n) {
|
|
285
277
|
return 0;
|
|
286
278
|
}
|
|
287
279
|
const exponent = fromMoveI64(float.exp) - 52;
|
|
288
|
-
const magnitude = Number(mantissa) *
|
|
280
|
+
const magnitude = Number(mantissa) * 2 ** exponent;
|
|
289
281
|
return float.is_negative ? -magnitude : magnitude;
|
|
290
282
|
}
|
|
291
283
|
function normalizeGameDetailValue(valueType, parsed) {
|
|
@@ -300,7 +292,7 @@ function normalizeGameDetailValue(valueType, parsed) {
|
|
|
300
292
|
function parseStringGameDetail(value) {
|
|
301
293
|
const bytes = Uint8Array.from(value);
|
|
302
294
|
try {
|
|
303
|
-
return
|
|
295
|
+
return bcs.String.parse(bytes);
|
|
304
296
|
} catch {
|
|
305
297
|
return textDecoder.decode(bytes);
|
|
306
298
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BcsType, BcsStruct } from '@mysten/sui/bcs';
|
|
2
2
|
import { SuiClientTypes, ClientWithCoreApi } from '@mysten/sui/client';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> = SuiClientTypes.GetObjectOptions<Include> & {
|
|
5
5
|
client: ClientWithCoreApi;
|
|
6
|
-
}
|
|
7
|
-
|
|
6
|
+
};
|
|
7
|
+
type GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> = SuiClientTypes.GetObjectsOptions<Include> & {
|
|
8
8
|
client: ClientWithCoreApi;
|
|
9
|
-
}
|
|
9
|
+
};
|
|
10
10
|
declare class MoveStruct<T extends Record<string, BcsType<any>>, const Name extends string = string> extends BcsStruct<T, Name> {
|
|
11
11
|
get<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({ objectId, ...options }: GetOptions<Include>): Promise<SuiClientTypes.Object<Include & {
|
|
12
12
|
content: true;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { BcsType, BcsStruct } from '@mysten/sui/bcs';
|
|
2
2
|
import { SuiClientTypes, ClientWithCoreApi } from '@mysten/sui/client';
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
type GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> = SuiClientTypes.GetObjectOptions<Include> & {
|
|
5
5
|
client: ClientWithCoreApi;
|
|
6
|
-
}
|
|
7
|
-
|
|
6
|
+
};
|
|
7
|
+
type GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> = SuiClientTypes.GetObjectsOptions<Include> & {
|
|
8
8
|
client: ClientWithCoreApi;
|
|
9
|
-
}
|
|
9
|
+
};
|
|
10
10
|
declare class MoveStruct<T extends Record<string, BcsType<any>>, const Name extends string = string> extends BcsStruct<T, Name> {
|
|
11
11
|
get<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({ objectId, ...options }: GetOptions<Include>): Promise<SuiClientTypes.Object<Include & {
|
|
12
12
|
content: true;
|
package/dist/index.cjs
CHANGED
|
@@ -126,56 +126,44 @@ function resolvePriceInfoObjectId(config, coinType) {
|
|
|
126
126
|
const normalizedCoinType = utils.normalizeStructTag(coinType);
|
|
127
127
|
const supportedCoin = resolveSupportedCoin(config, normalizedCoinType);
|
|
128
128
|
const objectId = config.priceInfoObjectIds[supportedCoin];
|
|
129
|
-
if (objectId) {
|
|
130
|
-
|
|
129
|
+
if (!objectId) {
|
|
130
|
+
throw new Error(
|
|
131
|
+
`Missing price info object configuration for coin type ${coinType}`
|
|
132
|
+
);
|
|
131
133
|
}
|
|
132
|
-
|
|
133
|
-
`Missing price info object configuration for coin type ${coinType}`
|
|
134
|
-
);
|
|
134
|
+
return objectId;
|
|
135
135
|
}
|
|
136
136
|
function resolveSupportedCoin(config, coinType) {
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
137
|
+
const [supportedCoin] = Object.entries(config.coinTypes).find(([_, value]) => value === coinType) ?? [];
|
|
138
|
+
if (!supportedCoin) {
|
|
139
|
+
throw new Error(
|
|
140
|
+
`Unsupported coin type ${coinType}. Supported coin types: ${Object.values(
|
|
141
|
+
config.coinTypes
|
|
142
|
+
).join(", ")}`
|
|
143
|
+
);
|
|
143
144
|
}
|
|
144
|
-
|
|
145
|
-
`Unsupported coin type ${coinType}. Supported coin types: ${entries.map(([, configuredCoinType]) => configuredCoinType).join(", ")}`
|
|
146
|
-
);
|
|
145
|
+
return supportedCoin;
|
|
147
146
|
}
|
|
148
|
-
var
|
|
149
|
-
var RESERVED_METADATA_KEYS = /* @__PURE__ */ new Set([
|
|
147
|
+
var PARTNER_METADATA_KEY = "partner";
|
|
148
|
+
var RESERVED_METADATA_KEYS = /* @__PURE__ */ new Set([PARTNER_METADATA_KEY, "referrer"]);
|
|
150
149
|
var textEncoder = new TextEncoder();
|
|
151
150
|
function parseHexAddress(value) {
|
|
152
|
-
const trimmed = value.trim();
|
|
153
|
-
if (!trimmed || !utils.isValidSuiAddress(trimmed)) return null;
|
|
154
151
|
try {
|
|
155
|
-
|
|
156
|
-
const bytes = new Uint8Array(normalized.length / 2);
|
|
157
|
-
for (let index = 0; index < normalized.length; index += 2) {
|
|
158
|
-
bytes[index / 2] = Number.parseInt(
|
|
159
|
-
normalized.slice(index, index + 2),
|
|
160
|
-
16
|
|
161
|
-
);
|
|
162
|
-
}
|
|
163
|
-
return bytes;
|
|
152
|
+
return utils.fromHex(value);
|
|
164
153
|
} catch {
|
|
165
154
|
return null;
|
|
166
155
|
}
|
|
167
156
|
}
|
|
168
|
-
function encodeMetadataValue(
|
|
157
|
+
function encodeMetadataValue(value) {
|
|
169
158
|
if (value instanceof Uint8Array) {
|
|
170
159
|
return Array.from(value);
|
|
171
160
|
}
|
|
172
161
|
if (Array.isArray(value)) {
|
|
173
162
|
return value;
|
|
174
163
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
return Array.from(textEncoder.encode(String(value)));
|
|
164
|
+
return Array.from(
|
|
165
|
+
parseHexAddress(String(value)) ?? textEncoder.encode(String(value))
|
|
166
|
+
);
|
|
179
167
|
}
|
|
180
168
|
function encodeBetMetadata(metadata, partner) {
|
|
181
169
|
const keys = [];
|
|
@@ -191,14 +179,15 @@ function encodeBetMetadata(metadata, partner) {
|
|
|
191
179
|
continue;
|
|
192
180
|
}
|
|
193
181
|
keys.push(key);
|
|
194
|
-
values.push(encodeMetadataValue(
|
|
182
|
+
values.push(encodeMetadataValue(value));
|
|
195
183
|
}
|
|
196
|
-
if (
|
|
197
|
-
|
|
184
|
+
if (partner?.trim()) {
|
|
185
|
+
keys.unshift(PARTNER_METADATA_KEY);
|
|
186
|
+
values.unshift(encodeMetadataValue(partner));
|
|
198
187
|
}
|
|
199
188
|
return {
|
|
200
|
-
keys
|
|
201
|
-
values
|
|
189
|
+
keys,
|
|
190
|
+
values
|
|
202
191
|
};
|
|
203
192
|
}
|
|
204
193
|
var MOVE_STDLIB_ADDRESS = utils.normalizeSuiAddress("0x1");
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as MoveStruct } from './index-
|
|
1
|
+
import { M as MoveStruct } from './index-3P_LBbDM.cjs';
|
|
2
2
|
import * as _mysten_bcs from '@mysten/bcs';
|
|
3
3
|
import { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';
|
|
4
4
|
import { Transaction, BuildTransactionOptions } from '@mysten/sui/transactions';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { M as MoveStruct } from './index-
|
|
1
|
+
import { M as MoveStruct } from './index-3P_LBbDM.js';
|
|
2
2
|
import * as _mysten_bcs from '@mysten/bcs';
|
|
3
3
|
import { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';
|
|
4
4
|
import { Transaction, BuildTransactionOptions } from '@mysten/sui/transactions';
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { MoveStruct, Float, toBigInt, toU8, DEFAULT_GAS_BUDGET_MIST, normalizeMoveArguments, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE } from './chunk-
|
|
2
|
-
import { toBase64, normalizeStructTag, parseStructTag, normalizeSuiAddress,
|
|
1
|
+
import { MoveStruct, Float, toBigInt, toU8, DEFAULT_GAS_BUDGET_MIST, normalizeMoveArguments, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE } from './chunk-FEQY5O43.js';
|
|
2
|
+
import { toBase64, normalizeStructTag, parseStructTag, normalizeSuiAddress, fromHex } from '@mysten/sui/utils';
|
|
3
3
|
import { Transaction } from '@mysten/sui/transactions';
|
|
4
4
|
import { bcs } from '@mysten/sui/bcs';
|
|
5
5
|
|
|
@@ -123,56 +123,44 @@ function resolvePriceInfoObjectId(config, coinType) {
|
|
|
123
123
|
const normalizedCoinType = normalizeStructTag(coinType);
|
|
124
124
|
const supportedCoin = resolveSupportedCoin(config, normalizedCoinType);
|
|
125
125
|
const objectId = config.priceInfoObjectIds[supportedCoin];
|
|
126
|
-
if (objectId) {
|
|
127
|
-
|
|
126
|
+
if (!objectId) {
|
|
127
|
+
throw new Error(
|
|
128
|
+
`Missing price info object configuration for coin type ${coinType}`
|
|
129
|
+
);
|
|
128
130
|
}
|
|
129
|
-
|
|
130
|
-
`Missing price info object configuration for coin type ${coinType}`
|
|
131
|
-
);
|
|
131
|
+
return objectId;
|
|
132
132
|
}
|
|
133
133
|
function resolveSupportedCoin(config, coinType) {
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
134
|
+
const [supportedCoin] = Object.entries(config.coinTypes).find(([_, value]) => value === coinType) ?? [];
|
|
135
|
+
if (!supportedCoin) {
|
|
136
|
+
throw new Error(
|
|
137
|
+
`Unsupported coin type ${coinType}. Supported coin types: ${Object.values(
|
|
138
|
+
config.coinTypes
|
|
139
|
+
).join(", ")}`
|
|
140
|
+
);
|
|
140
141
|
}
|
|
141
|
-
|
|
142
|
-
`Unsupported coin type ${coinType}. Supported coin types: ${entries.map(([, configuredCoinType]) => configuredCoinType).join(", ")}`
|
|
143
|
-
);
|
|
142
|
+
return supportedCoin;
|
|
144
143
|
}
|
|
145
|
-
var
|
|
146
|
-
var RESERVED_METADATA_KEYS = /* @__PURE__ */ new Set([
|
|
144
|
+
var PARTNER_METADATA_KEY = "partner";
|
|
145
|
+
var RESERVED_METADATA_KEYS = /* @__PURE__ */ new Set([PARTNER_METADATA_KEY, "referrer"]);
|
|
147
146
|
var textEncoder = new TextEncoder();
|
|
148
147
|
function parseHexAddress(value) {
|
|
149
|
-
const trimmed = value.trim();
|
|
150
|
-
if (!trimmed || !isValidSuiAddress(trimmed)) return null;
|
|
151
148
|
try {
|
|
152
|
-
|
|
153
|
-
const bytes = new Uint8Array(normalized.length / 2);
|
|
154
|
-
for (let index = 0; index < normalized.length; index += 2) {
|
|
155
|
-
bytes[index / 2] = Number.parseInt(
|
|
156
|
-
normalized.slice(index, index + 2),
|
|
157
|
-
16
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
return bytes;
|
|
149
|
+
return fromHex(value);
|
|
161
150
|
} catch {
|
|
162
151
|
return null;
|
|
163
152
|
}
|
|
164
153
|
}
|
|
165
|
-
function encodeMetadataValue(
|
|
154
|
+
function encodeMetadataValue(value) {
|
|
166
155
|
if (value instanceof Uint8Array) {
|
|
167
156
|
return Array.from(value);
|
|
168
157
|
}
|
|
169
158
|
if (Array.isArray(value)) {
|
|
170
159
|
return value;
|
|
171
160
|
}
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
return Array.from(textEncoder.encode(String(value)));
|
|
161
|
+
return Array.from(
|
|
162
|
+
parseHexAddress(String(value)) ?? textEncoder.encode(String(value))
|
|
163
|
+
);
|
|
176
164
|
}
|
|
177
165
|
function encodeBetMetadata(metadata, partner) {
|
|
178
166
|
const keys = [];
|
|
@@ -188,14 +176,15 @@ function encodeBetMetadata(metadata, partner) {
|
|
|
188
176
|
continue;
|
|
189
177
|
}
|
|
190
178
|
keys.push(key);
|
|
191
|
-
values.push(encodeMetadataValue(
|
|
179
|
+
values.push(encodeMetadataValue(value));
|
|
192
180
|
}
|
|
193
|
-
if (
|
|
194
|
-
|
|
181
|
+
if (partner?.trim()) {
|
|
182
|
+
keys.unshift(PARTNER_METADATA_KEY);
|
|
183
|
+
values.unshift(encodeMetadataValue(partner));
|
|
195
184
|
}
|
|
196
185
|
return {
|
|
197
|
-
keys
|
|
198
|
-
values
|
|
186
|
+
keys,
|
|
187
|
+
values
|
|
199
188
|
};
|
|
200
189
|
}
|
|
201
190
|
|
package/dist/utils.cjs
CHANGED
|
@@ -146,36 +146,28 @@ var GAME_DETAILS_SCHEMA = {
|
|
|
146
146
|
};
|
|
147
147
|
|
|
148
148
|
// src/utils/parser.ts
|
|
149
|
-
var bcsU8 = bcs.bcs.u8();
|
|
150
|
-
var bcsU64 = bcs.bcs.u64();
|
|
151
|
-
var bcsBool = bcs.bcs.bool();
|
|
152
|
-
var bcsString = bcs.bcs.string();
|
|
153
149
|
var textDecoder = new TextDecoder();
|
|
154
150
|
var GAME_DETAIL_BCS = {
|
|
155
|
-
u8:
|
|
156
|
-
u64:
|
|
157
|
-
bool:
|
|
151
|
+
u8: bcs.bcs.U8,
|
|
152
|
+
u64: bcs.bcs.U64,
|
|
153
|
+
bool: bcs.bcs.Bool,
|
|
158
154
|
float: Float,
|
|
159
|
-
string:
|
|
155
|
+
string: bcs.bcs.String
|
|
160
156
|
};
|
|
161
157
|
function fromMoveI64(i64) {
|
|
162
158
|
try {
|
|
163
|
-
|
|
164
|
-
const maxPositive = 1n << 63n;
|
|
165
|
-
const twoPow64 = 1n << 64n;
|
|
166
|
-
const signed = value >= maxPositive ? value - twoPow64 : value;
|
|
167
|
-
return Number(signed);
|
|
159
|
+
return Number(BigInt.asIntN(64, BigInt(i64.bits ?? 0)));
|
|
168
160
|
} catch {
|
|
169
161
|
return 0;
|
|
170
162
|
}
|
|
171
163
|
}
|
|
172
164
|
function fromMoveFloat(float) {
|
|
173
|
-
const mantissa = BigInt(float.mant);
|
|
165
|
+
const mantissa = BigInt(float.mant ?? 0);
|
|
174
166
|
if (mantissa === 0n) {
|
|
175
167
|
return 0;
|
|
176
168
|
}
|
|
177
169
|
const exponent = fromMoveI64(float.exp) - 52;
|
|
178
|
-
const magnitude = Number(mantissa) *
|
|
170
|
+
const magnitude = Number(mantissa) * 2 ** exponent;
|
|
179
171
|
return float.is_negative ? -magnitude : magnitude;
|
|
180
172
|
}
|
|
181
173
|
function normalizeGameDetailValue(valueType, parsed) {
|
|
@@ -190,7 +182,7 @@ function normalizeGameDetailValue(valueType, parsed) {
|
|
|
190
182
|
function parseStringGameDetail(value) {
|
|
191
183
|
const bytes = Uint8Array.from(value);
|
|
192
184
|
try {
|
|
193
|
-
return
|
|
185
|
+
return bcs.bcs.String.parse(bytes);
|
|
194
186
|
} catch {
|
|
195
187
|
return textDecoder.decode(bytes);
|
|
196
188
|
}
|
package/dist/utils.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _mysten_bcs from '@mysten/bcs';
|
|
2
|
-
import { M as MoveStruct } from './index-
|
|
2
|
+
import { M as MoveStruct } from './index-3P_LBbDM.cjs';
|
|
3
3
|
import '@mysten/sui/bcs';
|
|
4
4
|
import '@mysten/sui/client';
|
|
5
5
|
|
|
@@ -96,7 +96,29 @@ declare const Float: MoveStruct<{
|
|
|
96
96
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
|
|
97
97
|
|
|
98
98
|
type MoveFloat = ReturnType<(typeof Float)['parse']>;
|
|
99
|
+
/**
|
|
100
|
+
* Converts a generated Move `i64` wrapper into a JavaScript number.
|
|
101
|
+
*
|
|
102
|
+
* The generated bindings expose signed 64-bit integers through a `{ bits }`
|
|
103
|
+
* field that stores the raw two's-complement bit pattern. This helper
|
|
104
|
+
* reinterprets those bits as a signed `i64` and returns a plain JS number.
|
|
105
|
+
* Invalid or missing input falls back to `0`.
|
|
106
|
+
*
|
|
107
|
+
* @param i64 Generated Move `i64` value, typically used for float exponents.
|
|
108
|
+
* @returns The signed 64-bit value as a JavaScript number.
|
|
109
|
+
*/
|
|
99
110
|
declare function fromMoveI64(i64: MoveFloat['exp']): number;
|
|
111
|
+
/**
|
|
112
|
+
* Converts a generated Move `Float` struct into a JavaScript number.
|
|
113
|
+
*
|
|
114
|
+
* Suigar float values are represented as a sign flag, an unsigned mantissa,
|
|
115
|
+
* and a Move `i64` exponent. This helper rebuilds the numeric value using the
|
|
116
|
+
* same normalization expected by the onchain format and applies the sign at
|
|
117
|
+
* the end. Missing mantissas are treated as `0`, and a zero mantissa returns `0`.
|
|
118
|
+
*
|
|
119
|
+
* @param float Generated Move float value with `mant`, `exp`, and `is_negative`.
|
|
120
|
+
* @returns The decoded floating-point value as a JavaScript number.
|
|
121
|
+
*/
|
|
100
122
|
declare function fromMoveFloat(float: MoveFloat): number;
|
|
101
123
|
/**
|
|
102
124
|
* Decodes `BetResultEvent.game_details` into plain application values.
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _mysten_bcs from '@mysten/bcs';
|
|
2
|
-
import { M as MoveStruct } from './index-
|
|
2
|
+
import { M as MoveStruct } from './index-3P_LBbDM.js';
|
|
3
3
|
import '@mysten/sui/bcs';
|
|
4
4
|
import '@mysten/sui/client';
|
|
5
5
|
|
|
@@ -96,7 +96,29 @@ declare const Float: MoveStruct<{
|
|
|
96
96
|
}, "0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float">;
|
|
97
97
|
|
|
98
98
|
type MoveFloat = ReturnType<(typeof Float)['parse']>;
|
|
99
|
+
/**
|
|
100
|
+
* Converts a generated Move `i64` wrapper into a JavaScript number.
|
|
101
|
+
*
|
|
102
|
+
* The generated bindings expose signed 64-bit integers through a `{ bits }`
|
|
103
|
+
* field that stores the raw two's-complement bit pattern. This helper
|
|
104
|
+
* reinterprets those bits as a signed `i64` and returns a plain JS number.
|
|
105
|
+
* Invalid or missing input falls back to `0`.
|
|
106
|
+
*
|
|
107
|
+
* @param i64 Generated Move `i64` value, typically used for float exponents.
|
|
108
|
+
* @returns The signed 64-bit value as a JavaScript number.
|
|
109
|
+
*/
|
|
99
110
|
declare function fromMoveI64(i64: MoveFloat['exp']): number;
|
|
111
|
+
/**
|
|
112
|
+
* Converts a generated Move `Float` struct into a JavaScript number.
|
|
113
|
+
*
|
|
114
|
+
* Suigar float values are represented as a sign flag, an unsigned mantissa,
|
|
115
|
+
* and a Move `i64` exponent. This helper rebuilds the numeric value using the
|
|
116
|
+
* same normalization expected by the onchain format and applies the sign at
|
|
117
|
+
* the end. Missing mantissas are treated as `0`, and a zero mantissa returns `0`.
|
|
118
|
+
*
|
|
119
|
+
* @param float Generated Move float value with `mant`, `exp`, and `is_negative`.
|
|
120
|
+
* @returns The decoded floating-point value as a JavaScript number.
|
|
121
|
+
*/
|
|
100
122
|
declare function fromMoveFloat(float: MoveFloat): number;
|
|
101
123
|
/**
|
|
102
124
|
* Decodes `BetResultEvent.game_details` into plain application values.
|
package/dist/utils.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT, fromMoveFloat, fromMoveI64, parseGameDetails, toBigInt, toU8 } from './chunk-
|
|
1
|
+
export { DEFAULT_GAS_BUDGET_MIST, DEFAULT_LIMBO_MULTIPLIER_SCALE, DEFAULT_RANGE_SCALE, RANGE_POINT_LIMIT, fromMoveFloat, fromMoveI64, parseGameDetails, toBigInt, toU8 } from './chunk-FEQY5O43.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@suigar/sdk",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.9",
|
|
4
4
|
"description": "TypeScript SDK for Suigar v2 Move contracts on Sui.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"suigar",
|
|
@@ -46,18 +46,17 @@
|
|
|
46
46
|
"build": "npm run clean && npm run codegen && tsup",
|
|
47
47
|
"build:ci": "rm -rf dist && tsup",
|
|
48
48
|
"clean": "rm -rf dist src/contracts .vitest-cache",
|
|
49
|
-
"codegen": "sui-ts-codegen generate",
|
|
49
|
+
"codegen": "node ./scripts/update-package-configs.mjs && sui-ts-codegen generate",
|
|
50
50
|
"changeset": "changeset",
|
|
51
51
|
"changeset:beta:enter": "changeset pre enter beta",
|
|
52
52
|
"changeset:beta:exit": "changeset pre exit",
|
|
53
|
+
"changeset:version": "changeset version",
|
|
53
54
|
"format": "prettier --write .",
|
|
54
55
|
"lint": "eslint . --fix && npm run format",
|
|
55
56
|
"prepare": "husky",
|
|
56
57
|
"release": "changeset publish",
|
|
57
58
|
"test": "vitest run",
|
|
58
|
-
"typecheck": "tsc --noEmit"
|
|
59
|
-
"update:package-configs": "node ./scripts/update-package-configs.mjs",
|
|
60
|
-
"version-packages": "changeset version"
|
|
59
|
+
"typecheck": "tsc --noEmit"
|
|
61
60
|
},
|
|
62
61
|
"repository": {
|
|
63
62
|
"type": "git",
|
|
@@ -78,7 +77,7 @@
|
|
|
78
77
|
"@changesets/cli": "^2.31.0",
|
|
79
78
|
"@eslint/js": "^10.0.1",
|
|
80
79
|
"@mysten/bcs": "^2.0.3",
|
|
81
|
-
"@mysten/codegen": "^0.
|
|
80
|
+
"@mysten/codegen": "^0.10.0",
|
|
82
81
|
"@mysten/sui": "^2.16.0",
|
|
83
82
|
"@types/node": "^24.0.0",
|
|
84
83
|
"eslint": "^10.2.1",
|
|
@@ -89,7 +88,7 @@
|
|
|
89
88
|
"tsup": "^8.5.1",
|
|
90
89
|
"tsx": "^4.21.0",
|
|
91
90
|
"typescript": "^5.9.3",
|
|
92
|
-
"typescript-eslint": "^8.59.
|
|
91
|
+
"typescript-eslint": "^8.59.1",
|
|
93
92
|
"vitest": "^4.1.5"
|
|
94
93
|
}
|
|
95
94
|
}
|