@glowlabs-org/utils 0.2.132 → 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/esm/index.js CHANGED
@@ -13,8 +13,8 @@ import { parseUnits, formatUnits } from 'viem';
13
13
  import { MerkleTree } from 'merkletreejs';
14
14
  import { solidityPackedKeccak256, keccak256 } from 'ethers';
15
15
  import Decimal from 'decimal.js';
16
- import { H as HUB_URL, U as USDG_WEIGHT_DECIMAL_PRECISION, G as GLOW_WEIGHT_DECIMAL_PRECISION, M as MAX_WEIGHT } from './farms-router-DqPqj03h.js';
17
- export { C as ControlRouter, F as FarmsRouter, c as KICKSTARTER_STATUS, K as KickstarterRouter, O as OFF_CHAIN_PAYMENT_CURRENCIES, P as PAYMENT_CURRENCIES, b as REGIONS, R as RegionRouter, S as STAKING_DIRECTIONS, T as TRANSFER_TYPES, W as WalletsRouter, u as useForwarder, a as useOffchainFractions } from './farms-router-DqPqj03h.js';
16
+ import { H as HUB_URL, U as USDG_WEIGHT_DECIMAL_PRECISION, G as GLOW_WEIGHT_DECIMAL_PRECISION, M as MAX_WEIGHT } from './farms-router-CphuVUes.js';
17
+ export { C as ControlRouter, F as FarmsRouter, c as KICKSTARTER_STATUS, K as KickstarterRouter, O as OFF_CHAIN_PAYMENT_CURRENCIES, P as PAYMENT_CURRENCIES, b as REGIONS, R as RegionRouter, S as STAKING_DIRECTIONS, T as TRANSFER_TYPES, W as WalletsRouter, u as useForwarder, a as useOffchainFractions } from './farms-router-CphuVUes.js';
18
18
 
19
19
  const GENESIS_TIMESTAMP = 1700352000;
20
20
 
@@ -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
  };
