Skip to content

Commit

Permalink
fix(tests): update docker compose params
Browse files Browse the repository at this point in the history
  • Loading branch information
Atticus committed Mar 21, 2024
1 parent bf41b60 commit a71befd
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 70 deletions.
10 changes: 8 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,16 @@ services:
environment:
- LOG_LEVEL=debug
- PREFETCH_CONTRACTS=true
- PREFETCH_CONTRACT_IDS=['_NctcA2sRy1-J4OmIQZbYFPM17piNcbdBPH2ncX2RL8', 'UC2zwawQoTnh0TNd9mYLQS4wObBBeaOU5LPQTNETqA4']
- PREFETCH_CONTRACT_IDS=_NctcA2sRy1-J4OmIQZbYFPM17piNcbdBPH2ncX2RL8,UC2zwawQoTnh0TNd9mYLQS4wObBBeaOU5LPQTNETqA4
- BOOTSTRAP_CONTRACTS=false
healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:3000/healthcheck']
test:
[
'CMD',
'curl',
'-f',
'http://localhost:3000/healthcheck'
]
interval: 10s
timeout: 5s
retries: 5
33 changes: 2 additions & 31 deletions src/common/ant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
ANTRecord,
ANTState,
ArIOSigner,
BaseContract,
ContractConfiguration,
ContractInteractionProvider,
EvaluationOptions,
Expand All @@ -29,7 +30,7 @@ import {
import { RemoteContract } from './contracts/remote-contract.js';
import { WarpContract } from './index.js';

export class ANT implements ANTContract, ContractInteractionProvider<ANTState> {
export class ANT implements ANTContract, BaseContract<ANTState> {
private contract: ContractInteractionProvider<ANTState>;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand Down Expand Up @@ -66,36 +67,6 @@ export class ANT implements ANTContract, ContractInteractionProvider<ANTState> {
return state;
}

async readInteraction<Input, State>({
functionName,
inputs,
evaluationOptions,
}: EvaluationParameters<{
functionName: string;
inputs?: Input | undefined;
}>): Promise<State> {
return this.contract.readInteraction({
functionName,
inputs,
evaluationOptions,
});
}

async writeInteraction<Input, State>({
functionName,
inputs,
evaluationOptions,
}: EvaluationParameters<{
functionName: string;
inputs: Input;
}>): Promise<State> {
return this.contract.writeInteraction({
functionName,
inputs,
evaluationOptions,
});
}

async getRecord({
domain,
evaluationOptions,
Expand Down
36 changes: 2 additions & 34 deletions src/common/ar-io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import {
ArIOState,
ArNSAuctionData,
ArNSNameData,
BaseContract,
ContractConfiguration,
ContractInteractionProvider,
EpochDistributionData,
Expand All @@ -36,9 +37,7 @@ import {
import { RemoteContract } from './contracts/remote-contract.js';
import { WarpContract } from './index.js';

export class ArIO
implements ArIOContract, ContractInteractionProvider<ArIOState>
{
export class ArIO implements ArIOContract, BaseContract<ArIOState> {
private contract: ContractInteractionProvider<ArIOState>;
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
Expand Down Expand Up @@ -83,37 +82,6 @@ export class ArIO
const state = await this.contract.getState(params);
return state;
}

async readInteraction<Input, State>({
functionName,
inputs,
evaluationOptions,
}: EvaluationParameters<{
functionName: string;
inputs?: Input | undefined;
}>): Promise<State> {
return this.contract.readInteraction({
functionName,
inputs,
evaluationOptions,
});
}

async writeInteraction<Input, State>({
functionName,
inputs,
evaluationOptions,
}: EvaluationParameters<{
functionName: string;
inputs: Input;
}>): Promise<State> {
return this.contract.writeInteraction({
functionName,
inputs,
evaluationOptions,
});
}

/**
* Returns the ARNS record for the given domain.
*/
Expand Down
15 changes: 13 additions & 2 deletions src/common/contracts/warp-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import { Signer } from 'arbundles/node';
import {
Contract,
LoggerFactory,
Warp,
WarpFactory,
defaultCacheOptions,
Expand All @@ -29,6 +30,10 @@ import {
} from '../../types.js';
import { FailedRequestError } from '../error.js';

LoggerFactory.INST.setOptions({
logLevel: 'fatal',
});

export class WarpContract<T> implements ContractInteractionProvider<T> {
private contract: Contract<T>;
protected contractTxId: string;
Expand Down Expand Up @@ -93,13 +98,19 @@ export class WarpContract<T> implements ContractInteractionProvider<T> {
// TODO: view state only supports sort key so we won't be able to use block height
}: EvaluationParameters<{ functionName: string; inputs: I }>): Promise<K> {
const evaluationResult = await this.contract.viewState<unknown, K>({
functionName,
function: functionName,
...inputs,
});

if (!evaluationResult.result) {
throw new FailedRequestError(
502,
'Failed to evaluate contract read interaction',
'Failed to evaluate contract read interaction: ' +
JSON.stringify(
{ error: evaluationResult.errorMessage, functionName, inputs },
null,
2,
),
);
}

Expand Down
1 change: 0 additions & 1 deletion tests/ant.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ describe('ANT contract apis', () => {
`should get records with evaluation options: ${JSON.stringify('%s')}`,
async (evalTo) => {
const records = await ant.getRecords({ evaluationOptions: { evalTo } });
console.dir({ records: records['@'] }, { depth: 4 });
expect(records).toBeDefined();
},
);
Expand Down

0 comments on commit a71befd

Please sign in to comment.