Skip to content

Commit 1b417c1

Browse files
committed
refactor: generateNonce to avoid confusing packages
1 parent 6556dde commit 1b417c1

File tree

8 files changed

+19
-19
lines changed

8 files changed

+19
-19
lines changed

src/components/job/JobInstances.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { sendInstanceCommand } from '@lib/api/deeploy';
22
import { getDevAddress, isUsingDevAddress } from '@lib/config';
3-
import { buildDeeployMessage, generateNonce } from '@lib/deeploy-utils';
3+
import { buildDeeployMessage, generateDeeployNonce } from '@lib/deeploy-utils';
44
import { getShortAddressOrHash } from '@lib/utils';
55
import { CompactCustomCard } from '@shared/cards/CompactCustomCard';
66
import ContextMenuWithTrigger from '@shared/ContextMenuWithTrigger';
@@ -54,7 +54,7 @@ export default function JobInstances({
5454
return;
5555
}
5656

57-
const nonce = generateNonce();
57+
const nonce = generateDeeployNonce();
5858

5959
const payload = {
6060
app_id: jobAlias,

src/components/tunnels/TunnelingSecretsForm.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { zodResolver } from '@hookform/resolvers/zod';
22
import { addSecrets } from '@lib/api/tunnels';
33
import { getDevAddress, isUsingDevAddress } from '@lib/config';
44
import { InteractionContextType, useInteractionContext } from '@lib/contexts/interaction';
5-
import { buildDeeployMessage } from '@lib/deeploy-utils';
5+
import { buildDeeployMessage, generateDeeployNonce } from '@lib/deeploy-utils';
66
import { addSecretsSchema } from '@schemas/secrets';
77
import { SlateCard } from '@shared/cards/SlateCard';
88
import InputWithLabel from '@shared/InputWithLabel';
@@ -12,7 +12,6 @@ import { useState } from 'react';
1212
import { FormProvider, useForm } from 'react-hook-form';
1313
import toast from 'react-hot-toast';
1414
import { RiPencilLine } from 'react-icons/ri';
15-
import { generateNonce } from 'siwe';
1615
import { useAccount, useSignMessage } from 'wagmi';
1716
import { z } from 'zod';
1817

@@ -44,7 +43,7 @@ export default function TunnelingSecretsForm({
4443
try {
4544
setLoading(true);
4645

47-
const nonce = generateNonce();
46+
const nonce = generateDeeployNonce();
4847

4948
const message = buildDeeployMessage({
5049
nonce,

src/lib/contexts/deployment/deployment-provider.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { CspEscrowAbi } from '@blockchain/CspEscrow';
22
import { getApps } from '@lib/api/deeploy';
33
import { getDevAddress, isUsingDevAddress } from '@lib/config';
4-
import { buildDeeployMessage, generateNonce } from '@lib/deeploy-utils';
4+
import { buildDeeployMessage, generateDeeployNonce } from '@lib/deeploy-utils';
55
import { SigningModal } from '@shared/SigningModal';
66
import { EthAddress, R1Address } from '@typedefs/blockchain';
77
import { Apps, DeeploySpecs, JobConfig, Plugin } from '@typedefs/deeployApi';
@@ -77,7 +77,7 @@ export const DeploymentProvider = ({ children }) => {
7777
};
7878

7979
const signAndBuildGetAppsRequest = async (address: EthAddress) => {
80-
const nonce = generateNonce();
80+
const nonce = generateDeeployNonce();
8181

8282
const message = buildDeeployMessage(
8383
{

src/lib/deeploy-utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export const downloadDataAsJson = (data: any, filename: string) => {
128128
URL.revokeObjectURL(url);
129129
};
130130

131-
export const generateNonce = (): string => {
131+
export const generateDeeployNonce = (): string => {
132132
const now = new Date();
133133
const unixTimestamp = now.getTime();
134134
console.log({ now, unixTimestamp });
@@ -274,7 +274,7 @@ export const formatGenericJobPayload = (
274274
};
275275
}
276276

277-
const nonce = generateNonce();
277+
const nonce = generateDeeployNonce();
278278

279279
return {
280280
app_alias: deployment.jobAlias,
@@ -319,7 +319,7 @@ export const formatNativeJobPayload = (
319319

320320
const spareNodes = formatNodes(deployment.spareNodes);
321321

322-
const nonce = generateNonce();
322+
const nonce = generateDeeployNonce();
323323

324324
let appParams = {
325325
PORT: deployment.port,
@@ -369,7 +369,7 @@ export const formatServiceJobPayload = (
369369
const targetNodes = formatNodes(deployment.targetNodes);
370370
const spareNodes = formatNodes(deployment.spareNodes);
371371

372-
const nonce = generateNonce();
372+
const nonce = generateDeeployNonce();
373373

374374
return {
375375
nonce,

src/pages/deeploys/job/EditJob.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
formatGenericJobPayload,
1616
formatNativeJobPayload,
1717
formatServiceJobPayload,
18-
generateNonce,
18+
generateDeeployNonce,
1919
} from '@lib/deeploy-utils';
2020
import { routePath } from '@lib/routes/route-paths';
2121
import { jobSchema } from '@schemas/index';
@@ -253,7 +253,7 @@ export default function EditJob() {
253253
targetNodes: string[],
254254
containerType: ContainerOrWorkerType,
255255
) => {
256-
const nonce = generateNonce();
256+
const nonce = generateDeeployNonce();
257257

258258
const payloadWithIdentifiers = {
259259
job_id: Number(job.id),

src/pages/tunnels/Tunnels.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { checkSecrets, getSecrets, getTunnels } from '@lib/api/tunnels';
88
import { getDevAddress, isUsingDevAddress } from '@lib/config';
99
import { InteractionContextType, useInteractionContext } from '@lib/contexts/interaction';
1010
import { TunnelsContextType, useTunnelsContext } from '@lib/contexts/tunnels';
11-
import { buildDeeployMessage, generateNonce } from '@lib/deeploy-utils';
11+
import { buildDeeployMessage, generateDeeployNonce } from '@lib/deeploy-utils';
1212
import ActionButton from '@shared/ActionButton';
1313
import { DetailedAlert } from '@shared/DetailedAlert';
1414
import EmptyData from '@shared/EmptyData';
@@ -73,7 +73,7 @@ function Tunnels() {
7373
try {
7474
setFetchingSecrets(true);
7575

76-
const nonce = generateNonce();
76+
const nonce = generateDeeployNonce();
7777
const message = buildDeeployMessage(
7878
{
7979
nonce,

src/shared/jobs/CostAndDurationInterface.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ export default function CostAndDurationInterface({
4747
const epochs = BigInt(1 + paymentMonthsCount * 30);
4848
let totalCost = costPer24h * epochs;
4949

50+
console.log('[CostAndDurationInterface]', { totalCost, costPer24h, epochs });
51+
5052
if (applyDiscount) {
5153
const discountPercentage = getDiscountPercentage(paymentMonthsCount);
5254

src/shared/jobs/JobActions.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ import { deletePipeline, sendJobCommand } from '@lib/api/deeploy';
33
import { getCurrentEpoch, getDevAddress, isUsingDevAddress } from '@lib/config';
44
import { DeploymentContextType, useDeploymentContext } from '@lib/contexts/deployment';
55
import { InteractionContextType, useInteractionContext } from '@lib/contexts/interaction';
6-
import { buildDeeployMessage } from '@lib/deeploy-utils';
6+
import { buildDeeployMessage, generateDeeployNonce } from '@lib/deeploy-utils';
77
import { routePath } from '@lib/routes/route-paths';
88
import ContextMenuWithTrigger from '@shared/ContextMenuWithTrigger';
99
import { RunningJobWithResources } from '@typedefs/deeploys';
1010
import { useState } from 'react';
1111
import toast from 'react-hot-toast';
1212
import { RiArrowDownSLine } from 'react-icons/ri';
1313
import { useNavigate } from 'react-router-dom';
14-
import { generateNonce } from 'siwe';
1514
import { useAccount, useSignMessage } from 'wagmi';
1615

1716
export default function JobActions({
@@ -61,7 +60,7 @@ export default function JobActions({
6160
return;
6261
}
6362

64-
const nonce = generateNonce();
63+
const nonce = generateDeeployNonce();
6564

6665
const payload = {
6766
app_id: job!.alias,
@@ -145,7 +144,7 @@ export default function JobActions({
145144
throw new Error('Job data unavailable');
146145
}
147146

148-
const nonce = generateNonce();
147+
const nonce = generateDeeployNonce();
149148

150149
const payload = {
151150
app_id: job.alias,

0 commit comments

Comments
 (0)