Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(async () => {
const provider = createMockProvider();
const [ relayer, user1, user2, user3 ] = getWallets(provider);
await provider.ready;
const sdk = new SDK(provider, relayer);
// ------------------------ Check master deployments ------------------------
// for (let master of Object.keys(sdk.contracts.ABIS).filter(name => name !== "Proxy"))
// {
// let instance = await sdk.contracts.getMasterInstance(master);
// console.log(`${master} is available on chain '${name}' (${chainId}).`)
// console.log(`→ ${instance['address']}`);
// console.log(`---`);
// }
// ------------------------------ create proxy ------------------------------
let proxy = null;
const { ethers } = require('ethers');
const { createMockProvider, getWallets, solidity} = require('ethereum-waffle');
const { Sdk } = require('../sdk/sdk.js');
ethers.errors.setLogLevel('error');
const provider = createMockProvider();
const [ relayer, user1, user2, user3 ] = getWallets(provider);
provider.ready.then(async () => {
const sdk = new Sdk(provider, relayer);
// ------------------------ Check master deployments ------------------------
// for (let master of Object.keys(sdk.contracts.ABIS).filter(name => name !== "Proxy"))
// {
// let instance = await sdk.contracts.getMasterInstance(master);
// console.log(`${master} is available on chain '${name}' (${chainId}).`)
// console.log(`→ ${instance['address']}`);
// console.log(`---`);
// }
// ------------------------------ create proxy ------------------------------
describe('Doppelganger - Contract', () => {
const provider = createMockProvider();
const [wallet] = getWallets(provider);
let contract: Contract;
beforeEach(async () => {
contract = await deployContract(wallet, DoppelgangerContract);
});
describe('mocking mechanism', () => {
let pretender: Contract;
const readSignature = '0x57de26a4';
beforeEach(async () => {
pretender = new Contract(contract.address, Counter.interface, wallet);
});
it('returns preprogrammed return values for mocked functions', async () => {
describe('Doppelganger - Integration (called by other contract)', () => {
const provider = createMockProvider();
const [wallet] = getWallets(provider);
it('mocking mechanism works', async () => {
const doppelganger = new Doppelganger(Counter.interface);
await doppelganger.deploy(wallet);
const capContract = await deployContract(
wallet,
{
abi: Cap.interface,
evm: {
bytecode: {
object: Cap.bytecode,
},
},
},
[doppelganger.address],
describe('Doppelganger - Integration (called directly)', () => {
const provider = createMockProvider();
const [wallet] = getWallets(provider);
it('mocking mechanism works', async () => {
const doppelganger = new Doppelganger(Counter.interface);
await doppelganger.deploy(wallet);
await doppelganger.read.returns(45291);
const contract = doppelganger.pretendedContract(wallet);
const ret = await expect(contract.read()).to.be.eventually.fulfilled;
expect(ret.toNumber()).to.be.equal(45291);
});
});
const setupContext = async noInit => {
const provider = createMockProvider()
const wallets = getWallets(provider)
const [owner, partner1, partner2, weddingStub, other] = wallets
const wngMaster = await deployContract(owner, Wedding)
const wmrMaster = await deployContract(owner, WeddingManager)
const wmrMasterStub = await deployContract(owner, WeddingManagerStub)
const wngEmitterStub = await deployContract(owner, WeddingEventEmitterStub)
const wmrProxy = await deployContract(owner, UpgradeableProxy, [
wmrMaster.address
])
const wmr = new Contract(wmrProxy.address, WeddingManager.abi, owner)
if (!noInit) {
wmr.initialize(wngMaster.address, { gasLimit })
}
describe('Wallet', () => {
const provider = createMockProvider();
const [ wallet, relayer, user1, user2, user3 ] = getWallets(provider);
const sdk = new SDK(provider, relayer);
before(async () => {
await sdk.contracts.getMasterInstance("WalletMultisigRefund", { allowDeploy: true });
targetContract = await deployContract(wallet, Target, []);
tokenContract = await deployContract(wallet, Token, []);
});
beforeEach(async () => {
proxy = await sdk.contracts.deployProxy(
"WalletMultisigRefund",
[
[
sdk.utils.addrToKey(user1.address),
],
describe('Wallet', () => {
const provider = createMockProvider();
const [ wallet, relayer, user1, user2, user3 ] = getWallets(provider);
const sdk = new SDK(provider, relayer);
before(async () => {
await sdk.contracts.getMasterInstance("WalletMultisigRefundOutOfOrder", { allowDeploy: true });
targetContract = await deployContract(wallet, Target, []);
tokenContract = await deployContract(wallet, Token, []);
});
beforeEach(async () => {
proxy = await sdk.contracts.deployProxy(
"WalletMultisigRefundOutOfOrder",
[
[
sdk.utils.addrToKey(user1.address),
],
describe('Wallet', () => {
const provider = createMockProvider();
const [ wallet, relayer, user1, user2, user3 ] = getWallets(provider);
const sdk = new SDK(provider, relayer);
before(async () => {
await sdk.contracts.getMasterInstance("WalletMultisig", { allowDeploy: true });
targetContract = await deployContract(wallet, Target, []);
});
beforeEach(async () => {
proxy = await sdk.contracts.deployProxy(
"WalletMultisig",
[
[
sdk.utils.addrToKey(user1.address),
],
[
(async () => {
const provider = createMockProvider();
const [ wallet ] = getWallets(provider);
var sdk = new SDK(provider, wallet)
var proxy = await sdk.contracts.deployProxy(
"WalletOwnable",
[ wallet.address ],
{ deploy: { enable: true } }
);
console.log(`proxy : ${proxy.address}` );
console.log(`implementation : ${await proxy.implementation()}`);
console.log(`owner : ${await proxy.owner()}` );
console.log("");
proxy = await sdk.contracts.upgradeProxy(
proxy,