Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update web3 module to last one #97

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,17 @@
},
"dependencies": {
"@ethersproject/bignumber": "^5.1.1",
"@metamask/eth-sig-util": "^5.0.2",
"@metamask/eth-sig-util": "^7.0.1",
"bn.js": "^5.2.1",
"web3": "^1.8.1",
"ws": "^8.12.1",
"tslib": "^2.2.0"
"tslib": "^2.2.0",
"web3": "^4.8.0",
"ws": "^8.12.1"
},
"devDependencies": {
"@babel/core": "^7.13.16",
"@babel/preset-env": "^7.13.15",
"@babel/preset-typescript": "^7.13.0",
"@types/bn.js": "^5.1.5",
"@types/jest": "^26.0.22",
"@types/prompts": "^2.0.12",
"@types/ws": "^8.5.4",
Expand Down Expand Up @@ -76,7 +77,7 @@
]
},
"volta": {
"node": "16.19.0",
"node": "18.16.0",
"yarn": "1.22.17"
}
}
5 changes: 2 additions & 3 deletions src/connector/blockchain/web3-provider-connector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,14 @@ export class Web3ProviderConnector implements BlockchainProviderConnector {
walletAddress: string,
typedData: EIP712TypedData
): Promise<string> {
const extendedWeb3: ExtendedWeb3 = this.web3Provider.extend({
const extendedWeb3 = this.web3Provider.extend({
methods: [
{
name: 'signTypedDataV4',
call: 'eth_signTypedData_v4',
params: 2
}
]
})
}) as ExtendedWeb3

return extendedWeb3.signTypedDataV4(
walletAddress,
Expand Down
5 changes: 4 additions & 1 deletion src/connector/blockchain/web3-provider.connector.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
VerifyingContract
} from '../../limit-order'
import {Web3ProviderConnector} from './web3-provider-connector'
import {RegisteredSubscription} from 'web3-eth'

describe('Web3 provider connector', () => {
let web3Provider: Web3
Expand Down Expand Up @@ -60,7 +61,9 @@ describe('Web3 provider connector', () => {
signTypedDataV4: jest.fn()
}

when(web3Provider.extend(anything())).thenReturn(extendedWeb3)
when(web3Provider.extend(anything())).thenReturn(
extendedWeb3 as unknown as Web3<RegisteredSubscription>
)

await web3ProviderConnector.signTypedData(walletAddress, typedData)

Expand Down
2 changes: 1 addition & 1 deletion src/nonce-manager/nonce-manager.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ describe('Nonce Manager', () => {
}
})()

it('should get nonce', async () => {
it.only('should get nonce', async () => {
const nonceManager = NonceManager.new({provider})
const nonce = await nonceManager.getNonce(
'0xfb3c7eb936cAA12B5A884d612393969A557d4307'
Expand Down
8 changes: 6 additions & 2 deletions src/nonce-manager/utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import abiCoder from 'web3-eth-abi'
import {decodeParameter} from 'web3-eth-abi'
import {NONCE_SELECTOR} from './constants'
import {add0x} from '../utils'

Expand All @@ -7,5 +7,9 @@ export function encodeNonce(address: string): string {
}

export function decodeNonce(nonceHex: string): string {
return abiCoder.decodeParameter('uint256', nonceHex).toString()
return (
decodeParameter('uint256', nonceHex) as {
toString: () => string
}
).toString()
}
Loading
Loading