Skip to content

Commit

Permalink
v0.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
10xSebastian committed Jun 17, 2021
1 parent e4ce76b commit 958e1e7
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 48 deletions.
29 changes: 13 additions & 16 deletions dist/cjs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@ let call = function ({ params, provider }) {
} else {
let data = callParams.data;
let methodSelector = data.split('000000000000000000000000')[0];
let contract = new ethers.ethers.Contract(
address,
mocks[address].abi,
provider,
);
let contract = new ethers.ethers.Contract(address, mocks[address].abi, provider);

let contractFunction = contract.interface.getFunction(methodSelector);
if (mocks[address][contractFunction.name]) {
Expand Down Expand Up @@ -110,11 +106,7 @@ let mockTransactions = function (configuration) {
};

let getContract = function ({ params, mock, provider }) {
return new ethers.ethers.Contract(
params.to,
mock.abi,
provider,
)
return new ethers.ethers.Contract(params.to, mock.abi, provider)
};

let getContractFunction = function ({ data, params, mock, provider }) {
Expand Down Expand Up @@ -244,7 +236,6 @@ let on = (eventName, callback) => {
};

let request = ({ request, provider }) => {

switch (request.method) {
case 'eth_chainId':
return Promise.resolve('0x1')
Expand Down Expand Up @@ -316,18 +307,24 @@ let Ethereum = ({ configuration, window, provider }) => {
mockTransactions(_optionalChain$1([configuration, 'optionalAccess', _2 => _2.transactions]));
resetEvents();

if(provider) {
if(provider.send) { provider.send = (method, params)=>request({ provider, request: { method: method, params: params } }); }
if(provider.sendTransaction) { provider.sendTransaction = (method, params)=>request({ provider, request: { method: method, params: params } }); }
if (provider) {
if (provider.send) {
provider.send = (method, params) =>
request({ provider, request: { method: method, params: params } });
}
if (provider.sendTransaction) {
provider.sendTransaction = (method, params) =>
request({ provider, request: { method: method, params: params } });
}
} else {
window.ethereum = {
...window.ethereum,
on,
request: (configuration) => {
return request({
request: configuration,
provider: new ethers.ethers.providers.Web3Provider(window.ethereum)
})
provider: new ethers.ethers.providers.Web3Provider(window.ethereum),
})
},
};
}
Expand Down
29 changes: 13 additions & 16 deletions dist/es/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,7 @@ let call = function ({ params, provider }) {
} else {
let data = callParams.data;
let methodSelector = data.split('000000000000000000000000')[0];
let contract = new ethers.Contract(
address,
mocks[address].abi,
provider,
);
let contract = new ethers.Contract(address, mocks[address].abi, provider);

let contractFunction = contract.interface.getFunction(methodSelector);
if (mocks[address][contractFunction.name]) {
Expand Down Expand Up @@ -106,11 +102,7 @@ let mockTransactions = function (configuration) {
};

let getContract = function ({ params, mock, provider }) {
return new ethers.Contract(
params.to,
mock.abi,
provider,
)
return new ethers.Contract(params.to, mock.abi, provider)
};

let getContractFunction = function ({ data, params, mock, provider }) {
Expand Down Expand Up @@ -240,7 +232,6 @@ let on = (eventName, callback) => {
};

let request = ({ request, provider }) => {

switch (request.method) {
case 'eth_chainId':
return Promise.resolve('0x1')
Expand Down Expand Up @@ -312,18 +303,24 @@ let Ethereum = ({ configuration, window, provider }) => {
mockTransactions(_optionalChain$1([configuration, 'optionalAccess', _2 => _2.transactions]));
resetEvents();

if(provider) {
if(provider.send) { provider.send = (method, params)=>request({ provider, request: { method: method, params: params } }); }
if(provider.sendTransaction) { provider.sendTransaction = (method, params)=>request({ provider, request: { method: method, params: params } }); }
if (provider) {
if (provider.send) {
provider.send = (method, params) =>
request({ provider, request: { method: method, params: params } });
}
if (provider.sendTransaction) {
provider.sendTransaction = (method, params) =>
request({ provider, request: { method: method, params: params } });
}
} else {
window.ethereum = {
...window.ethereum,
on,
request: (configuration) => {
return request({
request: configuration,
provider: new ethers.providers.Web3Provider(window.ethereum)
})
provider: new ethers.providers.Web3Provider(window.ethereum),
})
},
};
}
Expand Down
29 changes: 13 additions & 16 deletions dist/umd/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,7 @@
} else {
let data = callParams.data;
let methodSelector = data.split('000000000000000000000000')[0];
let contract = new ethers.ethers.Contract(
address,
mocks[address].abi,
provider,
);
let contract = new ethers.ethers.Contract(address, mocks[address].abi, provider);

let contractFunction = contract.interface.getFunction(methodSelector);
if (mocks[address][contractFunction.name]) {
Expand Down Expand Up @@ -110,11 +106,7 @@
};

let getContract = function ({ params, mock, provider }) {
return new ethers.ethers.Contract(
params.to,
mock.abi,
provider,
)
return new ethers.ethers.Contract(params.to, mock.abi, provider)
};

let getContractFunction = function ({ data, params, mock, provider }) {
Expand Down Expand Up @@ -244,7 +236,6 @@
};

let request = ({ request, provider }) => {

switch (request.method) {
case 'eth_chainId':
return Promise.resolve('0x1')
Expand Down Expand Up @@ -316,18 +307,24 @@
mockTransactions(_optionalChain$1([configuration, 'optionalAccess', _2 => _2.transactions]));
resetEvents();

if(provider) {
if(provider.send) { provider.send = (method, params)=>request({ provider, request: { method: method, params: params } }); }
if(provider.sendTransaction) { provider.sendTransaction = (method, params)=>request({ provider, request: { method: method, params: params } }); }
if (provider) {
if (provider.send) {
provider.send = (method, params) =>
request({ provider, request: { method: method, params: params } });
}
if (provider.sendTransaction) {
provider.sendTransaction = (method, params) =>
request({ provider, request: { method: method, params: params } });
}
} else {
window.ethereum = {
...window.ethereum,
on,
request: (configuration) => {
return request({
request: configuration,
provider: new ethers.ethers.providers.Web3Provider(window.ethereum)
})
provider: new ethers.ethers.providers.Web3Provider(window.ethereum),
})
},
};
}
Expand Down

0 comments on commit 958e1e7

Please sign in to comment.