@@ -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 payProtocolDepositUsingStakedControlSignatureRequestSchema: z.ZodObject<{
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@glowlabs-org/utils",
3
- "version": "0.2.132",
3
+ "version": "0.2.133",
4
4
  "description": "A library containing all typechain types and addresses relating to the glow guarded launch",
5
5
  "keywords": [],
6
6
  "author": "",
@@ -36,6 +36,17 @@ export interface PayProtocolDepositUsingStakedControlResponse {
36
36
  applicationId: string;
37
37
  }
38
38
 
39
+ export interface MigrateUserRequest {
40
+ wallet: string;
41
+ signature: string;
42
+ deadline: string;
43
+ nonce: string;
44
+ }
45
+
46
+ export interface MigrateUserResponse {
47
+ success: true;
48
+ }
49
+
39
50
  // --------------------------------------------------------------------------
40
51
 
41
52
  /**
@@ -271,6 +282,7 @@ export function ControlRouter(baseUrl: string) {
271
282
  let isRestaking = false;
272
283
  let isRetryingFailedOperation = false;
273
284
  let isPayingProtocolDepositUsingStakedControl = false;
285
+ let isMigratingUser = false;
274
286
 
275
287
  const stakeGctl = async (stakeRequest: StakeRequest): Promise<boolean> => {
276
288
  isStaking = true;
@@ -363,6 +375,24 @@ export function ControlRouter(baseUrl: string) {
363
375
  }
364
376
  };
365
377
 
378
+ const migrateUser = async (
379
+ migrateRequest: MigrateUserRequest
380
+ ): Promise<MigrateUserResponse> => {
381
+ isMigratingUser = true;
382
+ try {
383
+ const response = await request<MigrateUserResponse>(`/migrate-user`, {
384
+ method: "POST",
385
+ headers: { "Content-Type": "application/json" },
386
+ body: JSON.stringify(migrateRequest),
387
+ });
388
+ return response;
389
+ } catch (error) {
390
+ throw new Error(parseApiError(error));
391
+ } finally {
392
+ isMigratingUser = false;
393
+ }
394
+ };
395
+
366
396
  // --------------------------- Public API ----------------------------------
367
397
  return {
368
398
  // Queries
@@ -389,6 +419,7 @@ export function ControlRouter(baseUrl: string) {
389
419
  restakeGctl,
390
420
  retryFailedOperation,
391
421
  payProtocolDepositUsingStakedControl,
422
+ migrateUser,
392
423
 
393
424
  // Processing flags
394
425
  get isStaking() {
@@ -406,5 +437,8 @@ export function ControlRouter(baseUrl: string) {
406
437
  get isPayingProtocolDepositUsingStakedControl() {
407
438
  return isPayingProtocolDepositUsingStakedControl;
408
439
  },
440
+ get isMigratingUser() {
441
+ return isMigratingUser;
442
+ },
409
443
  } as const;
410
444
  }
@@ -1,5 +1,5 @@
1
1
  import { TRANSFER_TYPES } from "src/browser";
2
- import { verifyTypedData, type Hex, getAddress } from "viem";
2
+ import { verifyTypedData, type Hex, checksumAddress } from "viem";
3
3
  import z from "zod";
4
4
 
5
5
  export const stakeControlEIP712Domain = (chainId: number) => ({
@@ -58,6 +58,14 @@ export const commitKickstarterEIP712Types = {
58
58
  ],
59
59
  } as const;
60
60
 
61
+ export const applyCertifiedInstallerEIP712Types = {
62
+ ApplyCertifiedInstaller: [
63
+ { name: "nonce", type: "uint256" },
64
+ { name: "regionId", type: "uint256" },
65
+ { name: "deadline", type: "uint256" },
66
+ ],
67
+ } as const;
68
+
61
69
  export const payProtocolDepositUsingStakedControlEIP712Types = {
62
70
  PayProtocolDepositUsingStakedControl: [
63
71
  { name: "amount", type: "uint256" },
@@ -67,6 +75,13 @@ export const payProtocolDepositUsingStakedControlEIP712Types = {
67
75
  ],
68
76
  } as const;
69
77
 
78
+ export const verifyUserEIP712Types = {
79
+ VerifyUser: [
80
+ { name: "nonce", type: "uint256" },
81
+ { name: "deadline", type: "uint256" },
82
+ ],
83
+ } as const;
84
+
70
85
  // Separate request schemas for clarity between stake and unstake
71
86
  export const stakeSignatureRequestSchema = z.object({
72
87
  wallet: z.string().regex(/^0x[a-fA-F0-9]{40}$/),
@@ -115,16 +130,31 @@ export const commitKickstarterSignatureRequestSchema = z.object({
115
130
  deadline: z.string(),
116
131
  });
117
132
 
133
+ export const applyCertifiedInstallerSignatureRequestSchema = z.object({
134
+ wallet: z.string().regex(/^0x[a-fA-F0-9]{40}$/),
135
+ signature: z.string().regex(/^0x[a-fA-F0-9]{130}$/),
136
+ nonce: z.string(),
137
+ regionId: z.string(),
138
+ deadline: z.string(),
139
+ });
140
+
118
141
  export const payProtocolDepositUsingStakedControlSignatureRequestSchema =
119
142
  z.object({
120
143
  wallet: z.string().regex(/^0x[a-fA-F0-9]{40}$/),
121
144
  signature: z.string().regex(/^0x[a-fA-F0-9]{130}$/),
122
- nonce: z.string(),
123
145
  amount: z.string(),
124
146
  applicationId: z.string(),
147
+ nonce: z.string(),
125
148
  deadline: z.string(),
126
149
  });
127
150
 
151
+ export const verifyUserSignatureRequestSchema = z.object({
152
+ wallet: z.string().regex(/^0x[a-fA-F0-9]{40}$/),
153
+ signature: z.string().regex(/^0x[a-fA-F0-9]{130}$/),
154
+ nonce: z.string(),
155
+ deadline: z.string(),
156
+ });
157
+
128
158
  export type StakeSignatureRequest = z.infer<typeof stakeSignatureRequestSchema>;
129
159
  export type UnstakeUnlockSignatureRequest = z.infer<
130
160
  typeof unstakeUnlockSignatureRequestSchema
@@ -138,10 +168,17 @@ export type RestakeSignatureRequest = z.infer<
138
168
  export type CommitKickstarterSignatureRequest = z.infer<
139
169
  typeof commitKickstarterSignatureRequestSchema
140
170
  >;
171
+ export type ApplyCertifiedInstallerSignatureRequest = z.infer<
172
+ typeof applyCertifiedInstallerSignatureRequestSchema
173
+ >;
141
174
  export type PayProtocolDepositUsingStakedControlSignatureRequest = z.infer<
142
175
  typeof payProtocolDepositUsingStakedControlSignatureRequestSchema
143
176
  >;
144
177
 
178
+ export type VerifyUserSignatureRequest = z.infer<
179
+ typeof verifyUserSignatureRequestSchema
180
+ >;
181
+
145
182
  export type StakeMessage = {
146
183
  nonce: bigint;
147
184
  amount: bigint;
@@ -179,6 +216,12 @@ export type CommitKickstarterMessage = {
179
216
  deadline: bigint;
180
217
  };
181
218
 
219
+ export type ApplyCertifiedInstallerMessage = {
220
+ nonce: bigint;
221
+ regionId: bigint;
222
+ deadline: bigint;
223
+ };
224
+
182
225
  export type PayProtocolDepositUsingStakedControlMessage = {
183
226
  amount: bigint;
184
227
  applicationId: string;
@@ -186,6 +229,19 @@ export type PayProtocolDepositUsingStakedControlMessage = {
186
229
  deadline: bigint;
187
230
  };
188
231
 
232
+ export type PayProtocolDepositMessage = {
233
+ nonce: bigint;
234
+ amount: bigint;
235
+ regionId: bigint;
236
+ applicationId: string;
237
+ deadline: bigint;
238
+ };
239
+
240
+ export type VerifyUserMessage = {
241
+ nonce: bigint;
242
+ deadline: bigint;
243
+ };
244
+
189
245
  export type SignatureValidationReason =
190
246
  | "deadline_expired"
191
247
  | "signature_failed"
@@ -226,11 +282,21 @@ type CommitKickstarterMessageInput = Pick<
226
282
  "nonce" | "amount" | "kickstarterId" | "deadline"
227
283
  >;
228
284
 
285
+ type ApplyCertifiedInstallerMessageInput = Pick<
286
+ ApplyCertifiedInstallerSignatureRequest,
287
+ "nonce" | "regionId" | "deadline"
288
+ >;
289
+
229
290
  type PayProtocolDepositUsingStakedControlMessageInput = Pick<
230
291
  PayProtocolDepositUsingStakedControlSignatureRequest,
231
292
  "amount" | "applicationId" | "nonce" | "deadline"
232
293
  >;
233
294
 
295
+ type VerifyUserMessageInput = Pick<
296
+ VerifyUserSignatureRequest,
297
+ "nonce" | "deadline"
298
+ >;
299
+
234
300
  export function buildStakeMessage(req: StakeMessageInput): StakeMessage {
235
301
  const nonce = BigInt(req.nonce);
236
302
  const amount = BigInt(req.amount);
@@ -301,26 +367,48 @@ export function buildCommitKickstarterMessage(
301
367
  return { nonce, amount, kickstarterId, deadline };
302
368
  }
303
369
 
370
+ export function buildApplyCertifiedInstallerMessage(
371
+ req: ApplyCertifiedInstallerMessageInput
372
+ ): ApplyCertifiedInstallerMessage {
373
+ const nonce = BigInt(req.nonce);
374
+ const deadline = BigInt(req.deadline);
375
+ const regionId = req.regionId;
376
+ if (nonce < 0n) throw new Error("Nonce must be non-negative");
377
+ if (deadline < 0n) throw new Error("Deadline must be non-negative");
378
+ if (!regionId) throw new Error("regionId must be non-empty");
379
+ return { nonce, regionId: BigInt(regionId), deadline };
380
+ }
381
+
304
382
  export function buildPayProtocolDepositUsingStakedControlMessage(
305
383
  req: PayProtocolDepositUsingStakedControlMessageInput
306
384
  ): PayProtocolDepositUsingStakedControlMessage {
307
- const amount = BigInt(req.amount);
308
385
  const nonce = BigInt(req.nonce);
386
+ const amount = BigInt(req.amount);
309
387
  const deadline = BigInt(req.deadline);
310
388
  const applicationId = req.applicationId;
311
- if (amount < 0n) throw new Error("Amount must be non-negative");
312
389
  if (nonce < 0n) throw new Error("Nonce must be non-negative");
390
+ if (amount < 0n) throw new Error("Amount must be non-negative");
313
391
  if (deadline < 0n) throw new Error("Deadline must be non-negative");
314
392
  if (!applicationId) throw new Error("applicationId must be non-empty");
315
393
  return { amount, applicationId, nonce, deadline };
316
394
  }
317
395
 
396
+ export function buildVerifyUserMessage(
397
+ req: VerifyUserMessageInput
398
+ ): VerifyUserMessage {
399
+ const nonce = BigInt(req.nonce);
400
+ const deadline = BigInt(req.deadline);
401
+ if (nonce < 0n) throw new Error("Nonce must be non-negative");
402
+ if (deadline < 0n) throw new Error("Deadline must be non-negative");
403
+ return { nonce, deadline };
404
+ }
405
+
318
406
  // Helper to validate the signature using viem
319
407
  export async function validateStakeSignature(
320
408
  input: StakeSignatureRequest,
321
409
  domain: ReturnType<
322
410
  typeof stakeControlEIP712Domain
323
- > = stakeControlEIP712Domain(1)
411
+ > = stakeControlEIP712Domain(Number(process.env.CHAIN_ID) || 1)
324
412
  ): Promise<SignatureValidationResult> {
325
413
  const message = buildStakeMessage({
326
414
  nonce: input.nonce,
@@ -333,7 +421,7 @@ export async function validateStakeSignature(
333
421
  }
334
422
  try {
335
423
  const verified = await verifyTypedData({
336
- address: input.wallet as Hex,
424
+ address: checksumAddress(input.wallet as Hex),
337
425
  domain,
338
426
  types: stakeEIP712Types,
339
427
  primaryType: "Stake",
@@ -352,7 +440,7 @@ export async function validateUnstakeUnlockSignature(
352
440
  input: UnstakeUnlockSignatureRequest,
353
441
  domain: ReturnType<
354
442
  typeof stakeControlEIP712Domain
355
- > = stakeControlEIP712Domain(1)
443
+ > = stakeControlEIP712Domain(Number(process.env.CHAIN_ID) || 1)
356
444
  ): Promise<SignatureValidationResult> {
357
445
  const message = buildUnstakeUnlockMessage({
358
446
  nonce: input.nonce,
@@ -365,7 +453,7 @@ export async function validateUnstakeUnlockSignature(
365
453
  }
366
454
  try {
367
455
  const verified = await verifyTypedData({
368
- address: input.wallet as Hex,
456
+ address: checksumAddress(input.wallet as Hex),
369
457
  domain,
370
458
  types: unstakeUnlockEIP712Types,
371
459
  primaryType: "Unstake",
@@ -384,7 +472,7 @@ export async function validateUnstakeMoveSignature(
384
472
  input: UnstakeMoveSignatureRequest,
385
473
  domain: ReturnType<
386
474
  typeof stakeControlEIP712Domain
387
- > = stakeControlEIP712Domain(1)
475
+ > = stakeControlEIP712Domain(Number(process.env.CHAIN_ID) || 1)
388
476
  ): Promise<SignatureValidationResult> {
389
477
  const message = buildUnstakeMoveMessage({
390
478
  nonce: input.nonce,
@@ -398,7 +486,7 @@ export async function validateUnstakeMoveSignature(
398
486
  }
399
487
  try {
400
488
  const verified = await verifyTypedData({
401
- address: input.wallet as Hex,
489
+ address: checksumAddress(input.wallet as Hex),
402
490
  domain,
403
491
  types: unstakeMoveEIP712Types,
404
492
  primaryType: "UnstakeMove",
@@ -417,7 +505,7 @@ export async function validateRestakeSignature(
417
505
  input: RestakeSignatureRequest,
418
506
  domain: ReturnType<
419
507
  typeof stakeControlEIP712Domain
420
- > = stakeControlEIP712Domain(1)
508
+ > = stakeControlEIP712Domain(Number(process.env.CHAIN_ID) || 1)
421
509
  ): Promise<SignatureValidationResult> {
422
510
  const message = buildRestakeMessage({
423
511
  nonce: input.nonce,
@@ -431,7 +519,7 @@ export async function validateRestakeSignature(
431
519
  }
432
520
  try {
433
521
  const verified = await verifyTypedData({
434
- address: input.wallet as Hex,
522
+ address: checksumAddress(input.wallet as Hex),
435
523
  domain,
436
524
  types: restakeEIP712Types,
437
525
  primaryType: "Restake",
@@ -450,7 +538,7 @@ export async function validateCommitKickstarterSignature(
450
538
  input: CommitKickstarterSignatureRequest,
451
539
  domain: ReturnType<
452
540
  typeof stakeControlEIP712Domain
453
- > = stakeControlEIP712Domain(1)
541
+ > = stakeControlEIP712Domain(Number(process.env.CHAIN_ID) || 1)
454
542
  ): Promise<SignatureValidationResult> {
455
543
  const message = buildCommitKickstarterMessage({
456
544
  nonce: input.nonce,
@@ -463,7 +551,7 @@ export async function validateCommitKickstarterSignature(
463
551
  }
464
552
  try {
465
553
  const verified = await verifyTypedData({
466
- address: input.wallet as Hex,
554
+ address: checksumAddress(input.wallet as Hex),
467
555
  domain,
468
556
  types: commitKickstarterEIP712Types,
469
557
  primaryType: "CommitKickstarter",
@@ -478,11 +566,42 @@ export async function validateCommitKickstarterSignature(
478
566
  }
479
567
  }
480
568
 
569
+ export async function validateApplyCertifiedInstallerSignature(
570
+ input: ApplyCertifiedInstallerSignatureRequest,
571
+ domain: ReturnType<
572
+ typeof stakeControlEIP712Domain
573
+ > = stakeControlEIP712Domain(Number(process.env.CHAIN_ID) || 1)
574
+ ): Promise<SignatureValidationResult> {
575
+ const message = buildApplyCertifiedInstallerMessage({
576
+ nonce: input.nonce,
577
+ regionId: input.regionId,
578
+ deadline: input.deadline,
579
+ });
580
+ if (isDeadlineExpired(message.deadline)) {
581
+ return { valid: false, recovered: null, reason: "deadline_expired" };
582
+ }
583
+ try {
584
+ const verified = await verifyTypedData({
585
+ address: checksumAddress(input.wallet as Hex),
586
+ domain,
587
+ types: applyCertifiedInstallerEIP712Types,
588
+ primaryType: "ApplyCertifiedInstaller",
589
+ message,
590
+ signature: input.signature as Hex,
591
+ });
592
+ return verified
593
+ ? { valid: true, recovered: input.wallet, reason: null }
594
+ : { valid: false, recovered: null, reason: "signer_mismatch" };
595
+ } catch (_) {
596
+ return { valid: false, recovered: null, reason: "signature_failed" };
597
+ }
598
+ }
599
+
481
600
  export async function validatePayProtocolDepositUsingStakedControlSignature(
482
601
  input: PayProtocolDepositUsingStakedControlSignatureRequest,
483
602
  domain: ReturnType<
484
603
  typeof stakeControlEIP712Domain
485
- > = stakeControlEIP712Domain(1)
604
+ > = stakeControlEIP712Domain(Number(process.env.CHAIN_ID) || 1)
486
605
  ): Promise<SignatureValidationResult> {
487
606
  const message = buildPayProtocolDepositUsingStakedControlMessage({
488
607
  amount: input.amount,
@@ -495,7 +614,7 @@ export async function validatePayProtocolDepositUsingStakedControlSignature(
495
614
  }
496
615
  try {
497
616
  const verified = await verifyTypedData({
498
- address: getAddress(input.wallet as Hex),
617
+ address: checksumAddress(input.wallet as Hex),
499
618
  domain,
500
619
  types: payProtocolDepositUsingStakedControlEIP712Types,
501
620
  primaryType: TRANSFER_TYPES.PayProtocolDepositUsingStakedControl,
@@ -509,3 +628,33 @@ export async function validatePayProtocolDepositUsingStakedControlSignature(
509
628
  return { valid: false, recovered: null, reason: "signature_failed" };
510
629
  }
511
630
  }
631
+
632
+ export async function validateVerifyUserSignature(
633
+ input: VerifyUserSignatureRequest,
634
+ domain: ReturnType<
635
+ typeof stakeControlEIP712Domain
636
+ > = stakeControlEIP712Domain(Number(process.env.CHAIN_ID) || 1)
637
+ ): Promise<SignatureValidationResult> {
638
+ const message = buildVerifyUserMessage({
639
+ nonce: input.nonce,
640
+ deadline: input.deadline,
641
+ });
642
+ if (isDeadlineExpired(message.deadline)) {
643
+ return { valid: false, recovered: null, reason: "deadline_expired" };
644
+ }
645
+ try {
646
+ const verified = await verifyTypedData({
647
+ address: checksumAddress(input.wallet as Hex),
648
+ domain,
649
+ types: verifyUserEIP712Types,
650
+ primaryType: "VerifyUser",
651
+ message,
652
+ signature: input.signature as Hex,
653
+ });
654
+ return verified
655
+ ? { valid: true, recovered: input.wallet, reason: null }
656
+ : { valid: false, recovered: null, reason: "signer_mismatch" };
657
+ } catch (_) {
658
+ return { valid: false, recovered: null, reason: "signature_failed" };
659
+ }
660
+ }