Skip to content

Commit b4e2e05

Browse files
committed
signature without db
1 parent d3c6759 commit b4e2e05

File tree

1 file changed

+23
-11
lines changed

1 file changed

+23
-11
lines changed

src/utils/onchain-allocator.ts

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -243,13 +243,12 @@ export const getSigner = async (chainId: string) => {
243243
return _getSignerCache.get(chainId)!;
244244
};
245245

246-
export const getSignature = async (id: string) => {
247-
const withdrawalRequest = await getWithdrawalRequest(id);
248-
if (!withdrawalRequest) {
249-
throw externalError("Could not find withdrawal request");
250-
}
251-
252-
const chain = await getChain(withdrawalRequest.chainId);
246+
export const getSignatureFromContract = async (
247+
chainId: string,
248+
payloadId: string,
249+
encodedData: string
250+
) => {
251+
const chain = await getChain(chainId);
253252
if (!chain.depository || !chain.metadata.allocatorChainId) {
254253
throw externalError(
255254
"Depository or allocator chain id not configured for chain"
@@ -274,12 +273,12 @@ export const getSignature = async (id: string) => {
274273
const hashToSign = await payloadBuilder.contract.read.hashToSign([
275274
BigInt(chain.metadata.allocatorChainId),
276275
chain.depository,
277-
withdrawalRequest.encodedData as Hex,
276+
encodedData as Hex,
278277
0,
279278
]);
280279

281280
const signature = await onchainAllocator.contract.read.signedPayloads([
282-
withdrawalRequest.payloadId as Hex,
281+
payloadId as Hex,
283282
hashToSign,
284283
]);
285284
if (signature === "0x") {
@@ -293,12 +292,12 @@ export const getSignature = async (id: string) => {
293292
const hashToSign = await payloadBuilder.contract.read.hashToSign([
294293
BigInt(chain.metadata.allocatorChainId),
295294
chain.depository,
296-
withdrawalRequest.encodedData as Hex,
295+
encodedData as Hex,
297296
0,
298297
]);
299298

300299
const signature = await onchainAllocator.contract.read.signedPayloads([
301-
withdrawalRequest.payloadId as Hex,
300+
payloadId as Hex,
302301
hashToSign,
303302
]);
304303
if (signature === "0x") {
@@ -313,3 +312,16 @@ export const getSignature = async (id: string) => {
313312
}
314313
}
315314
};
315+
316+
export const getSignature = async (id: string) => {
317+
const withdrawalRequest = await getWithdrawalRequest(id);
318+
if (!withdrawalRequest) {
319+
throw externalError("Could not find withdrawal request");
320+
}
321+
322+
await getSignatureFromContract(
323+
withdrawalRequest.chainId,
324+
withdrawalRequest.payloadId!,
325+
withdrawalRequest.encodedData
326+
);
327+
};

0 commit comments

Comments
 (0)