Skip to content

Commit

Permalink
fix(contract configuration): return cache url as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Atticus committed Mar 22, 2024
1 parent 21224e2 commit b4a7bc3
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/common/contracts/remote-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,26 +30,29 @@ export class RemoteContract<T> implements BaseContract<T>, ReadContract {
private logger: Logger;
private http: HTTPClient;
private contractTxId: string;
private cacheUrl: string;

constructor({
url = 'https://api.arns.app',
cacheUrl = 'https://api.arns.app',
contractTxId,
logger = new DefaultLogger(),
}: {
contractTxId: string;
url?: string;
cacheUrl?: string;
logger?: DefaultLogger;
}) {
this.cacheUrl = cacheUrl;
this.contractTxId = contractTxId;
this.logger = logger;
this.http = new AxiosHTTPService({
url: `${url}/v1/contract/${contractTxId}`,
url: `${cacheUrl}/v1/contract/${contractTxId}`,
});
}

configuration(): { contractTxId: string } {
configuration(): { contractTxId: string; cacheUrl: string } {
return {
contractTxId: this.contractTxId,
cacheUrl: this.cacheUrl,
};
}

Expand Down
3 changes: 2 additions & 1 deletion src/common/contracts/warp-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,10 @@ export class WarpContract<T> implements BaseContract<T>, ReadContract {
this.cacheUrl = cacheUrl;
}

configuration(): { contractTxId: string } {
configuration(): { contractTxId: string; cacheUrl: string | undefined } {
return {
contractTxId: this.contractTxId,
cacheUrl: this.cacheUrl,
};
}

Expand Down
2 changes: 1 addition & 1 deletion tests/ant.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('ANT contract apis', () => {
ant = new ANT({
signer,
contract: new RemoteContract<ANTState>({
url: localCacheUrl,
cacheUrl: localCacheUrl,
contractTxId,
}),
});
Expand Down
4 changes: 2 additions & 2 deletions tests/ar-io.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('ArIO Client', () => {
arIO = new ArIO({
contract: new RemoteContract<ArIOState>({
contractTxId: ARNS_DEVNET_REGISTRY_TX,
url: localCacheUrl,
cacheUrl: localCacheUrl,
}),
signer,
});
Expand All @@ -36,7 +36,7 @@ describe('ArIO Client', () => {
const client = new ArIO({
contract: new RemoteContract<ArIOState>({
contractTxId: ARNS_DEVNET_REGISTRY_TX,
url: process.env.REMOTE_CACHE_URL || 'http://localhost:3000',
cacheUrl: localCacheUrl,
}),
});
expect(client.connect(signer)).toBeDefined();
Expand Down

0 comments on commit b4a7bc3

Please sign in to comment.