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

Rename initProvider to initializeProvider #114

Merged
merged 2 commits into from
Nov 30, 2020
Merged
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
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ not suitable for out-of-the-box use with other wallets.
## Usage

```javascript
import { initProvider } from '@metamask/inpage-provider'
import { initializeProvider } from '@metamask/inpage-provider'

// Create a stream to a remote provider:
const metamaskStream = new LocalMessageDuplexStream({
Expand All @@ -20,7 +20,7 @@ const metamaskStream = new LocalMessageDuplexStream({
})

// this will initialize the provider and set it as window.ethereum
initProvider({
initializeProvider({
connectionStream: metamaskStream,
})

Expand Down
2 changes: 1 addition & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export class MetaMaskInpageProvider extends EventEmitter {
* Initializes a MetaMaskInpageProvider and (optionally) assigns it as window.ethereum.
* @returns The initialized provider (whether set or not).
*/
export function initProvider (
export function initializeProvider (
options: Pick<MetaMaskInpageProviderOptions, 'maxEventListeners' | 'shouldSendMetadata'> & {

/** A Node.js duplex stream. */
Expand Down
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const MetaMaskInpageProvider = require('./src/MetaMaskInpageProvider')
const { initProvider, setGlobalProvider } = require('./src/initProvider')
const { initializeProvider, setGlobalProvider } = require('./src/initializeProvider')

module.exports = {
MetaMaskInpageProvider,
initProvider,
initializeProvider,
setGlobalProvider,
}
4 changes: 2 additions & 2 deletions src/initProvider.js → src/initializeProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const MetaMaskInpageProvider = require('./MetaMaskInpageProvider')
* @param {boolean} options.shouldSetOnWindow - Whether the provider should be set as window.ethereum
* @returns {MetaMaskInpageProvider | Proxy} The initialized provider (whether set or not).
*/
function initProvider ({
function initializeProvider ({
connectionStream,
maxEventListeners = 100,
shouldSendMetadata = true,
Expand Down Expand Up @@ -44,6 +44,6 @@ function setGlobalProvider (providerInstance) {
}

module.exports = {
initProvider,
initializeProvider,
setGlobalProvider,
}
10 changes: 5 additions & 5 deletions test/MetaMaskInpageProvider.rpc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const MockDuplexStream = require('./mocks/DuplexStream')

const MOCK_ERROR_MESSAGE = 'Did you specify a mock return value?'

function initProvider () {
function initializeProvider () {
jest.useFakeTimers()
const mockStream = new MockDuplexStream()
const provider = new MetaMaskInpageProvider(mockStream)
Expand Down Expand Up @@ -35,7 +35,7 @@ describe('MetaMaskInpageProvider: RPC', () => {

beforeEach(() => {
resetRpcEngineResponseMock()
provider = initProvider()
provider = initializeProvider()
jest.spyOn(provider, '_handleAccountsChanged').mockImplementation()
jest.spyOn(provider._rpcEngine, 'handle').mockImplementation(
(_payload, cb) => cb(...mockRpcEngineResponse()),
Expand Down Expand Up @@ -245,7 +245,7 @@ describe('MetaMaskInpageProvider: RPC', () => {

beforeEach(() => {
resetRpcRequestResponseMock()
provider = initProvider()
provider = initializeProvider()
jest.spyOn(provider, '_rpcRequest').mockImplementation(
(_payload, cb, _isInternal) => cb(...mockRpcRequestResponse()),
)
Expand Down Expand Up @@ -354,7 +354,7 @@ describe('MetaMaskInpageProvider: RPC', () => {

beforeEach(() => {
resetRpcEngineResponseMock()
provider = initProvider()
provider = initializeProvider()
jest.spyOn(provider, '_handleAccountsChanged').mockImplementation()
jest.spyOn(provider._rpcEngine, 'handle').mockImplementation(
(_payload, cb) => cb(...mockRpcEngineResponse()),
Expand Down Expand Up @@ -473,7 +473,7 @@ describe('MetaMaskInpageProvider: RPC', () => {

beforeEach(() => {
resetRpcRequestResponseMock()
provider = initProvider()
provider = initializeProvider()
jest.spyOn(provider, '_rpcRequest').mockImplementation(
(_payload, cb, _isInternal) => cb(...mockRpcRequestResponse()),
)
Expand Down