@glowlabs-org/utils 0.2.131 → 0.2.133
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/cjs/browser.js +123 -17
- package/dist/cjs/browser.js.map +1 -1
- package/dist/cjs/{farms-router-DXTR8f4V.js → farms-router-Dxx681nB.js} +23 -1
- package/dist/cjs/farms-router-Dxx681nB.js.map +1 -0
- package/dist/cjs/index.js +1 -1
- package/dist/cjs/lib/control-api/control-router.d.ts +11 -0
- package/dist/cjs/lib/types/index.d.ts +2 -0
- package/dist/cjs/utils/stake-control.d.ts +59 -1
- package/dist/esm/browser.js +118 -20
- package/dist/esm/browser.js.map +1 -1
- package/dist/esm/{farms-router-DqPqj03h.js → farms-router-CphuVUes.js} +23 -1
- package/dist/esm/farms-router-CphuVUes.js.map +1 -0
- package/dist/esm/index.js +2 -2
- package/dist/esm/lib/control-api/control-router.d.ts +11 -0
- package/dist/esm/lib/types/index.d.ts +2 -0
- package/dist/esm/utils/stake-control.d.ts +59 -1
- package/package.json +1 -1
- package/src/lib/control-api/control-router.ts +34 -0
- package/src/lib/types/index.ts +2 -0
- package/src/utils/stake-control.ts +165 -16
- package/dist/cjs/farms-router-DXTR8f4V.js.map +0 -1
- package/dist/esm/farms-router-DqPqj03h.js.map +0 -1
package/dist/cjs/index.js
CHANGED
|
@@ -15,7 +15,7 @@ var viem = require('viem');
|
|
|
15
15
|
var merkletreejs = require('merkletreejs');
|
|
16
16
|
var ethers = require('ethers');
|
|
17
17
|
var Decimal = require('decimal.js');
|
|
18
|
-
var farmsRouter = require('./farms-router-
|
|
18
|
+
var farmsRouter = require('./farms-router-Dxx681nB.js');
|
|
19
19
|
|
|
20
20
|
const GENESIS_TIMESTAMP = 1700352000;
|
|
21
21
|
|
|
@@ -13,6 +13,15 @@ export interface PayProtocolDepositUsingStakedControlResponse {
|
|
|
13
13
|
farmId: string;
|
|
14
14
|
applicationId: string;
|
|
15
15
|
}
|
|
16
|
+
export interface MigrateUserRequest {
|
|
17
|
+
wallet: string;
|
|
18
|
+
signature: string;
|
|
19
|
+
deadline: string;
|
|
20
|
+
nonce: string;
|
|
21
|
+
}
|
|
22
|
+
export interface MigrateUserResponse {
|
|
23
|
+
success: true;
|
|
24
|
+
}
|
|
16
25
|
export declare function ControlRouter(baseUrl: string): {
|
|
17
26
|
readonly fetchGctlBalance: (wallet: string) => Promise<string>;
|
|
18
27
|
readonly fetchCommittedBalance: (wallet: string) => Promise<string>;
|
|
@@ -35,9 +44,11 @@ export declare function ControlRouter(baseUrl: string): {
|
|
|
35
44
|
readonly restakeGctl: (restakeRequest: RestakeRequest) => Promise<boolean>;
|
|
36
45
|
readonly retryFailedOperation: (operationId: string) => Promise<boolean>;
|
|
37
46
|
readonly payProtocolDepositUsingStakedControl: (paymentRequest: PayProtocolDepositUsingStakedControlRequest) => Promise<PayProtocolDepositUsingStakedControlResponse>;
|
|
47
|
+
readonly migrateUser: (migrateRequest: MigrateUserRequest) => Promise<MigrateUserResponse>;
|
|
38
48
|
readonly isStaking: boolean;
|
|
39
49
|
readonly isUnstaking: boolean;
|
|
40
50
|
readonly isRestaking: boolean;
|
|
41
51
|
readonly isRetryingFailedOperation: boolean;
|
|
42
52
|
readonly isPayingProtocolDepositUsingStakedControl: boolean;
|
|
53
|
+
readonly isMigratingUser: boolean;
|
|
43
54
|
};
|
|
@@ -475,6 +475,7 @@ export interface MiningScoreParams {
|
|
|
475
475
|
userId: string;
|
|
476
476
|
dollarCostOfMiner: string;
|
|
477
477
|
numberOfMiners: number;
|
|
478
|
+
minerRewardSplit: string;
|
|
478
479
|
}
|
|
479
480
|
export interface MiningScoresBatchParams {
|
|
480
481
|
farms: MiningScoreParams[];
|
|
@@ -485,6 +486,7 @@ export interface MiningScoreResponse {
|
|
|
485
486
|
glwPriceUsd6: string;
|
|
486
487
|
dollarCostOfMiner: string;
|
|
487
488
|
numberOfMiners: number;
|
|
489
|
+
minerRewardSplit: string;
|
|
488
490
|
weeksOfMinerLifeRemaining: number;
|
|
489
491
|
regionInfo: {
|
|
490
492
|
regionId: number;
|
|
@@ -86,6 +86,18 @@ export declare const commitKickstarterEIP712Types: {
|
|
|
86
86
|
readonly type: "uint256";
|
|
87
87
|
}];
|
|
88
88
|
};
|
|
89
|
+
export declare const applyCertifiedInstallerEIP712Types: {
|
|
90
|
+
readonly ApplyCertifiedInstaller: readonly [{
|
|
91
|
+
readonly name: "nonce";
|
|
92
|
+
readonly type: "uint256";
|
|
93
|
+
}, {
|
|
94
|
+
readonly name: "regionId";
|
|
95
|
+
readonly type: "uint256";
|
|
96
|
+
}, {
|
|
97
|
+
readonly name: "deadline";
|
|
98
|
+
readonly type: "uint256";
|
|
99
|
+
}];
|
|
100
|
+
};
|
|
89
101
|
export declare const payProtocolDepositUsingStakedControlEIP712Types: {
|
|
90
102
|
readonly PayProtocolDepositUsingStakedControl: readonly [{
|
|
91
103
|
readonly name: "amount";
|
|
@@ -101,6 +113,15 @@ export declare const payProtocolDepositUsingStakedControlEIP712Types: {
|
|
|
101
113
|
readonly type: "uint256";
|
|
102
114
|
}];
|
|
103
115
|
};
|
|
116
|
+
export declare const verifyUserEIP712Types: {
|
|
117
|
+
readonly VerifyUser: readonly [{
|
|
118
|
+
readonly name: "nonce";
|
|
119
|
+
readonly type: "uint256";
|
|
120
|
+
}, {
|
|
121
|
+
readonly name: "deadline";
|
|
122
|
+
readonly type: "uint256";
|
|
123
|
+
}];
|
|
124
|
+
};
|
|
104
125
|
export declare const stakeSignatureRequestSchema: z.ZodObject<{
|
|
105
126
|
wallet: z.ZodString;
|
|
106
127
|
signature: z.ZodString;
|
|
@@ -143,12 +164,25 @@ export declare const commitKickstarterSignatureRequestSchema: z.ZodObject<{
|
|
|
143
164
|
kickstarterId: z.ZodString;
|
|
144
165
|
deadline: z.ZodString;
|
|
145
166
|
}, z.core.$strip>;
|
|
146
|
-
export declare const
|
|
167
|
+
export declare const applyCertifiedInstallerSignatureRequestSchema: z.ZodObject<{
|
|
147
168
|
wallet: z.ZodString;
|
|
148
169
|
signature: z.ZodString;
|
|
149
170
|
nonce: z.ZodString;
|
|
171
|
+
regionId: z.ZodString;
|
|
172
|
+
deadline: z.ZodString;
|
|
173
|
+
}, z.core.$strip>;
|
|
174
|
+
export declare const payProtocolDepositUsingStakedControlSignatureRequestSchema: z.ZodObject<{
|
|
175
|
+
wallet: z.ZodString;
|
|
176
|
+
signature: z.ZodString;
|
|
150
177
|
amount: z.ZodString;
|
|
151
178
|
applicationId: z.ZodString;
|
|
179
|
+
nonce: z.ZodString;
|
|
180
|
+
deadline: z.ZodString;
|
|
181
|
+
}, z.core.$strip>;
|
|
182
|
+
export declare const verifyUserSignatureRequestSchema: z.ZodObject<{
|
|
183
|
+
wallet: z.ZodString;
|
|
184
|
+
signature: z.ZodString;
|
|
185
|
+
nonce: z.ZodString;
|
|
152
186
|
deadline: z.ZodString;
|
|
153
187
|
}, z.core.$strip>;
|
|
154
188
|
export type StakeSignatureRequest = z.infer<typeof stakeSignatureRequestSchema>;
|
|
@@ -156,7 +190,9 @@ export type UnstakeUnlockSignatureRequest = z.infer<typeof unstakeUnlockSignatur
|
|
|
156
190
|
export type UnstakeMoveSignatureRequest = z.infer<typeof unstakeMoveSignatureRequestSchema>;
|
|
157
191
|
export type RestakeSignatureRequest = z.infer<typeof restakeSignatureRequestSchema>;
|
|
158
192
|
export type CommitKickstarterSignatureRequest = z.infer<typeof commitKickstarterSignatureRequestSchema>;
|
|
193
|
+
export type ApplyCertifiedInstallerSignatureRequest = z.infer<typeof applyCertifiedInstallerSignatureRequestSchema>;
|
|
159
194
|
export type PayProtocolDepositUsingStakedControlSignatureRequest = z.infer<typeof payProtocolDepositUsingStakedControlSignatureRequestSchema>;
|
|
195
|
+
export type VerifyUserSignatureRequest = z.infer<typeof verifyUserSignatureRequestSchema>;
|
|
160
196
|
export type StakeMessage = {
|
|
161
197
|
nonce: bigint;
|
|
162
198
|
amount: bigint;
|
|
@@ -189,12 +225,28 @@ export type CommitKickstarterMessage = {
|
|
|
189
225
|
kickstarterId: string;
|
|
190
226
|
deadline: bigint;
|
|
191
227
|
};
|
|
228
|
+
export type ApplyCertifiedInstallerMessage = {
|
|
229
|
+
nonce: bigint;
|
|
230
|
+
regionId: bigint;
|
|
231
|
+
deadline: bigint;
|
|
232
|
+
};
|
|
192
233
|
export type PayProtocolDepositUsingStakedControlMessage = {
|
|
193
234
|
amount: bigint;
|
|
194
235
|
applicationId: string;
|
|
195
236
|
nonce: bigint;
|
|
196
237
|
deadline: bigint;
|
|
197
238
|
};
|
|
239
|
+
export type PayProtocolDepositMessage = {
|
|
240
|
+
nonce: bigint;
|
|
241
|
+
amount: bigint;
|
|
242
|
+
regionId: bigint;
|
|
243
|
+
applicationId: string;
|
|
244
|
+
deadline: bigint;
|
|
245
|
+
};
|
|
246
|
+
export type VerifyUserMessage = {
|
|
247
|
+
nonce: bigint;
|
|
248
|
+
deadline: bigint;
|
|
249
|
+
};
|
|
198
250
|
export type SignatureValidationReason = "deadline_expired" | "signature_failed" | "signer_mismatch" | null;
|
|
199
251
|
export type SignatureValidationResult = {
|
|
200
252
|
valid: boolean;
|
|
@@ -206,17 +258,23 @@ type UnstakeUnlockMessageInput = Pick<UnstakeUnlockSignatureRequest, "nonce" | "
|
|
|
206
258
|
type UnstakeMoveMessageInput = Pick<UnstakeMoveSignatureRequest, "nonce" | "amount" | "fromZoneId" | "toZoneId" | "deadline">;
|
|
207
259
|
type RestakeMessageInput = Pick<RestakeSignatureRequest, "nonce" | "amount" | "fromZoneId" | "toZoneId" | "deadline">;
|
|
208
260
|
type CommitKickstarterMessageInput = Pick<CommitKickstarterSignatureRequest, "nonce" | "amount" | "kickstarterId" | "deadline">;
|
|
261
|
+
type ApplyCertifiedInstallerMessageInput = Pick<ApplyCertifiedInstallerSignatureRequest, "nonce" | "regionId" | "deadline">;
|
|
209
262
|
type PayProtocolDepositUsingStakedControlMessageInput = Pick<PayProtocolDepositUsingStakedControlSignatureRequest, "amount" | "applicationId" | "nonce" | "deadline">;
|
|
263
|
+
type VerifyUserMessageInput = Pick<VerifyUserSignatureRequest, "nonce" | "deadline">;
|
|
210
264
|
export declare function buildStakeMessage(req: StakeMessageInput): StakeMessage;
|
|
211
265
|
export declare function buildUnstakeUnlockMessage(req: UnstakeUnlockMessageInput): UnstakeUnlockMessage;
|
|
212
266
|
export declare function buildUnstakeMoveMessage(req: UnstakeMoveMessageInput): UnstakeMoveMessage;
|
|
213
267
|
export declare function buildRestakeMessage(req: RestakeMessageInput): RestakeMessage;
|
|
214
268
|
export declare function buildCommitKickstarterMessage(req: CommitKickstarterMessageInput): CommitKickstarterMessage;
|
|
269
|
+
export declare function buildApplyCertifiedInstallerMessage(req: ApplyCertifiedInstallerMessageInput): ApplyCertifiedInstallerMessage;
|
|
215
270
|
export declare function buildPayProtocolDepositUsingStakedControlMessage(req: PayProtocolDepositUsingStakedControlMessageInput): PayProtocolDepositUsingStakedControlMessage;
|
|
271
|
+
export declare function buildVerifyUserMessage(req: VerifyUserMessageInput): VerifyUserMessage;
|
|
216
272
|
export declare function validateStakeSignature(input: StakeSignatureRequest, domain?: ReturnType<typeof stakeControlEIP712Domain>): Promise<SignatureValidationResult>;
|
|
217
273
|
export declare function validateUnstakeUnlockSignature(input: UnstakeUnlockSignatureRequest, domain?: ReturnType<typeof stakeControlEIP712Domain>): Promise<SignatureValidationResult>;
|
|
218
274
|
export declare function validateUnstakeMoveSignature(input: UnstakeMoveSignatureRequest, domain?: ReturnType<typeof stakeControlEIP712Domain>): Promise<SignatureValidationResult>;
|
|
219
275
|
export declare function validateRestakeSignature(input: RestakeSignatureRequest, domain?: ReturnType<typeof stakeControlEIP712Domain>): Promise<SignatureValidationResult>;
|
|
220
276
|
export declare function validateCommitKickstarterSignature(input: CommitKickstarterSignatureRequest, domain?: ReturnType<typeof stakeControlEIP712Domain>): Promise<SignatureValidationResult>;
|
|
277
|
+
export declare function validateApplyCertifiedInstallerSignature(input: ApplyCertifiedInstallerSignatureRequest, domain?: ReturnType<typeof stakeControlEIP712Domain>): Promise<SignatureValidationResult>;
|
|
221
278
|
export declare function validatePayProtocolDepositUsingStakedControlSignature(input: PayProtocolDepositUsingStakedControlSignatureRequest, domain?: ReturnType<typeof stakeControlEIP712Domain>): Promise<SignatureValidationResult>;
|
|
279
|
+
export declare function validateVerifyUserSignature(input: VerifyUserSignatureRequest, domain?: ReturnType<typeof stakeControlEIP712Domain>): Promise<SignatureValidationResult>;
|
|
222
280
|
export {};
|
package/dist/esm/browser.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { T as TRANSFER_TYPES } from './farms-router-
|
|
2
|
-
export { C as ControlRouter, D as DECIMALS_BY_TOKEN, i as FORWARDER_ABI, F as FarmsRouter, d as ForwarderError, l as GCA_URLS, G as GLOW_WEIGHT_DECIMAL_PRECISION, H as HUB_URL, c as KICKSTARTER_STATUS, K as KickstarterRouter, M as MAX_WEIGHT, j as OFFCHAIN_FRACTIONS_ABI, O as OFF_CHAIN_PAYMENT_CURRENCIES, e as OffchainFractionsError, P as PAYMENT_CURRENCIES, b as REGIONS, R as RegionRouter, S as STAKING_DIRECTIONS, U as USDG_WEIGHT_DECIMAL_PRECISION, W as WalletsRouter, f as allRegions, h as countries, k as getAddresses, r as regionMetadata, g as usStates, u as useForwarder, a as useOffchainFractions } from './farms-router-
|
|
3
|
-
import { verifyTypedData,
|
|
1
|
+
import { T as TRANSFER_TYPES } from './farms-router-CphuVUes.js';
|
|
2
|
+
export { C as ControlRouter, D as DECIMALS_BY_TOKEN, i as FORWARDER_ABI, F as FarmsRouter, d as ForwarderError, l as GCA_URLS, G as GLOW_WEIGHT_DECIMAL_PRECISION, H as HUB_URL, c as KICKSTARTER_STATUS, K as KickstarterRouter, M as MAX_WEIGHT, j as OFFCHAIN_FRACTIONS_ABI, O as OFF_CHAIN_PAYMENT_CURRENCIES, e as OffchainFractionsError, P as PAYMENT_CURRENCIES, b as REGIONS, R as RegionRouter, S as STAKING_DIRECTIONS, U as USDG_WEIGHT_DECIMAL_PRECISION, W as WalletsRouter, f as allRegions, h as countries, k as getAddresses, r as regionMetadata, g as usStates, u as useForwarder, a as useOffchainFractions } from './farms-router-CphuVUes.js';
|
|
3
|
+
import { verifyTypedData, checksumAddress } from 'viem';
|
|
4
4
|
import 'ethers';
|
|
5
5
|
|
|
6
6
|
/** A special constant with type `never` */
|
|
@@ -11990,6 +11990,13 @@ const commitKickstarterEIP712Types = {
|
|
|
11990
11990
|
{ name: "deadline", type: "uint256" },
|
|
11991
11991
|
],
|
|
11992
11992
|
};
|
|
11993
|
+
const applyCertifiedInstallerEIP712Types = {
|
|
11994
|
+
ApplyCertifiedInstaller: [
|
|
11995
|
+
{ name: "nonce", type: "uint256" },
|
|
11996
|
+
{ name: "regionId", type: "uint256" },
|
|
11997
|
+
{ name: "deadline", type: "uint256" },
|
|
11998
|
+
],
|
|
11999
|
+
};
|
|
11993
12000
|
const payProtocolDepositUsingStakedControlEIP712Types = {
|
|
11994
12001
|
PayProtocolDepositUsingStakedControl: [
|
|
11995
12002
|
{ name: "amount", type: "uint256" },
|
|
@@ -11998,6 +12005,12 @@ const payProtocolDepositUsingStakedControlEIP712Types = {
|
|
|
11998
12005
|
{ name: "deadline", type: "uint256" },
|
|
11999
12006
|
],
|
|
12000
12007
|
};
|
|
12008
|
+
const verifyUserEIP712Types = {
|
|
12009
|
+
VerifyUser: [
|
|
12010
|
+
{ name: "nonce", type: "uint256" },
|
|
12011
|
+
{ name: "deadline", type: "uint256" },
|
|
12012
|
+
],
|
|
12013
|
+
};
|
|
12001
12014
|
// Separate request schemas for clarity between stake and unstake
|
|
12002
12015
|
const stakeSignatureRequestSchema = z.object({
|
|
12003
12016
|
wallet: z.string().regex(/^0x[a-fA-F0-9]{40}$/),
|
|
@@ -12041,12 +12054,25 @@ const commitKickstarterSignatureRequestSchema = z.object({
|
|
|
12041
12054
|
kickstarterId: z.string(),
|
|
12042
12055
|
deadline: z.string(),
|
|
12043
12056
|
});
|
|
12044
|
-
const
|
|
12057
|
+
const applyCertifiedInstallerSignatureRequestSchema = z.object({
|
|
12045
12058
|
wallet: z.string().regex(/^0x[a-fA-F0-9]{40}$/),
|
|
12046
12059
|
signature: z.string().regex(/^0x[a-fA-F0-9]{130}$/),
|
|
12047
12060
|
nonce: z.string(),
|
|
12061
|
+
regionId: z.string(),
|
|
12062
|
+
deadline: z.string(),
|
|
12063
|
+
});
|
|
12064
|
+
const payProtocolDepositUsingStakedControlSignatureRequestSchema = z.object({
|
|
12065
|
+
wallet: z.string().regex(/^0x[a-fA-F0-9]{40}$/),
|
|
12066
|
+
signature: z.string().regex(/^0x[a-fA-F0-9]{130}$/),
|
|
12048
12067
|
amount: z.string(),
|
|
12049
12068
|
applicationId: z.string(),
|
|
12069
|
+
nonce: z.string(),
|
|
12070
|
+
deadline: z.string(),
|
|
12071
|
+
});
|
|
12072
|
+
const verifyUserSignatureRequestSchema = z.object({
|
|
12073
|
+
wallet: z.string().regex(/^0x[a-fA-F0-9]{40}$/),
|
|
12074
|
+
signature: z.string().regex(/^0x[a-fA-F0-9]{130}$/),
|
|
12075
|
+
nonce: z.string(),
|
|
12050
12076
|
deadline: z.string(),
|
|
12051
12077
|
});
|
|
12052
12078
|
function isDeadlineExpired(deadline) {
|
|
@@ -12130,23 +12156,44 @@ function buildCommitKickstarterMessage(req) {
|
|
|
12130
12156
|
throw new Error("kickstarterId must be non-empty");
|
|
12131
12157
|
return { nonce, amount, kickstarterId, deadline };
|
|
12132
12158
|
}
|
|
12159
|
+
function buildApplyCertifiedInstallerMessage(req) {
|
|
12160
|
+
const nonce = BigInt(req.nonce);
|
|
12161
|
+
const deadline = BigInt(req.deadline);
|
|
12162
|
+
const regionId = req.regionId;
|
|
12163
|
+
if (nonce < 0n)
|
|
12164
|
+
throw new Error("Nonce must be non-negative");
|
|
12165
|
+
if (deadline < 0n)
|
|
12166
|
+
throw new Error("Deadline must be non-negative");
|
|
12167
|
+
if (!regionId)
|
|
12168
|
+
throw new Error("regionId must be non-empty");
|
|
12169
|
+
return { nonce, regionId: BigInt(regionId), deadline };
|
|
12170
|
+
}
|
|
12133
12171
|
function buildPayProtocolDepositUsingStakedControlMessage(req) {
|
|
12134
|
-
const amount = BigInt(req.amount);
|
|
12135
12172
|
const nonce = BigInt(req.nonce);
|
|
12173
|
+
const amount = BigInt(req.amount);
|
|
12136
12174
|
const deadline = BigInt(req.deadline);
|
|
12137
12175
|
const applicationId = req.applicationId;
|
|
12138
|
-
if (amount < 0n)
|
|
12139
|
-
throw new Error("Amount must be non-negative");
|
|
12140
12176
|
if (nonce < 0n)
|
|
12141
12177
|
throw new Error("Nonce must be non-negative");
|
|
12178
|
+
if (amount < 0n)
|
|
12179
|
+
throw new Error("Amount must be non-negative");
|
|
12142
12180
|
if (deadline < 0n)
|
|
12143
12181
|
throw new Error("Deadline must be non-negative");
|
|
12144
12182
|
if (!applicationId)
|
|
12145
12183
|
throw new Error("applicationId must be non-empty");
|
|
12146
12184
|
return { amount, applicationId, nonce, deadline };
|
|
12147
12185
|
}
|
|
12186
|
+
function buildVerifyUserMessage(req) {
|
|
12187
|
+
const nonce = BigInt(req.nonce);
|
|
12188
|
+
const deadline = BigInt(req.deadline);
|
|
12189
|
+
if (nonce < 0n)
|
|
12190
|
+
throw new Error("Nonce must be non-negative");
|
|
12191
|
+
if (deadline < 0n)
|
|
12192
|
+
throw new Error("Deadline must be non-negative");
|
|
12193
|
+
return { nonce, deadline };
|
|
12194
|
+
}
|
|
12148
12195
|
// Helper to validate the signature using viem
|
|
12149
|
-
async function validateStakeSignature(input, domain = stakeControlEIP712Domain(1)) {
|
|
12196
|
+
async function validateStakeSignature(input, domain = stakeControlEIP712Domain(Number(process.env.CHAIN_ID) || 1)) {
|
|
12150
12197
|
const message = buildStakeMessage({
|
|
12151
12198
|
nonce: input.nonce,
|
|
12152
12199
|
amount: input.amount,
|
|
@@ -12158,7 +12205,7 @@ async function validateStakeSignature(input, domain = stakeControlEIP712Domain(1
|
|
|
12158
12205
|
}
|
|
12159
12206
|
try {
|
|
12160
12207
|
const verified = await verifyTypedData({
|
|
12161
|
-
address: input.wallet,
|
|
12208
|
+
address: checksumAddress(input.wallet),
|
|
12162
12209
|
domain,
|
|
12163
12210
|
types: stakeEIP712Types,
|
|
12164
12211
|
primaryType: "Stake",
|
|
@@ -12173,7 +12220,7 @@ async function validateStakeSignature(input, domain = stakeControlEIP712Domain(1
|
|
|
12173
12220
|
return { valid: false, recovered: null, reason: "signature_failed" };
|
|
12174
12221
|
}
|
|
12175
12222
|
}
|
|
12176
|
-
async function validateUnstakeUnlockSignature(input, domain = stakeControlEIP712Domain(1)) {
|
|
12223
|
+
async function validateUnstakeUnlockSignature(input, domain = stakeControlEIP712Domain(Number(process.env.CHAIN_ID) || 1)) {
|
|
12177
12224
|
const message = buildUnstakeUnlockMessage({
|
|
12178
12225
|
nonce: input.nonce,
|
|
12179
12226
|
amount: input.amount,
|
|
@@ -12185,7 +12232,7 @@ async function validateUnstakeUnlockSignature(input, domain = stakeControlEIP712
|
|
|
12185
12232
|
}
|
|
12186
12233
|
try {
|
|
12187
12234
|
const verified = await verifyTypedData({
|
|
12188
|
-
address: input.wallet,
|
|
12235
|
+
address: checksumAddress(input.wallet),
|
|
12189
12236
|
domain,
|
|
12190
12237
|
types: unstakeUnlockEIP712Types,
|
|
12191
12238
|
primaryType: "Unstake",
|
|
@@ -12200,7 +12247,7 @@ async function validateUnstakeUnlockSignature(input, domain = stakeControlEIP712
|
|
|
12200
12247
|
return { valid: false, recovered: null, reason: "signature_failed" };
|
|
12201
12248
|
}
|
|
12202
12249
|
}
|
|
12203
|
-
async function validateUnstakeMoveSignature(input, domain = stakeControlEIP712Domain(1)) {
|
|
12250
|
+
async function validateUnstakeMoveSignature(input, domain = stakeControlEIP712Domain(Number(process.env.CHAIN_ID) || 1)) {
|
|
12204
12251
|
const message = buildUnstakeMoveMessage({
|
|
12205
12252
|
nonce: input.nonce,
|
|
12206
12253
|
amount: input.amount,
|
|
@@ -12213,7 +12260,7 @@ async function validateUnstakeMoveSignature(input, domain = stakeControlEIP712Do
|
|
|
12213
12260
|
}
|
|
12214
12261
|
try {
|
|
12215
12262
|
const verified = await verifyTypedData({
|
|
12216
|
-
address: input.wallet,
|
|
12263
|
+
address: checksumAddress(input.wallet),
|
|
12217
12264
|
domain,
|
|
12218
12265
|
types: unstakeMoveEIP712Types,
|
|
12219
12266
|
primaryType: "UnstakeMove",
|
|
@@ -12228,7 +12275,7 @@ async function validateUnstakeMoveSignature(input, domain = stakeControlEIP712Do
|
|
|
12228
12275
|
return { valid: false, recovered: null, reason: "signature_failed" };
|
|
12229
12276
|
}
|
|
12230
12277
|
}
|
|
12231
|
-
async function validateRestakeSignature(input, domain = stakeControlEIP712Domain(1)) {
|
|
12278
|
+
async function validateRestakeSignature(input, domain = stakeControlEIP712Domain(Number(process.env.CHAIN_ID) || 1)) {
|
|
12232
12279
|
const message = buildRestakeMessage({
|
|
12233
12280
|
nonce: input.nonce,
|
|
12234
12281
|
amount: input.amount,
|
|
@@ -12241,7 +12288,7 @@ async function validateRestakeSignature(input, domain = stakeControlEIP712Domain
|
|
|
12241
12288
|
}
|
|
12242
12289
|
try {
|
|
12243
12290
|
const verified = await verifyTypedData({
|
|
12244
|
-
address: input.wallet,
|
|
12291
|
+
address: checksumAddress(input.wallet),
|
|
12245
12292
|
domain,
|
|
12246
12293
|
types: restakeEIP712Types,
|
|
12247
12294
|
primaryType: "Restake",
|
|
@@ -12256,7 +12303,7 @@ async function validateRestakeSignature(input, domain = stakeControlEIP712Domain
|
|
|
12256
12303
|
return { valid: false, recovered: null, reason: "signature_failed" };
|
|
12257
12304
|
}
|
|
12258
12305
|
}
|
|
12259
|
-
async function validateCommitKickstarterSignature(input, domain = stakeControlEIP712Domain(1)) {
|
|
12306
|
+
async function validateCommitKickstarterSignature(input, domain = stakeControlEIP712Domain(Number(process.env.CHAIN_ID) || 1)) {
|
|
12260
12307
|
const message = buildCommitKickstarterMessage({
|
|
12261
12308
|
nonce: input.nonce,
|
|
12262
12309
|
amount: input.amount,
|
|
@@ -12268,7 +12315,7 @@ async function validateCommitKickstarterSignature(input, domain = stakeControlEI
|
|
|
12268
12315
|
}
|
|
12269
12316
|
try {
|
|
12270
12317
|
const verified = await verifyTypedData({
|
|
12271
|
-
address: input.wallet,
|
|
12318
|
+
address: checksumAddress(input.wallet),
|
|
12272
12319
|
domain,
|
|
12273
12320
|
types: commitKickstarterEIP712Types,
|
|
12274
12321
|
primaryType: "CommitKickstarter",
|
|
@@ -12283,7 +12330,33 @@ async function validateCommitKickstarterSignature(input, domain = stakeControlEI
|
|
|
12283
12330
|
return { valid: false, recovered: null, reason: "signature_failed" };
|
|
12284
12331
|
}
|
|
12285
12332
|
}
|
|
12286
|
-
async function
|
|
12333
|
+
async function validateApplyCertifiedInstallerSignature(input, domain = stakeControlEIP712Domain(Number(process.env.CHAIN_ID) || 1)) {
|
|
12334
|
+
const message = buildApplyCertifiedInstallerMessage({
|
|
12335
|
+
nonce: input.nonce,
|
|
12336
|
+
regionId: input.regionId,
|
|
12337
|
+
deadline: input.deadline,
|
|
12338
|
+
});
|
|
12339
|
+
if (isDeadlineExpired(message.deadline)) {
|
|
12340
|
+
return { valid: false, recovered: null, reason: "deadline_expired" };
|
|
12341
|
+
}
|
|
12342
|
+
try {
|
|
12343
|
+
const verified = await verifyTypedData({
|
|
12344
|
+
address: checksumAddress(input.wallet),
|
|
12345
|
+
domain,
|
|
12346
|
+
types: applyCertifiedInstallerEIP712Types,
|
|
12347
|
+
primaryType: "ApplyCertifiedInstaller",
|
|
12348
|
+
message,
|
|
12349
|
+
signature: input.signature,
|
|
12350
|
+
});
|
|
12351
|
+
return verified
|
|
12352
|
+
? { valid: true, recovered: input.wallet, reason: null }
|
|
12353
|
+
: { valid: false, recovered: null, reason: "signer_mismatch" };
|
|
12354
|
+
}
|
|
12355
|
+
catch (_) {
|
|
12356
|
+
return { valid: false, recovered: null, reason: "signature_failed" };
|
|
12357
|
+
}
|
|
12358
|
+
}
|
|
12359
|
+
async function validatePayProtocolDepositUsingStakedControlSignature(input, domain = stakeControlEIP712Domain(Number(process.env.CHAIN_ID) || 1)) {
|
|
12287
12360
|
const message = buildPayProtocolDepositUsingStakedControlMessage({
|
|
12288
12361
|
amount: input.amount,
|
|
12289
12362
|
applicationId: input.applicationId,
|
|
@@ -12295,7 +12368,7 @@ async function validatePayProtocolDepositUsingStakedControlSignature(input, doma
|
|
|
12295
12368
|
}
|
|
12296
12369
|
try {
|
|
12297
12370
|
const verified = await verifyTypedData({
|
|
12298
|
-
address:
|
|
12371
|
+
address: checksumAddress(input.wallet),
|
|
12299
12372
|
domain,
|
|
12300
12373
|
types: payProtocolDepositUsingStakedControlEIP712Types,
|
|
12301
12374
|
primaryType: TRANSFER_TYPES.PayProtocolDepositUsingStakedControl,
|
|
@@ -12310,6 +12383,31 @@ async function validatePayProtocolDepositUsingStakedControlSignature(input, doma
|
|
|
12310
12383
|
return { valid: false, recovered: null, reason: "signature_failed" };
|
|
12311
12384
|
}
|
|
12312
12385
|
}
|
|
12386
|
+
async function validateVerifyUserSignature(input, domain = stakeControlEIP712Domain(Number(process.env.CHAIN_ID) || 1)) {
|
|
12387
|
+
const message = buildVerifyUserMessage({
|
|
12388
|
+
nonce: input.nonce,
|
|
12389
|
+
deadline: input.deadline,
|
|
12390
|
+
});
|
|
12391
|
+
if (isDeadlineExpired(message.deadline)) {
|
|
12392
|
+
return { valid: false, recovered: null, reason: "deadline_expired" };
|
|
12393
|
+
}
|
|
12394
|
+
try {
|
|
12395
|
+
const verified = await verifyTypedData({
|
|
12396
|
+
address: checksumAddress(input.wallet),
|
|
12397
|
+
domain,
|
|
12398
|
+
types: verifyUserEIP712Types,
|
|
12399
|
+
primaryType: "VerifyUser",
|
|
12400
|
+
message,
|
|
12401
|
+
signature: input.signature,
|
|
12402
|
+
});
|
|
12403
|
+
return verified
|
|
12404
|
+
? { valid: true, recovered: input.wallet, reason: null }
|
|
12405
|
+
: { valid: false, recovered: null, reason: "signer_mismatch" };
|
|
12406
|
+
}
|
|
12407
|
+
catch (_) {
|
|
12408
|
+
return { valid: false, recovered: null, reason: "signature_failed" };
|
|
12409
|
+
}
|
|
12410
|
+
}
|
|
12313
12411
|
|
|
12314
|
-
export { TRANSFER_TYPES, buildCommitKickstarterMessage, buildPayProtocolDepositUsingStakedControlMessage, buildRestakeMessage, buildStakeMessage, buildUnstakeMoveMessage, buildUnstakeUnlockMessage, commitKickstarterEIP712Types, commitKickstarterSignatureRequestSchema, payProtocolDepositUsingStakedControlEIP712Types, payProtocolDepositUsingStakedControlSignatureRequestSchema, restakeEIP712Types, restakeSignatureRequestSchema, stakeControlEIP712Domain, stakeEIP712Types, stakeSignatureRequestSchema, unstakeMoveEIP712Types, unstakeMoveSignatureRequestSchema, unstakeUnlockEIP712Types, unstakeUnlockSignatureRequestSchema, validateCommitKickstarterSignature, validatePayProtocolDepositUsingStakedControlSignature, validateRestakeSignature, validateStakeSignature, validateUnstakeMoveSignature, validateUnstakeUnlockSignature };
|
|
12412
|
+
export { TRANSFER_TYPES, applyCertifiedInstallerEIP712Types, applyCertifiedInstallerSignatureRequestSchema, buildApplyCertifiedInstallerMessage, buildCommitKickstarterMessage, buildPayProtocolDepositUsingStakedControlMessage, buildRestakeMessage, buildStakeMessage, buildUnstakeMoveMessage, buildUnstakeUnlockMessage, buildVerifyUserMessage, commitKickstarterEIP712Types, commitKickstarterSignatureRequestSchema, payProtocolDepositUsingStakedControlEIP712Types, payProtocolDepositUsingStakedControlSignatureRequestSchema, restakeEIP712Types, restakeSignatureRequestSchema, stakeControlEIP712Domain, stakeEIP712Types, stakeSignatureRequestSchema, unstakeMoveEIP712Types, unstakeMoveSignatureRequestSchema, unstakeUnlockEIP712Types, unstakeUnlockSignatureRequestSchema, validateApplyCertifiedInstallerSignature, validateCommitKickstarterSignature, validatePayProtocolDepositUsingStakedControlSignature, validateRestakeSignature, validateStakeSignature, validateUnstakeMoveSignature, validateUnstakeUnlockSignature, validateVerifyUserSignature, verifyUserEIP712Types, verifyUserSignatureRequestSchema };
|
|
12315
12413
|
//# sourceMappingURL=browser.js.map
|