diff --git a/src/common/ArIO.ts b/src/common/ArIO.ts index ffa888a6..e15bedf4 100644 --- a/src/common/ArIO.ts +++ b/src/common/ArIO.ts @@ -14,7 +14,6 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { ArweaveTransactionID } from '../types.js'; import { ContractStateProvider } from '../types.js'; import { DefaultLogger } from './logger.js'; @@ -46,7 +45,7 @@ export class ArIO implements ContractStateProvider { async getContractState({ contractTxId, }: { - contractTxId: ArweaveTransactionID; + contractTxId: string; }): Promise { return this.contractStateProvider.getContractState({ contractTxId }); } diff --git a/src/common/ContractStateProviders/ArNSRemoteCache.ts b/src/common/ContractStateProviders/ArNSRemoteCache.ts index f256fd04..b9997c71 100644 --- a/src/common/ContractStateProviders/ArNSRemoteCache.ts +++ b/src/common/ContractStateProviders/ArNSRemoteCache.ts @@ -14,11 +14,7 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -import { - ArweaveTransactionID, - ContractStateProvider, - HTTPClient, -} from '../../types.js'; +import { ContractStateProvider, HTTPClient } from '../../types.js'; import { AxiosHTTPService } from '../http.js'; import { DefaultLogger } from '../logger.js'; @@ -46,7 +42,7 @@ export class ArNSRemoteCache implements ContractStateProvider { async getContractState({ contractTxId, }: { - contractTxId: ArweaveTransactionID; + contractTxId: string; }): Promise { this.logger.debug(`Fetching contract state`); diff --git a/src/types.ts b/src/types.ts index 0b7cad41..ef09a2e8 100644 --- a/src/types.ts +++ b/src/types.ts @@ -17,17 +17,11 @@ import { Readable } from 'stream'; import { ReadableStream } from 'stream/web'; -import { ARWEAVE_TX_REGEX } from './constants.js'; - export interface ContractStateProvider { /** * The ContractStateProvider interface is used to define a contract state provider. */ - getContractState({ - contractTxId, - }: { - contractTxId: ArweaveTransactionID; - }): Promise; + getContractState({ contractTxId }: { contractTxId: string }): Promise; } /* eslint-disable @typescript-eslint/no-explicit-any */ export interface Logger { @@ -66,33 +60,3 @@ export interface HTTPClient { data: Readable | ReadableStream | Buffer; }): Promise; } - -export interface Equatable { - equals(other: T): boolean; -} - -export class ArweaveTransactionID implements Equatable { - constructor(private readonly transactionId?: string) { - if (transactionId === undefined || !ARWEAVE_TX_REGEX.test(transactionId)) { - throw new Error( - 'Transaction ID should be a 43-character, alphanumeric string potentially including "-" and "_" characters.', - ); - } - } - - [Symbol.toPrimitive](hint?: string): string { - if (hint === 'number') { - throw new Error('Transaction IDs cannot be interpreted as a number!'); - } - - return this.toString(); - } - - toString(): string { - return this.transactionId ?? ''; - } - - equals(entityId: ArweaveTransactionID): boolean { - return this.transactionId === entityId.transactionId; - } -} diff --git a/tests/ArNSRemoteCache.test.ts b/tests/ArNSRemoteCache.test.ts index 50bc73b0..acf77cca 100644 --- a/tests/ArNSRemoteCache.test.ts +++ b/tests/ArNSRemoteCache.test.ts @@ -1,6 +1,5 @@ import { ArIO } from '../src/common/ArIO.js'; import { ArNSRemoteCache } from '../src/common/ContractStateProviders/ArNSRemoteCache.js'; -import { ArweaveTransactionID } from '../src/types.js'; describe('ArIO Client', () => { const remoteCacheProvider = new ArNSRemoteCache({}); @@ -16,7 +15,7 @@ describe('ArIO Client', () => { const stubGetContractState = jest.fn(); remoteProvider.getContractState = stubGetContractState; - const contractTxId = new ArweaveTransactionID(''.padEnd(43, 'a')); + const contractTxId = ''.padEnd(43, 'a'); await client.getContractState({ contractTxId }); expect(stubGetContractState).toHaveBeenCalledWith({ contractTxId }); }); @@ -24,7 +23,7 @@ describe('ArIO Client', () => { it('should throw on bad contract id', async () => { let result; try { - const contractTxId = new ArweaveTransactionID(''.padEnd(42, 'a')); + const contractTxId = ''.padEnd(42, 'a'); result = await arioClient .getContractState({ contractTxId }) .catch((e) => e);