-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch '4.x' into ok/7017-Research-Snyk-Advisor-score-to-make-i…
…mprovements
- Loading branch information
Showing
43 changed files
with
2,556 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
42 changes: 42 additions & 0 deletions
42
packages/web3-rpc-methods/test/unit/eth_rpc_methods/get_uncle_by_block_number.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
This file is part of web3.js. | ||
web3.js is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
web3.js is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with web3.js. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { Web3RequestManager } from 'web3-core'; | ||
import { ethRpcMethods } from '../../../src/index'; | ||
|
||
jest.mock('web3-validator'); | ||
|
||
describe('getUncleByBlockNumberAndIndex', () => { | ||
let requestManagerSendSpy: jest.Mock; | ||
let requestManager: Web3RequestManager; | ||
|
||
beforeAll(() => { | ||
requestManager = new Web3RequestManager('http://127.0.0.1:8545'); | ||
requestManagerSendSpy = jest.fn(); | ||
requestManager.send = requestManagerSendSpy; | ||
}); | ||
|
||
it('should call requestManager.send with eth_getUncleByBlockNumberAndIndex method', async () => { | ||
await ethRpcMethods.getUncleByBlockNumberAndIndex(requestManager, 0, '1' ); | ||
expect(requestManagerSendSpy).toHaveBeenCalledWith({ | ||
method: 'eth_getUncleByBlockNumberAndIndex', | ||
params: [0,'1'], | ||
}); | ||
}, | ||
); | ||
|
||
}); |
145 changes: 145 additions & 0 deletions
145
packages/web3-rpc-methods/test/unit/personal_rpc_methods/eth_personal.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
/* | ||
This file is part of web3.js. | ||
web3.js is free software: you can redistribute it and/or modify | ||
it under the terms of the GNU Lesser General Public License as published by | ||
the Free Software Foundation, either version 3 of the License, or | ||
(at your option) any later version. | ||
web3.js is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU Lesser General Public License for more details. | ||
You should have received a copy of the GNU Lesser General Public License | ||
along with web3.js. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
import { Web3RequestManager } from 'web3-core'; | ||
import { EthPersonalAPI } from 'web3-types'; | ||
import { personalRpcMethods } from '../../../src/index'; | ||
|
||
describe('Eth Personal', () => { | ||
let requestManagerSendSpy: jest.Mock; | ||
let requestManager: Web3RequestManager<EthPersonalAPI>; | ||
|
||
beforeAll(() => { | ||
requestManager = new Web3RequestManager<EthPersonalAPI>('http://127.0.0.1:8545'); | ||
requestManagerSendSpy = jest.fn(); | ||
requestManager.send = requestManagerSendSpy; | ||
}); | ||
|
||
it('should call requestManager.send with personal_listAccounts method', async () => { | ||
await personalRpcMethods.getAccounts(requestManager); | ||
expect(requestManagerSendSpy).toHaveBeenCalledWith({ | ||
method: 'personal_listAccounts', | ||
params: [], | ||
}); | ||
}); | ||
|
||
it('should call requestManager.send with personal_newAccount method', async () => { | ||
const pass = "ABC123"; | ||
await personalRpcMethods.newAccount(requestManager, pass); | ||
expect(requestManagerSendSpy).toHaveBeenCalledWith({ | ||
method: 'personal_newAccount', | ||
params: [pass], | ||
}); | ||
}); | ||
|
||
it('should call requestManager.send with personal_unlockAccount method', async () => { | ||
const pass = "ABC123"; | ||
const address = "0x4106486FB42F3Abf07CC07ef5DEE38f60319e789"; | ||
const duration = 100; | ||
await personalRpcMethods.unlockAccount(requestManager, address, pass, duration); | ||
|
||
expect(requestManagerSendSpy).toHaveBeenCalledWith({ | ||
method: 'personal_unlockAccount', | ||
params: [address, pass, duration], | ||
}); | ||
}); | ||
|
||
it('should call requestManager.send with personal_lockAccount method', async () => { | ||
const address = "0x4106486FB42F3Abf07CC07ef5DEE38f60319e789"; | ||
|
||
await personalRpcMethods.lockAccount(requestManager, address ); | ||
|
||
expect(requestManagerSendSpy).toHaveBeenCalledWith({ | ||
method: 'personal_lockAccount', | ||
params: [address], | ||
}); | ||
}); | ||
|
||
it('should call requestManager.send with personal_importRawKey method', async () => { | ||
const passPhrase = "123456"; | ||
const keyData = "abe40cb08850da918ee951b237fa87946499b2d8643e4aa12b0610b050c731f6"; | ||
await personalRpcMethods.importRawKey(requestManager, keyData, passPhrase ); | ||
|
||
expect(requestManagerSendSpy).toHaveBeenCalledWith({ | ||
method: 'personal_importRawKey', | ||
params: [keyData,passPhrase], | ||
}); | ||
}); | ||
|
||
it('should call requestManager.send with personal_sendTransaction method', async () => { | ||
const passPhrase = "123456"; | ||
const tx = { | ||
from: "0x0d4aa485ecbc499c70860feb7e5aaeaf5fd8172e", | ||
gasPrice: "20000", | ||
gas: "21000", | ||
to: "0x4106486FB42F3Abf07CC07ef5DEE38f60319e789", | ||
value: "1000000", | ||
data: "", | ||
nonce: 0, | ||
}; | ||
await personalRpcMethods.sendTransaction(requestManager, tx, passPhrase ); | ||
|
||
expect(requestManagerSendSpy).toHaveBeenCalledWith({ | ||
method: 'personal_sendTransaction', | ||
params: [tx,passPhrase], | ||
}); | ||
}); | ||
|
||
it('should call requestManager.send with personal_signTransaction method', async () => { | ||
const passPhrase = "123456"; | ||
const tx = { | ||
from: "0x0d4aa485ecbc499c70860feb7e5aaeaf5fd8172e", | ||
gasPrice: "20000", | ||
gas: "21000", | ||
to: "0x4106486FB42F3Abf07CC07ef5DEE38f60319e789", | ||
value: "1000000", | ||
data: "", | ||
nonce: 0, | ||
}; | ||
await personalRpcMethods.signTransaction(requestManager, tx, passPhrase ); | ||
|
||
expect(requestManagerSendSpy).toHaveBeenCalledWith({ | ||
method: 'personal_signTransaction', | ||
params: [tx,passPhrase], | ||
}); | ||
}); | ||
|
||
it('should call requestManager.send with personal_sign method', async () => { | ||
const data = "Hello world"; | ||
const address = "0x0D4Aa485ECbC499c70860fEb7e5AaeAf5fd8172E"; | ||
const pass = "123456"; | ||
|
||
await personalRpcMethods.sign(requestManager, data,address,pass); | ||
|
||
expect(requestManagerSendSpy).toHaveBeenCalledWith({ | ||
method: 'personal_sign', | ||
params: [ data,address,pass], | ||
}); | ||
}); | ||
|
||
it('should call requestManager.send with personal_ecRecover method', async () => { | ||
const data = "Hello world"; | ||
const signature = "0x5d21d01b3198ac34d0585a9d76c4d1c8123e5e06746c8962318a1c08ffb207596e6fce4a6f377b7c0fc98c5f646cd73438c80e8a1a95cbec55a84c2889dca0301b"; | ||
|
||
await personalRpcMethods.ecRecover(requestManager,data, signature); | ||
|
||
expect(requestManagerSendSpy).toHaveBeenCalledWith({ | ||
method: 'personal_ecRecover', | ||
params: [ data, signature], | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../templates/.eslintignore.tmpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module.exports = { | ||
extends: '../../.eslintrc.js', | ||
parserOptions: { | ||
project: './tsconfig.esm.json', | ||
tsconfigRootDir: __dirname, | ||
}, | ||
}; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../templates/.npmignore.tmpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../templates/.npmrc.tmpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../templates/.prettierignore.tmpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../../templates/.prettierrc.json.tmpl |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# Changelog | ||
|
||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
<!-- EXAMPLE | ||
## [1.0.0] | ||
### Added | ||
- I've added feature XY (#1000) | ||
### Changed | ||
- I've cleaned up XY (#1000) | ||
### Deprecated | ||
- I've deprecated XY (#1000) | ||
### Removed | ||
- I've removed XY (#1000) | ||
### Fixed | ||
- I've fixed XY (#1000) | ||
### Security | ||
- I've improved the security in XY (#1000) | ||
--> | ||
|
||
## [Unreleased] |
Oops, something went wrong.