diff --git a/src/common/io.ts b/src/common/io.ts index 78a994bf..047bdd86 100644 --- a/src/common/io.ts +++ b/src/common/io.ts @@ -72,11 +72,7 @@ import { } from '../types/io.js'; import { AoSigner, mARIOToken } from '../types/token.js'; import { createAoSigner } from '../utils/ao.js'; -import { - getCurrentBlockUnixTimestampMs, - paginationParamsToTags, - pruneTags, -} from '../utils/arweave.js'; +import { paginationParamsToTags, pruneTags } from '../utils/arweave.js'; import { defaultArweave } from './arweave.js'; import { AOProcess } from './contracts/ao-process.js'; import { InvalidContractConfigurationError } from './error.js'; @@ -166,12 +162,6 @@ export class ARIOReadable implements AoARIORead { async getEpochSettings(params?: EpochInput): Promise { const allTags = [ { name: 'Action', value: 'Epoch-Settings' }, - { - name: 'Timestamp', - value: - (params as { timestamp?: number })?.timestamp?.toString() ?? - (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(), - }, { name: 'Epoch-Index', value: (params as { epochIndex?: number })?.epochIndex?.toString(), @@ -185,12 +175,6 @@ export class ARIOReadable implements AoARIORead { async getEpoch(epoch?: EpochInput): Promise { const allTags = [ { name: 'Action', value: 'Epoch' }, - { - name: 'Timestamp', - value: - (epoch as { timestamp?: number })?.timestamp?.toString() ?? - (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(), - }, { name: 'Epoch-Index', value: (epoch as { epochIndex?: number })?.epochIndex?.toString(), @@ -349,15 +333,7 @@ export class ARIOReadable implements AoARIORead { async getCurrentEpoch(): Promise { return this.process.read({ - tags: [ - { name: 'Action', value: 'Epoch' }, - { - name: 'Timestamp', - value: ( - await getCurrentBlockUnixTimestampMs(this.arweave) - ).toString(), - }, - ], + tags: [{ name: 'Action', value: 'Epoch' }], }); } @@ -366,12 +342,6 @@ export class ARIOReadable implements AoARIORead { ): Promise { const allTags = [ { name: 'Action', value: 'Epoch-Prescribed-Observers' }, - { - name: 'Timestamp', - value: - (epoch as { timestamp?: number })?.timestamp?.toString() ?? - (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(), - }, { name: 'Epoch-Index', value: (epoch as { epochIndex?: number })?.epochIndex?.toString(), @@ -386,12 +356,6 @@ export class ARIOReadable implements AoARIORead { async getPrescribedNames(epoch?: EpochInput): Promise { const allTags = [ { name: 'Action', value: 'Epoch-Prescribed-Names' }, - { - name: 'Timestamp', - value: - (epoch as { timestamp?: number })?.timestamp?.toString() ?? - (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(), - }, { name: 'Epoch-Index', value: (epoch as { epochIndex?: number })?.epochIndex?.toString(), @@ -406,12 +370,6 @@ export class ARIOReadable implements AoARIORead { async getObservations(epoch?: EpochInput): Promise { const allTags = [ { name: 'Action', value: 'Epoch-Observations' }, - { - name: 'Timestamp', - value: - (epoch as { timestamp?: number })?.timestamp?.toString() ?? - (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(), - }, { name: 'Epoch-Index', value: (epoch as { epochIndex?: number })?.epochIndex?.toString(), @@ -426,12 +384,6 @@ export class ARIOReadable implements AoARIORead { async getDistributions(epoch?: EpochInput): Promise { const allTags = [ { name: 'Action', value: 'Epoch-Distributions' }, - { - name: 'Timestamp', - value: - (epoch as { timestamp?: number })?.timestamp?.toString() ?? - (await getCurrentBlockUnixTimestampMs(this.arweave)).toString(), - }, { name: 'Epoch-Index', value: (epoch as { epochIndex?: number })?.epochIndex?.toString(), @@ -497,19 +449,6 @@ export class ARIOReadable implements AoARIORead { name: 'Purchase-Type', value: type, }, - { - name: 'Timestamp', - value: ( - await this.arweave.blocks - .getCurrent() - .then((block) => { - return { timestamp: block.timestamp * 1000 }; - }) - .catch(() => { - return { timestamp: Date.now() }; // fallback to current time - }) - ).timestamp.toString(), - }, ]; return this.process.read({ @@ -554,19 +493,6 @@ export class ARIOReadable implements AoARIORead { name: 'Fund-From', value: fundFrom, }, - { - name: 'Timestamp', - value: ( - await this.arweave.blocks - .getCurrent() - .then((block) => { - return { timestamp: block.timestamp * 1000 }; - }) - .catch(() => { - return { timestamp: Date.now() }; // fallback to current time - }) - ).timestamp.toString(), - }, ]; return this.process.read({ diff --git a/src/types/io.ts b/src/types/io.ts index 82fabc0f..d2f5d6bc 100644 --- a/src/types/io.ts +++ b/src/types/io.ts @@ -62,9 +62,6 @@ export type EpochInput = | { epochIndex: AoEpochIndex; } - | { - timestamp: Timestamp; - } | undefined; // AO/ARIO Contract diff --git a/src/utils/arweave.ts b/src/utils/arweave.ts index b9030949..3b6d6569 100644 --- a/src/utils/arweave.ts +++ b/src/utils/arweave.ts @@ -13,10 +13,8 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -import Arweave from 'arweave'; - import { ARWEAVE_TX_REGEX } from '../constants.js'; -import { BlockHeight, Timestamp } from '../types/common.js'; +import { BlockHeight } from '../types/common.js'; import { PaginationParams } from '../types/io.js'; export const validateArweaveId = (id: string): boolean => { @@ -44,19 +42,6 @@ export const pruneTags = ( ); }; -export const getCurrentBlockUnixTimestampMs = async ( - arweave: Arweave, -): Promise => { - return await arweave.blocks - .getCurrent() - .then((block) => { - return block.timestamp * 1000; - }) - .catch(() => { - return Date.now(); // fallback to current time - }); -}; - export const paginationParamsToTags = ( params?: PaginationParams, ): { name: string; value: string }[] => { diff --git a/tests/unit/utils.test.ts b/tests/unit/utils.test.ts index 022329ab..57f20111 100644 --- a/tests/unit/utils.test.ts +++ b/tests/unit/utils.test.ts @@ -1,11 +1,7 @@ -import Arweave from 'arweave'; import { strict as assert } from 'node:assert'; import { describe, it } from 'node:test'; -import { - getCurrentBlockUnixTimestampMs, - pruneTags, -} from '../../src/utils/arweave.js'; +import { pruneTags } from '../../src/utils/arweave.js'; describe('pruneTags', () => { it('should remove tags with undefined values', () => { @@ -52,15 +48,3 @@ describe('pruneTags', () => { assert.deepEqual(prunedTags, []); }); }); - -describe('getCurrentBlockUnixTimestamp', () => { - it('should return the current block timestamp', async () => { - const arweave = Arweave.init({}); - // cheap way to check the returned timestamp is within the boundaries of the async call - const minTimestamp = Date.now(); - const timestamp = await getCurrentBlockUnixTimestampMs(arweave); - const maxTimestamp = Date.now(); - assert.ok(timestamp >= minTimestamp); - assert.ok(timestamp <= maxTimestamp); - }); -});