Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PE-5005: fix(contract reader): switch to a PDS managed default contract cache #230

Merged
merged 4 commits into from
Nov 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ardrive-core-js",
"version": "2.0.1",
"version": "2.0.2",
"description": "ArDrive Core contains the essential back end application features to support the ArDrive CLI and Desktop apps, such as file management, Permaweb upload/download, wallet management and other common functions.",
"main": "./lib/exports.js",
"types": "./lib/exports.d.ts",
Expand Down
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 { PDSContractCacheServiceContractReader } from './pds_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 PDSContractCacheServiceContractReader(),
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 PDS Contract Cache Microservice
*/
export class VertoContractReader implements ContractReader {
export class PDSContractCacheServiceContractReader 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/pds_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, PDSContractCacheServiceContractReader } 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 PDSContractCacheServiceContractReader();
stub(fakeContractReader, 'readContract').resolves(stubCommunityContract);

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