Skip to content

Commit

Permalink
fix(contract reader): switch to a PDS managed default contract cache
Browse files Browse the repository at this point in the history
  • Loading branch information
fedellen committed Nov 10, 2023
1 parent d0a2adb commit 50dc1fe
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/community/ardrive_community_oracle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { CommunityOracle } from './community_oracle';
import { ArDriveContractOracle } from './ardrive_contract_oracle';
import Arweave from 'arweave';
import { SmartweaveContractReader } from './smartweave_contract_oracle';
import { VertoContractReader } from './verto_contract_oracle';
import { ArNSMicroserviceContractReader } from './arns_microservice_contract_oracle';
import { ADDR, ArweaveAddress, W, Winston } from '../types';

/**
Expand All @@ -29,7 +29,7 @@ export class ArDriveCommunityOracle implements CommunityOracle {
private readonly contractOracle: ContractOracle;

private defaultContractReaders: ContractReader[] = [
new VertoContractReader(),
new ArNSMicroserviceContractReader(),
new SmartweaveContractReader(this.arweave)
];

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { ContractReader } from './contract_oracle';

/**
* Oracle class responsible for retrieving and
* reading Smartweave Contracts from the Verto cache
* reading Smartweave Contracts from the ArNS Microservice
*/
export class VertoContractReader implements ContractReader {
export class ArNSMicroserviceContractReader implements ContractReader {
/** Fetches smartweave contracts from the Verto cache */
public async readContract(txId: TransactionID): Promise<unknown> {
const response: AxiosResponse = await axios.get(`https://v2.cache.verto.exchange/${txId}`);
const response: AxiosResponse = await axios.get(`https://api.arns.app/v1/contract/${txId}`);
const contract = response.data;
return contract.state;
}
Expand Down
2 changes: 1 addition & 1 deletion src/exports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export * from './community/community_oracle';
export * from './community/contract_oracle';
export * from './community/contract_types';
export * from './community/smartweave_contract_oracle';
export * from './community/verto_contract_oracle';
export * from './community/arns_microservice_contract_oracle';

// Pricing
export * from './pricing/ar_data_price';
Expand Down
4 changes: 2 additions & 2 deletions tests/integration/arlocal.int.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ import {
assertFolderMetaDataJson,
assertFolderMetaDataGqlTags
} from '../helpers/arlocal_test_assertions';
import { CustomMetaData, CustomMetaDataJsonFields, VertoContractReader } from '../../src/exports';
import { CustomMetaData, CustomMetaDataJsonFields, ArNSMicroserviceContractReader } from '../../src/exports';

describe('ArLocal Integration Tests', function () {
const wallet = readJWKFile('./test_wallet.json');
Expand All @@ -84,7 +84,7 @@ describe('ArLocal Integration Tests', function () {
const fakeVersion = 'FAKE_VERSION';

const arweaveOracle = new GatewayOracle(gatewayUrlForArweave(arweave));
const fakeContractReader = new VertoContractReader();
const fakeContractReader = new ArNSMicroserviceContractReader();
stub(fakeContractReader, 'readContract').resolves(stubCommunityContract);

const communityOracle = new ArDriveCommunityOracle(arweave, [fakeContractReader]);
Expand Down

0 comments on commit 50dc1fe

Please sign in to comment.