Skip to content

Commit

Permalink
change the return values rounded to boolean type
Browse files Browse the repository at this point in the history
  • Loading branch information
aggre committed Feb 2, 2022
1 parent 48d3db5 commit 3ba050b
Show file tree
Hide file tree
Showing 45 changed files with 167 additions and 145 deletions.
8 changes: 3 additions & 5 deletions lib/common/erc20/approve.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import { createApproveCaller } from './approve'
import { stubbedSendTx } from '../utils/for-test'
import { stubTransactionResposeFactory } from '../utils/for-test'

describe('approve.spec.ts', () => {
describe('createApproveCaller', () => {
it('call success', async () => {
const success = true
const success = stubTransactionResposeFactory({})
const to = '0x0472ec0185ebb8202f3d4ddb0226998889663cf2'
const value = '12345'

const contract = {
approve: jest
.fn()
// eslint-disable-next-line @typescript-eslint/no-unused-vars
.mockImplementation(async (to: string, value: number) =>
stubbedSendTx()
),
.mockImplementation(async (to: string, value: number) => success),
}

const expected = success
Expand Down
6 changes: 3 additions & 3 deletions lib/common/erc20/approve.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import {
FallbackableOverrides,
MutationOption,
} from '../utils/execute'
import { T } from 'ramda'
import { TransactionResponse } from '@ethersproject/abstract-provider'

export type CreateApproveCaller = (
contract: ethers.Contract
) => (
to: string,
value: string,
overrides?: FallbackableOverrides
) => Promise<boolean>
) => Promise<TransactionResponse>

export const createApproveCaller: CreateApproveCaller =
(contract: ethers.Contract) =>
Expand All @@ -23,4 +23,4 @@ export const createApproveCaller: CreateApproveCaller =
mutation: true,
args: [to, value],
overrides,
}).then(T)
})
7 changes: 4 additions & 3 deletions lib/common/erc20/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { createSymbolCaller } from './symbol'
import { createDecimalsCaller } from './decimals'
import { createAllowanceCaller } from './allowance'
import { FallbackableOverrides } from '../utils/execute'
import { TransactionResponse } from '@ethersproject/abstract-provider'

export type Erc20Contract = {
readonly totalSupply: () => Promise<string>
Expand All @@ -20,19 +21,19 @@ export type Erc20Contract = {
to: string,
value: string,
overrides?: FallbackableOverrides
) => Promise<boolean>
) => Promise<TransactionResponse>
readonly allowance: (from: string, to: string) => Promise<string>
readonly approve: (
to: string,
value: string,
overrides?: FallbackableOverrides
) => Promise<boolean>
) => Promise<TransactionResponse>
readonly transferFrom: (
from: string,
to: string,
value: string,
overrides?: FallbackableOverrides
) => Promise<boolean>
) => Promise<TransactionResponse>
readonly name: () => Promise<string>
readonly symbol: () => Promise<string>
readonly decimals: () => Promise<string>
Expand Down
8 changes: 3 additions & 5 deletions lib/common/erc20/transfer.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import { createTransferCaller } from './transfer'
import { stubbedSendTx } from '../../common/utils/for-test'
import { stubTransactionResposeFactory } from '../../common/utils/for-test'

