Skip to content

Commit

Permalink
Merge pull request #665 from ar-io/develop
Browse files Browse the repository at this point in the history
Release fix for TTL limits
  • Loading branch information
atticusofsparta authored Feb 6, 2025
2 parents 916ef98 + 2677cf9 commit 6270e73
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 24 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
},
"dependencies": {
"@ant-design/icons": "5.4.0",
"@ar.io/sdk": "^3.3.1-alpha.2",
"@ar.io/sdk": "^3.5.0-alpha.5",
"@permaweb/aoconnect": "^0.0.59",
"@radix-ui/react-radio-group": "^1.2.1",
"@radix-ui/react-select": "^2.1.4",
Expand Down
16 changes: 14 additions & 2 deletions src/components/forms/DomainSettings/TTLRow.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@ import {
VALIDATION_INPUT_TYPES,
} from '@src/types';
import { validateTTLSeconds } from '@src/utils';
import { DEFAULT_TTL_SECONDS, MAX_TTL_SECONDS } from '@src/utils/constants';
import {
DEFAULT_TTL_SECONDS,
MAX_TTL_SECONDS,
MIN_TTL_SECONDS,
} from '@src/utils/constants';
import eventEmitter from '@src/utils/events';
import { Skeleton } from 'antd';
import { useState } from 'react';
Expand Down Expand Up @@ -84,7 +88,15 @@ export default function TTLRow({
editable={editable}
editing={editing}
setEditing={() => setEditing(true)}
onSave={() => setShowModal(true)}
onSave={() => {
try {
if (newTTL > MAX_TTL_SECONDS || newTTL < MIN_TTL_SECONDS)
throw new Error(VALIDATION_INPUT_TYPES.VALID_TTL);
setShowModal(true);
} catch (error) {
eventEmitter.emit('error', error);
}
}}
onCancel={() => {
setEditing(false);
setNewTTL(ttlSeconds ?? DEFAULT_TTL_SECONDS);
Expand Down
4 changes: 2 additions & 2 deletions src/state/actions/dispatchArNSUpdate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function dispatchArNSUpdate({
const handlers = await queryClient.fetchQuery({
queryKey: ['handlers', id, aoNetworkSettings.ANT],
queryFn: async () => {
// validate transfer supports eth addresses and single char undername fix
// validate transfer supports eth addresses and single char undername fix and max ttl
const drySetRecordRes = await antAo
.dryrun({
process: id,
Expand All @@ -57,7 +57,7 @@ export function dispatchArNSUpdate({
{ name: 'Action', value: 'Set-Record' },
{ name: 'Sub-Domain', value: 'a' },
{ name: 'Transaction-Id', value: 'test-'.padEnd(43, '1') },
{ name: 'TTL-Seconds', value: '900' },
{ name: 'TTL-Seconds', value: '86400' },
],
})
.catch(() => {
Expand Down
10 changes: 4 additions & 6 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { Dispatch, SetStateAction } from 'react';

import { AntDetailKey } from './components/cards/ANTCard/ANTCard';
import { ArweaveTransactionID } from './services/arweave/ArweaveTransactionID';
import { MAX_TTL_SECONDS, MIN_TTL_SECONDS } from './utils/constants';

export type ARNSDomains = Record<string, AoArNSNameData>;

Expand Down Expand Up @@ -521,14 +522,11 @@ export enum VALIDATION_INPUT_TYPES {
ARWEAVE_ID = 'Is valid Arweave Transaction (TX) ID.',
ARWEAVE_ADDRESS = 'Is likely an Arweave wallet address.',
AO_ADDRESS = 'Is a valid AO Address.',
ARNS_NAME = 'ARNS Name.',

UNDERNAME = 'Is a valid Undername.',
ANT_CONTRACT_ID = 'Is a valid Arweave Name Token (ANT).',
// unfortunately we cannot use computed values in enums, so be careful if we ever modify this number
TRANSACTION_CONFIRMATIONS = `Has sufficient confirmations (50+).`,
VALID_TTL = `Minimum ttl allowed is 900 and Maximum ttl allowed is 2,592,000.`,
EMAIL = `Is a valid email`,
SMARTWEAVE_CONTRACT = `Is a SmartWeave Contract`,
VALID_TTL = `TTL must between ${MIN_TTL_SECONDS} and ${MAX_TTL_SECONDS} seconds`,

VALID_ANT_NAME = `ANT name or ticker must be equal or less than 1798 characters.`,
}

Expand Down
9 changes: 4 additions & 5 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,6 @@ export const ARWEAVE_TX_LENGTH = 43;
export const EMAIL_REGEX = new RegExp(
"([!#-'*+/-9=?A-Z^-~-]+(.[!#-'*+/-9=?A-Z^-~-]+)*|\"([]!#-[^-~ \t]|(\\[\t -~]))+\")@([!#-'*+/-9=?A-Z^-~-]+(.[!#-'*+/-9=?A-Z^-~-]+)*|[[\t -Z^-~]*])", // eslint-disable-line
);
export const TTL_SECONDS_REGEX = new RegExp('^[0-9]{3,7}$');
export const TTL_SECONDS_ENTRY_REGEX = new RegExp('^[0-9]{1,7}$');

export const FQDN_REGEX = new RegExp(
'^(?:(?!-)[A-Za-z0-9-]{1,63}(?<!-)\\.)+[A-Za-z]{1,63}$',
Expand Down Expand Up @@ -127,7 +125,7 @@ export const NETWORK_DEFAULTS = {
};

export const RECOMMENDED_TRANSACTION_CONFIRMATIONS = 50;
export const DEFAULT_TTL_SECONDS = 3600;

export const DEFAULT_MAX_UNDERNAMES = 10;
export const MAX_UNDERNAME_COUNT = 10_000;

Expand All @@ -149,8 +147,9 @@ export const FEATURED_DOMAINS: { [x: string]: { imageUrl: string } } = {
mfers: { imageUrl: MFERS_IMAGE },
};

export const MAX_TTL_SECONDS = 2_592_000;
export const MIN_TTL_SECONDS = 900;
export const DEFAULT_TTL_SECONDS = 900;
export const MAX_TTL_SECONDS = 86400;
export const MIN_TTL_SECONDS = 60;
export const MAX_LEASE_DURATION = 5;
export const MIN_LEASE_DURATION = 1;
export const SECONDS_IN_GRACE_PERIOD = 14 * 24 * 60 * 60; // 2 weeks
Expand Down
4 changes: 0 additions & 4 deletions src/utils/transactionUtils/transactionUtils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
MAX_TTL_SECONDS,
MIN_TTL_SECONDS,
PERMANENT_DOMAIN_MESSAGE,
TTL_SECONDS_REGEX,
YEAR_IN_MILLISECONDS,
} from '../constants';
import eventEmitter from '../events';
Expand Down Expand Up @@ -666,9 +665,6 @@ export async function validateTTLSeconds(ttl: number): Promise<void> {
`${ttl} is more than the maximum ttlSeconds requirement of ${MAX_TTL_SECONDS}`,
);
}
if (!TTL_SECONDS_REGEX.test(ttl.toString())) {
throw new Error(`${ttl} is not a valid ttlSeconds value`);
}
}

export async function withExponentialBackoff<T>({
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@
plimit-lit "^3.0.1"
warp-contracts "1.4.45"

"@ar.io/sdk@^3.3.1-alpha.2":
version "3.3.1-alpha.2"
resolved "https://registry.yarnpkg.com/@ar.io/sdk/-/sdk-3.3.1-alpha.2.tgz#1e28e0c8b26280c7692fd4f4c705801d91467606"
integrity sha512-WEF6gFNuQq9iKYExrAQrAy32r7zsPQbMAt6wjU7znlMZn1Fq8kYAuwE5QYxzgpzDhIlgEfMOoqjxetHZMkbB4Q==
"@ar.io/sdk@^3.5.0-alpha.5":
version "3.5.0-alpha.5"
resolved "https://registry.yarnpkg.com/@ar.io/sdk/-/sdk-3.5.0-alpha.5.tgz#58827c5bf601cd510b0ef9893a48acbf589ada73"
integrity sha512-/j1dPVXzkitJuenQ4FAwH9fCWTsN+v8+L7kKLXqvX2J/Rq47dRFKD7fHyyZL/vZIKkkUBQSLvQ48EvFUdb+DYQ==
dependencies:
"@dha-team/arbundles" "^1.0.1"
"@permaweb/aoconnect" "^0.0.57"
Expand Down

0 comments on commit 6270e73

Please sign in to comment.