@reyaxyz/api-sdk 0.137.0 → 0.137.2
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
CHANGED
|
@@ -6,5 +6,5 @@
|
|
|
6
6
|
|
|
7
7
|
| Statements | Branches | Functions | Lines |
|
|
8
8
|
| --------------------------- | ----------------------- | ------------------------- | ----------------- |
|
|
9
|
-
|  |  |  |  |
|
|
10
10
|
|
|
@@ -63,7 +63,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
63
63
|
};
|
|
64
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
65
|
var common_1 = require("@reyaxyz/common");
|
|
66
|
-
var constants_1 = require("./constants");
|
|
67
66
|
var LotteryClient = /** @class */ (function (_super) {
|
|
68
67
|
__extends(LotteryClient, _super);
|
|
69
68
|
function LotteryClient(serviceEnvironment, host) {
|
|
@@ -74,19 +73,17 @@ var LotteryClient = /** @class */ (function (_super) {
|
|
|
74
73
|
}
|
|
75
74
|
LotteryClient.prototype.getLotteryPotBalance = function () {
|
|
76
75
|
return __awaiter(this, void 0, void 0, function () {
|
|
77
|
-
var lotteryPotOwnerAddress, lotteryPotAccountId, contributionFromReya, uri, lotteryPotMarginAccountData;
|
|
78
76
|
return __generator(this, function (_a) {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
77
|
+
// const lotteryPotOwnerAddress: string =
|
|
78
|
+
// LOTTERY_CONFIGS[this.serviceEnvironment].address;
|
|
79
|
+
// const lotteryPotAccountId: MarginAccountEntity['id'] =
|
|
80
|
+
// LOTTERY_CONFIGS[this.serviceEnvironment].marginAccountId;
|
|
81
|
+
// const contributionFromReya: number = 20000;
|
|
82
|
+
// const uri = `/api/accounts/${lotteryPotOwnerAddress}/marginAccount/${lotteryPotAccountId}`;
|
|
83
|
+
// const lotteryPotMarginAccountData: MarginAccountEntity =
|
|
84
|
+
// await this.get<MarginAccountEntity>(uri);
|
|
85
|
+
// return lotteryPotMarginAccountData.totalBalance + contributionFromReya;
|
|
86
|
+
return [2 /*return*/, 23598.637065];
|
|
90
87
|
});
|
|
91
88
|
});
|
|
92
89
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/lottery/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["clients/modules/lottery/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAKyB;AAGzB;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;;;gBACE,yCAAyC;gBACzC,sDAAsD;gBACtD,yDAAyD;gBACzD,8DAA8D;gBAC9D,8CAA8C;gBAE9C,8FAA8F;gBAC9F,2DAA2D;gBAC3D,8CAA8C;gBAC9C,0EAA0E;gBAE1E,sBAAO,YAAY,EAAC;;;KACrB;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,O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teryWinnersResult } 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 return 23598.637065;\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":"index.d.ts","sourceRoot":"/","sources":["clients/modules/lottery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["clients/modules/lottery/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,kBAAkB,EAElB,0BAA0B,EAC3B,MAAM,iBAAiB,CAAC;AACzB,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;IAevC,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/api-sdk",
|
|
3
|
-
"version": "0.137.
|
|
3
|
+
"version": "0.137.2",
|
|
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.210.
|
|
36
|
+
"@reyaxyz/common": "0.210.1",
|
|
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": "cc6d69ff0156a948b834fe07bc754e7599dd69e9",
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/ws": "8.5.10"
|
|
48
48
|
}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RestClient,
|
|
3
|
-
MarginAccountEntity,
|
|
4
3
|
ServiceEnvironment,
|
|
5
4
|
GetLotteryWinnersResult,
|
|
6
5
|
SelectLotteryWinnersParams,
|
|
7
6
|
} from '@reyaxyz/common';
|
|
8
|
-
import { LOTTERY_CONFIGS } from './constants';
|
|
9
7
|
import { LotteryWinnersResult } from './types';
|
|
10
8
|
|
|
11
9
|
export default class LotteryClient extends RestClient {
|
|
@@ -16,16 +14,18 @@ export default class LotteryClient extends RestClient {
|
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
async getLotteryPotBalance(): Promise<number> {
|
|
19
|
-
const lotteryPotOwnerAddress: string =
|
|
20
|
-
|
|
21
|
-
const lotteryPotAccountId: MarginAccountEntity['id'] =
|
|
22
|
-
|
|
23
|
-
const contributionFromReya: number = 20000;
|
|
24
|
-
|
|
25
|
-
const uri = `/api/accounts/${lotteryPotOwnerAddress}/marginAccount/${lotteryPotAccountId}`;
|
|
26
|
-
const lotteryPotMarginAccountData: MarginAccountEntity =
|
|
27
|
-
|
|
28
|
-
return lotteryPotMarginAccountData.totalBalance + contributionFromReya;
|
|
17
|
+
// const lotteryPotOwnerAddress: string =
|
|
18
|
+
// LOTTERY_CONFIGS[this.serviceEnvironment].address;
|
|
19
|
+
// const lotteryPotAccountId: MarginAccountEntity['id'] =
|
|
20
|
+
// LOTTERY_CONFIGS[this.serviceEnvironment].marginAccountId;
|
|
21
|
+
// const contributionFromReya: number = 20000;
|
|
22
|
+
|
|
23
|
+
// const uri = `/api/accounts/${lotteryPotOwnerAddress}/marginAccount/${lotteryPotAccountId}`;
|
|
24
|
+
// const lotteryPotMarginAccountData: MarginAccountEntity =
|
|
25
|
+
// await this.get<MarginAccountEntity>(uri);
|
|
26
|
+
// return lotteryPotMarginAccountData.totalBalance + contributionFromReya;
|
|
27
|
+
|
|
28
|
+
return 23598.637065;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
async getNumberOfLotteryTickets(walletAddress: string): Promise<number> {
|