@reyaxyz/community-sdk 0.32.4 → 0.32.5
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/modules/vote/index.js +20 -1
- package/dist/modules/vote/index.js.map +1 -1
- package/dist/modules/vote/services/vote/index.js +1 -2
- package/dist/modules/vote/services/vote/index.js.map +1 -1
- package/dist/modules/vote/types.js.map +1 -1
- package/dist/types/modules/vote/index.d.ts.map +1 -1
- package/dist/types/modules/vote/services/vote/index.d.ts +2 -2
- package/dist/types/modules/vote/services/vote/index.d.ts.map +1 -1
- package/dist/types/modules/vote/types.d.ts +5 -1
- package/dist/types/modules/vote/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/modules/vote/index.ts +4 -1
- package/src/modules/vote/services/vote/index.ts +3 -4
- package/src/modules/vote/types.ts +11 -1
|
@@ -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 __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
18
29
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
19
30
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -71,8 +82,16 @@ var VoteModule = /** @class */ (function (_super) {
|
|
|
71
82
|
// WRITE
|
|
72
83
|
VoteModule.prototype.vote = function (params) {
|
|
73
84
|
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
+
var uri, metadata;
|
|
74
86
|
return __generator(this, function (_a) {
|
|
75
|
-
|
|
87
|
+
switch (_a.label) {
|
|
88
|
+
case 0:
|
|
89
|
+
uri = "/api/vote/contract-details/".concat(params.slug);
|
|
90
|
+
return [4 /*yield*/, this.get(uri)];
|
|
91
|
+
case 1:
|
|
92
|
+
metadata = _a.sent();
|
|
93
|
+
return [2 /*return*/, (0, services_1.vote)(__assign(__assign({}, params), { contractAddress: metadata.contractAddress }))];
|
|
94
|
+
}
|
|
76
95
|
});
|
|
77
96
|
});
|
|
78
97
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/vote/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/vote/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA6C;AAS7C,uCAAkC;AAClC,0CAAmD;AAEnD;IAAwC,8BAAU;IAGhD,oBAAY,MAAc,EAAE,cAAuB;QACjD,YAAA,MAAK,YAAC,MAAM,CAAC,SAAC;QAHhB,oBAAc,GAAY,KAAK,CAAC;QAI9B,KAAI,CAAC,cAAc,GAAG,cAAc,CAAC;;IACvC,CAAC;IAED,QAAQ;IAEF,yBAAI,GAAJ,UAAK,MAAkB;;;;;;wBACrB,GAAG,GAAG,qCAA8B,MAAM,CAAC,IAAI,CAAE,CAAC;wBACvC,qBAAM,IAAI,CAAC,GAAG,CAA+B,GAAG,CAAC,EAAA;;wBAA5D,QAAQ,GAAG,SAAiD;wBAClE,sBAAO,IAAA,eAAI,wBAAM,MAAM,KAAE,eAAe,EAAE,QAAQ,CAAC,eAAe,IAAG,EAAC;;;;KACvE;IAED,OAAO;IAED,mCAAc,GAAd,UAAe,MAA4B;;;;gBACzC,GAAG,GAAG,oBAAa,MAAM,CAAC,IAAI,CAAE,CAAC;gBACvC,sBAAO,IAAI,CAAC,GAAG,CAAuB,GAAG,CAAC,EAAC;;;KAC5C;IAGK,kCAAa,GAAb,UAAc,MAA2B;;;;gBACvC,GAAG,GAAG,oBAAa,MAAM,CAAC,IAAI,mBAAS,MAAM,CAAC,OAAO,CAAE,CAAC;gBAC9D,sBAAO,IAAI,CAAC,GAAG,CAAsB,GAAG,CAAC,EAAC;;;KAC3C;IAjBK;QADL,IAAA,eAAM,EAAC,iBAAiB,CAAC;0CAKzB;IAIK;QADL,IAAA,eAAM,EAAC,2BAA2B,CAAC;oDAInC;IAGK;QADL,IAAA,eAAM,EAAC,0BAA0B,CAAC;mDAIlC;IACH,iBAAC;CAAA,AA5BD,CAAwC,mBAAU,GA4BjD;kBA5BoB,UAAU","sourcesContent":["import { RestClient } from '@reyaxyz/common';\nimport {\n GetVoteContractDetailsResult,\n GetVoteDetailsParams,\n GetVoteDetailsResult,\n GetVoteStatusParams,\n GetVoteStatusResult,\n VoteParams,\n} from './types';\nimport { vote } from './services';\nimport { Logger, Loggable } from '@reyaxyz/common';\n\nexport default class VoteModule extends RestClient implements Loggable {\n loggingEnabled: boolean = false;\n\n constructor(apiUrl: string, loggingEnabled: boolean) {\n super(apiUrl);\n this.loggingEnabled = loggingEnabled;\n }\n\n // WRITE\n @Logger('VoteModule.vote')\n async vote(params: VoteParams) {\n const uri = `/api/vote/contract-details/${params.slug}`;\n const metadata = await this.get<GetVoteContractDetailsResult>(uri);\n return vote({ ...params, contractAddress: metadata.contractAddress });\n }\n\n // READ\n @Logger('VoteModule.getVoteDetails')\n async getVoteDetails(params: GetVoteDetailsParams) {\n const uri = `/api/vote/${params.slug}`;\n return this.get<GetVoteDetailsResult>(uri);\n }\n\n @Logger('VoteModule.getVoteStatus')\n async getVoteStatus(params: GetVoteStatusParams) {\n const uri = `/api/vote/${params.slug}/user/${params.address}`;\n return this.get<GetVoteStatusResult>(uri);\n }\n}\n"]}
|
|
@@ -37,7 +37,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
39
|
exports.vote = void 0;
|
|
40
|
-
var contractAddresses_1 = require("../../../../utils/contractAddresses");
|
|
41
40
|
var executeTransaction_1 = require("../executeTransaction");
|
|
42
41
|
var encode_1 = require("./encode");
|
|
43
42
|
var vote = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
@@ -54,7 +53,7 @@ var vote = function (params) { return __awaiter(void 0, void 0, void 0, function
|
|
|
54
53
|
_c.label = 2;
|
|
55
54
|
case 2:
|
|
56
55
|
_c.trys.push([2, 4, , 5]);
|
|
57
|
-
return [4 /*yield*/, (0, executeTransaction_1.executeTransaction)(params.signer, data, value, chainId,
|
|
56
|
+
return [4 /*yield*/, (0, executeTransaction_1.executeTransaction)(params.signer, data, value, chainId, params.contractAddress)];
|
|
58
57
|
case 3:
|
|
59
58
|
result = _c.sent();
|
|
60
59
|
return [2 /*return*/, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/vote/services/vote/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/vote/services/vote/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4DAA2D;AAC3D,mCAA0C;AAGnC,IAAM,IAAI,GAAG,UAAO,MAAyB;;;;;;gBAC5C,KAA4B,IAAA,uBAAc,EAAC,MAAM,CAAC,KAAK,IAAI,KAAK,CAAC,EAArD,IAAI,cAAA,EAAE,KAAK,WAAA,CAA2C;gBAExD,qBAAM,CAAA,MAAA,MAAM,CAAC,MAAM,CAAC,QAAQ,0CAAE,UAAU,EAAE,CAAA,EAAA;;gBAApD,OAAO,GAAG,SAA0C;gBACpD,OAAO,GAAG,MAAM,CAAC,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,OAAO,CAAC,CAAC;;;;gBAGxB,qBAAM,IAAA,uCAAkB,EACrC,MAAM,CAAC,MAAM,EACb,IAAI,EACJ,KAAK,EACL,OAAO,EACP,MAAM,CAAC,eAAe,CACvB,EAAA;;gBANK,MAAM,GAAG,SAMd;gBACD,sBAAO;wBACL,eAAe,EAAE,CAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,KAAI,IAAI;qBACtC,EAAC;;;gBAEF,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;;;;KAEjE,CAAC;AApBW,QAAA,IAAI,QAoBf","sourcesContent":["import { executeTransaction } from '../executeTransaction';\nimport { encodeCastVote } from './encode';\nimport { ExecuteVoteParams, VoteResult } from '../../types';\n\nexport const vote = async (params: ExecuteVoteParams): Promise<VoteResult> => {\n const { calldata: data, value } = encodeCastVote(params.voted == 'yes');\n\n const network = await params.signer.provider?.getNetwork();\n const chainId = Number(network?.chainId);\n\n try {\n const result = await executeTransaction(\n params.signer,\n data,\n value,\n chainId,\n params.contractAddress,\n );\n return {\n transactionHash: result?.hash || null,\n };\n } catch (error) {\n throw new Error('Vote failed. Please reach out via Discord.');\n }\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["modules/vote/types.ts"],"names":[],"mappings":"","sourcesContent":["import { JsonRpcSigner, Signer } from 'ethers';\nimport {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["modules/vote/types.ts"],"names":[],"mappings":"","sourcesContent":["import { JsonRpcSigner, Signer } from 'ethers';\nimport {\n VoteDetailsEntity,\n VoteContractDetailsEntity,\n VoteStatusEntity,\n} from '@reyaxyz/common';\n\nexport type VoteResult = {\n transactionHash: string | null;\n};\n\nexport type GetVoteDetailsParams = {\n slug: VoteDetailsEntity['slug'];\n};\nexport type GetVoteDetailsResult = VoteDetailsEntity;\n\nexport type GetVoteContractDetailsResult = VoteContractDetailsEntity;\n\nexport type VoteParams = {\n slug: VoteDetailsEntity['slug'];\n voted: 'yes' | 'no';\n signer: Signer | JsonRpcSigner;\n};\n\nexport type ExecuteVoteParams = VoteParams & {\n contractAddress: string;\n};\n\nexport type GetVoteStatusParams = {\n address: string;\n slug: VoteDetailsEntity['slug'];\n};\nexport type GetVoteStatusResult = VoteStatusEntity;\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/vote/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/vote/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAEL,oBAAoB,EAEpB,mBAAmB,EAEnB,UAAU,EACX,MAAM,SAAS,CAAC;AAEjB,OAAO,EAAU,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,UAAW,YAAW,QAAQ;IACpE,cAAc,EAAE,OAAO,CAAS;gBAEpB,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO;IAO7C,IAAI,CAAC,MAAM,EAAE,UAAU;IAQvB,cAAc,CAAC,MAAM,EAAE,oBAAoB;IAM3C,aAAa,CAAC,MAAM,EAAE,mBAAmB;CAIhD"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export declare const vote: (params:
|
|
1
|
+
import { ExecuteVoteParams, VoteResult } from '../../types';
|
|
2
|
+
export declare const vote: (params: ExecuteVoteParams) => Promise<VoteResult>;
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/vote/services/vote/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/vote/services/vote/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE5D,eAAO,MAAM,IAAI,WAAkB,iBAAiB,KAAG,QAAQ,UAAU,CAoBxE,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { JsonRpcSigner, Signer } from 'ethers';
|
|
2
|
-
import { VoteDetailsEntity, VoteStatusEntity } from '@reyaxyz/common';
|
|
2
|
+
import { VoteDetailsEntity, VoteContractDetailsEntity, VoteStatusEntity } from '@reyaxyz/common';
|
|
3
3
|
export type VoteResult = {
|
|
4
4
|
transactionHash: string | null;
|
|
5
5
|
};
|
|
@@ -7,11 +7,15 @@ export type GetVoteDetailsParams = {
|
|
|
7
7
|
slug: VoteDetailsEntity['slug'];
|
|
8
8
|
};
|
|
9
9
|
export type GetVoteDetailsResult = VoteDetailsEntity;
|
|
10
|
+
export type GetVoteContractDetailsResult = VoteContractDetailsEntity;
|
|
10
11
|
export type VoteParams = {
|
|
11
12
|
slug: VoteDetailsEntity['slug'];
|
|
12
13
|
voted: 'yes' | 'no';
|
|
13
14
|
signer: Signer | JsonRpcSigner;
|
|
14
15
|
};
|
|
16
|
+
export type ExecuteVoteParams = VoteParams & {
|
|
17
|
+
contractAddress: string;
|
|
18
|
+
};
|
|
15
19
|
export type GetVoteStatusParams = {
|
|
16
20
|
address: string;
|
|
17
21
|
slug: VoteDetailsEntity['slug'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["modules/vote/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["modules/vote/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,EACL,iBAAiB,EACjB,yBAAyB,EACzB,gBAAgB,EACjB,MAAM,iBAAiB,CAAC;AAEzB,MAAM,MAAM,UAAU,GAAG;IACvB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;CACjC,CAAC;AACF,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AAErD,MAAM,MAAM,4BAA4B,GAAG,yBAAyB,CAAC;AAErE,MAAM,MAAM,UAAU,GAAG;IACvB,IAAI,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAChC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,GAAG,aAAa,CAAC;CAChC,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,UAAU,GAAG;IAC3C,eAAe,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;CACjC,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@reyaxyz/community-sdk",
|
|
3
|
-
"version": "0.32.
|
|
3
|
+
"version": "0.32.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -10,8 +10,8 @@
|
|
|
10
10
|
"url": "https://github.com/Reya-Labs/reya-off-chain-monorepo.git"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@reyaxyz/common": "0.93.
|
|
14
|
-
"@reyaxyz/sdk": "0.78.
|
|
13
|
+
"@reyaxyz/common": "0.93.1",
|
|
14
|
+
"@reyaxyz/sdk": "0.78.2",
|
|
15
15
|
"ethers": "6.9.0"
|
|
16
16
|
},
|
|
17
17
|
"main": "dist/index.js",
|
|
@@ -38,5 +38,5 @@
|
|
|
38
38
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
39
39
|
},
|
|
40
40
|
"packageManager": "pnpm@8.3.1",
|
|
41
|
-
"gitHead": "
|
|
41
|
+
"gitHead": "4cb15327562c48491a5d1313386d207447f76772"
|
|
42
42
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { RestClient } from '@reyaxyz/common';
|
|
2
2
|
import {
|
|
3
|
+
GetVoteContractDetailsResult,
|
|
3
4
|
GetVoteDetailsParams,
|
|
4
5
|
GetVoteDetailsResult,
|
|
5
6
|
GetVoteStatusParams,
|
|
@@ -20,7 +21,9 @@ export default class VoteModule extends RestClient implements Loggable {
|
|
|
20
21
|
// WRITE
|
|
21
22
|
@Logger('VoteModule.vote')
|
|
22
23
|
async vote(params: VoteParams) {
|
|
23
|
-
|
|
24
|
+
const uri = `/api/vote/contract-details/${params.slug}`;
|
|
25
|
+
const metadata = await this.get<GetVoteContractDetailsResult>(uri);
|
|
26
|
+
return vote({ ...params, contractAddress: metadata.contractAddress });
|
|
24
27
|
}
|
|
25
28
|
|
|
26
29
|
// READ
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { ContractType } from '../../../../utils/contractAddresses';
|
|
2
1
|
import { executeTransaction } from '../executeTransaction';
|
|
3
2
|
import { encodeCastVote } from './encode';
|
|
4
|
-
import {
|
|
3
|
+
import { ExecuteVoteParams, VoteResult } from '../../types';
|
|
5
4
|
|
|
6
|
-
export const vote = async (params:
|
|
5
|
+
export const vote = async (params: ExecuteVoteParams): Promise<VoteResult> => {
|
|
7
6
|
const { calldata: data, value } = encodeCastVote(params.voted == 'yes');
|
|
8
7
|
|
|
9
8
|
const network = await params.signer.provider?.getNetwork();
|
|
@@ -15,7 +14,7 @@ export const vote = async (params: VoteParams): Promise<VoteResult> => {
|
|
|
15
14
|
data,
|
|
16
15
|
value,
|
|
17
16
|
chainId,
|
|
18
|
-
|
|
17
|
+
params.contractAddress,
|
|
19
18
|
);
|
|
20
19
|
return {
|
|
21
20
|
transactionHash: result?.hash || null,
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { JsonRpcSigner, Signer } from 'ethers';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
VoteDetailsEntity,
|
|
4
|
+
VoteContractDetailsEntity,
|
|
5
|
+
VoteStatusEntity,
|
|
6
|
+
} from '@reyaxyz/common';
|
|
3
7
|
|
|
4
8
|
export type VoteResult = {
|
|
5
9
|
transactionHash: string | null;
|
|
@@ -10,12 +14,18 @@ export type GetVoteDetailsParams = {
|
|
|
10
14
|
};
|
|
11
15
|
export type GetVoteDetailsResult = VoteDetailsEntity;
|
|
12
16
|
|
|
17
|
+
export type GetVoteContractDetailsResult = VoteContractDetailsEntity;
|
|
18
|
+
|
|
13
19
|
export type VoteParams = {
|
|
14
20
|
slug: VoteDetailsEntity['slug'];
|
|
15
21
|
voted: 'yes' | 'no';
|
|
16
22
|
signer: Signer | JsonRpcSigner;
|
|
17
23
|
};
|
|
18
24
|
|
|
25
|
+
export type ExecuteVoteParams = VoteParams & {
|
|
26
|
+
contractAddress: string;
|
|
27
|
+
};
|
|
28
|
+
|
|
19
29
|
export type GetVoteStatusParams = {
|
|
20
30
|
address: string;
|
|
21
31
|
slug: VoteDetailsEntity['slug'];
|