@reyaxyz/api-sdk 0.136.1 → 0.137.0
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/README.md +1 -1
- package/dist/clients/modules/lottery/index.js +59 -55
- package/dist/clients/modules/lottery/index.js.map +1 -1
- package/dist/clients/modules/lottery/types.js.map +1 -1
- package/dist/types/clients/modules/lottery/index.d.ts +3 -2
- package/dist/types/clients/modules/lottery/index.d.ts.map +1 -1
- package/dist/types/clients/modules/lottery/types.d.ts +1 -11
- package/dist/types/clients/modules/lottery/types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/clients/modules/lottery/index.ts +46 -67
- package/src/clients/modules/lottery/types.ts +1 -12
package/README.md
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
|
|
7
7
|
| Statements | Branches | Functions | Lines |
|
|
8
8
|
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
|
|
9
|
-
|  |  |  |  |
|
|
10
10
|
|
|
@@ -14,6 +14,17 @@ var __extends = (this && this.__extends) || (function () {
|
|
|
14
14
|
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
15
|
};
|
|
16
16
|
})();
|
|
17
|
+
var __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
17
28
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
29
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
30
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -88,70 +99,63 @@ var LotteryClient = /** @class */ (function (_super) {
|
|
|
88
99
|
});
|
|
89
100
|
});
|
|
90
101
|
};
|
|
91
|
-
LotteryClient.prototype.
|
|
102
|
+
LotteryClient.prototype.getEnhancedLotteryWinners = function (lotteryWinners) {
|
|
92
103
|
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
-
var
|
|
104
|
+
var lotteryPot, amounts, enhancedLotteryWinners;
|
|
94
105
|
return __generator(this, function (_a) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
amount: 10,
|
|
112
|
-
place: 3,
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
executor: {
|
|
116
|
-
address: (0, common_1.convertToAddress)('0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5'),
|
|
117
|
-
timestampMs: 1728389136000,
|
|
118
|
-
},
|
|
119
|
-
}];
|
|
106
|
+
switch (_a.label) {
|
|
107
|
+
case 0: return [4 /*yield*/, this.getLotteryPotBalance()];
|
|
108
|
+
case 1:
|
|
109
|
+
lotteryPot = _a.sent();
|
|
110
|
+
amounts = {
|
|
111
|
+
1: lotteryPot * 0.7,
|
|
112
|
+
2: lotteryPot * 0.2,
|
|
113
|
+
3: lotteryPot * 0.1,
|
|
114
|
+
};
|
|
115
|
+
enhancedLotteryWinners = {
|
|
116
|
+
winners: lotteryWinners.winners.map(function (winner) {
|
|
117
|
+
return __assign(__assign({}, winner), { amount: amounts[winner.place] });
|
|
118
|
+
}),
|
|
119
|
+
executor: lotteryWinners.executor,
|
|
120
|
+
};
|
|
121
|
+
return [2 /*return*/, enhancedLotteryWinners];
|
|
120
122
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
LotteryClient.prototype.getLotteryWinners = function () {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
128
|
+
var uri, lotteryWinners;
|
|
129
|
+
return __generator(this, function (_a) {
|
|
130
|
+
switch (_a.label) {
|
|
131
|
+
case 0:
|
|
132
|
+
uri = '/api/xp/lottery/get-winners';
|
|
133
|
+
return [4 /*yield*/, this.get(uri)];
|
|
134
|
+
case 1:
|
|
135
|
+
lotteryWinners = _a.sent();
|
|
136
|
+
if (lotteryWinners === null) {
|
|
137
|
+
return [2 /*return*/, null];
|
|
138
|
+
}
|
|
139
|
+
return [2 /*return*/, this.getEnhancedLotteryWinners(lotteryWinners)];
|
|
123
140
|
}
|
|
124
|
-
return [2 /*return*/];
|
|
125
141
|
});
|
|
126
142
|
});
|
|
127
143
|
};
|
|
128
|
-
LotteryClient.prototype.selectLotteryWinners = function () {
|
|
144
|
+
LotteryClient.prototype.selectLotteryWinners = function (params) {
|
|
129
145
|
return __awaiter(this, void 0, void 0, function () {
|
|
146
|
+
var uri, lotteryWinners;
|
|
130
147
|
return __generator(this, function (_a) {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
winners
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
place: 2,
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
address: (0, common_1.convertToAddress)('0x1Fe50318e5E3165742eDC9c4a15d997bDB935Eb9'),
|
|
146
|
-
amount: 10,
|
|
147
|
-
place: 3,
|
|
148
|
-
},
|
|
149
|
-
],
|
|
150
|
-
executor: {
|
|
151
|
-
address: (0, common_1.convertToAddress)('0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5'),
|
|
152
|
-
timestampMs: 1728389136000,
|
|
153
|
-
},
|
|
154
|
-
}];
|
|
148
|
+
switch (_a.label) {
|
|
149
|
+
case 0:
|
|
150
|
+
uri = "/api/xp/lottery/select-winners/".concat(params.executorAddress);
|
|
151
|
+
return [4 /*yield*/, this.get(uri)];
|
|
152
|
+
case 1:
|
|
153
|
+
lotteryWinners = _a.sent();
|
|
154
|
+
if (lotteryWinners === null) {
|
|
155
|
+
throw new Error('Unpexpected error while selecting lottery winners');
|
|
156
|
+
}
|
|
157
|
+
return [2 /*return*/, this.getEnhancedLotteryWinners(lotteryWinners)];
|
|
158
|
+
}
|
|
155
159
|
});
|
|
156
160
|
});
|
|
157
161
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/lottery/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/lottery/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAMyB;AACzB,yCAA8C;AAG9C;IAA2C,iCAAU;IAEnD,uBAAY,kBAAsC,EAAE,IAAY;QAC9D,YAAA,MAAK,YAAC,IAAI,CAAC,SAAC;QAFN,wBAAkB,GAAuB,MAAM,CAAC;QAGtD,KAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;;IAC/C,CAAC;IAEK,4CAAoB,GAA1B;;;;;;wBACQ,sBAAsB,GAC1B,2BAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,OAAO,CAAC;wBAC7C,mBAAmB,GACvB,2BAAe,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC,eAAe,CAAC;wBACrD,oBAAoB,GAAW,KAAK,CAAC;wBAErC,GAAG,GAAG,wBAAiB,sBAAsB,4BAAkB,mBAAmB,CAAE,CAAC;wBAEzF,qBAAM,IAAI,CAAC,GAAG,CAAsB,GAAG,CAAC,EAAA;;wBADpC,2BAA2B,GAC/B,SAAwC;wBAC1C,sBAAO,2BAA2B,CAAC,YAAY,GAAG,oBAAoB,EAAC;;;;KACxE;IAEK,iDAAyB,GAA/B,UAAgC,aAAqB;;;gBACnD,+BAA+B;gBAC/B,OAAO,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;gBAC3B,sBAAO,CAAC,EAAC;;;KACV;IAEa,iDAAyB,GAAvC,UACE,cAAuC;;;;;4BAEpB,qBAAM,IAAI,CAAC,oBAAoB,EAAE,EAAA;;wBAA9C,UAAU,GAAG,SAAiC;wBAC9C,OAAO,GAAG;4BACd,CAAC,EAAE,UAAU,GAAG,GAAG;4BACnB,CAAC,EAAE,UAAU,GAAG,GAAG;4BACnB,CAAC,EAAE,UAAU,GAAG,GAAG;yBACpB,CAAC;wBAEI,sBAAsB,GAAyB;4BACnD,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,GAAG,CAAC,UAAC,MAAM;gCACzC,6BACK,MAAM,KACT,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,KAAkB,CAAC,IAC1C;4BACJ,CAAC,CAAC;4BACF,QAAQ,EAAE,cAAc,CAAC,QAAQ;yBAClC,CAAC;wBAEF,sBAAO,sBAAsB,EAAC;;;;KAC/B;IAEK,yCAAiB,GAAvB;;;;;;wBACQ,GAAG,GAAG,6BAA6B,CAAC;wBAGxC,qBAAM,IAAI,CAAC,GAAG,CAAiC,GAAG,CAAC,EAAA;;wBAD/C,cAAc,GAClB,SAAmD;wBAErD,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;4BAC5B,sBAAO,IAAI,EAAC;wBACd,CAAC;wBAED,sBAAO,IAAI,CAAC,yBAAyB,CAAC,cAAc,CAAC,EAAC;;;;KACvD;IAEK,4CAAoB,GAA1B,UACE,MAAkC;;;;;;wBAE5B,GAAG,GAAG,yCAAkC,MAAM,CAAC,eAAe,CAAE,CAAC;wBAGrE,qBAAM,IAAI,CAAC,GAAG,CAA8B,GAAG,CAAC,EAAA;;wBAD5C,cAAc,GAClB,SAAgD;wBAElD,IAAI,cAAc,KAAK,IAAI,EAAE,CAAC;4BAC5B,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAC;wBACvE,CAAC;wBAED,sBAAO,IAAI,CAAC,yBAAyB,CAAC,cAAc,CAAC,EAAC;;;;KACvD;IACH,oBAAC;AAAD,CAAC,AA5ED,CAA2C,mBAAU,GA4EpD","sourcesContent":["import {\n RestClient,\n MarginAccountEntity,\n ServiceEnvironment,\n GetLotteryWinnersResult,\n SelectLotteryWinnersParams,\n} from '@reyaxyz/common';\nimport { LOTTERY_CONFIGS } from './constants';\nimport { LotteryWinnersResult } from './types';\n\nexport default class LotteryClient extends RestClient {\n private serviceEnvironment: ServiceEnvironment = 'test';\n constructor(serviceEnvironment: ServiceEnvironment, host: string) {\n super(host);\n this.serviceEnvironment = serviceEnvironment;\n }\n\n async getLotteryPotBalance(): Promise<number> {\n const lotteryPotOwnerAddress: string =\n LOTTERY_CONFIGS[this.serviceEnvironment].address;\n const lotteryPotAccountId: MarginAccountEntity['id'] =\n LOTTERY_CONFIGS[this.serviceEnvironment].marginAccountId;\n const contributionFromReya: number = 20000;\n\n const uri = `/api/accounts/${lotteryPotOwnerAddress}/marginAccount/${lotteryPotAccountId}`;\n const lotteryPotMarginAccountData: MarginAccountEntity =\n await this.get<MarginAccountEntity>(uri);\n return lotteryPotMarginAccountData.totalBalance + contributionFromReya;\n }\n\n async getNumberOfLotteryTickets(walletAddress: string): Promise<number> {\n // todo: p1: add implementation\n console.log(walletAddress);\n return 1;\n }\n\n private async getEnhancedLotteryWinners(\n lotteryWinners: GetLotteryWinnersResult,\n ): Promise<LotteryWinnersResult> {\n const lotteryPot = await this.getLotteryPotBalance();\n const amounts = {\n 1: lotteryPot * 0.7,\n 2: lotteryPot * 0.2,\n 3: lotteryPot * 0.1,\n };\n\n const enhancedLotteryWinners: LotteryWinnersResult = {\n winners: lotteryWinners.winners.map((winner) => {\n return {\n ...winner,\n amount: amounts[winner.place as 1 | 2 | 3],\n };\n }),\n executor: lotteryWinners.executor,\n };\n\n return enhancedLotteryWinners;\n }\n\n async getLotteryWinners(): Promise<LotteryWinnersResult | null> {\n const uri = '/api/xp/lottery/get-winners';\n\n const lotteryWinners: GetLotteryWinnersResult | null =\n await this.get<GetLotteryWinnersResult | null>(uri);\n\n if (lotteryWinners === null) {\n return null;\n }\n\n return this.getEnhancedLotteryWinners(lotteryWinners);\n }\n\n async selectLotteryWinners(\n params: SelectLotteryWinnersParams,\n ): Promise<LotteryWinnersResult> {\n const uri = `/api/xp/lottery/select-winners/${params.executorAddress}`;\n\n const lotteryWinners: LotteryWinnersResult | null =\n await this.get<LotteryWinnersResult | null>(uri);\n\n if (lotteryWinners === null) {\n throw new Error('Unpexpected error while selecting lottery winners');\n }\n\n return this.getEnhancedLotteryWinners(lotteryWinners);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/lottery/types.ts"],"names":[],"mappings":"","sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["clients/modules/lottery/types.ts"],"names":[],"mappings":"","sourcesContent":["import { WinnerData, ExecutorData } from '@reyaxyz/common';\n\nexport type LotteryWinnersResult = {\n winners: WinnerData[];\n executor: ExecutorData;\n};\n"]}
|
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { RestClient, ServiceEnvironment } from '@reyaxyz/common';
|
|
1
|
+
import { RestClient, ServiceEnvironment, SelectLotteryWinnersParams } from '@reyaxyz/common';
|
|
2
2
|
import { LotteryWinnersResult } from './types';
|
|
3
3
|
export default class LotteryClient extends RestClient {
|
|
4
4
|
private serviceEnvironment;
|
|
5
5
|
constructor(serviceEnvironment: ServiceEnvironment, host: string);
|
|
6
6
|
getLotteryPotBalance(): Promise<number>;
|
|
7
7
|
getNumberOfLotteryTickets(walletAddress: string): Promise<number>;
|
|
8
|
+
private getEnhancedLotteryWinners;
|
|
8
9
|
getLotteryWinners(): Promise<LotteryWinnersResult | null>;
|
|
9
|
-
selectLotteryWinners(): Promise<LotteryWinnersResult>;
|
|
10
|
+
selectLotteryWinners(params: SelectLotteryWinnersParams): Promise<LotteryWinnersResult>;
|
|
10
11
|
}
|
|
11
12
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/lottery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAEV,kBAAkB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/lottery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EAEV,kBAAkB,EAElB,0BAA0B,EAC3B,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAE/C,MAAM,CAAC,OAAO,OAAO,aAAc,SAAQ,UAAU;IACnD,OAAO,CAAC,kBAAkB,CAA8B;gBAC5C,kBAAkB,EAAE,kBAAkB,EAAE,IAAI,EAAE,MAAM;IAK1D,oBAAoB,IAAI,OAAO,CAAC,MAAM,CAAC;IAavC,yBAAyB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;YAMzD,yBAAyB;IAuBjC,iBAAiB,IAAI,OAAO,CAAC,oBAAoB,GAAG,IAAI,CAAC;IAazD,oBAAoB,CACxB,MAAM,EAAE,0BAA0B,GACjC,OAAO,CAAC,oBAAoB,CAAC;CAYjC"}
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
type WinnerData = {
|
|
3
|
-
address: Address;
|
|
4
|
-
amount: number;
|
|
5
|
-
place: number;
|
|
6
|
-
};
|
|
7
|
-
type ExecutorData = {
|
|
8
|
-
address: Address;
|
|
9
|
-
timestampMs: number;
|
|
10
|
-
};
|
|
1
|
+
import { WinnerData, ExecutorData } from '@reyaxyz/common';
|
|
11
2
|
export type LotteryWinnersResult = {
|
|
12
3
|
winners: WinnerData[];
|
|
13
4
|
executor: ExecutorData;
|
|
14
5
|
};
|
|
15
|
-
export {};
|
|
16
6
|
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/lottery/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["clients/modules/lottery/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAE3D,MAAM,MAAM,oBAAoB,GAAG;IACjC,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,QAAQ,EAAE,YAAY,CAAC;CACxB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/api-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.137.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@reyaxyz/common": "0.
|
|
36
|
+
"@reyaxyz/common": "0.210.0",
|
|
37
37
|
"@simplewebauthn/types": "^10.0.0",
|
|
38
38
|
"axios": "^1.6.2",
|
|
39
39
|
"bignumber.js": "^9.1.2",
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
"ws": "^8.16.0"
|
|
43
43
|
},
|
|
44
44
|
"packageManager": "pnpm@8.3.1",
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "1c9a103892678fd3f8971a550980bb8cac55ed6e",
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/ws": "8.5.10"
|
|
48
48
|
}
|
|
@@ -2,7 +2,8 @@ import {
|
|
|
2
2
|
RestClient,
|
|
3
3
|
MarginAccountEntity,
|
|
4
4
|
ServiceEnvironment,
|
|
5
|
-
|
|
5
|
+
GetLotteryWinnersResult,
|
|
6
|
+
SelectLotteryWinnersParams,
|
|
6
7
|
} from '@reyaxyz/common';
|
|
7
8
|
import { LOTTERY_CONFIGS } from './constants';
|
|
8
9
|
import { LotteryWinnersResult } from './types';
|
|
@@ -33,76 +34,54 @@ export default class LotteryClient extends RestClient {
|
|
|
33
34
|
return 1;
|
|
34
35
|
}
|
|
35
36
|
|
|
37
|
+
private async getEnhancedLotteryWinners(
|
|
38
|
+
lotteryWinners: GetLotteryWinnersResult,
|
|
39
|
+
): Promise<LotteryWinnersResult> {
|
|
40
|
+
const lotteryPot = await this.getLotteryPotBalance();
|
|
41
|
+
const amounts = {
|
|
42
|
+
1: lotteryPot * 0.7,
|
|
43
|
+
2: lotteryPot * 0.2,
|
|
44
|
+
3: lotteryPot * 0.1,
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const enhancedLotteryWinners: LotteryWinnersResult = {
|
|
48
|
+
winners: lotteryWinners.winners.map((winner) => {
|
|
49
|
+
return {
|
|
50
|
+
...winner,
|
|
51
|
+
amount: amounts[winner.place as 1 | 2 | 3],
|
|
52
|
+
};
|
|
53
|
+
}),
|
|
54
|
+
executor: lotteryWinners.executor,
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return enhancedLotteryWinners;
|
|
58
|
+
}
|
|
59
|
+
|
|
36
60
|
async getLotteryWinners(): Promise<LotteryWinnersResult | null> {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
address: convertToAddress(
|
|
44
|
-
'0xF8F6B70a36f4398f0853a311dC6699Aba8333Cc1',
|
|
45
|
-
),
|
|
46
|
-
amount: 70,
|
|
47
|
-
place: 1,
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
address: convertToAddress(
|
|
51
|
-
'0xaE173a960084903b1d278Ff9E3A81DeD82275556',
|
|
52
|
-
),
|
|
53
|
-
amount: 20,
|
|
54
|
-
place: 2,
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
address: convertToAddress(
|
|
58
|
-
'0x1Fe50318e5E3165742eDC9c4a15d997bDB935Eb9',
|
|
59
|
-
),
|
|
60
|
-
amount: 10,
|
|
61
|
-
place: 3,
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
executor: {
|
|
65
|
-
address: convertToAddress(
|
|
66
|
-
'0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5',
|
|
67
|
-
),
|
|
68
|
-
timestampMs: 1728389136000,
|
|
69
|
-
},
|
|
70
|
-
};
|
|
71
|
-
} else {
|
|
61
|
+
const uri = '/api/xp/lottery/get-winners';
|
|
62
|
+
|
|
63
|
+
const lotteryWinners: GetLotteryWinnersResult | null =
|
|
64
|
+
await this.get<GetLotteryWinnersResult | null>(uri);
|
|
65
|
+
|
|
66
|
+
if (lotteryWinners === null) {
|
|
72
67
|
return null;
|
|
73
68
|
}
|
|
69
|
+
|
|
70
|
+
return this.getEnhancedLotteryWinners(lotteryWinners);
|
|
74
71
|
}
|
|
75
72
|
|
|
76
|
-
async selectLotteryWinners(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
'0xaE173a960084903b1d278Ff9E3A81DeD82275556',
|
|
90
|
-
),
|
|
91
|
-
amount: 20,
|
|
92
|
-
place: 2,
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
address: convertToAddress(
|
|
96
|
-
'0x1Fe50318e5E3165742eDC9c4a15d997bDB935Eb9',
|
|
97
|
-
),
|
|
98
|
-
amount: 10,
|
|
99
|
-
place: 3,
|
|
100
|
-
},
|
|
101
|
-
],
|
|
102
|
-
executor: {
|
|
103
|
-
address: convertToAddress('0x95222290dd7278aa3ddd389cc1e1d165cc4bafe5'),
|
|
104
|
-
timestampMs: 1728389136000,
|
|
105
|
-
},
|
|
106
|
-
};
|
|
73
|
+
async selectLotteryWinners(
|
|
74
|
+
params: SelectLotteryWinnersParams,
|
|
75
|
+
): Promise<LotteryWinnersResult> {
|
|
76
|
+
const uri = `/api/xp/lottery/select-winners/${params.executorAddress}`;
|
|
77
|
+
|
|
78
|
+
const lotteryWinners: LotteryWinnersResult | null =
|
|
79
|
+
await this.get<LotteryWinnersResult | null>(uri);
|
|
80
|
+
|
|
81
|
+
if (lotteryWinners === null) {
|
|
82
|
+
throw new Error('Unpexpected error while selecting lottery winners');
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return this.getEnhancedLotteryWinners(lotteryWinners);
|
|
107
86
|
}
|
|
108
87
|
}
|
|
@@ -1,15 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
type WinnerData = {
|
|
4
|
-
address: Address;
|
|
5
|
-
amount: number;
|
|
6
|
-
place: number;
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
type ExecutorData = {
|
|
10
|
-
address: Address;
|
|
11
|
-
timestampMs: number;
|
|
12
|
-
};
|
|
1
|
+
import { WinnerData, ExecutorData } from '@reyaxyz/common';
|
|
13
2
|
|
|
14
3
|
export type LotteryWinnersResult = {
|
|
15
4
|
winners: WinnerData[];
|