@reyaxyz/community-sdk 0.48.8 → 0.49.1
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/sbt/index.js +3 -49
- package/dist/modules/sbt/index.js.map +1 -1
- package/dist/modules/vote/index.js +3 -63
- package/dist/modules/vote/index.js.map +1 -1
- package/dist/modules/vote/services/vote/index.js +1 -50
- package/dist/modules/vote/services/vote/index.js.map +1 -1
- package/dist/modules/vote/types.js.map +1 -1
- package/dist/types/modules/sbt/index.d.ts.map +1 -1
- package/dist/types/modules/vote/index.d.ts +2 -5
- package/dist/types/modules/vote/index.d.ts.map +1 -1
- package/dist/types/modules/vote/services/vote/index.d.ts +1 -2
- package/dist/types/modules/vote/services/vote/index.d.ts.map +1 -1
- package/dist/types/modules/vote/types.d.ts +1 -8
- package/dist/types/modules/vote/types.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/modules/sbt/index.ts +4 -39
- package/src/modules/vote/index.ts +3 -44
- package/src/modules/vote/services/vote/index.ts +3 -59
- package/src/modules/vote/types.ts +1 -15
- package/dist/modules/sbt/services/index.js +0 -18
- package/dist/modules/sbt/services/index.js.map +0 -1
- package/dist/modules/sbt/services/signMintTx.js +0 -70
- package/dist/modules/sbt/services/signMintTx.js.map +0 -1
- package/dist/types/modules/sbt/services/index.d.ts +0 -2
- package/dist/types/modules/sbt/services/index.d.ts.map +0 -1
- package/dist/types/modules/sbt/services/signMintTx.d.ts +0 -3
- package/dist/types/modules/sbt/services/signMintTx.d.ts.map +0 -1
- package/src/modules/sbt/services/index.ts +0 -1
- package/src/modules/sbt/services/signMintTx.ts +0 -40
|
@@ -58,7 +58,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
58
58
|
};
|
|
59
59
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
60
60
|
var common_1 = require("@reyaxyz/common");
|
|
61
|
-
var signMintTx_1 = require("./services/signMintTx");
|
|
62
61
|
var common_2 = require("@reyaxyz/common");
|
|
63
62
|
var SbtModule = /** @class */ (function (_super) {
|
|
64
63
|
__extends(SbtModule, _super);
|
|
@@ -70,55 +69,9 @@ var SbtModule = /** @class */ (function (_super) {
|
|
|
70
69
|
}
|
|
71
70
|
// WRITE
|
|
72
71
|
SbtModule.prototype.mint = function (params) {
|
|
73
|
-
var _a, _b;
|
|
74
72
|
return __awaiter(this, void 0, void 0, function () {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
return __generator(this, function (_g) {
|
|
78
|
-
switch (_g.label) {
|
|
79
|
-
case 0: return [4 /*yield*/, params.signer.getAddress()];
|
|
80
|
-
case 1:
|
|
81
|
-
owner = _g.sent();
|
|
82
|
-
userRoot = '';
|
|
83
|
-
_g.label = 2;
|
|
84
|
-
case 2:
|
|
85
|
-
_g.trys.push([2, 4, , 6]);
|
|
86
|
-
userRootUri = "/api/sbt/root/owner/".concat(owner, "/tokenCount/0");
|
|
87
|
-
return [4 /*yield*/, this.get(userRootUri)];
|
|
88
|
-
case 3:
|
|
89
|
-
userRoot = _g.sent();
|
|
90
|
-
return [3 /*break*/, 6];
|
|
91
|
-
case 4:
|
|
92
|
-
e_1 = _g.sent();
|
|
93
|
-
return [4 /*yield*/, ((_a = params.signer.provider) === null || _a === void 0 ? void 0 : _a.getNetwork())];
|
|
94
|
-
case 5:
|
|
95
|
-
network = _g.sent();
|
|
96
|
-
if (!network) {
|
|
97
|
-
throw new Error('Mint failed. Network not found to get root.');
|
|
98
|
-
}
|
|
99
|
-
reyaChainId = Number(network.chainId);
|
|
100
|
-
userRoot = (_b = common_1.SBT_ROOT[reyaChainId]) !== null && _b !== void 0 ? _b : '';
|
|
101
|
-
return [3 /*break*/, 6];
|
|
102
|
-
case 6: return [4 /*yield*/, (0, signMintTx_1.signMint)(params, userRoot)];
|
|
103
|
-
case 7:
|
|
104
|
-
_c = _g.sent(), signature = _c.signature, signatureDeadline = _c.deadline, sbtRoot = _c.sbtRoot;
|
|
105
|
-
mintUri = "/api/sbt/mint";
|
|
106
|
-
_d = this.put;
|
|
107
|
-
_e = [mintUri,
|
|
108
|
-
{}];
|
|
109
|
-
_f = {};
|
|
110
|
-
return [4 /*yield*/, params.signer.getAddress()];
|
|
111
|
-
case 8: return [4 /*yield*/, _d.apply(this, _e.concat([(_f.owner = _g.sent(),
|
|
112
|
-
_f.merkleRoot = sbtRoot,
|
|
113
|
-
_f.tokenRootCounter = 0,
|
|
114
|
-
_f.signature = signature,
|
|
115
|
-
_f.signatureDeadline = signatureDeadline,
|
|
116
|
-
_f)]))];
|
|
117
|
-
case 9:
|
|
118
|
-
result = _g.sent();
|
|
119
|
-
response = { transactionHash: result.txHash };
|
|
120
|
-
return [2 /*return*/, response];
|
|
121
|
-
}
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
throw new Error('Unimplemented.');
|
|
122
75
|
});
|
|
123
76
|
});
|
|
124
77
|
};
|
|
@@ -143,6 +96,7 @@ var SbtModule = /** @class */ (function (_super) {
|
|
|
143
96
|
};
|
|
144
97
|
__decorate([
|
|
145
98
|
(0, common_2.Logger)('SbtModule.mint')
|
|
99
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
146
100
|
], SbtModule.prototype, "mint", null);
|
|
147
101
|
__decorate([
|
|
148
102
|
(0, common_2.Logger)('SbtModule.getSbtMintedStatus')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/sbt/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/sbt/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,0CAA6C;AAQ7C,0CAAmD;AAEnD;IAAuC,6BAAU;IAG/C,mBAAY,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;IAGF,wBAAI,GAAJ,UAAK,MAAqB;;;gBAC9B,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;;;KACnC;IAED,OAAO;IAED,sCAAkB,GAAlB,UAAmB,MAA0B;;;;gBAC3C,GAAG,GAAG,qCAA8B,MAAM,CAAC,YAAY,kBAAe,CAAC;gBAC7E,sBAAO,IAAI,CAAC,GAAG,CAAqB,GAAG,CAAC,EAAC;;;KAC1C;IAGK,+BAAW,GAAX;;;;gBACE,GAAG,GAAG,eAAe,CAAC;gBAC5B,sBAAO,IAAI,CAAC,GAAG,CAAoB,GAAG,CAAC,EAAC;;;KACzC;IAfK;QAFL,IAAA,eAAM,EAAC,gBAAgB,CAAC;QACzB,6DAA6D;yCAG5D;IAIK;QADL,IAAA,eAAM,EAAC,8BAA8B,CAAC;uDAItC;IAGK;QADL,IAAA,eAAM,EAAC,uBAAuB,CAAC;gDAI/B;IACH,gBAAC;CAAA,AA3BD,CAAuC,mBAAU,GA2BhD;kBA3BoB,SAAS","sourcesContent":["import { RestClient } from '@reyaxyz/common';\nimport {\n SbtMintResult,\n SbtMintParams,\n GetSbtMintedParams,\n GetSbtMintedResult,\n GetSbtsInfoResult,\n} from './types';\nimport { Logger, Loggable } from '@reyaxyz/common';\n\nexport default class SbtModule 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('SbtModule.mint')\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async mint(params: SbtMintParams): Promise<SbtMintResult> {\n throw new Error('Unimplemented.');\n }\n\n // READ\n @Logger('SbtModule.getSbtMintedStatus')\n async getSbtMintedStatus(params: GetSbtMintedParams) {\n const uri = `/api/sbt/mint-status/owner/${params.ownerAddress}/tokenCount/0`;\n return this.get<GetSbtMintedResult>(uri);\n }\n\n @Logger('SbtModule.getSbtsInfo')\n async getSbtsInfo() {\n const uri = `/api/sbt/info`;\n return this.get<GetSbtsInfoResult>(uri);\n }\n}\n"]}
|
|
@@ -14,17 +14,6 @@ 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
|
-
};
|
|
28
17
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
29
18
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
30
19
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
@@ -69,7 +58,6 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
69
58
|
};
|
|
70
59
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
71
60
|
var common_1 = require("@reyaxyz/common");
|
|
72
|
-
var services_1 = require("./services");
|
|
73
61
|
var common_2 = require("@reyaxyz/common");
|
|
74
62
|
var VoteModule = /** @class */ (function (_super) {
|
|
75
63
|
__extends(VoteModule, _super);
|
|
@@ -79,60 +67,11 @@ var VoteModule = /** @class */ (function (_super) {
|
|
|
79
67
|
_this.loggingEnabled = loggingEnabled;
|
|
80
68
|
return _this;
|
|
81
69
|
}
|
|
82
|
-
VoteModule.prototype.executeVoteTx = function (voteInfo) {
|
|
83
|
-
var _a;
|
|
84
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
85
|
-
var uri, result;
|
|
86
|
-
return __generator(this, function (_b) {
|
|
87
|
-
switch (_b.label) {
|
|
88
|
-
case 0:
|
|
89
|
-
uri = "/api/transaction-gelato/executeGelatoEip2771";
|
|
90
|
-
return [4 /*yield*/, this.post(uri, {}, {
|
|
91
|
-
signature: voteInfo.signature,
|
|
92
|
-
chainId: voteInfo.struct.chainId.toString(),
|
|
93
|
-
data: voteInfo.struct.data,
|
|
94
|
-
userDeadline: voteInfo.struct.userDeadline,
|
|
95
|
-
userNonce: ((_a = voteInfo.struct.userNonce) !== null && _a !== void 0 ? _a : 0).toString(),
|
|
96
|
-
user: voteInfo.struct.user,
|
|
97
|
-
contractAddress: voteInfo.contractAddress,
|
|
98
|
-
})];
|
|
99
|
-
case 1:
|
|
100
|
-
result = _b.sent();
|
|
101
|
-
return [2 /*return*/, { transactionHash: result.txHash }];
|
|
102
|
-
}
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
};
|
|
106
70
|
// WRITE
|
|
107
71
|
VoteModule.prototype.vote = function (params) {
|
|
108
72
|
return __awaiter(this, void 0, void 0, function () {
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
return __generator(this, function (_e) {
|
|
112
|
-
switch (_e.label) {
|
|
113
|
-
case 0:
|
|
114
|
-
infoUri = "/api/vote/contract-details/".concat(params.slug);
|
|
115
|
-
return [4 /*yield*/, this.get(infoUri)];
|
|
116
|
-
case 1:
|
|
117
|
-
infoMetadata = _e.sent();
|
|
118
|
-
return [4 /*yield*/, (0, services_1.sendVote)(__assign(__assign({}, params), { contractAddress: infoMetadata.contractAddress }))];
|
|
119
|
-
case 2:
|
|
120
|
-
_a = _e.sent(), signature = _a.signature, signatureDeadline = _a.deadline;
|
|
121
|
-
voteUri = "/api/vote/".concat(infoMetadata.contractAddress, "/vote");
|
|
122
|
-
_b = this.put;
|
|
123
|
-
_c = [voteUri,
|
|
124
|
-
{}];
|
|
125
|
-
_d = {};
|
|
126
|
-
return [4 /*yield*/, params.signer.getAddress()];
|
|
127
|
-
case 3: return [4 /*yield*/, _b.apply(this, _c.concat([(_d.voter = _e.sent(),
|
|
128
|
-
_d.isYesVote = params.voted,
|
|
129
|
-
_d.signature = signature,
|
|
130
|
-
_d.signatureDeadline = signatureDeadline,
|
|
131
|
-
_d)]))];
|
|
132
|
-
case 4:
|
|
133
|
-
result = _e.sent();
|
|
134
|
-
return [2 /*return*/, { transactionHash: result.txHash }];
|
|
135
|
-
}
|
|
73
|
+
return __generator(this, function (_a) {
|
|
74
|
+
throw new Error('Unimplemented.');
|
|
136
75
|
});
|
|
137
76
|
});
|
|
138
77
|
};
|
|
@@ -168,6 +107,7 @@ var VoteModule = /** @class */ (function (_super) {
|
|
|
168
107
|
};
|
|
169
108
|
__decorate([
|
|
170
109
|
(0, common_2.Logger)('VoteModule.vote')
|
|
110
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
171
111
|
], VoteModule.prototype, "vote", null);
|
|
172
112
|
__decorate([
|
|
173
113
|
(0, common_2.Logger)('VoteModule.getVoteDetails')
|
|
@@ -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,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;IAGF,yBAAI,GAAJ,UAAK,MAAkB;;;gBAC3B,MAAM,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAAC;;;KACnC;IAED,OAAO;IAED,mCAAc,GAAd,UAAe,MAA4B;;;;;;wBACzC,GAAG,GAAG,oBAAa,MAAM,CAAC,IAAI,CAAE,CAAC;wBACnB,qBAAM,IAAI,CAAC,GAAG,CAAuB,GAAG,CAAC,EAAA;;wBAAvD,WAAW,GAAG,SAAyC;wBACzD,mBAAmB,GAAG,EAAE,CAAC;wBAC7B,WAAW,CAAC,WAAW,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,UAAC,CAAC;4BAChD,mBAAmB,GAAG,UAAG,mBAAmB,iBAEhD,CAAC,CAAE,CAAC;wBACF,CAAC,CAAC,CAAC;wBACH,WAAW,CAAC,WAAW,GAAG,mBAAmB,CAAC;wBAC9C,sBAAO,WAAW,EAAC;;;;KACpB;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;IAvBK;QAFL,IAAA,eAAM,EAAC,iBAAiB,CAAC;QAC1B,6DAA6D;0CAG5D;IAIK;QADL,IAAA,eAAM,EAAC,2BAA2B,CAAC;oDAYnC;IAGK;QADL,IAAA,eAAM,EAAC,0BAA0B,CAAC;mDAIlC;IACH,iBAAC;CAAA,AAnCD,CAAwC,mBAAU,GAmCjD;kBAnCoB,UAAU","sourcesContent":["import { RestClient } from '@reyaxyz/common';\nimport {\n GetVoteDetailsParams,\n GetVoteDetailsResult,\n GetVoteStatusParams,\n GetVoteStatusResult,\n VoteParams,\n VoteResult,\n} from './types';\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 // eslint-disable-next-line @typescript-eslint/no-unused-vars\n async vote(params: VoteParams): Promise<VoteResult> {\n throw new Error('Unimplemented.');\n }\n\n // READ\n @Logger('VoteModule.getVoteDetails')\n async getVoteDetails(params: GetVoteDetailsParams) {\n const uri = `/api/vote/${params.slug}`;\n const voteDetails = await this.get<GetVoteDetailsResult>(uri);\n let markdownDescription = '';\n voteDetails.description.split('\\n ').forEach((i) => {\n markdownDescription = `${markdownDescription}\n\n${i}`;\n });\n voteDetails.description = markdownDescription;\n return voteDetails;\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"]}
|
|
@@ -36,57 +36,8 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
36
36
|
}
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.sendVote =
|
|
40
|
-
var executeTransaction_1 = require("../executeTransaction");
|
|
41
|
-
var encode_1 = require("./encode");
|
|
42
|
-
var relay_sdk_1 = require("@gelatonetwork/relay-sdk");
|
|
39
|
+
exports.sendVote = void 0;
|
|
43
40
|
var common_1 = require("@reyaxyz/common");
|
|
44
|
-
var vote = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
-
var _a, data, value, network, user, relay, request, signer, signatureData, error_1;
|
|
46
|
-
var _b;
|
|
47
|
-
return __generator(this, function (_c) {
|
|
48
|
-
switch (_c.label) {
|
|
49
|
-
case 0:
|
|
50
|
-
_a = (0, encode_1.encodeCastVote)(params.voted == 'yes'), data = _a.calldata, value = _a.value;
|
|
51
|
-
return [4 /*yield*/, ((_b = params.signer.provider) === null || _b === void 0 ? void 0 : _b.getNetwork())];
|
|
52
|
-
case 1:
|
|
53
|
-
network = _c.sent();
|
|
54
|
-
if (!network) {
|
|
55
|
-
throw new Error('Vote failed. Network not found.');
|
|
56
|
-
}
|
|
57
|
-
return [4 /*yield*/, params.signer.getAddress()];
|
|
58
|
-
case 2:
|
|
59
|
-
user = _c.sent();
|
|
60
|
-
relay = new relay_sdk_1.GelatoRelay();
|
|
61
|
-
_c.label = 3;
|
|
62
|
-
case 3:
|
|
63
|
-
_c.trys.push([3, 6, , 7]);
|
|
64
|
-
request = {
|
|
65
|
-
chainId: network.chainId,
|
|
66
|
-
target: params.contractAddress,
|
|
67
|
-
data: data,
|
|
68
|
-
user: user,
|
|
69
|
-
};
|
|
70
|
-
signer = params.signer;
|
|
71
|
-
return [4 /*yield*/, (0, executeTransaction_1.estimateGas)(params.signer, data, value, Number(network.chainId), params.contractAddress)];
|
|
72
|
-
case 4:
|
|
73
|
-
_c.sent();
|
|
74
|
-
return [4 /*yield*/, relay.getSignatureDataERC2771(request, signer, relay_sdk_1.ERC2771Type.SponsoredCall)];
|
|
75
|
-
case 5:
|
|
76
|
-
signatureData = _c.sent();
|
|
77
|
-
return [2 /*return*/, {
|
|
78
|
-
signature: signatureData.signature,
|
|
79
|
-
struct: signatureData.struct,
|
|
80
|
-
contractAddress: (0, common_1.convertToAddress)(params.contractAddress),
|
|
81
|
-
}];
|
|
82
|
-
case 6:
|
|
83
|
-
error_1 = _c.sent();
|
|
84
|
-
throw new Error('Vote failed. Please reach out via Discord.');
|
|
85
|
-
case 7: return [2 /*return*/];
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
}); };
|
|
89
|
-
exports.vote = vote;
|
|
90
41
|
var sendVote = function (params) { return __awaiter(void 0, void 0, void 0, function () {
|
|
91
42
|
var network, reyaChainId, user, deadline, signature;
|
|
92
43
|
var _a;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/vote/services/vote/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/vote/services/vote/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,0CAA4E;AAErE,IAAM,QAAQ,GAAG,UACtB,MAAyB;;;;;oBAET,qBAAM,CAAA,MAAA,MAAM,CAAC,MAAM,CAAC,QAAQ,0CAAE,UAAU,EAAE,CAAA,EAAA;;gBAApD,OAAO,GAAG,SAA0C;gBAC1D,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;gBACrD,CAAC;gBAEK,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBAC5C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,oBAAW,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;oBACtD,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;gBAC1C,CAAC;gBAEY,qBAAM,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,EAAA;;gBAAvC,IAAI,GAAG,SAAgC;gBACvC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,2BAAkB,GAAG,CAAC,CAAC;gBAEtD,qBAAM,IAAA,iBAAQ,EAC9B,MAAM,CAAC,MAAM,EACb,WAAW,EACX,MAAM,CAAC,eAAe,EACtB,IAAI,EACJ,MAAM,CAAC,KAAK,IAAI,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,EACpC,QAAQ,CACT,EAAA;;gBAPK,SAAS,GAAG,SAOjB;gBAED,sBAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAC;;;KACrD,CAAC;AA1BW,QAAA,QAAQ,YA0BnB","sourcesContent":["import { ExecuteVoteParams, SignedVote } from '../../types';\nimport { ReyaChainId, signVote, ONE_DAY_IN_SECONDS } from '@reyaxyz/common';\n\nexport const sendVote = async (\n params: ExecuteVoteParams,\n): Promise<SignedVote> => {\n const network = await params.signer.provider?.getNetwork();\n if (!network) {\n throw new Error('Vote failed. Network not found.');\n }\n\n const reyaChainId = Number(network.chainId);\n if (!Object.values(ReyaChainId).includes(reyaChainId)) {\n throw new Error('Not on Reya Network.');\n }\n\n const user = await params.signer.getAddress();\n const deadline = Math.floor(Date.now() / 1000) + ONE_DAY_IN_SECONDS * 7;\n\n const signature = await signVote(\n params.signer,\n reyaChainId,\n params.contractAddress,\n user,\n params.voted == 'yes' ? true : false,\n deadline,\n );\n\n return { signature: signature, deadline: deadline };\n};\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["modules/vote/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Signer } from 'ethers';\nimport {
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"/","sources":["modules/vote/types.ts"],"names":[],"mappings":"","sourcesContent":["import { Signer } from 'ethers';\nimport { VoteDetailsEntity, VoteStatusEntity } from '@reyaxyz/common';\n\nexport type SignedVote = {\n signature: string;\n deadline: number;\n};\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 VoteParams = {\n slug: VoteDetailsEntity['slug'];\n voted: 'yes' | 'no';\n signer: Signer;\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/sbt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/sbt/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EACL,aAAa,EACb,aAAa,EACb,kBAAkB,EAElB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAU,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,CAAC,OAAO,OAAO,SAAU,SAAQ,UAAW,YAAW,QAAQ;IACnE,cAAc,EAAE,OAAO,CAAS;gBAEpB,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,OAAO;IAQ7C,IAAI,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,aAAa,CAAC;IAMnD,kBAAkB,CAAC,MAAM,EAAE,kBAAkB;IAM7C,WAAW;CAIlB"}
|
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { RestClient } from '@reyaxyz/common';
|
|
2
|
-
import { GetVoteDetailsParams, GetVoteStatusParams, VoteParams } from './types';
|
|
2
|
+
import { GetVoteDetailsParams, GetVoteStatusParams, VoteParams, VoteResult } from './types';
|
|
3
3
|
import { Loggable } from '@reyaxyz/common';
|
|
4
4
|
export default class VoteModule extends RestClient implements Loggable {
|
|
5
5
|
loggingEnabled: boolean;
|
|
6
6
|
constructor(apiUrl: string, loggingEnabled: boolean);
|
|
7
|
-
|
|
8
|
-
vote(params: VoteParams): Promise<{
|
|
9
|
-
transactionHash: string;
|
|
10
|
-
}>;
|
|
7
|
+
vote(params: VoteParams): Promise<VoteResult>;
|
|
11
8
|
getVoteDetails(params: GetVoteDetailsParams): Promise<import("@reyaxyz/common").VoteDetailsEntity>;
|
|
12
9
|
getVoteStatus(params: GetVoteStatusParams): Promise<import("@reyaxyz/common").VoteStatusEntity>;
|
|
13
10
|
}
|
|
@@ -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,EACL,oBAAoB,EAEpB,mBAAmB,EAEnB,UAAU,EACV,UAAU,EACX,MAAM,SAAS,CAAC;AACjB,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;IAQ7C,IAAI,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC;IAM7C,cAAc,CAAC,MAAM,EAAE,oBAAoB;IAc3C,aAAa,CAAC,MAAM,EAAE,mBAAmB;CAIhD"}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { ExecuteVoteParams, SignedVote
|
|
2
|
-
export declare const vote: (params: ExecuteVoteParams) => Promise<VoteInfo>;
|
|
1
|
+
import { ExecuteVoteParams, SignedVote } from '../../types';
|
|
3
2
|
export declare const sendVote: (params: ExecuteVoteParams) => Promise<SignedVote>;
|
|
4
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":"AAAA,OAAO,EAAE,iBAAiB,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG5D,eAAO,MAAM,QAAQ,WACX,iBAAiB,KACxB,QAAQ,UAAU,CAwBpB,CAAC"}
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import {
|
|
3
|
-
import { VoteDetailsEntity, VoteContractDetailsEntity, VoteStatusEntity, Address } from '@reyaxyz/common';
|
|
4
|
-
export type VoteInfo = {
|
|
5
|
-
signature: string;
|
|
6
|
-
struct: CallWithERC2771Request;
|
|
7
|
-
contractAddress: Address;
|
|
8
|
-
};
|
|
2
|
+
import { VoteDetailsEntity, VoteStatusEntity } from '@reyaxyz/common';
|
|
9
3
|
export type SignedVote = {
|
|
10
4
|
signature: string;
|
|
11
5
|
deadline: number;
|
|
@@ -17,7 +11,6 @@ export type GetVoteDetailsParams = {
|
|
|
17
11
|
slug: VoteDetailsEntity['slug'];
|
|
18
12
|
};
|
|
19
13
|
export type GetVoteDetailsResult = VoteDetailsEntity;
|
|
20
|
-
export type GetVoteContractDetailsResult = VoteContractDetailsEntity;
|
|
21
14
|
export type VoteParams = {
|
|
22
15
|
slug: VoteDetailsEntity['slug'];
|
|
23
16
|
voted: 'yes' | 'no';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["modules/vote/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["modules/vote/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAChC,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEtE,MAAM,MAAM,UAAU,GAAG;IACvB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,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,UAAU,GAAG;IACvB,IAAI,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAChC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB,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.
|
|
3
|
+
"version": "0.49.1",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"registry": "https://registry.npmjs.org"
|
|
@@ -11,8 +11,8 @@
|
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
13
|
"@gelatonetwork/relay-sdk": "^5.5.0",
|
|
14
|
-
"@reyaxyz/common": "0.
|
|
15
|
-
"@reyaxyz/sdk": "0.129.
|
|
14
|
+
"@reyaxyz/common": "0.271.0",
|
|
15
|
+
"@reyaxyz/sdk": "0.129.2",
|
|
16
16
|
"ethers": "6.9.0"
|
|
17
17
|
},
|
|
18
18
|
"main": "dist/index.js",
|
|
@@ -39,5 +39,5 @@
|
|
|
39
39
|
"generate:coverage-badges": "npx istanbul-badges-readme --silent"
|
|
40
40
|
},
|
|
41
41
|
"packageManager": "pnpm@8.3.1",
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "ba8c3ff0cc1c7b48725050ea238ad28d2af828b5"
|
|
43
43
|
}
|
package/src/modules/sbt/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { RestClient
|
|
1
|
+
import { RestClient } from '@reyaxyz/common';
|
|
2
2
|
import {
|
|
3
3
|
SbtMintResult,
|
|
4
4
|
SbtMintParams,
|
|
@@ -6,7 +6,6 @@ import {
|
|
|
6
6
|
GetSbtMintedResult,
|
|
7
7
|
GetSbtsInfoResult,
|
|
8
8
|
} from './types';
|
|
9
|
-
import { signMint } from './services/signMintTx';
|
|
10
9
|
import { Logger, Loggable } from '@reyaxyz/common';
|
|
11
10
|
|
|
12
11
|
export default class SbtModule extends RestClient implements Loggable {
|
|
@@ -19,43 +18,9 @@ export default class SbtModule extends RestClient implements Loggable {
|
|
|
19
18
|
|
|
20
19
|
// WRITE
|
|
21
20
|
@Logger('SbtModule.mint')
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
let userRoot = '';
|
|
26
|
-
try {
|
|
27
|
-
const userRootUri = `/api/sbt/root/owner/${owner}/tokenCount/0`;
|
|
28
|
-
userRoot = await this.get<string>(userRootUri);
|
|
29
|
-
} catch (e) {
|
|
30
|
-
const network = await params.signer.provider?.getNetwork();
|
|
31
|
-
if (!network) {
|
|
32
|
-
throw new Error('Mint failed. Network not found to get root.');
|
|
33
|
-
}
|
|
34
|
-
const reyaChainId = Number(network.chainId) as ReyaChainId;
|
|
35
|
-
userRoot = SBT_ROOT[reyaChainId] ?? '';
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const {
|
|
39
|
-
signature: signature,
|
|
40
|
-
deadline: signatureDeadline,
|
|
41
|
-
sbtRoot: sbtRoot,
|
|
42
|
-
} = await signMint(params, userRoot);
|
|
43
|
-
|
|
44
|
-
const mintUri = `/api/sbt/mint`;
|
|
45
|
-
const result = await this.put<{ txHash: string }>(
|
|
46
|
-
mintUri,
|
|
47
|
-
{},
|
|
48
|
-
{
|
|
49
|
-
owner: await params.signer.getAddress(),
|
|
50
|
-
merkleRoot: sbtRoot,
|
|
51
|
-
tokenRootCounter: 0, // hardcoded value for this batch
|
|
52
|
-
signature: signature,
|
|
53
|
-
signatureDeadline: signatureDeadline,
|
|
54
|
-
},
|
|
55
|
-
);
|
|
56
|
-
|
|
57
|
-
const response: SbtMintResult = { transactionHash: result.txHash };
|
|
58
|
-
return response;
|
|
21
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
22
|
+
async mint(params: SbtMintParams): Promise<SbtMintResult> {
|
|
23
|
+
throw new Error('Unimplemented.');
|
|
59
24
|
}
|
|
60
25
|
|
|
61
26
|
// READ
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import { RestClient } from '@reyaxyz/common';
|
|
2
2
|
import {
|
|
3
|
-
GetVoteContractDetailsResult,
|
|
4
3
|
GetVoteDetailsParams,
|
|
5
4
|
GetVoteDetailsResult,
|
|
6
5
|
GetVoteStatusParams,
|
|
7
6
|
GetVoteStatusResult,
|
|
8
|
-
VoteInfo,
|
|
9
7
|
VoteParams,
|
|
10
8
|
VoteResult,
|
|
11
9
|
} from './types';
|
|
12
|
-
import { sendVote } from './services';
|
|
13
10
|
import { Logger, Loggable } from '@reyaxyz/common';
|
|
14
11
|
|
|
15
12
|
export default class VoteModule extends RestClient implements Loggable {
|
|
@@ -20,49 +17,11 @@ export default class VoteModule extends RestClient implements Loggable {
|
|
|
20
17
|
this.loggingEnabled = loggingEnabled;
|
|
21
18
|
}
|
|
22
19
|
|
|
23
|
-
private async executeVoteTx(voteInfo: VoteInfo): Promise<VoteResult> {
|
|
24
|
-
const uri = `/api/transaction-gelato/executeGelatoEip2771`;
|
|
25
|
-
const result = await this.post<{ txHash: string; accountId?: string }>(
|
|
26
|
-
uri,
|
|
27
|
-
{},
|
|
28
|
-
{
|
|
29
|
-
signature: voteInfo.signature,
|
|
30
|
-
chainId: voteInfo.struct.chainId.toString(),
|
|
31
|
-
data: voteInfo.struct.data,
|
|
32
|
-
userDeadline: voteInfo.struct.userDeadline,
|
|
33
|
-
userNonce: (voteInfo.struct.userNonce ?? 0).toString(),
|
|
34
|
-
user: voteInfo.struct.user,
|
|
35
|
-
contractAddress: voteInfo.contractAddress,
|
|
36
|
-
},
|
|
37
|
-
);
|
|
38
|
-
return { transactionHash: result.txHash };
|
|
39
|
-
}
|
|
40
|
-
|
|
41
20
|
// WRITE
|
|
42
21
|
@Logger('VoteModule.vote')
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
const { signature: signature, deadline: signatureDeadline } =
|
|
48
|
-
await sendVote({
|
|
49
|
-
...params,
|
|
50
|
-
contractAddress: infoMetadata.contractAddress,
|
|
51
|
-
});
|
|
52
|
-
|
|
53
|
-
const voteUri = `/api/vote/${infoMetadata.contractAddress}/vote`;
|
|
54
|
-
const result = await this.put<{ txHash: string }>(
|
|
55
|
-
voteUri,
|
|
56
|
-
{},
|
|
57
|
-
{
|
|
58
|
-
voter: await params.signer.getAddress(),
|
|
59
|
-
isYesVote: params.voted,
|
|
60
|
-
signature: signature,
|
|
61
|
-
signatureDeadline: signatureDeadline,
|
|
62
|
-
},
|
|
63
|
-
);
|
|
64
|
-
|
|
65
|
-
return { transactionHash: result.txHash };
|
|
22
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
23
|
+
async vote(params: VoteParams): Promise<VoteResult> {
|
|
24
|
+
throw new Error('Unimplemented.');
|
|
66
25
|
}
|
|
67
26
|
|
|
68
27
|
// READ
|
|
@@ -1,62 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { ExecuteVoteParams, SignedVote, VoteInfo } from '../../types';
|
|
4
|
-
import {
|
|
5
|
-
GelatoRelay,
|
|
6
|
-
CallWithERC2771Request,
|
|
7
|
-
ERC2771Type,
|
|
8
|
-
SignerOrProvider,
|
|
9
|
-
} from '@gelatonetwork/relay-sdk';
|
|
10
|
-
import {
|
|
11
|
-
convertToAddress,
|
|
12
|
-
ReyaChainId,
|
|
13
|
-
signVote,
|
|
14
|
-
ONE_DAY_IN_SECONDS,
|
|
15
|
-
} from '@reyaxyz/common';
|
|
16
|
-
|
|
17
|
-
export const vote = async (params: ExecuteVoteParams): Promise<VoteInfo> => {
|
|
18
|
-
const { calldata: data, value } = encodeCastVote(params.voted == 'yes');
|
|
19
|
-
|
|
20
|
-
const network = await params.signer.provider?.getNetwork();
|
|
21
|
-
if (!network) {
|
|
22
|
-
throw new Error('Vote failed. Network not found.');
|
|
23
|
-
}
|
|
24
|
-
const user = await params.signer.getAddress();
|
|
25
|
-
|
|
26
|
-
const relay = new GelatoRelay();
|
|
27
|
-
|
|
28
|
-
try {
|
|
29
|
-
const request: CallWithERC2771Request = {
|
|
30
|
-
chainId: network.chainId,
|
|
31
|
-
target: params.contractAddress,
|
|
32
|
-
data: data,
|
|
33
|
-
user: user,
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
const signer = params.signer as unknown as SignerOrProvider;
|
|
37
|
-
|
|
38
|
-
await estimateGas(
|
|
39
|
-
params.signer,
|
|
40
|
-
data,
|
|
41
|
-
value,
|
|
42
|
-
Number(network.chainId),
|
|
43
|
-
params.contractAddress,
|
|
44
|
-
);
|
|
45
|
-
const signatureData = await relay.getSignatureDataERC2771(
|
|
46
|
-
request,
|
|
47
|
-
signer,
|
|
48
|
-
ERC2771Type.SponsoredCall,
|
|
49
|
-
);
|
|
50
|
-
|
|
51
|
-
return {
|
|
52
|
-
signature: signatureData.signature,
|
|
53
|
-
struct: signatureData.struct,
|
|
54
|
-
contractAddress: convertToAddress(params.contractAddress),
|
|
55
|
-
};
|
|
56
|
-
} catch (error) {
|
|
57
|
-
throw new Error('Vote failed. Please reach out via Discord.');
|
|
58
|
-
}
|
|
59
|
-
};
|
|
1
|
+
import { ExecuteVoteParams, SignedVote } from '../../types';
|
|
2
|
+
import { ReyaChainId, signVote, ONE_DAY_IN_SECONDS } from '@reyaxyz/common';
|
|
60
3
|
|
|
61
4
|
export const sendVote = async (
|
|
62
5
|
params: ExecuteVoteParams,
|
|
@@ -65,6 +8,7 @@ export const sendVote = async (
|
|
|
65
8
|
if (!network) {
|
|
66
9
|
throw new Error('Vote failed. Network not found.');
|
|
67
10
|
}
|
|
11
|
+
|
|
68
12
|
const reyaChainId = Number(network.chainId);
|
|
69
13
|
if (!Object.values(ReyaChainId).includes(reyaChainId)) {
|
|
70
14
|
throw new Error('Not on Reya Network.');
|
|
@@ -1,17 +1,5 @@
|
|
|
1
1
|
import { Signer } from 'ethers';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
VoteDetailsEntity,
|
|
5
|
-
VoteContractDetailsEntity,
|
|
6
|
-
VoteStatusEntity,
|
|
7
|
-
Address,
|
|
8
|
-
} from '@reyaxyz/common';
|
|
9
|
-
|
|
10
|
-
export type VoteInfo = {
|
|
11
|
-
signature: string;
|
|
12
|
-
struct: CallWithERC2771Request;
|
|
13
|
-
contractAddress: Address;
|
|
14
|
-
};
|
|
2
|
+
import { VoteDetailsEntity, VoteStatusEntity } from '@reyaxyz/common';
|
|
15
3
|
|
|
16
4
|
export type SignedVote = {
|
|
17
5
|
signature: string;
|
|
@@ -27,8 +15,6 @@ export type GetVoteDetailsParams = {
|
|
|
27
15
|
};
|
|
28
16
|
export type GetVoteDetailsResult = VoteDetailsEntity;
|
|
29
17
|
|
|
30
|
-
export type GetVoteContractDetailsResult = VoteContractDetailsEntity;
|
|
31
|
-
|
|
32
18
|
export type VoteParams = {
|
|
33
19
|
slug: VoteDetailsEntity['slug'];
|
|
34
20
|
voted: 'yes' | 'no';
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./signMintTx"), exports);
|
|
18
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["modules/sbt/services/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B","sourcesContent":["export * from './signMintTx';\n"]}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.signMint = void 0;
|
|
40
|
-
var common_1 = require("@reyaxyz/common");
|
|
41
|
-
var signMint = function (params, sbtRoot) { return __awaiter(void 0, void 0, void 0, function () {
|
|
42
|
-
var network, reyaChainId, user, deadline, contractAddress, tokenRootCounter, signature;
|
|
43
|
-
var _a;
|
|
44
|
-
return __generator(this, function (_b) {
|
|
45
|
-
switch (_b.label) {
|
|
46
|
-
case 0: return [4 /*yield*/, ((_a = params.signer.provider) === null || _a === void 0 ? void 0 : _a.getNetwork())];
|
|
47
|
-
case 1:
|
|
48
|
-
network = _b.sent();
|
|
49
|
-
if (!network) {
|
|
50
|
-
throw new Error('Mint failed. Network not found.');
|
|
51
|
-
}
|
|
52
|
-
reyaChainId = Number(network.chainId);
|
|
53
|
-
if (!Object.values(common_1.ReyaChainId).includes(reyaChainId)) {
|
|
54
|
-
throw new Error('Not on Reya Network.');
|
|
55
|
-
}
|
|
56
|
-
return [4 /*yield*/, params.signer.getAddress()];
|
|
57
|
-
case 2:
|
|
58
|
-
user = _b.sent();
|
|
59
|
-
deadline = Math.floor(Date.now() / 1000) + common_1.ONE_DAY_IN_SECONDS * 7;
|
|
60
|
-
contractAddress = (0, common_1.getAddress)(reyaChainId, common_1.ContractType.REYA_SBTS);
|
|
61
|
-
tokenRootCounter = 0;
|
|
62
|
-
return [4 /*yield*/, (0, common_1.signSbtMint)(params.signer, reyaChainId, contractAddress, user, tokenRootCounter, sbtRoot, deadline)];
|
|
63
|
-
case 3:
|
|
64
|
-
signature = _b.sent();
|
|
65
|
-
return [2 /*return*/, { signature: signature, deadline: deadline, sbtRoot: sbtRoot }];
|
|
66
|
-
}
|
|
67
|
-
});
|
|
68
|
-
}); };
|
|
69
|
-
exports.signMint = signMint;
|
|
70
|
-
//# sourceMappingURL=signMintTx.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signMintTx.js","sourceRoot":"/","sources":["modules/sbt/services/signMintTx.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,0CAMyB;AAElB,IAAM,QAAQ,GAAG,UACtB,MAAqB,EACrB,OAAe;;;;;oBAEC,qBAAM,CAAA,MAAA,MAAM,CAAC,MAAM,CAAC,QAAQ,0CAAE,UAAU,EAAE,CAAA,EAAA;;gBAApD,OAAO,GAAG,SAA0C;gBAC1D,IAAI,CAAC,OAAO,EAAE,CAAC;oBACb,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;gBACrD,CAAC;gBACK,WAAW,GAAG,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC;gBAC5C,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,oBAAW,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;oBACtD,MAAM,IAAI,KAAK,CAAC,sBAAsB,CAAC,CAAC;gBAC1C,CAAC;gBAEY,qBAAM,MAAM,CAAC,MAAM,CAAC,UAAU,EAAE,EAAA;;gBAAvC,IAAI,GAAG,SAAgC;gBACvC,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,2BAAkB,GAAG,CAAC,CAAC;gBAElE,eAAe,GAAG,IAAA,mBAAU,EAAC,WAAW,EAAE,qBAAY,CAAC,SAAS,CAAC,CAAC;gBAElE,gBAAgB,GAAG,CAAC,CAAC;gBACT,qBAAM,IAAA,oBAAW,EACjC,MAAM,CAAC,MAAM,EACb,WAAW,EACX,eAAe,EACf,IAAI,EACJ,gBAAgB,EAChB,OAAO,EACP,QAAQ,CACT,EAAA;;gBARK,SAAS,GAAG,SAQjB;gBAED,sBAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,EAAC;;;KACvE,CAAC;AA9BW,QAAA,QAAQ,YA8BnB","sourcesContent":["import { SbtMintParams, SignedSbtMintTx } from '../types';\nimport {\n ReyaChainId,\n signSbtMint,\n ONE_DAY_IN_SECONDS,\n getAddress,\n ContractType,\n} from '@reyaxyz/common';\n\nexport const signMint = async (\n params: SbtMintParams,\n sbtRoot: string,\n): Promise<SignedSbtMintTx> => {\n const network = await params.signer.provider?.getNetwork();\n if (!network) {\n throw new Error('Mint failed. Network not found.');\n }\n const reyaChainId = Number(network.chainId);\n if (!Object.values(ReyaChainId).includes(reyaChainId)) {\n throw new Error('Not on Reya Network.');\n }\n\n const user = await params.signer.getAddress();\n const deadline = Math.floor(Date.now() / 1000) + ONE_DAY_IN_SECONDS * 7;\n\n const contractAddress = getAddress(reyaChainId, ContractType.REYA_SBTS);\n\n const tokenRootCounter = 0; // hardcoded for this batch\n const signature = await signSbtMint(\n params.signer,\n reyaChainId,\n contractAddress,\n user,\n tokenRootCounter,\n sbtRoot,\n deadline,\n );\n\n return { signature: signature, deadline: deadline, sbtRoot: sbtRoot };\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["modules/sbt/services/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signMintTx.d.ts","sourceRoot":"/","sources":["modules/sbt/services/signMintTx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAS1D,eAAO,MAAM,QAAQ,WACX,aAAa,WACZ,MAAM,KACd,QAAQ,eAAe,CA2BzB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './signMintTx';
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { SbtMintParams, SignedSbtMintTx } from '../types';
|
|
2
|
-
import {
|
|
3
|
-
ReyaChainId,
|
|
4
|
-
signSbtMint,
|
|
5
|
-
ONE_DAY_IN_SECONDS,
|
|
6
|
-
getAddress,
|
|
7
|
-
ContractType,
|
|
8
|
-
} from '@reyaxyz/common';
|
|
9
|
-
|
|
10
|
-
export const signMint = async (
|
|
11
|
-
params: SbtMintParams,
|
|
12
|
-
sbtRoot: string,
|
|
13
|
-
): Promise<SignedSbtMintTx> => {
|
|
14
|
-
const network = await params.signer.provider?.getNetwork();
|
|
15
|
-
if (!network) {
|
|
16
|
-
throw new Error('Mint failed. Network not found.');
|
|
17
|
-
}
|
|
18
|
-
const reyaChainId = Number(network.chainId);
|
|
19
|
-
if (!Object.values(ReyaChainId).includes(reyaChainId)) {
|
|
20
|
-
throw new Error('Not on Reya Network.');
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
const user = await params.signer.getAddress();
|
|
24
|
-
const deadline = Math.floor(Date.now() / 1000) + ONE_DAY_IN_SECONDS * 7;
|
|
25
|
-
|
|
26
|
-
const contractAddress = getAddress(reyaChainId, ContractType.REYA_SBTS);
|
|
27
|
-
|
|
28
|
-
const tokenRootCounter = 0; // hardcoded for this batch
|
|
29
|
-
const signature = await signSbtMint(
|
|
30
|
-
params.signer,
|
|
31
|
-
reyaChainId,
|
|
32
|
-
contractAddress,
|
|
33
|
-
user,
|
|
34
|
-
tokenRootCounter,
|
|
35
|
-
sbtRoot,
|
|
36
|
-
deadline,
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
return { signature: signature, deadline: deadline, sbtRoot: sbtRoot };
|
|
40
|
-
};
|