describe('transfer.spec.ts', () => {
describe('createTransferCaller', () => {
it('call success', async () => {
const success = true
const success = stubTransactionResposeFactory({})
const to = '0x0472ec0185ebb8202f3d4ddb0226998889663cf2'
const value = '12345'

const contract = {
transfer: jest
.fn()
// eslint-disable-next-line @typescript-eslint/no-unused-vars
.mockImplementation(async (to: string, value: number) =>
stubbedSendTx()
),
.mockImplementation(async (to: string, value: number) => success),
}

const expected = success
Expand Down
6 changes: 3 additions & 3 deletions lib/common/erc20/transfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import {
FallbackableOverrides,
MutationOption,
} from '../utils/execute'
import { T } from 'ramda'
import { TransactionResponse } from '@ethersproject/abstract-provider'

export type CreateTransferCaller = (
contract: ethers.Contract
) => (
to: string,
value: string,
overrides?: FallbackableOverrides
) => Promise<boolean>
) => Promise<TransactionResponse>

export const createTransferCaller: CreateTransferCaller =
(contract: ethers.Contract) =>
Expand All @@ -23,4 +23,4 @@ export const createTransferCaller: CreateTransferCaller =
args: [to, value],
mutation: true,
overrides,
}).then(T)
})
8 changes: 4 additions & 4 deletions lib/common/erc20/transferFrom.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { createTransferFromCaller } from './transferFrom'
import { stubbedSendTx } from '../../common/utils/for-test'
import { stubTransactionResposeFactory } from '../../common/utils/for-test'

describe('transferFrom.spec.ts', () => {
describe('createTransferFromCaller', () => {
it('call success', async () => {
const success = true
const success = stubTransactionResposeFactory({})
const from = '0x1E9342827907CD370CB8Ba2F768d7D50b2f457F9'
const to = '0x0472ec0185ebb8202f3d4ddb0226998889663cf2'
const value = '12345'
Expand All @@ -13,8 +13,8 @@ describe('transferFrom.spec.ts', () => {
transferFrom: jest
.fn()
// eslint-disable-next-line @typescript-eslint/no-unused-vars
.mockImplementation(async (from: string, to: string, value: number) =>
stubbedSendTx()
.mockImplementation(
async (from: string, to: string, value: number) => success
),
}

Expand Down
6 changes: 3 additions & 3 deletions lib/common/erc20/transferFrom.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
FallbackableOverrides,
MutationOption,
} from '../utils/execute'
import { T } from 'ramda'
import { TransactionResponse } from '@ethersproject/abstract-provider'

export type CreateTransferFromCaller = (
contract: ethers.Contract
Expand All @@ -13,7 +13,7 @@ export type CreateTransferFromCaller = (
to: string,
value: string,
overrides?: FallbackableOverrides
) => Promise<boolean>
) => Promise<TransactionResponse>

export const createTransferFromCaller: CreateTransferFromCaller =
(contract: ethers.Contract) =>
Expand All @@ -29,4 +29,4 @@ export const createTransferFromCaller: CreateTransferFromCaller =
mutation: true,
args: [from, to, value],
overrides,
}).then(T)
})
8 changes: 3 additions & 5 deletions lib/ethereum/dev/deposit.spec.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,18 @@
import { createDepositCaller } from './deposit'
import { stubbedSendTx } from '../../common/utils/for-test'
import { stubTransactionResposeFactory } from '../../common/utils/for-test'

describe('deposit.spec.ts', () => {
describe('createDepositCaller', () => {
it('call success', async () => {
const success = true
const success = stubTransactionResposeFactory({})
const to = '0x0472ec0185ebb8202f3d4ddb0226998889663cf2'
const value = '12345'

const devContract = {
deposit: jest
.fn()
// eslint-disable-next-line @typescript-eslint/no-unused-vars
.mockImplementation(async (to: string, value: number) =>
stubbedSendTx()
),
.mockImplementation(async (to: string, value: number) => success),
}

const expected = success
Expand Down
6 changes: 3 additions & 3 deletions lib/ethereum/dev/deposit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@ import {
MutationOption,
FallbackableOverrides,
} from '../../common/utils/execute'
import { T } from 'ramda'
import { TransactionResponse } from '@ethersproject/abstract-provider'

export type CreateDepositCaller = (
contract: ethers.Contract
) => (
to: string,
value: string,
overrides?: FallbackableOverrides
) => Promise<boolean>
) => Promise<TransactionResponse>

export const createDepositCaller: CreateDepositCaller =
(contract: ethers.Contract) =>
Expand All @@ -23,4 +23,4 @@ export const createDepositCaller: CreateDepositCaller =
args: [to, value],
mutation: true,
overrides,
}).then(T)
})
9 changes: 5 additions & 4 deletions lib/ethereum/dev/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,27 @@ import { createDecimalsCaller } from '../../common/erc20/decimals'
import { createAllowanceCaller } from '../../common/erc20/allowance'
import { createDepositCaller } from './deposit'
import { FallbackableOverrides } from '../../common/utils/execute'
import { TransactionResponse } from '@ethersproject/abstract-provider'

export type DevContract = {
readonly totalSupply: () => Promise<string>
readonly balanceOf: (address: string) => Promise<string>
readonly transfer: (to: string, value: string) => Promise<boolean>
readonly transfer: (to: string, value: string) => Promise<TransactionResponse>
readonly allowance: (from: string, to: string) => Promise<string>
readonly approve: (to: string, value: string) => Promise<boolean>
readonly approve: (to: string, value: string) => Promise<TransactionResponse>
readonly transferFrom: (
from: string,
to: string,
value: string
) => Promise<boolean>
) => Promise<TransactionResponse>
readonly name: () => Promise<string>
readonly symbol: () => Promise<string>
readonly decimals: () => Promise<string>
readonly deposit: (
to: string,
value: string,
overrides?: FallbackableOverrides
) => Promise<boolean>
) => Promise<TransactionResponse>
}

export const createDevContract =
Expand Down
8 changes: 5 additions & 3 deletions lib/ethereum/lockup/depositToPosition.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import { createDepositToPositionCaller } from './depositToPosition'
import { stubbedSendTx } from '../../common/utils/for-test'
import { stubTransactionResposeFactory } from '../../common/utils/for-test'

describe('depositToPosition.spec.ts', () => {
describe('createDepositToPositionCaller', () => {
it('call success', async () => {
const expected = true
const expected = stubTransactionResposeFactory({})
const lockupContract = {
depositToPosition: jest.fn().mockImplementation(stubbedSendTx),
depositToPosition: jest
.fn()
.mockImplementation(() => Promise.resolve(expected)),
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
6 changes: 3 additions & 3 deletions lib/ethereum/lockup/depositToPosition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import {
FallbackableOverrides,
MutationOption,
} from '../../common/utils/execute'
import { T } from 'ramda'
import { TransactionResponse } from '@ethersproject/abstract-provider'

export type CreateDepositToPositionCaller = (
contract: ethers.Contract
) => (
positionTokenId: string,
amount: string,
overrides?: FallbackableOverrides
) => Promise<boolean>
) => Promise<TransactionResponse>

export const createDepositToPositionCaller: CreateDepositToPositionCaller =
(contract: ethers.Contract) =>
Expand All @@ -28,4 +28,4 @@ export const createDepositToPositionCaller: CreateDepositToPositionCaller =
mutation: true,
args: [positionTokenId, amount],
overrides,
}).then(T)
})
8 changes: 4 additions & 4 deletions lib/ethereum/lockup/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@ export type LockupContract = {
positionTokenId: string,
amount: string,
overrides?: FallbackableOverrides
) => Promise<boolean>
) => Promise<TransactionResponse>
readonly withdraw: (
propertyAddress: string,
amount: string,
overrides?: FallbackableOverrides
) => Promise<boolean>
) => Promise<TransactionResponse>
readonly calculateWithdrawableInterestAmountByPosition: (
positionTokenId: string
) => Promise<string>
Expand Down Expand Up @@ -67,11 +67,11 @@ export type LockupContract = {
positionTokenId: string,
amount: string,
overrides?: FallbackableOverrides
) => Promise<boolean>
) => Promise<TransactionResponse>
readonly migrateToSTokens: (
positionTokenId: string,
overrides?: FallbackableOverrides
) => Promise<boolean>
) => Promise<TransactionResponse>
}

