@suigar/sdk 2.0.0-beta.2 → 2.0.0-beta.20

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.
Files changed (147) hide show
  1. package/CHANGELOG.md +165 -1
  2. package/README.md +300 -59
  3. package/dist/client.d.mts +257 -0
  4. package/dist/client.d.mts.map +1 -0
  5. package/dist/client.mjs +278 -0
  6. package/dist/client.mjs.map +1 -0
  7. package/dist/configs/package.mainnet.mjs +23 -0
  8. package/dist/configs/package.mainnet.mjs.map +1 -0
  9. package/dist/configs/package.mjs +19 -0
  10. package/dist/configs/package.mjs.map +1 -0
  11. package/dist/configs/package.testnet.mjs +23 -0
  12. package/dist/configs/package.testnet.mjs.map +1 -0
  13. package/dist/configs/registry.mainnet.mjs +6 -0
  14. package/dist/configs/registry.mainnet.mjs.map +1 -0
  15. package/dist/configs/registry.mjs +11 -0
  16. package/dist/configs/registry.mjs.map +1 -0
  17. package/dist/configs/registry.testnet.mjs +6 -0
  18. package/dist/configs/registry.testnet.mjs.map +1 -0
  19. package/dist/contracts/coinflip/coinflip.mjs +46 -0
  20. package/dist/contracts/coinflip/coinflip.mjs.map +1 -0
  21. package/dist/contracts/core/core.d.mts +54 -0
  22. package/dist/contracts/core/core.d.mts.map +1 -0
  23. package/dist/contracts/core/core.mjs +22 -0
  24. package/dist/contracts/core/core.mjs.map +1 -0
  25. package/dist/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs +10 -0
  26. package/dist/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs.map +1 -0
  27. package/dist/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs +26 -0
  28. package/dist/contracts/core/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -0
  29. package/dist/contracts/core/float.d.mts +13 -0
  30. package/dist/contracts/core/float.d.mts.map +1 -0
  31. package/dist/contracts/core/float.mjs +15 -0
  32. package/dist/contracts/core/float.mjs.map +1 -0
  33. package/dist/contracts/core/i64.mjs +10 -0
  34. package/dist/contracts/core/i64.mjs.map +1 -0
  35. package/dist/contracts/limbo/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs +15 -0
  36. package/dist/contracts/limbo/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -0
  37. package/dist/contracts/limbo/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs +10 -0
  38. package/dist/contracts/limbo/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -0
  39. package/dist/contracts/limbo/limbo.mjs +53 -0
  40. package/dist/contracts/limbo/limbo.mjs.map +1 -0
  41. package/dist/contracts/plinko/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs +26 -0
  42. package/dist/contracts/plinko/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -0
  43. package/dist/contracts/plinko/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs +15 -0
  44. package/dist/contracts/plinko/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -0
  45. package/dist/contracts/plinko/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs +10 -0
  46. package/dist/contracts/plinko/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -0
  47. package/dist/contracts/plinko/plinko.mjs +59 -0
  48. package/dist/contracts/plinko/plinko.mjs.map +1 -0
  49. package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs +10 -0
  50. package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs.map +1 -0
  51. package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/balance.mjs +10 -0
  52. package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/balance.mjs.map +1 -0
  53. package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs +26 -0
  54. package/dist/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -0
  55. package/dist/contracts/pvp-coinflip/pvp_coinflip.d.mts +33 -0
  56. package/dist/contracts/pvp-coinflip/pvp_coinflip.d.mts.map +1 -0
  57. package/dist/contracts/pvp-coinflip/pvp_coinflip.mjs +131 -0
  58. package/dist/contracts/pvp-coinflip/pvp_coinflip.mjs.map +1 -0
  59. package/dist/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs +15 -0
  60. package/dist/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -0
  61. package/dist/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs +10 -0
  62. package/dist/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -0
  63. package/dist/contracts/range/range.mjs +53 -0
  64. package/dist/contracts/range/range.mjs.map +1 -0
  65. package/dist/contracts/utils/index.d.mts +68 -0
  66. package/dist/contracts/utils/index.d.mts.map +1 -0
  67. package/dist/contracts/utils/index.mjs +185 -0
  68. package/dist/contracts/utils/index.mjs.map +1 -0
  69. package/dist/contracts/wheel/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs +26 -0
  70. package/dist/contracts/wheel/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs.map +1 -0
  71. package/dist/contracts/wheel/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs +15 -0
  72. package/dist/contracts/wheel/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs.map +1 -0
  73. package/dist/contracts/wheel/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs +10 -0
  74. package/dist/contracts/wheel/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.mjs.map +1 -0
  75. package/dist/contracts/wheel/wheel.mjs +59 -0
  76. package/dist/contracts/wheel/wheel.mjs.map +1 -0
  77. package/dist/games.d.mts +3 -0
  78. package/dist/games.mjs +1 -0
  79. package/dist/helpers/config.mjs +51 -0
  80. package/dist/helpers/config.mjs.map +1 -0
  81. package/dist/helpers/game-settings.mjs +19 -0
  82. package/dist/helpers/game-settings.mjs.map +1 -0
  83. package/dist/helpers/metadata.mjs +42 -0
  84. package/dist/helpers/metadata.mjs.map +1 -0
  85. package/dist/index.d.mts +2 -0
  86. package/dist/index.mjs +2 -0
  87. package/dist/transactions/coinflip.mjs +27 -0
  88. package/dist/transactions/coinflip.mjs.map +1 -0
  89. package/dist/transactions/limbo.mjs +31 -0
  90. package/dist/transactions/limbo.mjs.map +1 -0
  91. package/dist/transactions/plinko.mjs +29 -0
  92. package/dist/transactions/plinko.mjs.map +1 -0
  93. package/dist/transactions/pvp-coinflip.mjs +70 -0
  94. package/dist/transactions/pvp-coinflip.mjs.map +1 -0
  95. package/dist/transactions/range.mjs +33 -0
  96. package/dist/transactions/range.mjs.map +1 -0
  97. package/dist/transactions/shared.mjs +49 -0
  98. package/dist/transactions/shared.mjs.map +1 -0
  99. package/dist/transactions/wheel.mjs +29 -0
  100. package/dist/transactions/wheel.mjs.map +1 -0
  101. package/dist/ttl-cache.mjs +60 -0
  102. package/dist/ttl-cache.mjs.map +1 -0
  103. package/dist/types/bet-metadata.type.d.mts +7 -0
  104. package/dist/types/bet-metadata.type.d.mts.map +1 -0
  105. package/dist/types/build-game-transaction-options.type.d.mts +9 -0
  106. package/dist/types/build-game-transaction-options.type.d.mts.map +1 -0
  107. package/dist/types/game-details.type.d.mts +72 -0
  108. package/dist/types/game-details.type.d.mts.map +1 -0
  109. package/dist/types/game-details.type.mjs +59 -0
  110. package/dist/types/game-details.type.mjs.map +1 -0
  111. package/dist/types/game-settings.type.d.mts +200 -0
  112. package/dist/types/game-settings.type.d.mts.map +1 -0
  113. package/dist/types/game-settings.type.mjs +37 -0
  114. package/dist/types/game-settings.type.mjs.map +1 -0
  115. package/dist/types/game.type.d.mts +15 -0
  116. package/dist/types/game.type.d.mts.map +1 -0
  117. package/dist/types/game.type.mjs +19 -0
  118. package/dist/types/game.type.mjs.map +1 -0
  119. package/dist/types/index.d.mts +7 -0
  120. package/dist/types/move-float.type.d.mts +7 -0
  121. package/dist/types/move-float.type.d.mts.map +1 -0
  122. package/dist/types/network.type.d.mts +1 -0
  123. package/dist/types/network.type.mjs +6 -0
  124. package/dist/types/network.type.mjs.map +1 -0
  125. package/dist/types/suigar-config.type.d.mts +33 -0
  126. package/dist/types/suigar-config.type.d.mts.map +1 -0
  127. package/dist/types/transaction-options.type.d.mts +63 -0
  128. package/dist/types/transaction-options.type.d.mts.map +1 -0
  129. package/dist/utils/constants.d.mts +8 -0
  130. package/dist/utils/constants.d.mts.map +1 -0
  131. package/dist/utils/constants.mjs +10 -0
  132. package/dist/utils/constants.mjs.map +1 -0
  133. package/dist/utils/numeric.d.mts +86 -0
  134. package/dist/utils/numeric.d.mts.map +1 -0
  135. package/dist/utils/numeric.mjs +148 -0
  136. package/dist/utils/numeric.mjs.map +1 -0
  137. package/dist/utils/parser.d.mts +54 -0
  138. package/dist/utils/parser.d.mts.map +1 -0
  139. package/dist/utils/parser.mjs +94 -0
  140. package/dist/utils/parser.mjs.map +1 -0
  141. package/dist/utils.d.mts +4 -0
  142. package/dist/utils.mjs +4 -0
  143. package/package.json +80 -82
  144. package/dist/index.cjs +0 -1016
  145. package/dist/index.d.cts +0 -267
  146. package/dist/index.d.ts +0 -267
  147. package/dist/index.js +0 -1014
