Skip to content

Commit

Permalink
fix(contracts): remove write method and type from remote contract
Browse files Browse the repository at this point in the history
  • Loading branch information
Atticus committed Mar 21, 2024
1 parent 2cd1b5c commit 740d8b8
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 20 deletions.
6 changes: 3 additions & 3 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ export type ContractConfiguration = {
}
);

export type ContractInteractionProvider<T> = BaseContract<T> &
ReadContract &
WriteContract;
export type ContractInteractionProvider<T> =
| (BaseContract<T> & ReadContract & WriteContract)
| (BaseContract<T> & ReadContract);

export function isContractConfiguration<T>(
config: ContractConfiguration,
Expand Down
18 changes: 3 additions & 15 deletions src/common/contracts/remote-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@
*/
import {
ArIOSigner,
ContractInteractionProvider,
BaseContract,
EvaluationParameters,
HTTPClient,
Logger,
ReadContract,
} from '../../types.js';
import { AxiosHTTPService } from '../http.js';
import { DefaultLogger } from '../logger.js';

// TODO: this assumes the API structure matches the current arns-service API - we will want to consider another interface that exposes relevant APIs with client implementations (arns-service, DRE nodes, etc.)
export class RemoteContract<T> implements ContractInteractionProvider<T> {
export class RemoteContract<T> implements BaseContract<T>, ReadContract {
private logger: Logger;
private http: HTTPClient;
contractTxId: string;
Expand Down Expand Up @@ -90,17 +91,4 @@ export class RemoteContract<T> implements ContractInteractionProvider<T> {
});
return result;
}
/* eslint-disable */
// @ts-ignore
async writeInteraction<Input, State>({
functionName,
inputs,
evaluationOptions,
}: EvaluationParameters<{
functionName: string;
inputs: Input;
}>): Promise<State> {
/* eslint-enable */
throw new Error('Cannot write to a remote contract');
}
}
8 changes: 6 additions & 2 deletions src/common/contracts/warp-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,20 @@ import {

import {
ArIOSigner,
ContractInteractionProvider,
BaseContract,
EvaluationParameters,
ReadContract,
WriteContract,
} from '../../types.js';
import { FailedRequestError } from '../error.js';

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

export class WarpContract<T> implements ContractInteractionProvider<T> {
export class WarpContract<T>
implements BaseContract<T>, ReadContract, WriteContract
{
private contract: Contract<T>;
protected contractTxId: string;
private cacheUrl: string | undefined;
Expand Down

0 comments on commit 740d8b8

Please sign in to comment.