export const createLockupContract =
Expand Down
6 changes: 3 additions & 3 deletions lib/ethereum/lockup/migrateToSTokens.spec.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { createMigrateToSTokensCaller } from './migrateToSTokens'
import { stubbedSendTx } from '../../common/utils/for-test'
import { stubTransactionResposeFactory } from '../../common/utils/for-test'

describe('migrateToSTokens.spec.ts', () => {
describe('createMigrateToSTokensCaller', () => {
it('call success', async () => {
const expected = true
const expected = stubTransactionResposeFactory({})
const lockupContract = {
migrateToSTokens: jest.fn().mockImplementation(stubbedSendTx),
migrateToSTokens: jest.fn().mockImplementation(()=>Promise.resolve(expected)),
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
6 changes: 3 additions & 3 deletions lib/ethereum/lockup/migrateToSTokens.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import {
FallbackableOverrides,
MutationOption,
} from '../../common/utils/execute'
import { T } from 'ramda'
import { TransactionResponse } from '@ethersproject/abstract-provider'

export type CreateMigrateToSTokensCaller = (
contract: ethers.Contract
) => (
propertyAddress: string,
overrides?: FallbackableOverrides
) => Promise<boolean>
) => Promise<TransactionResponse>

export const createMigrateToSTokensCaller: CreateMigrateToSTokensCaller =
(contract: ethers.Contract) =>
Expand All @@ -23,4 +23,4 @@ export const createMigrateToSTokensCaller: CreateMigrateToSTokensCaller =
mutation: true,
args: [propertyAddress],
overrides,
}).then(T)
})
6 changes: 3 additions & 3 deletions lib/ethereum/lockup/withdraw.spec.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { createWithdrawCaller } from './withdraw'
import { stubbedSendTx } from '../../common/utils/for-test'
import { stubTransactionResposeFactory } from '../../common/utils/for-test'

describe('withdraw.spec.ts', () => {
describe('createWithdrawCaller', () => {
it('call success', async () => {
const expected = true
const expected = stubTransactionResposeFactory({})
const lockupContract = {
withdraw: jest
.fn()
// eslint-disable-next-line @typescript-eslint/no-unused-vars
.mockImplementation(async (property: string) => stubbedSendTx()),
.mockImplementation(async (property: string) => expected),
}

// eslint-disable-next-line @typescript-eslint/no-explicit-any
Expand Down
Loading

0 comments on commit 3ba050b

Please sign in to comment.