Skip to content

Commit

Permalink
fix(warp contract): added test for getting state after connecting wit…
Browse files Browse the repository at this point in the history
…h warp
  • Loading branch information
Atticus committed Mar 22, 2024
1 parent 9869415 commit 060ee2c
Show file tree
Hide file tree
Showing 18 changed files with 24 additions and 5 deletions.
Binary file added cache/warp/contracts/000003.log
Binary file not shown.
1 change: 1 addition & 0 deletions cache/warp/contracts/CURRENT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MANIFEST-000002
Empty file added cache/warp/contracts/LOCK
Empty file.
1 change: 1 addition & 0 deletions cache/warp/contracts/LOG
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2024/03/22-08:17:56.172701 17335b000 Delete type=3 #1
Binary file added cache/warp/contracts/MANIFEST-000002
Binary file not shown.
Binary file added cache/warp/source/000003.log
Binary file not shown.
1 change: 1 addition & 0 deletions cache/warp/source/CURRENT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MANIFEST-000002
Empty file added cache/warp/source/LOCK
Empty file.
1 change: 1 addition & 0 deletions cache/warp/source/LOG
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2024/03/22-08:17:57.525010 173b63000 Delete type=3 #1
Binary file added cache/warp/source/MANIFEST-000002
Binary file not shown.
Binary file added cache/warp/state/000003.log
Binary file not shown.
1 change: 1 addition & 0 deletions cache/warp/state/CURRENT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
MANIFEST-000002
Empty file added cache/warp/state/LOCK
Empty file.
1 change: 1 addition & 0 deletions cache/warp/state/LOG
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2024/03/22-08:17:56.169630 17436b000 Delete type=3 #1
Binary file added cache/warp/state/MANIFEST-000002
Binary file not shown.
2 changes: 1 addition & 1 deletion src/common/ant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ export class ANT implements ANTContract, BaseContract<ANTState> {
/**
* Returns the current state of the contract.
*/
async getState(params: EvaluationParameters): Promise<ANTState> {
async getState(params: EvaluationParameters = {}): Promise<ANTState> {
const state = await this.contract.getState(params);
return state;
}
Expand Down
12 changes: 8 additions & 4 deletions src/common/contracts/warp-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,20 @@ export class WarpContract<T> implements BaseContract<T>, ReadContract {
constructor({
contractTxId,
cacheUrl,
warp = WarpFactory.forMainnet({
...defaultCacheOptions,
inMemory: true, // default to in memory for now, a custom warp implementation can be provided
}),
warp = WarpFactory.forMainnet(
{
...defaultCacheOptions,
// inMemory: true, // default to in memory for now, a custom warp implementation can be provided
},
true,
),
}: {
contractTxId: string;
cacheUrl?: string;
warp?: Warp;
signer?: ContractSigner;
}) {
this.contractTxId = contractTxId;
this.contract = warp.contract<T>(contractTxId);
this.cacheUrl = cacheUrl;
}
Expand Down
9 changes: 9 additions & 0 deletions tests/ant.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,4 +143,13 @@ describe('ANT contract apis', () => {
expect(state).toBeDefined();
},
);

it('Should get state with warp contract', async () => {
const jwk = await arweave.wallets.generate();
const signer = new ArweaveSigner(jwk);
// connecting updates contract to use warp
ant.connect(signer);
const state = await ant.getState();
expect(state).toBeDefined();
});
});

0 comments on commit 060ee2c

Please sign in to comment.