Skip to content

Commit 1259e39

Browse files
committed
fix major type errors: test
1 parent 3852b6b commit 1259e39

File tree

35 files changed

+81
-92
lines changed

35 files changed

+81
-92
lines changed

lib/agent/fixtures/swap/index.spec.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,12 @@ describe('swap/index.ts', () => {
2525
it('check return object', () => {
2626
const host = 'localhost'
2727
const address = '0x0000000000000000000000000000000000000000'
28-
const provider = new ethers.providers.JsonRpcProvider(host)
28+
const provider = new ethers.JsonRpcProvider(host)
2929

3030
const expected: (address: string) => SwapContract = (address: string) => {
3131
const contract = new ethers.Contract(address, [...swapAbiV3], provider)
3232
return {
33-
getEstimatedDevForEth: createGetEstimatedDevForEthCaller(
34-
contract,
35-
),
33+
getEstimatedDevForEth: createGetEstimatedDevForEthCaller(contract),
3634
getEstimatedEthForDev: createGetEstimatedEthForDevCaller(contract),
3735
swapEthAndStakeDevCaller: createSwapEthAndStakeDevCaller(contract),
3836
swapEthAndStakeDevPolygonCaller:

lib/agent/fixtures/swap/swapEthAndStakeDev.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createSwapEthAndStakeDevCaller } from './swapEthAndStakeDev'
22
import { stubTransactionResposeFactory } from '../../../common/utils/for-test'
3-
import { ethers } from 'ethers'
3+
import { ethers, getDefaultProvider } from 'ethers'
44

55
describe('depositToProperty.spec.ts', () => {
66
describe('createDepositToPropertyCaller', () => {
@@ -16,12 +16,12 @@ describe('depositToProperty.spec.ts', () => {
1616
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1717
const caller = createSwapEthAndStakeDevCaller(swapContract as any)
1818

19-
const provider = await ethers.getDefaultProvider()
19+
const provider = getDefaultProvider(137)
2020
const block = await provider.getBlock('latest')
2121

2222
const result = await caller(
2323
'0x80a25ACDD0797dfCe02dA25e4a55A4a334EE51c5',
24-
block.timestamp + 300
24+
block?.timestamp ?? 0 + 300
2525
)
2626

2727
expect(result).toEqual(stubTx)
@@ -38,12 +38,12 @@ describe('depositToProperty.spec.ts', () => {
3838
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3939
const caller = createSwapEthAndStakeDevCaller(swapContract as any)
4040

41-
const provider = await ethers.getDefaultProvider()
41+
const provider = getDefaultProvider(137)
4242
const block = await provider.getBlock('latest')
4343

4444
const result = await caller(
4545
'0x80a25ACDD0797dfCe02dA25e4a55A4a334EE51c5',
46-
block.timestamp + 300
46+
block?.timestamp ?? 0 + 300
4747
).catch((err) => err)
4848

4949
expect(result).toEqual(error)

lib/agent/fixtures/swap/swapEthAndStakeDevPolygon.spec.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { createSwapEthAndStakeDevCaller } from './swapEthAndStakeDev'
22
import { stubTransactionResposeFactory } from '../../../common/utils/for-test'
3-
import { ethers } from 'ethers'
3+
import { ethers, getDefaultProvider } from 'ethers'
44

55
describe('depositToProperty.spec.ts', () => {
66
describe('createDepositToPropertyCaller', () => {
@@ -16,12 +16,12 @@ describe('depositToProperty.spec.ts', () => {
1616
// eslint-disable-next-line @typescript-eslint/no-explicit-any
1717
const caller = createSwapEthAndStakeDevCaller(swapContract as any)
1818

19-
const provider = await ethers.getDefaultProvider()
19+
const provider = getDefaultProvider(137)
2020
const block = await provider.getBlock('latest')
2121

2222
const result = await caller(
2323
'0x80a25ACDD0797dfCe02dA25e4a55A4a334EE51c5',
24-
block.timestamp + 300
24+
block?.timestamp ?? 0 + 300
2525
)
2626

2727
expect(result).toEqual(stubTx)
@@ -38,12 +38,12 @@ describe('depositToProperty.spec.ts', () => {
3838
// eslint-disable-next-line @typescript-eslint/no-explicit-any
3939
const caller = createSwapEthAndStakeDevCaller(swapContract as any)
4040

41-
const provider = await ethers.getDefaultProvider()
41+
const provider = getDefaultProvider(137)
4242
const block = await provider.getBlock('latest')
4343

4444
const result = await caller(
4545
'0x80a25ACDD0797dfCe02dA25e4a55A4a334EE51c5',
46-
block.timestamp + 300
46+
block?.timestamp ?? 0 + 300
4747
).catch((err) => err)
4848

4949
expect(result).toEqual(error)

lib/common/erc20/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('erc20/index.ts', () => {
4444
it('check return object', () => {
4545
const host = 'localhost'
4646
const address = '0x0000000000000000000000000000000000000000'
47-
const provider = new ethers.providers.JsonRpcProvider(host)
47+
const provider = new ethers.JsonRpcProvider(host)
4848
const expected: (address: string) => Erc20Contract = (
4949
address: string
5050
) => {

lib/common/utils/execute.spec.ts

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* eslint-disable @typescript-eslint/no-unused-vars */
2-
import { BigNumber, ethers, utils } from 'ethers'
2+
import { ethers, keccak256, toUtf8Bytes } from 'ethers'
33
import { execute } from './execute'
44

55
describe('execute.ts', () => {
@@ -115,15 +115,13 @@ describe('execute.ts', () => {
115115
const result = await execute({
116116
contract,
117117
method: 'foo',
118-
args: ['abc', utils.toUtf8Bytes('TEST')],
118+
args: ['abc', toUtf8Bytes('TEST')],
119119
mutation: false,
120120
})
121121
expect(result).toEqual('value')
122122
expect(fooStub.mock.calls.length).toEqual(1)
123123
expect(fooStub.mock.calls[0][0]).toEqual('abc')
124-
expect(fooStub.mock.calls[0][1]).toEqual(
125-
utils.keccak256(utils.toUtf8Bytes('TEST'))
126-
)
124+
expect(fooStub.mock.calls[0][1]).toEqual(keccak256(toUtf8Bytes('TEST')))
127125
})
128126
it("Execute the contract instance's `[passed overloaded method]()`.", async () => {
129127
const fooStub = jest.fn(async () => Promise.resolve(true))
@@ -195,7 +193,7 @@ describe('execute.ts', () => {
195193
})
196194
it('Returns string when the response is BigNumber', async () => {
197195
const contract = {
198-
foo: jest.fn(async () => Promise.resolve(BigNumber.from(123456789))),
196+
foo: jest.fn(async () => Promise.resolve(123456789n)),
199197
} as unknown as ethers.Contract
200198
const result = await execute({
201199
contract,
@@ -207,12 +205,7 @@ describe('execute.ts', () => {
207205
it('Returns array of string, number, boolean when the response included BigNumber', async () => {
208206
const contract = {
209207
foo: jest.fn(async () =>
210-
Promise.resolve([
211-
'value',
212-
123456789,
213-
false,
214-
BigNumber.from(123456789),
215-
])
208+
Promise.resolve(['value', 123456789, false, 123456789n])
216209
),
217210
} as unknown as ethers.Contract
218211
const result = await execute({
@@ -230,21 +223,21 @@ describe('execute.ts', () => {
230223
0: 'value1',
231224
1: 123456789,
232225
2: false,
233-
3: BigNumber.from(123456789),
226+
3: 123456789n,
234227
a: 'value',
235228
b: 123456789,
236229
c: false,
237-
d: BigNumber.from(123456789),
230+
d: 123456789n,
238231
},
239232
{
240233
0: 'value2',
241234
1: 1234567891,
242235
2: true,
243-
3: BigNumber.from(1234567891),
236+
3: 1234567891n,
244237
a: 'value2',
245238
b: 1234567891,
246239
c: true,
247-
d: BigNumber.from(1234567891),
240+
d: 1234567891n,
248241
},
249242
])
250243
),
@@ -284,11 +277,11 @@ describe('execute.ts', () => {
284277
0: 'value',
285278
1: 123456789,
286279
2: false,
287-
3: BigNumber.from(123456789),
280+
3: 123456789n,
288281
a: 'value',
289282
b: 123456789,
290283
c: false,
291-
d: BigNumber.from(123456789),
284+
d: 123456789n,
292285
})
293286
),
294287
} as unknown as ethers.Contract
@@ -312,7 +305,7 @@ describe('execute.ts', () => {
312305
const contract = {
313306
foo: jest.fn(async () =>
314307
Promise.resolve({
315-
data: BigNumber.from(123456789),
308+
data: 123456789n,
316309
})
317310
),
318311
} as unknown as ethers.Contract
@@ -322,7 +315,7 @@ describe('execute.ts', () => {
322315
mutation: true,
323316
})
324317
expect(result).toEqual({
325-
data: BigNumber.from(123456789),
318+
data: 123456789n,
326319
})
327320
})
328321
})

lib/ethereum/allocator/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('allocator/index.ts', () => {
1313
it('check return object', () => {
1414
const host = 'localhost'
1515
const address = 'address'
16-
const provider = new ethers.providers.JsonRpcProvider(host)
16+
const provider = new ethers.JsonRpcProvider(host)
1717
const expected: (address: string) => CreateAllocatorContract = (
1818
address: string
1919
) => {

lib/ethereum/contract.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ describe('contract.ts', () => {
2424
describe('createDevkitContract', () => {
2525
it('check return object', () => {
2626
const host = 'localhost'
27-
const provider = new ethers.providers.JsonRpcProvider(host)
27+
const provider = new ethers.JsonRpcProvider(host)
2828

2929
const expected: DevkitContract = {
3030
allocator: createAllocatorContract(provider),
@@ -53,7 +53,7 @@ describe('contract.ts', () => {
5353
describe('contractFactory', () => {
5454
it('check return object', () => {
5555
const host = 'localhost'
56-
const provider = new ethers.providers.JsonRpcProvider(host)
56+
const provider = new ethers.JsonRpcProvider(host)
5757

5858
const expected = createDevkitContract(provider)
5959
const result = contractFactory(provider)

lib/ethereum/dev/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ describe('dev/index.ts', () => {
4747
it('check return object', () => {
4848
const host = 'localhost'
4949
const address = '0x0000000000000000000000000000000000000000'
50-
const provider = new ethers.providers.JsonRpcProvider(host)
50+
const provider = new ethers.JsonRpcProvider(host)
5151
const expected: (address: string) => DevContract = (address: string) => {
5252
const contract = new ethers.Contract(address, [...devAbi], provider)
5353
return {

lib/ethereum/lockup/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ describe('lockup/index.ts', () => {
7777
it('check return object', () => {
7878
const host = 'localhost'
7979
const address = '0x0000000000000000000000000000000000000000'
80-
const provider = new ethers.providers.JsonRpcProvider(host)
80+
const provider = new ethers.JsonRpcProvider(host)
8181

8282
const expected: (address: string) => LockupContract = (
8383
address: string

lib/ethereum/market-behavior/index.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('getId/index.ts', () => {
1212
it('check return object', () => {
1313
const host = 'localhost'
1414
const address = '0x0000000000000000000000000000000000000000'
15-
const provider = new ethers.providers.JsonRpcProvider(host)
15+
const provider = new ethers.JsonRpcProvider(host)
1616

1717
const expected: (address: string) => CreateMarketBehaviorContract = (
1818
address: string

0 commit comments

Comments
 (0)