@@ -0,0 +1,26 @@
1
+ import { MoveStruct } from "../../../utils/index.mjs";
2
+ import { bcs } from "@mysten/sui/bcs";
3
+ //#region src/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.ts
4
+ /**************************************************************
5
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
6
+ **************************************************************/
7
+ const $moduleName = "0x2::vec_map";
8
+ function Entry(...typeParameters) {
9
+ return new MoveStruct({
10
+ name: `${$moduleName}::Entry<${typeParameters[0].name}, ${typeParameters[1].name}>`,
11
+ fields: {
12
+ key: typeParameters[0],
13
+ value: typeParameters[1]
14
+ }
15
+ });
16
+ }
17
+ function VecMap(...typeParameters) {
18
+ return new MoveStruct({
19
+ name: `${$moduleName}::VecMap<${typeParameters[0].name}, ${typeParameters[1].name}>`,
20
+ fields: { contents: bcs.vector(Entry(typeParameters[0], typeParameters[1])) }
21
+ });
22
+ }
23
+ //#endregion
24
+ export { VecMap };
25
+
26
+ //# sourceMappingURL=vec_map.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vec_map.mjs","names":[],"sources":["../../../../../src/contracts/pvp-coinflip/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { bcs, type BcsType } from '@mysten/sui/bcs';\nimport { MoveStruct } from '../../../utils/index.js';\n\nconst $moduleName = '0x2::vec_map';\nexport function Entry<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::Entry<${typeParameters[0].name as T0['name']}, ${typeParameters[1].name as T1['name']}>`,\n\t\tfields: {\n\t\t\tkey: typeParameters[0],\n\t\t\tvalue: typeParameters[1],\n\t\t},\n\t});\n}\nexport function VecMap<T0 extends BcsType<any>, T1 extends BcsType<any>>(\n\t...typeParameters: [T0, T1]\n) {\n\treturn new MoveStruct({\n\t\tname: `${$moduleName}::VecMap<${typeParameters[0].name as T0['name']}, ${typeParameters[1].name as T1['name']}>`,\n\t\tfields: {\n\t\t\tcontents: bcs.vector(Entry(typeParameters[0], typeParameters[1])),\n\t\t},\n\t});\n}\n"],"mappings":";;;;;;AAMA,MAAM,cAAc;AACpB,SAAgB,MACf,GAAG,gBACF;CACD,OAAO,IAAI,WAAW;EACrB,MAAM,GAAG,YAAY,UAAU,eAAe,EAAE,CAAC,KAAmB,IAAI,eAAe,EAAE,CAAC,KAAmB;EAC7G,QAAQ;GACP,KAAK,eAAe;GACpB,OAAO,eAAe;EACvB;CACD,CAAC;AACF;AACA,SAAgB,OACf,GAAG,gBACF;CACD,OAAO,IAAI,WAAW;EACrB,MAAM,GAAG,YAAY,WAAW,eAAe,EAAE,CAAC,KAAmB,IAAI,eAAe,EAAE,CAAC,KAAmB;EAC9G,QAAQ,EACP,UAAU,IAAI,OAAO,MAAM,eAAe,IAAI,eAAe,EAAE,CAAC,EACjE;CACD,CAAC;AACF"}
@@ -0,0 +1,33 @@
1
+ import { MoveStruct } from "../utils/index.mjs";
2
+ import { Transaction } from "@mysten/sui/transactions";
3
+
4
+ //#region src/contracts/pvp-coinflip/pvp_coinflip.d.ts
5
+ declare const Game: MoveStruct<{
6
+ id: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
7
+ creator: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
8
+ creator_is_tails: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
9
+ is_private: import("@mysten/sui/bcs").BcsType<boolean, boolean, "bool">;
10
+ creator_metadata: MoveStruct<{
11
+ contents: import("@mysten/sui/bcs").BcsType<{
12
+ key: string;
13
+ value: number[];
14
+ }[], Iterable<{
15
+ key: string;
16
+ value: Iterable<number> & {
17
+ length: number;
18
+ };
19
+ }> & {
20
+ length: number;
21
+ }, string>;
22
+ }, "0x2::vec_map::VecMap<string, vector<u8>>">;
23
+ joiner: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
24
+ winner: import("@mysten/sui/bcs").BcsType<string, string | Uint8Array<ArrayBufferLike>, "bytes[32]">;
25
+ stake_per_player: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
26
+ house_edge_bps: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
27
+ stake_pot: MoveStruct<{
28
+ value: import("@mysten/sui/bcs").BcsType<string, string | number | bigint, "u64">;
29
+ }, "0x2::balance::Balance<phantom T0>">;
30
+ }, "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202::pvp_coinflip::Game<phantom T0>">;
31
+ //#endregion
32
+ export { Game };
33
+ //# sourceMappingURL=pvp_coinflip.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pvp_coinflip.d.mts","names":[],"sources":["../../../src/contracts/pvp-coinflip/pvp_coinflip.ts"],"mappings":";;;;cAsBa,IAAA,EAAI,UAAA"}
@@ -0,0 +1,131 @@
1
+ import { MoveStruct, normalizeMoveArguments } from "../utils/index.mjs";
2
+ import { TypeName } from "./deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.mjs";
3
+ import { Balance } from "./deps/0x0000000000000000000000000000000000000000000000000000000000000002/balance.mjs";
4
+ import { VecMap } from "./deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.mjs";
5
+ import { bcs } from "@mysten/sui/bcs";
6
+ //#region src/contracts/pvp-coinflip/pvp_coinflip.ts
7
+ /**************************************************************
8
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
9
+ **************************************************************/
10
+ const $moduleName = "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202::pvp_coinflip";
11
+ const PvpCoinflipSettingsKey = new MoveStruct({
12
+ name: `${$moduleName}::PvpCoinflipSettingsKey`,
13
+ fields: { dummy_field: bcs.bool() }
14
+ });
15
+ const Game = new MoveStruct({
16
+ name: `${$moduleName}::Game<phantom T0>`,
17
+ fields: {
18
+ id: bcs.Address,
19
+ creator: bcs.Address,
20
+ creator_is_tails: bcs.bool(),
21
+ is_private: bcs.bool(),
22
+ creator_metadata: VecMap(bcs.string(), bcs.vector(bcs.u8())),
23
+ joiner: bcs.Address,
24
+ winner: bcs.Address,
25
+ stake_per_player: bcs.u64(),
26
+ house_edge_bps: bcs.u64(),
27
+ stake_pot: Balance
28
+ }
29
+ });
30
+ const GameCreatedEvent = new MoveStruct({
31
+ name: `${$moduleName}::GameCreatedEvent<phantom T0>`,
32
+ fields: {
33
+ game_id: bcs.Address,
34
+ creator: bcs.Address,
35
+ creator_is_tails: bcs.bool(),
36
+ is_private: bcs.bool(),
37
+ joiner_is_tails: bcs.bool(),
38
+ stake_per_player: bcs.u64(),
39
+ house_edge_bps: bcs.u64(),
40
+ coin_type: TypeName
41
+ }
42
+ });
43
+ const GameResolvedEvent = new MoveStruct({
44
+ name: `${$moduleName}::GameResolvedEvent<phantom T0>`,
45
+ fields: {
46
+ game_id: bcs.Address,
47
+ creator: bcs.Address,
48
+ joiner: bcs.Address,
49
+ winner: bcs.Address,
50
+ creator_is_tails: bcs.bool(),
51
+ is_private: bcs.bool(),
52
+ joiner_is_tails: bcs.bool(),
53
+ stake_per_player: bcs.u64(),
54
+ total_pot: bcs.u64(),
55
+ house_edge_amount: bcs.u64(),
56
+ payout_amount: bcs.u64(),
57
+ coin_type: TypeName
58
+ }
59
+ });
60
+ const GameCancelledEvent = new MoveStruct({
61
+ name: `${$moduleName}::GameCancelledEvent<phantom T0>`,
62
+ fields: {
63
+ game_id: bcs.Address,
64
+ creator: bcs.Address,
65
+ creator_is_tails: bcs.bool(),
66
+ is_private: bcs.bool(),
67
+ stake_per_player: bcs.u64(),
68
+ coin_type: TypeName
69
+ }
70
+ });
71
+ const Parameters = new MoveStruct({
72
+ name: `${$moduleName}::Parameters<phantom T0>`,
73
+ fields: {
74
+ id: bcs.Address,
75
+ house_edge_bps: bcs.u64(),
76
+ min_stake: bcs.u64()
77
+ }
78
+ });
79
+ function createGame(options) {
80
+ const packageAddress = options.package ?? "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202";
81
+ const argumentsTypes = [
82
+ null,
83
+ null,
84
+ "bool",
85
+ "bool",
86
+ "vector<0x1::string::String>",
87
+ "vector<vector<u8>>"
88
+ ];
89
+ return (tx) => tx.moveCall({
90
+ package: packageAddress,
91
+ module: "pvp_coinflip",
92
+ function: "create_game",
93
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
94
+ typeArguments: options.typeArguments
95
+ });
96
+ }
97
+ function joinGame(options) {
98
+ const packageAddress = options.package ?? "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202";
99
+ const argumentsTypes = [
100
+ "0x2::object::ID",
101
+ null,
102
+ null,
103
+ "vector<0x1::string::String>",
104
+ "vector<vector<u8>>",
105
+ null,
106
+ "0x2::clock::Clock",
107
+ "0x2::random::Random"
108
+ ];
109
+ return (tx) => tx.moveCall({
110
+ package: packageAddress,
111
+ module: "pvp_coinflip",
112
+ function: "join_game",
113
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
114
+ typeArguments: options.typeArguments
115
+ });
116
+ }
117
+ function cancelGame(options) {
118
+ const packageAddress = options.package ?? "0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202";
119
+ const argumentsTypes = ["0x2::object::ID", null];
120
+ return (tx) => tx.moveCall({
121
+ package: packageAddress,
122
+ module: "pvp_coinflip",
123
+ function: "cancel_game",
124
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
125
+ typeArguments: options.typeArguments
126
+ });
127
+ }
128
+ //#endregion
129
+ export { Game, GameCancelledEvent, GameCreatedEvent, GameResolvedEvent, Parameters, PvpCoinflipSettingsKey, cancelGame, createGame, joinGame };
130
+
131
+ //# sourceMappingURL=pvp_coinflip.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pvp_coinflip.mjs","names":["vec_map.VecMap","balance.Balance","type_name.TypeName"],"sources":["../../../src/contracts/pvp-coinflip/pvp_coinflip.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { bcs } from '@mysten/sui/bcs';\nimport { type Transaction } from '@mysten/sui/transactions';\nimport {\n\tMoveStruct,\n\tnormalizeMoveArguments,\n\ttype RawTransactionArgument,\n} from '../utils/index.js';\nimport * as type_name from './deps/0x0000000000000000000000000000000000000000000000000000000000000001/type_name.js';\nimport * as balance from './deps/0x0000000000000000000000000000000000000000000000000000000000000002/balance.js';\nimport * as vec_map from './deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.js';\n\nconst $moduleName =\n\t'0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202::pvp_coinflip';\nexport const PvpCoinflipSettingsKey = new MoveStruct({\n\tname: `${$moduleName}::PvpCoinflipSettingsKey`,\n\tfields: {\n\t\tdummy_field: bcs.bool(),\n\t},\n});\nexport const Game = new MoveStruct({\n\tname: `${$moduleName}::Game<phantom T0>`,\n\tfields: {\n\t\tid: bcs.Address,\n\t\tcreator: bcs.Address,\n\t\tcreator_is_tails: bcs.bool(),\n\t\tis_private: bcs.bool(),\n\t\tcreator_metadata: vec_map.VecMap(bcs.string(), bcs.vector(bcs.u8())),\n\t\tjoiner: bcs.Address,\n\t\twinner: bcs.Address,\n\t\tstake_per_player: bcs.u64(),\n\t\thouse_edge_bps: bcs.u64(),\n\t\tstake_pot: balance.Balance,\n\t},\n});\nexport const GameCreatedEvent = new MoveStruct({\n\tname: `${$moduleName}::GameCreatedEvent<phantom T0>`,\n\tfields: {\n\t\tgame_id: bcs.Address,\n\t\tcreator: bcs.Address,\n\t\tcreator_is_tails: bcs.bool(),\n\t\tis_private: bcs.bool(),\n\t\tjoiner_is_tails: bcs.bool(),\n\t\tstake_per_player: bcs.u64(),\n\t\thouse_edge_bps: bcs.u64(),\n\t\tcoin_type: type_name.TypeName,\n\t},\n});\nexport const GameResolvedEvent = new MoveStruct({\n\tname: `${$moduleName}::GameResolvedEvent<phantom T0>`,\n\tfields: {\n\t\tgame_id: bcs.Address,\n\t\tcreator: bcs.Address,\n\t\tjoiner: bcs.Address,\n\t\twinner: bcs.Address,\n\t\tcreator_is_tails: bcs.bool(),\n\t\tis_private: bcs.bool(),\n\t\tjoiner_is_tails: bcs.bool(),\n\t\tstake_per_player: bcs.u64(),\n\t\ttotal_pot: bcs.u64(),\n\t\thouse_edge_amount: bcs.u64(),\n\t\tpayout_amount: bcs.u64(),\n\t\tcoin_type: type_name.TypeName,\n\t},\n});\nexport const GameCancelledEvent = new MoveStruct({\n\tname: `${$moduleName}::GameCancelledEvent<phantom T0>`,\n\tfields: {\n\t\tgame_id: bcs.Address,\n\t\tcreator: bcs.Address,\n\t\tcreator_is_tails: bcs.bool(),\n\t\tis_private: bcs.bool(),\n\t\tstake_per_player: bcs.u64(),\n\t\tcoin_type: type_name.TypeName,\n\t},\n});\nexport const Parameters = new MoveStruct({\n\tname: `${$moduleName}::Parameters<phantom T0>`,\n\tfields: {\n\t\tid: bcs.Address,\n\t\thouse_edge_bps: bcs.u64(),\n\t\tmin_stake: bcs.u64(),\n\t},\n});\nexport interface CreateGameOptions {\n\tpackage?: string;\n\targuments: [\n\t\tRawTransactionArgument<string>,\n\t\tRawTransactionArgument<string>,\n\t\tRawTransactionArgument<boolean>,\n\t\tRawTransactionArgument<boolean>,\n\t\tRawTransactionArgument<Array<string>>,\n\t\tRawTransactionArgument<Array<Array<number>>>,\n\t];\n\ttypeArguments: [string];\n}\nexport function createGame(options: CreateGameOptions) {\n\tconst packageAddress =\n\t\toptions.package ??\n\t\t'0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202';\n\tconst argumentsTypes = [\n\t\tnull,\n\t\tnull,\n\t\t'bool',\n\t\t'bool',\n\t\t'vector<0x1::string::String>',\n\t\t'vector<vector<u8>>',\n\t] satisfies (string | null)[];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'pvp_coinflip',\n\t\t\tfunction: 'create_game',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface JoinGameOptions {\n\tpackage?: string;\n\targuments: [\n\t\tRawTransactionArgument<string>,\n\t\tRawTransactionArgument<string>,\n\t\tRawTransactionArgument<string>,\n\t\tRawTransactionArgument<Array<string>>,\n\t\tRawTransactionArgument<Array<Array<number>>>,\n\t\tRawTransactionArgument<string>,\n\t];\n\ttypeArguments: [string];\n}\nexport function joinGame(options: JoinGameOptions) {\n\tconst packageAddress =\n\t\toptions.package ??\n\t\t'0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202';\n\tconst argumentsTypes = [\n\t\t'0x2::object::ID',\n\t\tnull,\n\t\tnull,\n\t\t'vector<0x1::string::String>',\n\t\t'vector<vector<u8>>',\n\t\tnull,\n\t\t'0x2::clock::Clock',\n\t\t'0x2::random::Random',\n\t] satisfies (string | null)[];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'pvp_coinflip',\n\t\t\tfunction: 'join_game',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\nexport interface CancelGameOptions {\n\tpackage?: string;\n\targuments: [RawTransactionArgument<string>, RawTransactionArgument<string>];\n\ttypeArguments: [string];\n}\nexport function cancelGame(options: CancelGameOptions) {\n\tconst packageAddress =\n\t\toptions.package ??\n\t\t'0xb43cf6583c0c15315c7e66f173af4be79ac40c38aad1fd92ec08638ab2026202';\n\tconst argumentsTypes = ['0x2::object::ID', null] satisfies (string | null)[];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'pvp_coinflip',\n\t\t\tfunction: 'cancel_game',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\n"],"mappings":";;;;;;;;;AAcA,MAAM,cACL;AACD,MAAa,yBAAyB,IAAI,WAAW;CACpD,MAAM,GAAG,YAAY;CACrB,QAAQ,EACP,aAAa,IAAI,KAAK,EACvB;AACD,CAAC;AACD,MAAa,OAAO,IAAI,WAAW;CAClC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,IAAI,IAAI;EACR,SAAS,IAAI;EACb,kBAAkB,IAAI,KAAK;EAC3B,YAAY,IAAI,KAAK;EACrB,kBAAkBA,OAAe,IAAI,OAAO,GAAG,IAAI,OAAO,IAAI,GAAG,CAAC,CAAC;EACnE,QAAQ,IAAI;EACZ,QAAQ,IAAI;EACZ,kBAAkB,IAAI,IAAI;EAC1B,gBAAgB,IAAI,IAAI;EACxB,WAAWC;CACZ;AACD,CAAC;AACD,MAAa,mBAAmB,IAAI,WAAW;CAC9C,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,SAAS,IAAI;EACb,SAAS,IAAI;EACb,kBAAkB,IAAI,KAAK;EAC3B,YAAY,IAAI,KAAK;EACrB,iBAAiB,IAAI,KAAK;EAC1B,kBAAkB,IAAI,IAAI;EAC1B,gBAAgB,IAAI,IAAI;EACxB,WAAWC;CACZ;AACD,CAAC;AACD,MAAa,oBAAoB,IAAI,WAAW;CAC/C,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,SAAS,IAAI;EACb,SAAS,IAAI;EACb,QAAQ,IAAI;EACZ,QAAQ,IAAI;E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UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,cAAc;EACnE,eAAe,QAAQ;CACxB,CAAC;AACH"}
@@ -0,0 +1,15 @@
1
+ import { MoveStruct } from "../../../utils/index.mjs";
2
+ import { I64 } from "./i64.mjs";
3
+ import { bcs } from "@mysten/sui/bcs";
4
+ const Float = new MoveStruct({
5
+ name: `0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float::Float`,
6
+ fields: {
7
+ is_negative: bcs.bool(),
8
+ exp: I64,
9
+ mant: bcs.u64()
10
+ }
11
+ });
12
+ //#endregion
13
+ export { Float };
14
+
15
+ //# sourceMappingURL=float.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"float.mjs","names":["i64.I64"],"sources":["../../../../../src/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { bcs } from '@mysten/sui/bcs';\nimport { MoveStruct } from '../../../utils/index.js';\nimport * as i64 from './i64.js';\n\nconst $moduleName =\n\t'0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::float';\nexport const Float = new MoveStruct({\n\tname: `${$moduleName}::Float`,\n\tfields: {\n\t\tis_negative: bcs.bool(),\n\t\texp: i64.I64,\n\t\tmant: bcs.u64(),\n\t},\n});\n"],"mappings":";;;AASA,MAAa,QAAQ,IAAI,WAAW;CACnC,MAAM;CACN,QAAQ;EACP,aAAa,IAAI,KAAK;EACtB,KAAKA;EACL,MAAM,IAAI,IAAI;CACf;AACD,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { MoveStruct } from "../../../utils/index.mjs";
2
+ import { bcs } from "@mysten/sui/bcs";
3
+ const I64 = new MoveStruct({
4
+ name: `0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64::I64`,
5
+ fields: { bits: bcs.u64() }
6
+ });
7
+ //#endregion
8
+ export { I64 };
9
+
10
+ //# sourceMappingURL=i64.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i64.mjs","names":[],"sources":["../../../../../src/contracts/range/deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/i64.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { bcs } from '@mysten/sui/bcs';\nimport { MoveStruct } from '../../../utils/index.js';\n\nconst $moduleName =\n\t'0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc::i64';\nexport const I64 = new MoveStruct({\n\tname: `${$moduleName}::I64`,\n\tfields: {\n\t\tbits: bcs.u64(),\n\t},\n});\n"],"mappings":";;AAQA,MAAa,MAAM,IAAI,WAAW;CACjC,MAAM;CACN,QAAQ,EACP,MAAM,IAAI,IAAI,EACf;AACD,CAAC"}
@@ -0,0 +1,53 @@
1
+ import { MoveStruct, normalizeMoveArguments } from "../utils/index.mjs";
2
+ import { Float } from "./deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.mjs";
3
+ import { bcs } from "@mysten/sui/bcs";
4
+ //#region src/contracts/range/range.ts
5
+ /**************************************************************
6
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
7
+ **************************************************************/
8
+ const $moduleName = "0x096a4cf18b3661e76b2c62b90785418345d52f45b272448794f123a4cb6b6416::range";
9
+ const RangeSettingsKey = new MoveStruct({
10
+ name: `${$moduleName}::RangeSettingsKey`,
11
+ fields: { dummy_field: bcs.bool() }
12
+ });
13
+ const Parameters = new MoveStruct({
14
+ name: `${$moduleName}::Parameters<phantom T0>`,
15
+ fields: {
16
+ id: bcs.Address,
17
+ min_stake: bcs.u64(),
18
+ max_stake: bcs.u64(),
19
+ min_zone_size: bcs.u64(),
20
+ max_zone_size: bcs.u64(),
21
+ max_number_of_games: bcs.u64(),
22
+ min_rtp: Float,
23
+ max_rtp: Float
24
+ }
25
+ });
26
+ function play(options) {
27
+ const packageAddress = options.package ?? "0x096a4cf18b3661e76b2c62b90785418345d52f45b272448794f123a4cb6b6416";
28
+ const argumentsTypes = [
29
+ null,
30
+ "u64",
31
+ null,
32
+ "u64",
33
+ "u64",
34
+ "u64",
35
+ "bool",
36
+ "vector<0x1::string::String>",
37
+ "vector<vector<u8>>",
38
+ null,
39
+ "0x2::clock::Clock",
40
+ "0x2::random::Random"
41
+ ];
42
+ return (tx) => tx.moveCall({
43
+ package: packageAddress,
44
+ module: "range",
45
+ function: "play",
46
+ arguments: normalizeMoveArguments(options.arguments, argumentsTypes),
47
+ typeArguments: options.typeArguments
48
+ });
49
+ }
50
+ //#endregion
51
+ export { Parameters, RangeSettingsKey, play };
52
+
53
+ //# sourceMappingURL=range.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"range.mjs","names":["float.Float"],"sources":["../../../src/contracts/range/range.ts"],"sourcesContent":["/**************************************************************\n * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *\n **************************************************************/\nimport { bcs } from '@mysten/sui/bcs';\nimport { type Transaction } from '@mysten/sui/transactions';\nimport {\n\tMoveStruct,\n\tnormalizeMoveArguments,\n\ttype RawTransactionArgument,\n} from '../utils/index.js';\nimport * as float from './deps/0xf391858d2a08473e8d4defcc8df89976bd7b123d3865c6b9341b237f7853dbbc/float.js';\n\nconst $moduleName =\n\t'0x096a4cf18b3661e76b2c62b90785418345d52f45b272448794f123a4cb6b6416::range';\nexport const RangeSettingsKey = new MoveStruct({\n\tname: `${$moduleName}::RangeSettingsKey`,\n\tfields: {\n\t\tdummy_field: bcs.bool(),\n\t},\n});\nexport const Parameters = new MoveStruct({\n\tname: `${$moduleName}::Parameters<phantom T0>`,\n\tfields: {\n\t\tid: bcs.Address,\n\t\tmin_stake: bcs.u64(),\n\t\tmax_stake: bcs.u64(),\n\t\tmin_zone_size: bcs.u64(),\n\t\tmax_zone_size: bcs.u64(),\n\t\tmax_number_of_games: bcs.u64(),\n\t\tmin_rtp: float.Float,\n\t\tmax_rtp: float.Float,\n\t},\n});\nexport interface PlayOptions {\n\tpackage?: string;\n\targuments: [\n\t\tRawTransactionArgument<string>,\n\t\tRawTransactionArgument<number | bigint>,\n\t\tRawTransactionArgument<string>,\n\t\tRawTransactionArgument<number | bigint>,\n\t\tRawTransactionArgument<number | bigint>,\n\t\tRawTransactionArgument<number | bigint>,\n\t\tRawTransactionArgument<boolean>,\n\t\tRawTransactionArgument<Array<string>>,\n\t\tRawTransactionArgument<Array<Array<number>>>,\n\t\tRawTransactionArgument<string>,\n\t];\n\ttypeArguments: [string];\n}\nexport function play(options: PlayOptions) {\n\tconst packageAddress =\n\t\toptions.package ??\n\t\t'0x096a4cf18b3661e76b2c62b90785418345d52f45b272448794f123a4cb6b6416';\n\tconst argumentsTypes = [\n\t\tnull,\n\t\t'u64',\n\t\tnull,\n\t\t'u64',\n\t\t'u64',\n\t\t'u64',\n\t\t'bool',\n\t\t'vector<0x1::string::String>',\n\t\t'vector<vector<u8>>',\n\t\tnull,\n\t\t'0x2::clock::Clock',\n\t\t'0x2::random::Random',\n\t] satisfies (string | null)[];\n\treturn (tx: Transaction) =>\n\t\ttx.moveCall({\n\t\t\tpackage: packageAddress,\n\t\t\tmodule: 'range',\n\t\t\tfunction: 'play',\n\t\t\targuments: normalizeMoveArguments(options.arguments, argumentsTypes),\n\t\t\ttypeArguments: options.typeArguments,\n\t\t});\n}\n"],"mappings":";;;;;;;AAYA,MAAM,cACL;AACD,MAAa,mBAAmB,IAAI,WAAW;CAC9C,MAAM,GAAG,YAAY;CACrB,QAAQ,EACP,aAAa,IAAI,KAAK,EACvB;AACD,CAAC;AACD,MAAa,aAAa,IAAI,WAAW;CACxC,MAAM,GAAG,YAAY;CACrB,QAAQ;EACP,IAAI,IAAI;EACR,WAAW,IAAI,IAAI;EACnB,WAAW,IAAI,IAAI;EACnB,eAAe,IAAI,IAAI;EACvB,eAAe,IAAI,IAAI;EACvB,qBAAqB,IAAI,IAAI;EAC7B,SAASA;EACT,SAASA;CACV;AACD,CAAC;AAiBD,SAAgB,KAAK,SAAsB;CAC1C,MAAM,iBACL,QAAQ,WACR;CACD,MAAM,iBAAiB;EACtB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;CACD;CACA,QAAQ,OACP,GAAG,SAAS;EACX,SAAS;EACT,QAAQ;EACR,UAAU;EACV,WAAW,uBAAuB,QAAQ,WAAW,cAAc;EACnE,eAAe,QAAQ;CACxB,CAAC;AACH"}
@@ -0,0 +1,68 @@
1
+ import { BcsStruct, BcsType } from "@mysten/sui/bcs";
2
+ import { ClientWithCoreApi, SuiClientTypes } from "@mysten/sui/client";
3
+
4
+ //#region src/contracts/utils/index.d.ts
5
+ type GetOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> = SuiClientTypes.GetObjectOptions<Include> & {
6
+ client: ClientWithCoreApi;
7
+ };
8
+ type GetManyOptions<Include extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {}> = SuiClientTypes.GetObjectsOptions<Include> & {
9
+ client: ClientWithCoreApi;
10
+ };
11
+ /** A type argument: a type tag string, or a BCS type whose name is a Move type. */
12
+ type TypeArgument = string | BcsType<any>;
13
+ interface TypeTagOptions {
14
+ package?: string;
15
+ typeArguments?: readonly TypeArgument[];
16
+ }
17
+ /**
18
+ * `typeArguments` is required when the type's name contains unfilled
19
+ * `phantom X` parameters (at any depth). Everything else — argument arity,
20
+ * position contents, and tag validity — is validated at runtime.
21
+ */
22
+ type TypeTagParams<Name extends string> = Name extends `${string}phantom ${string}` ? [options: TypeTagOptions & {
23
+ typeArguments: readonly TypeArgument[];
24
+ }] : [options?: TypeTagOptions];
25
+ type ResolveTypeTagOptions<Name extends string> = {
26
+ client: ClientWithCoreApi;
27
+ } & (Name extends `${string}phantom ${string}` ? TypeTagOptions & {
28
+ typeArguments: readonly TypeArgument[];
29
+ } : TypeTagOptions);
30
+ declare class MoveStruct<T extends Record<string, BcsType<any>>, const Name extends string = string> extends BcsStruct<T, Name> {
31
+ /**
32
+ * Build the type tag for this struct.
33
+ *
34
+ * `typeArguments` is the full positional list, in Move declaration order, and
35
+ * is required when the struct has unfilled phantom parameters. The result may
36
+ * contain MVR names: those are valid in transaction `typeArguments`, but for
37
+ * queries or comparisons against on-chain data use `resolveTypeTag` instead.
38
+ */
39
+ typeTag(...args: TypeTagParams<Name>): string;
40
+ /**
41
+ * Build the type tag for this struct, then resolve any MVR names through the
42
+ * client (using its configured overrides and the MVR API) and return the
43
+ * normalized, address-only form suitable for queries and comparisons against
44
+ * on-chain data.
45
+ */
46
+ resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string>;
47
+ get<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({
48
+ objectId,
49
+ ...options
50
+ }: GetOptions<Include>): Promise<SuiClientTypes.Object<Include & {
51
+ content: true;
52
+ json: true;
53
+ }> & {
54
+ json: BcsStruct<T>['$inferType'];
55
+ }>;
56
+ getMany<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({
57
+ client,
58
+ ...options
59
+ }: GetManyOptions<Include>): Promise<Array<SuiClientTypes.Object<Include & {
60
+ content: true;
61
+ json: true;
62
+ }> & {
63
+ json: BcsStruct<T>['$inferType'];
64
+ }>>;
65
+ }
66
+ //#endregion
67
+ export { MoveStruct };
68
+ //# sourceMappingURL=index.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../../src/contracts/utils/index.ts"],"mappings":";;;;KAqBY,UAAA,iBACK,IAAA,CAAK,cAAA,CAAe,aAAA,qBACjC,cAAA,CAAe,gBAAA,CAAiB,OAAA;EAAa,MAAA,EAAQ,iBAAA;AAAA;AAAA,KAE7C,cAAA,iBACK,IAAA,CAAK,cAAA,CAAe,aAAA,qBACjC,cAAA,CAAe,iBAAA,CAAkB,OAAA;EAAa,MAAA,EAAQ,iBAAA;AAAA;;KAiJ9C,YAAA,YAAwB,OAAO;AAAA,UAE1B,cAAA;EAChB,OAAA;EACA,aAAA,YAAyB,YAAY;AAAA;;;;;;KAQjC,aAAA,wBACJ,IAAA,yCACI,OAAA,EAAS,cAAA;EAAmB,aAAA,WAAwB,YAAA;AAAA,MACpD,OAAA,GAAU,cAAA;AAAA,KAEV,qBAAA;EACJ,MAAA,EAAQ,iBAAA;AAAA,KACJ,IAAA,wCACF,cAAA;EAAmB,aAAA,WAAwB,YAAA;AAAA,IAC3C,cAAA;AAAA,cA6FU,UAAA,WACF,MAAA,SAAe,OAAA,oDAEhB,SAAA,CAAU,CAAA,EAAG,IAAA;EAtQnB;;;;;;;;EA+QH,OAAA,IAAW,IAAA,EAAM,aAAA,CAAc,IAAA;EA/Qb;;;;;AAAwD;EAyRpE,cAAA,CAAe,OAAA,EAAS,qBAAA,CAAsB,IAAA,IAAQ,OAAA;EAOtD,GAAA,iBACW,IAAA,CAAK,cAAA,CAAe,aAAA;IAEpC,QAAA;IAAA,GACG;EAAA,GACD,UAAA,CAAW,OAAA,IAAW,OAAA,CACxB,cAAA,CAAe,MAAA,CAAO,OAAA;IAAY,OAAA;IAAe,IAAA;EAAA;IAChD,IAAA,EAAM,SAAA,CAAU,CAAA;EAAA;EAeZ,OAAA,iBACW,IAAA,CAAK,cAAA,CAAe,aAAA;IAEpC,MAAA;IAAA,GACG;EAAA,GACD,cAAA,CAAe,OAAA,IAAW,OAAA,CAC5B,KAAA,CACC,cAAA,CAAe,MAAA,CAAO,OAAA;IAAY,OAAA;IAAe,IAAA;EAAA;IAChD,IAAA,EAAM,SAAA,CAAU,CAAA;EAAA;AAAA"}
@@ -0,0 +1,185 @@
1
+ import { normalizeStructTag, normalizeSuiAddress } from "@mysten/sui/utils";
2
+ import { BcsStruct, TypeTagSerializer, bcs } from "@mysten/sui/bcs";
3
+ import { isArgument } from "@mysten/sui/transactions";
4
+ //#region src/contracts/utils/index.ts
5
+ const MOVE_STDLIB_ADDRESS = normalizeSuiAddress("0x1");
6
+ const SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress("0x2");
7
+ function getPureBcsSchema(typeTag) {
8
+ const parsedTag = typeof typeTag === "string" ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;
9
+ if ("u8" in parsedTag) return bcs.U8;
10
+ else if ("u16" in parsedTag) return bcs.U16;
11
+ else if ("u32" in parsedTag) return bcs.U32;
12
+ else if ("u64" in parsedTag) return bcs.U64;
13
+ else if ("u128" in parsedTag) return bcs.U128;
14
+ else if ("u256" in parsedTag) return bcs.U256;
15
+ else if ("address" in parsedTag) return bcs.Address;
16
+ else if ("bool" in parsedTag) return bcs.Bool;
17
+ else if ("vector" in parsedTag) {
18
+ const type = getPureBcsSchema(parsedTag.vector);
19
+ return type ? bcs.vector(type) : null;
20
+ } else if ("struct" in parsedTag) {
21
+ const structTag = parsedTag.struct;
22
+ const pkg = normalizeSuiAddress(structTag.address);
23
+ if (pkg === MOVE_STDLIB_ADDRESS) {
24
+ if ((structTag.module === "ascii" || structTag.module === "string") && structTag.name === "String") return bcs.String;
25
+ if (structTag.module === "option" && structTag.name === "Option") {
26
+ const inner = structTag.typeParams[0];
27
+ const type = inner ? getPureBcsSchema(inner) : null;
28
+ return type ? bcs.option(type) : null;
29
+ }
30
+ }
31
+ if (pkg === SUI_FRAMEWORK_ADDRESS && structTag.module === "object" && (structTag.name === "ID" || structTag.name === "UID")) return bcs.Address;
32
+ }
33
+ return null;
34
+ }
35
+ function normalizeMoveArguments(args, argTypes, parameterNames) {
36
+ const argLen = Array.isArray(args) ? args.length : Object.keys(args).length;
37
+ if (parameterNames && argLen !== parameterNames.length) throw new Error(`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`);
38
+ const normalizedArgs = [];
39
+ let index = 0;
40
+ for (const argType of argTypes) {
41
+ if (argType === "0x2::clock::Clock") {
42
+ normalizedArgs.push((tx) => tx.object.clock());
43
+ continue;
44
+ }
45
+ if (argType === "0x2::random::Random") {
46
+ normalizedArgs.push((tx) => tx.object.random());
47
+ continue;
48
+ }
49
+ if (argType === "0x2::deny_list::DenyList") {
50
+ normalizedArgs.push((tx) => tx.object.denyList());
51
+ continue;
52
+ }
53
+ if (argType === "0x3::sui_system::SuiSystemState") {
54
+ normalizedArgs.push((tx) => tx.object.system());
55
+ continue;
56
+ }
57
+ let arg;
58
+ if (Array.isArray(args)) {
59
+ if (index >= args.length) throw new Error(`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`);
60
+ arg = args[index];
61
+ } else {
62
+ if (!parameterNames) throw new Error(`Expected arguments to be passed as an array`);
63
+ const name = parameterNames[index];
64
+ arg = args[name];
65
+ if (arg === void 0) throw new Error(`Parameter ${name} is required`);
66
+ }
67
+ index += 1;
68
+ if (typeof arg === "function" || isArgument(arg)) {
69
+ normalizedArgs.push(arg);
70
+ continue;
71
+ }
72
+ const bcsType = argType === null ? null : getPureBcsSchema(argType);
73
+ if (bcsType) {
74
+ const bytes = bcsType.serialize(arg);
75
+ normalizedArgs.push((tx) => tx.pure(bytes));
76
+ continue;
77
+ }
78
+ if (typeof arg === "string") {
79
+ normalizedArgs.push((tx) => tx.object(arg));
80
+ continue;
81
+ }
82
+ throw new Error(`Invalid argument ${stringify(arg)} for type ${argType}`);
83
+ }
84
+ return normalizedArgs;
85
+ }
86
+ const HAS_PHANTOM_REGEX = /phantom [A-Za-z_$][A-Za-z0-9_$]*/;
87
+ function splitTopLevelTypeArgs(inner) {
88
+ const parts = [];
89
+ let depth = 0;
90
+ let current = "";
91
+ for (const char of inner) {
92
+ if (char === "," && depth === 0) {
93
+ parts.push(current.trim());
94
+ current = "";
95
+ continue;
96
+ }
97
+ if (char === "<") depth++;
98
+ if (char === ">") depth--;
99
+ current += char;
100
+ }
101
+ if (current) parts.push(current.trim());
102
+ return parts;
103
+ }
104
+ function buildTypeTag(name, options) {
105
+ const lt = name.indexOf("<");
106
+ const base = lt === -1 ? name : name.slice(0, lt);
107
+ if (base.split("::").length !== 3) throw new Error(`${name} is not a top-level Move type`);
108
+ let result = name;
109
+ if (options?.typeArguments) {
110
+ const baked = lt === -1 ? [] : splitTopLevelTypeArgs(name.slice(lt + 1, -1));
111
+ const supplied = options.typeArguments.map((arg) => {
112
+ if (typeof arg === "string") return arg;
113
+ if (arg && typeof arg.serialize === "function" && typeof arg.name === "string") return arg.name;
114
+ throw new Error(`Invalid type argument ${stringify(arg)}`);
115
+ });
116
+ if (supplied.length !== baked.length) throw new Error(`Expected ${baked.length} type arguments for ${base}, got ${supplied.length}`);
117
+ result = supplied.length === 0 ? base : `${base}<${supplied.join(", ")}>`;
118
+ }
119
+ if (HAS_PHANTOM_REGEX.test(result)) throw new Error(options?.typeArguments ? `A type argument contains an unfilled phantom parameter in ${result}` : `Missing type arguments for ${result}`);
120
+ if (options?.package) {
121
+ const [, ...rest] = result.split("::");
122
+ result = [options.package, ...rest].join("::");
123
+ }
124
+ if (!HAS_PHANTOM_REGEX.test(result) && !/[@/]/.test(result)) TypeTagSerializer.parseFromStr(result);
125
+ return result;
126
+ }
127
+ async function resolveBuiltTypeTag(name, options) {
128
+ const { client, ...rest } = options;
129
+ const { type } = await client.core.mvr.resolveType({ type: buildTypeTag(name, rest) });
130
+ return normalizeStructTag(type);
131
+ }
132
+ var MoveStruct = class extends BcsStruct {
133
+ /**
134
+ * Build the type tag for this struct.
135
+ *
136
+ * `typeArguments` is the full positional list, in Move declaration order, and
137
+ * is required when the struct has unfilled phantom parameters. The result may
138
+ * contain MVR names: those are valid in transaction `typeArguments`, but for
139
+ * queries or comparisons against on-chain data use `resolveTypeTag` instead.
140
+ */
141
+ typeTag(...args) {
142
+ return buildTypeTag(this.name, args[0]);
143
+ }
144
+ /**
145
+ * Build the type tag for this struct, then resolve any MVR names through the
146
+ * client (using its configured overrides and the MVR API) and return the
147
+ * normalized, address-only form suitable for queries and comparisons against
148
+ * on-chain data.
149
+ */
150
+ async resolveTypeTag(options) {
151
+ return resolveBuiltTypeTag(this.name, options);
152
+ }
153
+ async get({ objectId, ...options }) {
154
+ const [res] = await this.getMany({
155
+ ...options,
156
+ objectIds: [objectId]
157
+ });
158
+ if (!res) throw new Error(`No object found for id ${objectId}`);
159
+ return res;
160
+ }
161
+ async getMany({ client, ...options }) {
162
+ return (await client.core.getObjects({
163
+ ...options,
164
+ include: {
165
+ ...options.include,
166
+ content: true
167
+ }
168
+ })).objects.map((obj) => {
169
+ if (obj instanceof Error) throw obj;
170
+ return {
171
+ ...obj,
172
+ json: this.parse(obj.content)
173
+ };
174
+ });
175
+ }
176
+ };
177
+ function stringify(val) {
178
+ if (typeof val === "object") return JSON.stringify(val, (_key, value) => typeof value === "bigint" ? value.toString() : value);
179
+ if (typeof val === "bigint") return val.toString();
180
+ return val;
181
+ }
182
+ //#endregion
183
+ export { MoveStruct, normalizeMoveArguments };
184
+
185
+ //# sourceMappingURL=index.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../src/contracts/utils/index.ts"],"sourcesContent":["import {\n\tbcs,\n\tBcsEnum,\n\tBcsStruct,\n\tBcsTuple,\n\tTypeTagSerializer,\n\ttype BcsType,\n\ttype TypeTag,\n} from '@mysten/sui/bcs';\nimport {\n\ttype ClientWithCoreApi,\n\ttype SuiClientTypes,\n} from '@mysten/sui/client';\nimport { isArgument, type TransactionArgument } from '@mysten/sui/transactions';\nimport { normalizeStructTag, normalizeSuiAddress } from '@mysten/sui/utils';\n\nconst MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');\nconst SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');\n\nexport type RawTransactionArgument<T> = T | TransactionArgument;\n\nexport type GetOptions<\n\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {},\n> = SuiClientTypes.GetObjectOptions<Include> & { client: ClientWithCoreApi };\n\nexport type GetManyOptions<\n\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {},\n> = SuiClientTypes.GetObjectsOptions<Include> & { client: ClientWithCoreApi };\n\nexport function getPureBcsSchema(\n\ttypeTag: string | TypeTag,\n): BcsType<any> | null {\n\tconst parsedTag =\n\t\ttypeof typeTag === 'string'\n\t\t\t? TypeTagSerializer.parseFromStr(typeTag)\n\t\t\t: typeTag;\n\n\tif ('u8' in parsedTag) {\n\t\treturn bcs.U8;\n\t} else if ('u16' in parsedTag) {\n\t\treturn bcs.U16;\n\t} else if ('u32' in parsedTag) {\n\t\treturn bcs.U32;\n\t} else if ('u64' in parsedTag) {\n\t\treturn bcs.U64;\n\t} else if ('u128' in parsedTag) {\n\t\treturn bcs.U128;\n\t} else if ('u256' in parsedTag) {\n\t\treturn bcs.U256;\n\t} else if ('address' in parsedTag) {\n\t\treturn bcs.Address;\n\t} else if ('bool' in parsedTag) {\n\t\treturn bcs.Bool;\n\t} else if ('vector' in parsedTag) {\n\t\tconst type = getPureBcsSchema(parsedTag.vector);\n\t\treturn type ? bcs.vector(type) : null;\n\t} else if ('struct' in parsedTag) {\n\t\tconst structTag = parsedTag.struct;\n\t\tconst pkg = normalizeSuiAddress(structTag.address);\n\n\t\tif (pkg === MOVE_STDLIB_ADDRESS) {\n\t\t\tif (\n\t\t\t\t(structTag.module === 'ascii' || structTag.module === 'string') &&\n\t\t\t\tstructTag.name === 'String'\n\t\t\t) {\n\t\t\t\treturn bcs.String;\n\t\t\t}\n\n\t\t\tif (structTag.module === 'option' && structTag.name === 'Option') {\n\t\t\t\tconst inner = structTag.typeParams[0];\n\t\t\t\tconst type = inner ? getPureBcsSchema(inner) : null;\n\t\t\t\treturn type ? bcs.option(type) : null;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tpkg === SUI_FRAMEWORK_ADDRESS &&\n\t\t\tstructTag.module === 'object' &&\n\t\t\t(structTag.name === 'ID' || structTag.name === 'UID')\n\t\t) {\n\t\t\treturn bcs.Address;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function normalizeMoveArguments(\n\targs: unknown[] | object,\n\targTypes: readonly (string | null)[],\n\tparameterNames?: string[],\n) {\n\tconst argLen = Array.isArray(args) ? args.length : Object.keys(args).length;\n\tif (parameterNames && argLen !== parameterNames.length) {\n\t\tthrow new Error(\n\t\t\t`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`,\n\t\t);\n\t}\n\n\tconst normalizedArgs: TransactionArgument[] = [];\n\n\tlet index = 0;\n\tfor (const argType of argTypes) {\n\t\tif (argType === '0x2::clock::Clock') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.clock());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::random::Random') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.random());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::deny_list::DenyList') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.denyList());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x3::sui_system::SuiSystemState') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.system());\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet arg;\n\t\tif (Array.isArray(args)) {\n\t\t\tif (index >= args.length) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\targ = args[index];\n\t\t} else {\n\t\t\tif (!parameterNames) {\n\t\t\t\tthrow new Error(`Expected arguments to be passed as an array`);\n\t\t\t}\n\t\t\tconst name = parameterNames[index];\n\t\t\targ = args[name as keyof typeof args];\n\n\t\t\tif (arg === undefined) {\n\t\t\t\tthrow new Error(`Parameter ${name} is required`);\n\t\t\t}\n\t\t}\n\n\t\tindex += 1;\n\n\t\tif (typeof arg === 'function' || isArgument(arg)) {\n\t\t\tnormalizedArgs.push(arg as TransactionArgument);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst bcsType = argType === null ? null : getPureBcsSchema(argType);\n\n\t\tif (bcsType) {\n\t\t\tconst bytes = bcsType.serialize(arg as never);\n\t\t\tnormalizedArgs.push((tx) => tx.pure(bytes));\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (typeof arg === 'string') {\n\t\t\tnormalizedArgs.push((tx) => tx.object(arg));\n\t\t\tcontinue;\n\t\t}\n\n\t\tthrow new Error(`Invalid argument ${stringify(arg)} for type ${argType}`);\n\t}\n\n\treturn normalizedArgs;\n}\n\n/* -------------------------- Move type tags -------------------------- */\n\n/** A type argument: a type tag string, or a BCS type whose name is a Move type. */\nexport type TypeArgument = string | BcsType<any>;\n\nexport interface TypeTagOptions {\n\tpackage?: string;\n\ttypeArguments?: readonly TypeArgument[];\n}\n\n/**\n * `typeArguments` is required when the type's name contains unfilled\n * `phantom X` parameters (at any depth). Everything else — argument arity,\n * position contents, and tag validity — is validated at runtime.\n */\ntype TypeTagParams<Name extends string> =\n\tName extends `${string}phantom ${string}`\n\t\t? [options: TypeTagOptions & { typeArguments: readonly TypeArgument[] }]\n\t\t: [options?: TypeTagOptions];\n\ntype ResolveTypeTagOptions<Name extends string> = {\n\tclient: ClientWithCoreApi;\n} & (Name extends `${string}phantom ${string}`\n\t? TypeTagOptions & { typeArguments: readonly TypeArgument[] }\n\t: TypeTagOptions);\n\nconst HAS_PHANTOM_REGEX = /phantom [A-Za-z_$][A-Za-z0-9_$]*/;\n\nfunction splitTopLevelTypeArgs(inner: string): string[] {\n\tconst parts: string[] = [];\n\tlet depth = 0;\n\tlet current = '';\n\tfor (const char of inner) {\n\t\tif (char === ',' && depth === 0) {\n\t\t\tparts.push(current.trim());\n\t\t\tcurrent = '';\n\t\t\tcontinue;\n\t\t}\n\t\tif (char === '<') depth++;\n\t\tif (char === '>') depth--;\n\t\tcurrent += char;\n\t}\n\tif (current) parts.push(current.trim());\n\treturn parts;\n}\n\nfunction buildTypeTag(\n\tname: string,\n\toptions: TypeTagOptions | undefined,\n): string {\n\tconst lt = name.indexOf('<');\n\tconst base = lt === -1 ? name : name.slice(0, lt);\n\n\tif (base.split('::').length !== 3) {\n\t\tthrow new Error(`${name} is not a top-level Move type`);\n\t}\n\n\tlet result = name;\n\n\tif (options?.typeArguments) {\n\t\tconst baked =\n\t\t\tlt === -1 ? [] : splitTopLevelTypeArgs(name.slice(lt + 1, -1));\n\t\tconst supplied = options.typeArguments.map((arg) => {\n\t\t\tif (typeof arg === 'string') {\n\t\t\t\treturn arg;\n\t\t\t}\n\t\t\tif (\n\t\t\t\targ &&\n\t\t\t\ttypeof arg.serialize === 'function' &&\n\t\t\t\ttypeof arg.name === 'string'\n\t\t\t) {\n\t\t\t\treturn arg.name;\n\t\t\t}\n\t\t\tthrow new Error(`Invalid type argument ${stringify(arg)}`);\n\t\t});\n\n\t\tif (supplied.length !== baked.length) {\n\t\t\tthrow new Error(\n\t\t\t\t`Expected ${baked.length} type arguments for ${base}, got ${supplied.length}`,\n\t\t\t);\n\t\t}\n\n\t\tresult = supplied.length === 0 ? base : `${base}<${supplied.join(', ')}>`;\n\t}\n\n\tif (HAS_PHANTOM_REGEX.test(result)) {\n\t\tthrow new Error(\n\t\t\toptions?.typeArguments\n\t\t\t\t? `A type argument contains an unfilled phantom parameter in ${result}`\n\t\t\t\t: `Missing type arguments for ${result}`,\n\t\t);\n\t}\n\n\tif (options?.package) {\n\t\tconst [, ...rest] = result.split('::');\n\t\tresult = [options.package, ...rest].join('::');\n\t}\n\n\t// fully validate address-only tags (MVR names can't be parsed as type tags)\n\tif (!HAS_PHANTOM_REGEX.test(result) && !/[@/]/.test(result)) {\n\t\tTypeTagSerializer.parseFromStr(result);\n\t}\n\n\treturn result;\n}\n\nasync function resolveBuiltTypeTag(\n\tname: string,\n\toptions: { client: ClientWithCoreApi } & TypeTagOptions,\n): Promise<string> {\n\tconst { client, ...rest } = options;\n\tconst { type } = await client.core.mvr.resolveType({\n\t\ttype: buildTypeTag(name, rest),\n\t});\n\treturn normalizeStructTag(type);\n}\n\nexport class MoveStruct<\n\tT extends Record<string, BcsType<any>>,\n\tconst Name extends string = string,\n> extends BcsStruct<T, Name> {\n\t/**\n\t * Build the type tag for this struct.\n\t *\n\t * `typeArguments` is the full positional list, in Move declaration order, and\n\t * is required when the struct has unfilled phantom parameters. The result may\n\t * contain MVR names: those are valid in transaction `typeArguments`, but for\n\t * queries or comparisons against on-chain data use `resolveTypeTag` instead.\n\t */\n\ttypeTag(...args: TypeTagParams<Name>): string {\n\t\treturn buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);\n\t}\n\n\t/**\n\t * Build the type tag for this struct, then resolve any MVR names through the\n\t * client (using its configured overrides and the MVR API) and return the\n\t * normalized, address-only form suitable for queries and comparisons against\n\t * on-chain data.\n\t */\n\tasync resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {\n\t\treturn resolveBuiltTypeTag(\n\t\t\tthis.name,\n\t\t\toptions as { client: ClientWithCoreApi } & TypeTagOptions,\n\t\t);\n\t}\n\n\tasync get<\n\t\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {},\n\t>({\n\t\tobjectId,\n\t\t...options\n\t}: GetOptions<Include>): Promise<\n\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t}\n\t> {\n\t\tconst [res] = await this.getMany<Include>({\n\t\t\t...options,\n\t\t\tobjectIds: [objectId],\n\t\t});\n\n\t\tif (!res) {\n\t\t\tthrow new Error(`No object found for id ${objectId}`);\n\t\t}\n\n\t\treturn res;\n\t}\n\n\tasync getMany<\n\t\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {},\n\t>({\n\t\tclient,\n\t\t...options\n\t}: GetManyOptions<Include>): Promise<\n\t\tArray<\n\t\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t\t}\n\t\t>\n\t> {\n\t\tconst response = (await client.core.getObjects({\n\t\t\t...options,\n\t\t\tinclude: {\n\t\t\t\t...options.include,\n\t\t\t\tcontent: true,\n\t\t\t},\n\t\t})) as SuiClientTypes.GetObjectsResponse<Include & { content: true }>;\n\n\t\treturn response.objects.map((obj) => {\n\t\t\tif (obj instanceof Error) {\n\t\t\t\tthrow obj;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...obj,\n\t\t\t\tjson: this.parse(obj.content),\n\t\t\t};\n\t\t});\n\t}\n}\n\nexport class MoveEnum<\n\tT extends Record<string, BcsType<any> | null>,\n\tconst Name extends string,\n> extends BcsEnum<T, Name> {\n\t/** Build the type tag for this enum. See `MoveStruct.typeTag` for semantics. */\n\ttypeTag(...args: TypeTagParams<Name>): string {\n\t\treturn buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);\n\t}\n\n\t/** Build and resolve the type tag for this enum. See `MoveStruct.resolveTypeTag`. */\n\tasync resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {\n\t\treturn resolveBuiltTypeTag(\n\t\t\tthis.name,\n\t\t\toptions as { client: ClientWithCoreApi } & TypeTagOptions,\n\t\t);\n\t}\n}\n\nexport class MoveTuple<\n\tconst T extends readonly BcsType<any>[],\n\tconst Name extends string,\n> extends BcsTuple<T, Name> {\n\t/** Build the type tag for this struct. See `MoveStruct.typeTag` for semantics. */\n\ttypeTag(...args: TypeTagParams<Name>): string {\n\t\treturn buildTypeTag(this.name, args[0] as TypeTagOptions | undefined);\n\t}\n\n\t/** Build and resolve the type tag for this struct. See `MoveStruct.resolveTypeTag`. */\n\tasync resolveTypeTag(options: ResolveTypeTagOptions<Name>): Promise<string> {\n\t\treturn resolveBuiltTypeTag(\n\t\t\tthis.name,\n\t\t\toptions as { client: ClientWithCoreApi } & TypeTagOptions,\n\t\t);\n\t}\n}\n\nfunction stringify(val: unknown) {\n\tif (typeof val === 'object') {\n\t\treturn JSON.stringify(val, (_key, value) =>\n\t\t\ttypeof value === 'bigint' ? value.toString() : value,\n\t\t);\n\t}\n\tif (typeof val === 'bigint') {\n\t\treturn val.toString();\n\t}\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UAAU,MAAM,MAAM,UACjC,OAAO,UAAU,WAAW,MAAM,SAAS,IAAI,KAChD;CAED,IAAI,OAAO,QAAQ,UAClB,OAAO,IAAI,SAAS;CAGrB,OAAO;AACR"}
@@ -0,0 +1,26 @@
1
+ import { MoveStruct } from "../../../utils/index.mjs";
2
+ import { bcs } from "@mysten/sui/bcs";
3
+ //#region src/contracts/wheel/deps/0x0000000000000000000000000000000000000000000000000000000000000002/vec_map.ts
4
+ /**************************************************************
5
+ * THIS FILE IS GENERATED AND SHOULD NOT BE MANUALLY MODIFIED *
6
+ **************************************************************/
7
+ const $moduleName = "0x2::vec_map";
8
+ function Entry(...typeParameters) {
9
+ return new MoveStruct({
10
+ name: `${$moduleName}::Entry<${typeParameters[0].name}, ${typeParameters[1].name}>`,
11
+ fields: {
12
+ key: typeParameters[0],
13
+ value: typeParameters[1]
14
+ }
15
+ });
16
+ }
17
+ function VecMap(...typeParameters) {
18
+ return new MoveStruct({
19
+ name: `${$moduleName}::VecMap<${typeParameters[0].name}, ${typeParameters[1].name}>`,
20
+ fields: { contents: bcs.vector(Entry(typeParameters[0], typeParameters[1])) }
21
+ });
22
+ }
23
+ //#endregion
24
+ export { VecMap };
25
+
26
+ //# sourceMappingURL=vec_map.mjs.map