@suigar/sdk 2.0.0-beta.16 → 2.0.0-beta.18
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
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @suigar/sdk
|
|
2
2
|
|
|
3
|
+
## 2.0.0-beta.18
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- de9e425: Update SDK dependency metadata to use the shared Mysten and TypeScript pnpm catalogs, including the `@mysten/sui` and `tsx` dependency updates.
|
|
8
|
+
|
|
9
|
+
## 2.0.0-beta.17
|
|
10
|
+
|
|
11
|
+
### Major Changes
|
|
12
|
+
|
|
13
|
+
- bd8499e: Rename transaction builder option `playerAddress` to `owner` across standard and PvP transaction APIs.
|
|
14
|
+
|
|
3
15
|
## 2.0.0-beta.16
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -114,7 +114,7 @@ const client = new SuiGrpcClient({
|
|
|
114
114
|
}).$extend(suigar());
|
|
115
115
|
|
|
116
116
|
const tx = client.suigar.tx.createBetTransaction('coinflip', {
|
|
117
|
-
|
|
117
|
+
owner: '0x123',
|
|
118
118
|
coinType: '0x2::sui::SUI',
|
|
119
119
|
stake: 1_000_000_000n,
|
|
120
120
|
side: 'heads',
|
|
@@ -305,7 +305,7 @@ Use `createBetTransaction(gameId, options)` for:
|
|
|
305
305
|
|
|
306
306
|
```ts
|
|
307
307
|
const tx = client.suigar.tx.createBetTransaction('coinflip', {
|
|
308
|
-
|
|
308
|
+
owner: '0x123',
|
|
309
309
|
coinType: '0x2::sui::SUI',
|
|
310
310
|
stake: 1_000_000_000n,
|
|
311
311
|
side: 'tails',
|
|
@@ -314,7 +314,7 @@ const tx = client.suigar.tx.createBetTransaction('coinflip', {
|
|
|
314
314
|
|
|
315
315
|
Shared option shape:
|
|
316
316
|
|
|
317
|
-
- `
|
|
317
|
+
- `owner: string`
|
|
318
318
|
- `coinType: string`
|
|
319
319
|
- `stake: number | bigint`
|
|
320
320
|
- `cashStake?: number | bigint`
|
|
@@ -332,7 +332,7 @@ Shared behavior:
|
|
|
332
332
|
- `partner` configured via `suigar({ partner })` is prepended automatically to metadata as the partner wallet address
|
|
333
333
|
- `metadata.partner` and `metadata.referrer` are reserved and ignored with a warning
|
|
334
334
|
- the SDK resolves the price info object from the configured supported-coin mapping
|
|
335
|
-
- the reward object is transferred back to `
|
|
335
|
+
- the reward object is transferred back to `owner`
|
|
336
336
|
|
|
337
337
|
Error behavior:
|
|
338
338
|
|
|
@@ -352,14 +352,14 @@ Examples:
|
|
|
352
352
|
|
|
353
353
|
```ts
|
|
354
354
|
const limboTx = client.suigar.tx.createBetTransaction('limbo', {
|
|
355
|
-
|
|
355
|
+
owner: '0x123',
|
|
356
356
|
coinType: '0x2::sui::SUI',
|
|
357
357
|
stake: 1_000_000_000n,
|
|
358
358
|
targetMultiplier: 2.5,
|
|
359
359
|
});
|
|
360
360
|
|
|
361
361
|
const rangeTx = client.suigar.tx.createBetTransaction('range', {
|
|
362
|
-
|
|
362
|
+
owner: '0x123',
|
|
363
363
|
coinType: '0x2::sui::SUI',
|
|
364
364
|
stake: 1_000_000_000n,
|
|
365
365
|
leftPoint: 25,
|
|
@@ -394,7 +394,7 @@ Create:
|
|
|
394
394
|
|
|
395
395
|
```ts
|
|
396
396
|
const tx = client.suigar.tx.createPvPCoinflipTransaction('create', {
|
|
397
|
-
|
|
397
|
+
owner: '0x123',
|
|
398
398
|
coinType: '0x2::sui::SUI',
|
|
399
399
|
stake: 1_000_000_000n,
|
|
400
400
|
side: 'heads',
|
|
@@ -406,7 +406,7 @@ Join:
|
|
|
406
406
|
|
|
407
407
|
```ts
|
|
408
408
|
const tx = client.suigar.tx.createPvPCoinflipTransaction('join', {
|
|
409
|
-
|
|
409
|
+
owner: '0x123',
|
|
410
410
|
coinType: '0x2::sui::SUI',
|
|
411
411
|
gameId: '0xGAME_ID',
|
|
412
412
|
});
|
|
@@ -416,7 +416,7 @@ Cancel:
|
|
|
416
416
|
|
|
417
417
|
```ts
|
|
418
418
|
const tx = client.suigar.tx.createPvPCoinflipTransaction('cancel', {
|
|
419
|
-
|
|
419
|
+
owner: '0x123',
|
|
420
420
|
coinType: '0x2::sui::SUI',
|
|
421
421
|
gameId: '0xGAME_ID',
|
|
422
422
|
});
|
|
@@ -427,7 +427,7 @@ id for `coinType`.
|
|
|
427
427
|
|
|
428
428
|
PvP shared options:
|
|
429
429
|
|
|
430
|
-
- `
|
|
430
|
+
- `owner: string`
|
|
431
431
|
- `coinType: string`
|
|
432
432
|
- `metadata?: Record<string, string | number | boolean | bigint | Uint8Array | number[] | null | undefined>`
|
|
433
433
|
- `gasBudget?: number | bigint`
|
|
@@ -5,23 +5,23 @@ import { toBigInt } from "../utils/numeric.mjs";
|
|
|
5
5
|
import { normalizeStructTag, normalizeSuiAddress } from "@mysten/sui/utils";
|
|
6
6
|
import { Transaction } from "@mysten/sui/transactions";
|
|
7
7
|
//#region src/transactions/shared.ts
|
|
8
|
-
function createBaseGameTransaction({ config, game,
|
|
8
|
+
function createBaseGameTransaction({ config, game, owner, gasBudget }) {
|
|
9
9
|
assertConfiguredBetGame(config, game);
|
|
10
10
|
const tx = new Transaction();
|
|
11
|
-
tx.setSenderIfNotSet(normalizeSuiAddress(
|
|
11
|
+
tx.setSenderIfNotSet(normalizeSuiAddress(owner));
|
|
12
12
|
tx.setGasBudgetIfNotSet(gasBudget ?? DEFAULT_GAS_BUDGET_MIST);
|
|
13
13
|
return tx;
|
|
14
14
|
}
|
|
15
|
-
function buildSharedStandardGameBetCall({ config,
|
|
15
|
+
function buildSharedStandardGameBetCall({ config, owner, coinType, stake, cashStake, betCount, metadata, partner, allowGasCoinShortcut = true, buildRewardCoin }) {
|
|
16
16
|
return (tx) => {
|
|
17
|
-
const
|
|
17
|
+
const normalizedOwner = normalizeSuiAddress(owner);
|
|
18
18
|
const normalizedCoinType = normalizeStructTag(coinType);
|
|
19
19
|
const resolvedStake = toBigInt(stake);
|
|
20
20
|
const resolvedCashStake = toBigInt(cashStake ?? stake);
|
|
21
21
|
const rewardCoin = buildRewardCoin({
|
|
22
22
|
tx,
|
|
23
23
|
config,
|
|
24
|
-
|
|
24
|
+
owner: normalizedOwner,
|
|
25
25
|
coinType: normalizedCoinType,
|
|
26
26
|
stake: resolvedStake,
|
|
27
27
|
cashStake: resolvedCashStake,
|
|
@@ -34,7 +34,7 @@ function buildSharedStandardGameBetCall({ config, playerAddress, coinType, stake
|
|
|
34
34
|
useGasCoin: allowGasCoinShortcut
|
|
35
35
|
})
|
|
36
36
|
});
|
|
37
|
-
tx.transferObjects([rewardCoin], tx.pure.address(
|
|
37
|
+
tx.transferObjects([rewardCoin], tx.pure.address(normalizedOwner));
|
|
38
38
|
return rewardCoin;
|
|
39
39
|
};
|
|
40
40
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shared.mjs","names":[],"sources":["../../src/transactions/shared.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n\tTransaction,\n\ttype TransactionArgument,\n\ttype TransactionResult,\n} from '@mysten/sui/transactions';\nimport { normalizeStructTag, normalizeSuiAddress } from '@mysten/sui/utils';\nimport {\n\tassertConfiguredBetGame,\n\tencodeBetMetadata,\n\tresolvePriceInfoObjectId,\n} from '../helpers/index.js';\nimport type {\n\tBaseTransactionOptions,\n\tCoinTransactionOptions,\n\tEncodedBetMetadata,\n\tGame,\n\tSharedBetTransactionOptions,\n\tStakeTransactionOptions,\n\tWithPartner,\n} from '../types';\nimport { DEFAULT_GAS_BUDGET_MIST, toBigInt } from '../utils/index.js';\n\ntype StrictStakeTransactionOptions = {\n\t[K in keyof StakeTransactionOptions]-?: Exclude<\n\t\tStakeTransactionOptions[K],\n\t\tnumber\n\t>;\n};\n\nexport type BuildSharedBetTransactionContext = Pick<\n\tBaseTransactionOptions,\n\t'config' | '
|
|
1
|
+
{"version":3,"file":"shared.mjs","names":[],"sources":["../../src/transactions/shared.ts"],"sourcesContent":["// Copyright (c) Suigar\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n\tTransaction,\n\ttype TransactionArgument,\n\ttype TransactionResult,\n} from '@mysten/sui/transactions';\nimport { normalizeStructTag, normalizeSuiAddress } from '@mysten/sui/utils';\nimport {\n\tassertConfiguredBetGame,\n\tencodeBetMetadata,\n\tresolvePriceInfoObjectId,\n} from '../helpers/index.js';\nimport type {\n\tBaseTransactionOptions,\n\tCoinTransactionOptions,\n\tEncodedBetMetadata,\n\tGame,\n\tSharedBetTransactionOptions,\n\tStakeTransactionOptions,\n\tWithPartner,\n} from '../types';\nimport { DEFAULT_GAS_BUDGET_MIST, toBigInt } from '../utils/index.js';\n\ntype StrictStakeTransactionOptions = {\n\t[K in keyof StakeTransactionOptions]-?: Exclude<\n\t\tStakeTransactionOptions[K],\n\t\tnumber\n\t>;\n};\n\nexport type BuildSharedBetTransactionContext = Pick<\n\tBaseTransactionOptions,\n\t'config' | 'owner'\n> &\n\tPick<CoinTransactionOptions, 'coinType'> &\n\tStrictStakeTransactionOptions & {\n\t\ttx: Transaction;\n\t\tmetadata: EncodedBetMetadata;\n\t\tpriceInfoObjectId: string;\n\t\tbetCoin: TransactionResult;\n\t};\n\nexport type CreateBaseGameTransactionOptions = BaseTransactionOptions & {\n\tgame: Game;\n};\n\nexport type BuildSharedBetTransactionOptions = WithPartner<\n\tSharedBetTransactionOptions & {\n\t\tgame: Game;\n\t\tbuildRewardCoin: (\n\t\t\tcontext: BuildSharedBetTransactionContext,\n\t\t) => TransactionResult;\n\t}\n>;\n\nexport function createBaseGameTransaction({\n\tconfig,\n\tgame,\n\towner,\n\tgasBudget,\n}: CreateBaseGameTransactionOptions): Transaction {\n\tassertConfiguredBetGame(config, game);\n\n\tconst tx = new Transaction();\n\ttx.setSenderIfNotSet(normalizeSuiAddress(owner));\n\ttx.setGasBudgetIfNotSet(gasBudget ?? DEFAULT_GAS_BUDGET_MIST);\n\n\treturn tx;\n}\n\nexport function buildSharedStandardGameBetCall({\n\tconfig,\n\towner,\n\tcoinType,\n\tstake,\n\tcashStake,\n\tbetCount,\n\tmetadata,\n\tpartner,\n\tallowGasCoinShortcut = true,\n\tbuildRewardCoin,\n}: BuildSharedBetTransactionOptions): (tx: Transaction) => TransactionArgument {\n\treturn (tx: Transaction) => {\n\t\tconst normalizedOwner = normalizeSuiAddress(owner);\n\t\tconst normalizedCoinType = normalizeStructTag(coinType);\n\t\tconst resolvedStake = toBigInt(stake);\n\t\tconst resolvedCashStake = toBigInt(cashStake ?? stake);\n\t\tconst resolvedBetCount = toBigInt(betCount ?? 1);\n\t\tconst encodedMetadata = encodeBetMetadata(metadata, partner);\n\t\tconst priceInfoObjectId = resolvePriceInfoObjectId(\n\t\t\tconfig,\n\t\t\tnormalizedCoinType,\n\t\t);\n\n\t\tconst betCoin = tx.coin({\n\t\t\ttype: normalizedCoinType,\n\t\t\tbalance: resolvedCashStake,\n\t\t\tuseGasCoin: allowGasCoinShortcut,\n\t\t});\n\n\t\tconst rewardCoin = buildRewardCoin({\n\t\t\ttx,\n\t\t\tconfig,\n\t\t\towner: normalizedOwner,\n\t\t\tcoinType: normalizedCoinType,\n\t\t\tstake: resolvedStake,\n\t\t\tcashStake: resolvedCashStake,\n\t\t\tbetCount: resolvedBetCount,\n\t\t\tmetadata: encodedMetadata,\n\t\t\tpriceInfoObjectId,\n\t\t\tbetCoin,\n\t\t});\n\n\t\ttx.transferObjects([rewardCoin], tx.pure.address(normalizedOwner));\n\t\treturn rewardCoin;\n\t};\n}\n\nexport function buildSharedStandardGameBetTransaction(\n\toptions: BuildSharedBetTransactionOptions,\n): Transaction {\n\tconst tx = createBaseGameTransaction(options);\n\ttx.add(buildSharedStandardGameBetCall(options));\n\treturn tx;\n}\n"],"mappings":";;;;;;;AAyDA,SAAgB,0BAA0B,EACzC,QACA,MACA,OACA,aACiD;CACjD,wBAAwB,QAAQ,KAAK;CAErC,MAAM,KAAK,IAAI,aAAa;CAC5B,GAAG,kBAAkB,oBAAoB,MAAM,CAAC;CAChD,GAAG,qBAAqB,aAAa,wBAAwB;CAE7D,OAAO;;AAGR,SAAgB,+BAA+B,EAC9C,QACA,OACA,UACA,OACA,WACA,UACA,UACA,SACA,uBAAuB,MACvB,mBAC8E;CAC9E,QAAQ,OAAoB;EAC3B,MAAM,kBAAkB,oBAAoB,MAAM;EAClD,MAAM,qBAAqB,mBAAmB,SAAS;EACvD,MAAM,gBAAgB,SAAS,MAAM;EACrC,MAAM,oBAAoB,SAAS,aAAa,MAAM;EActD,MAAM,aAAa,gBAAgB;GAClC;GACA;GACA,OAAO;GACP,UAAU;GACV,OAAO;GACP,WAAW;GACX,UApBwB,SAAS,YAAY,EAoBnB;GAC1B,UApBuB,kBAAkB,UAAU,QAoB1B;GACzB,mBApByB,yBACzB,QACA,mBAkBiB;GACjB,SAhBe,GAAG,KAAK;IACvB,MAAM;IACN,SAAS;IACT,YAAY;IACZ,CAYO;GACP,CAAC;EAEF,GAAG,gBAAgB,CAAC,WAAW,EAAE,GAAG,KAAK,QAAQ,gBAAgB,CAAC;EAClE,OAAO;;;AAIT,SAAgB,sCACf,SACc;CACd,MAAM,KAAK,0BAA0B,QAAQ;CAC7C,GAAG,IAAI,+BAA+B,QAAQ,CAAC;CAC/C,OAAO"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-options.type.d.mts","names":[],"sources":["../../src/types/transaction-options.type.ts"],"mappings":";;;;;;KAQY,aAAA;EACX,SAAA,GAAY,UAAA,CAAW,WAAA;AAAA;AAAA,KAOZ,gBAAA,eAA+B,CAAA;EAC1C,YAAA;AAAA;AAAA,KAGW,sBAAA,GAAyB,aAAA;EACpC,MAAA,EAAQ,YAAA;EACR,
|
|
1
|
+
{"version":3,"file":"transaction-options.type.d.mts","names":[],"sources":["../../src/types/transaction-options.type.ts"],"mappings":";;;;;;KAQY,aAAA;EACX,SAAA,GAAY,UAAA,CAAW,WAAA;AAAA;AAAA,KAOZ,gBAAA,eAA+B,CAAA;EAC1C,YAAA;AAAA;AAAA,KAGW,sBAAA,GAAyB,aAAA;EACpC,MAAA,EAAQ,YAAA;EACR,KAAA;AAAA;AAAA,KAGW,sBAAA;EACX,QAAA;EACA,QAAA,GAAW,gBAAA;EACX,oBAAA;AAAA;AAAA,KAGW,uBAAA;EACX,KAAA;EACA,SAAA;EACA,QAAA;AAAA;AAAA,KAGW,2BAAA,GAA8B,sBAAA,GACzC,sBAAA,GACA,uBAAA;AAAA,KAEW,+BAAA,GAAkC,2BAAA;EAC7C,IAAA,EAAM,QAAA;AAAA;AAAA,KAGK,4BAAA,GAA+B,2BAAA;EAC1C,gBAAA;EACA,KAAA;AAAA;AAAA,KAGW,6BAAA,GAAgC,2BAAA;EAC3C,QAAA;AAAA;AAAA,KAGW,4BAAA,GAA+B,2BAAA;EAC1C,SAAA;EACA,UAAA;EACA,UAAA;EACA,KAAA;AAAA;AAAA,KAGW,4BAAA,GAA+B,2BAAA;EAC1C,QAAA;AAAA;AAAA,KAGW,iBAAA;AAAA,KAEA,mCAAA,GAAsC,sBAAA,GACjD,sBAAA;AAAA,KAEW,wCAAA,GACX,mCAAA;EACC,KAAA,EAAO,uBAAA;EACP,IAAA,EAAM,QAAA;EACN,SAAA;AAAA;AAAA,KAGU,sCAAA,GACX,mCAAA;EACC,MAAA;AAAA;AAAA,KAQU,wCAAA,GACX,mCAAA;EACC,MAAA;AAAA;AAAA,KAGU,kCAAA,gBACI,iBAAA,GAAoB,iBAAA,IAChC,MAAA,oBACD,wCAAA,GACA,MAAA,kBACC,sCAAA,GACA,MAAA,oBACC,wCAAA"}
|
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.18",
|
|
4
4
|
"description": "TypeScript SDK for Suigar v2 Move contracts on Sui.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"suigar",
|
|
@@ -54,17 +54,17 @@
|
|
|
54
54
|
"homepage": "https://docs.suigar.com/sdk",
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"@mysten/bcs": "^2.0.5",
|
|
57
|
-
"@mysten/sui": "^2.16.
|
|
57
|
+
"@mysten/sui": "^2.16.3"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
60
|
"@mysten/bcs": "^2.0.5",
|
|
61
61
|
"@mysten/codegen": "^0.10.6",
|
|
62
|
-
"@mysten/sui": "^2.16.
|
|
62
|
+
"@mysten/sui": "^2.16.3",
|
|
63
63
|
"@types/node": "^24.0.0",
|
|
64
64
|
"tsdown": "^0.22.0",
|
|
65
|
-
"tsx": "^4.
|
|
65
|
+
"tsx": "^4.22.0",
|
|
66
66
|
"typescript": "^5.9.3",
|
|
67
|
-
"vitest": "^4.1.
|
|
67
|
+
"vitest": "^4.1.6"
|
|
68
68
|
},
|
|
69
69
|
"scripts": {
|
|
70
70
|
"build": "pnpm clean && pnpm codegen && tsdown",
|