Skip to content

Commit

Permalink
chore: move type files up and cleanup exports
Browse files Browse the repository at this point in the history
  • Loading branch information
dtfiedler committed Mar 8, 2024
1 parent 1c0897e commit d484544
Show file tree
Hide file tree
Showing 18 changed files with 24 additions and 56 deletions.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions src/common/ar-io.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import {
EvaluationParameters,
Gateway,
SmartWeaveContract,
} from '../types/index.js';
import { RemoteContract } from './index.js';
} from '../types.js';
import { RemoteContract } from './contracts/remote-contract.js';

// TODO: append this with other configuration options (e.g. local vs. remote evaluation)
export type ContractConfiguration =
Expand Down
18 changes: 0 additions & 18 deletions src/common/contracts/index.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/common/contracts/remote-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
HTTPClient,
Logger,
SmartWeaveContract,
} from '../../types/index.js';
} from '../../types.js';
import { AxiosHTTPService } from '../http.js';
import { DefaultLogger } from '../logger.js';

Expand Down
16 changes: 7 additions & 9 deletions src/common/contracts/warp-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,9 @@ import {
defaultCacheOptions,
} from 'warp-contracts';

import { EvaluationParameters, SmartWeaveContract } from '../../types/index.js';
import { EvaluationParameters, SmartWeaveContract } from '../../types.js';
import { FailedRequestError } from '../error.js';

export const defaultWarpClient = WarpFactory.forMainnet({
...defaultCacheOptions,
inMemory: true, // default to in memory for now, a custom warp implementation can be provided
});

export class WarpContract<T> implements SmartWeaveContract<T> {
private contract: Contract<T>;
private contractTxId: string;
Expand All @@ -37,18 +32,21 @@ export class WarpContract<T> implements SmartWeaveContract<T> {
constructor({
contractTxId,
cacheUrl,
warp = defaultWarpClient,
warp = WarpFactory.forMainnet({
...defaultCacheOptions,
inMemory: true, // default to in memory for now, a custom warp implementation can be provided
}),
}: {
contractTxId: string;
cacheUrl?: string;
warp: Warp;
contractTxId: string;
}) {
// sync state
this.contract = warp.contract<T>(contractTxId);
this.cacheUrl = cacheUrl;
}

private async syncState() {
// TODO: get contract manifest and set it before evaluating
if (this.cacheUrl !== undefined) {
await this.contract.syncState(
`${this.cacheUrl}/v1/contract/${this.contractTxId}`,
Expand Down
2 changes: 1 addition & 1 deletion src/common/http.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/
import { AxiosInstance } from 'axios';

import { HTTPClient, Logger } from '../types/index.js';
import { HTTPClient, Logger } from '../types.js';
import { createAxiosInstance } from '../utils/index.js';
import { FailedRequestError, NotFound, UnknownError } from './error.js';
import { DefaultLogger } from './logger.js';
Expand Down
5 changes: 4 additions & 1 deletion src/common/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from './ar-io.js';
export * from './contracts/index.js';
export * from './error.js';
export * from './logger.js';

// contracts
export * from './contracts/remote-contract.js';
export * from './contracts/warp-contract.js';
2 changes: 1 addition & 1 deletion src/common/logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import 'setimmediate';
import winston, { createLogger, format, transports } from 'winston';

import { Logger } from '../types/index.js';
import { Logger } from '../types.js';
import { version } from '../version.js';

export class DefaultLogger implements Logger {
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/node/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from '../types/index.js';
export * from '../types.js';
export * from '../common/index.js';
export * from '../constants.js';
export * from '../utils/index.js';
1 change: 0 additions & 1 deletion src/types/index.ts → src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

export * from './arns-service.js';
export * from './contract-state.js';
export * from './common.js';
2 changes: 1 addition & 1 deletion src/utils/arweave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { BlockHeight } from '../common.js';
import { ARWEAVE_TX_REGEX } from '../constants.js';
import { BlockHeight } from '../types/common.js';

export const validateArweaveId = (id: string): boolean => {
return ARWEAVE_TX_REGEX.test(id);
Expand Down
2 changes: 1 addition & 1 deletion src/utils/smartweave.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
import { SortKey } from '../common.js';
import { SORT_KEY_REGEX } from '../constants.js';
import { SortKey } from '../types/common.js';

export function isSortKey(sortKey: string): sortKey is SortKey {
return SmartWeaveSortKey.validate(sortKey);
Expand Down
2 changes: 1 addition & 1 deletion src/web/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
export * from '../types/index.js';
export * from '../types.js';
export * from '../common/index.js';
export * from '../constants.js';
export * from '../utils/index.js';
4 changes: 2 additions & 2 deletions tests/ar-io.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { ArIO } from '../src/common/ar-io.js';
import { RemoteContract } from '../src/common/index.js';
import { RemoteContract } from '../src/common/contracts/remote-contract.js';
import { ARNS_DEVNET_REGISTRY_TX } from '../src/constants.js';
import { ArIOState } from '../src/types/contract-state.js';
import { ArIOState } from '../src/contract-state.js';
import { SmartWeaveSortKey } from '../src/utils/smartweave.js';

const gatewayAddress = '1H7WZIWhzwTH9FIcnuMqYkTsoyv1OTfGa_amvuYwrgo';
Expand Down
14 changes: 0 additions & 14 deletions tests/utils/arweave.test.ts

This file was deleted.

4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"skipLibCheck": true,
"strictNullChecks": true
},
"include": ["src", "tests/utils/arweave.test.ts"],
"exclude": ["lib", "node_modules", "bundles"]
"include": ["src"],
"exclude": ["lib", "node_modules", "bundles", "tests"]
}

0 comments on commit d484544

Please sign in to comment.