Skip to content

Commit

Permalink
fix getEscrows function of typescript sdk (#871)
Browse files Browse the repository at this point in the history
  • Loading branch information
leric7 authored Sep 6, 2023
1 parent d37684e commit 890b8ef
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
3 changes: 2 additions & 1 deletion packages/sdk/typescript/human-protocol-sdk/example/escrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { providers } from 'ethers';
import { EscrowClient } from '../src/escrow';
import { NETWORKS } from '../src/constants';
import { ChainId } from '../src/enums';
import { EscrowStatus } from '../src/types';

export const getEscrows = async () => {
if (!NETWORKS[ChainId.POLYGON_MUMBAI]) {
Expand All @@ -16,7 +17,7 @@ export const getEscrows = async () => {
);

const escrows = await escrowClient.getEscrows({
status: 'Pending',
status: EscrowStatus.Pending,
from: new Date(2023, 4, 8),
to: new Date(2023, 5, 8),
});
Expand Down
5 changes: 5 additions & 0 deletions packages/sdk/typescript/human-protocol-sdk/src/escrow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -779,6 +779,11 @@ export class EscrowClient {
GET_ESCROWS_QUERY(filter),
{
...filter,
status: filter.status
? Object.entries(EscrowStatus).find(
([, value]) => value === filter.status
)?.[0]
: undefined,
from: filter.from ? +filter.from.getTime() / 1000 : undefined,
to: filter.to ? +filter.to.getTime() / 1000 : undefined,
}
Expand Down
9 changes: 1 addition & 8 deletions packages/sdk/typescript/human-protocol-sdk/src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { BigNumber } from 'ethers';
import { EscrowStatus } from './types';

export interface IAllocation {
escrowAddress: string;
Expand All @@ -22,14 +23,6 @@ export interface IStaker {
tokensAvailable: BigNumber;
}

type EscrowStatus =
| 'Launched'
| 'Pending'
| 'Partial'
| 'Paid'
| 'Complete'
| 'Cancelled';

export interface IEscrowsFilter {
launcher?: string;
reputationOracle?: string;
Expand Down

0 comments on commit 890b8ef

Please sign in to comment.