How to use the ethereum-waffle.getWallets function in ethereum-waffle

To help you get started, we’ve selected a few ethereum-waffle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Amxx / KitsuneWallet-ERC1836 / examples / 000_deploy-and-upgrade.js View on Github external
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 ------------------------------
	let proxy = null;
github Amxx / KitsuneWallet-ERC1836 / kitsune-sdk / examples / 000_deploy-and-upgrade.js View on Github external
(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;
github Amxx / KitsuneWallet-ERC1836 / test / fixtures / testInitialize.js View on Github external
describe('Initialize', async () => {

		const [ wallet, relayer, user1, user2, user3 ] = getWallets(sdk.provider);

		it('Verify proxy initialization', async () => {
			expect(await proxy.owner()).to.eq(proxy.address);
			expect(await proxy.master()).to.eq((await sdk.contracts.getMasterInstance(name)).address);
			expect(await proxy.getManagementThreshold()).to.eq(1);
			expect(await proxy.getActionThreshold()).to.eq(1);
		});

		it('reintrance protection', async () => {
			await expect(proxy.connect(user1).initialize(
				[
					sdk.utils.addrToKey(user1.address),
				],
				[
					'0x0000000000000000000000000000000000000000000000000000000000000007',
				],
github Amxx / KitsuneWallet-ERC1836 / test / fixtures / testKeyManagement.js View on Github external
describe('Key Management', async () => {

		const [ wallet, relayer, user1, user2, user3 ] = getWallets(sdk.provider);
		const dest = ethers.utils.getAddress(ethers.utils.hexlify(ethers.utils.randomBytes(20)));

		it('getKey', async () => {
			expect(await proxy.functions['getKey(bytes32)'](sdk.utils.addrToKey(user1.address))).to.be.eq('0x0000000000000000000000000000000000000000000000000000000000000007');
			expect(await proxy.functions['getKey(bytes32)'](sdk.utils.addrToKey(user2.address))).to.be.eq('0x0000000000000000000000000000000000000000000000000000000000000000');
			expect(await proxy.functions['getKey(address)'](                    user1.address )).to.be.eq('0x0000000000000000000000000000000000000000000000000000000000000007');
			expect(await proxy.functions['getKey(address)'](                    user2.address )).to.be.eq('0x0000000000000000000000000000000000000000000000000000000000000000');
		});

		it('keyHasPurpose', async () => {
			expect(await proxy.functions['keyHasPurpose(bytes32,bytes32)'](sdk.utils.addrToKey(user1.address), '0x0000000000000000000000000000000000000000000000000000000000000001')).to.be.eq(true);
			expect(await proxy.functions['keyHasPurpose(bytes32,bytes32)'](sdk.utils.addrToKey(user1.address), '0x0000000000000000000000000000000000000000000000000000000000000002')).to.be.eq(true);
			expect(await proxy.functions['keyHasPurpose(bytes32,bytes32)'](sdk.utils.addrToKey(user1.address), '0x0000000000000000000000000000000000000000000000000000000000000004')).to.be.eq(true);
			expect(await proxy.functions['keyHasPurpose(bytes32,bytes32)'](sdk.utils.addrToKey(user1.address), '0x0000000000000000000000000000000000000000000000000000000000000008')).to.be.eq(false);
			expect(await proxy.functions['keyHasPurpose(bytes32,bytes32)'](sdk.utils.addrToKey(user1.address), '0x0000000000000000000000000000000000000000000000000000000000000007')).to.be.eq(true);
			expect(await proxy.functions['keyHasPurpose(bytes32,bytes32)'](sdk.utils.addrToKey(user1.address), '0x0000000000000000000000000000000000000000000000000000000000000009')).to.be.eq(false);
github EthWorks / Doppelganger / test / integrations / direct.ts View on Github external
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);
  });
});
github Amxx / KitsuneWallet-ERC1836 / test / fixtures / testOutOfOrder.js View on Github external
describe('testOutOfOrder', async () => {

		const [ wallet, relayer, user1, user2, user3 ] = getWallets(sdk.provider);
		const dest = ethers.utils.getAddress(ethers.utils.hexlify(ethers.utils.randomBytes(20)));

		it('valid nonce', async () => {
			expect(await proxy.nonce()).to.be.eq(0);
			await expect(sdk.multisig.execute(
				proxy,
				[ user1 ],
				{ to: dest, nonce: 1 },
				{ options: { gasLimit: 1000000 } },
			)).to.emit(proxy, 'CallSuccess').withArgs(dest);
			expect(await proxy.nonce()).to.be.eq(1);
		});

		it('invalid nonce', async () => {
			expect(await proxy.nonce()).to.be.eq(0);
			await expect(sdk.multisig.execute(
github EthWorks / Doppelganger / test / integrations / proxied.ts View on Github external
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],
    );
github Amxx / KitsuneWallet-ERC1836 / test / wallets / WalletOwnable.js View on Github external
describe('WalletOwnable', () => {

	const provider = createMockProvider();
	const [ wallet, relayer, user1, user2, user3 ] = getWallets(provider);
	const sdk = new SDK(provider, relayer);

	before(async () => {
		walletContract = await sdk.contracts.getMasterInstance("WalletOwnable", { allowDeploy: true });
		targetContract = await deployContract(wallet, Target, []);
		dest = ethers.utils.getAddress(ethers.utils.hexlify(ethers.utils.randomBytes(20)));
	});

	beforeEach(async () => {
		proxy = await sdk.contracts.deployProxy("WalletOwnable", [ user1.address ]);

		await wallet.sendTransaction({to: proxy.address, value: eth(1.0)});
	});

	it ("Verify proxy initialization", async () => {
		expect(await proxy.owner()).to.eq(user1.address);
github TovarishFin / crypto-weddings-contracts / test / helpers / general.js View on Github external
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 })
  }
github Amxx / KitsuneWallet-ERC1836 / kitsune-sdk / examples / 100_deploy-and-upgrade.ts View on Github external
(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,
		"WalletMultisig",

ethereum-waffle

Sweeter, faster and simpler than truffle.

MIT
Latest version published 2 years ago

Package Health Score

53 / 100
Full package analysis