@typus/typus-sdk 1.4.8 → 1.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.json +19 -14
- package/dist/src/dice/api.d.ts +1 -0
- package/dist/src/{tails-exp-dice → dice}/api.js +8 -3
- package/dist/src/{tails-exp-dice → dice}/fetch.d.ts +15 -12
- package/dist/src/{tails-exp-dice → dice}/fetch.js +48 -148
- package/dist/src/{tails-exp-dice → dice}/user-entry.d.ts +4 -4
- package/dist/src/{tails-exp-dice → dice}/user-entry.js +26 -11
- package/dist/src/dice/view-function.d.ts +8 -0
- package/dist/src/{tails-exp-dice → dice}/view-function.js +3 -3
- package/dist/src/{leaderboard → typus/leaderboard}/view-function.js +2 -2
- package/dist/src/{tails-staking → typus/tails-staking}/user-entry.js +1 -1
- package/dist/src/{tails-staking → typus/tails-staking}/view-function.js +2 -2
- package/dist/src/typus-dov-single-v2/{entry/authority-entry.js → authority-entry.js} +1 -1
- package/dist/src/typus-dov-single-v2/function/bidding.d.ts +2 -2
- package/dist/src/typus-dov-single-v2/function/bidding.js +21 -23
- package/dist/src/typus-dov-single-v2/function/vault.js +2 -2
- package/dist/src/typus-dov-single-v2/history/user-history.js +43 -43
- package/dist/src/typus-dov-single-v2/history/vault-history.js +11 -11
- package/dist/src/typus-dov-single-v2/index.d.ts +3 -1
- package/dist/src/typus-dov-single-v2/index.js +3 -1
- package/dist/src/typus-dov-single-v2/{entry/mfud-user-entry.js → token-user-entry.js} +1 -1
- package/dist/src/typus-dov-single-v2/{entry/user-entry.js → user-entry.js} +1 -1
- package/dist/src/typus-dov-single-v2/view-function.js +8 -8
- package/dist/src/typus-nft/fetch.js +1 -0
- package/dist/src/typus-perp/fetch.d.ts +10 -10
- package/dist/src/typus-perp/fetch.js +20 -21
- package/dist/src/typus-perp/readVec.js +6 -6
- package/dist/src/typus-perp/user/order.d.ts +10 -10
- package/dist/src/typus-perp/user/order.js +31 -32
- package/dist/src/typus-perp/user/orderWithBidReceipt.d.ts +6 -6
- package/dist/src/typus-perp/user/orderWithBidReceipt.js +15 -17
- package/dist/src/typus-perp/user/tlp.d.ts +12 -13
- package/dist/src/typus-perp/user/tlp.js +38 -41
- package/dist/src/typus-safu/index.d.ts +3 -0
- package/dist/src/typus-safu/index.js +20 -0
- package/dist/src/typus-safu/user-entry.d.ts +84 -0
- package/dist/src/typus-safu/user-entry.js +158 -0
- package/dist/src/typus-safu/view-function.d.ts +31 -0
- package/dist/src/typus-safu/view-function.js +147 -0
- package/dist/src/utils/api/sentio/reward-generated.js +3 -3
- package/dist/src/utils/index.d.ts +1 -0
- package/dist/src/utils/index.js +1 -0
- package/dist/src/utils/pyth/constant.js +1 -1
- package/dist/src/utils/pyth/pythClient.d.ts +1 -1
- package/dist/src/utils/pyth/pythClient.js +1 -1
- package/dist/src/utils/typusConfig.d.ts +93 -0
- package/dist/src/utils/typusConfig.js +21 -0
- package/package.json +4 -1
- package/dist/src/index.d.ts +0 -11
- package/dist/src/index.js +0 -27
- package/dist/src/tails-exp-dice/api.d.ts +0 -1
- package/dist/src/tails-exp-dice/view-function.d.ts +0 -8
- package/dist/src/typus-dov-single-v2/entry/index.d.ts +0 -3
- package/dist/src/typus-dov-single-v2/entry/index.js +0 -19
- /package/dist/src/{tails-exp-dice → dice}/index.d.ts +0 -0
- /package/dist/src/{tails-exp-dice → dice}/index.js +0 -0
- /package/dist/src/{airdrop → typus/airdrop}/authority-entry.d.ts +0 -0
- /package/dist/src/{airdrop → typus/airdrop}/authority-entry.js +0 -0
- /package/dist/src/{airdrop → typus/airdrop}/index.d.ts +0 -0
- /package/dist/src/{airdrop → typus/airdrop}/index.js +0 -0
- /package/dist/src/{airdrop → typus/airdrop}/user-entry.d.ts +0 -0
- /package/dist/src/{airdrop → typus/airdrop}/user-entry.js +0 -0
- /package/dist/src/{airdrop → typus/airdrop}/view-function.d.ts +0 -0
- /package/dist/src/{airdrop → typus/airdrop}/view-function.js +0 -0
- /package/dist/src/{leaderboard → typus/leaderboard}/authority-entry.d.ts +0 -0
- /package/dist/src/{leaderboard → typus/leaderboard}/authority-entry.js +0 -0
- /package/dist/src/{leaderboard → typus/leaderboard}/index.d.ts +0 -0
- /package/dist/src/{leaderboard → typus/leaderboard}/index.js +0 -0
- /package/dist/src/{leaderboard → typus/leaderboard}/view-function.d.ts +0 -0
- /package/dist/src/{tails-staking → typus/tails-staking}/authority-entry.d.ts +0 -0
- /package/dist/src/{tails-staking → typus/tails-staking}/authority-entry.js +0 -0
- /package/dist/src/{tails-staking → typus/tails-staking}/index.d.ts +0 -0
- /package/dist/src/{tails-staking → typus/tails-staking}/index.js +0 -0
- /package/dist/src/{tails-staking → typus/tails-staking}/user-entry.d.ts +0 -0
- /package/dist/src/{tails-staking → typus/tails-staking}/view-function.d.ts +0 -0
- /package/dist/src/{user → typus/user}/index.d.ts +0 -0
- /package/dist/src/{user → typus/user}/index.js +0 -0
- /package/dist/src/{user → typus/user}/view-function.d.ts +0 -0
- /package/dist/src/{user → typus/user}/view-function.js +0 -0
- /package/dist/src/typus-dov-single-v2/{entry/authority-entry.d.ts → authority-entry.d.ts} +0 -0
- /package/dist/src/typus-dov-single-v2/{entry/mfud-user-entry.d.ts → token-user-entry.d.ts} +0 -0
- /package/dist/src/typus-dov-single-v2/{entry/user-entry.d.ts → user-entry.d.ts} +0 -0
package/dist/config.json
CHANGED
|
@@ -4,32 +4,36 @@
|
|
|
4
4
|
"PACKAGE_ORIGIN": {
|
|
5
5
|
"DOV_SINGLE": "0x321848bf1ae327a9e022ccb3701940191e02fa193ab160d9c0e49cd3c003de3a",
|
|
6
6
|
"FRAMEWORK": "0xb4f25230ba74837d8299e92951306100c4a532e8c48cc3d8828abe9b91c8b274",
|
|
7
|
-
"
|
|
7
|
+
"DICE": "0x37816d28c34cc0df82655ca97b3f066112a5f3c202cbb4aaa76c8af54e779750",
|
|
8
8
|
"MFUD": "0xd8f04cd2a16c19c17428c3b4c22b01dd06740423b93fb7ee88fbe2676a82849d",
|
|
9
9
|
"NFT": "0xbd147bc7f12f38f175d78947a61364e8e077b9b188b00e7094bc0c3623162196",
|
|
10
10
|
"ORACLE": "0x855eb2d260ee42b898266e6df90bfd3c4ed821ccb253a352c159c223244a4b8a",
|
|
11
11
|
"TYPUS": "0x4b0f4ee1a40ce37ec81c987cc4e76a665419e74b863319492fc7d26f708b835a",
|
|
12
|
+
"SAFU": "0x4a68c41bfa2b908ce449e411d0e16718839a62780df0fee568bc027ee2d14ebb",
|
|
12
13
|
"PERP": ""
|
|
13
14
|
},
|
|
14
15
|
"PACKAGE": {
|
|
15
16
|
"DOV_SINGLE": "0xf7ef57f3bd98455262417886b17eb4d5af1a18d2dec19c5b34e512bf4fc10acf",
|
|
16
17
|
"FRAMEWORK": "0x5c6648fb219c046256488486d23d4af7bc562d5ab5c382e1f4b558066a327fe8",
|
|
17
|
-
"
|
|
18
|
+
"DICE": "0x14f1676b7a3b3a6c35eeff747bdb6fcb5bfe920755086c4af1079c23107c22aa",
|
|
18
19
|
"MFUD": "0xd8f04cd2a16c19c17428c3b4c22b01dd06740423b93fb7ee88fbe2676a82849d",
|
|
19
20
|
"NFT": "0xba06aae31d9b7c9f651e783272c7e4f776fb5ae17e89d525b75a17b099f58202",
|
|
20
21
|
"ORACLE": "0x978f65df8570a075298598a9965c18de9087f9e888eb3430fe20334f5c554cfd",
|
|
21
22
|
"TYPUS": "0xf5c7e61fd28d1ed38711f03e1c5ffc6c5b8435eff386132fc5822efe6d90b138",
|
|
23
|
+
"SAFU": "0xdda1734b67dca059111849d17a54a095d5e3847eafcd7bf5636c6972f12a9050",
|
|
22
24
|
"PERP": ""
|
|
23
25
|
},
|
|
24
26
|
"REGISTRY": {
|
|
25
27
|
"AIRDROP": "0x4b451f4632bd64af82d5e6fe46e20705c9468bd46d6758a0f7093fde2930d084",
|
|
26
28
|
"DOV_SINGLE": "0x3d70b09359e3ca8301ae0abeda4f2fdf72ce313ba58c919ce568e5f535fd2ea8",
|
|
29
|
+
"TYPUS_DICE": "0x16657424191772d40afac15738abb26cdf41172d2d205694b04d1300ad403c55",
|
|
27
30
|
"EXP_GUESS": "0x7679ab7157f13ec945579e3098ba589eb8b4eec841c775799d2aa22b565187c7",
|
|
28
31
|
"LEADERBOARD": "0xc515a3e7fd12ba902f7f1ebe52c676136e1b34cb614ae9c79a46b257ca7d5534",
|
|
29
32
|
"MFUD": "0xb8d7e7ab783e56700c0212bd9f0938bba9dd3e7241c149e6c52b21334ec45ece",
|
|
30
33
|
"TAILS_STAKING": "0xeca3e88577dc3f45df8b7bace51f26b126271ce4c5fa33b3739fd7b69fc16559",
|
|
31
34
|
"TGLD": "0x8ee1af362fe9e0a29f6bad48d8ff44249ece5aaa77a4302c2ffcc90950e52ed2",
|
|
32
|
-
"USER": "0xb1b16eb4845b5ee1a29432b1f2bcfe8cbb33c234492baf31a706d82e28e18bce"
|
|
35
|
+
"USER": "0xb1b16eb4845b5ee1a29432b1f2bcfe8cbb33c234492baf31a706d82e28e18bce",
|
|
36
|
+
"SAFU": "0x855b51c812e593d1eb563430593ff42a966b5704e98e93e58a94b555fd25ceeb"
|
|
33
37
|
},
|
|
34
38
|
"TOKEN": {
|
|
35
39
|
"FUD": "0x76cb819b01abed502bee8a702b4c2d547532c12f25001c9dea795a5e631c26f1::fud::FUD",
|
|
@@ -55,15 +59,15 @@
|
|
|
55
59
|
"TGLD_TOKEN_POLICY": "0xd9461bd329f1df24be9698131b6e2c2b9eaac7c9cf6d76689112f2e57be12009",
|
|
56
60
|
"NFT_TRANSFER_POLICY": "0x55475b9e16d9a0176dcef37f83a1921b15f2cbd2711a5f30b9d952c0c8f5f957",
|
|
57
61
|
"STRATEGY_POOL": "0x2c60ddd50d76beb00faa025962d566359a6ea05b1f7f19ac6bd050f4db8c885c",
|
|
58
|
-
"TAILS_IDS": "0x3a6a403eb7c123b6f4d25081078b6f07c0ee5987d3ac8ab3e6bcf707c1b0e778"
|
|
62
|
+
"TAILS_IDS": "0x3a6a403eb7c123b6f4d25081078b6f07c0ee5987d3ac8ab3e6bcf707c1b0e778",
|
|
63
|
+
"SAFU_VERSION": "0x63702bd95f1359399e8b26830905e35867310a88a029963ddfa50f7e55c63e79"
|
|
59
64
|
}
|
|
60
65
|
},
|
|
61
66
|
"TESTNET": {
|
|
62
67
|
"RPC_ENDPOINT": "https://sui-testnet.blastapi.io:443/7f446a12-c4ab-4e3c-b2d8-ebb0fcbe5cdd",
|
|
63
68
|
"PACKAGE_ORIGIN": {
|
|
64
69
|
"DOV_SINGLE": "0x6c9a394a43844fc09d9617bc8a8e775a4521f0e28e83de1da780d043a498671f",
|
|
65
|
-
"
|
|
66
|
-
"EXP_GUESS": "0x9b43ee208a3b235810c145bca1161d1a71d08bfe76b1e55bb3db319ea95d0149",
|
|
70
|
+
"DICE": "0x9b43ee208a3b235810c145bca1161d1a71d08bfe76b1e55bb3db319ea95d0149",
|
|
67
71
|
"FRAMEWORK": "0x908a10789a1a6953e0b73a997c10e3552f7ce4e2907afd00a334ed74bd973ded",
|
|
68
72
|
"MFUD": "0x7755ff79f0f27256c73e6c197e25b407ef6d4b9bd6e1af8cdd50fef28f84712c",
|
|
69
73
|
"NFT": "0x5cfd0819411be98034cba544cbffab192c2c35674a05ff57f4f1c5042875b828",
|
|
@@ -74,7 +78,7 @@
|
|
|
74
78
|
},
|
|
75
79
|
"PACKAGE": {
|
|
76
80
|
"DOV_SINGLE": "0x2e462aa0224bec76acaea81c51ca5b9ae4b27ec50281a764797c84148c8a463f",
|
|
77
|
-
"
|
|
81
|
+
"DICE": "0x112321a74fb0903aff5c654603c19060552a704b5fb13a6cefa84e1147e66db8",
|
|
78
82
|
"FRAMEWORK": "0x90ca6e2393e3adc91b4e9b70ab16c017e5f70f7094b6f09b913fef2833a656e9",
|
|
79
83
|
"MFUD": "0x7755ff79f0f27256c73e6c197e25b407ef6d4b9bd6e1af8cdd50fef28f84712c",
|
|
80
84
|
"NFT": "0x0f5162014f18686640b8d0adefd60c3fe5b377413ec4f1e77001c67d96f8501a",
|
|
@@ -88,17 +92,17 @@
|
|
|
88
92
|
"LEADERBOARD": "0x4faabe5a4a509a145fc9bae95761d34c11571da4cb25d681f06ffcbadbc355e7",
|
|
89
93
|
"MFUD": "0x7ad87901531693f1baa541712947860dcc543617e11b14993ad70d20daf159c6",
|
|
90
94
|
"TAILS_EXP": "0x37e0c8c80a5099d5dfe1b0aeae62e3f01916be73935090efb9c95279b7bb1ce7",
|
|
95
|
+
"TYPUS_DICE": "0x034f58472d9604eee3e1fb5896e4d6a14f426c17c504cdb9dcdc7269ca4ad3b4",
|
|
91
96
|
"EXP_GUESS": "0x37e0c8c80a5099d5dfe1b0aeae62e3f01916be73935090efb9c95279b7bb1ce7",
|
|
92
97
|
"TAILS_STAKING": "0x989bd585b580dfc22d9d7656a5807b2f6c8fe36260a2003ef697adc8a38d21af",
|
|
93
98
|
"TGLD": "0x2118b4056c89d90a6dc40d198fbe239cb8e83f7ea20daaf4ea53341c7fdb043c",
|
|
94
99
|
"USER": "0x5f1894a3680949111a7530d63ceda6857d31521ab2de625e9f826cae17c9a7f3",
|
|
95
100
|
"LOCKED_VAULT": "0x50f1fc44c907f8738b098abf2b594e523739df7d40df8164154cfe6f60513302",
|
|
96
|
-
"
|
|
97
|
-
"
|
|
98
|
-
"
|
|
99
|
-
"
|
|
100
|
-
"
|
|
101
|
-
"TREASURY_CAPS": "0xeb835b5db70144d098f7b4885ac525900fb5a6b47565f31d2275e34479ef7889"
|
|
101
|
+
"STAKE_POOL": "0xc853c36a9317a709ac92b611daa910b43805876ba6ca78fbbab9d51359994c5b",
|
|
102
|
+
"LP_POOL": "0x0a213c906f7a9fc369f1e7d0ffabb7701bfd1cdff04679b1132c5838306e3394",
|
|
103
|
+
"LIQUIDITY_POOL": "0x40d1ea0f0dfebbe0b130f08c0c62bfee1c58f6a99c0960cb4f08fd3040bf4714",
|
|
104
|
+
"MARKET": "0xa522a55413d109c568c3d42cbcd0e344000d61086f390df672663424e0329288",
|
|
105
|
+
"TLP": "0x4e40c46ebe73b3fdca694040747b99a1b25600ddeae26f9fbb8cda5a683d26de"
|
|
102
106
|
},
|
|
103
107
|
"TOKEN": {
|
|
104
108
|
"FUD": "0x461efa7ee5aa1b27e44450d79e2104e7fc0991461e9eb1c2a3fc1f44cd554856::fud::FUD",
|
|
@@ -134,7 +138,8 @@
|
|
|
134
138
|
"NFT_TRANSFER_POLICY": "0x1c62271ecc443c3d92a8fe8f5662e877856d26b971d967f66937a65f55160831",
|
|
135
139
|
"STRATEGY_POOL": "0x50b01081469d032e04bfcbd057614b1359376920f55c7bebd076e0e2af07a57f",
|
|
136
140
|
"TAILS_IDS": "0xf4ea1c4432823ebde3b0c1f0705a45b08571b48237db879502b8ba336ea5b916",
|
|
137
|
-
"TYPUS_PERP_VERSION": "0x3aafe933e23a9e10f3a34febf6a2996961989558315bae46458fd234496e8a97"
|
|
141
|
+
"TYPUS_PERP_VERSION": "0x3aafe933e23a9e10f3a34febf6a2996961989558315bae46458fd234496e8a97",
|
|
142
|
+
"TLP_TREASURY_CAP": "0xeb835b5db70144d098f7b4885ac525900fb5a6b47565f31d2275e34479ef7889"
|
|
138
143
|
}
|
|
139
144
|
},
|
|
140
145
|
"MOVEMENT": {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function getDrawResult(network: "mainnet" | "testnet", packageId: string, module: "tails_exp" | "combo_dice", registry: string, index: string, amount: string, guess_1: string, larger_than_1: boolean, guess_2: string, larger_than_2: boolean, vrf_input_1: number[], vrf_input_2: number[]): Promise<any>;
|
|
@@ -37,10 +37,9 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.getDrawResult = getDrawResult;
|
|
40
|
-
|
|
41
|
-
function getDrawResult(network, packageId, registry, index, amount, guess_1, larger_than_1, guess_2, larger_than_2, vrf_input_1, vrf_input_2) {
|
|
40
|
+
function getDrawResult(network, packageId, module, registry, index, amount, guess_1, larger_than_1, guess_2, larger_than_2, vrf_input_1, vrf_input_2) {
|
|
42
41
|
return __awaiter(this, void 0, void 0, function () {
|
|
43
|
-
var queryParams, vrf_input_1_string, vrf_input_2_string, apiUrlWithParams, response, data;
|
|
42
|
+
var queryParams, vrf_input_1_string, vrf_input_2_string, apiUrl, apiUrlWithParams, response, data;
|
|
44
43
|
return __generator(this, function (_a) {
|
|
45
44
|
switch (_a.label) {
|
|
46
45
|
case 0:
|
|
@@ -57,6 +56,12 @@ function getDrawResult(network, packageId, registry, index, amount, guess_1, lar
|
|
|
57
56
|
});
|
|
58
57
|
vrf_input_1_string = JSON.stringify(vrf_input_1);
|
|
59
58
|
vrf_input_2_string = JSON.stringify(vrf_input_2);
|
|
59
|
+
if (module === "tails_exp") {
|
|
60
|
+
apiUrl = "https://us-central1-aqueous-freedom-378103.cloudfunctions.net/draw-result-1";
|
|
61
|
+
}
|
|
62
|
+
else if (module === "combo_dice") {
|
|
63
|
+
apiUrl = "https://us-central1-aqueous-freedom-378103.cloudfunctions.net/draw-result-2";
|
|
64
|
+
}
|
|
60
65
|
apiUrlWithParams = "".concat(apiUrl, "?").concat(queryParams.toString(), "&vrf_input_1=").concat(vrf_input_1_string, "&vrf_input_2=").concat(vrf_input_2_string);
|
|
61
66
|
return [4 /*yield*/, fetch(apiUrlWithParams, {
|
|
62
67
|
method: "GET",
|
|
@@ -9,14 +9,22 @@ export interface Playground {
|
|
|
9
9
|
opened_games: Map<string, Game>;
|
|
10
10
|
game_config: GameConfig;
|
|
11
11
|
is_active: boolean;
|
|
12
|
+
exp_config?: ExpConfig;
|
|
12
13
|
}
|
|
13
14
|
export interface GameConfig {
|
|
14
15
|
max_stake: string;
|
|
15
16
|
min_stake: string;
|
|
16
17
|
stake_lot_size: string;
|
|
17
|
-
base_exp_divisor: string;
|
|
18
|
-
losses_multiplier_bp: string;
|
|
19
18
|
critical_hits_multiplier_bp: string;
|
|
19
|
+
base_exp_divisor?: string;
|
|
20
|
+
losses_multiplier_bp?: string;
|
|
21
|
+
banker_edge_bp?: string;
|
|
22
|
+
max_single_game_loss_ratio_bp?: string;
|
|
23
|
+
u64_padding?: string[];
|
|
24
|
+
}
|
|
25
|
+
export interface ExpConfig {
|
|
26
|
+
base_exp_divisor: string;
|
|
27
|
+
u64_padding: string[];
|
|
20
28
|
}
|
|
21
29
|
export interface Game {
|
|
22
30
|
game_id: string;
|
|
@@ -29,13 +37,11 @@ export interface Game {
|
|
|
29
37
|
larger_than_2: boolean | null;
|
|
30
38
|
vrf_input_2: number[] | null;
|
|
31
39
|
}
|
|
32
|
-
export declare function getHistory(provider: SuiClient, dicePackage: string, playgrounds: Playground[]): Promise<DrawDisplay[]>;
|
|
33
|
-
export declare function waitHistory(provider: SuiClient, dicePackage: string, onMessage: any): Promise<import("@mysten/sui.js/client").Unsubscribe>;
|
|
40
|
+
export declare function getHistory(provider: SuiClient, dicePackage: string, module: "tails_exp" | "combo_dice", playgrounds: Playground[]): Promise<DrawDisplay[]>;
|
|
34
41
|
export declare function parseHistory(datas: any, playgrounds: Playground[]): Promise<DrawDisplay[]>;
|
|
35
42
|
export interface DrawEvent {
|
|
36
43
|
answer_1: string;
|
|
37
44
|
answer_2: string;
|
|
38
|
-
exp: string;
|
|
39
45
|
game_id: string;
|
|
40
46
|
guess_1: string;
|
|
41
47
|
guess_2: string;
|
|
@@ -51,6 +57,9 @@ export interface DrawEvent {
|
|
|
51
57
|
signer: string;
|
|
52
58
|
stake_amount: string;
|
|
53
59
|
timestampMs: string;
|
|
60
|
+
exp?: string;
|
|
61
|
+
exp_amount?: string;
|
|
62
|
+
reward?: string;
|
|
54
63
|
}
|
|
55
64
|
export interface DrawDisplay {
|
|
56
65
|
game_id: string;
|
|
@@ -62,13 +71,8 @@ export interface DrawDisplay {
|
|
|
62
71
|
bet_amount: string;
|
|
63
72
|
exp: string;
|
|
64
73
|
timestampMs: string;
|
|
74
|
+
reward?: string;
|
|
65
75
|
}
|
|
66
|
-
export interface LeaderBoard {
|
|
67
|
-
player: string;
|
|
68
|
-
total_bet_amount: number;
|
|
69
|
-
total_earn_exp: number;
|
|
70
|
-
}
|
|
71
|
-
export declare function getLeaderBoard(drawDisplays: DrawDisplay[]): Promise<LeaderBoard[]>;
|
|
72
76
|
export interface ProfitSharing {
|
|
73
77
|
level_profits: string[];
|
|
74
78
|
level_users: string[];
|
|
@@ -78,4 +82,3 @@ export interface ProfitSharing {
|
|
|
78
82
|
tokenType: string;
|
|
79
83
|
}
|
|
80
84
|
export declare function getProfitSharing(provider: SuiClient, diceProfitSharing: string): Promise<ProfitSharing>;
|
|
81
|
-
export declare function calculateLevelReward(totalRewards: number, levelShares: number[], numOfHolders: number[]): number[];
|
|
@@ -49,12 +49,9 @@ var __values = (this && this.__values) || function(o) {
|
|
|
49
49
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
50
|
exports.getPlaygrounds = getPlaygrounds;
|
|
51
51
|
exports.getHistory = getHistory;
|
|
52
|
-
exports.waitHistory = waitHistory;
|
|
53
52
|
exports.parseHistory = parseHistory;
|
|
54
|
-
exports.getLeaderBoard = getLeaderBoard;
|
|
55
53
|
exports.getProfitSharing = getProfitSharing;
|
|
56
|
-
|
|
57
|
-
var token_1 = require("../constants/token");
|
|
54
|
+
var constants_1 = require("../constants");
|
|
58
55
|
function getPlaygrounds(provider, diceRegistry) {
|
|
59
56
|
return __awaiter(this, void 0, void 0, function () {
|
|
60
57
|
var playgroundIds, objects, result;
|
|
@@ -76,16 +73,30 @@ function getPlaygrounds(provider, diceRegistry) {
|
|
|
76
73
|
// @ts-ignore
|
|
77
74
|
.filter(function (object) { var _a, _b; return (_b = (_a = object.data) === null || _a === void 0 ? void 0 : _a.content) === null || _b === void 0 ? void 0 : _b.type.endsWith("Playground"); })
|
|
78
75
|
.map(function (object) {
|
|
79
|
-
var _a;
|
|
76
|
+
var e_1, _a;
|
|
77
|
+
var _b;
|
|
80
78
|
// @ts-ignore
|
|
81
|
-
var fields = (
|
|
79
|
+
var fields = (_b = object.data) === null || _b === void 0 ? void 0 : _b.content.fields;
|
|
82
80
|
// console.log(fields);
|
|
83
|
-
var opened_games =
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
81
|
+
var opened_games = new Map();
|
|
82
|
+
if (fields.opened_games.fields) {
|
|
83
|
+
try {
|
|
84
|
+
for (var _c = __values(fields.opened_games.fields.contents), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
85
|
+
var curr = _d.value;
|
|
86
|
+
// console.log(curr);
|
|
87
|
+
opened_games.set(curr.fields.key, curr.fields.value.fields);
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
91
|
+
finally {
|
|
92
|
+
try {
|
|
93
|
+
if (_d && !_d.done && (_a = _c.return)) _a.call(_c);
|
|
94
|
+
}
|
|
95
|
+
finally { if (e_1) throw e_1.error; }
|
|
96
|
+
}
|
|
97
|
+
}
|
|
88
98
|
// console.log(opened_games);
|
|
99
|
+
var game_config = fields.game_config.fields;
|
|
89
100
|
// console.log(game_config);
|
|
90
101
|
var playground = {
|
|
91
102
|
id: fields.id.id,
|
|
@@ -97,6 +108,9 @@ function getPlaygrounds(provider, diceRegistry) {
|
|
|
97
108
|
game_config: game_config,
|
|
98
109
|
is_active: fields.is_active,
|
|
99
110
|
};
|
|
111
|
+
if (fields.exp_config) {
|
|
112
|
+
playground.exp_config = fields.exp_config.fields;
|
|
113
|
+
}
|
|
100
114
|
// console.log(playground);
|
|
101
115
|
return playground;
|
|
102
116
|
});
|
|
@@ -105,14 +119,14 @@ function getPlaygrounds(provider, diceRegistry) {
|
|
|
105
119
|
});
|
|
106
120
|
});
|
|
107
121
|
}
|
|
108
|
-
function getHistory(provider, dicePackage, playgrounds) {
|
|
122
|
+
function getHistory(provider, dicePackage, module, playgrounds) {
|
|
109
123
|
return __awaiter(this, void 0, void 0, function () {
|
|
110
124
|
var eventFilter, result, history, nextPage;
|
|
111
125
|
return __generator(this, function (_a) {
|
|
112
126
|
switch (_a.label) {
|
|
113
127
|
case 0:
|
|
114
128
|
eventFilter = {
|
|
115
|
-
MoveEventType: "".concat(dicePackage, "::
|
|
129
|
+
MoveEventType: "".concat(dicePackage, "::").concat(module, "::Draw"),
|
|
116
130
|
};
|
|
117
131
|
return [4 /*yield*/, provider.queryEvents({ query: eventFilter, order: "descending" })];
|
|
118
132
|
case 1:
|
|
@@ -136,26 +150,6 @@ function getHistory(provider, dicePackage, playgrounds) {
|
|
|
136
150
|
});
|
|
137
151
|
});
|
|
138
152
|
}
|
|
139
|
-
function waitHistory(provider, dicePackage, onMessage) {
|
|
140
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
141
|
-
var eventFilter, unsubscribe;
|
|
142
|
-
return __generator(this, function (_a) {
|
|
143
|
-
switch (_a.label) {
|
|
144
|
-
case 0:
|
|
145
|
-
eventFilter = {
|
|
146
|
-
MoveEventType: "".concat(dicePackage, "::tails_exp::Draw"),
|
|
147
|
-
};
|
|
148
|
-
return [4 /*yield*/, provider.subscribeEvent({
|
|
149
|
-
filter: eventFilter,
|
|
150
|
-
onMessage: onMessage,
|
|
151
|
-
})];
|
|
152
|
-
case 1:
|
|
153
|
-
unsubscribe = _a.sent();
|
|
154
|
-
return [2 /*return*/, unsubscribe];
|
|
155
|
-
}
|
|
156
|
-
});
|
|
157
|
-
});
|
|
158
|
-
}
|
|
159
153
|
function parseHistory(datas, playgrounds) {
|
|
160
154
|
return __awaiter(this, void 0, void 0, function () {
|
|
161
155
|
var result;
|
|
@@ -165,8 +159,8 @@ function parseHistory(datas, playgrounds) {
|
|
|
165
159
|
drawEvent.timestampMs = event.timestampMs;
|
|
166
160
|
var playground = playgrounds[Number(drawEvent.index)];
|
|
167
161
|
var coinType = "0x" + playground.stake_token;
|
|
168
|
-
var asset = (0,
|
|
169
|
-
var decimal = (0,
|
|
162
|
+
var asset = (0, constants_1.typeArgToAsset)(coinType);
|
|
163
|
+
var decimal = (0, constants_1.assetToDecimal)(asset);
|
|
170
164
|
var guess_1 = (drawEvent.larger_than_1 ? "> " : "< ") + "".concat(Number(drawEvent.guess_1) / 100);
|
|
171
165
|
var guess_2 = (drawEvent.larger_than_2 ? "> " : "< ") + "".concat(Number(drawEvent.guess_2) / 100);
|
|
172
166
|
var result_1 = "".concat(Number(drawEvent.answer_1) / 100);
|
|
@@ -194,7 +188,15 @@ function parseHistory(datas, playgrounds) {
|
|
|
194
188
|
break;
|
|
195
189
|
}
|
|
196
190
|
var stake_amount = Number(drawEvent.stake_amount) / Math.pow(10, decimal);
|
|
197
|
-
var amount
|
|
191
|
+
var amount;
|
|
192
|
+
if (asset == "FUD") {
|
|
193
|
+
amount = "".concat(stake_amount / 1000000, "m");
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
amount = stake_amount;
|
|
197
|
+
}
|
|
198
|
+
var exp = Number(drawEvent.exp) | Number(drawEvent.exp_amount);
|
|
199
|
+
// console.log(drawEvent);
|
|
198
200
|
var display = {
|
|
199
201
|
game_id: drawEvent.game_id,
|
|
200
202
|
player: drawEvent.player,
|
|
@@ -203,52 +205,24 @@ function parseHistory(datas, playgrounds) {
|
|
|
203
205
|
result_1: result_1,
|
|
204
206
|
result_2: result_2,
|
|
205
207
|
bet_amount: "".concat(amount, " ").concat(asset),
|
|
206
|
-
exp: "".concat(
|
|
208
|
+
exp: "".concat(exp, " EXP"),
|
|
207
209
|
timestampMs: drawEvent.timestampMs,
|
|
208
210
|
};
|
|
211
|
+
if (drawEvent.reward) {
|
|
212
|
+
var reward = Number(drawEvent.reward) / Math.pow(10, decimal);
|
|
213
|
+
if (asset == "FUD") {
|
|
214
|
+
display.reward = "".concat(reward / 1000000, "m ").concat(asset);
|
|
215
|
+
}
|
|
216
|
+
else {
|
|
217
|
+
display.reward = "".concat(reward, " ").concat(asset);
|
|
218
|
+
}
|
|
219
|
+
}
|
|
209
220
|
return display;
|
|
210
221
|
});
|
|
211
222
|
return [2 /*return*/, result];
|
|
212
223
|
});
|
|
213
224
|
});
|
|
214
225
|
}
|
|
215
|
-
function getLeaderBoard(drawDisplays) {
|
|
216
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
217
|
-
var leaderBoard, _loop_1, drawDisplays_1, drawDisplays_1_1, drawDisplay;
|
|
218
|
-
var e_1, _a;
|
|
219
|
-
return __generator(this, function (_b) {
|
|
220
|
-
leaderBoard = [];
|
|
221
|
-
_loop_1 = function (drawDisplay) {
|
|
222
|
-
var i = leaderBoard.findIndex(function (x) { return x.player == drawDisplay.player; });
|
|
223
|
-
if (i == -1) {
|
|
224
|
-
leaderBoard.push({
|
|
225
|
-
player: drawDisplay.player,
|
|
226
|
-
total_bet_amount: Number(drawDisplay.bet_amount.split(" ")[0]),
|
|
227
|
-
total_earn_exp: Number(drawDisplay.exp.split(" ")[0]),
|
|
228
|
-
});
|
|
229
|
-
}
|
|
230
|
-
else {
|
|
231
|
-
leaderBoard[i].total_bet_amount += Number(drawDisplay.bet_amount.split(" ")[0]);
|
|
232
|
-
leaderBoard[i].total_earn_exp += Number(drawDisplay.exp.split(" ")[0]);
|
|
233
|
-
}
|
|
234
|
-
};
|
|
235
|
-
try {
|
|
236
|
-
for (drawDisplays_1 = __values(drawDisplays), drawDisplays_1_1 = drawDisplays_1.next(); !drawDisplays_1_1.done; drawDisplays_1_1 = drawDisplays_1.next()) {
|
|
237
|
-
drawDisplay = drawDisplays_1_1.value;
|
|
238
|
-
_loop_1(drawDisplay);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
242
|
-
finally {
|
|
243
|
-
try {
|
|
244
|
-
if (drawDisplays_1_1 && !drawDisplays_1_1.done && (_a = drawDisplays_1.return)) _a.call(drawDisplays_1);
|
|
245
|
-
}
|
|
246
|
-
finally { if (e_1) throw e_1.error; }
|
|
247
|
-
}
|
|
248
|
-
return [2 /*return*/, leaderBoard];
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
}
|
|
252
226
|
function getProfitSharing(provider, diceProfitSharing) {
|
|
253
227
|
return __awaiter(this, void 0, void 0, function () {
|
|
254
228
|
var object, type, tokenType, result;
|
|
@@ -270,77 +244,3 @@ function getProfitSharing(provider, diceProfitSharing) {
|
|
|
270
244
|
});
|
|
271
245
|
});
|
|
272
246
|
}
|
|
273
|
-
function calculateLevelReward(totalRewards, levelShares, numOfHolders) {
|
|
274
|
-
// Step 1: Calculate original level rewards (per holder)
|
|
275
|
-
var totalShares = levelShares.reduce(function (acc, share) { return acc + share; }, 0);
|
|
276
|
-
var originalRewardPerHolder = levelShares.map(function (levelShare, index) {
|
|
277
|
-
var num = numOfHolders[index];
|
|
278
|
-
var levelRewardPerHolder = num > 0 ? (totalRewards * levelShare) / totalShares / num : 0;
|
|
279
|
-
return Math.floor(levelRewardPerHolder);
|
|
280
|
-
});
|
|
281
|
-
var originalLevelRewards = originalRewardPerHolder.map(function (reward, index) { return reward * numOfHolders[index]; });
|
|
282
|
-
var distributedRewards = originalLevelRewards.reduce(function (acc, reward) { return acc + reward; }, 0);
|
|
283
|
-
var emptyLevelRewards = totalRewards - distributedRewards;
|
|
284
|
-
// console.log("Step 1 - ", originalRewardPerHolder);
|
|
285
|
-
// Step 2: Distribute rewards from empty levels
|
|
286
|
-
var reversedOriginalRewardPerHolder = originalRewardPerHolder.slice().reverse();
|
|
287
|
-
var reversedNumOfHolders = numOfHolders.slice().reverse();
|
|
288
|
-
var reversedScaledRewardPerHolder = [];
|
|
289
|
-
if (emptyLevelRewards > 0) {
|
|
290
|
-
var undistributedRewards_1 = emptyLevelRewards;
|
|
291
|
-
var uncalculatedDistributedRewards_1 = distributedRewards;
|
|
292
|
-
reversedScaledRewardPerHolder = reversedOriginalRewardPerHolder.map(function (rewardPerHolder, index) {
|
|
293
|
-
var num = reversedNumOfHolders[index];
|
|
294
|
-
var scaledRewardPerHolder = num > 0
|
|
295
|
-
? uncalculatedDistributedRewards_1 > 0
|
|
296
|
-
? (rewardPerHolder * (uncalculatedDistributedRewards_1 + undistributedRewards_1)) / uncalculatedDistributedRewards_1
|
|
297
|
-
: rewardPerHolder
|
|
298
|
-
: 0;
|
|
299
|
-
undistributedRewards_1 -= (scaledRewardPerHolder - rewardPerHolder) * num;
|
|
300
|
-
uncalculatedDistributedRewards_1 -= rewardPerHolder * num;
|
|
301
|
-
return Math.floor(scaledRewardPerHolder);
|
|
302
|
-
});
|
|
303
|
-
}
|
|
304
|
-
else {
|
|
305
|
-
reversedScaledRewardPerHolder = reversedOriginalRewardPerHolder.slice();
|
|
306
|
-
}
|
|
307
|
-
// let scaledRewardPerHolder: number[] = reversedScaledRewardPerHolder.slice().reverse();
|
|
308
|
-
// console.log("Step 2 - ", scaledRewardPerHolder);
|
|
309
|
-
// Step 3: Capped level reward
|
|
310
|
-
var reversedCappedRewardPerHolder = [reversedOriginalRewardPerHolder[0]];
|
|
311
|
-
var tempHighLevelReward = 0;
|
|
312
|
-
reversedScaledRewardPerHolder.forEach(function (highLevelReward, index) {
|
|
313
|
-
var lowLevelReward = reversedScaledRewardPerHolder[index + 1] || 0;
|
|
314
|
-
tempHighLevelReward =
|
|
315
|
-
highLevelReward > 0
|
|
316
|
-
? tempHighLevelReward > 0
|
|
317
|
-
? Math.min(highLevelReward, tempHighLevelReward)
|
|
318
|
-
: highLevelReward
|
|
319
|
-
: tempHighLevelReward;
|
|
320
|
-
reversedCappedRewardPerHolder.push(tempHighLevelReward > 0 ? Math.min(lowLevelReward, tempHighLevelReward) : lowLevelReward);
|
|
321
|
-
});
|
|
322
|
-
reversedCappedRewardPerHolder.pop();
|
|
323
|
-
var cappedRewardPerHolder = reversedCappedRewardPerHolder.slice().reverse();
|
|
324
|
-
// console.log("Step 3 - ", cappedRewardPerHolder);
|
|
325
|
-
// Step 4: Distribute capped reward from Step 3 into each level
|
|
326
|
-
var distributedRewardsStep4 = reversedCappedRewardPerHolder.reduce(function (acc, reward, index) { return acc + reward * reversedNumOfHolders[index]; }, 0);
|
|
327
|
-
var undistributedRewardsStep4 = totalRewards - distributedRewardsStep4;
|
|
328
|
-
var uncalculatedDistributedRewardsStep4 = distributedRewardsStep4;
|
|
329
|
-
// console.log(distributedRewardsStep4);
|
|
330
|
-
// console.log(totalRewards);
|
|
331
|
-
// console.log(undistributedRewardsStep4);
|
|
332
|
-
// console.log(uncalculatedDistributedRewardsStep4);
|
|
333
|
-
var levelReward = cappedRewardPerHolder.map(function (rewardPerHolder, index) {
|
|
334
|
-
var num = reversedNumOfHolders[index];
|
|
335
|
-
var scaledRewardPerHolder = uncalculatedDistributedRewardsStep4 > 0
|
|
336
|
-
? (rewardPerHolder * (uncalculatedDistributedRewardsStep4 + undistributedRewardsStep4)) /
|
|
337
|
-
uncalculatedDistributedRewardsStep4
|
|
338
|
-
: rewardPerHolder;
|
|
339
|
-
undistributedRewardsStep4 -= (scaledRewardPerHolder - rewardPerHolder) * num;
|
|
340
|
-
uncalculatedDistributedRewardsStep4 -= rewardPerHolder * num;
|
|
341
|
-
// console.log(undistributedRewardsStep4);
|
|
342
|
-
return Math.floor(scaledRewardPerHolder);
|
|
343
|
-
});
|
|
344
|
-
// console.log("Step 4 - ", levelReward);
|
|
345
|
-
return levelReward;
|
|
346
|
-
}
|
|
@@ -8,7 +8,7 @@ import { TransactionBlock } from "@mysten/sui.js/transactions";
|
|
|
8
8
|
ctx: &mut TxContext
|
|
9
9
|
)
|
|
10
10
|
*/
|
|
11
|
-
export declare function newGameTx(gasBudget: number, packageId: string, typeArguments: string[], // [TOKEN]
|
|
11
|
+
export declare function newGameTx(gasBudget: number, packageId: string, module: "tails_exp" | "combo_dice", typeArguments: string[], // [TOKEN]
|
|
12
12
|
registry: string, index: string, coins: string[], amount: string): Promise<TransactionBlock>;
|
|
13
13
|
/**
|
|
14
14
|
public(friend) entry fun play_guess(
|
|
@@ -22,9 +22,9 @@ registry: string, index: string, coins: string[], amount: string): Promise<Trans
|
|
|
22
22
|
ctx: &mut TxContext
|
|
23
23
|
)
|
|
24
24
|
*/
|
|
25
|
-
export declare function playGuessTx(gasBudget: number, packageId: string, registry: string, index: string, guess_1: string, larger_than_1: boolean, guess_2: string, larger_than_2: boolean): Promise<TransactionBlock>;
|
|
26
|
-
export declare function newGamePlayGuessTx(gasBudget: number, packageId: string, typeArguments: string[], // [TOKEN]
|
|
27
|
-
registry: string, index: string, coins: string[], amount: string, guess_1: string, larger_than_1: boolean, guess_2: string, larger_than_2: boolean): Promise<TransactionBlock>;
|
|
25
|
+
export declare function playGuessTx(gasBudget: number, packageId: string, module: "tails_exp" | "combo_dice", registry: string, index: string, guess_1: string, larger_than_1: boolean, guess_2: string, larger_than_2: boolean): Promise<TransactionBlock>;
|
|
26
|
+
export declare function newGamePlayGuessTx(gasBudget: number, packageId: string, module: "tails_exp" | "combo_dice", typeArguments: string[], // [TOKEN]
|
|
27
|
+
registry: string, expRegistry: string, index: string, coins: string[], amount: string, guess_1: string, larger_than_1: boolean, guess_2: string, larger_than_2: boolean): Promise<TransactionBlock>;
|
|
28
28
|
/**
|
|
29
29
|
public fun consume_exp_coin_staked(
|
|
30
30
|
registry: &mut Registry,
|
|
@@ -67,14 +67,14 @@ var transactions_1 = require("@mysten/sui.js/transactions");
|
|
|
67
67
|
ctx: &mut TxContext
|
|
68
68
|
)
|
|
69
69
|
*/
|
|
70
|
-
function newGameTx(gasBudget, packageId, typeArguments, // [TOKEN]
|
|
70
|
+
function newGameTx(gasBudget, packageId, module, typeArguments, // [TOKEN]
|
|
71
71
|
registry, index, coins, amount) {
|
|
72
72
|
return __awaiter(this, void 0, void 0, function () {
|
|
73
73
|
var tx;
|
|
74
74
|
return __generator(this, function (_a) {
|
|
75
75
|
tx = new transactions_1.TransactionBlock();
|
|
76
76
|
tx.moveCall({
|
|
77
|
-
target: "".concat(packageId, "::
|
|
77
|
+
target: "".concat(packageId, "::").concat(module, "::new_game"),
|
|
78
78
|
typeArguments: typeArguments,
|
|
79
79
|
arguments: [tx.object(registry), tx.pure(index), tx.makeMoveVec({ objects: coins.map(function (id) { return tx.object(id); }) }), tx.pure(amount)],
|
|
80
80
|
});
|
|
@@ -95,13 +95,13 @@ registry, index, coins, amount) {
|
|
|
95
95
|
ctx: &mut TxContext
|
|
96
96
|
)
|
|
97
97
|
*/
|
|
98
|
-
function playGuessTx(gasBudget, packageId, registry, index, guess_1, larger_than_1, guess_2, larger_than_2) {
|
|
98
|
+
function playGuessTx(gasBudget, packageId, module, registry, index, guess_1, larger_than_1, guess_2, larger_than_2) {
|
|
99
99
|
return __awaiter(this, void 0, void 0, function () {
|
|
100
100
|
var tx;
|
|
101
101
|
return __generator(this, function (_a) {
|
|
102
102
|
tx = new transactions_1.TransactionBlock();
|
|
103
103
|
tx.moveCall({
|
|
104
|
-
target: "".concat(packageId, "::
|
|
104
|
+
target: "".concat(packageId, "::").concat(module, "::play_guess"),
|
|
105
105
|
typeArguments: [],
|
|
106
106
|
arguments: [
|
|
107
107
|
tx.object(registry),
|
|
@@ -117,8 +117,8 @@ function playGuessTx(gasBudget, packageId, registry, index, guess_1, larger_than
|
|
|
117
117
|
});
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
|
-
function newGamePlayGuessTx(gasBudget, packageId, typeArguments, // [TOKEN]
|
|
121
|
-
registry, index, coins, amount, guess_1, larger_than_1, guess_2, larger_than_2) {
|
|
120
|
+
function newGamePlayGuessTx(gasBudget, packageId, module, typeArguments, // [TOKEN]
|
|
121
|
+
registry, expRegistry, index, coins, amount, guess_1, larger_than_1, guess_2, larger_than_2) {
|
|
122
122
|
return __awaiter(this, void 0, void 0, function () {
|
|
123
123
|
var tx, _a, coin;
|
|
124
124
|
return __generator(this, function (_b) {
|
|
@@ -127,14 +127,16 @@ registry, index, coins, amount, guess_1, larger_than_1, guess_2, larger_than_2)
|
|
|
127
127
|
typeArguments[0] == "0x0000000000000000000000000000000000000000000000000000000000000002::sui::SUI") {
|
|
128
128
|
_a = __read(tx.splitCoins(tx.gas, [tx.pure(amount)]), 1), coin = _a[0];
|
|
129
129
|
tx.moveCall({
|
|
130
|
-
target: "".concat(packageId, "::
|
|
130
|
+
target: "".concat(packageId, "::").concat(module, "::new_game"),
|
|
131
131
|
typeArguments: typeArguments,
|
|
132
|
-
arguments:
|
|
132
|
+
arguments: module == "combo_dice"
|
|
133
|
+
? [tx.object(registry), tx.object(expRegistry), tx.pure(index), tx.makeMoveVec({ objects: [coin] }), tx.pure(amount)]
|
|
134
|
+
: [tx.object(registry), tx.pure(index), tx.makeMoveVec({ objects: [coin] }), tx.pure(amount)],
|
|
133
135
|
});
|
|
134
136
|
}
|
|
135
137
|
else {
|
|
136
138
|
tx.moveCall({
|
|
137
|
-
target: "".concat(packageId, "::
|
|
139
|
+
target: "".concat(packageId, "::").concat(module, "::new_game"),
|
|
138
140
|
typeArguments: typeArguments,
|
|
139
141
|
arguments: [
|
|
140
142
|
tx.object(registry),
|
|
@@ -145,7 +147,7 @@ registry, index, coins, amount, guess_1, larger_than_1, guess_2, larger_than_2)
|
|
|
145
147
|
});
|
|
146
148
|
}
|
|
147
149
|
tx.moveCall({
|
|
148
|
-
target: "".concat(packageId, "::
|
|
150
|
+
target: "".concat(packageId, "::").concat(module, "::play_guess"),
|
|
149
151
|
typeArguments: [],
|
|
150
152
|
arguments: [
|
|
151
153
|
tx.object(registry),
|
|
@@ -154,9 +156,22 @@ registry, index, coins, amount, guess_1, larger_than_1, guess_2, larger_than_2)
|
|
|
154
156
|
tx.pure(larger_than_1),
|
|
155
157
|
tx.pure(guess_2),
|
|
156
158
|
tx.pure(larger_than_2),
|
|
157
|
-
// tx.object("0x8"), // TODO: waiting for upgrade
|
|
158
159
|
],
|
|
159
160
|
});
|
|
161
|
+
// TODO: waiting for upgrade
|
|
162
|
+
// tx.moveCall({
|
|
163
|
+
// target: `${packageId}::${module}::play_guess_with_random`,
|
|
164
|
+
// typeArguments: module == "combo_dice" ? typeArguments : [],
|
|
165
|
+
// arguments: [
|
|
166
|
+
// tx.object(registry),
|
|
167
|
+
// tx.pure(index),
|
|
168
|
+
// tx.pure(guess_1),
|
|
169
|
+
// tx.pure(larger_than_1),
|
|
170
|
+
// tx.pure(guess_2),
|
|
171
|
+
// tx.pure(larger_than_2),
|
|
172
|
+
// tx.object("0x8"),
|
|
173
|
+
// ],
|
|
174
|
+
// });
|
|
160
175
|
tx.setGasBudget(gasBudget);
|
|
161
176
|
return [2 /*return*/, tx];
|
|
162
177
|
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface DrawResult {
|
|
2
|
+
answer_1: string;
|
|
3
|
+
result_1: string;
|
|
4
|
+
answer_2: string;
|
|
5
|
+
result_2: string;
|
|
6
|
+
exp: string;
|
|
7
|
+
}
|
|
8
|
+
export declare function simulateGame(network: "mainnet" | "testnet", packageId: string, module: "tails_exp" | "combo_dice", registry: string, index: string, amount: string, guess_1: string, larger_than_1: boolean, guess_2: string, larger_than_2: boolean, vrf_input_1: number[], vrf_input_2: number[], drawKeys: any, sender?: string): Promise<DrawResult>;
|
|
@@ -44,8 +44,8 @@ var transactions_1 = require("@mysten/sui.js/transactions");
|
|
|
44
44
|
var client_1 = require("@mysten/sui.js/client");
|
|
45
45
|
var bcs_1 = require("@mysten/bcs");
|
|
46
46
|
var bls_signatures_1 = __importDefault(require("bls-signatures"));
|
|
47
|
-
function simulateGame(network_1, packageId_1, registry_1, index_1, amount_1, guess_1_1, larger_than_1_1, guess_2_1, larger_than_2_1, vrf_input_1_1, vrf_input_2_1, drawKeys_1) {
|
|
48
|
-
return __awaiter(this, arguments, void 0, function (network, packageId, registry, index, amount, guess_1, larger_than_1, guess_2, larger_than_2, vrf_input_1, vrf_input_2, drawKeys, sender) {
|
|
47
|
+
function simulateGame(network_1, packageId_1, module_1, registry_1, index_1, amount_1, guess_1_1, larger_than_1_1, guess_2_1, larger_than_2_1, vrf_input_1_1, vrf_input_2_1, drawKeys_1) {
|
|
48
|
+
return __awaiter(this, arguments, void 0, function (network, packageId, module, registry, index, amount, guess_1, larger_than_1, guess_2, larger_than_2, vrf_input_1, vrf_input_2, drawKeys, sender) {
|
|
49
49
|
var provider, transactionBlock, target, BLS, PRIVATE_KEY, draw_private_key, bls_signature_1, bls_signature_2, transactionBlockArguments, results, bytes, reader, answer_1, result_1, answer_2, result_2, exp, result;
|
|
50
50
|
if (sender === void 0) { sender = "0xb6c7e3b1c61ee81516a8317f221daa035f1503e0ac3ae7a50b61834bc7a3ead9"; }
|
|
51
51
|
return __generator(this, function (_a) {
|
|
@@ -53,7 +53,7 @@ function simulateGame(network_1, packageId_1, registry_1, index_1, amount_1, gue
|
|
|
53
53
|
case 0:
|
|
54
54
|
provider = new client_1.SuiClient({ url: (0, client_1.getFullnodeUrl)(network) });
|
|
55
55
|
transactionBlock = new transactions_1.TransactionBlock();
|
|
56
|
-
target = "".concat(packageId, "::
|
|
56
|
+
target = "".concat(packageId, "::").concat(module, "::simulate_game");
|
|
57
57
|
return [4 /*yield*/, (0, bls_signatures_1.default)()];
|
|
58
58
|
case 1:
|
|
59
59
|
BLS = _a.sent();
|
|
@@ -39,7 +39,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
39
39
|
exports.getRankings = getRankings;
|
|
40
40
|
var transactions_1 = require("@mysten/sui.js/transactions");
|
|
41
41
|
var bcs_1 = require("@mysten/bcs");
|
|
42
|
-
var
|
|
42
|
+
var utils_1 = require("../../utils");
|
|
43
43
|
function getRankings(input) {
|
|
44
44
|
return __awaiter(this, void 0, void 0, function () {
|
|
45
45
|
var transactionBlock, results, bytes, reader, result;
|
|
@@ -78,7 +78,7 @@ function getRankings(input) {
|
|
|
78
78
|
return {
|
|
79
79
|
score: reader.read64(),
|
|
80
80
|
users: reader.readVec(function (reader) {
|
|
81
|
-
return (0,
|
|
81
|
+
return (0, utils_1.AddressFromBytes)(reader.readBytes(32));
|
|
82
82
|
}),
|
|
83
83
|
};
|
|
84
84
|
}
|